mirror of https://github.com/acanas/swad-core.git
Version 20.96.3: Sep 08, 2021 Queries moved to module swad_exam_database.
This commit is contained in:
parent
5611c0e7e7
commit
c8f9d9baad
|
@ -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.2 (2021-09-08)"
|
#define Log_PLATFORM_VERSION "SWAD 20.96.3 (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.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.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)
|
||||||
|
|
|
@ -485,6 +485,21 @@ unsigned Exa_DB_GetNumQstsInSet (long SetCod)
|
||||||
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 ********************/
|
/******************* Get some random questions from a set ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -505,11 +520,30 @@ unsigned Exa_DB_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res,
|
||||||
NumQstsToPrint);
|
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 ************/
|
/********** 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)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get a question",
|
DB_QuerySELECT (mysql_res,"can not get a question",
|
||||||
|
@ -520,6 +554,20 @@ unsigned Exa_DB_GetValidityAndTypeOfQuestion (MYSQL_RES **mysql_res,long QstCod)
|
||||||
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 ************/
|
/********* Remove the questions in sets of questions from an exam ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -69,9 +69,12 @@ void Exa_DB_RemoveSetsFromExam (long ExaCod);
|
||||||
void Exa_DB_RemoveSetsFromCrs (long CrsCod);
|
void Exa_DB_RemoveSetsFromCrs (long CrsCod);
|
||||||
|
|
||||||
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_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res,
|
unsigned Exa_DB_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res,
|
||||||
long SetCod,unsigned NumQstsToPrint);
|
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_RemoveSetQuestionsFromExam (long ExaCod);
|
||||||
void Exa_DB_RemoveSetQuestionsFromCrs (long CrsCod);
|
void Exa_DB_RemoveSetQuestionsFromCrs (long CrsCod);
|
||||||
|
|
||||||
|
|
|
@ -1091,7 +1091,7 @@ static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Pri
|
||||||
/***** Compute question score *****/
|
/***** Compute question score *****/
|
||||||
Tst_QstConstructor (&Question);
|
Tst_QstConstructor (&Question);
|
||||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
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);
|
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question);
|
||||||
Tst_QstDestructor (&Question);
|
Tst_QstDestructor (&Question);
|
||||||
|
|
||||||
|
|
|
@ -1448,7 +1448,7 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print)
|
||||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||||
|
|
||||||
/***** Get validity and answer type from database *****/
|
/***** 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);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
|
|
@ -682,36 +682,25 @@ static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams,
|
||||||
unsigned NumQsts;
|
unsigned NumQsts;
|
||||||
bool ICanEditQuestions = Exa_CheckIfEditable (Exam);
|
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 *****/
|
/***** Begin box *****/
|
||||||
if (ICanEditQuestions)
|
Box_BoxBegin (NULL,Txt_Questions,
|
||||||
Box_BoxBegin (NULL,Txt_Questions,
|
ICanEditQuestions ? ExaSet_PutIconToAddNewQuestions :
|
||||||
ExaSet_PutIconToAddNewQuestions,Exams,
|
NULL,
|
||||||
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
|
ICanEditQuestions ? Exams :
|
||||||
else
|
NULL,
|
||||||
Box_BoxBegin (NULL,Txt_Questions,
|
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
|
||||||
NULL,NULL,
|
|
||||||
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
|
|
||||||
|
|
||||||
/***** Show table with questions *****/
|
/***** Show table with questions *****/
|
||||||
if (NumQsts)
|
if ((NumQsts = Exa_DB_GetQstsFromSet (&mysql_res,Set->SetCod)))
|
||||||
ExaSet_ListOneOrMoreQuestionsForEdition (Exams,NumQsts,mysql_res,
|
ExaSet_ListOneOrMoreQuestionsForEdition (Exams,NumQsts,mysql_res,
|
||||||
ICanEditQuestions);
|
ICanEditQuestions);
|
||||||
|
|
||||||
/***** Put button to add a new question in this set *****/
|
/***** Put button to add a new question in this set *****/
|
||||||
if (ICanEditQuestions) // I can edit questions
|
if (ICanEditQuestions) // I can edit questions
|
||||||
ExaSet_PutButtonToAddNewQuestions (Exams);
|
ExaSet_PutButtonToAddNewQuestions (Exams);
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** End box *****/
|
/***** End box *****/
|
||||||
Box_BoxEnd ();
|
Box_BoxEnd ();
|
||||||
|
@ -1049,18 +1038,14 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
|
||||||
/*************** Get answer type of a question from database *****************/
|
/*************** 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_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
Tst_AnswerType_t AnswerType;
|
Tst_AnswerType_t AnswerType;
|
||||||
|
|
||||||
/***** Get type of answer from database *****/
|
/***** Get type of answer from database *****/
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get the type of a question",
|
if (!Exa_DB_GetAnswerType (&mysql_res,QstCod))
|
||||||
"SELECT AnsType" // row[0]
|
|
||||||
" FROM exa_set_questions"
|
|
||||||
" WHERE QstCod=%ld",
|
|
||||||
QstCod))
|
|
||||||
Err_WrongQuestionExit ();
|
Err_WrongQuestionExit ();
|
||||||
|
|
||||||
/* Get type of answer */
|
/* Get type of answer */
|
||||||
|
@ -1085,18 +1070,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
|
|
||||||
/***** Get question data from database *****/
|
/***** Get question data from database *****/
|
||||||
QuestionExists = (DB_QuerySELECT (&mysql_res,"can not get a question",
|
if ((QuestionExists = (Exa_DB_GetQstDataByCod (&mysql_res,Question->QstCod) != 0)))
|
||||||
"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)
|
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void ExaSet_ListExamSets (struct Exa_Exams *Exams,
|
||||||
|
|
||||||
void ExaSet_ResetSet (struct ExaSet_Set *Set);
|
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_GetQstDataFromDB (struct Tst_Question *Question);
|
||||||
void ExaSet_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
|
void ExaSet_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
|
||||||
bool Shuffle);
|
bool Shuffle);
|
||||||
|
|
Loading…
Reference in New Issue