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

This commit is contained in:
acanas 2021-09-08 19:29:18 +02:00
parent 5611c0e7e7
commit c8f9d9baad
7 changed files with 76 additions and 50 deletions

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.
*/
#define Log_PLATFORM_VERSION "SWAD 20.96.2 (2021-09-08)"
#define Log_PLATFORM_VERSION "SWAD 20.96.3 (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.3: Sep 08, 2021 Queries moved to module swad_exam_database. (314384 lines)
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)

View File

@ -485,6 +485,21 @@ unsigned Exa_DB_GetNumQstsInSet (long SetCod)
SetCod);
}
/*****************************************************************************/
/*********************** Get all questions from a set ************************/
/*****************************************************************************/
unsigned Exa_DB_GetQstsFromSet (MYSQL_RES **mysql_res,long SetCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get questions from set",
"SELECT QstCod" // row[0]
" FROM exa_set_questions"
" WHERE SetCod=%ld"
" ORDER BY Stem",
SetCod);
}
/*****************************************************************************/
/******************* Get some random questions from a set ********************/
/*****************************************************************************/
@ -505,11 +520,30 @@ unsigned Exa_DB_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res,
NumQstsToPrint);
}
/*****************************************************************************/
/********************* Get data from a question in a set *********************/
/*****************************************************************************/
unsigned Exa_DB_GetQstDataByCod (MYSQL_RES **mysql_res,long QstCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get a question",
"SELECT Invalid," // row[0]
"AnsType," // row[1]
"Shuffle," // row[2]
"Stem," // row[3]
"Feedback," // row[4]
"MedCod" // row[5]
" FROM exa_set_questions"
" WHERE QstCod=%ld",
QstCod);
}
/*****************************************************************************/
/********** Get validity and answer type from a question in a set ************/
/*****************************************************************************/
unsigned Exa_DB_GetValidityAndTypeOfQuestion (MYSQL_RES **mysql_res,long QstCod)
unsigned Exa_DB_GetValidityAndAnswerType (MYSQL_RES **mysql_res,long QstCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get a question",
@ -520,6 +554,20 @@ unsigned Exa_DB_GetValidityAndTypeOfQuestion (MYSQL_RES **mysql_res,long QstCod)
QstCod);
}
/*****************************************************************************/
/***************** Get answer type from a question in a set ******************/
/*****************************************************************************/
unsigned Exa_DB_GetAnswerType (MYSQL_RES **mysql_res,long QstCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get a question",
"SELECT AnsType" // row[0]
" FROM exa_set_questions"
" WHERE QstCod=%ld",
QstCod);
}
/*****************************************************************************/
/********* Remove the questions in sets of questions from an exam ************/
/*****************************************************************************/

View File

@ -69,9 +69,12 @@ void Exa_DB_RemoveSetsFromExam (long ExaCod);
void Exa_DB_RemoveSetsFromCrs (long CrsCod);
unsigned Exa_DB_GetNumQstsInSet (long SetCod);
unsigned Exa_DB_GetQstsFromSet (MYSQL_RES **mysql_res,long SetCod);
unsigned Exa_DB_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res,
long SetCod,unsigned NumQstsToPrint);
unsigned Exa_DB_GetValidityAndTypeOfQuestion (MYSQL_RES **mysql_res,long QstCod);
unsigned Exa_DB_GetQstDataByCod (MYSQL_RES **mysql_res,long QstCod);
unsigned Exa_DB_GetValidityAndAnswerType (MYSQL_RES **mysql_res,long QstCod);
unsigned Exa_DB_GetAnswerType (MYSQL_RES **mysql_res,long QstCod);
void Exa_DB_RemoveSetQuestionsFromExam (long ExaCod);
void Exa_DB_RemoveSetQuestionsFromCrs (long CrsCod);

View File

@ -1091,7 +1091,7 @@ static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Pri
/***** Compute question score *****/
Tst_QstConstructor (&Question);
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
Question.Answer.Type = ExaSet_GetQstAnswerTypeFromDB (Question.QstCod);
Question.Answer.Type = ExaSet_GetAnswerType (Question.QstCod);
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question);
Tst_QstDestructor (&Question);

View File

@ -1448,7 +1448,7 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print)
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
/***** Get validity and answer type from database *****/
if ((QuestionExists = (Exa_DB_GetValidityAndTypeOfQuestion (&mysql_res,Question.QstCod) != 0)))
if ((QuestionExists = (Exa_DB_GetValidityAndAnswerType (&mysql_res,Question.QstCod) != 0)))
{
row = mysql_fetch_row (mysql_res);

View File

@ -682,36 +682,25 @@ static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams,
unsigned NumQsts;
bool ICanEditQuestions = Exa_CheckIfEditable (Exam);
/***** Get data of questions from database *****/
NumQsts = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get exam questions",
"SELECT QstCod" // row[0]
" FROM exa_set_questions"
" WHERE SetCod=%ld"
" ORDER BY Stem",
Set->SetCod);
/***** Begin box *****/
if (ICanEditQuestions)
Box_BoxBegin (NULL,Txt_Questions,
ExaSet_PutIconToAddNewQuestions,Exams,
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
else
Box_BoxBegin (NULL,Txt_Questions,
NULL,NULL,
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
Box_BoxBegin (NULL,Txt_Questions,
ICanEditQuestions ? ExaSet_PutIconToAddNewQuestions :
NULL,
ICanEditQuestions ? Exams :
NULL,
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
/***** Show table with questions *****/
if (NumQsts)
ExaSet_ListOneOrMoreQuestionsForEdition (Exams,NumQsts,mysql_res,
ICanEditQuestions);
/***** Show table with questions *****/
if ((NumQsts = Exa_DB_GetQstsFromSet (&mysql_res,Set->SetCod)))
ExaSet_ListOneOrMoreQuestionsForEdition (Exams,NumQsts,mysql_res,
ICanEditQuestions);
/***** Put button to add a new question in this set *****/
if (ICanEditQuestions) // I can edit questions
ExaSet_PutButtonToAddNewQuestions (Exams);
/***** Put button to add a new question in this set *****/
if (ICanEditQuestions) // I can edit questions
ExaSet_PutButtonToAddNewQuestions (Exams);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** End box *****/
Box_BoxEnd ();
@ -1049,18 +1038,14 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
/*************** Get answer type of a question from database *****************/
/*****************************************************************************/
Tst_AnswerType_t ExaSet_GetQstAnswerTypeFromDB (long QstCod)
Tst_AnswerType_t ExaSet_GetAnswerType (long QstCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
Tst_AnswerType_t AnswerType;
/***** Get type of answer from database *****/
if (!DB_QuerySELECT (&mysql_res,"can not get the type of a question",
"SELECT AnsType" // row[0]
" FROM exa_set_questions"
" WHERE QstCod=%ld",
QstCod))
if (!Exa_DB_GetAnswerType (&mysql_res,QstCod))
Err_WrongQuestionExit ();
/* Get type of answer */
@ -1085,18 +1070,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
unsigned NumOpt;
/***** Get question data from database *****/
QuestionExists = (DB_QuerySELECT (&mysql_res,"can not get a question",
"SELECT Invalid," // row[0]
"AnsType," // row[1]
"Shuffle," // row[2]
"Stem," // row[3]
"Feedback," // row[4]
"MedCod" // row[5]
" FROM exa_set_questions"
" WHERE QstCod=%ld",
Question->QstCod) != 0);
if (QuestionExists)
if ((QuestionExists = (Exa_DB_GetQstDataByCod (&mysql_res,Question->QstCod) != 0)))
{
row = mysql_fetch_row (mysql_res);

View File

@ -58,7 +58,7 @@ void ExaSet_ListExamSets (struct Exa_Exams *Exams,
void ExaSet_ResetSet (struct ExaSet_Set *Set);
Tst_AnswerType_t ExaSet_GetQstAnswerTypeFromDB (long QstCod);
Tst_AnswerType_t ExaSet_GetAnswerType (long QstCod);
void ExaSet_GetQstDataFromDB (struct Tst_Question *Question);
void ExaSet_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
bool Shuffle);