Version 21.46.2: Oct 26, 2021 Queries moved to module swad_test_database.

This commit is contained in:
acanas 2021-10-26 22:20:18 +02:00
parent d38b53b196
commit 5ad59021f1
5 changed files with 37 additions and 31 deletions

View File

@ -602,14 +602,15 @@ 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 21.46.1 (2021-10-26)"
#define Log_PLATFORM_VERSION "SWAD 21.46.2 (2021-10-26)"
#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 21.46.1: Oct 26, 2021 Queries moved to module swad_test_database. (? lines)
Version 21.46.2: Oct 26, 2021 Queries moved to module swad_test_database. (321062 lines)
Version 21.46.1: Oct 26, 2021 Queries moved to module swad_test_database. (321058 lines)
Version 21.46: Oct 26, 2021 New module swad_test_database for database queries related to self-assessment tests. (321036 lines)
Version 21.45.1: Oct 25, 2021 Code refactoring in test questions. (320932 lines)
Version 21.45: Oct 25, 2021 Functions moved to module swad_question. (320930 lines)

View File

@ -1354,7 +1354,7 @@ static void ExaSet_CopyQstFromBankToExamSet (const struct ExaSet_Set *Set,long Q
QstCodInSet = Exa_DB_AddQuestionToSet (Set->SetCod,&Question,CloneMedCod);
/***** Get the answers from the database *****/
Qst_GetAnswersQst (&Question,&mysql_res,
Question.Answer.NumOptions = Qst_DB_GetAnswersQst (&mysql_res,&Question,
false); // Don't shuffle
/*
row[0] AnsInd

View File

@ -1402,11 +1402,14 @@ unsigned Qst_DB_GetNumAnswersQst (long QstCod)
/***************** Get answers of a question from database *******************/
/*****************************************************************************/
void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res,
unsigned Qst_DB_GetAnswersQst (MYSQL_RES **mysql_res,
const struct Qst_Question *Question,
bool Shuffle)
{
unsigned NumOptions;
/***** Get answers of a question from database *****/
Question->Answer.NumOptions = (unsigned)
if (!(NumOptions = (unsigned)
DB_QuerySELECT (mysql_res,"can not get answers of a question",
"SELECT AnsInd," // row[0]
"Answer," // row[1]
@ -1418,9 +1421,10 @@ void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res,
" ORDER BY %s",
Question->QstCod,
Shuffle ? "RAND()" :
"AnsInd");
if (!Question->Answer.NumOptions)
"AnsInd")))
Err_WrongAnswerExit ();
return NumOptions;
}
/*****************************************************************************/
@ -2606,7 +2610,7 @@ bool Qst_GetQstDataFromDB (struct Qst_Question *Question)
DB_FreeMySQLResult (&mysql_res);
/***** Get the answers from the database *****/
Qst_GetAnswersQst (Question,&mysql_res,
Question->Answer.NumOptions = Qst_DB_GetAnswersQst (&mysql_res,Question,
false); // Don't shuffle
/*
row[0] AnsInd

View File

@ -178,7 +178,8 @@ void Qst_WriteQuestionRowForSelection (unsigned QstInd,
void Qst_PutParamsEditQst (void *Questions);
unsigned Qst_DB_GetNumAnswersQst (long QstCod);
void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res,
unsigned Qst_DB_GetAnswersQst (MYSQL_RES **mysql_res,
const struct Qst_Question *Question,
bool Shuffle);
void Qst_WriteAnswersBank (struct Qst_Question *Question,

View File

@ -193,11 +193,11 @@ static void Tst_ShowFormRequestTest (struct Qst_Questions *Questions)
Qst_PutButtonToAddQuestion ();
}
/***** End box *****/
Box_BoxEnd ();
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** End box *****/
Box_BoxEnd ();
}
/*****************************************************************************/
@ -582,7 +582,7 @@ static void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQue
Question.QstCod = PrintedQuestion->QstCod;
/***** Get answers of question from database *****/
Qst_GetAnswersQst (&Question,&mysql_res,Shuffle);
Question.Answer.NumOptions = Qst_DB_GetAnswersQst (&mysql_res,&Question,Shuffle);
/*
row[0] AnsInd
row[1] Answer