From 3699490179fe451568d544539d35930784fd7c28 Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 31 May 2021 13:52:39 +0200 Subject: [PATCH] Version 20.86: May 31, 2021 New module swad_call_for_exam_database for database queries related to calls for exams. --- Makefile | 6 +- swad_call_for_exam.c | 212 ++++-------------------------- swad_call_for_exam.h | 2 - swad_call_for_exam_database.c | 236 ++++++++++++++++++++++++++++++++++ swad_call_for_exam_database.h | 59 +++++++++ swad_changelog.h | 3 +- swad_degree_database.c | 16 --- swad_degree_database.h | 5 - 8 files changed, 328 insertions(+), 211 deletions(-) create mode 100644 swad_call_for_exam_database.c create mode 100644 swad_call_for_exam_database.h diff --git a/Makefile b/Makefile index c2314dd4..92161e64 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,9 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \ swad_assignment_database.o swad_attendance.o swad_attendance_database.o \ swad_banner.o swad_banner_database.o swad_box.o swad_building.o \ swad_button.o \ - swad_calendar.o swad_call_for_exam.o swad_center.o \ - swad_center_config.o swad_chat.o swad_chat_database.o swad_config.o \ - swad_connected.o swad_connected_database.o swad_cookie.o \ + swad_calendar.o swad_call_for_exam.o swad_call_for_exam_database.o \ + swad_center.o swad_center_config.o swad_chat.o swad_chat_database.o \ + swad_config.o swad_connected.o swad_connected_database.o swad_cookie.o \ swad_cookie_database.o swad_country.o swad_country_config.o \ swad_country_database.o swad_course.o swad_course_config.o \ swad_course_database.o swad_cryptography.o \ diff --git a/swad_call_for_exam.c b/swad_call_for_exam.c index c27faa6f..2688745f 100644 --- a/swad_call_for_exam.c +++ b/swad_call_for_exam.c @@ -33,6 +33,7 @@ #include "swad_box.h" #include "swad_call_for_exam.h" +#include "swad_call_for_exam_database.h" #include "swad_config.h" #include "swad_database.h" #include "swad_degree_database.h" @@ -80,9 +81,6 @@ static long Cfe_GetParamsCallsForExams (struct Cfe_CallsForExams *CallsForExams) static void Cfe_AllocMemCallForExam (struct Cfe_CallsForExams *CallsForExams); static void Cfe_FreeMemCallForExam (struct Cfe_CallsForExams *CallsForExams); -static void Cfe_UpdateNumUsrsNotifiedByEMailAboutCallForExam (long ExaCod, - unsigned NumUsrsToBeNotifiedByEMail); - static void Cfe_GetExaCodToHighlight (struct Cfe_CallsForExams *CallsForExams); static void Cfe_GetDateToHighlight (struct Cfe_CallsForExams *CallsForExams); @@ -91,9 +89,6 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams, static void Cfe_PutIconToCreateNewCallForExam (__attribute__((unused)) void *Args); static void Cfe_PutButtonToCreateNewCallForExam (void); -static long Cfe_AddCallForExamToDB (const struct Cfe_CallsForExams *CallsForExams); -static void Cfe_ModifyCallForExamInDB (const struct Cfe_CallsForExams *CallsForExams, - long ExaCod); static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExams, long ExaCod); static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, @@ -124,7 +119,7 @@ static struct Cfe_CallsForExams *Cfe_GetGlobalCallsForExams (void) void Cfe_ResetCallsForExams (struct Cfe_CallsForExams *CallsForExams) { - CallsForExams->NumCallsForExams = 0; + CallsForExams->NumCallsForExams = 0; CallsForExams->Lst = NULL; CallsForExams->NewExaCod = -1L; CallsForExams->HighlightExaCod = -1L; @@ -200,10 +195,10 @@ static long Cfe_GetParamsCallsForExams (struct Cfe_CallsForExams *CallsForExams) /***** Get the year *****/ CallsForExams->CallForExam.Year = (unsigned) - Par_GetParToUnsignedLong ("Year", - 0, // N.A. - Deg_MAX_YEARS_PER_DEGREE, - (unsigned long) Gbl.Hierarchy.Crs.Year); + Par_GetParToUnsignedLong ("Year", + 0, // N.A. + Deg_MAX_YEARS_PER_DEGREE, + (unsigned long) Gbl.Hierarchy.Crs.Year); /***** Get the type of call for exam *****/ Par_GetParToText ("ExamSession",CallsForExams->CallForExam.Session,Cfe_MAX_BYTES_SESSION); @@ -234,26 +229,16 @@ static long Cfe_GetParamsCallsForExams (struct Cfe_CallsForExams *CallsForExams) CallsForExams->CallForExam.Duration.Minute = (unsigned) Par_GetParToUnsignedLong ("DurationMinute", 0,59,0); - /***** Get the place where the exam will happen *****/ - Par_GetParToHTML ("Place",CallsForExams->CallForExam.Place,Cns_MAX_BYTES_TEXT); - - /***** Get the modality of exam *****/ - Par_GetParToHTML ("ExamMode",CallsForExams->CallForExam.Mode,Cns_MAX_BYTES_TEXT); - - /***** Get the structure of exam *****/ - Par_GetParToHTML ("Structure",CallsForExams->CallForExam.Structure,Cns_MAX_BYTES_TEXT); - - /***** Get the mandatory documentation *****/ + /***** Get the place where the exam will happen, the modality of exam, + the structure of exam, the mandatory documentation, the mandatory material, + the allowed material and other information *****/ + Par_GetParToHTML ("Place" ,CallsForExams->CallForExam.Place ,Cns_MAX_BYTES_TEXT); + Par_GetParToHTML ("ExamMode" ,CallsForExams->CallForExam.Mode ,Cns_MAX_BYTES_TEXT); + Par_GetParToHTML ("Structure" ,CallsForExams->CallForExam.Structure ,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("DocRequired",CallsForExams->CallForExam.DocRequired,Cns_MAX_BYTES_TEXT); - - /***** Get the mandatory material *****/ Par_GetParToHTML ("MatRequired",CallsForExams->CallForExam.MatRequired,Cns_MAX_BYTES_TEXT); - - /***** Get the allowed material *****/ - Par_GetParToHTML ("MatAllowed",CallsForExams->CallForExam.MatAllowed,Cns_MAX_BYTES_TEXT); - - /***** Get other information *****/ - Par_GetParToHTML ("OtherInfo",CallsForExams->CallForExam.OtherInfo,Cns_MAX_BYTES_TEXT); + Par_GetParToHTML ("MatAllowed" ,CallsForExams->CallForExam.MatAllowed ,Cns_MAX_BYTES_TEXT); + Par_GetParToHTML ("OtherInfo" ,CallsForExams->CallForExam.OtherInfo ,Cns_MAX_BYTES_TEXT); return ExaCod; } @@ -356,9 +341,9 @@ void Cfe_ReceiveCallForExam1 (void) /***** Add the call for exam to the database and read it again from the database *****/ if (NewCallForExam) - CallsForExams->NewExaCod = ExaCod = Cfe_AddCallForExamToDB (CallsForExams); + CallsForExams->NewExaCod = ExaCod = Cfe_DB_CreateCallForExam (&CallsForExams->CallForExam); else - Cfe_ModifyCallForExamInDB (CallsForExams,ExaCod); + Cfe_DB_ModifyCallForExam (&CallsForExams->CallForExam,ExaCod); /***** Free memory of the call for exam *****/ Cfe_FreeMemCallForExam (CallsForExams); @@ -381,7 +366,7 @@ void Cfe_ReceiveCallForExam2 (void) /***** Notify by email about the new call for exam *****/ if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_CALL_FOR_EXAM,CallsForExams->HighlightExaCod))) - Cfe_UpdateNumUsrsNotifiedByEMailAboutCallForExam (CallsForExams->HighlightExaCod,NumUsrsToBeNotifiedByEMail); + Cfe_DB_UpdateNumUsrsNotifiedByEMailAboutCallForExam (CallsForExams->HighlightExaCod,NumUsrsToBeNotifiedByEMail); /***** Create a new social note about the new call for exam *****/ Tml_Not_StoreAndPublishNote (TL_NOTE_CALL_FOR_EXAM,CallsForExams->HighlightExaCod); @@ -393,23 +378,6 @@ void Cfe_ReceiveCallForExam2 (void) Cfe_ListCallsForExamsEdit (); } -/*****************************************************************************/ -/******* Update number of users notified in table of calls for exams *********/ -/*****************************************************************************/ - -static void Cfe_UpdateNumUsrsNotifiedByEMailAboutCallForExam (long ExaCod, - unsigned NumUsrsToBeNotifiedByEMail) - { - /***** Update number of users notified *****/ - DB_QueryUPDATE ("can not update the number of notifications" - " of a call for exam", - "UPDATE cfe_exams" - " SET NumNotif=NumNotif+%u" - " WHERE ExaCod=%ld", - NumUsrsToBeNotifiedByEMail, - ExaCod); - } - /*****************************************************************************/ /*************************** Print a call for exam ***************************/ /*****************************************************************************/ @@ -462,15 +430,14 @@ void Cfe_ReqRemoveCallForExam (void) /* Begin alert */ Ale_ShowAlertAndButton1 (Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_following_call_for_exam); - /* Show call for exam */ - Cfe_AllocMemCallForExam (&CallsForExams); - Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod); - Cfe_ShowCallForExam (&CallsForExams,ExaCod,Cfe_NORMAL_VIEW, - false); // Don't highlight - Cfe_FreeMemCallForExam (&CallsForExams); + /* Show call for exam */ + Cfe_AllocMemCallForExam (&CallsForExams); + Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod); + Cfe_ShowCallForExam (&CallsForExams,ExaCod,Cfe_NORMAL_VIEW, + false); // Don't highlight + Cfe_FreeMemCallForExam (&CallsForExams); /* End alert */ - Ale_ShowAlertAndButton2 (ActRemCfe,NULL,NULL, Cfe_PutParamExaCodToEdit,&CallsForExams.ExaCod, Btn_REMOVE_BUTTON,Txt_Remove); @@ -495,14 +462,7 @@ void Cfe_RemoveCallForExam1 (void) Err_WrongCallForExamExit (); /***** Mark the call for exam as deleted in the database *****/ - DB_QueryUPDATE ("can not remove call for exam", - "UPDATE cfe_exams" - " SET Status=%u" - " WHERE ExaCod=%ld" - " AND CrsCod=%ld", - (unsigned) Cfe_DELETED_CALL_FOR_EXAM, - ExaCod, - Gbl.Hierarchy.Crs.CrsCod); + Cfe_DB_MarkACallForExamAsDeleted (ExaCod); /***** Mark possible notifications as removed *****/ Ntf_MarkNotifAsRemoved (Ntf_EVENT_CALL_FOR_EXAM,ExaCod); @@ -544,14 +504,7 @@ void Cfe_HideCallForExam (void) Err_WrongCallForExamExit (); /***** Mark the call for exam as hidden in the database *****/ - DB_QueryUPDATE ("can not hide call for exam", - "UPDATE cfe_exams" - " SET Status=%u" - " WHERE ExaCod=%ld" - " AND CrsCod=%ld", - (unsigned) Cfe_HIDDEN_CALL_FOR_EXAM, - ExaCod, - Gbl.Hierarchy.Crs.CrsCod); + Cfe_DB_HideCallForExam (ExaCod); /***** Set exam to be highlighted *****/ CallsForExams->HighlightExaCod = ExaCod; @@ -576,14 +529,7 @@ void Cfe_UnhideCallForExam (void) Err_WrongCallForExamExit (); /***** Mark the call for exam as visible in the database *****/ - DB_QueryUPDATE ("can not unhide call for exam", - "UPDATE cfe_exams" - " SET Status=%u" - " WHERE ExaCod=%ld" - " AND CrsCod=%ld", - (unsigned) Cfe_VISIBLE_CALL_FOR_EXAM, - ExaCod, - Gbl.Hierarchy.Crs.CrsCod); + Cfe_DB_UnhideCallForExam (ExaCod); /***** Set exam to be highlighted *****/ CallsForExams->HighlightExaCod = ExaCod; @@ -710,7 +656,7 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams, NumExaAnns = (unsigned) DB_QuerySELECT (&mysql_res,"can not get calls for exams" " in this course for listing", - "SELECT ExaCod" // row[0] + "SELECT ExaCod" // row[0] " FROM cfe_exams" " WHERE CrsCod=%ld" " AND %s" @@ -798,98 +744,10 @@ static void Cfe_PutButtonToCreateNewCallForExam (void) extern const char *Txt_New_call_FOR_EXAM; Frm_BeginForm (ActEdiCfe); - Btn_PutConfirmButton (Txt_New_call_FOR_EXAM); + Btn_PutConfirmButton (Txt_New_call_FOR_EXAM); Frm_EndForm (); } -/*****************************************************************************/ -/******************** Add a call for exam to the database ********************/ -/*****************************************************************************/ -// Return the code of the call for exam just added - -static long Cfe_AddCallForExamToDB (const struct Cfe_CallsForExams *CallsForExams) - { - long ExaCod; - - /***** Add call for exam *****/ - ExaCod = - DB_QueryINSERTandReturnCode ("can not create a new call for exam", - "INSERT INTO cfe_exams " - "(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')", - Gbl.Hierarchy.Crs.CrsCod, - (unsigned) Cfe_VISIBLE_CALL_FOR_EXAM, - CallsForExams->CallForExam.CrsFullName, - CallsForExams->CallForExam.Year, - CallsForExams->CallForExam.Session, - CallsForExams->CallForExam.ExamDate.Year, - CallsForExams->CallForExam.ExamDate.Month, - CallsForExams->CallForExam.ExamDate.Day, - CallsForExams->CallForExam.StartTime.Hour, - CallsForExams->CallForExam.StartTime.Minute, - CallsForExams->CallForExam.Duration.Hour, - CallsForExams->CallForExam.Duration.Minute, - CallsForExams->CallForExam.Place, - CallsForExams->CallForExam.Mode, - CallsForExams->CallForExam.Structure, - CallsForExams->CallForExam.DocRequired, - CallsForExams->CallForExam.MatRequired, - CallsForExams->CallForExam.MatAllowed, - CallsForExams->CallForExam.OtherInfo); - - return ExaCod; - } - -/*****************************************************************************/ -/***************** Modify a call for exam in the database ********************/ -/*****************************************************************************/ - -static void Cfe_ModifyCallForExamInDB (const struct Cfe_CallsForExams *CallsForExams, - long ExaCod) - { - /***** Modify call for exam *****/ - DB_QueryUPDATE ("can not update a call for exam", - "UPDATE cfe_exams" - " 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", - CallsForExams->CallForExam.CrsFullName, - CallsForExams->CallForExam.Year, - CallsForExams->CallForExam.Session, - CallsForExams->CallForExam.ExamDate.Year, - CallsForExams->CallForExam.ExamDate.Month, - CallsForExams->CallForExam.ExamDate.Day, - CallsForExams->CallForExam.StartTime.Hour, - CallsForExams->CallForExam.StartTime.Minute, - CallsForExams->CallForExam.Duration.Hour, - CallsForExams->CallForExam.Duration.Minute, - CallsForExams->CallForExam.Place, - CallsForExams->CallForExam.Mode, - CallsForExams->CallForExam.Structure, - CallsForExams->CallForExam.DocRequired, - CallsForExams->CallForExam.MatRequired, - CallsForExams->CallForExam.MatAllowed, - CallsForExams->CallForExam.OtherInfo, - ExaCod); - } - /*****************************************************************************/ /******** Create a list with the dates of all the calls for exams ************/ /*****************************************************************************/ @@ -1842,17 +1700,3 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call Txt_CALL_FOR_EXAM_Other_information,CallsForExams->CallForExam.OtherInfo) < 0) Err_NotEnoughMemoryExit (); } - -/*****************************************************************************/ -/*********** Mark all exam announcements in the course as deleted ************/ -/*****************************************************************************/ - -void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod) - { - DB_QueryUPDATE ("can not remove calls for exams of a course", - "UPDATE cfe_exams" - " SET Status=%u" - " WHERE CrsCod=%ld", - (unsigned) Cfe_DELETED_CALL_FOR_EXAM, - CrsCod); - } diff --git a/swad_call_for_exam.h b/swad_call_for_exam.h index 9d1a957e..0d90e926 100644 --- a/swad_call_for_exam.h +++ b/swad_call_for_exam.h @@ -126,6 +126,4 @@ void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY char **ContentStr, long ExaCod,bool GetContent); -void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod); - #endif diff --git a/swad_call_for_exam_database.c b/swad_call_for_exam_database.c new file mode 100644 index 00000000..f8dd38e8 --- /dev/null +++ b/swad_call_for_exam_database.c @@ -0,0 +1,236 @@ +// swad_exam_announcement_database.c: calls for exams operations with database + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General 3 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 . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +// #define _GNU_SOURCE // For asprintf +// #include // For NULL +// #include // For sscanf, asprintf, etc. +// #include // For exit, system, malloc, calloc, free, etc. +// #include // For string functions + +// #include "swad_box.h" +#include "swad_call_for_exam.h" +#include "swad_call_for_exam_database.h" +// #include "swad_config.h" +#include "swad_database.h" +// #include "swad_degree_database.h" +// #include "swad_error.h" +// #include "swad_form.h" +#include "swad_global.h" +// #include "swad_hierarchy.h" +// #include "swad_hierarchy_level.h" +// #include "swad_HTML.h" +// #include "swad_logo.h" +// #include "swad_notification.h" +// #include "swad_parameter.h" +// #include "swad_QR.h" +// #include "swad_RSS.h" +// #include "swad_string.h" +// #include "swad_timeline.h" +// #include "swad_timeline_database.h" + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/***************************** Private constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************* Private types *******************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private variables *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************** Add a call for exam to the database ********************/ +/*****************************************************************************/ +// Return the code of the call for exam just added + +long Cfe_DB_CreateCallForExam (const struct Cfe_CallForExam *CallForExam) + { + return + DB_QueryINSERTandReturnCode ("can not create a new call for exam", + "INSERT INTO cfe_exams " + "(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')", + Gbl.Hierarchy.Crs.CrsCod, + (unsigned) Cfe_VISIBLE_CALL_FOR_EXAM, + CallForExam->CrsFullName, + CallForExam->Year, + CallForExam->Session, + CallForExam->ExamDate.Year, + CallForExam->ExamDate.Month, + CallForExam->ExamDate.Day, + CallForExam->StartTime.Hour, + CallForExam->StartTime.Minute, + CallForExam->Duration.Hour, + CallForExam->Duration.Minute, + CallForExam->Place, + CallForExam->Mode, + CallForExam->Structure, + CallForExam->DocRequired, + CallForExam->MatRequired, + CallForExam->MatAllowed, + CallForExam->OtherInfo); + } + +/*****************************************************************************/ +/***************** Modify a call for exam in the database ********************/ +/*****************************************************************************/ + +void Cfe_DB_ModifyCallForExam (const struct Cfe_CallForExam *CallForExam, + long ExaCod) + { + /***** Modify call for exam *****/ + DB_QueryUPDATE ("can not update a call for exam", + "UPDATE cfe_exams" + " 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", + CallForExam->CrsFullName, + CallForExam->Year, + CallForExam->Session, + CallForExam->ExamDate.Year, + CallForExam->ExamDate.Month, + CallForExam->ExamDate.Day, + CallForExam->StartTime.Hour, + CallForExam->StartTime.Minute, + CallForExam->Duration.Hour, + CallForExam->Duration.Minute, + CallForExam->Place, + CallForExam->Mode, + CallForExam->Structure, + CallForExam->DocRequired, + CallForExam->MatRequired, + CallForExam->MatAllowed, + CallForExam->OtherInfo, + ExaCod); + } + +/*****************************************************************************/ +/******* Update number of users notified in table of calls for exams *********/ +/*****************************************************************************/ + +void Cfe_DB_UpdateNumUsrsNotifiedByEMailAboutCallForExam (long ExaCod, + unsigned NumUsrsToBeNotifiedByEMail) + { + DB_QueryUPDATE ("can not update the number of notifications" + " of a call for exam", + "UPDATE cfe_exams" + " SET NumNotif=NumNotif+%u" + " WHERE ExaCod=%ld", + NumUsrsToBeNotifiedByEMail, + ExaCod); + } + +/*****************************************************************************/ +/************* Mark the call for exam as hidden in the database **************/ +/*****************************************************************************/ + +void Cfe_DB_HideCallForExam (long ExaCod) + { + DB_QueryUPDATE ("can not hide call for exam", + "UPDATE cfe_exams" + " SET Status=%u" + " WHERE ExaCod=%ld" + " AND CrsCod=%ld", // Extra check + (unsigned) Cfe_HIDDEN_CALL_FOR_EXAM, + ExaCod, + Gbl.Hierarchy.Crs.CrsCod); + } + +/*****************************************************************************/ +/************* Mark the call for exam as visible in the database *************/ +/*****************************************************************************/ + +void Cfe_DB_UnhideCallForExam (long ExaCod) + { + DB_QueryUPDATE ("can not unhide call for exam", + "UPDATE cfe_exams" + " SET Status=%u" + " WHERE ExaCod=%ld" + " AND CrsCod=%ld", // Extra check + (unsigned) Cfe_VISIBLE_CALL_FOR_EXAM, + ExaCod, + Gbl.Hierarchy.Crs.CrsCod); + } + +/*****************************************************************************/ + /***** Mark a call for exam as deleted in the database *****/ +/*****************************************************************************/ + +void Cfe_DB_MarkACallForExamAsDeleted (long ExaCod) + { + DB_QueryUPDATE ("can not remove call for exam", + "UPDATE cfe_exams" + " SET Status=%u" + " WHERE ExaCod=%ld" + " AND CrsCod=%ld", // Extra check + (unsigned) Cfe_DELETED_CALL_FOR_EXAM, + ExaCod, + Gbl.Hierarchy.Crs.CrsCod); + } + +/*****************************************************************************/ +/*********** Mark all exam announcements in the course as deleted ************/ +/*****************************************************************************/ + +void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod) + { + DB_QueryUPDATE ("can not remove calls for exams of a course", + "UPDATE cfe_exams" + " SET Status=%u" + " WHERE CrsCod=%ld", + (unsigned) Cfe_DELETED_CALL_FOR_EXAM, + CrsCod); + } diff --git a/swad_call_for_exam_database.h b/swad_call_for_exam_database.h new file mode 100644 index 00000000..ce70daff --- /dev/null +++ b/swad_call_for_exam_database.h @@ -0,0 +1,59 @@ +// swad_call_for_exam_database.h: calls for exams operations with database + +#ifndef _SWAD_CFE_DB +#define _SWAD_CFE_DB +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General 3 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 . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +// #include // For boolean type + +#include "swad_call_for_exam.h" +// #include "swad_constant.h" +// #include "swad_course.h" +// #include "swad_date.h" +// #include "swad_notification.h" + +/*****************************************************************************/ +/************************** Public types and constants ***********************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Public prototypes *****************************/ +/*****************************************************************************/ + +long Cfe_DB_CreateCallForExam (const struct Cfe_CallForExam *CallForExam); + +void Cfe_DB_ModifyCallForExam (const struct Cfe_CallForExam *CallForExam, + long ExaCod); +void Cfe_DB_UpdateNumUsrsNotifiedByEMailAboutCallForExam (long ExaCod, + unsigned NumUsrsToBeNotifiedByEMail); + +void Cfe_DB_HideCallForExam (long ExaCod); +void Cfe_DB_UnhideCallForExam (long ExaCod); + +void Cfe_DB_MarkACallForExamAsDeleted (long ExaCod); +void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod); + +#endif diff --git a/swad_changelog.h b/swad_changelog.h index 89274c33..8400f308 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 20.85 (2021-05-28)" +#define Log_PLATFORM_VERSION "SWAD 20.86 (2021-05-31)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 20.86: May 31, 2021 New module swad_call_for_exam_database for database queries related to calls for exams. (? lines) Version 20.85: May 28, 2021 Queries moved to module swad_degree_database. (312319 lines) Version 20.84: May 27, 2021 New module swad_degree_database for database queries related to degrees. (312216 lines) Version 20.83.1: May 27, 2021 Database function moved from swad_date to swad_setting. (311993 lines) diff --git a/swad_degree_database.c b/swad_degree_database.c index ead418ff..23783bdb 100644 --- a/swad_degree_database.c +++ b/swad_degree_database.c @@ -25,26 +25,10 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ -// #include // For boolean type -// #include // For NULL -// #include // For free -// #include // For string functions - #include "swad_database.h" -// #include "swad_degree.h" -// #include "swad_degree_config.h" #include "swad_degree_database.h" #include "swad_error.h" -// #include "swad_figure.h" -// #include "swad_figure_cache.h" -// #include "swad_form.h" -// #include "swad_forum.h" #include "swad_global.h" -// #include "swad_hierarchy.h" -// #include "swad_HTML.h" -// #include "swad_logo.h" -// #include "swad_message.h" -// #include "swad_survey.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ diff --git a/swad_degree_database.h b/swad_degree_database.h index 8f2c9f41..e477a657 100644 --- a/swad_degree_database.h +++ b/swad_degree_database.h @@ -29,13 +29,8 @@ #include // To access MySQL databases -// #include "swad_action.h" -// #include "swad_constant.h" #include "swad_degree.h" #include "swad_degree_type.h" -// #include "swad_hierarchy_level.h" -// #include "swad_role_type.h" -// #include "swad_string.h" /*****************************************************************************/ /***************************** Public constants ******************************/