Version 20.51.1: Mar 18, 2021 Calls for exams database table renamed.

This commit is contained in:
acanas 2021-03-18 02:04:26 +01:00
parent 789b3697f5
commit 7810833e07
8 changed files with 163 additions and 119 deletions

View File

@ -151,6 +151,30 @@ CREATE TABLE IF NOT EXISTS brw_clipboards (
INDEX(FileBrowser,Cod),
INDEX(WorksUsrCod));
--
-- Table cfe_calls_for_exams: stores the calls for examination
--
CREATE TABLE IF NOT EXISTS cfe_calls_for_exams (
ExaCod INT NOT NULL AUTO_INCREMENT,
CrsCod INT NOT NULL DEFAULT -1,
Status TINYINT NOT NULL DEFAULT 0,
NumNotif INT NOT NULL DEFAULT 0,
CrsFullName VARCHAR(2047) NOT NULL,
Year TINYINT NOT NULL,
ExamSession VARCHAR(2047) NOT NULL,
CallDate DATETIME NOT NULL,
ExamDate DATETIME NOT NULL,
Duration TIME NOT NULL,
Place TEXT NOT NULL,
ExamMode TEXT NOT NULL,
Structure TEXT NOT NULL,
DocRequired TEXT NOT NULL,
MatRequired TEXT NOT NULL,
MatAllowed TEXT NOT NULL,
OtherInfo TEXT NOT NULL,
UNIQUE INDEX(ExaCod),
INDEX(CrsCod,Status),
INDEX(Status));
--
-- Table cht_rooms: stores number of users in each chat room (this table is not used now)
--
CREATE TABLE IF NOT EXISTS cht_rooms (
@ -534,30 +558,6 @@ CREATE TABLE IF NOT EXISTS exa_sets (
UNIQUE INDEX(SetCod),
UNIQUE INDEX(ExaCod,SetInd));
--
-- Table exam_announcements: stores the calls for examination
--
CREATE TABLE IF NOT EXISTS exam_announcements (
ExaCod INT NOT NULL AUTO_INCREMENT,
CrsCod INT NOT NULL DEFAULT -1,
Status TINYINT NOT NULL DEFAULT 0,
NumNotif INT NOT NULL DEFAULT 0,
CrsFullName VARCHAR(2047) NOT NULL,
Year TINYINT NOT NULL,
ExamSession VARCHAR(2047) NOT NULL,
CallDate DATETIME NOT NULL,
ExamDate DATETIME NOT NULL,
Duration TIME NOT NULL,
Place TEXT NOT NULL,
ExamMode TEXT NOT NULL,
Structure TEXT NOT NULL,
DocRequired TEXT NOT NULL,
MatRequired TEXT NOT NULL,
MatAllowed TEXT NOT NULL,
OtherInfo TEXT NOT NULL,
UNIQUE INDEX(ExaCod),
INDEX(CrsCod,Status),
INDEX(Status));
--
-- Table expanded_folders: stores the expanded folders for each user
--
CREATE TABLE IF NOT EXISTS expanded_folders (

View File

@ -253,14 +253,18 @@ static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Crs_Course *Crs)
if (Gbl.DB.DatabaseIsOpen)
{
/***** Get exam announcements (only future exams) in current course from database *****/
NumExamAnnouncements = DB_QuerySELECT (&mysql_res,"can not get exam announcements",
"SELECT ExaCod,UNIX_TIMESTAMP(CallDate) AS T,"
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')"
" FROM exam_announcements"
" WHERE CrsCod=%ld AND Status=%u AND ExamDate>=NOW()"
" ORDER BY T",
Gbl.Hierarchy.Crs.CrsCod,
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
NumExamAnnouncements =
DB_QuerySELECT (&mysql_res,"can not get exam announcements",
"SELECT ExaCod," // row[0]
"UNIX_TIMESTAMP(CallDate) AS T," // row[1]
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')" // row[2]
" FROM cfe_calls_for_exams"
" WHERE CrsCod=%ld"
" AND Status=%u"
" AND ExamDate>=NOW()"
" ORDER BY T",
Gbl.Hierarchy.Crs.CrsCod,
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
/***** Write items with notices *****/
if (NumExamAnnouncements)

View File

@ -400,7 +400,8 @@ static void Cfe_UpdateNumUsrsNotifiedByEMailAboutCallForExam (long ExaCod,
/***** Update number of users notified *****/
DB_QueryUPDATE ("can not update the number of notifications"
" of a call for exam",
"UPDATE exam_announcements SET NumNotif=NumNotif+%u"
"UPDATE cfe_calls_for_exams"
" SET NumNotif=NumNotif+%u"
" WHERE ExaCod=%ld",
NumUsrsToBeNotifiedByEMail,ExaCod);
}
@ -491,8 +492,10 @@ void Cfe_RemoveCallForExam1 (void)
/***** Mark the call for exam as deleted in the database *****/
DB_QueryUPDATE ("can not remove call for exam",
"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
"UPDATE cfe_calls_for_exams"
" SET Status=%u"
" WHERE ExaCod=%ld"
" AND CrsCod=%ld",
(unsigned) Cfe_DELETED_CALL_FOR_EXAM,
ExaCod,Gbl.Hierarchy.Crs.CrsCod);
@ -537,8 +540,10 @@ void Cfe_HideCallForExam (void)
/***** Mark the call for exam as hidden in the database *****/
DB_QueryUPDATE ("can not hide call for exam",
"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
"UPDATE cfe_calls_for_exams"
" SET Status=%u"
" WHERE ExaCod=%ld"
" AND CrsCod=%ld",
(unsigned) Cfe_HIDDEN_CALL_FOR_EXAM,
ExaCod,Gbl.Hierarchy.Crs.CrsCod);
@ -566,8 +571,10 @@ void Cfe_UnhideCallForExam (void)
/***** Mark the call for exam as visible in the database *****/
DB_QueryUPDATE ("can not unhide call for exam",
"UPDATE exam_announcements SET Status=%u"
" WHERE ExaCod=%ld AND CrsCod=%ld",
"UPDATE cfe_calls_for_exams"
" SET Status=%u"
" WHERE ExaCod=%ld"
" AND CrsCod=%ld",
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM,
ExaCod,Gbl.Hierarchy.Crs.CrsCod);
@ -696,9 +703,10 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams,
in current course from database *****/
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get calls for exams"
" in this course for listing",
"SELECT ExaCod"
" FROM exam_announcements"
" WHERE CrsCod=%ld AND %s"
"SELECT ExaCod" // row[0]
" FROM cfe_calls_for_exams"
" WHERE CrsCod=%ld"
" AND %s"
" ORDER BY ExamDate DESC",
Gbl.Hierarchy.Crs.CrsCod,SubQueryStatus);
@ -800,7 +808,7 @@ static long Cfe_AddCallForExamToDB (const struct Cfe_CallsForExams *CallsForExam
/***** Add call for exam *****/
ExaCod =
DB_QueryINSERTandReturnCode ("can not create a new call for exam",
"INSERT INTO exam_announcements "
"INSERT INTO cfe_calls_for_exams "
"(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,"
"Place,ExamMode,Structure,DocRequired,MatRequired,MatAllowed,OtherInfo)"
@ -840,12 +848,19 @@ static void Cfe_ModifyCallForExamInDB (const struct Cfe_CallsForExams *CallsForE
{
/***** Modify call for exam *****/
DB_QueryUPDATE ("can not update a call for exam",
"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'"
"UPDATE cfe_calls_for_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,
@ -885,8 +900,9 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams)
in current course from database *****/
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get calls for exams"
" in this course",
"SELECT ExaCod,DATE(ExamDate)"
" FROM exam_announcements"
"SELECT ExaCod," // row[0]
"DATE(ExamDate)" // row[1]
" FROM cfe_calls_for_exams"
" WHERE CrsCod=%ld AND Status=%u"
" ORDER BY ExamDate DESC",
Gbl.Hierarchy.Crs.CrsCod,
@ -961,10 +977,23 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
/***** Get data of a call for exam from database *****/
NumExaAnns = DB_QuerySELECT (&mysql_res,"can not get data"
" of a call for exam",
"SELECT CrsCod,Status,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,Place,ExamMode,"
"Structure,DocRequired,MatRequired,MatAllowed,OtherInfo"
" FROM exam_announcements WHERE ExaCod=%ld",
"SELECT CrsCod," // row[ 0]
"Status," // row[ 1]
"CrsFullName," // row[ 2]
"Year," // row[ 3]
"ExamSession," // row[ 4]
"CallDate," // row[ 5]
"ExamDate," // row[ 6]
"Duration," // row[ 7]
"Place," // row[ 8]
"ExamMode," // row[ 9]
"Structure," // row[10]
"DocRequired," // row[11]
"MatRequired," // row[12]
"MatAllowed," // row[13]
"OtherInfo" // row[14]
" FROM cfe_calls_for_exams"
" WHERE ExaCod=%ld",
ExaCod);
/***** The result of the query must have one row *****/

View File

@ -600,14 +600,18 @@ TODO: Salvador Romero Cort
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
*/
#define Log_PLATFORM_VERSION "SWAD 20.51 (2021-03-18)"
#define Log_PLATFORM_VERSION "SWAD 20.51.1 (2021-03-18)"
#define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.6.2.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.51: Mar 18, 2021 Call for exam module renamed. (307459 lines)
Version 20.51.1: Mar 18, 2021 Calls for exams database table renamed. (? lines)
1 change necessary in database:
RENAME TABLE exam_announcements TO cfe_calls_for_exams;
Version 20.51: Mar 18, 2021 Calls for exams module renamed. (307459 lines)
Version 20.50.11: Mar 17, 2021 Departments database table renamed. (307450 lines)
1 change necessary in database:
RENAME TABLE departments TO dpt_departments;

View File

@ -462,11 +462,12 @@ static unsigned Con_GetConnectedUsrsTotal (Rol_Role_t Role)
return 0;
/***** Get number of connected users with a role from database *****/
return
(unsigned) DB_QueryCOUNT ("can not get number of connected users",
"SELECT COUNT(*) FROM connected"
" WHERE RoleInLastCrs=%u",
(unsigned) Role);
return (unsigned)
DB_QueryCOUNT ("can not get number of connected users",
"SELECT COUNT(*)"
" FROM usr_connected"
" WHERE RoleInLastCrs=%u",
(unsigned) Role);
}
/*****************************************************************************/

View File

@ -1931,22 +1931,26 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
/***** Remove information of the course ****/
/* Remove timetable of the course */
DB_QueryDELETE ("can not remove the timetable of a course",
"DELETE FROM timetable_crs WHERE CrsCod=%ld",
"DELETE FROM timetable_crs"
" WHERE CrsCod=%ld",
CrsCod);
/* Remove other information of the course */
DB_QueryDELETE ("can not remove info sources of a course",
"DELETE FROM crs_info_src WHERE CrsCod=%ld",
"DELETE FROM crs_info_src"
" WHERE CrsCod=%ld",
CrsCod);
DB_QueryDELETE ("can not remove info of a course",
"DELETE FROM crs_info_txt WHERE CrsCod=%ld",
"DELETE FROM crs_info_txt"
" WHERE CrsCod=%ld",
CrsCod);
/***** Remove exam announcements in the course *****/
/* Mark all exam announcements in the course as deleted */
DB_QueryUPDATE ("can not remove exam announcements of a course",
"UPDATE exam_announcements SET Status=%u"
"UPDATE cfe_calls_for_exams"
" SET Status=%u"
" WHERE CrsCod=%ld",
(unsigned) Cfe_DELETED_CALL_FOR_EXAM,CrsCod);
@ -1954,14 +1958,16 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
/* Remove content of course cards */
DB_QueryDELETE ("can not remove content of cards in a course",
"DELETE FROM crs_records"
" USING crs_record_fields,crs_records"
" USING crs_record_fields,"
"crs_records"
" WHERE crs_record_fields.CrsCod=%ld"
" AND crs_record_fields.FieldCod=crs_records.FieldCod",
" AND crs_record_fields.FieldCod=crs_records.FieldCod",
CrsCod);
/* Remove definition of fields in course cards */
DB_QueryDELETE ("can not remove fields of cards in a course",
"DELETE FROM crs_record_fields WHERE CrsCod=%ld",
"DELETE FROM crs_record_fields"
" WHERE CrsCod=%ld",
CrsCod);
/***** Remove information related to files in course,

View File

@ -409,6 +409,54 @@ mysql> DESCRIBE brw_clipboards;
"INDEX(FileBrowser,Cod),"
"INDEX(WorksUsrCod))");
/***** Table cfe_calls_for_exams *****/
/*
mysql> DESCRIBE cfe_calls_for_exams;
+-------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+----------------+
| ExaCod | int(11) | NO | PRI | NULL | auto_increment |
| CrsCod | int(11) | NO | MUL | -1 | |
| Status | tinyint(4) | NO | MUL | 0 | |
| NumNotif | int(11) | NO | | 0 | |
| CrsFullName | varchar(2047) | NO | | NULL | |
| Year | tinyint(4) | NO | | NULL | |
| ExamSession | varchar(2047) | NO | | NULL | |
| CallDate | datetime | NO | | NULL | |
| ExamDate | datetime | NO | | NULL | |
| Duration | time | NO | | NULL | |
| Place | text | NO | | NULL | |
| ExamMode | text | NO | | NULL | |
| Structure | text | NO | | NULL | |
| DocRequired | text | NO | | NULL | |
| MatRequired | text | NO | | NULL | |
| MatAllowed | text | NO | | NULL | |
| OtherInfo | text | NO | | NULL | |
+-------------+---------------+------+-----+---------+----------------+
17 rows in set (0,00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS cfe_calls_for_exams ("
"ExaCod INT NOT NULL AUTO_INCREMENT,"
"CrsCod INT NOT NULL DEFAULT -1,"
"Status TINYINT NOT NULL DEFAULT 0,"
"NumNotif INT NOT NULL DEFAULT 0,"
"CrsFullName VARCHAR(2047) NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME
"Year TINYINT NOT NULL,"
"ExamSession VARCHAR(2047) NOT NULL," // Cfe_MAX_BYTES_SESSION
"CallDate DATETIME NOT NULL,"
"ExamDate DATETIME NOT NULL,"
"Duration TIME NOT NULL,"
"Place TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"ExamMode TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"Structure TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"DocRequired TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"MatRequired TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"MatAllowed TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"OtherInfo TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(ExaCod),"
"INDEX(CrsCod,Status),"
"INDEX(Status))");
/***** Table cht_rooms *****/
/*
mysql> DESCRIBE cht_rooms;
@ -1181,54 +1229,6 @@ mysql> DESCRIBE exa_sets;
"UNIQUE INDEX(SetCod),"
"UNIQUE INDEX(ExaCod,SetInd))");
/***** Table exam_announcements *****/
/*
mysql> DESCRIBE exam_announcements;
+-------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------+------+-----+---------+----------------+
| ExaCod | int(11) | NO | PRI | NULL | auto_increment |
| CrsCod | int(11) | NO | MUL | -1 | |
| Status | tinyint(4) | NO | MUL | 0 | |
| NumNotif | int(11) | NO | | 0 | |
| CrsFullName | varchar(2047) | NO | | NULL | |
| Year | tinyint(4) | NO | | NULL | |
| ExamSession | varchar(2047) | NO | | NULL | |
| CallDate | datetime | NO | | NULL | |
| ExamDate | datetime | NO | | NULL | |
| Duration | time | NO | | NULL | |
| Place | text | NO | | NULL | |
| ExamMode | text | NO | | NULL | |
| Structure | text | NO | | NULL | |
| DocRequired | text | NO | | NULL | |
| MatRequired | text | NO | | NULL | |
| MatAllowed | text | NO | | NULL | |
| OtherInfo | text | NO | | NULL | |
+-------------+---------------+------+-----+---------+----------------+
17 rows in set (0,00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS exam_announcements ("
"ExaCod INT NOT NULL AUTO_INCREMENT,"
"CrsCod INT NOT NULL DEFAULT -1,"
"Status TINYINT NOT NULL DEFAULT 0,"
"NumNotif INT NOT NULL DEFAULT 0,"
"CrsFullName VARCHAR(2047) NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME
"Year TINYINT NOT NULL,"
"ExamSession VARCHAR(2047) NOT NULL," // Cfe_MAX_BYTES_SESSION
"CallDate DATETIME NOT NULL,"
"ExamDate DATETIME NOT NULL,"
"Duration TIME NOT NULL,"
"Place TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"ExamMode TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"Structure TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"DocRequired TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"MatRequired TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"MatAllowed TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"OtherInfo TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(ExaCod),"
"INDEX(CrsCod,Status),"
"INDEX(Status))");
/***** Table expanded_folders *****/
/*
mysql> DESCRIBE expanded_folders;

View File

@ -61,9 +61,9 @@ mysql> SHOW TABLES LIKE 'tml_%';
| | (3863) | |
|Publication i+3|-- | |
|(original note)| \ | |
|_______________| \ ___tml_notes___ | | exam_announcements
|_______________| \ ___tml_notes___ | | _calls_for_exams
| | \ | | | | | |
|Publication i+2|-- ---->| Note n |<-+ | | Exam announc. | (5571)
|Publication i+2|-- ---->| Note n |<-+ | | Call for exam | (5571)
|(original note)| \ |(exam announc.)|-(2639)->|_______________|
|_______________| \ |_______________| 12% ____files____
| | \ | | | | |