From 3b6a4f4443898490e4e8f996b2ccc0e916af94c8 Mon Sep 17 00:00:00 2001 From: acanas Date: Thu, 21 May 2020 14:17:26 +0200 Subject: [PATCH] Version19.239.8 --- swad_changelog.h | 5 +++-- swad_exam_session.c | 35 ++++++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index eb92915e6..944e9d564 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -557,10 +557,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.239.7 (2020-05-21)" +#define Log_PLATFORM_VERSION "SWAD 19.239.8 (2020-05-21)" #define CSS_FILE "swad19.238.2.css" #define JS_FILE "swad19.239.6.js" /* + Version 19.239.8: May 21, 2020 Fixed issue in exam sessions: a student can not see hidden sessions. (301433 lines) Version 19.239.7: May 21, 2020 Fixed bug in permissions to see exam results. Reported by Eduardo Ros Vidal. (301412 lines) Version 19.239.6: May 21, 2020 Code refactoring in JS function to escape chars. (301411 lines) Version 19.239.5: May 21, 2020 Fixed bug in charset in answer forms in exam prints. (301405 lines) @@ -696,7 +697,7 @@ DELETE FROM figures; UPDATE usr_data SET SideCols=0 WHERE (SideCols & 1)<>0 AND UsrCod NOT IN (SELECT UsrCod FROM crs_usr WHERE Role>3); Version 19.219: May 09, 2020 Create exam print. (302347 lines) - 2 change necessary in database: + 2 changes necessary in database: CREATE TABLE IF NOT EXISTS exa_prints (PrnCod INT NOT NULL AUTO_INCREMENT,EvtCod INT NOT NULL,UsrCod INT NOT NULL,StartTime DATETIME NOT NULL,EndTime DATETIME NOT NULL,NumQsts INT NOT NULL DEFAULT 0,NumQstsNotBlank INT NOT NULL DEFAULT 0,Sent ENUM('N','Y') NOT NULL DEFAULT 'N',Score DOUBLE PRECISION NOT NULL DEFAULT 0,UNIQUE INDEX(PrnCod),UNIQUE INDEX(EvtCod,UsrCod)); CREATE TABLE IF NOT EXISTS exa_print_questions (PrnCod INT NOT NULL,QstCod INT NOT NULL,QstInd INT NOT NULL,Score DOUBLE PRECISION NOT NULL DEFAULT 0,Indexes TEXT NOT NULL,Answers TEXT NOT NULL,UNIQUE INDEX(PrnCod,QstCod)); diff --git a/swad_exam_session.c b/swad_exam_session.c index ce1fc7cda..872b8c49d 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -151,14 +151,35 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams, { extern const char *Hlp_ASSESSMENT_Exams_sessions; extern const char *Txt_Sessions; + char *HiddenSubQuery; char *GroupsSubQuery; MYSQL_RES *mysql_res; unsigned NumSessions; long SesCodToBeEdited; bool PutFormNewSession; - /***** Get data of sessions from database *****/ - /* Fill groups subquery for exam */ + /***** Subquery: get hidden sessions depending on user's role *****/ + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_STD: + if (asprintf (&HiddenSubQuery," AND Hidden='N'") < 0) + Lay_NotEnoughMemoryExit (); + break; + case Rol_NET: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + if (asprintf (&HiddenSubQuery,"%s","") < 0) + Lay_NotEnoughMemoryExit (); + break; + default: + Rol_WrongRoleExit (); + break; + } + + /***** Subquery: get sessions depending on groups *****/ if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS) { if (asprintf (&GroupsSubQuery," AND" @@ -177,7 +198,7 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams, if (asprintf (&GroupsSubQuery,"%s","") < 0) Lay_NotEnoughMemoryExit (); - /* Make query */ + /***** Get data of sessions from database *****/ NumSessions = (unsigned) DB_QuerySELECT (&mysql_res,"can not get sessions", "SELECT SesCod," // row[0] @@ -190,13 +211,13 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams, "Title," // row[7] "ShowUsrResults" // row[8] " FROM exa_sessions" - " WHERE ExaCod=%ld%s" + " WHERE ExaCod=%ld%s%s" " ORDER BY SesCod", - Exam->ExaCod, - GroupsSubQuery); + Exam->ExaCod,HiddenSubQuery,GroupsSubQuery); - /* Free allocated memory for subquery */ + /***** Free allocated memory for subqueries *****/ free (GroupsSubQuery); + free (HiddenSubQuery); /***** Begin box *****/ Exams->ExaCod = Exam->ExaCod;