swad-core/swad_exam.c

1724 lines
65 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 ***********************************/
/*****************************************************************************/
2018-10-17 14:12:09 +02:00
#define _GNU_SOURCE // For asprintf
2014-12-01 23:55:08 +01:00
#include <linux/stddef.h> // For NULL
2018-10-17 14:12:09 +02:00
#include <stdio.h> // For sscanf, asprintf, etc.
2014-12-01 23:55:08 +01:00
#include <stdlib.h> // For exit, system, malloc, calloc, free, etc.
#include <string.h> // For string functions
2017-06-10 21:38:10 +02:00
#include "swad_box.h"
2014-12-01 23:55:08 +01:00
#include "swad_config.h"
#include "swad_database.h"
#include "swad_exam.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2014-12-01 23:55:08 +01:00
#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"
#include "swad_string.h"
2019-03-12 21:25:55 +01:00
#include "swad_timeline.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************** 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);
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);
2019-03-25 19:05:10 +01:00
static void Exa_ModifyExamAnnouncementInDB (long ExaCod);
static void Exa_GetDataExamAnnouncementFromDB (long ExaCod);
static void Exa_ShowExamAnnouncement (long ExaCod,
Exa_TypeViewExamAnnouncement_t TypeViewExamAnnouncement,
bool HighLight);
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)
{
2019-03-25 19:05:10 +01:00
long ExaCod;
2014-12-01 23:55:08 +01:00
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get the code of the exam announcement *****/
2019-03-25 19:05:10 +01:00
ExaCod = Exa_GetParamsExamAnnouncement ();
2014-12-01 23:55:08 +01:00
2019-03-25 19:05:10 +01: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 *****/
2019-03-25 19:05:10 +01:00
Exa_GetDataExamAnnouncementFromDB (ExaCod);
2014-12-01 23:55:08 +01:00
/***** Show exam announcement *****/
2019-03-25 19:05:10 +01:00
Exa_ShowExamAnnouncement (ExaCod,Exa_FORM_VIEW,
false); // Don't highlight
2014-12-01 23:55:08 +01:00
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
/*****************************************************************************/
/**************** Get parameters of an exam announcement *********************/
/*****************************************************************************/
static long Exa_GetParamsExamAnnouncement (void)
{
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) *****/
2017-03-08 14:12:33 +01:00
Par_GetParToText ("CrsName",Gbl.ExamAnns.ExaDat.CrsFullName,Hie_MAX_BYTES_FULL_NAME);
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
2017-01-15 18:02:52 +01:00
if (!Gbl.ExamAnns.ExaDat.CrsFullName[0])
2019-04-04 10:45:15 +02:00
Str_Copy (Gbl.ExamAnns.ExaDat.CrsFullName,Gbl.Hierarchy.Crs.FullName,
2017-03-08 14:12:33 +01:00
Hie_MAX_BYTES_FULL_NAME);
2014-12-01 23:55:08 +01:00
/***** Get the year *****/
2017-01-29 21:41:08 +01:00
Gbl.ExamAnns.ExaDat.Year = (unsigned)
Par_GetParToUnsignedLong ("Year",
0, // N.A.
Deg_MAX_YEARS_PER_DEGREE,
2019-04-04 10:45:15 +02:00
(unsigned long) Gbl.Hierarchy.Crs.Year);
2014-12-01 23:55:08 +01:00
/***** Get the type of exam announcement *****/
2017-03-08 14:12:33 +01:00
Par_GetParToText ("ExamSession",Gbl.ExamAnns.ExaDat.Session,Exa_MAX_BYTES_SESSION);
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",
2017-01-15 18:02:52 +01:00
&Gbl.ExamAnns.ExaDat.ExamDate.Day,
&Gbl.ExamAnns.ExaDat.ExamDate.Month,
&Gbl.ExamAnns.ExaDat.ExamDate.Year);
if (Gbl.ExamAnns.ExaDat.ExamDate.Day == 0 ||
Gbl.ExamAnns.ExaDat.ExamDate.Month == 0 ||
Gbl.ExamAnns.ExaDat.ExamDate.Year == 0)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.ExamDate.Day = Gbl.Now.Date.Day;
Gbl.ExamAnns.ExaDat.ExamDate.Month = Gbl.Now.Date.Month;
Gbl.ExamAnns.ExaDat.ExamDate.Year = Gbl.Now.Date.Year;
2014-12-01 23:55:08 +01:00
}
/***** Get the hour of the exam *****/
2017-01-29 21:41:08 +01:00
Gbl.ExamAnns.ExaDat.StartTime.Hour = (unsigned) Par_GetParToUnsignedLong ("ExamHour",
0,23,0);
Gbl.ExamAnns.ExaDat.StartTime.Minute = (unsigned) Par_GetParToUnsignedLong ("ExamMinute",
0,59,0);
2014-12-01 23:55:08 +01:00
/***** Get the duration of the exam *****/
2017-01-29 21:41:08 +01:00
Gbl.ExamAnns.ExaDat.Duration.Hour = (unsigned) Par_GetParToUnsignedLong ("DurationHour",
0,23,0);
Gbl.ExamAnns.ExaDat.Duration.Minute = (unsigned) Par_GetParToUnsignedLong ("DurationMinute",
0,59,0);
2014-12-01 23:55:08 +01:00
/***** Get the place where the exam will happen *****/
2017-01-15 18:02:52 +01:00
Par_GetParToHTML ("Place",Gbl.ExamAnns.ExaDat.Place,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the modality of exam *****/
2017-01-15 18:02:52 +01:00
Par_GetParToHTML ("ExamMode",Gbl.ExamAnns.ExaDat.Mode,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the structure of exam *****/
2017-01-15 18:02:52 +01:00
Par_GetParToHTML ("Structure",Gbl.ExamAnns.ExaDat.Structure,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the mandatory documentation *****/
2017-01-15 18:02:52 +01:00
Par_GetParToHTML ("DocRequired",Gbl.ExamAnns.ExaDat.DocRequired,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the mandatory material *****/
2017-01-15 18:02:52 +01:00
Par_GetParToHTML ("MatRequired",Gbl.ExamAnns.ExaDat.MatRequired,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get the allowed material *****/
2017-01-15 18:02:52 +01:00
Par_GetParToHTML ("MatAllowed",Gbl.ExamAnns.ExaDat.MatAllowed,Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
/***** Get other information *****/
2017-01-15 18:02:52 +01:00
Par_GetParToHTML ("OtherInfo",Gbl.ExamAnns.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)
{
2018-10-08 12:37:29 +02:00
if ((Gbl.ExamAnns.ExaDat.Place = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
2018-10-08 12:37:29 +02:00
if ((Gbl.ExamAnns.ExaDat.Mode = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
2018-10-08 12:37:29 +02:00
if ((Gbl.ExamAnns.ExaDat.Structure = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
2018-10-08 12:37:29 +02:00
if ((Gbl.ExamAnns.ExaDat.DocRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
2018-10-08 12:37:29 +02:00
if ((Gbl.ExamAnns.ExaDat.MatRequired = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
2018-10-08 12:37:29 +02:00
if ((Gbl.ExamAnns.ExaDat.MatAllowed = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
2018-10-08 12:37:29 +02:00
if ((Gbl.ExamAnns.ExaDat.OtherInfo = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/* Free memory of those parameters of an exam announcem. with a lot of text **/
/*****************************************************************************/
void Exa_FreeMemExamAnnouncement (void)
{
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Place)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.ExaDat.Place);
Gbl.ExamAnns.ExaDat.Place = NULL;
2014-12-01 23:55:08 +01:00
}
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Mode)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.ExaDat.Mode);
Gbl.ExamAnns.ExaDat.Mode = NULL;
2014-12-01 23:55:08 +01:00
}
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Structure)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.ExaDat.Structure);
Gbl.ExamAnns.ExaDat.Structure = NULL;
2014-12-01 23:55:08 +01:00
}
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.DocRequired)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.ExaDat.DocRequired);
Gbl.ExamAnns.ExaDat.DocRequired = NULL;
2014-12-01 23:55:08 +01:00
}
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.MatRequired)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.ExaDat.MatRequired);
Gbl.ExamAnns.ExaDat.MatRequired = NULL;
2014-12-01 23:55:08 +01:00
}
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.MatAllowed)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.ExaDat.MatAllowed);
Gbl.ExamAnns.ExaDat.MatAllowed = NULL;
2014-12-01 23:55:08 +01:00
}
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.OtherInfo)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.ExaDat.OtherInfo);
Gbl.ExamAnns.ExaDat.OtherInfo = NULL;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/************************ Receive an exam announcement ***********************/
/*****************************************************************************/
2016-12-12 09:38:46 +01:00
// This function is splitted into a-priori and a-posteriori functions
// in order to view updated links in month of left column
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
void Exa_ReceiveExamAnnouncement1 (void)
2014-12-01 23:55:08 +01:00
{
2019-03-25 19:05:10 +01:00
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;
char *Anchor = NULL;
2014-12-01 23:55:08 +01:00
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get parameters of the exam announcement *****/
2019-03-25 19:05:10 +01:00
ExaCod = Exa_GetParamsExamAnnouncement ();
NewExamAnnouncement = (ExaCod < 0);
2014-12-01 23:55:08 +01:00
/***** Add the exam announcement to the database and read it again from the database *****/
2019-03-25 19:05:10 +01:00
if (NewExamAnnouncement)
Gbl.ExamAnns.NewExaCod = ExaCod = Exa_AddExamAnnouncementToDB ();
2014-12-01 23:55:08 +01:00
else
2019-03-25 19:05:10 +01:00
Exa_ModifyExamAnnouncementInDB (ExaCod);
2014-12-01 23:55:08 +01:00
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
2019-03-25 19:05:10 +01:00
/***** Create alert to show the change made *****/
Exa_SetAnchorStr (ExaCod,&Anchor);
Ale_CreateAlert (Ale_SUCCESS,Anchor,
NewExamAnnouncement ? Txt_Created_new_announcement_of_exam :
Txt_The_announcement_of_exam_has_been_successfully_updated);
Exa_FreeAnchorStr (Anchor);
/***** Set exam to be highlighted *****/
Gbl.ExamAnns.HighlightExaCod = ExaCod;
2016-12-12 02:21:41 +01:00
}
void Exa_ReceiveExamAnnouncement2 (void)
{
unsigned NumUsrsToBeNotifiedByEMail;
2019-03-12 21:25:55 +01:00
struct TL_Publication SocPub;
2014-12-01 23:55:08 +01:00
2016-11-16 23:19:52 +01:00
/***** Notify by email about the new exam announcement *****/
2019-03-25 19:05:10 +01:00
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_EXAM_ANNOUNCEMENT,Gbl.ExamAnns.HighlightExaCod)))
Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (Gbl.ExamAnns.HighlightExaCod,NumUsrsToBeNotifiedByEMail);
2014-12-01 23:55:08 +01:00
2015-12-31 14:25:28 +01:00
/***** Create a new social note about the new exam announcement *****/
2019-03-25 19:05:10 +01:00
TL_StoreAndPublishNote (TL_NOTE_EXAM_ANNOUNCEMENT,Gbl.ExamAnns.HighlightExaCod,&SocPub);
2014-12-01 23:55:08 +01:00
/***** Update RSS of current course *****/
2019-04-04 10:45:15 +02:00
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Crs);
2016-12-12 02:21:41 +01:00
2019-03-25 19:05:10 +01:00
/***** Show exam announcements *****/
2016-12-12 02:21:41 +01:00
Exa_ListExamAnnouncementsEdit ();
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/***** Update number of users notified in table of exam announcements ********/
/*****************************************************************************/
static void Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (long ExaCod,unsigned NumUsrsToBeNotifiedByEMail)
{
/***** Update number of users notified *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update the number of notifications"
" of an exam announcement",
"UPDATE exam_announcements SET NumNotif=NumNotif+%u"
" WHERE ExaCod=%ld",
NumUsrsToBeNotifiedByEMail,ExaCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/************************* Print an exam announcement ************************/
/*****************************************************************************/
void Exa_PrintExamAnnouncement (void)
{
2019-03-25 19:05:10 +01:00
long ExaCod;
2014-12-01 23:55:08 +01:00
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get the code of the exam announcement *****/
2019-03-25 19:05:10 +01: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 *****/
2019-03-25 19:05:10 +01:00
Exa_GetDataExamAnnouncementFromDB (ExaCod);
2014-12-01 23:55:08 +01:00
/***** Show exam announcement *****/
2019-03-25 19:05:10 +01:00
Exa_ShowExamAnnouncement (ExaCod,Exa_PRINT_VIEW,
false); // Don't highlight
2014-12-01 23:55:08 +01:00
/***** Free memory of the exam announcement *****/
Exa_FreeMemExamAnnouncement ();
}
/*****************************************************************************/
/************************ Remove an exam announcement ************************/
/*****************************************************************************/
2016-12-11 21:02:22 +01:00
void Exa_ReqRemoveExamAnnouncement (void)
{
extern const char *Txt_Do_you_really_want_to_remove_the_following_announcement_of_exam;
extern const char *Txt_Remove;
2019-03-25 19:05:10 +01:00
long ExaCod;
2016-12-11 21:02:22 +01:00
/***** Get the code of the exam announcement *****/
2019-03-25 19:05:10 +01:00
if ((ExaCod = Exa_GetParamExaCod ()) <= 0)
2016-12-11 21:02:22 +01:00
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
2017-04-28 12:11:25 +02:00
/***** Show question and button to remove exam announcement *****/
/* Start alert */
2017-05-11 23:45:46 +02:00
Ale_ShowAlertAndButton1 (Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_following_announcement_of_exam);
2016-12-11 21:02:22 +01:00
2017-04-28 12:11:25 +02:00
/* Show announcement */
2016-12-11 21:02:22 +01:00
Exa_AllocMemExamAnnouncement ();
2019-03-25 19:05:10 +01:00
Exa_GetDataExamAnnouncementFromDB (ExaCod);
Exa_ShowExamAnnouncement (ExaCod,Exa_NORMAL_VIEW,
false); // Don't highlight
2016-12-11 21:02:22 +01:00
Exa_FreeMemExamAnnouncement ();
2017-04-28 12:11:25 +02:00
/* End alert */
2019-03-25 19:05:10 +01:00
2017-05-25 14:25:22 +02:00
Ale_ShowAlertAndButton2 (ActRemExaAnn,NULL,NULL,Exa_PutParamExaCodToEdit,
2017-06-11 19:02:40 +02:00
Btn_REMOVE_BUTTON,Txt_Remove);
2016-12-11 21:02:22 +01:00
}
/*****************************************************************************/
/************************ Remove an exam announcement ************************/
/*****************************************************************************/
2016-12-12 09:38:46 +01:00
// This function is splitted into a-priori and a-posteriori functions
// in order to view updated links in month of left column
2016-12-11 21:02:22 +01:00
2016-12-12 02:21:41 +01:00
void Exa_RemoveExamAnnouncement1 (void)
2014-12-01 23:55:08 +01:00
{
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 *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not remove exam announcement",
"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT,
2019-04-04 10:45:15 +02:00
ExaCod,Gbl.Hierarchy.Crs.CrsCod);
2014-12-01 23:55:08 +01:00
/***** 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 *****/
2019-03-12 21:25:55 +01:00
TL_MarkNoteAsUnavailableUsingNoteTypeAndCod (TL_NOTE_EXAM_ANNOUNCEMENT,ExaCod);
2016-01-03 19:34:40 +01:00
2016-12-12 02:21:41 +01:00
/***** Update RSS of current course *****/
2019-04-04 10:45:15 +02:00
RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Crs);
2016-12-12 02:21:41 +01:00
}
void Exa_RemoveExamAnnouncement2 (void)
{
extern const char *Txt_Announcement_of_exam_removed;
2014-12-01 23:55:08 +01:00
/***** Write message *****/
2019-02-16 14:37:34 +01:00
Ale_ShowAlert (Ale_SUCCESS,Txt_Announcement_of_exam_removed);
2014-12-01 23:55:08 +01:00
/***** List again all the remaining exam announcements *****/
Exa_ListExamAnnouncementsEdit ();
2016-12-12 02:21:41 +01:00
}
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/*****************************************************************************/
/************************ Hide an exam announcement **************************/
/*****************************************************************************/
2016-12-12 09:38:46 +01:00
// This function is splitted into a-priori and a-posteriori functions
// in order to view updated links in month of left column
2016-12-12 02:21:41 +01:00
2019-03-25 19:05:10 +01:00
void Exa_HideExamAnnouncement (void)
2016-12-12 02:21:41 +01:00
{
2019-03-25 19:05:10 +01:00
extern const char *Txt_The_announcement_of_exam_is_now_hidden;
2016-12-12 02:21:41 +01:00
long ExaCod;
2019-03-25 19:05:10 +01:00
char *Anchor = NULL;
2016-12-12 02:21:41 +01:00
/***** Get the code of the exam announcement *****/
if ((ExaCod = Exa_GetParamExaCod ()) <= 0)
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Mark the exam announcement as hidden in the database *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not hide exam announcement",
"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_HIDDEN_EXAM_ANNOUNCEMENT,
2019-04-04 10:45:15 +02:00
ExaCod,Gbl.Hierarchy.Crs.CrsCod);
2016-12-12 02:21:41 +01:00
2019-03-25 19:05:10 +01:00
/***** Set exam to be highlighted *****/
Gbl.ExamAnns.HighlightExaCod = ExaCod;
2016-12-12 02:21:41 +01:00
2019-03-25 19:05:10 +01:00
/***** Create alert to show the change made *****/
Exa_SetAnchorStr (ExaCod,&Anchor);
Ale_CreateAlert (Ale_SUCCESS,Anchor,
Txt_The_announcement_of_exam_is_now_hidden);
Exa_FreeAnchorStr (Anchor);
2016-12-12 02:21:41 +01:00
}
/*****************************************************************************/
/************************ Unhide an exam announcement ************************/
/*****************************************************************************/
2016-12-12 09:38:46 +01:00
// This function is splitted into a-priori and a-posteriori functions
// in order to view updated links in month of left column
2016-12-12 02:21:41 +01:00
2019-03-25 19:05:10 +01:00
void Exa_UnhideExamAnnouncement (void)
2016-12-12 02:21:41 +01:00
{
2019-03-25 19:05:10 +01:00
extern const char *Txt_The_announcement_of_exam_is_now_visible;
2016-12-12 02:21:41 +01:00
long ExaCod;
2019-03-25 19:05:10 +01:00
char *Anchor = NULL;
2016-12-12 02:21:41 +01:00
/***** Get the code of the exam announcement *****/
if ((ExaCod = Exa_GetParamExaCod ()) <= 0)
Lay_ShowErrorAndExit ("Code of exam announcement is missing.");
/***** Mark the exam announcement as visible in the database *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not unhide exam announcement",
"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT,
2019-04-04 10:45:15 +02:00
ExaCod,Gbl.Hierarchy.Crs.CrsCod);
2016-12-12 02:21:41 +01:00
2019-03-25 19:05:10 +01:00
/***** Set exam to be highlighted *****/
Gbl.ExamAnns.HighlightExaCod = ExaCod;
2016-12-12 02:21:41 +01:00
2019-03-25 19:05:10 +01:00
/***** Create alert to show the change made *****/
Exa_SetAnchorStr (ExaCod,&Anchor);
Ale_CreateAlert (Ale_SUCCESS,Anchor,
Txt_The_announcement_of_exam_is_now_visible);
Exa_FreeAnchorStr (Anchor);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/*************** 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,
2019-04-04 10:45:15 +02:00
-1L,Gbl.Hierarchy.Crs.CrsCod,
2016-06-01 13:43:22 +02:00
Gbl.Usrs.Me.UsrDat.UsrCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/********** List all the exam announcements to edit or remove them ***********/
/*****************************************************************************/
2019-03-25 19:05:10 +01:00
void Exa_ListExamAnnouncementsEdit (void)
2014-12-01 23:55:08 +01:00
{
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 *****/
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.HighlightExaCod = Exa_GetParamExaCod ();
2016-06-03 10:37:00 +02:00
}
/*****************************************************************************/
/*********** Get date of exam announcements to show highlighted **************/
/*****************************************************************************/
void Exa_GetDateToHighlight (void)
2016-06-01 19:34:44 +02:00
{
2019-03-25 19:05:10 +01:00
/***** Get the date (in YYYYMMDD format)
2016-06-01 19:34:44 +02:00
of the exam announcements to highlight *****/
2019-03-25 19:05:10 +01:00
Par_GetParToText ("Date",Gbl.ExamAnns.HighlightDate,4 + 2 + 2);
2016-06-01 19:34:44 +02:00
}
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_Announcements_of_exams;
2014-12-01 23:55:08 +01:00
extern const char *Txt_No_announcements_of_exams_of_X;
2016-12-12 02:21:41 +01:00
char SubQueryStatus[64];
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-01 13:43:22 +02:00
unsigned long NumExaAnn;
unsigned long NumExaAnns;
2019-03-25 19:05:10 +01:00
long ExaCod;
bool HighLight;
2017-06-04 18:18:54 +02:00
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
2016-06-01 13:43:22 +02:00
2016-12-12 02:21:41 +01:00
/***** Build subquery about status depending on my role *****/
if (ICanEdit)
2017-03-24 01:09:27 +01:00
sprintf (SubQueryStatus,"Status<>%u",
2016-12-12 02:21:41 +01:00
(unsigned) Exa_DELETED_EXAM_ANNOUNCEMENT);
else
2017-03-24 01:09:27 +01:00
sprintf (SubQueryStatus,"Status=%u",
2016-12-12 02:21:41 +01:00
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT);
2016-06-01 13:43:22 +02:00
/***** Get exam announcements (the most recent first)
in current course from database *****/
2018-10-30 23:56:45 +01:00
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get exam announcements"
" in this course for listing",
"SELECT ExaCod"
" FROM exam_announcements"
" WHERE CrsCod=%ld AND %s"
" ORDER BY ExamDate DESC",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,SubQueryStatus);
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Start box *****/
2019-03-25 19:05:10 +01:00
Box_StartBox (NULL,Txt_Announcements_of_exams,
2017-06-11 22:26:40 +02:00
ICanEdit ? Exa_PutIconToCreateNewExamAnnouncement :
NULL,
2017-06-12 15:03:29 +02:00
Hlp_ASSESSMENT_Announcements,Box_NOT_CLOSABLE);
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)
2019-02-16 14:37:34 +01:00
Ale_ShowAlert (Ale_INFO,Txt_No_announcements_of_exams_of_X,
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.FullName);
2014-12-01 23:55:08 +01:00
/***** 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);
2019-03-25 19:05:10 +01:00
if (sscanf (row[0],"%ld",&ExaCod) != 1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong code of exam announcement.");
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Read the data of the exam announcement *****/
2019-03-25 19:05:10 +01:00
Exa_GetDataExamAnnouncementFromDB (ExaCod);
2014-12-01 23:55:08 +01:00
/***** Show exam announcement *****/
2019-03-25 19:05:10 +01:00
HighLight = false;
if (ExaCod == Gbl.ExamAnns.HighlightExaCod)
HighLight = true;
else if (Gbl.ExamAnns.HighlightDate[0])
{
if (!strcmp (Gbl.ExamAnns.ExaDat.ExamDate.YYYYMMDD,
Gbl.ExamAnns.HighlightDate))
HighLight = true;
}
Exa_ShowExamAnnouncement (ExaCod,TypeViewExamAnnouncement,
HighLight);
2014-12-01 23:55:08 +01:00
/***** 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
2017-05-29 21:34:43 +02:00
/***** Button to create a new exam announcement *****/
2016-06-01 13:43:22 +02:00
if (ICanEdit)
Exa_PutButtonToCreateNewExamAnnouncement ();
2017-06-12 14:16:33 +02:00
/***** End box *****/
2017-06-10 21:38:10 +02:00
Box_EndBox ();
2016-06-01 13:43:22 +02:00
}
/*****************************************************************************/
/***************** Put icon to create a new exam announcement ****************/
/*****************************************************************************/
static void Exa_PutIconToCreateNewExamAnnouncement (void)
{
extern const char *Txt_New_announcement_OF_EXAM;
2019-01-10 15:26:33 +01:00
Ico_PutContextualIconToAdd (ActEdiExaAnn,NULL,NULL,
Txt_New_announcement_OF_EXAM);
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;
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActEdiExaAnn);
2017-06-11 19:02:40 +02:00
Btn_PutConfirmButton (Txt_New_announcement_OF_EXAM);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
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)
{
long ExaCod;
/***** Add exam announcement *****/
2018-11-03 01:45:36 +01:00
ExaCod =
DB_QueryINSERTandReturnCode ("can not create a new exam announcement",
"INSERT INTO exam_announcements "
"(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,"
"Place,ExamMode,Structure,DocRequired,MatRequired,MatAllowed,OtherInfo)"
" VALUES "
"(%ld,%u,0,'%s',%u,'%s',"
"NOW(),'%04u-%02u-%02u %02u:%02u:00','%02u:%02u:00','%s',"
"'%s','%s','%s','%s','%s','%s')",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-11-03 01:45:36 +01:00
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT,
Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnns.ExaDat.Year,
Gbl.ExamAnns.ExaDat.Session,
Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.StartTime.Minute,
Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnns.ExaDat.Duration.Minute,
Gbl.ExamAnns.ExaDat.Place,
Gbl.ExamAnns.ExaDat.Mode,
Gbl.ExamAnns.ExaDat.Structure,
Gbl.ExamAnns.ExaDat.DocRequired,
Gbl.ExamAnns.ExaDat.MatRequired,
Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnns.ExaDat.OtherInfo);
2014-12-01 23:55:08 +01:00
return ExaCod;
}
/*****************************************************************************/
/*************** Modify an exam announcement in the database *****************/
/*****************************************************************************/
2019-03-25 19:05:10 +01:00
static void Exa_ModifyExamAnnouncementInDB (long ExaCod)
2014-12-01 23:55:08 +01:00
{
/***** Modify exam announcement *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not update an exam announcement",
"UPDATE exam_announcements"
" SET CrsFullName='%s',Year=%u,ExamSession='%s',"
"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'"
" WHERE ExaCod=%ld",
Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnns.ExaDat.Year,
Gbl.ExamAnns.ExaDat.Session,
Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.StartTime.Minute,
Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnns.ExaDat.Duration.Minute,
Gbl.ExamAnns.ExaDat.Place,
Gbl.ExamAnns.ExaDat.Mode,
Gbl.ExamAnns.ExaDat.Structure,
Gbl.ExamAnns.ExaDat.DocRequired,
Gbl.ExamAnns.ExaDat.MatRequired,
Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnns.ExaDat.OtherInfo,
2019-03-25 19:05:10 +01:00
ExaCod);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******* Create a list with the dates of all the exam announcements **********/
/*****************************************************************************/
2016-12-12 02:21:41 +01:00
void Exa_CreateListDatesOfExamAnnouncements (void)
2014-12-01 23:55:08 +01:00
{
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)
{
2019-03-25 19:05:10 +01:00
/***** Get exam dates (ordered from more recent to older)
2016-12-12 02:21:41 +01:00
of visible exam announcements
2016-06-01 13:43:22 +02:00
in current course from database *****/
2018-10-30 23:56:45 +01:00
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get exam announcements"
" in this course",
2019-03-25 19:05:10 +01:00
"SELECT ExaCod,DATE(ExamDate)"
2018-10-30 23:56:45 +01:00
" FROM exam_announcements"
2019-03-25 19:05:10 +01:00
" WHERE CrsCod=%ld AND Status=%u"
" ORDER BY ExamDate DESC",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
2018-10-30 23:56:45 +01:00
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT);
2014-12-01 23:55:08 +01:00
/***** The result of the query may be empty *****/
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.Lst = NULL;
Gbl.ExamAnns.NumExaAnns = 0;
2016-06-01 13:43:22 +02:00
if (NumExaAnns)
2014-12-01 23:55:08 +01:00
{
/***** Allocate memory for the list *****/
2019-03-25 19:05:10 +01:00
if ((Gbl.ExamAnns.Lst = (struct Exa_ExamCodeAndDate *) calloc (NumExaAnns,sizeof (struct Exa_ExamCodeAndDate))) == NULL)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
/***** 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);
2019-03-25 19:05:10 +01:00
/* Get exam code (row[0]) */
Gbl.ExamAnns.Lst[Gbl.ExamAnns.NumExaAnns].ExaCod = Str_ConvertStrCodToLongCod (row[0]);
/* Read the date of the exam (row[1]) */
if (sscanf (row[1],"%04u-%02u-%02u",
&Gbl.ExamAnns.Lst[Gbl.ExamAnns.NumExaAnns].ExamDate.Year,
&Gbl.ExamAnns.Lst[Gbl.ExamAnns.NumExaAnns].ExamDate.Month,
&Gbl.ExamAnns.Lst[Gbl.ExamAnns.NumExaAnns].ExamDate.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 *****/
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.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)
{
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.Lst)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
free ((void *) Gbl.ExamAnns.Lst);
Gbl.ExamAnns.Lst = NULL;
Gbl.ExamAnns.NumExaAnns = 0;
2014-12-01 23:55:08 +01:00
}
}
/*****************************************************************************/
/******** Read the data of an exam announcement from the database ************/
/*****************************************************************************/
2019-03-25 19:05:10 +01:00
static void Exa_GetDataExamAnnouncementFromDB (long ExaCod)
2014-12-01 23:55:08 +01:00
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-01 13:43:22 +02:00
unsigned long NumExaAnns;
2016-12-12 02:21:41 +01:00
unsigned UnsignedNum;
2016-06-01 13:43:22 +02:00
unsigned Hour;
unsigned Minute;
unsigned Second;
2014-12-01 23:55:08 +01:00
/***** Get data of an exam announcement from database *****/
2018-10-30 23:56:45 +01:00
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get data"
" of an exam announcement",
"SELECT CrsCod,Status,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,Place,ExamMode,"
"Structure,DocRequired,MatRequired,MatAllowed,OtherInfo"
" FROM exam_announcements WHERE ExaCod=%ld",
2019-03-25 19:05:10 +01:00
ExaCod);
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]) */
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Status of the exam announcement (row[1]) */
if (sscanf (row[1],"%u",&UnsignedNum) != 1)
Lay_ShowErrorAndExit ("Wrong status.");
if (UnsignedNum >= Exa_NUM_STATUS)
Lay_ShowErrorAndExit ("Wrong status.");
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Status = (Exa_ExamAnnouncementStatus_t) UnsignedNum;
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Name of the course (row[2]) */
2017-01-15 18:02:52 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.CrsFullName,row[2],
2017-03-08 14:12:33 +01:00
Hie_MAX_BYTES_FULL_NAME);
2016-12-12 02:21:41 +01:00
/* Year (row[3]) */
2017-01-15 18:02:52 +01:00
if (sscanf (row[3],"%u",&Gbl.ExamAnns.ExaDat.Year) != 1)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong year.");
2016-12-12 02:21:41 +01:00
/* Exam session (row[4]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.Session,row[4],
2017-03-08 14:12:33 +01:00
Exa_MAX_BYTES_SESSION);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Date of exam announcement (row[5]) */
if (sscanf (row[5],"%04u-%02u-%02u %02u:%02u:%02u",
2017-01-15 18:02:52 +01:00
&Gbl.ExamAnns.ExaDat.CallDate.Year,
&Gbl.ExamAnns.ExaDat.CallDate.Month,
&Gbl.ExamAnns.ExaDat.CallDate.Day,
2019-03-25 19:05:10 +01:00
&Hour,
&Minute,
&Second) != 6)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong date of exam announcement.");
2016-12-12 02:21:41 +01:00
/* Date of exam (row[6]) */
if (sscanf (row[6],"%04u-%02u-%02u %02u:%02u:%02u",
2019-03-25 19:05:10 +01:00
&Gbl.ExamAnns.ExaDat.ExamDate.Year,
&Gbl.ExamAnns.ExaDat.ExamDate.Month,
&Gbl.ExamAnns.ExaDat.ExamDate.Day,
&Gbl.ExamAnns.ExaDat.StartTime.Hour,
&Gbl.ExamAnns.ExaDat.StartTime.Minute,
&Second) != 6)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong date of exam.");
2019-03-25 19:05:10 +01:00
snprintf (Gbl.ExamAnns.ExaDat.ExamDate.YYYYMMDD,sizeof (Gbl.ExamAnns.ExaDat.ExamDate.YYYYMMDD),
"%04u%02u%02u",
Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnns.ExaDat.ExamDate.Day);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Approximate duration (row[7]) */
2017-01-15 18:02:52 +01:00
if (sscanf (row[7],"%02u:%02u:%02u",&Gbl.ExamAnns.ExaDat.Duration.Hour,&Gbl.ExamAnns.ExaDat.Duration.Minute,&Second) != 3)
2014-12-01 23:55:08 +01:00
Lay_ShowErrorAndExit ("Wrong duration of exam.");
2016-12-12 02:21:41 +01:00
/* Place (row[8]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.Place,row[8],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Exam mode (row[9]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.Mode,row[9],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Structure (row[10]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.Structure,row[10],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Documentation required (row[11]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.DocRequired,row[11],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Material required (row[12]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.MatRequired,row[12],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Material allowed (row[13]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.MatAllowed,row[13],
Cns_MAX_BYTES_TEXT);
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/* Other information for students (row[14]) */
2017-01-17 03:10:43 +01:00
Str_Copy (Gbl.ExamAnns.ExaDat.OtherInfo,row[14],
Cns_MAX_BYTES_TEXT);
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 **************/
/*****************************************************************************/
2019-03-25 19:05:10 +01:00
static void Exa_ShowExamAnnouncement (long ExaCod,
Exa_TypeViewExamAnnouncement_t TypeViewExamAnnouncement,
bool HighLight)
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;
2017-01-28 15:58:46 +01:00
extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE];
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[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;
2017-03-07 11:03:05 +01:00
char StrExamDate[Cns_MAX_BYTES_DATE + 1];
2017-05-05 02:03:28 +02:00
unsigned Year;
unsigned Hour;
unsigned Minute;
2019-03-25 19:05:10 +01:00
char *Anchor = NULL;
const char *Width;
void (*FunctionToDrawContextualIcons) (void);
const char *HelpLink;
2016-12-27 11:33:13 +01:00
const char *ClassExaAnnouncement[Exa_NUM_VIEWS][Exa_NUM_STATUS] =
2016-12-12 02:21:41 +01:00
{
2016-12-27 11:33:13 +01:00
{ // Exa_NORMAL_VIEW
"EXA_ANN_VISIBLE", // Exa_VISIBLE_EXAM_ANNOUNCEMENT
"EXA_ANN_HIDDEN", // Exa_HIDDEN_EXAM_ANNOUNCEMENT
NULL, // Exa_DELETED_EXAM_ANNOUNCEMENT, Not applicable here
},
{ // Exa_PRINT_VIEW
"EXA_ANN_VISIBLE", // Exa_VISIBLE_EXAM_ANNOUNCEMENT
"EXA_ANN_VISIBLE", // Exa_HIDDEN_EXAM_ANNOUNCEMENT
NULL, // Exa_DELETED_EXAM_ANNOUNCEMENT, Not applicable here
},
{ // Exa_FORM_VIEW
"EXA_ANN_VISIBLE", // Exa_VISIBLE_EXAM_ANNOUNCEMENT
"EXA_ANN_VISIBLE", // Exa_HIDDEN_EXAM_ANNOUNCEMENT
NULL, // Exa_DELETED_EXAM_ANNOUNCEMENT, Not applicable here
},
2016-12-12 02:21:41 +01:00
};
2014-12-01 23:55:08 +01:00
/***** Get data of institution of this degree *****/
2019-04-03 20:57:04 +02:00
Ins.InsCod = Gbl.Hierarchy.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:
2019-02-22 21:47:50 +01:00
StyleForm = The_ClassFormInBox[Gbl.Prefs.Theme];
2014-12-01 23:55:08 +01:00
break;
}
2019-03-25 19:05:10 +01:00
/***** Build anchor string *****/
Exa_SetAnchorStr (ExaCod,&Anchor);
/***** Start article *****/
if (TypeViewExamAnnouncement == Exa_NORMAL_VIEW)
Lay_StartArticle (Anchor);
2017-06-12 14:16:33 +02:00
/***** Start box *****/
2019-03-25 19:05:10 +01:00
Width = "625px";
Gbl.ExamAnns.Anchor = Anchor; // Used to put contextual icons
Gbl.ExamAnns.ExaCod = ExaCod; // Used to put contextual icons
FunctionToDrawContextualIcons = TypeViewExamAnnouncement == Exa_NORMAL_VIEW ? Exa_PutIconsExamAnnouncement :
NULL;
HelpLink = TypeViewExamAnnouncement == Exa_FORM_VIEW ? ((ExaCod > 0) ? Hlp_ASSESSMENT_Announcements_edit_announcement :
Hlp_ASSESSMENT_Announcements_new_announcement) :
NULL;
if (HighLight)
{
/* Show pending alerts */
Ale_ShowAlerts (Anchor);
/* Start highlighted box */
Box_StartBoxShadow (Width,NULL,FunctionToDrawContextualIcons,HelpLink);
}
else // Don't highlight
/* Start normal box */
Box_StartBox (Width,NULL,FunctionToDrawContextualIcons,HelpLink,
Box_NOT_CLOSABLE);
2015-04-01 12:54:25 +02:00
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
{
/***** Start form *****/
2019-03-25 19:05:10 +01:00
Frm_StartFormAnchor (ActRcvExaAnn,Anchor);
if (ExaCod > 0) // Existing announcement of exam
Exa_PutHiddenParamExaCod (ExaCod);
2015-04-01 12:54:25 +02:00
}
2016-12-12 02:21:41 +01:00
/***** Start table *****/
fprintf (Gbl.F.Out,"<table class=\"%s CELLS_PAD_2\">",
2017-01-15 18:02:52 +01:00
ClassExaAnnouncement[TypeViewExamAnnouncement][Gbl.ExamAnns.ExaDat.Status]);
2014-12-01 23:55:08 +01:00
/***** Institution logo *****/
2016-12-27 11:33:13 +01:00
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);
2019-04-03 20:57:04 +02:00
Log_DrawLogo (Hie_INS,Ins.InsCod,Ins.FullName,64,NULL,true);
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<br />%s%s"
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>",
Ins.FullName,
TypeViewExamAnnouncement == Exa_PRINT_VIEW ? "</span>" :
"</a>");
/***** Degree *****/
2016-12-27 11:33:13 +01:00
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\">",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.WWW,StyleTitle);
fprintf (Gbl.F.Out,"%s",Gbl.Hierarchy.Deg.FullName);
2014-12-01 23:55:08 +01:00
if (TypeViewExamAnnouncement == Exa_NORMAL_VIEW)
fprintf (Gbl.F.Out,"</a>");
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Title *****/
2016-12-27 11:33:13 +01:00
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>"
2016-12-27 11:33:13 +01:00
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>",
StyleNormal,Txt_EXAM_ANNOUNCEMENT);
2016-12-27 11:33:13 +01:00
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;"
2016-12-27 11:33:13 +01:00
"</td>"
2014-12-01 23:55:08 +01:00
"</tr>",
StyleNormal);
/***** Name of the course *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_BOTTOM\">"
"<label for=\"CrsName\" class=\"%s\">%s:</label>"
"</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)
{
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\" id=\"CrsName\" name=\"CrsName\""
2015-04-01 12:54:25 +02:00
" size=\"30\" maxlength=\"%u\" value=\"%s\" />",
2017-03-08 14:12:33 +01:00
Hie_MAX_CHARS_FULL_NAME,Gbl.ExamAnns.ExaDat.CrsFullName);
2014-12-01 23:55:08 +01:00
}
else
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<strong>%s</strong>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.CrsFullName);
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
2016-12-11 14:29:26 +01:00
/***** Year/semester (N.A., 1<>, 2<>, 3<>, 4<>, 5<>...) *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_BOTTOM\">"
"<label for=\"Year\" class=\"%s\">%s:</label>"
"</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)
{
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<select id=\"Year\" name=\"Year\">");
2014-12-01 23:55:08 +01:00
for (Year = 0;
Year <= Deg_MAX_YEARS_PER_DEGREE;
Year++)
{
fprintf (Gbl.F.Out,"<option");
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Year == Year)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," selected=\"selected\"");
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out," value=\"%u\">"
"%s"
"</option>",
Year,Txt_YEAR_OF_DEGREE[Year]);
2014-12-01 23:55:08 +01:00
}
fprintf (Gbl.F.Out,"</select>");
}
else
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"%s",
2017-01-15 18:02:52 +01:00
Txt_YEAR_OF_DEGREE[Gbl.ExamAnns.ExaDat.Year]);
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Exam session *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_BOTTOM\">"
"<label for=\"ExamSession\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<input type=\"text\""
" id=\"ExamSession\" name=\"ExamSession\""
2015-04-01 12:54:25 +02:00
" size=\"30\" maxlength=\"%u\" value=\"%s\" />",
2017-03-08 14:12:33 +01:00
Exa_MAX_CHARS_SESSION,Gbl.ExamAnns.ExaDat.Session);
2014-12-01 23:55:08 +01:00
else
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Session);
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Date of the exam *****/
2016-12-27 11:33:13 +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>",
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\">");
2017-01-15 18:02:52 +01:00
Dat_WriteFormDate (Gbl.ExamAnns.ExaDat.ExamDate.Year < Gbl.Now.Date.Year ? Gbl.ExamAnns.ExaDat.ExamDate.Year :
2017-05-05 02:03:28 +02:00
Gbl.Now.Date.Year,
2015-10-23 01:06:32 +02:00
Gbl.Now.Date.Year + 1,"Exam",
2017-01-15 18:02:52 +01:00
&(Gbl.ExamAnns.ExaDat.ExamDate),
2014-12-01 23:55:08 +01:00
false,false);
fprintf (Gbl.F.Out,"</td>");
}
else
{
2017-01-15 18:02:52 +01:00
Dat_ConvDateToDateStr (&Gbl.ExamAnns.ExaDat.ExamDate,
2016-12-27 11:33:13 +01:00
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 *****/
2016-12-27 11:33:13 +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:"
2016-12-27 11:33:13 +01:00
"</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)
{
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<select name=\"ExamHour\">"
"<option value=\"0\"");
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.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);
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.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);
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</select>"
2014-12-01 23:55:08 +01:00
"<select name=\"ExamMinute\">");
for (Minute = 0;
Minute <= 59;
Minute++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute);
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.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>");
}
2017-01-15 18:02:52 +01:00
else if (Gbl.ExamAnns.ExaDat.StartTime.Hour)
2015-10-31 02:11:38 +01:00
fprintf (Gbl.F.Out,"%2u:%02u",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.StartTime.Minute);
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Approximate duration of the exam *****/
2016-12-27 11:33:13 +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:"
2016-12-27 11:33:13 +01:00
"</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);
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.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);
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</select>"
"<select name=\"DurationMinute\">");
2014-12-01 23:55:08 +01:00
for (Minute = 0;
Minute <= 59;
Minute++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",Minute);
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.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>");
}
2017-01-15 18:02:52 +01:00
else if (Gbl.ExamAnns.ExaDat.Duration.Hour ||
Gbl.ExamAnns.ExaDat.Duration.Minute)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Duration.Hour)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Duration.Minute)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"%u %s %u &#39;",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Duration.Hour,
2014-12-01 23:55:08 +01:00
Txt_hours_ABBREVIATION,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Duration.Minute);
2014-12-01 23:55:08 +01:00
else
{
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Duration.Hour == 1)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"1 %s",Txt_hour);
else
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"%u %s",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Duration.Hour,Txt_hours);
2014-12-01 23:55:08 +01:00
}
}
2017-01-15 18:02:52 +01:00
else if (Gbl.ExamAnns.ExaDat.Duration.Minute)
2014-12-01 23:55:08 +01:00
{
2017-01-15 18:02:52 +01:00
if (Gbl.ExamAnns.ExaDat.Duration.Minute == 1)
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"1 %s",Txt_minute);
else
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"%u %s",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Duration.Minute,Txt_minutes);
2014-12-01 23:55:08 +01:00
}
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Place where the exam will be made *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<label for=\"Place\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"Place\" name=\"Place\""
" cols=\"40\" rows=\"4\">"
"%s"
"</textarea>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Place);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Place,
2016-12-27 11:33:13 +01:00
Cns_MAX_BYTES_TEXT,false);
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Place);
2014-12-01 23:55:08 +01:00
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Exam mode *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<label for=\"ExamMode\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"ExamMode\" name=\"ExamMode\""
" cols=\"40\" rows=\"2\">"
"%s"
"</textarea>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Mode);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Mode,
2016-12-27 11:33:13 +01:00
Cns_MAX_BYTES_TEXT,false);
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Mode);
2014-12-01 23:55:08 +01:00
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Structure of the exam *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<label for=\"Structure\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"Structure\" name=\"Structure\""
" cols=\"40\" rows=\"8\">"
"%s"
"</textarea>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Structure);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.Structure,
2016-12-27 11:33:13 +01:00
Cns_MAX_BYTES_TEXT,false);
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.Structure);
2014-12-01 23:55:08 +01:00
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Documentation required *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<label for=\"DocRequired\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"DocRequired\" name=\"DocRequired\""
" cols=\"40\" rows=\"2\">"
"%s"
"</textarea>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.DocRequired);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.DocRequired,
2016-12-27 11:33:13 +01:00
Cns_MAX_BYTES_TEXT,false);
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.DocRequired);
2014-12-01 23:55:08 +01:00
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Material required *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<label for=\"MatRequired\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"MatRequired\" name=\"MatRequired\""
" cols=\"40\" rows=\"4\">"
"%s"
"</textarea>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.MatRequired);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.MatRequired,
2016-12-27 11:33:13 +01:00
Cns_MAX_BYTES_TEXT,false);
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.MatRequired);
2014-12-01 23:55:08 +01:00
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Material allowed *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<label for=\"MatAllowed\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"MatAllowed\" name=\"MatAllowed\""
" cols=\"40\" rows=\"4\">"
"%s"
"</textarea>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.MatAllowed);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.MatAllowed,
2016-12-27 11:33:13 +01:00
Cns_MAX_BYTES_TEXT,false);
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.MatAllowed);
2014-12-01 23:55:08 +01:00
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2014-12-01 23:55:08 +01:00
"</tr>");
/***** Other information to students *****/
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"RIGHT_TOP\">"
"<label for=\"OtherInfo\" class=\"%s\">%s:</label>"
"</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)
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"<textarea id=\"OtherInfo\" name=\"OtherInfo\""
" cols=\"40\" rows=\"5\">"
"%s"
"</textarea>",
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.OtherInfo);
2014-12-01 23:55:08 +01:00
else
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
2017-01-15 18:02:52 +01:00
Gbl.ExamAnns.ExaDat.OtherInfo,
2016-12-27 11:33:13 +01:00
Cns_MAX_BYTES_TEXT,false);
2017-01-15 18:02:52 +01:00
fprintf (Gbl.F.Out,"%s",Gbl.ExamAnns.ExaDat.OtherInfo);
2014-12-01 23:55:08 +01:00
}
2016-12-27 11:33:13 +01:00
fprintf (Gbl.F.Out,"</td>"
2016-12-12 02:21:41 +01:00
"</tr>");
2017-06-12 14:16:33 +02:00
/***** End table, send button and end box *****/
2015-04-11 23:46:21 +02:00
if (TypeViewExamAnnouncement == Exa_FORM_VIEW)
2019-03-25 19:05:10 +01:00
Box_EndBoxTableWithButton ((ExaCod > 0) ? Btn_CONFIRM_BUTTON :
Btn_CREATE_BUTTON,
2017-06-12 14:16:33 +02:00
Txt_Publish_announcement_OF_EXAM);
2015-04-11 23:46:21 +02:00
else
2017-06-12 14:16:33 +02:00
Box_EndBoxTable ();
2014-12-08 17:35:48 +01:00
2019-03-25 19:05:10 +01:00
/***** Show QR code *****/
2015-04-01 12:54:25 +02:00
if (TypeViewExamAnnouncement == Exa_PRINT_VIEW)
QR_ExamAnnnouncement ();
2019-03-25 19:05:10 +01:00
/***** End article *****/
if (TypeViewExamAnnouncement == Exa_NORMAL_VIEW)
Lay_EndArticle ();
/***** Free anchor string *****/
Exa_FreeAnchorStr (Anchor);
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)
{
2017-06-04 18:18:54 +02:00
if (Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
2016-03-16 12:05:10 +01:00
{
/***** Link to remove this exam announcement *****/
2017-06-11 19:13:28 +02:00
Ico_PutContextualIconToRemove (ActReqRemExaAnn,Exa_PutParamExaCodToEdit);
2016-03-16 12:05:10 +01:00
2016-12-12 02:21:41 +01:00
/***** Put form to hide/show exam announement *****/
2017-01-15 18:02:52 +01:00
switch (Gbl.ExamAnns.ExaDat.Status)
2016-12-12 02:21:41 +01:00
{
case Exa_VISIBLE_EXAM_ANNOUNCEMENT:
2019-03-25 19:05:10 +01:00
Ico_PutContextualIconToHide (ActHidExaAnn,Gbl.ExamAnns.Anchor,Exa_PutParamExaCodToEdit);
2016-12-12 02:21:41 +01:00
break;
case Exa_HIDDEN_EXAM_ANNOUNCEMENT:
2019-03-25 19:05:10 +01:00
Ico_PutContextualIconToUnhide (ActShoExaAnn,Gbl.ExamAnns.Anchor,Exa_PutParamExaCodToEdit);
2016-12-12 02:21:41 +01:00
break;
case Exa_DELETED_EXAM_ANNOUNCEMENT: // Not applicable here
break;
}
2016-03-16 12:05:10 +01:00
/***** Link to edit this exam announcement *****/
2017-06-11 19:13:28 +02:00
Ico_PutContextualIconToEdit (ActEdiExaAnn,Exa_PutParamExaCodToEdit);
2016-03-16 12:05:10 +01:00
}
/***** Link to print view *****/
2017-06-11 19:13:28 +02:00
Ico_PutContextualIconToPrint (ActPrnExaAnn,Exa_PutParamExaCodToEdit);
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
{
2019-03-25 19:05:10 +01:00
Exa_PutHiddenParamExaCod (Gbl.ExamAnns.ExaCod);
2016-06-01 19:34:44 +02:00
}
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)
{
/* Get notice code */
2017-01-28 20:32:50 +01:00
return Par_GetParToLong ("ExaCod");
2015-12-13 19:55:52 +01:00
}
2019-03-25 19:05:10 +01:00
/*****************************************************************************/
/*********** Build/free anchor string for an announcement of exam ************/
/*****************************************************************************/
void Exa_SetAnchorStr (long ExaCod,char **Anchor)
{
if (ExaCod > 0)
{
if (ExaCod == Gbl.ExamAnns.NewExaCod) // New announcement of exam
{
if (asprintf (Anchor,"exam_new") < 0)
Lay_NotEnoughMemoryExit ();
}
else // Existing announcement of exam, not a new one
{
// Existing announcement of exam, not new
if (asprintf (Anchor,"exam_%ld",
ExaCod) < 0)
Lay_NotEnoughMemoryExit ();
}
}
else // ?
*Anchor = NULL;
}
void Exa_FreeAnchorStr (char *Anchor)
{
if (Anchor)
{
free ((void *) Anchor);
Anchor = NULL;
}
}
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
/*****************************************************************************/
2017-03-08 14:12:33 +01:00
void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
2017-01-15 22:58:26 +01:00
char **ContentStr,
2017-03-06 13:01:16 +01:00
long ExaCod,bool GetContent)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_hours_ABBREVIATION;
2017-03-08 14:12:33 +01:00
char CrsNameAndDate[Hie_MAX_BYTES_FULL_NAME + (2 + Cns_MAX_BYTES_DATE + 6) + 1];
2017-05-05 02:03:28 +02:00
char StrExamDate[Cns_MAX_BYTES_DATE + 1];
2014-12-01 23:55:08 +01:00
2016-12-12 02:21:41 +01:00
/***** Initializations *****/
2014-12-01 23:55:08 +01:00
SummaryStr[0] = '\0'; // Return nothing on error
/***** Allocate memory for the exam announcement *****/
Exa_AllocMemExamAnnouncement ();
/***** Get data of an exam announcement from database *****/
2019-03-25 19:05:10 +01:00
Exa_GetDataExamAnnouncementFromDB (ExaCod);
2014-12-01 23:55:08 +01:00
/***** Content *****/
if (GetContent)
Exa_GetNotifContentExamAnnouncement (ContentStr);
/***** Summary *****/
2017-03-06 13:01:16 +01:00
/* Name of the course and date of exam */
2017-05-05 02:03:28 +02:00
Dat_ConvDateToDateStr (&Gbl.ExamAnns.ExaDat.ExamDate,StrExamDate);
2018-10-17 14:12:09 +02:00
snprintf (CrsNameAndDate,sizeof (CrsNameAndDate),
"%s, %s, %2u:%02u",
Gbl.ExamAnns.ExaDat.CrsFullName,
StrExamDate,
Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.StartTime.Minute);
2017-03-06 13:01:16 +01:00
Str_Copy (SummaryStr,CrsNameAndDate,
2017-03-08 14:12:33 +01:00
Ntf_MAX_BYTES_SUMMARY);
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;
2017-01-28 15:58:46 +01:00
extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE];
2014-12-01 23:55:08 +01:00
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;
2017-03-07 11:03:05 +01:00
char StrExamDate[Cns_MAX_BYTES_DATE + 1];
2014-12-01 23:55:08 +01:00
/***** Get data of course *****/
2017-01-15 18:02:52 +01:00
Crs.CrsCod = Gbl.ExamAnns.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
2018-10-17 14:12:09 +02:00
/***** Convert struct date to a date string *****/
2017-01-15 18:02:52 +01:00
Dat_ConvDateToDateStr (&Gbl.ExamAnns.ExaDat.ExamDate,StrExamDate);
2014-12-01 23:55:08 +01:00
2018-10-17 14:12:09 +02:00
/***** Fill content string *****/
if (asprintf (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,
Txt_EXAM_ANNOUNCEMENT_Course,Gbl.ExamAnns.ExaDat.CrsFullName,
Txt_EXAM_ANNOUNCEMENT_Year_or_semester,Txt_YEAR_OF_DEGREE[Gbl.ExamAnns.ExaDat.Year],
Txt_EXAM_ANNOUNCEMENT_Session,Gbl.ExamAnns.ExaDat.Session,
Txt_EXAM_ANNOUNCEMENT_Exam_date,StrExamDate,
Txt_EXAM_ANNOUNCEMENT_Start_time,Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.StartTime.Minute,
Txt_hours_ABBREVIATION,
Txt_EXAM_ANNOUNCEMENT_Approximate_duration,Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnns.ExaDat.Duration.Minute,
Txt_hours_ABBREVIATION,
Txt_EXAM_ANNOUNCEMENT_Place_of_exam,Gbl.ExamAnns.ExaDat.Place,
Txt_EXAM_ANNOUNCEMENT_Mode,Gbl.ExamAnns.ExaDat.Mode,
Txt_EXAM_ANNOUNCEMENT_Structure_of_the_exam,Gbl.ExamAnns.ExaDat.Structure,
Txt_EXAM_ANNOUNCEMENT_Documentation_required,Gbl.ExamAnns.ExaDat.DocRequired,
Txt_EXAM_ANNOUNCEMENT_Material_required,Gbl.ExamAnns.ExaDat.MatRequired,
Txt_EXAM_ANNOUNCEMENT_Material_allowed,Gbl.ExamAnns.ExaDat.MatAllowed,
Txt_EXAM_ANNOUNCEMENT_Other_information,Gbl.ExamAnns.ExaDat.OtherInfo) < 0)
2018-10-18 20:06:54 +02:00
Lay_NotEnoughMemoryExit ();
2014-12-01 23:55:08 +01:00
}