Version 20.96.2: Sep 08, 2021 Queries moved to module swad_exam_database.

This commit is contained in:
acanas 2021-09-08 11:05:08 +02:00
parent 0e5ed54fa2
commit 5611c0e7e7
9 changed files with 453 additions and 462 deletions

View File

@ -1017,7 +1017,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
/***** Remove test, exams and matches made by user in all courses *****/ /***** Remove test, exams and matches made by user in all courses *****/
TstPrn_RemovePrintsMadeByUsrInAllCrss (UsrDat->UsrCod); TstPrn_RemovePrintsMadeByUsrInAllCrss (UsrDat->UsrCod);
Exa_DB_RemovePrintQuestionsMadeByUsrInAllCrss (UsrDat->UsrCod); Exa_DB_RemovePrintQstsMadeByUsrInAllCrss (UsrDat->UsrCod);
Exa_DB_RemovePrintsMadeByUsrInAllCrss (UsrDat->UsrCod); Exa_DB_RemovePrintsMadeByUsrInAllCrss (UsrDat->UsrCod);
Mch_RemoveMatchesMadeByUsrInAllCrss (UsrDat->UsrCod); Mch_RemoveMatchesMadeByUsrInAllCrss (UsrDat->UsrCod);

View File

@ -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. 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 CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams 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.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.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) Version 20.95.3: Jul 20, 2021 Queries moved to module swad_exam_database. (314210 lines)

View File

@ -3212,7 +3212,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
/* Remove tests, exams and matches results made by user in course */ /* Remove tests, exams and matches results made by user in course */
TstPrn_RemovePrintsMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod); 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); Exa_DB_RemovePrintsMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod);
Mch_RemoveMatchesMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod); Mch_RemoveMatchesMadeByUsrInCrs (UsrDat->UsrCod,Crs->CrsCod);
} }

View File

@ -1078,12 +1078,14 @@ void Exa_RemoveExam (void)
static void Exa_RemoveExamFromAllTables (long ExaCod) static void Exa_RemoveExamFromAllTables (long ExaCod)
{ {
/***** Remove questions of exams prints, and exam prints, of this exam *****/ /***** Remove questions of exams prints, and exam prints, in this exam *****/
Exa_DB_RemovePrintQuestionsFromExam (ExaCod); // TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints
Exa_DB_RemovePrintsFromExam (ExaCod); Exa_DB_RemovePrintQstsFromExa (ExaCod);
Exa_DB_RemovePrintsFromExa (ExaCod);
/***** Remove all sessions in this exam *****/ /***** Remove groups associated to sessions, and sessions, in this exam *****/
Exa_DB_RemoveSessionsInExamFromAllTables (ExaCod); Exa_DB_RemoveGrpsFromExa (ExaCod);
Exa_DB_RemoveSessionsFromExam (ExaCod);
/***** Remove media associated to exam questions in the exam *****/ /***** Remove media associated to exam questions in the exam *****/
Exa_RemoveAllMedFilesFromStemOfAllQstsFromExam (ExaCod); Exa_RemoveAllMedFilesFromStemOfAllQstsFromExam (ExaCod);
@ -1108,11 +1110,13 @@ void Exa_RemoveCrsExams (long CrsCod)
{ {
/***** Remove questions of exams prints, and exam prints, /***** Remove questions of exams prints, and exam prints,
made in the given course *****/ 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); Exa_DB_RemovePrintsFromCrs (CrsCod);
/***** Remove all sessions in the course *****/ /***** Remove groups associated to sessions, and sessions, in this course *****/
Exa_DB_RemoveSessionInCourseFromAllTables (CrsCod); Exa_DB_RemoveGrpsFromCrs (CrsCod);
Exa_DB_RemoveSessionsFromCrs (CrsCod);
/***** Remove media associated to test questions in the course *****/ /***** Remove media associated to test questions in the course *****/
Exa_RemoveAllMedFilesFromStemOfAllQstsFromCrs (CrsCod); Exa_RemoveAllMedFilesFromStemOfAllQstsFromCrs (CrsCod);

View File

@ -873,26 +873,6 @@ void Exa_DB_HideUnhideSession (const struct ExaSes_Session *Session,bool Hide)
void Exa_DB_RemoveSessionFromAllTables (long SesCod) 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 *****/ /***** Remove groups associated to this exam session *****/
DB_QueryDELETE ("can not remove groups associated to exam session", DB_QueryDELETE ("can not remove groups associated to exam session",
"DELETE FROM exa_groups" "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", DB_QueryDELETE ("can not remove sessions of an exam",
"DELETE FROM exa_sessions" "DELETE FROM exa_sessions"
" WHERE ExaCod=%ld", " 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", DB_QueryDELETE ("can not remove sessions of a course",
"DELETE FROM exa_sessions" "DELETE FROM exa_sessions"
" USING exa_exams," " 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 *****************/ /**************** 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", DB_QueryINSERT ("can not associate a group to an exam session",
"INSERT INTO exa_groups" "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 **********/ /*********** 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) return (unsigned)
DB_QuerySELECT (mysql_res,"can not get groups of an exam session", 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 *********************/ /******************** 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", DB_QueryDELETE ("can not remove groups associated to a session",
"DELETE FROM exa_groups" "DELETE FROM exa_groups"
@ -1102,11 +1014,43 @@ void Exa_DB_RemoveAllGrpsAssociatedToSession (long SesCod)
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 ****************/ /**************** 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" DB_QueryDELETE ("can not remove groups of a type"
" from the associations between sessions and groups", " from the associations between sessions and groups",
@ -1122,7 +1066,7 @@ void Exa_DB_RemoveGroupsOfType (long GrpTypCod)
/******************** Remove one group from all sessions *********************/ /******************** Remove one group from all sessions *********************/
/*****************************************************************************/ /*****************************************************************************/
void Exa_DB_RemoveGrpAssociatedToExamSessions (long GrpCod) void Exa_DB_RemoveGrpAssociatedToExamSess (long GrpCod)
{ {
/***** Remove group from all the sessions *****/ /***** Remove group from all the sessions *****/
DB_QueryDELETE ("can not remove group" DB_QueryDELETE ("can not remove group"
@ -1256,11 +1200,23 @@ void Exa_DB_RemovePrintsMadeByUsrInCrs (long UsrCod,long CrsCod)
UsrCod); 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 *****************/ /**************** 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", DB_QueryDELETE ("can not remove exams prints in a course",
"DELETE FROM exa_prints" "DELETE FROM exa_prints"
@ -1378,7 +1334,7 @@ double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod)
/*************** Remove exam prints questions for a given user ***************/ /*************** 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", DB_QueryDELETE ("can not remove exam prints made by a user",
"DELETE FROM exa_print_questions" "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 */ /* 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", DB_QueryDELETE ("can not remove exams prints made by a user in a course",
"DELETE FROM exa_print_questions" "DELETE FROM exa_print_questions"
@ -1410,11 +1366,26 @@ void Exa_DB_RemovePrintsQuestionsMadeByUsrInCrs (long UsrCod,long CrsCod)
UsrCod); 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 *************/ /************ 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", DB_QueryDELETE ("can not remove exams prints in an exam",
"DELETE FROM exa_print_questions" "DELETE FROM exa_print_questions"
@ -1431,7 +1402,7 @@ void Exa_DB_RemovePrintQuestionsFromExam (long ExaCod)
/************ Remove questions of exams prints in a given course *************/ /************ 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", DB_QueryDELETE ("can not remove exams prints in a course",
"DELETE FROM exa_print_questions" "DELETE FROM exa_print_questions"

View File

@ -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_ToggleVisResultsSesUsr (const struct ExaSes_Session *Session);
void Exa_DB_HideUnhideSession (const struct ExaSes_Session *Session,bool Hide); void Exa_DB_HideUnhideSession (const struct ExaSes_Session *Session,bool Hide);
void Exa_DB_RemoveSessionFromAllTables (long SesCod); void Exa_DB_RemoveSessionFromAllTables (long SesCod);
void Exa_DB_RemoveSessionsInExamFromAllTables (long ExaCod); void Exa_DB_RemoveSessionsFromExam (long ExaCod);
void Exa_DB_RemoveSessionInCourseFromAllTables (long CrsCod); void Exa_DB_RemoveSessionsFromCrs (long CrsCod);
void Exa_DB_RemoveUsrFromSessionTablesInCrs (long UsrCod,long CrsCod); void Exa_DB_RemoveUsrFromSessionTablesInCrs (long UsrCod,long CrsCod);
void Exa_DB_CreateGrpAssociatedToSession (long SesCod,long GrpCod); void Exa_DB_CreateGrpAssociatedToSes (long SesCod,long GrpCod);
unsigned Exa_DB_GetGrpsAssociatedToSession (MYSQL_RES **mysql_res,long SesCod); unsigned Exa_DB_GetGrpsAssociatedToSes (MYSQL_RES **mysql_res,long SesCod);
bool Exa_DB_CheckIfICanListThisSessionBasedOnGrps (long SesCod); bool Exa_DB_CheckIfICanListThisSessionBasedOnGrps (long SesCod);
void Exa_DB_RemoveAllGrpsAssociatedToSession (long SesCod); void Exa_DB_RemoveGrpsFromExa (long ExaCod);
void Exa_DB_RemoveGroupsOfType (long GrpTypCod); void Exa_DB_RemoveGrpsFromCrs (long CrsCod);
void Exa_DB_RemoveGrpAssociatedToExamSessions (long GrpCod); 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); long Exa_DB_CreatePrint (const struct ExaPrn_Print *Print);
void Exa_DB_UpdatePrint (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); long SesCod,long UsrCod);
void Exa_DB_RemovePrintsMadeByUsrInAllCrss (long UsrCod); void Exa_DB_RemovePrintsMadeByUsrInAllCrss (long UsrCod);
void Exa_DB_RemovePrintsMadeByUsrInCrs (long UsrCod,long CrsCod); 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_RemovePrintsFromCrs (long CrsCod);
void Exa_DB_StoreOneQstOfPrint (const struct ExaPrn_Print *Print, 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]); char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]);
unsigned Exa_DB_GetNumQstsNotBlankInPrint (long PrnCod); unsigned Exa_DB_GetNumQstsNotBlankInPrint (long PrnCod);
double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod); double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod);
void Exa_DB_RemovePrintQuestionsMadeByUsrInAllCrss (long UsrCod); void Exa_DB_RemovePrintQstsMadeByUsrInAllCrss (long UsrCod);
void Exa_DB_RemovePrintsQuestionsMadeByUsrInCrs (long UsrCod,long CrsCod); void Exa_DB_RemovePrintQstsMadeByUsrInCrs (long UsrCod,long CrsCod);
void Exa_DB_RemovePrintQuestionsFromExam (long ExaCod); void Exa_DB_RemovePrintQstsFromSes (long SesCod);
void Exa_DB_RemovePrintQuestionsFromCrs (long CrsCod); void Exa_DB_RemovePrintQstsFromExa (long ExaCod);
void Exa_DB_RemovePrintQstsFromCrs (long CrsCod);
bool Exa_DB_CheckIfSessionIsTheSameAsTheLast (long PrnCod); bool Exa_DB_CheckIfSessionIsTheSameAsTheLast (long PrnCod);
bool Exa_DB_CheckIfUserAgentIsTheSameAsTheLast (long PrnCod,const char *UserAgentDB); bool Exa_DB_CheckIfUserAgentIsTheSameAsTheLast (long PrnCod,const char *UserAgentDB);

View File

@ -816,265 +816,273 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
/***** Show user's data *****/ /***** Show user's data *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
Usr_ShowTableCellWithUsrData (UsrDat,NumResults); Usr_ShowTableCellWithUsrData (UsrDat,NumResults);
/***** Get and print sessions results *****/ /***** Get and print sessions results *****/
if (NumResults) if (NumResults)
{
for (NumResult = 0;
NumResult < NumResults;
NumResult++)
{ {
/* Get print code (row[0]) */ for (NumResult = 0;
if ((Print.PrnCod = DB_GetNextCode (mysql_res)) <= 0) NumResult < NumResults;
Err_WrongExamExit (); NumResult++)
/* 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++; /* Get print code (row[0]) */
if (asprintf (&Id,"exa_res_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) if ((Print.PrnCod = DB_GetNextCode (mysql_res)) <= 0)
Err_NotEnoughMemoryExit (); Err_WrongExamExit ();
HTM_TD_Begin ("id =\"%s\" class=\"DAT LT COLOR%u\"",
Id,Gbl.RowEvenOdd); /* Get print data */
Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime], ExaPrn_GetDataOfPrintByPrnCod (&Print);
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
true,true,false,0x7); /* 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 (); HTM_TD_End ();
free (Id);
}
/* Write session title */ /* Get and accumulate questions and score */
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);
if (ICanView.Score) if (ICanView.Score)
{ {
if (Print.NumQsts.Valid.Total) /* Get questions and user's answers of exam print from database */
HTM_Unsigned (Print.NumQsts.Valid.Total); 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 else
HTM_Light0 (); Ico_PutIconNotVisible ();
} HTM_TD_End ();
else
Ico_PutIconNotVisible ();
HTM_TD_End ();
/* Invalid questions */ /* Valid questions */
HTM_TD_Begin ("class=\"DAT_RED RT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT_GREEN RT COLOR%u\"",Gbl.RowEvenOdd);
if (ICanView.Score) 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: if (Print.NumQsts.Valid.Total)
Frm_BeginForm (ActSeeOneExaResMe); HTM_Unsigned (Print.NumQsts.Valid.Total);
ExaSes_PutParamsEdit (Exams); else
break; HTM_Light0 ();
case Usr_OTHER:
Frm_BeginForm (ActSeeOneExaResOth);
ExaSes_PutParamsEdit (Exams);
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
break;
} }
Ico_PutIconLink ("tasks.svg",Txt_Result); else
Frm_EndForm (); Ico_PutIconNotVisible ();
} HTM_TD_End ();
else
Ico_PutIconNotVisible (); /* 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_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 *****/ /***** End last row *****/
ExaRes_ShowResultsSummaryRow (NumResults,&NumTotalQsts,&TotalScore,TotalGrade); HTM_TR_End ();
}
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 ();
}
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
@ -1094,101 +1102,95 @@ static void ExaRes_ShowResultsSummaryRow (unsigned NumResults,
extern const char *Txt_Sessions; extern const char *Txt_Sessions;
unsigned NumTotalQstsInvalid; unsigned NumTotalQstsInvalid;
/***** Begin row *****/ /***** Row title *****/
HTM_TR_Begin (NULL); 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 *****/ /***** Write total number of questions *****/
HTM_TD_Begin ("colspan=\"3\" class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd);
HTM_TxtColonNBSP (Txt_Sessions); HTM_Unsigned (NumTotalQsts->All);
HTM_Unsigned (NumResults); HTM_TD_End ();
HTM_TD_End ();
/***** Write total number of questions *****/ /***** Write total number of valid questions *****/
HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT_GREEN RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd);
HTM_Unsigned (NumTotalQsts->All); if (NumTotalQsts->Valid.Total)
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 ("/");
HTM_Unsigned (NumTotalQsts->Valid.Total); HTM_Unsigned (NumTotalQsts->Valid.Total);
HTM_TD_End (); else
HTM_Light0 ();
HTM_TD_End ();
/***** Write average valid score per valid question *****/ /***** Write total number of invalid questions *****/
HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT_RED RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd);
HTM_Double2Decimals (NumTotalQsts->Valid.Total ? TotalScore->Valid / NumTotalQstsInvalid = NumTotalQsts->All - NumTotalQsts->Valid.Total;
(double) NumTotalQsts->Valid.Total : if (NumTotalQstsInvalid)
0.0); HTM_Unsigned (NumTotalQstsInvalid);
HTM_TD_End (); 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 *****/ /***** Write total grade *****/
HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd);
HTM_Double2Decimals (TotalGrade); HTM_Double2Decimals (TotalGrade);
HTM_TD_End (); HTM_TD_End ();
/***** Last cell *****/ /***** Last cell *****/
HTM_TD_Begin ("class=\"DAT_N LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT_N LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd);
HTM_TD_End (); HTM_TD_End ();
/***** End row *****/
HTM_TR_End ();
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -582,7 +582,7 @@ static void ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (const struct ExaSe
unsigned NumGrp; unsigned NumGrp;
/***** Get groups *****/ /***** Get groups *****/
NumGrps = Exa_DB_GetGrpsAssociatedToSession (&mysql_res,Session->SesCod); NumGrps = Exa_DB_GetGrpsAssociatedToSes (&mysql_res,Session->SesCod);
/***** Write heading *****/ /***** Write heading *****/
HTM_DIV_Begin ("class=\"%s\"",Session->Hidden ? "ASG_GRP_LIGHT": HTM_DIV_Begin ("class=\"%s\"",Session->Hidden ? "ASG_GRP_LIGHT":
@ -853,6 +853,15 @@ void ExaSes_RemoveSession (void)
if (!ExaSes_CheckIfICanEditThisSession (&Session)) if (!ExaSes_CheckIfICanEditThisSession (&Session))
Err_NoPermissionExit (); 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 *****/ /***** Remove the exam session from all database tables *****/
Exa_DB_RemoveSessionFromAllTables (Session.SesCod); Exa_DB_RemoveSessionFromAllTables (Session.SesCod);
@ -1298,7 +1307,7 @@ static void ExaSes_UpdateSession (struct ExaSes_Session *Session)
Exa_DB_UpdateSession (Session); Exa_DB_UpdateSession (Session);
/***** Update groups associated to the exam 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) if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
ExaSes_CreateGrpsAssociatedToExamSession (Session->SesCod,&Gbl.Crs.Grps.LstGrpsSel); // Associate new groups 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 < LstGrpsSel->NumGrps;
NumGrpSel++) NumGrpSel++)
/* Create group */ /* Create group */
Exa_DB_CreateGrpAssociatedToSession (SesCod,LstGrpsSel->GrpCods[NumGrpSel]); Exa_DB_CreateGrpAssociatedToSes (SesCod,LstGrpsSel->GrpCods[NumGrpSel]);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -3507,7 +3507,7 @@ static void Grp_RemoveGroupTypeCompletely (void)
Att_DB_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); Att_DB_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod);
/***** Remove the associations of exam sessions to groups of this type *****/ /***** 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 *****/ /***** Remove the associations of matches to groups of this type *****/
Mch_DB_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod); Mch_DB_RemoveGroupsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod);
@ -3563,7 +3563,7 @@ static void Grp_RemoveGroupCompletely (void)
Mch_DB_RemoveGroup (GrpDat.GrpCod); Mch_DB_RemoveGroup (GrpDat.GrpCod);
/***** Remove this group from all exam sessions *****/ /***** Remove this group from all exam sessions *****/
Exa_DB_RemoveGrpAssociatedToExamSessions (GrpDat.GrpCod); Exa_DB_RemoveGrpAssociatedToExamSess (GrpDat.GrpCod);
/***** Remove this group from all surveys *****/ /***** Remove this group from all surveys *****/
Svy_DB_RemoveGroup (GrpDat.GrpCod); Svy_DB_RemoveGroup (GrpDat.GrpCod);