mirror of https://github.com/acanas/swad-core.git
Version 21.46.2: Oct 26, 2021 Queries moved to module swad_test_database.
This commit is contained in:
parent
d38b53b196
commit
5ad59021f1
|
@ -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)
|
||||
|
|
|
@ -1354,8 +1354,8 @@ 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,
|
||||
false); // Don't shuffle
|
||||
Question.Answer.NumOptions = Qst_DB_GetAnswersQst (&mysql_res,&Question,
|
||||
false); // Don't shuffle
|
||||
/*
|
||||
row[0] AnsInd
|
||||
row[1] Answer
|
||||
|
|
|
@ -1402,25 +1402,29 @@ unsigned Qst_DB_GetNumAnswersQst (long QstCod)
|
|||
/***************** Get answers of a question from database *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res,
|
||||
bool Shuffle)
|
||||
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)
|
||||
DB_QuerySELECT (mysql_res,"can not get answers of a question",
|
||||
"SELECT AnsInd," // row[0]
|
||||
"Answer," // row[1]
|
||||
"Feedback," // row[2]
|
||||
"MedCod," // row[3]
|
||||
"Correct" // row[4]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
Shuffle ? "RAND()" :
|
||||
"AnsInd");
|
||||
if (!Question->Answer.NumOptions)
|
||||
if (!(NumOptions = (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get answers of a question",
|
||||
"SELECT AnsInd," // row[0]
|
||||
"Answer," // row[1]
|
||||
"Feedback," // row[2]
|
||||
"MedCod," // row[3]
|
||||
"Correct" // row[4]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
Shuffle ? "RAND()" :
|
||||
"AnsInd")))
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
return NumOptions;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2606,8 +2610,8 @@ bool Qst_GetQstDataFromDB (struct Qst_Question *Question)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** Get the answers from the database *****/
|
||||
Qst_GetAnswersQst (Question,&mysql_res,
|
||||
false); // Don't shuffle
|
||||
Question->Answer.NumOptions = Qst_DB_GetAnswersQst (&mysql_res,Question,
|
||||
false); // Don't shuffle
|
||||
/*
|
||||
row[0] AnsInd
|
||||
row[1] Answer
|
||||
|
|
|
@ -178,8 +178,9 @@ 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,
|
||||
bool Shuffle);
|
||||
unsigned Qst_DB_GetAnswersQst (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Question *Question,
|
||||
bool Shuffle);
|
||||
|
||||
void Qst_WriteAnswersBank (struct Qst_Question *Question,
|
||||
const char *ClassTxt,
|
||||
|
|
14
swad_test.c
14
swad_test.c
|
@ -193,11 +193,11 @@ static void Tst_ShowFormRequestTest (struct Qst_Questions *Questions)
|
|||
Qst_PutButtonToAddQuestion ();
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -250,7 +250,7 @@ void Tst_ShowNewTest (void)
|
|||
}
|
||||
}
|
||||
else
|
||||
Tst_ShowFormRequestTest (&Questions); // Show the form again
|
||||
Tst_ShowFormRequestTest (&Questions); // Show the form again
|
||||
}
|
||||
|
||||
/***** Destroy test *****/
|
||||
|
@ -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
|
||||
|
@ -706,8 +706,8 @@ bool Tst_GetParamsTst (struct Qst_Questions *Questions,
|
|||
Par_GetParMultiToText ("Order",UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT);
|
||||
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
|
||||
Questions->SelectedOrder = (Qst_QuestionsOrder_t)
|
||||
((UnsignedNum < Qst_NUM_TYPES_ORDER_QST) ? UnsignedNum :
|
||||
0);
|
||||
((UnsignedNum < Qst_NUM_TYPES_ORDER_QST) ? UnsignedNum :
|
||||
0);
|
||||
else
|
||||
Questions->SelectedOrder = (Qst_QuestionsOrder_t) 0;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue