swad-core/swad_exam.c

1548 lines
62 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_exam.c: exam announcements
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
Copyright (C) 1999-2014
SWAD core (1999-2014):
Antonio Ca<EFBFBD>as Vargas
Photo processing (2006-2014):
Daniel J. Calandria Hern<EFBFBD>ndez
Chat (2009-2014):
Daniel J. Calandria Hern<EFBFBD>ndez
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include <linux/stddef.h> // For NULL
#include <stdio.h> // For sscanf, etc.
#include <stdlib.h> // For exit, system, malloc, calloc, free, etc.
#include <string.h> // For string functions
#include "swad_config.h"
#include "swad_database.h"
#include "swad_exam.h"
#include "swad_global.h"
2015-01-17 20:06:25 +01:00
#include "swad_logo.h"
2014-12-01 23:55:08 +01:00
#include "swad_notification.h"
#include "swad_parameter.h"
#include "swad_QR.h"
#include "swad_RSS.h"
2015-12-29 02:09:50 +01:00
#include "swad_social.h"
2014-12-01 23:55:08 +01:00
#include "swad_string.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private variables *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static long Exa_GetParamsExamAnnouncement (void);
static void Exa_AllocMemExamAnnouncement (void);
static void Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (long ExaCod,unsigned NumUsrsToBeNotifiedByEMail);
static void Exa_ListExamAnnouncementsEdit (void);
2015-11-13 01:27:44 +01:00
static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewExamAnnouncement);
2016-06-01 13:43:22 +02:00
static void Exa_PutIconToCreateNewExamAnnouncement (void);
static void Exa_PutButtonToCreateNewExamAnnouncement (void);
2014-12-01 23:55:08 +01:00
static long Exa_AddExamAnnouncementToDB (void);
static void Exa_ModifyExamAnnouncementInDB (long ExaCod);
static void Exa_GetDataExamAnnouncementFromDB (long ExaCod);
2015-11-13 01:27:44 +01:00
static void Exa_ShowExamAnnouncement (long ExaCod,Exa_TypeViewExamAnnouncement_t TypeViewExamAnnouncement);
2016-03-16 12:05:10 +01:00
static void Exa_PutIconsExamAnnouncement (void);
2016-06-01 19:34:44 +02:00
static void Exa_PutParamExaCodToEdit (void);
static long Exa_GetParamExaCod (void);
2015-12-13 19:55:52 +01:00
2014-12-01 23:55:08 +01:00
static void Exa_GetNotifContentExamAnnouncement (char **ContentStr);
/*****************************************************************************/
/********************** Form to edit an exam announcement ********************/
/*****************************************************************************/
void Exa_PutFrmEditAExamAnnouncement (void)
{
long ExaCod;
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get the code of the exam announcement *****/
ExaCod = Exa_GetParamsExamAnnouncement ();
2016-06-01 13:43:22 +02:00
if (ExaCod > 0) // -1 indicates that this is a new exam announcement
2014-12-01 23:55:08 +01:00
/***** Read exam announcement from the database *****/
Exa_GetDataExamAnnouncementFromDB (ExaCod);
/***** Show exam announcement *****/
Exa_ShowExamAnnouncement (ExaCod,Exa_FORM_VIEW);
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
/*****************************************************************************/
/**************** Get parameters of an exam announcement *********************/
/*****************************************************************************/
static long Exa_GetParamsExamAnnouncement (void)
{
char UnsignedStr[10+1];
long ExaCod;
/***** Get the code of the exam announcement *****/
2016-06-01 19:34:44 +02:00
ExaCod = Exa_GetParamExaCod ();
2014-12-01 23:55:08 +01:00
/***** Get the name of the course (it is allowed to be different from the official name of the course) *****/
2016-06-01 13:43:22 +02:00
Par_GetParToText ("CrsName",Gbl.ExamAnnouncements.ExaDat.CrsFullName,Cns_MAX_BYTES_STRING);
2014-12-01 23:55:08 +01:00
// If the parameter is not present or is empty, initialize the string to the full name of the current course
2016-06-01 13:43:22 +02:00
if (!Gbl.ExamAnnouncements.ExaDat.CrsFullName[0])
strcpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName);
2014-12-01 23:55:08 +01:00
/***** Get the year *****/
Par_GetParToText ("Year",UnsignedStr,10);
2016-06-01 13:43:22 +02:00
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.Year) != 1)
Gbl.ExamAnnouncements.ExaDat.Year = Gbl.CurrentCrs.Crs.Year;
if (Gbl.ExamAnnouncements.ExaDat.Year > Deg_MAX_YEARS_PER_DEGREE)
Gbl.ExamAnnouncements.ExaDat.Year = Gbl.CurrentCrs.Crs.Year;
2014-12-01 23:55:08 +01:00
/***** Get the type of exam announcement *****/
2016-06-01 13:43:22 +02:00
Par_GetParToText ("ExamSession",Gbl.ExamAnnouncements.ExaDat.Session,Cns_MAX_BYTES_STRING);
2014-12-01 23:55:08 +01:00
/***** Get the data of the exam *****/
2016-06-01 19:34:44 +02:00
Dat_GetDateFromForm ("ExamDay","ExamMonth","ExamYear",
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Day,
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Month,
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Year);
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.ExamDate.Day == 0 ||
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month == 0 ||
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year == 0)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day = Gbl.Now.Date.Day;
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month = Gbl.Now.Date.Month;
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year = Gbl.Now.Date.Year;
2014-12-01 23:55:08 +01:00
}
/***** Get the hour of the exam *****/
Par_GetParToText ("ExamHour",UnsignedStr,10);
2016-06-01 13:43:22 +02:00
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.StartTime.Hour) != 1)
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour = 0;
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour > 23)
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour = 0;
2014-12-01 23:55:08 +01:00
Par_GetParToText ("ExamMinute",UnsignedStr,10);
2016-06-01 13:43:22 +02:00
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.StartTime.Minute) != 1)
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute = 0;
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Minute > 59)
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute = 0;
2014-12-01 23:55:08 +01:00
/***** Get the duration of the exam *****/
Par_GetParToText ("DurationHour",UnsignedStr,10);
2016-06-01 13:43:22 +02:00
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.Duration.Hour) != 1)
Gbl.ExamAnnouncements.ExaDat.Duration.Hour = 0;
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour > 23)
Gbl.ExamAnnouncements.ExaDat.Duration.Hour = 0;
2014-12-01 23:55:08 +01:00
Par_GetParToText ("DurationMinute",UnsignedStr,10);
2016-06-01 13:43:22 +02:00
if (sscanf (UnsignedStr,"%u",&Gbl.ExamAnnouncements.ExaDat.Duration.Minute) != 1)
Gbl.ExamAnnouncements.ExaDat.Duration.Minute = 0;
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute > 59)
Gbl.ExamAnnouncements.ExaDat.Duration.Minute = 0;
2014-12-01 23:55:08 +01:00
/***** Get the place where the exam will happen *****/
2016-06-01 13:43:22 +02:00
Par_GetParToHTML ("Place",Gbl.ExamAnnouncements.ExaDat.Place,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the modality of exam *****/
2016-06-01 13:43:22 +02:00
Par_GetParToHTML ("ExamMode",Gbl.ExamAnnouncements.ExaDat.Mode,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the structure of exam *****/
2016-06-01 13:43:22 +02:00
Par_GetParToHTML ("Structure",Gbl.ExamAnnouncements.ExaDat.Structure,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the mandatory documentation *****/
2016-06-01 13:43:22 +02:00
Par_GetParToHTML ("DocRequired",Gbl.ExamAnnouncements.ExaDat.DocRequired,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the mandatory material *****/
2016-06-01 13:43:22 +02:00
Par_GetParToHTML ("MatRequired",Gbl.ExamAnnouncements.ExaDat.MatRequired,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the allowed material *****/
2016-06-01 13:43:22 +02:00
Par_GetParToHTML ("MatAllowed",Gbl.ExamAnnouncements.ExaDat.MatAllowed,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get other information *****/
2016-06-01 13:43:22 +02:00
Par_GetParToHTML ("OtherInfo",Gbl.ExamAnnouncements.ExaDat.OtherInfo,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
return ExaCod;
}
/*****************************************************************************/
/* Allocate memory for those parameters of an exam anno. with a lot of text **/
/*****************************************************************************/
static void Exa_AllocMemExamAnnouncement (void)
{
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.ExaDat.Place = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.ExaDat.Mode = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.ExaDat.Structure = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.ExaDat.DocRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.ExaDat.MatRequired = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.ExaDat.MatAllowed = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.ExaDat.OtherInfo = malloc (Cns_MAX_BYTES_TEXT+1)) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store exam announcement.");
}
/*****************************************************************************/
/* Free memory of those parameters of an exam announcem. with a lot of text **/
/*****************************************************************************/
void Exa_FreeMemExamAnnouncement (void)
{
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Place)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.ExaDat.Place);
Gbl.ExamAnnouncements.ExaDat.Place = NULL;
2014-12-01 23:55:08 +01:00
}
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Mode)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.ExaDat.Mode);
Gbl.ExamAnnouncements.ExaDat.Mode = NULL;
2014-12-01 23:55:08 +01:00
}
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Structure)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.ExaDat.Structure);
Gbl.ExamAnnouncements.ExaDat.Structure = NULL;
2014-12-01 23:55:08 +01:00
}
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.DocRequired)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.ExaDat.DocRequired);
Gbl.ExamAnnouncements.ExaDat.DocRequired = NULL;
2014-12-01 23:55:08 +01:00
}
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.MatRequired)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.ExaDat.MatRequired);
Gbl.ExamAnnouncements.ExaDat.MatRequired = NULL;
2014-12-01 23:55:08 +01:00
}
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.MatAllowed)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.ExaDat.MatAllowed);
Gbl.ExamAnnouncements.ExaDat.MatAllowed = NULL;
2014-12-01 23:55:08 +01:00
}
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.OtherInfo)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.ExaDat.OtherInfo);
Gbl.ExamAnnouncements.ExaDat.OtherInfo = NULL;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/************************ Receive an exam announcement ***********************/
/*****************************************************************************/
void Exa_ReceiveExamAnnouncement (void)
{
extern const char *Txt_Created_new_announcement_of_exam;
extern const char *Txt_The_announcement_of_exam_has_been_successfully_updated;
long ExaCod;
bool NewExamAnnouncement;
unsigned NumUsrsToBeNotifiedByEMail;
2016-01-25 11:43:14 +01:00
struct SocialPublishing SocPub;
2014-12-01 23:55:08 +01:00
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get parameters of the exam announcement *****/
ExaCod = Exa_GetParamsExamAnnouncement ();
NewExamAnnouncement = (ExaCod == -1L); // -1 indicates that it is a new exam announcement
/***** Add the exam announcement to the database and read it again from the database *****/
if (NewExamAnnouncement)
ExaCod = Exa_AddExamAnnouncementToDB ();
else
Exa_ModifyExamAnnouncementInDB (ExaCod);
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
/***** Show message *****/
Lay_ShowAlert (Lay_SUCCESS,NewExamAnnouncement ? Txt_Created_new_announcement_of_exam :
Txt_The_announcement_of_exam_has_been_successfully_updated);
2016-11-16 23:19:52 +01:00
/***** Notify by email about the new exam announcement *****/
2014-12-01 23:55:08 +01:00
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_EXAM_ANNOUNCEMENT,ExaCod)))
Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (ExaCod,NumUsrsToBeNotifiedByEMail);
Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail);
2015-12-31 14:25:28 +01:00
/***** Create a new social note about the new exam announcement *****/
2016-01-25 11:43:14 +01:00
Soc_StoreAndPublishSocialNote (Soc_NOTE_EXAM_ANNOUNCEMENT,ExaCod,&SocPub);
2015-12-29 02:09:50 +01:00
2014-12-01 23:55:08 +01:00
/***** Show exam announcement *****/
Exa_ListExamAnnouncementsEdit ();
/***** Update RSS of current course *****/
RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);
}
/*****************************************************************************/
/***** Update number of users notified in table of exam announcements ********/
/*****************************************************************************/
static void Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (long ExaCod,unsigned NumUsrsToBeNotifiedByEMail)
{
char Query[512];
/***** Update number of users notified *****/
sprintf (Query,"UPDATE exam_announcements SET NumNotif=NumNotif+'%u'"
" WHERE ExaCod='%ld'",
NumUsrsToBeNotifiedByEMail,ExaCod);
DB_QueryUPDATE (Query,"can not update the number of notifications of an exam announcement");
}
/*****************************************************************************/
/************************* Print an exam announcement ************************/
/*****************************************************************************/
void Exa_PrintExamAnnouncement (void)
{
long ExaCod;
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get the code of the exam announcement *****/
2016-06-01 19:34:44 +02:00
if ((ExaCod = Exa_GetParamExaCod ()) <= 0)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Read exam announcement from the database *****/
Exa_GetDataExamAnnouncementFromDB (ExaCod);
/***** Show exam announcement *****/
Exa_ShowExamAnnouncement (ExaCod,Exa_PRINT_VIEW);
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
/*****************************************************************************/
/************************ Remove an exam announcement ************************/
/*****************************************************************************/
void Exa_RemoveExamAnnouncement (void)
{
extern const char *Txt_Announcement_of_exam_removed;
char Query[1024];
long ExaCod;
/***** Get the code of the exam announcement *****/
2016-06-01 19:34:44 +02:00
if ((ExaCod = Exa_GetParamExaCod ()) <= 0)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Mark the exam announcement as deleted in the database *****/
sprintf (Query,"UPDATE exam_announcements SET Status='%u'"
" WHERE ExaCod='%ld' AND CrsCod='%ld'",
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT,ExaCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE (Query,"can not remove an exam announcement");
/***** Mark possible notifications as removed *****/
2016-01-04 01:56:28 +01:00
Ntf_MarkNotifAsRemoved (Ntf_EVENT_EXAM_ANNOUNCEMENT,ExaCod);
2014-12-01 23:55:08 +01:00
2016-01-03 19:34:40 +01:00
/***** Mark possible social note as unavailable *****/
Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NOTE_EXAM_ANNOUNCEMENT,ExaCod);
2014-12-01 23:55:08 +01:00
/***** Write message *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_Announcement_of_exam_removed);
/***** List again all the remaining exam announcements *****/
Exa_ListExamAnnouncementsEdit ();
/***** Update RSS of current course *****/
RSS_UpdateRSSFileForACrs (&Gbl.CurrentCrs.Crs);
}
/*****************************************************************************/
/*************** List all the exam announcements to see them *****************/
/*****************************************************************************/
void Exa_ListExamAnnouncementsSee (void)
{
2016-06-01 13:43:22 +02:00
/***** List all exam announcements *****/
2014-12-01 23:55:08 +01:00
Exa_ListExamAnnouncements (Exa_NORMAL_VIEW);
/***** Mark possible notifications as seen *****/
2016-01-04 01:56:28 +01:00
Ntf_MarkNotifAsSeen (Ntf_EVENT_EXAM_ANNOUNCEMENT,
2016-06-01 13:43:22 +02:00
-1L,Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********** List all the exam announcements to edit or remove them ***********/
/*****************************************************************************/
static void Exa_ListExamAnnouncementsEdit (void)
{
Exa_ListExamAnnouncements (Exa_NORMAL_VIEW);
}
2016-06-01 19:34:44 +02:00
/*****************************************************************************/
2016-06-03 10:37:00 +02:00
/*********** Get date of exam announcements to show highlighted **************/
2016-06-01 19:34:44 +02:00
/*****************************************************************************/
2016-06-03 10:37:00 +02:00
void Exa_GetExaCodToHighlight (void)
{
/***** Get the exam announcement code
of the exam announcement to highlight *****/
Gbl.ExamAnnouncements.HighlightExaCod = Exa_GetParamExaCod ();
}
/*****************************************************************************/
/*********** Get date of exam announcements to show highlighted **************/
/*****************************************************************************/
void Exa_GetDateToHighlight (void)
2016-06-01 19:34:44 +02:00
{
/***** Get the date (in YYYY-MM-DD format)
of the exam announcements to highlight *****/
Par_GetParToText ("Date",Gbl.ExamAnnouncements.HighlightDate,4+1+2+1+2);
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************** List all the exam announcements ************************/
/*****************************************************************************/
2015-11-13 01:27:44 +01:00
static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewExamAnnouncement)
2014-12-01 23:55:08 +01:00
{
2016-12-11 14:29:26 +01:00
extern const char *Hlp_ASSESSMENT_Announcements;
extern const char *Txt_All_announcements_of_exams;
extern const char *Txt_Announcements_of_exams;
2014-12-01 23:55:08 +01:00
extern const char *Txt_No_announcements_of_exams_of_X;
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-01 13:43:22 +02:00
unsigned long NumExaAnn;
unsigned long NumExaAnns;
2014-12-01 23:55:08 +01:00
long ExaCod;
2016-06-01 13:43:22 +02:00
bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM);
2016-06-03 10:37:00 +02:00
/***** Show one highlighted exam announcement *****/
if (Gbl.ExamAnnouncements.HighlightExaCod > 0)
{
/***** Get one exam announcement from database *****/
sprintf (Query,"SELECT ExaCod"
" FROM exam_announcements"
" WHERE ExaCod='%ld' AND CrsCod='%ld' AND Status<>'%u'",
Gbl.ExamAnnouncements.HighlightExaCod,
Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course for listing");
/***** List the existing exam announcements *****/
for (NumExaAnn = 0;
NumExaAnn < NumExaAnns;
NumExaAnn++)
{
/***** Get the code of the exam announcement (row[0]) *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%ld",&ExaCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of exam announcement.");
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Read the data of the exam announcement *****/
Exa_GetDataExamAnnouncementFromDB (ExaCod);
/***** Show exam announcement *****/
Exa_ShowExamAnnouncement (ExaCod,TypeViewExamAnnouncement);
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
}
/***** Show highlighted exam announcements of a date *****/
2016-06-01 19:34:44 +02:00
if (Gbl.ExamAnnouncements.HighlightDate[0])
{
/***** Get exam announcements (the most recent first)
in current course for a date from database *****/
2016-06-03 10:37:00 +02:00
sprintf (Query,"SELECT ExaCod"
2016-06-01 19:34:44 +02:00
" FROM exam_announcements"
" WHERE CrsCod='%ld' AND Status<>'%u'"
" AND DATE(ExamDate)='%s'"
" ORDER BY ExamDate DESC",
Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT,
Gbl.ExamAnnouncements.HighlightDate);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course for listing");
/***** List the existing exam announcements *****/
for (NumExaAnn = 0;
NumExaAnn < NumExaAnns;
NumExaAnn++)
{
/***** Get the code of the exam announcement (row[0]) *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%ld",&ExaCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of exam announcement.");
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Read the data of the exam announcement *****/
Exa_GetDataExamAnnouncementFromDB (ExaCod);
/***** Show exam announcement *****/
Exa_ShowExamAnnouncement (ExaCod,TypeViewExamAnnouncement);
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
}
2016-06-01 13:43:22 +02:00
/***** Get exam announcements (the most recent first)
in current course from database *****/
2016-06-03 10:37:00 +02:00
sprintf (Query,"SELECT ExaCod"
2016-06-01 13:43:22 +02:00
" FROM exam_announcements"
" WHERE CrsCod='%ld' AND Status<>'%u'"
" ORDER BY ExamDate DESC",
Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course for listing");
2014-12-01 23:55:08 +01:00
2016-06-01 13:43:22 +02:00
/***** Start frame *****/
Lay_StartRoundFrame (NULL,
2016-06-03 10:37:00 +02:00
(Gbl.ExamAnnouncements.HighlightExaCod > 0 ||
2016-12-11 14:29:26 +01:00
Gbl.ExamAnnouncements.HighlightDate[0]) ? Txt_All_announcements_of_exams :
Txt_Announcements_of_exams,
2016-06-01 13:43:22 +02:00
ICanEdit ? Exa_PutIconToCreateNewExamAnnouncement :
2016-11-12 22:00:50 +01:00
NULL,
2016-12-11 14:29:26 +01:00
Hlp_ASSESSMENT_Announcements);
2014-12-01 23:55:08 +01:00
/***** The result of the query may be empty *****/
2016-06-01 13:43:22 +02:00
if (!NumExaAnns)
2014-12-01 23:55:08 +01:00
{
sprintf (Gbl.Message,Txt_No_announcements_of_exams_of_X,
Gbl.CurrentCrs.Crs.FullName);
Lay_ShowAlert (Lay_INFO,Gbl.Message);
}
/***** List the existing exam announcements *****/
2016-06-01 13:43:22 +02:00
for (NumExaAnn = 0;
NumExaAnn < NumExaAnns;
NumExaAnn++)
2014-12-01 23:55:08 +01:00
{
/***** Get the code of the exam announcement (row[0]) *****/
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%ld",&ExaCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of exam announcement.");
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Read the data of the exam announcement *****/
Exa_GetDataExamAnnouncementFromDB (ExaCod);
/***** Show exam announcement *****/
Exa_ShowExamAnnouncement (ExaCod,TypeViewExamAnnouncement);
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
2016-06-01 13:43:22 +02:00
/***** Button to create a new assignment *****/
if (ICanEdit)
Exa_PutButtonToCreateNewExamAnnouncement ();
/***** End frame *****/
Lay_EndRoundFrame ();
}
/*****************************************************************************/
/***************** Put icon to create a new exam announcement ****************/
/*****************************************************************************/
static void Exa_PutIconToCreateNewExamAnnouncement (void)
{
extern const char *Txt_New_announcement_OF_EXAM;
2016-07-01 16:32:42 +02:00
Lay_PutContextualLink (ActEdiExaAnn,NULL,
"plus64x64.png",
Txt_New_announcement_OF_EXAM,NULL,
NULL);
2016-06-01 13:43:22 +02:00
}
/*****************************************************************************/
/**************** Put button to create a new exam announcement ***************/
/*****************************************************************************/
static void Exa_PutButtonToCreateNewExamAnnouncement (void)
{
extern const char *Txt_New_announcement_OF_EXAM;
Act_FormStart (ActEdiExaAnn);
Lay_PutConfirmButton (Txt_New_announcement_OF_EXAM);
Act_FormEnd ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/****************** Add an exam announcement to the database *****************/
/*****************************************************************************/
// Return the code of the exam announcement just added
static long Exa_AddExamAnnouncementToDB (void)
{
char *Query;
long ExaCod;
/***** Add exam announcement *****/
if ((Query = malloc (512+2*Cns_MAX_BYTES_STRING+7*Cns_MAX_BYTES_TEXT)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to query database.");
2016-06-01 19:34:44 +02:00
sprintf (Query,"INSERT INTO exam_announcements "
"(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,Place,"
2014-12-01 23:55:08 +01:00
"ExamMode,Structure,DocRequired,MatRequired,MatAllowed,OtherInfo)"
2016-06-01 19:34:44 +02:00
" VALUES "
"('%ld','%u','0','%s','%u','%s',"
"NOW(),'%04u-%02u-%02u %02u:%02u:00','%02u:%02u:00','%s',"
"'%s','%s','%s','%s','%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Exa_ACTIVE_EXAM_ANNOUNCEMENT,
Gbl.ExamAnnouncements.ExaDat.CrsFullName,
Gbl.ExamAnnouncements.ExaDat.Year,
Gbl.ExamAnnouncements.ExaDat.Session,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day,
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute,
Gbl.ExamAnnouncements.ExaDat.Duration.Hour,
Gbl.ExamAnnouncements.ExaDat.Duration.Minute,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Place,
2016-06-01 19:34:44 +02:00
Gbl.ExamAnnouncements.ExaDat.Mode,
Gbl.ExamAnnouncements.ExaDat.Structure,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.DocRequired,
2016-06-01 19:34:44 +02:00
Gbl.ExamAnnouncements.ExaDat.MatRequired,
Gbl.ExamAnnouncements.ExaDat.MatAllowed,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.OtherInfo);
2014-12-01 23:55:08 +01:00
ExaCod = DB_QueryINSERTandReturnCode (Query,"can not create a new exam announcement");
free ((void *) Query);
return ExaCod;
}
/*****************************************************************************/
/*************** Modify an exam announcement in the database *****************/
/*****************************************************************************/
static void Exa_ModifyExamAnnouncementInDB (long ExaCod)
{
char *Query;
/***** Modify exam announcement *****/
if ((Query = malloc (512+2*Cns_MAX_BYTES_STRING+7*Cns_MAX_BYTES_TEXT)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to query database.");
sprintf (Query,"UPDATE exam_announcements"
" SET CrsFullName='%s',Year='%u',ExamSession='%s',"
2016-06-01 19:34:44 +02:00
"ExamDate='%04u-%02u-%02u %02u:%02u:00',"
"Duration='%02u:%02u:00',"
"Place='%s',ExamMode='%s',Structure='%s',"
"DocRequired='%s',MatRequired='%s',MatAllowed='%s',OtherInfo='%s'" \
2014-12-01 23:55:08 +01:00
" WHERE ExaCod='%ld'",
2016-06-01 19:34:44 +02:00
Gbl.ExamAnnouncements.ExaDat.CrsFullName,
Gbl.ExamAnnouncements.ExaDat.Year,
Gbl.ExamAnnouncements.ExaDat.Session,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day,
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute,
Gbl.ExamAnnouncements.ExaDat.Duration.Hour,
Gbl.ExamAnnouncements.ExaDat.Duration.Minute,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Place,
2016-06-01 19:34:44 +02:00
Gbl.ExamAnnouncements.ExaDat.Mode,
Gbl.ExamAnnouncements.ExaDat.Structure,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.DocRequired,
2016-06-01 19:34:44 +02:00
Gbl.ExamAnnouncements.ExaDat.MatRequired,
Gbl.ExamAnnouncements.ExaDat.MatAllowed,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.OtherInfo,
2014-12-01 23:55:08 +01:00
ExaCod);
DB_QueryUPDATE (Query,"can not update an exam announcement");
free ((void *) Query);
}
/*****************************************************************************/
/******* Create a list with the dates of all the exam announcements **********/
/*****************************************************************************/
void Exa_CreateListOfExamAnnouncements (void)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-01 19:34:44 +02:00
unsigned long NumExaAnn;
unsigned long NumExaAnns;
2014-12-01 23:55:08 +01:00
if (Gbl.DB.DatabaseIsOpen)
{
2016-06-01 19:34:44 +02:00
/***** Get exam dates (no matter in what order)
2016-06-01 13:43:22 +02:00
in current course from database *****/
2016-06-01 19:34:44 +02:00
sprintf (Query,"SELECT DISTINCT(DATE(ExamDate))"
2016-06-01 13:43:22 +02:00
" FROM exam_announcements" \
" WHERE CrsCod='%ld' AND Status<>'%u'",
Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get exam announcements in this course");
2014-12-01 23:55:08 +01:00
/***** The result of the query may be empty *****/
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.Lst = NULL;
Gbl.ExamAnnouncements.NumExaAnns = 0;
if (NumExaAnns)
2014-12-01 23:55:08 +01:00
{
/***** Allocate memory for the list *****/
2016-06-01 13:43:22 +02:00
if ((Gbl.ExamAnnouncements.Lst = (struct Date *) calloc (NumExaAnns,sizeof (struct Date))) == NULL)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Not enough memory to store dates of exam announcements.");
/***** Get the dates of the existing exam announcements *****/
2016-06-01 13:43:22 +02:00
for (NumExaAnn = 0;
NumExaAnn < NumExaAnns;
NumExaAnn++)
2014-12-01 23:55:08 +01:00
{
2016-06-01 19:34:44 +02:00
/***** Get next exam announcement *****/
2014-12-01 23:55:08 +01:00
row = mysql_fetch_row (mysql_res);
2016-06-01 19:34:44 +02:00
/* Read the date of the exam (row[0]) */
if (sscanf (row[0],"%04u-%02u-%02u",
&Gbl.ExamAnnouncements.Lst[Gbl.ExamAnnouncements.NumExaAnns].Year,
&Gbl.ExamAnnouncements.Lst[Gbl.ExamAnnouncements.NumExaAnns].Month,
&Gbl.ExamAnnouncements.Lst[Gbl.ExamAnnouncements.NumExaAnns].Day) != 3)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong date of exam.");
2016-06-01 19:34:44 +02:00
/***** Increment number of elements in list *****/
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.NumExaAnns++;
2014-12-01 23:55:08 +01:00
}
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
}
/*****************************************************************************/
/***************** Free list of dates of exam announcements ******************/
/*****************************************************************************/
void Exa_FreeListExamAnnouncements (void)
{
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.Lst)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
free ((void *) Gbl.ExamAnnouncements.Lst);
Gbl.ExamAnnouncements.Lst = NULL;
Gbl.ExamAnnouncements.NumExaAnns = 0;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/******** Read the data of an exam announcement from the database ************/
/*****************************************************************************/
static void Exa_GetDataExamAnnouncementFromDB (long ExaCod)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-01 13:43:22 +02:00
unsigned long NumExaAnns;
unsigned Hour;
unsigned Minute;
unsigned Second;
2014-12-01 23:55:08 +01:00
/***** Get data of an exam announcement from database *****/
2016-06-01 13:43:22 +02:00
sprintf (Query,"SELECT CrsCod,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,Place,ExamMode,"
"Structure,DocRequired,MatRequired,MatAllowed,OtherInfo"
" FROM exam_announcements WHERE ExaCod='%ld'",
ExaCod);
NumExaAnns = DB_QuerySELECT (Query,&mysql_res,"can not get data of an exam announcement");
2014-12-01 23:55:08 +01:00
/***** The result of the query must have one row *****/
2016-06-01 13:43:22 +02:00
if (NumExaAnns != 1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Error when getting data of an exam announcement.");
/***** Get the data of the exam announcement *****/
row = mysql_fetch_row (mysql_res);
/* Code of the course in which the exam announcement is inserted (row[0]) */
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
2014-12-01 23:55:08 +01:00
/* Name of the course (row[1]) */
2016-06-01 13:43:22 +02:00
strcpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,row[1]);
2014-12-01 23:55:08 +01:00
/* Year (row[2]) */
2016-06-01 13:43:22 +02:00
if (sscanf (row[2],"%u",&Gbl.ExamAnnouncements.ExaDat.Year) != 1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong year.");
/* Exam session (row[3]) */
2016-06-01 13:43:22 +02:00
strcpy (Gbl.ExamAnnouncements.ExaDat.Session,row[3]);
2014-12-01 23:55:08 +01:00
/* Date of exam announcement (row[4]) */
if (sscanf (row[4],"%04u-%02u-%02u %02u:%02u:%02u",
2016-06-01 13:43:22 +02:00
&Gbl.ExamAnnouncements.ExaDat.CallDate.Year,
&Gbl.ExamAnnouncements.ExaDat.CallDate.Month,
&Gbl.ExamAnnouncements.ExaDat.CallDate.Day,
2014-12-01 23:55:08 +01:00
&Hour,&Minute,&Second) != 6)
Lay_ShowErrorAndExit ("Wrong date of exam announcement.");
/* Date of exam (row[5]) */
if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u",
2016-06-01 13:43:22 +02:00
&Gbl.ExamAnnouncements.ExaDat.ExamDate.Year,&Gbl.ExamAnnouncements.ExaDat.ExamDate.Month,&Gbl.ExamAnnouncements.ExaDat.ExamDate.Day,
&Gbl.ExamAnnouncements.ExaDat.StartTime.Hour,&Gbl.ExamAnnouncements.ExaDat.StartTime.Minute,&Second) != 6)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong date of exam.");
/* Approximate duration (row[6]) */
2016-06-01 13:43:22 +02:00
if (sscanf (row[6],"%02u:%02u:%02u",&Gbl.ExamAnnouncements.ExaDat.Duration.Hour,&Gbl.ExamAnnouncements.ExaDat.Duration.Minute,&Second) != 3)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong duration of exam.");
/* Place (row[7]) */
2016-06-01 13:43:22 +02:00
strncpy (Gbl.ExamAnnouncements.ExaDat.Place,row[7],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.Place[Cns_MAX_BYTES_TEXT] = '\0';
2014-12-01 23:55:08 +01:00
/* Exam mode (row[8]) */
2016-06-01 13:43:22 +02:00
strncpy (Gbl.ExamAnnouncements.ExaDat.Mode,row[8],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.Mode[Cns_MAX_BYTES_TEXT] = '\0';
2014-12-01 23:55:08 +01:00
/* Structure (row[9]) */
2016-06-01 13:43:22 +02:00
strncpy (Gbl.ExamAnnouncements.ExaDat.Structure,row[9],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.Structure[Cns_MAX_BYTES_TEXT] = '\0';
2014-12-01 23:55:08 +01:00
/* Documentation required (row[10]) */
2016-06-01 13:43:22 +02:00
strncpy (Gbl.ExamAnnouncements.ExaDat.DocRequired,row[10],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.DocRequired[Cns_MAX_BYTES_TEXT] = '\0';
2014-12-01 23:55:08 +01:00
/* Material required (row[11]) */
2016-06-01 13:43:22 +02:00
strncpy (Gbl.ExamAnnouncements.ExaDat.MatRequired,row[11],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.MatRequired[Cns_MAX_BYTES_TEXT] = '\0';
2014-12-01 23:55:08 +01:00
/* Material allowed (row[12]) */
2016-06-01 13:43:22 +02:00
strncpy (Gbl.ExamAnnouncements.ExaDat.MatAllowed,row[12],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.MatAllowed[Cns_MAX_BYTES_TEXT] = '\0';
2014-12-01 23:55:08 +01:00
/* Other information for students (row[13]) */
2016-06-01 13:43:22 +02:00
strncpy (Gbl.ExamAnnouncements.ExaDat.OtherInfo,row[13],Cns_MAX_BYTES_TEXT);
Gbl.ExamAnnouncements.ExaDat.OtherInfo[Cns_MAX_BYTES_TEXT] = '\0';
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/************ Show a form with the data of an exam announcement **************/
/*****************************************************************************/
2015-11-13 01:27:44 +01:00
static void Exa_ShowExamAnnouncement (long ExaCod,Exa_TypeViewExamAnnouncement_t TypeViewExamAnnouncement)
2014-12-01 23:55:08 +01:00
{
2016-12-11 14:29:26 +01:00
extern const char *Hlp_ASSESSMENT_Announcements_new_announcement;
extern const char *Hlp_ASSESSMENT_Announcements_edit_announcement;
2014-12-01 23:55:08 +01:00
extern const char *Txt_YEAR_OF_DEGREE[1+Deg_MAX_YEARS_PER_DEGREE];
2015-07-27 21:25:45 +02:00
extern const char *The_ClassForm[The_NUM_THEMES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_EXAM_ANNOUNCEMENT;
extern const char *Txt_EXAM_ANNOUNCEMENT_Course;
2016-12-11 14:29:26 +01:00
extern const char *Txt_EXAM_ANNOUNCEMENT_Year_or_semester;
2014-12-01 23:55:08 +01:00
extern const char *Txt_EXAM_ANNOUNCEMENT_Session;
extern const char *Txt_EXAM_ANNOUNCEMENT_Exam_date;
extern const char *Txt_EXAM_ANNOUNCEMENT_Start_time;
extern const char *Txt_EXAM_ANNOUNCEMENT_Approximate_duration;
extern const char *Txt_EXAM_ANNOUNCEMENT_Place_of_exam;
extern const char *Txt_EXAM_ANNOUNCEMENT_Mode;
extern const char *Txt_EXAM_ANNOUNCEMENT_Structure_of_the_exam;
extern const char *Txt_EXAM_ANNOUNCEMENT_Documentation_required;
extern const char *Txt_EXAM_ANNOUNCEMENT_Material_required;
extern const char *Txt_EXAM_ANNOUNCEMENT_Material_allowed;
extern const char *Txt_EXAM_ANNOUNCEMENT_Other_information;
extern const char *Txt_hours_ABBREVIATION;
extern const char *Txt_hour;
extern const char *Txt_hours;
extern const char *Txt_minute;
extern const char *Txt_minutes;
2015-03-24 17:47:26 +01:00
extern const char *Txt_Publish_announcement_OF_EXAM;
2014-12-01 23:55:08 +01:00
const char *StyleTitle = "CONV_TIT";
const char *StyleForm = "CONV_NEG";
const char *StyleNormal = "CONV";
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2014-12-01 23:55:08 +01:00
char StrExamDate[Cns_MAX_LENGTH_DATE+1];
unsigned Year,Hour,Minute;
/***** Get data of institution of this degree *****/
Ins.InsCod = Gbl.CurrentIns.Ins.InsCod;
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
switch (TypeViewExamAnnouncement)
{
case Exa_NORMAL_VIEW:
break;
case Exa_PRINT_VIEW:
StyleTitle = "CONV_TIT_IMPR";
StyleForm = "CONV_NEG_IMPR";
StyleNormal = "CONV_IMPR";
break;
case Exa_FORM_VIEW:
2015-07-27 21:25:45 +02:00
StyleForm = The_ClassForm[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
break;
}
2014-12-08 17:35:48 +01:00
/***** Start frame *****/
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaCodToEdit = ExaCod; // Used as parameter in contextual links
2016-03-16 12:05:10 +01:00
Lay_StartRoundFrame ("625px",NULL,
TypeViewExamAnnouncement == Exa_NORMAL_VIEW ? Exa_PutIconsExamAnnouncement :
2016-11-12 22:00:50 +01:00
NULL,
2016-12-11 14:29:26 +01:00
TypeViewExamAnnouncement == Exa_FORM_VIEW ? ((ExaCod > 0) ? Hlp_ASSESSMENT_Announcements_edit_announcement :
Hlp_ASSESSMENT_Announcements_new_announcement) :
NULL);
2015-04-01 12:54:25 +02:00
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{
/***** Start form *****/
Act_FormStart (ActRcvExaAnn);
if (ExaCod > 0)
2016-06-01 19:34:44 +02:00
Exa_PutHiddenParamExaCod (ExaCod);
2015-04-01 12:54:25 +02:00
}
fprintf (Gbl.F.Out,"<table class=\"CELLS_PAD_2\""
2015-09-05 19:19:39 +02:00
" style=\"width:100%%;"
2015-09-28 18:28:29 +02:00
" padding:25px 25px 125px 25px;\">"); // Bottom space used for signatures
2014-12-01 23:55:08 +01:00
/***** Institution logo *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-08-01 08:40:58 +02:00
"<td colspan=\"2\" class=\"CENTER_MIDDLE\">");
2014-12-01 23:55:08 +01:00
if (TypeViewExamAnnouncement == Exa_PRINT_VIEW)
fprintf (Gbl.F.Out,"<span class=\"%s\">",StyleTitle);
else
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"%s\">",
Ins.WWW,StyleTitle);
2015-02-01 20:17:24 +01:00
Log_DrawLogo (Sco_SCOPE_INS,Ins.InsCod,Ins.FullName,64,NULL,true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<br />%s%s" \
"</td>" \
"</tr>",
Ins.FullName,
TypeViewExamAnnouncement == Exa_PRINT_VIEW ? "</span>" :
"</a>");
/***** Degree *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-08-01 08:40:58 +02:00
"<td colspan=\"2\" class=\"%s CENTER_MIDDLE\">",
2014-12-01 23:55:08 +01:00
StyleTitle);
if (TypeViewExamAnnouncement == Exa_NORMAL_VIEW)
fprintf (Gbl.F.Out,"<a href=\"%s\" target=\"_blank\" class=\"%s\">",
Gbl.CurrentDeg.Deg.WWW,StyleTitle);
fprintf (Gbl.F.Out,"%s",Gbl.CurrentDeg.Deg.FullName);
if (TypeViewExamAnnouncement == Exa_NORMAL_VIEW)
fprintf (Gbl.F.Out,"</a>");
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Title *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-08-01 08:40:58 +02:00
"<td colspan=\"2\" class=\"%s CENTER_MIDDLE\">"
2014-12-22 21:52:37 +01:00
"&nbsp;<br />"
"<strong>%s</strong>"
"</td>" \
2014-12-01 23:55:08 +01:00
"</tr>",
StyleNormal,Txt_EXAM_ANNOUNCEMENT);
fprintf (Gbl.F.Out,"<tr>" \
2015-08-01 08:40:58 +02:00
"<td colspan=\"2\" class=\"%s LEFT_MIDDLE\">"
2014-12-22 21:52:37 +01:00
"&nbsp;"
"</td>" \
2014-12-01 23:55:08 +01:00
"</tr>",
StyleNormal);
/***** Name of the course *****/
fprintf (Gbl.F.Out,"<tr>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s RIGHT_BOTTOM\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s LEFT_BOTTOM\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Course,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{
2015-04-01 12:54:25 +02:00
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"CrsName\""
" size=\"30\" maxlength=\"%u\" value=\"%s\" />",
2016-06-01 13:43:22 +02:00
Cns_MAX_LENGTH_STRING,Gbl.ExamAnnouncements.ExaDat.CrsFullName);
2014-12-01 23:55:08 +01:00
}
else
2016-06-01 13:43:22 +02:00
fprintf (Gbl.F.Out,"<strong>%s</strong>",Gbl.ExamAnnouncements.ExaDat.CrsFullName);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
2016-12-11 14:29:26 +01:00
/***** Year/semester (N.A., 1<>, 2<>, 3<>, 4<>, 5<>...) *****/
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<tr>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s RIGHT_BOTTOM\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s LEFT_BOTTOM\">",
2015-07-27 21:25:45 +02:00
StyleForm,
2016-12-11 14:29:26 +01:00
Txt_EXAM_ANNOUNCEMENT_Year_or_semester,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{
fprintf (Gbl.F.Out,"<select name=\"Year\">");
for (Year = 0;
Year <= Deg_MAX_YEARS_PER_DEGREE;
Year++)
{
fprintf (Gbl.F.Out,"<option");
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Year == Year)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," value=\"%u\">%s</option>",Year,Txt_YEAR_OF_DEGREE[Year]);
}
fprintf (Gbl.F.Out,"</select>");
}
else
2016-06-01 13:43:22 +02:00
fprintf (Gbl.F.Out,"%s",Txt_YEAR_OF_DEGREE[Gbl.ExamAnnouncements.ExaDat.Year]);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Exam session *****/
fprintf (Gbl.F.Out,"<tr>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s RIGHT_BOTTOM\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s LEFT_BOTTOM\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Session,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
2015-04-01 12:54:25 +02:00
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"ExamSession\""
" size=\"30\" maxlength=\"%u\" value=\"%s\" />",
2016-06-01 13:43:22 +02:00
Cns_MAX_LENGTH_STRING,Gbl.ExamAnnouncements.ExaDat.Session);
2014-12-01 23:55:08 +01:00
else
2016-06-01 13:43:22 +02:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Session);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Date of the exam *****/
fprintf (Gbl.F.Out,"<tr>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s RIGHT_BOTTOM\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Exam_date);
2014-12-01 23:55:08 +01:00
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{
2016-12-11 14:29:26 +01:00
fprintf (Gbl.F.Out,"<td class=\"LEFT_BOTTOM\">");
2016-06-01 13:43:22 +02:00
Dat_WriteFormDate (Gbl.ExamAnnouncements.ExaDat.ExamDate.Year < Gbl.Now.Date.Year ? Gbl.ExamAnnouncements.ExaDat.ExamDate.Year :
Gbl.Now.Date.Year,
2015-10-23 01:06:32 +02:00
Gbl.Now.Date.Year + 1,"Exam",
2016-06-01 13:43:22 +02:00
&(Gbl.ExamAnnouncements.ExaDat.ExamDate),
2014-12-01 23:55:08 +01:00
false,false);
fprintf (Gbl.F.Out,"</td>");
}
else
{
2016-06-01 13:43:22 +02:00
Dat_ConvDateToDateStr (&Gbl.ExamAnnouncements.ExaDat.ExamDate,StrExamDate);
2016-12-11 14:29:26 +01:00
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_BOTTOM\">"
2014-12-22 21:52:37 +01:00
"%s"
"</td>",
2014-12-01 23:55:08 +01:00
StyleNormal,StrExamDate);
}
fprintf (Gbl.F.Out,"</tr>");
/***** Start time *****/
fprintf (Gbl.F.Out,"<tr>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s RIGHT_BOTTOM\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s LEFT_BOTTOM\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Start_time,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{
fprintf (Gbl.F.Out,"<select name=\"ExamHour\"><option value=\"0\"");
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour == 0)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">-</option>");
for (Hour = 7;
Hour <= 22;
Hour++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",Hour);
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour == Hour)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u %s</option>",
Hour,Txt_hours_ABBREVIATION);
}
fprintf (Gbl.F.Out,"</select>" \
"<select name=\"ExamMinute\">");
for (Minute = 0;
Minute <= 59;
Minute++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute);
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.StartTime.Minute == Minute)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u &#39;</option>",Minute);
}
fprintf (Gbl.F.Out,"</select>");
}
2016-06-01 13:43:22 +02:00
else if (Gbl.ExamAnnouncements.ExaDat.StartTime.Hour)
2015-10-31 02:11:38 +01:00
fprintf (Gbl.F.Out,"%2u:%02u",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Approximate duration of the exam *****/
fprintf (Gbl.F.Out,"<tr>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s RIGHT_BOTTOM\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2016-12-11 14:29:26 +01:00
"<td class=\"%s LEFT_BOTTOM\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Approximate_duration,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{
fprintf (Gbl.F.Out,"<select name=\"DurationHour\">");
for (Hour = 0;
Hour <= 8;
Hour++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",Hour);
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour == Hour)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u %s</option>",
Hour,Txt_hours_ABBREVIATION);
}
fprintf (Gbl.F.Out,"</select><select name=\"DurationMinute\">");
for (Minute = 0;
Minute <= 59;
Minute++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute);
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute == Minute)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%02u &#39;</option>",Minute);
}
fprintf (Gbl.F.Out,"</select>");
}
2016-06-01 13:43:22 +02:00
else if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour ||
Gbl.ExamAnnouncements.ExaDat.Duration.Minute)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"%u %s %u &#39;",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Duration.Hour,
2014-12-01 23:55:08 +01:00
Txt_hours_ABBREVIATION,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Duration.Minute);
2014-12-01 23:55:08 +01:00
else
{
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Duration.Hour == 1)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"1 %s",Txt_hour);
else
2016-06-01 13:43:22 +02:00
fprintf (Gbl.F.Out,"%u %s",Gbl.ExamAnnouncements.ExaDat.Duration.Hour,Txt_hours);
2014-12-01 23:55:08 +01:00
}
}
2016-06-01 13:43:22 +02:00
else if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute)
2014-12-01 23:55:08 +01:00
{
2016-06-01 13:43:22 +02:00
if (Gbl.ExamAnnouncements.ExaDat.Duration.Minute == 1)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"1 %s",Txt_minute);
else
2016-06-01 13:43:22 +02:00
fprintf (Gbl.F.Out,"%u %s",Gbl.ExamAnnouncements.ExaDat.Duration.Minute,Txt_minutes);
2014-12-01 23:55:08 +01:00
}
}
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Place where the exam will be made *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_TOP\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2015-08-01 08:40:58 +02:00
"<td class=\"%s LEFT_TOP\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Place_of_exam,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
fprintf (Gbl.F.Out,"<textarea name=\"Place\" cols=\"40\" rows=\"4\">%s</textarea>",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Place);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Place,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Place);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Exam mode *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_TOP\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2015-08-01 08:40:58 +02:00
"<td class=\"%s LEFT_TOP\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Mode,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
fprintf (Gbl.F.Out,"<textarea name=\"ExamMode\" cols=\"40\" rows=\"2\">%s</textarea>",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Mode);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Mode,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Mode);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Structure of the exam *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_TOP\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2015-08-01 08:40:58 +02:00
"<td class=\"%s LEFT_TOP\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Structure_of_the_exam,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
fprintf (Gbl.F.Out,"<textarea name=\"Structure\" cols=\"40\" rows=\"8\">%s</textarea>",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Structure);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.Structure,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.Structure);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Documentation required *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_TOP\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2015-08-01 08:40:58 +02:00
"<td class=\"%s LEFT_TOP\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Documentation_required,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
fprintf (Gbl.F.Out,"<textarea name=\"DocRequired\" cols=\"40\" rows=\"2\">%s</textarea>",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.DocRequired);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.DocRequired,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.DocRequired);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Material required *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_TOP\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2015-08-01 08:40:58 +02:00
"<td class=\"%s LEFT_TOP\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Material_required,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
fprintf (Gbl.F.Out,"<textarea name=\"MatRequired\" cols=\"40\" rows=\"4\">%s</textarea>",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.MatRequired);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.MatRequired,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.MatRequired);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Material allowed *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_TOP\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2015-08-01 08:40:58 +02:00
"<td class=\"%s LEFT_TOP\">",
2015-07-27 21:25:45 +02:00
StyleForm,
Txt_EXAM_ANNOUNCEMENT_Material_allowed,
2014-12-01 23:55:08 +01:00
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
fprintf (Gbl.F.Out,"<textarea name=\"MatAllowed\" cols=\"40\" rows=\"4\">%s</textarea>",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.MatAllowed);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.MatAllowed,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.MatAllowed);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>" \
"</tr>");
/***** Other information to students *****/
fprintf (Gbl.F.Out,"<tr>" \
2015-07-27 21:25:45 +02:00
"<td class=\"%s RIGHT_TOP\">"
2014-12-22 21:52:37 +01:00
"%s:"
"</td>" \
2015-08-01 08:40:58 +02:00
"<td class=\"%s LEFT_TOP\">",
2014-12-01 23:55:08 +01:00
StyleForm,Txt_EXAM_ANNOUNCEMENT_Other_information,
StyleNormal);
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
fprintf (Gbl.F.Out,"<textarea name=\"OtherInfo\" cols=\"40\" rows=\"5\">%s</textarea>",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.OtherInfo);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.OtherInfo,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnnouncements.ExaDat.OtherInfo);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</td>" \
2015-04-01 12:54:25 +02:00
"</tr>" \
"</table>");
2014-12-01 23:55:08 +01:00
2014-12-08 17:35:48 +01:00
/***** End frame *****/
2015-04-11 23:46:21 +02:00
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
2016-03-16 12:05:10 +01:00
Lay_EndRoundFrameWithButton ((ExaCod > 0) ? Lay_CONFIRM_BUTTON :
Lay_CREATE_BUTTON,
Txt_Publish_announcement_OF_EXAM);
2015-04-11 23:46:21 +02:00
else
2016-03-16 12:05:10 +01:00
Lay_EndRoundFrame ();
2014-12-08 17:35:48 +01:00
2015-04-01 12:54:25 +02:00
if (TypeViewExamAnnouncement == Exa_PRINT_VIEW)
QR_ExamAnnnouncement ();
2014-12-01 23:55:08 +01:00
}
2015-12-13 19:55:52 +01:00
/*****************************************************************************/
2016-03-16 12:05:10 +01:00
/********* Put icons to remove / edit / print an exam announcement ***********/
/*****************************************************************************/
static void Exa_PutIconsExamAnnouncement (void)
{
extern const char *Txt_Remove;
extern const char *Txt_Edit;
extern const char *Txt_Print;
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
{
/***** Link to remove this exam announcement *****/
2016-07-01 16:32:42 +02:00
Lay_PutContextualLink (ActRemExaAnn,Exa_PutParamExaCodToEdit,
"remove-on64x64.png",
Txt_Remove,NULL,
NULL);
2016-03-16 12:05:10 +01:00
/***** Link to edit this exam announcement *****/
2016-07-01 16:32:42 +02:00
Lay_PutContextualLink (ActEdiExaAnn,Exa_PutParamExaCodToEdit,
"edit64x64.png",
Txt_Edit,NULL,
NULL);
2016-03-16 12:05:10 +01:00
}
/***** Link to print view *****/
2016-07-01 16:32:42 +02:00
Lay_PutContextualLink (ActPrnExaAnn,Exa_PutParamExaCodToEdit,
"print64x64.png",
Txt_Print,NULL,
NULL);
2016-03-16 12:05:10 +01:00
}
/*****************************************************************************/
/*************** Param with the code of an exam announcement *****************/
2015-12-13 19:55:52 +01:00
/*****************************************************************************/
2016-06-01 19:34:44 +02:00
static void Exa_PutParamExaCodToEdit (void)
2015-12-13 19:55:52 +01:00
{
2016-06-01 19:34:44 +02:00
Exa_PutHiddenParamExaCod (Gbl.ExamAnnouncements.ExaCodToEdit);
}
2016-06-03 10:37:00 +02:00
void Exa_PutHiddenParamExaCod (long ExaCod)
2016-06-01 19:34:44 +02:00
{
Par_PutHiddenParamLong ("ExaCod",ExaCod);
}
/*****************************************************************************/
/********** Get parameter with the code of an exam announcement **************/
/*****************************************************************************/
static long Exa_GetParamExaCod (void)
{
char LongStr[1+10+1]; // String that holds the exam announcement code
long ExaCod;
/* Get notice code */
Par_GetParToText ("ExaCod",LongStr,1+10);
if (sscanf (LongStr,"%ld",&ExaCod) != 1)
ExaCod = -1L;
return ExaCod;
2015-12-13 19:55:52 +01:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2015-12-29 02:09:50 +01:00
/************ Get summary and content about an exam announcement *************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
// This function may be called inside a web service, so don't report error
2015-12-29 02:09:50 +01:00
// MaxChars must be > 3+(2+Cns_MAX_LENGTH_DATE+6)
2014-12-01 23:55:08 +01:00
2015-12-29 02:09:50 +01:00
void Exa_GetSummaryAndContentExamAnnouncement (char *SummaryStr,char **ContentStr,
long ExaCod,unsigned MaxChars,bool GetContent)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_hours_ABBREVIATION;
SummaryStr[0] = '\0'; // Return nothing on error
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get data of an exam announcement from database *****/
Exa_GetDataExamAnnouncementFromDB (ExaCod);
/***** Content *****/
if (GetContent)
Exa_GetNotifContentExamAnnouncement (ContentStr);
/***** Summary *****/
/* Name of the course */
if (MaxChars)
2016-06-01 13:43:22 +02:00
Str_LimitLengthHTMLStr (Gbl.ExamAnnouncements.ExaDat.CrsFullName,
2015-12-29 02:09:50 +01:00
MaxChars-(2+Cns_MAX_LENGTH_DATE+6));
2014-12-01 23:55:08 +01:00
/* Date of exam */
2015-10-31 02:11:38 +01:00
sprintf (SummaryStr,"%s, %04u-%02u-%02u %2u:%02u",
2016-06-01 13:43:22 +02:00
Gbl.ExamAnnouncements.ExaDat.CrsFullName,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Year,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Month,
Gbl.ExamAnnouncements.ExaDat.ExamDate.Day,
Gbl.ExamAnnouncements.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute);
2014-12-01 23:55:08 +01:00
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
/*****************************************************************************/
/************ Show a form with the data of an exam announcement **************/
/*****************************************************************************/
static void Exa_GetNotifContentExamAnnouncement (char **ContentStr)
{
extern const char *Txt_Institution;
extern const char *Txt_Degree;
extern const char *Txt_YEAR_OF_DEGREE[1+Deg_MAX_YEARS_PER_DEGREE];
extern const char *Txt_EXAM_ANNOUNCEMENT_Course;
2016-12-11 14:29:26 +01:00
extern const char *Txt_EXAM_ANNOUNCEMENT_Year_or_semester;
2014-12-01 23:55:08 +01:00
extern const char *Txt_EXAM_ANNOUNCEMENT_Session;
extern const char *Txt_EXAM_ANNOUNCEMENT_Exam_date;
extern const char *Txt_EXAM_ANNOUNCEMENT_Start_time;
extern const char *Txt_EXAM_ANNOUNCEMENT_Approximate_duration;
extern const char *Txt_EXAM_ANNOUNCEMENT_Place_of_exam;
extern const char *Txt_EXAM_ANNOUNCEMENT_Mode;
extern const char *Txt_EXAM_ANNOUNCEMENT_Structure_of_the_exam;
extern const char *Txt_EXAM_ANNOUNCEMENT_Documentation_required;
extern const char *Txt_EXAM_ANNOUNCEMENT_Material_required;
extern const char *Txt_EXAM_ANNOUNCEMENT_Material_allowed;
extern const char *Txt_EXAM_ANNOUNCEMENT_Other_information;
extern const char *Txt_hours_ABBREVIATION;
struct Course Crs;
struct Degree Deg;
2016-10-28 10:03:37 +02:00
struct Instit Ins;
2014-12-01 23:55:08 +01:00
char StrExamDate[Cns_MAX_LENGTH_DATE+1];
if ((*ContentStr = (char *) malloc (Cns_MAX_BYTES_TEXT*8)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
(*ContentStr)[0] = '\0'; // Return nothing on error
/***** Get data of course *****/
2016-06-01 13:43:22 +02:00
Crs.CrsCod = Gbl.ExamAnnouncements.ExaDat.CrsCod;
2014-12-01 23:55:08 +01:00
Crs_GetDataOfCourseByCod (&Crs);
/***** Get data of degree *****/
Deg.DegCod = Crs.DegCod;
Deg_GetDataOfDegreeByCod (&Deg);
/***** Get data of institution *****/
Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Deg.DegCod);
2015-12-09 19:51:17 +01:00
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
2014-12-01 23:55:08 +01:00
2016-06-01 13:43:22 +02:00
Dat_ConvDateToDateStr (&Gbl.ExamAnnouncements.ExaDat.ExamDate,StrExamDate);
2014-12-01 23:55:08 +01:00
/***** Institution *****/
sprintf (*ContentStr,"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %2u:%02u %s<br />" \
"%s: %2u:%02u %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s<br />" \
"%s: %s",
Txt_Institution,Ins.FullName,
Txt_Degree,Deg.FullName,
2016-06-01 13:43:22 +02:00
Txt_EXAM_ANNOUNCEMENT_Course,Gbl.ExamAnnouncements.ExaDat.CrsFullName,
2016-12-11 14:29:26 +01:00
Txt_EXAM_ANNOUNCEMENT_Year_or_semester,Txt_YEAR_OF_DEGREE[Gbl.ExamAnnouncements.ExaDat.Year],
2016-06-01 13:43:22 +02:00
Txt_EXAM_ANNOUNCEMENT_Session,Gbl.ExamAnnouncements.ExaDat.Session,
2014-12-01 23:55:08 +01:00
Txt_EXAM_ANNOUNCEMENT_Exam_date,StrExamDate,
2016-06-01 13:43:22 +02:00
Txt_EXAM_ANNOUNCEMENT_Start_time,Gbl.ExamAnnouncements.ExaDat.StartTime.Hour,
Gbl.ExamAnnouncements.ExaDat.StartTime.Minute,
2014-12-01 23:55:08 +01:00
Txt_hours_ABBREVIATION,
2016-06-01 13:43:22 +02:00
Txt_EXAM_ANNOUNCEMENT_Approximate_duration,Gbl.ExamAnnouncements.ExaDat.Duration.Hour,
Gbl.ExamAnnouncements.ExaDat.Duration.Minute,
2014-12-01 23:55:08 +01:00
Txt_hours_ABBREVIATION,
2016-06-01 13:43:22 +02:00
Txt_EXAM_ANNOUNCEMENT_Place_of_exam,Gbl.ExamAnnouncements.ExaDat.Place,
Txt_EXAM_ANNOUNCEMENT_Mode,Gbl.ExamAnnouncements.ExaDat.Mode,
Txt_EXAM_ANNOUNCEMENT_Structure_of_the_exam,Gbl.ExamAnnouncements.ExaDat.Structure,
Txt_EXAM_ANNOUNCEMENT_Documentation_required,Gbl.ExamAnnouncements.ExaDat.DocRequired,
Txt_EXAM_ANNOUNCEMENT_Material_required,Gbl.ExamAnnouncements.ExaDat.MatRequired,
Txt_EXAM_ANNOUNCEMENT_Material_allowed,Gbl.ExamAnnouncements.ExaDat.MatAllowed,
Txt_EXAM_ANNOUNCEMENT_Other_information,Gbl.ExamAnnouncements.ExaDat.OtherInfo);
2014-12-01 23:55:08 +01:00
}