From 5611c0e7e7d23924961f1160e8463fb0130a4597 Mon Sep 17 00:00:00 2001 From: acanas Date: Wed, 8 Sep 2021 11:05:08 +0200 Subject: [PATCH] Version 20.96.2: Sep 08, 2021 Queries moved to module swad_exam_database. --- swad_account.c | 2 +- swad_changelog.h | 3 +- swad_enrolment.c | 2 +- swad_exam.c | 20 +- swad_exam_database.c | 175 +++++------- swad_exam_database.h | 28 +- swad_exam_result.c | 666 ++++++++++++++++++++++--------------------- swad_exam_session.c | 15 +- swad_group.c | 4 +- 9 files changed, 453 insertions(+), 462 deletions(-) diff --git a/swad_account.c b/swad_account.c index 933f290b..d99767a1 100644 --- a/swad_account.c +++ b/swad_account.c @@ -1017,7 +1017,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, /***** Remove test, exams and matches made by user in all courses *****/ TstPrn_RemovePrintsMadeByUsrInAllCrss (UsrDat->UsrCod); - Exa_DB_RemovePrintQuestionsMadeByUsrInAllCrss (UsrDat->UsrCod); + Exa_DB_RemovePrintQstsMadeByUsrInAllCrss (UsrDat->UsrCod); Exa_DB_RemovePrintsMadeByUsrInAllCrss (UsrDat->UsrCod); Mch_RemoveMatchesMadeByUsrInAllCrss (UsrDat->UsrCod); diff --git a/swad_changelog.h b/swad_changelog.h index e373810b..fd7d018d 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.96.1 (2021-07-30)" +#define Log_PLATFORM_VERSION "SWAD 20.96.2 (2021-09-08)" #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.96.2: Sep 08, 2021 Queries moved to module swad_exam_database. (314362 lines) Version 20.96.1: Jul 30, 2021 Fix bugs removing exams. (314373 lines) Version 20.96: Jul 27, 2021 Queries moved to module swad_exam_database. (314247 lines) Version 20.95.3: Jul 20, 2021 Queries moved to module swad_exam_database. (314210 lines) diff --git a/swad_enrolment.c b/swad_enrolment.c index 4a0a9699..d7622892 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -3212,7 +3212,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat, /* Remove tests, exams and matches results made by user in course */ TstPrn_RemovePrintsMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod); - Exa_DB_RemovePrintsQuestionsMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod); + Exa_DB_RemovePrintQstsMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod); Exa_DB_RemovePrintsMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod); Mch_RemoveMatchesMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod); } diff --git a/swad_exam.c b/swad_exam.c index c48a05f8..c3edc131 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -1078,12 +1078,14 @@ void Exa_RemoveExam (void) static void Exa_RemoveExamFromAllTables (long ExaCod) { - /***** Remove questions of exams prints, and exam prints, of this exam *****/ - Exa_DB_RemovePrintQuestionsFromExam (ExaCod); - Exa_DB_RemovePrintsFromExam (ExaCod); + /***** Remove questions of exams prints, and exam prints, in this exam *****/ + // TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints + Exa_DB_RemovePrintQstsFromExa (ExaCod); + Exa_DB_RemovePrintsFromExa (ExaCod); - /***** Remove all sessions in this exam *****/ - Exa_DB_RemoveSessionsInExamFromAllTables (ExaCod); + /***** Remove groups associated to sessions, and sessions, in this exam *****/ + Exa_DB_RemoveGrpsFromExa (ExaCod); + Exa_DB_RemoveSessionsFromExam (ExaCod); /***** Remove media associated to exam questions in the exam *****/ Exa_RemoveAllMedFilesFromStemOfAllQstsFromExam (ExaCod); @@ -1108,11 +1110,13 @@ void Exa_RemoveCrsExams (long CrsCod) { /***** Remove questions of exams prints, and exam prints, made in the given course *****/ - Exa_DB_RemovePrintQuestionsFromCrs (CrsCod); + // TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints + Exa_DB_RemovePrintQstsFromCrs (CrsCod); Exa_DB_RemovePrintsFromCrs (CrsCod); - /***** Remove all sessions in the course *****/ - Exa_DB_RemoveSessionInCourseFromAllTables (CrsCod); + /***** Remove groups associated to sessions, and sessions, in this course *****/ + Exa_DB_RemoveGrpsFromCrs (CrsCod); + Exa_DB_RemoveSessionsFromCrs (CrsCod); /***** Remove media associated to test questions in the course *****/ Exa_RemoveAllMedFilesFromStemOfAllQstsFromCrs (CrsCod); diff --git a/swad_exam_database.c b/swad_exam_database.c index 33fef0f3..b4ed09a7 100644 --- a/swad_exam_database.c +++ b/swad_exam_database.c @@ -873,26 +873,6 @@ void Exa_DB_HideUnhideSession (const struct ExaSes_Session *Session,bool Hide) void Exa_DB_RemoveSessionFromAllTables (long SesCod) { - /* To delete orphan exam prints: - // DELETE FROM exa_print_questions WHERE PrnCod IN (SELECT PrnCod FROM exa_prints WHERE SesCod NOT IN (SELECT SesCod FROM exa_sessions)); - // DELETE FROM exa_prints WHERE SesCod NOT IN (SELECT SesCod FROM exa_sessions); - */ - /***** Remove exam prints in this session *****/ - /* - * TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints - DB_QueryDELETE ("can not remove exam print questions in exam session", - "DELETE FROM exa_print_questions" - " USING exa_print_questions, - "exa_prints" - " WHERE exa_prints.SesCod=%ld" - " AND exa_prints.PrnCod=exa_print_questions.PrnCod", - SesCod); - DB_QueryDELETE ("can not remove exam prints in exam session", - "DELETE FROM exa_prints" - " WHERE exa_prints.SesCod=%ld", - SesCod); - */ - /***** Remove groups associated to this exam session *****/ DB_QueryDELETE ("can not remove groups associated to exam session", "DELETE FROM exa_groups" @@ -907,42 +887,11 @@ void Exa_DB_RemoveSessionFromAllTables (long SesCod) } /*****************************************************************************/ -/**************** Remove exam session in exam from all tables ****************/ +/*********************** Remove exam sessions from exam **********************/ /*****************************************************************************/ -void Exa_DB_RemoveSessionsInExamFromAllTables (long ExaCod) +void Exa_DB_RemoveSessionsFromExam (long ExaCod) { - /***** Remove exam prints in this session *****/ - /* - * TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints - DB_QueryDELETE ("can not remove exam print questions in exam", - "DELETE FROM exa_print_questions" - " USING exa_print_questions, - "exa_prints, - "exa_sessions" - " WHERE exa_sessions.ExaCod=%ld" - " AND exa_sessions.SesCod=exa_prints.SesCod" - " AND exa_prints.PrnCod=exa_print_questions.PrnCod", - ExaCod); - DB_QueryDELETE ("can not remove exam prints in exam", - "DELETE FROM exa_prints" - " USING exa_prints, - "exa_sessions" - " WHERE exa_sessions.ExaCod=%ld" - " AND exa_sessions.SesCod=exa_prints.SesCod", - ExaCod); - */ - - /***** Remove groups associated to exam sessions of this exam *****/ - DB_QueryDELETE ("can not remove groups associated to sessions of an exam", - "DELETE FROM exa_groups" - " USING exa_sessions," - "exa_groups" - " WHERE exa_sessions.ExaCod=%ld" - " AND exa_sessions.SesCod=exa_groups.SesCod", - ExaCod); - - /***** Remove sessions from main table *****/ DB_QueryDELETE ("can not remove sessions of an exam", "DELETE FROM exa_sessions" " WHERE ExaCod=%ld", @@ -950,48 +899,11 @@ void Exa_DB_RemoveSessionsInExamFromAllTables (long ExaCod) } /*****************************************************************************/ -/*************** Remove exam session in course from all tables ***************/ +/********************** Remove exam sessions from course *********************/ /*****************************************************************************/ -void Exa_DB_RemoveSessionInCourseFromAllTables (long CrsCod) +void Exa_DB_RemoveSessionsFromCrs (long CrsCod) { - /***** Remove exam prints in this course *****/ - /* - * TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints - DB_QueryDELETE ("can not remove exam print questions in course", - "DELETE FROM exa_print_questions" - " USING exa_print_questions, - "exa_prints, - "exa_sessions, - "exa_exams" - " WHERE exa_exams.CrsCod=%ld" - " AND exa_exams.ExaCod=exa_sessions" - " AND exa_sessions.SesCod=exa_prints.SesCod" - " AND exa_prints.PrnCod=exa_print_questions.PrnCod", - CrsCod); - DB_QueryDELETE ("can not remove exam print questions in course", - "DELETE FROM exa_prints" - " USING exa_prints, - "exa_sessions, - "exa_exams" - " WHERE exa_exams.CrsCod=%ld" - " AND exa_exams.ExaCod=exa_sessions" - " AND exa_sessions.SesCod=exa_prints.SesCod", - CrsCod); - */ - - /***** Remove sessions from table of sessions groups *****/ - DB_QueryDELETE ("can not remove sessions of a course", - "DELETE FROM exa_groups" - " USING exa_exams," - "exa_sessions," - "exa_groups" - " WHERE exa_exams.CrsCod=%ld" - " AND exa_exams.ExaCod=exa_sessions.ExaCod" - " AND exa_sessions.SesCod=exa_groups.SesCod", - CrsCod); - - /***** Remove sessions from exam sessions table *****/ DB_QueryDELETE ("can not remove sessions of a course", "DELETE FROM exa_sessions" " USING exa_exams," @@ -1035,7 +947,7 @@ static void Exa_DB_RemoveUsrSesResultsInCrs (long UsrCod,long CrsCod,const char /**************** Create group associated to an exam session *****************/ /*****************************************************************************/ -void Exa_DB_CreateGrpAssociatedToSession (long SesCod,long GrpCod) +void Exa_DB_CreateGrpAssociatedToSes (long SesCod,long GrpCod) { DB_QueryINSERT ("can not associate a group to an exam session", "INSERT INTO exa_groups" @@ -1050,7 +962,7 @@ void Exa_DB_CreateGrpAssociatedToSession (long SesCod,long GrpCod) /*********** Get groups associated to an exam session from database **********/ /*****************************************************************************/ -unsigned Exa_DB_GetGrpsAssociatedToSession (MYSQL_RES **mysql_res,long SesCod) +unsigned Exa_DB_GetGrpsAssociatedToSes (MYSQL_RES **mysql_res,long SesCod) { return (unsigned) DB_QuerySELECT (mysql_res,"can not get groups of an exam session", @@ -1094,7 +1006,7 @@ bool Exa_DB_CheckIfICanListThisSessionBasedOnGrps (long SesCod) /******************** Remove all groups from one session *********************/ /*****************************************************************************/ -void Exa_DB_RemoveAllGrpsAssociatedToSession (long SesCod) +void Exa_DB_RemoveGrpsFromSes (long SesCod) { DB_QueryDELETE ("can not remove groups associated to a session", "DELETE FROM exa_groups" @@ -1102,11 +1014,43 @@ void Exa_DB_RemoveAllGrpsAssociatedToSession (long SesCod) SesCod); } +/*****************************************************************************/ +/********* Remove groups associated to exam sessions of a given exam *********/ +/*****************************************************************************/ + +void Exa_DB_RemoveGrpsFromExa (long ExaCod) + { + DB_QueryDELETE ("can not remove groups associated to sessions of an exam", + "DELETE FROM exa_groups" + " USING exa_sessions," + "exa_groups" + " WHERE exa_sessions.ExaCod=%ld" + " AND exa_sessions.SesCod=exa_groups.SesCod", + ExaCod); + } + +/*****************************************************************************/ +/******** Remove groups associated to exam sessions of a given course ********/ +/*****************************************************************************/ + +void Exa_DB_RemoveGrpsFromCrs (long CrsCod) + { + DB_QueryDELETE ("can not remove sessions of a course", + "DELETE FROM exa_groups" + " USING exa_exams," + "exa_sessions," + "exa_groups" + " WHERE exa_exams.CrsCod=%ld" + " AND exa_exams.ExaCod=exa_sessions.ExaCod" + " AND exa_sessions.SesCod=exa_groups.SesCod", + CrsCod); + } + /*****************************************************************************/ /**************** Remove groups of one type from all sessions ****************/ /*****************************************************************************/ -void Exa_DB_RemoveGroupsOfType (long GrpTypCod) +void Exa_DB_RemoveGrpsOfType (long GrpTypCod) { DB_QueryDELETE ("can not remove groups of a type" " from the associations between sessions and groups", @@ -1122,7 +1066,7 @@ void Exa_DB_RemoveGroupsOfType (long GrpTypCod) /******************** Remove one group from all sessions *********************/ /*****************************************************************************/ -void Exa_DB_RemoveGrpAssociatedToExamSessions (long GrpCod) +void Exa_DB_RemoveGrpAssociatedToExamSess (long GrpCod) { /***** Remove group from all the sessions *****/ DB_QueryDELETE ("can not remove group" @@ -1256,11 +1200,23 @@ void Exa_DB_RemovePrintsMadeByUsrInCrs (long UsrCod,long CrsCod) UsrCod); } +/*****************************************************************************/ +/************ Remove exams prints made in the given exam session *************/ +/*****************************************************************************/ + +void Exa_DB_RemovePrintsFromSes (long SesCod) + { + DB_QueryDELETE ("can not remove exam prints in exam session", + "DELETE FROM exa_prints" + " WHERE exa_prints.SesCod=%ld", + SesCod); + } + /*****************************************************************************/ /**************** Remove exams prints made in the given exam *****************/ /*****************************************************************************/ -void Exa_DB_RemovePrintsFromExam (long ExaCod) +void Exa_DB_RemovePrintsFromExa (long ExaCod) { DB_QueryDELETE ("can not remove exams prints in a course", "DELETE FROM exa_prints" @@ -1378,7 +1334,7 @@ double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod) /*************** Remove exam prints questions for a given user ***************/ /*****************************************************************************/ -void Exa_DB_RemovePrintQuestionsMadeByUsrInAllCrss (long UsrCod) +void Exa_DB_RemovePrintQstsMadeByUsrInAllCrss (long UsrCod) { DB_QueryDELETE ("can not remove exam prints made by a user", "DELETE FROM exa_print_questions" @@ -1393,7 +1349,7 @@ void Exa_DB_RemovePrintQuestionsMadeByUsrInAllCrss (long UsrCod) /* Remove questions of exams prints made by the given user in a given course */ /*****************************************************************************/ -void Exa_DB_RemovePrintsQuestionsMadeByUsrInCrs (long UsrCod,long CrsCod) +void Exa_DB_RemovePrintQstsMadeByUsrInCrs (long UsrCod,long CrsCod) { DB_QueryDELETE ("can not remove exams prints made by a user in a course", "DELETE FROM exa_print_questions" @@ -1410,11 +1366,26 @@ void Exa_DB_RemovePrintsQuestionsMadeByUsrInCrs (long UsrCod,long CrsCod) UsrCod); } +/*****************************************************************************/ +/************ Remove questions of exams prints in a given session ************/ +/*****************************************************************************/ + +void Exa_DB_RemovePrintQstsFromSes (long SesCod) + { + DB_QueryDELETE ("can not remove exam print questions in exam session", + "DELETE FROM exa_print_questions" + " USING exa_prints," + "exa_print_questions" + " WHERE exa_prints.SesCod=%ld" + " AND exa_prints.PrnCod=exa_print_questions.PrnCod", + SesCod); + } + /*****************************************************************************/ /************ Remove questions of exams prints in a given course *************/ /*****************************************************************************/ -void Exa_DB_RemovePrintQuestionsFromExam (long ExaCod) +void Exa_DB_RemovePrintQstsFromExa (long ExaCod) { DB_QueryDELETE ("can not remove exams prints in an exam", "DELETE FROM exa_print_questions" @@ -1431,7 +1402,7 @@ void Exa_DB_RemovePrintQuestionsFromExam (long ExaCod) /************ Remove questions of exams prints in a given course *************/ /*****************************************************************************/ -void Exa_DB_RemovePrintQuestionsFromCrs (long CrsCod) +void Exa_DB_RemovePrintQstsFromCrs (long CrsCod) { DB_QueryDELETE ("can not remove exams prints in a course", "DELETE FROM exa_print_questions" diff --git a/swad_exam_database.h b/swad_exam_database.h index 2dfb2be8..7889d0b4 100644 --- a/swad_exam_database.h +++ b/swad_exam_database.h @@ -89,16 +89,18 @@ unsigned Exa_DB_GetDataOfSessionByCod (MYSQL_RES **mysql_res,long SesCod); void Exa_DB_ToggleVisResultsSesUsr (const struct ExaSes_Session *Session); void Exa_DB_HideUnhideSession (const struct ExaSes_Session *Session,bool Hide); void Exa_DB_RemoveSessionFromAllTables (long SesCod); -void Exa_DB_RemoveSessionsInExamFromAllTables (long ExaCod); -void Exa_DB_RemoveSessionInCourseFromAllTables (long CrsCod); +void Exa_DB_RemoveSessionsFromExam (long ExaCod); +void Exa_DB_RemoveSessionsFromCrs (long CrsCod); void Exa_DB_RemoveUsrFromSessionTablesInCrs (long UsrCod,long CrsCod); -void Exa_DB_CreateGrpAssociatedToSession (long SesCod,long GrpCod); -unsigned Exa_DB_GetGrpsAssociatedToSession (MYSQL_RES **mysql_res,long SesCod); +void Exa_DB_CreateGrpAssociatedToSes (long SesCod,long GrpCod); +unsigned Exa_DB_GetGrpsAssociatedToSes (MYSQL_RES **mysql_res,long SesCod); bool Exa_DB_CheckIfICanListThisSessionBasedOnGrps (long SesCod); -void Exa_DB_RemoveAllGrpsAssociatedToSession (long SesCod); -void Exa_DB_RemoveGroupsOfType (long GrpTypCod); -void Exa_DB_RemoveGrpAssociatedToExamSessions (long GrpCod); +void Exa_DB_RemoveGrpsFromExa (long ExaCod); +void Exa_DB_RemoveGrpsFromCrs (long CrsCod); +void Exa_DB_RemoveGrpsFromSes (long SesCod); +void Exa_DB_RemoveGrpsOfType (long GrpTypCod); +void Exa_DB_RemoveGrpAssociatedToExamSess (long GrpCod); long Exa_DB_CreatePrint (const struct ExaPrn_Print *Print); void Exa_DB_UpdatePrint (const struct ExaPrn_Print *Print); @@ -107,7 +109,8 @@ unsigned Exa_DB_GetDataOfPrintBySesCodAndUsrCod (MYSQL_RES **mysql_res, long SesCod,long UsrCod); void Exa_DB_RemovePrintsMadeByUsrInAllCrss (long UsrCod); void Exa_DB_RemovePrintsMadeByUsrInCrs (long UsrCod,long CrsCod); -void Exa_DB_RemovePrintsFromExam (long ExaCod); +void Exa_DB_RemovePrintsFromSes (long SesCod); +void Exa_DB_RemovePrintsFromExa (long ExaCod); void Exa_DB_RemovePrintsFromCrs (long CrsCod); void Exa_DB_StoreOneQstOfPrint (const struct ExaPrn_Print *Print, @@ -117,10 +120,11 @@ void Exa_DB_GetAnswersFromQstInPrint (long PrnCod,long QstCod, char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]); unsigned Exa_DB_GetNumQstsNotBlankInPrint (long PrnCod); double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod); -void Exa_DB_RemovePrintQuestionsMadeByUsrInAllCrss (long UsrCod); -void Exa_DB_RemovePrintsQuestionsMadeByUsrInCrs (long UsrCod,long CrsCod); -void Exa_DB_RemovePrintQuestionsFromExam (long ExaCod); -void Exa_DB_RemovePrintQuestionsFromCrs (long CrsCod); +void Exa_DB_RemovePrintQstsMadeByUsrInAllCrss (long UsrCod); +void Exa_DB_RemovePrintQstsMadeByUsrInCrs (long UsrCod,long CrsCod); +void Exa_DB_RemovePrintQstsFromSes (long SesCod); +void Exa_DB_RemovePrintQstsFromExa (long ExaCod); +void Exa_DB_RemovePrintQstsFromCrs (long CrsCod); bool Exa_DB_CheckIfSessionIsTheSameAsTheLast (long PrnCod); bool Exa_DB_CheckIfUserAgentIsTheSameAsTheLast (long PrnCod,const char *UserAgentDB); diff --git a/swad_exam_result.c b/swad_exam_result.c index cd2fd836..8473b2b1 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -816,265 +816,273 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams, /***** Show user's data *****/ HTM_TR_Begin (NULL); - Usr_ShowTableCellWithUsrData (UsrDat,NumResults); + Usr_ShowTableCellWithUsrData (UsrDat,NumResults); - /***** Get and print sessions results *****/ - if (NumResults) - { - for (NumResult = 0; - NumResult < NumResults; - NumResult++) + /***** Get and print sessions results *****/ + if (NumResults) { - /* Get print code (row[0]) */ - if ((Print.PrnCod = DB_GetNextCode (mysql_res)) <= 0) - Err_WrongExamExit (); - - /* Get print data */ - ExaPrn_GetDataOfPrintByPrnCod (&Print); - - /* Get data of session and exam */ - Session.SesCod = Print.SesCod; - ExaSes_GetDataOfSessionByCod (&Session); - Exam.ExaCod = Session.ExaCod; - Exa_GetDataOfExamByCod (&Exam); - - /* Check if I can view this print result and its score */ - ExaRes_CheckIfICanViewResult (&Exam,&Session,UsrDat->UsrCod,&ICanView); - - if (NumResult) - HTM_TR_Begin (NULL); - - /* Write start/end times */ - for (StartEndTime = (Dat_StartEndTime_t) 0; - StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1); - StartEndTime++) + for (NumResult = 0; + NumResult < NumResults; + NumResult++) { - UniqueId++; - if (asprintf (&Id,"exa_res_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) - Err_NotEnoughMemoryExit (); - HTM_TD_Begin ("id =\"%s\" class=\"DAT LT COLOR%u\"", - Id,Gbl.RowEvenOdd); - Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, - true,true,false,0x7); + /* Get print code (row[0]) */ + if ((Print.PrnCod = DB_GetNextCode (mysql_res)) <= 0) + Err_WrongExamExit (); + + /* Get print data */ + ExaPrn_GetDataOfPrintByPrnCod (&Print); + + /* Get data of session and exam */ + Session.SesCod = Print.SesCod; + ExaSes_GetDataOfSessionByCod (&Session); + Exam.ExaCod = Session.ExaCod; + Exa_GetDataOfExamByCod (&Exam); + + /* Check if I can view this print result and its score */ + ExaRes_CheckIfICanViewResult (&Exam,&Session,UsrDat->UsrCod,&ICanView); + + if (NumResult) + HTM_TR_Begin (NULL); + + /* Write start/end times */ + for (StartEndTime = (Dat_StartEndTime_t) 0; + StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1); + StartEndTime++) + { + UniqueId++; + if (asprintf (&Id,"exa_res_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) + Err_NotEnoughMemoryExit (); + HTM_TD_Begin ("id =\"%s\" class=\"DAT LT COLOR%u\"", + Id,Gbl.RowEvenOdd); + Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, + true,true,false,0x7); + HTM_TD_End (); + free (Id); + } + + /* Write session title */ + HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Txt (Session.Title); HTM_TD_End (); - free (Id); - } - /* Write session title */ - HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Txt (Session.Title); - HTM_TD_End (); - - /* Get and accumulate questions and score */ - if (ICanView.Score) - { - /* Get questions and user's answers of exam print from database */ - ExaPrn_GetPrintQuestionsFromDB (&Print); - NumTotalQsts.All += Print.NumQsts.All; - - /* Compute score taking into account only valid questions */ - ExaRes_ComputeValidPrintScore (&Print); - NumTotalQsts.Valid.Correct += Print.NumQsts.Valid.Correct; - NumTotalQsts.Valid.Wrong.Negative += Print.NumQsts.Valid.Wrong.Negative; - NumTotalQsts.Valid.Wrong.Zero += Print.NumQsts.Valid.Wrong.Zero; - NumTotalQsts.Valid.Wrong.Positive += Print.NumQsts.Valid.Wrong.Positive; - NumTotalQsts.Valid.Blank += Print.NumQsts.Valid.Blank; - NumTotalQsts.Valid.Total += Print.NumQsts.Valid.Total; - TotalScore.Valid += Print.Score.Valid; - } - - /* Write total number of questions */ - HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - HTM_Unsigned (Print.NumQsts.All); - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Valid questions */ - HTM_TD_Begin ("class=\"DAT_GREEN RT COLOR%u\"",Gbl.RowEvenOdd); + /* Get and accumulate questions and score */ if (ICanView.Score) { - if (Print.NumQsts.Valid.Total) - HTM_Unsigned (Print.NumQsts.Valid.Total); + /* Get questions and user's answers of exam print from database */ + ExaPrn_GetPrintQuestionsFromDB (&Print); + NumTotalQsts.All += Print.NumQsts.All; + + /* Compute score taking into account only valid questions */ + ExaRes_ComputeValidPrintScore (&Print); + NumTotalQsts.Valid.Correct += Print.NumQsts.Valid.Correct; + NumTotalQsts.Valid.Wrong.Negative += Print.NumQsts.Valid.Wrong.Negative; + NumTotalQsts.Valid.Wrong.Zero += Print.NumQsts.Valid.Wrong.Zero; + NumTotalQsts.Valid.Wrong.Positive += Print.NumQsts.Valid.Wrong.Positive; + NumTotalQsts.Valid.Blank += Print.NumQsts.Valid.Blank; + NumTotalQsts.Valid.Total += Print.NumQsts.Valid.Total; + TotalScore.Valid += Print.Score.Valid; + } + + /* Write total number of questions */ + HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + HTM_Unsigned (Print.NumQsts.All); else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); + Ico_PutIconNotVisible (); + HTM_TD_End (); - /* Invalid questions */ - HTM_TD_Begin ("class=\"DAT_RED RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - NumQstsInvalid = Print.NumQsts.All - Print.NumQsts.Valid.Total; - if (NumQstsInvalid) - HTM_Unsigned (NumQstsInvalid); - else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Write number of correct questions */ - HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Correct) - HTM_Unsigned (Print.NumQsts.Valid.Correct); - else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Write number of wrong questions */ - HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Wrong.Negative) - HTM_Unsigned (Print.NumQsts.Valid.Wrong.Negative); - else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Wrong.Zero) - HTM_Unsigned (Print.NumQsts.Valid.Wrong.Zero); - else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Wrong.Positive) - HTM_Unsigned (Print.NumQsts.Valid.Wrong.Positive); - else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Write number of blank questions */ - HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Blank) - HTM_Unsigned (Print.NumQsts.Valid.Blank); - else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Write score valid (taking into account only valid questions) */ - HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - HTM_Double2Decimals (Print.Score.Valid); - HTM_Txt ("/"); - HTM_Unsigned (Print.NumQsts.Valid.Total); - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Write average score per question (taking into account only valid questions) */ - HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - HTM_Double2Decimals (Print.NumQsts.Valid.Total ? Print.Score.Valid / - (double) Print.NumQsts.Valid.Total : - 0.0); - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Write grade over maximum grade (taking into account only valid questions) */ - HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - Grade = TstPrn_ComputeGrade (Print.NumQsts.Valid.Total,Print.Score.Valid,Exam.MaxGrade); - TstPrn_ShowGrade (Grade,Exam.MaxGrade); - TotalGrade += Grade; - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); - - /* Link to show this result */ - HTM_TD_Begin ("class=\"RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Result) - { - Exams->ExaCod = Session.ExaCod; - Exams->SesCod = Session.SesCod; - switch (MeOrOther) + /* Valid questions */ + HTM_TD_Begin ("class=\"DAT_GREEN RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) { - case Usr_ME: - Frm_BeginForm (ActSeeOneExaResMe); - ExaSes_PutParamsEdit (Exams); - break; - case Usr_OTHER: - Frm_BeginForm (ActSeeOneExaResOth); - ExaSes_PutParamsEdit (Exams); - Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod); - break; + if (Print.NumQsts.Valid.Total) + HTM_Unsigned (Print.NumQsts.Valid.Total); + else + HTM_Light0 (); } - Ico_PutIconLink ("tasks.svg",Txt_Result); - Frm_EndForm (); - } - else - Ico_PutIconNotVisible (); + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Invalid questions */ + HTM_TD_Begin ("class=\"DAT_RED RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + NumQstsInvalid = Print.NumQsts.All - Print.NumQsts.Valid.Total; + if (NumQstsInvalid) + HTM_Unsigned (NumQstsInvalid); + else + HTM_Light0 (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Write number of correct questions */ + HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Correct) + HTM_Unsigned (Print.NumQsts.Valid.Correct); + else + HTM_Light0 (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Write number of wrong questions */ + HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Wrong.Negative) + HTM_Unsigned (Print.NumQsts.Valid.Wrong.Negative); + else + HTM_Light0 (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Wrong.Zero) + HTM_Unsigned (Print.NumQsts.Valid.Wrong.Zero); + else + HTM_Light0 (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Wrong.Positive) + HTM_Unsigned (Print.NumQsts.Valid.Wrong.Positive); + else + HTM_Light0 (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Write number of blank questions */ + HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Blank) + HTM_Unsigned (Print.NumQsts.Valid.Blank); + else + HTM_Light0 (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Write score valid (taking into account only valid questions) */ + HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + HTM_Double2Decimals (Print.Score.Valid); + HTM_Txt ("/"); + HTM_Unsigned (Print.NumQsts.Valid.Total); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Write average score per question (taking into account only valid questions) */ + HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + HTM_Double2Decimals (Print.NumQsts.Valid.Total ? Print.Score.Valid / + (double) Print.NumQsts.Valid.Total : + 0.0); + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Write grade over maximum grade (taking into account only valid questions) */ + HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Score) + { + Grade = TstPrn_ComputeGrade (Print.NumQsts.Valid.Total,Print.Score.Valid,Exam.MaxGrade); + TstPrn_ShowGrade (Grade,Exam.MaxGrade); + TotalGrade += Grade; + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + /* Link to show this result */ + HTM_TD_Begin ("class=\"RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanView.Result) + { + Exams->ExaCod = Session.ExaCod; + Exams->SesCod = Session.SesCod; + switch (MeOrOther) + { + case Usr_ME: + Frm_BeginForm (ActSeeOneExaResMe); + ExaSes_PutParamsEdit (Exams); + break; + case Usr_OTHER: + Frm_BeginForm (ActSeeOneExaResOth); + ExaSes_PutParamsEdit (Exams); + Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod); + break; + } + Ico_PutIconLink ("tasks.svg",Txt_Result); + Frm_EndForm (); + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); + + HTM_TR_End (); + } + + /***** Write totals for this user *****/ + HTM_TR_Begin (NULL); + ExaRes_ShowResultsSummaryRow (NumResults,&NumTotalQsts,&TotalScore,TotalGrade); + } + else + { + /* Columns for dates and title */ + HTM_TD_Begin ("colspan=\"3\" class=\"LINE_BOTTOM COLOR%u\"", + Gbl.RowEvenOdd); HTM_TD_End (); - HTM_TR_End (); + /* Columns for questions */ + HTM_TD_Begin ("colspan=\"3\" class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"", + Gbl.RowEvenOdd); + HTM_TD_End (); + + /* Columns for answers */ + HTM_TD_Begin ("colspan=\"5\" class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"", + Gbl.RowEvenOdd); + HTM_TD_End (); + + /* Columns for score */ + HTM_TD_Begin ("colspan=\"2\" class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"", + Gbl.RowEvenOdd); + HTM_TD_End (); + + /* Column for grade */ + HTM_TD_Begin ("class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"", + Gbl.RowEvenOdd); + HTM_TD_End (); + + /* Column for link to show the result */ + HTM_TD_Begin ("class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"", + Gbl.RowEvenOdd); + HTM_TD_End (); } - /***** Write totals for this user *****/ - ExaRes_ShowResultsSummaryRow (NumResults,&NumTotalQsts,&TotalScore,TotalGrade); - } - else - { - /* Columns for dates and title */ - HTM_TD_Begin ("colspan=\"3\" class=\"LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); - - /* Columns for questions */ - HTM_TD_Begin ("colspan=\"3\" class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); - - /* Columns for answers */ - HTM_TD_Begin ("colspan=\"5\" class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); - - /* Columns for score */ - HTM_TD_Begin ("colspan=\"2\" class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); - - /* Column for grade */ - HTM_TD_Begin ("class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); - - /* Column for link to show the result */ - HTM_TD_Begin ("class=\"LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); - - HTM_TR_End (); - } + /***** End last row *****/ + HTM_TR_End (); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -1094,101 +1102,95 @@ static void ExaRes_ShowResultsSummaryRow (unsigned NumResults, extern const char *Txt_Sessions; unsigned NumTotalQstsInvalid; - /***** Begin row *****/ - HTM_TR_Begin (NULL); + /***** Row title *****/ + HTM_TD_Begin ("colspan=\"3\" class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + HTM_TxtColonNBSP (Txt_Sessions); + HTM_Unsigned (NumResults); + HTM_TD_End (); - /***** Row title *****/ - HTM_TD_Begin ("colspan=\"3\" class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - HTM_TxtColonNBSP (Txt_Sessions); - HTM_Unsigned (NumResults); - HTM_TD_End (); + /***** Write total number of questions *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Unsigned (NumTotalQsts->All); + HTM_TD_End (); - /***** Write total number of questions *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Unsigned (NumTotalQsts->All); - HTM_TD_End (); - - /***** Write total number of valid questions *****/ - HTM_TD_Begin ("class=\"DAT_GREEN RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Total) - HTM_Unsigned (NumTotalQsts->Valid.Total); - else - HTM_Light0 (); - HTM_TD_End (); - - /***** Write total number of invalid questions *****/ - HTM_TD_Begin ("class=\"DAT_RED RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - NumTotalQstsInvalid = NumTotalQsts->All - NumTotalQsts->Valid.Total; - if (NumTotalQstsInvalid) - HTM_Unsigned (NumTotalQstsInvalid); - else - HTM_Light0 (); - HTM_TD_End (); - - /***** Write number of correct questions *****/ - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Correct) - HTM_Unsigned (NumTotalQsts->Valid.Correct); - else - HTM_Light0 (); - HTM_TD_End (); - - /***** Write number of wrong questions *****/ - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Wrong.Negative) - HTM_Unsigned (NumTotalQsts->Valid.Wrong.Negative); - else - HTM_Light0 (); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Wrong.Zero) - HTM_Unsigned (NumTotalQsts->Valid.Wrong.Zero); - else - HTM_Light0 (); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Wrong.Positive) - HTM_Unsigned (NumTotalQsts->Valid.Wrong.Positive); - else - HTM_Light0 (); - HTM_TD_End (); - - /***** Write number of blank questions *****/ - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Blank) - HTM_Unsigned (NumTotalQsts->Valid.Blank); - else - HTM_Light0 (); - HTM_TD_End (); - - /***** Write total valid score *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Double2Decimals (TotalScore->Valid); - HTM_Txt ("/"); + /***** Write total number of valid questions *****/ + HTM_TD_Begin ("class=\"DAT_GREEN RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Total) HTM_Unsigned (NumTotalQsts->Valid.Total); - HTM_TD_End (); + else + HTM_Light0 (); + HTM_TD_End (); - /***** Write average valid score per valid question *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - HTM_Double2Decimals (NumTotalQsts->Valid.Total ? TotalScore->Valid / - (double) NumTotalQsts->Valid.Total : - 0.0); - HTM_TD_End (); + /***** Write total number of invalid questions *****/ + HTM_TD_Begin ("class=\"DAT_RED RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + NumTotalQstsInvalid = NumTotalQsts->All - NumTotalQsts->Valid.Total; + if (NumTotalQstsInvalid) + HTM_Unsigned (NumTotalQstsInvalid); + else + HTM_Light0 (); + HTM_TD_End (); + + /***** Write number of correct questions *****/ + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Correct) + HTM_Unsigned (NumTotalQsts->Valid.Correct); + else + HTM_Light0 (); + HTM_TD_End (); + + /***** Write number of wrong questions *****/ + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Wrong.Negative) + HTM_Unsigned (NumTotalQsts->Valid.Wrong.Negative); + else + HTM_Light0 (); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Wrong.Zero) + HTM_Unsigned (NumTotalQsts->Valid.Wrong.Zero); + else + HTM_Light0 (); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Wrong.Positive) + HTM_Unsigned (NumTotalQsts->Valid.Wrong.Positive); + else + HTM_Light0 (); + HTM_TD_End (); + + /***** Write number of blank questions *****/ + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Blank) + HTM_Unsigned (NumTotalQsts->Valid.Blank); + else + HTM_Light0 (); + HTM_TD_End (); + + /***** Write total valid score *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Double2Decimals (TotalScore->Valid); + HTM_Txt ("/"); + HTM_Unsigned (NumTotalQsts->Valid.Total); + HTM_TD_End (); + + /***** Write average valid score per valid question *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + HTM_Double2Decimals (NumTotalQsts->Valid.Total ? TotalScore->Valid / + (double) NumTotalQsts->Valid.Total : + 0.0); + HTM_TD_End (); - /***** Write total grade *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Double2Decimals (TotalGrade); - HTM_TD_End (); + /***** Write total grade *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Double2Decimals (TotalGrade); + HTM_TD_End (); - /***** Last cell *****/ - HTM_TD_Begin ("class=\"DAT_N LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); - - /***** End row *****/ - HTM_TR_End (); + /***** Last cell *****/ + HTM_TD_Begin ("class=\"DAT_N LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TD_End (); } /*****************************************************************************/ diff --git a/swad_exam_session.c b/swad_exam_session.c index e8110c00..b0c0c060 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -582,7 +582,7 @@ static void ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (const struct ExaSe unsigned NumGrp; /***** Get groups *****/ - NumGrps = Exa_DB_GetGrpsAssociatedToSession (&mysql_res,Session->SesCod); + NumGrps = Exa_DB_GetGrpsAssociatedToSes (&mysql_res,Session->SesCod); /***** Write heading *****/ HTM_DIV_Begin ("class=\"%s\"",Session->Hidden ? "ASG_GRP_LIGHT": @@ -853,6 +853,15 @@ void ExaSes_RemoveSession (void) if (!ExaSes_CheckIfICanEditThisSession (&Session)) Err_NoPermissionExit (); + /***** Remove questions of exams prints, and exam prints, in this session *****/ + //* TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints + /* To delete orphan exam prints: + // DELETE FROM exa_print_questions WHERE PrnCod IN (SELECT PrnCod FROM exa_prints WHERE SesCod NOT IN (SELECT SesCod FROM exa_sessions)); + // DELETE FROM exa_prints WHERE SesCod NOT IN (SELECT SesCod FROM exa_sessions); + */ + Exa_DB_RemovePrintQstsFromSes (Session.SesCod); + Exa_DB_RemovePrintsFromSes (Session.SesCod); + /***** Remove the exam session from all database tables *****/ Exa_DB_RemoveSessionFromAllTables (Session.SesCod); @@ -1298,7 +1307,7 @@ static void ExaSes_UpdateSession (struct ExaSes_Session *Session) Exa_DB_UpdateSession (Session); /***** Update groups associated to the exam session *****/ - Exa_DB_RemoveAllGrpsAssociatedToSession (Session->SesCod); // Remove all groups associated to this session + Exa_DB_RemoveGrpsFromSes (Session->SesCod); // Remove all groups associated to this session if (Gbl.Crs.Grps.LstGrpsSel.NumGrps) ExaSes_CreateGrpsAssociatedToExamSession (Session->SesCod,&Gbl.Crs.Grps.LstGrpsSel); // Associate new groups } @@ -1317,7 +1326,7 @@ static void ExaSes_CreateGrpsAssociatedToExamSession (long SesCod, NumGrpSel < LstGrpsSel->NumGrps; NumGrpSel++) /* Create group */ - Exa_DB_CreateGrpAssociatedToSession (SesCod,LstGrpsSel->GrpCods[NumGrpSel]); + Exa_DB_CreateGrpAssociatedToSes (SesCod,LstGrpsSel->GrpCods[NumGrpSel]); } /*****************************************************************************/ diff --git a/swad_group.c b/swad_group.c index 4c24cf54..8f3415b6 100644 --- a/swad_group.c +++ b/swad_group.c @@ -3507,7 +3507,7 @@ static void Grp_RemoveGroupTypeCompletely (void) Att_DB_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); /***** Remove the associations of exam sessions to groups of this type *****/ - Exa_DB_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); + Exa_DB_RemoveGrpsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); /***** Remove the associations of matches to groups of this type *****/ Mch_DB_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); @@ -3563,7 +3563,7 @@ static void Grp_RemoveGroupCompletely (void) Mch_DB_RemoveGroup (GrpDat.GrpCod); /***** Remove this group from all exam sessions *****/ - Exa_DB_RemoveGrpAssociatedToExamSessions (GrpDat.GrpCod); + Exa_DB_RemoveGrpAssociatedToExamSess (GrpDat.GrpCod); /***** Remove this group from all surveys *****/ Svy_DB_RemoveGroup (GrpDat.GrpCod);