mirror of https://github.com/acanas/swad-core.git
Version 20.96.6: Sep 09, 2021 Queries moved to module swad_exam_database.
This commit is contained in:
parent
f976c4c944
commit
3a4dd6c7ce
|
@ -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.5 (2021-09-09)"
|
#define Log_PLATFORM_VERSION "SWAD 20.96.6 (2021-09-09)"
|
||||||
#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.6: Sep 09, 2021 Queries moved to module swad_exam_database. (314471 lines)
|
||||||
Version 20.96.5: Sep 09, 2021 Queries moved to module swad_exam_database. (314448 lines)
|
Version 20.96.5: Sep 09, 2021 Queries moved to module swad_exam_database. (314448 lines)
|
||||||
Version 20.96.4: Sep 08, 2021 Queries moved to module swad_exam_database. (314414 lines)
|
Version 20.96.4: Sep 08, 2021 Queries moved to module swad_exam_database. (314414 lines)
|
||||||
Version 20.96.3: Sep 08, 2021 Queries moved to module swad_exam_database. (314384 lines)
|
Version 20.96.3: Sep 08, 2021 Queries moved to module swad_exam_database. (314384 lines)
|
||||||
|
|
|
@ -280,6 +280,45 @@ void Exa_DB_UpdateSetIndexesInExamGreaterThan (long ExaCod,long SetInd)
|
||||||
SetInd);
|
SetInd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************* Change index of a set in an exam **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Exa_DB_UpdateSetIndex (long SetInd,long SetCod,long ExaCod)
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not exchange indexes of sets",
|
||||||
|
"UPDATE exa_sets"
|
||||||
|
" SET SetInd=%ld"
|
||||||
|
" WHERE SetCod=%ld"
|
||||||
|
" AND ExaCod=%ld", // Extra check
|
||||||
|
SetInd,
|
||||||
|
SetCod,
|
||||||
|
ExaCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************ Lock tables to make the exchange of sets atomic ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Exa_DB_LockTables (void)
|
||||||
|
{
|
||||||
|
DB_Query ("can not lock tables to exchange sets of questions",
|
||||||
|
"LOCK TABLES exa_sets WRITE");
|
||||||
|
Gbl.DB.LockedTables = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********** Unlock tables to make the exchange of sets atomic ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Exa_DB_UnlockTables (void)
|
||||||
|
{
|
||||||
|
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
||||||
|
// ...to not retry the unlock if error in unlocking
|
||||||
|
DB_Query ("can not unlock tables after exchanging sets of questions",
|
||||||
|
"UNLOCK TABLES");
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********************** Get number of sets in an exam ***********************/
|
/*********************** Get number of sets in an exam ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -529,6 +568,37 @@ long Exa_DB_AddQuestionToSet (long SetCod,const struct Tst_Question *Question,lo
|
||||||
MedCod);
|
MedCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Validate/invalidate a question **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Exa_DB_ChangeValidityQst (long QstCod,long SetCod,long ExaCod,long CrsCod,
|
||||||
|
Tst_Validity_t Validity)
|
||||||
|
{
|
||||||
|
static char CharInvalid[Tst_NUM_VALIDITIES] =
|
||||||
|
{
|
||||||
|
[Tst_INVALID_QUESTION] = 'Y',
|
||||||
|
[Tst_VALID_QUESTION ] = 'N'
|
||||||
|
};
|
||||||
|
|
||||||
|
DB_QueryUPDATE ("can not validate question",
|
||||||
|
"UPDATE exa_set_questions,"
|
||||||
|
"exa_sets,"
|
||||||
|
"exa_exams"
|
||||||
|
" SET exa_set_questions.Invalid='%c'"
|
||||||
|
" WHERE exa_set_questions.QstCod=%ld"
|
||||||
|
" AND exa_set_questions.SetCod=%ld" // Extra check
|
||||||
|
" AND exa_set_questions.SetCod=exa_sets.SetCod"
|
||||||
|
" AND exa_sets.ExaCod=%ld" // Extra check
|
||||||
|
" AND exa_sets.ExaCod=exa_exams.ExaCod"
|
||||||
|
" AND exa_exams.CrsCod=%ld", // Extra check
|
||||||
|
CharInvalid[Validity],
|
||||||
|
QstCod,
|
||||||
|
SetCod,
|
||||||
|
ExaCod,
|
||||||
|
CrsCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************* Get number of questions in a set **********************/
|
/********************* Get number of questions in a set **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -54,6 +54,9 @@ void Exa_DB_UpdateSetTitle (long SetCod,long ExaCod,
|
||||||
const char NewTitle[ExaSet_MAX_BYTES_TITLE + 1]);
|
const char NewTitle[ExaSet_MAX_BYTES_TITLE + 1]);
|
||||||
void Exa_DB_UpdateNumQstsToExam (long SetCod,long ExaCod,unsigned NumQstsToPrint);
|
void Exa_DB_UpdateNumQstsToExam (long SetCod,long ExaCod,unsigned NumQstsToPrint);
|
||||||
void Exa_DB_UpdateSetIndexesInExamGreaterThan (long ExaCod,long SetInd);
|
void Exa_DB_UpdateSetIndexesInExamGreaterThan (long ExaCod,long SetInd);
|
||||||
|
void Exa_DB_UpdateSetIndex (long SetInd,long SetCod,long ExaCod);
|
||||||
|
void Exa_DB_LockTables (void);
|
||||||
|
void Exa_DB_UnlockTables (void);
|
||||||
unsigned Exa_DB_GetNumSetsExam (long ExaCod);
|
unsigned Exa_DB_GetNumSetsExam (long ExaCod);
|
||||||
unsigned Exa_DB_GetNumQstsExam (long ExaCod);
|
unsigned Exa_DB_GetNumQstsExam (long ExaCod);
|
||||||
unsigned Exa_DB_GetExamSets (MYSQL_RES **mysql_res,long ExaCod);
|
unsigned Exa_DB_GetExamSets (MYSQL_RES **mysql_res,long ExaCod);
|
||||||
|
@ -70,6 +73,8 @@ void Exa_DB_RemoveAllSetsFromExam (long ExaCod);
|
||||||
void Exa_DB_RemoveAllSetsFromCrs (long CrsCod);
|
void Exa_DB_RemoveAllSetsFromCrs (long CrsCod);
|
||||||
|
|
||||||
long Exa_DB_AddQuestionToSet (long SetCod,const struct Tst_Question *Question,long MedCod);
|
long Exa_DB_AddQuestionToSet (long SetCod,const struct Tst_Question *Question,long MedCod);
|
||||||
|
void Exa_DB_ChangeValidityQst (long QstCod,long SetCod,long ExaCod,long CrsCod,
|
||||||
|
Tst_Validity_t Validity);
|
||||||
unsigned Exa_DB_GetNumQstsInSet (long SetCod);
|
unsigned Exa_DB_GetNumQstsInSet (long SetCod);
|
||||||
unsigned Exa_DB_GetQstsFromSet (MYSQL_RES **mysql_res,long SetCod);
|
unsigned Exa_DB_GetQstsFromSet (MYSQL_RES **mysql_res,long SetCod);
|
||||||
unsigned Exa_DB_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res,
|
unsigned Exa_DB_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res,
|
||||||
|
|
|
@ -1686,7 +1686,7 @@ static void ExaSet_RemoveMediaFromAllAnsOfQst (long QstCod,long SetCod)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Validate a question ***************************/
|
/*********************** Validate/invalidate a question **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void ExaSet_ValidateQst (void)
|
void ExaSet_ValidateQst (void)
|
||||||
|
@ -1705,11 +1705,6 @@ static void ExaSet_ChangeValidityQst (Tst_Validity_t Validity)
|
||||||
struct Exa_Exam Exam;
|
struct Exa_Exam Exam;
|
||||||
struct ExaSet_Set Set;
|
struct ExaSet_Set Set;
|
||||||
long QstCod;
|
long QstCod;
|
||||||
static char CharInvalid[Tst_NUM_VALIDITIES] =
|
|
||||||
{
|
|
||||||
[Tst_INVALID_QUESTION] = 'Y',
|
|
||||||
[Tst_VALID_QUESTION ] = 'N'
|
|
||||||
};
|
|
||||||
|
|
||||||
/***** Reset exams context *****/
|
/***** Reset exams context *****/
|
||||||
Exa_ResetExams (&Exams);
|
Exa_ResetExams (&Exams);
|
||||||
|
@ -1722,22 +1717,9 @@ static void ExaSet_ChangeValidityQst (Tst_Validity_t Validity)
|
||||||
/***** Get question index *****/
|
/***** Get question index *****/
|
||||||
QstCod = ExaSet_GetParamQstCod ();
|
QstCod = ExaSet_GetParamQstCod ();
|
||||||
|
|
||||||
/***** Validate question *****/
|
/***** Validate/unvalidate question *****/
|
||||||
DB_QueryUPDATE ("can not validate question",
|
Exa_DB_ChangeValidityQst (QstCod,Set.SetCod,Exam.ExaCod,Gbl.Hierarchy.Crs.CrsCod,
|
||||||
"UPDATE exa_set_questions,"
|
Validity);
|
||||||
"exa_sets,exa_exams"
|
|
||||||
" SET exa_set_questions.Invalid='%c'"
|
|
||||||
" WHERE exa_set_questions.QstCod=%ld"
|
|
||||||
" AND exa_set_questions.SetCod=%ld" // Extra check
|
|
||||||
" AND exa_set_questions.SetCod=exa_sets.SetCod"
|
|
||||||
" AND exa_sets.ExaCod=%ld" // Extra check
|
|
||||||
" AND exa_sets.ExaCod=exa_exams.ExaCod"
|
|
||||||
" AND exa_exams.CrsCod=%ld", // Extra check
|
|
||||||
CharInvalid[Validity],
|
|
||||||
QstCod,
|
|
||||||
Set.SetCod,
|
|
||||||
Exam.ExaCod,
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
|
|
||||||
/***** Show current exam and its sets *****/
|
/***** Show current exam and its sets *****/
|
||||||
Exa_PutFormsOneExam (&Exams,&Exam,&Set,
|
Exa_PutFormsOneExam (&Exams,&Exam,&Set,
|
||||||
|
@ -1806,12 +1788,10 @@ static void ExaSet_ExchangeSets (long ExaCod,
|
||||||
long SetCodBottom;
|
long SetCodBottom;
|
||||||
|
|
||||||
/***** Lock table to make the move atomic *****/
|
/***** Lock table to make the move atomic *****/
|
||||||
DB_Query ("can not lock tables to exchange sets of questions",
|
Exa_DB_LockTables ();
|
||||||
"LOCK TABLES exa_sets WRITE");
|
|
||||||
Gbl.DB.LockedTables = true;
|
|
||||||
|
|
||||||
/***** Get set codes of the sets to be moved *****/
|
/***** Get set codes of the sets to be moved *****/
|
||||||
SetCodTop = Exa_DB_GetSetCodFromSetInd (ExaCod,SetIndTop);
|
SetCodTop = Exa_DB_GetSetCodFromSetInd (ExaCod,SetIndTop );
|
||||||
SetCodBottom = Exa_DB_GetSetCodFromSetInd (ExaCod,SetIndBottom);
|
SetCodBottom = Exa_DB_GetSetCodFromSetInd (ExaCod,SetIndBottom);
|
||||||
|
|
||||||
/***** Exchange indexes of sets *****/
|
/***** Exchange indexes of sets *****/
|
||||||
|
@ -1830,40 +1810,16 @@ static void ExaSet_ExchangeSets (long ExaCod,
|
||||||
*/
|
*/
|
||||||
/* Step 1: change temporarily top index to minus bottom index
|
/* Step 1: change temporarily top index to minus bottom index
|
||||||
in order to not repeat unique index (ExaCod,SetInd) */
|
in order to not repeat unique index (ExaCod,SetInd) */
|
||||||
DB_QueryUPDATE ("can not exchange indexes of sets",
|
Exa_DB_UpdateSetIndex (-((long) SetIndBottom),SetCodTop ,ExaCod);
|
||||||
"UPDATE exa_sets"
|
|
||||||
" SET SetInd=-%u"
|
|
||||||
" WHERE ExaCod=%ld"
|
|
||||||
" AND SetCod=%ld",
|
|
||||||
SetIndBottom,
|
|
||||||
ExaCod,
|
|
||||||
SetCodTop);
|
|
||||||
|
|
||||||
/* Step 2: change bottom index to old top index */
|
/* Step 2: change bottom index to old top index */
|
||||||
DB_QueryUPDATE ("can not exchange indexes of sets",
|
Exa_DB_UpdateSetIndex ( (long) SetIndTop ,SetCodBottom,ExaCod);
|
||||||
"UPDATE exa_sets"
|
|
||||||
" SET SetInd=%u"
|
|
||||||
" WHERE ExaCod=%ld"
|
|
||||||
" AND SetCod=%ld",
|
|
||||||
SetIndTop,
|
|
||||||
ExaCod,
|
|
||||||
SetCodBottom);
|
|
||||||
|
|
||||||
/* Step 3: change top index to old bottom index */
|
/* Step 3: change top index to old bottom index */
|
||||||
DB_QueryUPDATE ("can not exchange indexes of sets",
|
Exa_DB_UpdateSetIndex ( (long) SetIndBottom ,SetCodTop ,ExaCod);
|
||||||
"UPDATE exa_sets"
|
|
||||||
" SET SetInd=%u"
|
|
||||||
" WHERE ExaCod=%ld"
|
|
||||||
" AND SetCod=%ld",
|
|
||||||
SetIndBottom,
|
|
||||||
ExaCod,
|
|
||||||
SetCodTop);
|
|
||||||
|
|
||||||
/***** Unlock table *****/
|
/***** Unlock table *****/
|
||||||
Gbl.DB.LockedTables = false; // Set to false before the following unlock...
|
Exa_DB_LockTables ();
|
||||||
// ...to not retry the unlock if error in unlocking
|
|
||||||
DB_Query ("can not unlock tables after exchanging sets of questions",
|
|
||||||
"UNLOCK TABLES");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue