From a1ffed3be1e4409fbcd75753c4e8216478045cb4 Mon Sep 17 00:00:00 2001 From: acanas Date: Wed, 24 Mar 2021 13:36:04 +0100 Subject: [PATCH] Version 20.51.42: Mar 24, 2021 Exam logs database tables renamed. --- sql/swad.sql | 50 ++++++++++++++++++++++++------------------------ swad_changelog.h | 9 +++++++-- swad_database.c | 12 ++++++------ swad_exam_log.c | 37 ++++++++++++++++++----------------- 4 files changed, 57 insertions(+), 51 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index 26e8ee942..64a2fc2d7 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -493,26 +493,6 @@ CREATE TABLE IF NOT EXISTS dpt_departments ( UNIQUE INDEX(DptCod), INDEX(InsCod)); -- --- Table exa_groups: stores the groups associated to each event in an exam --- -CREATE TABLE IF NOT EXISTS exa_groups ( - SesCod INT NOT NULL, - GrpCod INT NOT NULL, - UNIQUE INDEX(SesCod,GrpCod)); --- --- Table exa_sessions: stores the exam sessions that have already taken place --- -CREATE TABLE IF NOT EXISTS exa_sessions ( - SesCod INT NOT NULL AUTO_INCREMENT, - ExaCod INT NOT NULL, - Hidden ENUM('N','Y') NOT NULL DEFAULT 'N', - UsrCod INT NOT NULL, - StartTime DATETIME NOT NULL, - EndTime DATETIME NOT NULL, - Title VARCHAR(2047) NOT NULL, - UNIQUE INDEX(SesCod), - INDEX(ExaCod)); --- -- Table exa_exams: stores the exams -- CREATE TABLE IF NOT EXISTS exa_exams ( @@ -527,6 +507,13 @@ CREATE TABLE IF NOT EXISTS exa_exams ( UNIQUE INDEX(ExaCod), INDEX(CrsCod)); -- +-- Table exa_groups: stores the groups associated to each session in an exam +-- +CREATE TABLE IF NOT EXISTS exa_groups ( + SesCod INT NOT NULL, + GrpCod INT NOT NULL, + UNIQUE INDEX(SesCod,GrpCod)); +-- -- Table exa_log: stores the access log to exam prints -- CREATE TABLE IF NOT EXISTS exa_log ( @@ -541,18 +528,18 @@ CREATE TABLE IF NOT EXISTS exa_log ( UNIQUE INDEX(PrnCod,LogCod), INDEX(ClickTime)); -- --- Table exa_log_session: stores the session id field for access log to exam prints +-- Table exa_log_sessions: stores the session id fields for access log to exam prints -- -CREATE TABLE IF NOT EXISTS exa_log_session ( +CREATE TABLE IF NOT EXISTS exa_log_sessions ( LogCod INT NOT NULL, PrnCod INT NOT NULL, SessionId CHAR(43) NOT NULL, UNIQUE INDEX(LogCod), UNIQUE INDEX(PrnCod,LogCod)); -- --- Table exa_log_user_agent: stores the user agent field for access log to exam prints +-- Table exa_log_user_agents: stores the user agent fields for access log to exam prints -- -CREATE TABLE IF NOT EXISTS exa_log_user_agent ( +CREATE TABLE IF NOT EXISTS exa_log_user_agents ( LogCod INT NOT NULL, PrnCod INT NOT NULL, UserAgent TEXT NOT NULL, @@ -571,7 +558,7 @@ CREATE TABLE IF NOT EXISTS exa_print_questions ( Answers TEXT NOT NULL, UNIQUE INDEX(PrnCod,QstCod)); -- --- Table exa_prints: stores the exam prints of every exam event +-- Table exa_prints: stores the exam prints of every exam session -- CREATE TABLE IF NOT EXISTS exa_prints ( PrnCod INT NOT NULL AUTO_INCREMENT, @@ -586,6 +573,19 @@ CREATE TABLE IF NOT EXISTS exa_prints ( UNIQUE INDEX(PrnCod), UNIQUE INDEX(SesCod,UsrCod)); -- +-- Table exa_sessions: stores the exam sessions +-- +CREATE TABLE IF NOT EXISTS exa_sessions ( + SesCod INT NOT NULL AUTO_INCREMENT, + ExaCod INT NOT NULL, + Hidden ENUM('N','Y') NOT NULL DEFAULT 'N', + UsrCod INT NOT NULL, + StartTime DATETIME NOT NULL, + EndTime DATETIME NOT NULL, + Title VARCHAR(2047) NOT NULL, + UNIQUE INDEX(SesCod), + INDEX(ExaCod)); +-- -- Table exa_set_answers: stores the answers of questions in exam sets -- CREATE TABLE IF NOT EXISTS exa_set_answers ( diff --git a/swad_changelog.h b/swad_changelog.h index 481289ce6..141410e8e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -600,14 +600,19 @@ 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.41 (2021-03-24)" +#define Log_PLATFORM_VERSION "SWAD 20.51.42 (2021-03-24)" #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.41: Mar 24, 2021 Course user settings database table renamed. (? lines) + Version 20.51.42: Mar 24, 2021 Exam logs database tables renamed. (308703 lines) + 2 changes necessary in database: +RENAME TABLE exa_log_session TO exa_log_sessions; +RENAME TABLE exa_log_user_agent TO exa_log_user_agents; + + Version 20.51.41: Mar 24, 2021 Course user settings database table renamed. (308698 lines) 1 change necessary in database: RENAME TABLE crs_usr_last TO crs_user_settings; diff --git a/swad_database.c b/swad_database.c index e48e2be21..d094b558a 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1161,9 +1161,9 @@ mysql> DESCRIBE exa_log; "UNIQUE INDEX(PrnCod,LogCod)," "INDEX(ClickTime))"); - /***** Table exa_log_session *****/ + /***** Table exa_log_sessions *****/ /* -mysql> DESCRIBE exa_log_session; +mysql> DESCRIBE exa_log_sessions; +-----------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+----------+------+-----+---------+-------+ @@ -1174,16 +1174,16 @@ mysql> DESCRIBE exa_log_session; 3 rows in set (0.00 sec) */ // TODO: Change NtfCod and LogCod from INT to BIGINT in database tables. - DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_log_session (" + DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_log_sessions (" "LogCod INT NOT NULL," "PrnCod INT NOT NULL," "SessionId CHAR(43) NOT NULL," // Cns_BYTES_SESSION_ID "UNIQUE INDEX(LogCod)," "UNIQUE INDEX(PrnCod,LogCod))"); - /***** Table exa_log_user_agent *****/ + /***** Table exa_log_user_agents *****/ /* -mysql> DESCRIBE exa_log_user_agent; +mysql> DESCRIBE exa_log_user_agents; +-----------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------+------+-----+---------+-------+ @@ -1194,7 +1194,7 @@ mysql> DESCRIBE exa_log_user_agent; 3 rows in set (0.00 sec) */ // TODO: Change NtfCod and LogCod from INT to BIGINT in database tables. - DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_log_user_agent (" + DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_log_user_agents (" "LogCod INT NOT NULL," "PrnCod INT NOT NULL," "UserAgent TEXT NOT NULL," diff --git a/swad_exam_log.c b/swad_exam_log.c index 6e65617e1..8d3a40272 100644 --- a/swad_exam_log.c +++ b/swad_exam_log.c @@ -182,12 +182,12 @@ static void ExaLog_LogSession (long LogCod,long PrnCod) is the same as the last stored in database *****/ TheSameAsTheLast = (DB_QueryCOUNT ("can not check session", "SELECT COUNT(*)" - " FROM exa_log_session" + " FROM exa_log_sessions" " WHERE LogCod=" - "(SELECT MAX(LogCod)" - " FROM exa_log_session" - " WHERE PrnCod=%ld)" - " AND SessionId='%s'", + "(SELECT MAX(LogCod)" + " FROM exa_log_sessions" + " WHERE PrnCod=%ld)" + " AND SessionId='%s'", PrnCod, Gbl.Session.Id) != 0); @@ -196,7 +196,7 @@ static void ExaLog_LogSession (long LogCod,long PrnCod) only if it's not the same as the last one stored *****/ if (!TheSameAsTheLast) DB_QueryINSERT ("can not log session", - "INSERT INTO exa_log_session " + "INSERT INTO exa_log_sessions " "(LogCod,PrnCod,SessionId)" " VALUES " "(%ld,%ld,'%s')", @@ -245,12 +245,12 @@ static void ExaLog_LogUsrAgent (long LogCod,long PrnCod) is the same as the last stored in database *****/ TheSameAsTheLast = (DB_QueryCOUNT ("can not check user agent", "SELECT COUNT(*)" - " FROM exa_log_user_agent" + " FROM exa_log_user_agents" " WHERE LogCod=" - "(SELECT MAX(LogCod)" - " FROM exa_log_user_agent" - " WHERE PrnCod=%ld)" - " AND UserAgent='%s'", + "(SELECT MAX(LogCod)" + " FROM exa_log_user_agents" + " WHERE PrnCod=%ld)" + " AND UserAgent='%s'", PrnCod, UserAgentDB) != 0); @@ -259,7 +259,7 @@ static void ExaLog_LogUsrAgent (long LogCod,long PrnCod) only if it's not the same as the last one stored *****/ if (!TheSameAsTheLast) DB_QueryINSERT ("can not log user agent", - "INSERT INTO exa_log_user_agent " + "INSERT INTO exa_log_user_agents " "(LogCod,PrnCod,UserAgent)" " VALUES " "(%ld,%ld,'%s')", @@ -313,12 +313,13 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print) "exa_log.CanAnswer," // row[2] "UNIX_TIMESTAMP(exa_log.ClickTime)," // row[3] "exa_log.IP," // row[4] - "exa_log_session.SessionId," // row[5] - "exa_log_user_agent.UserAgent" // row[6] - " FROM exa_log LEFT JOIN exa_log_session" - " ON exa_log.LogCod=exa_log_session.LogCod" - " LEFT JOIN exa_log_user_agent" - " ON exa_log.LogCod=exa_log_user_agent.LogCod" + "exa_log_sessions.SessionId," // row[5] + "exa_log_user_agents.UserAgent" // row[6] + " FROM exa_log" + " LEFT JOIN exa_log_sessions" + " ON exa_log.LogCod=exa_log_sessions.LogCod" + " LEFT JOIN exa_log_user_agents" + " ON exa_log.LogCod=exa_log_user_agents.LogCod" " WHERE exa_log.PrnCod=%ld" " ORDER BY exa_log.LogCod", Print->PrnCod);