mirror of https://github.com/acanas/swad-core.git
Version 21.45.1: Oct 25, 2021 Code refactoring in test questions.
This commit is contained in:
parent
12bb423b13
commit
352de7c69d
|
@ -5223,7 +5223,7 @@ int swad__getMatchStatus (struct soap *soap,
|
|||
case Mch_STEM: // Showing only the question stem
|
||||
case Mch_ANSWERS: // Showing the question stem and the answers
|
||||
case Mch_RESULTS: // Showing the results
|
||||
getMatchStatusOut->numAnswers = (int) Qst_GetNumAnswersQst (Match.Status.QstCod);
|
||||
getMatchStatusOut->numAnswers = (int) Qst_DB_GetNumAnswersQst (Match.Status.QstCod);
|
||||
Mch_GetQstAnsFromDB (Match.MchCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Match.Status.QstInd,
|
||||
|
|
|
@ -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 21.45 (2021-10-25)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.45.1 (2021-10-25)"
|
||||
#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.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)
|
||||
Version 21.44: Oct 25, 2021 Functions moved to module swad_question. (320928 lines)
|
||||
Version 21.43: Oct 25, 2021 New module swad_question for test/exam/game questions. (320919 lines)
|
||||
|
|
|
@ -2013,7 +2013,7 @@ static void Fig_GetAndShowTestsStats (void)
|
|||
AnsType++)
|
||||
{
|
||||
/***** Get the stats about test questions from this location *****/
|
||||
Tst_GetTestStats (AnsType,&Stats);
|
||||
Qst_GetTestStats (AnsType,&Stats);
|
||||
|
||||
/***** Write number of assignments *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
@ -2062,7 +2062,7 @@ static void Fig_GetAndShowTestsStats (void)
|
|||
}
|
||||
|
||||
/***** Get the stats about test questions from this location *****/
|
||||
Tst_GetTestStats (Qst_ANS_UNKNOWN,&Stats);
|
||||
Qst_GetTestStats (Qst_ANS_UNKNOWN,&Stats);
|
||||
|
||||
/***** Write number of assignments *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
|
|
@ -3018,7 +3018,7 @@ static void Mch_ShowQuestionAndAnswersStd (const struct Mch_Match *Match,
|
|||
char *Class;
|
||||
|
||||
/***** Get number of options in this question *****/
|
||||
NumOptions = Qst_GetNumAnswersQst (Match->Status.QstCod);
|
||||
NumOptions = Qst_DB_GetNumAnswersQst (Match->Status.QstCod);
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWidePadding (8);
|
||||
|
|
|
@ -1408,10 +1408,10 @@ void Qst_PutParamsEditQst (void *Questions)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Get answers of a test question from database ****************/
|
||||
/************ Get number of answers of a question from database **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Qst_GetNumAnswersQst (long QstCod)
|
||||
unsigned Qst_DB_GetNumAnswersQst (long QstCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of answers of a question",
|
||||
|
@ -1421,6 +1421,10 @@ unsigned Qst_GetNumAnswersQst (long QstCod)
|
|||
QstCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Get answers of a question from database *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res,
|
||||
bool Shuffle)
|
||||
{
|
||||
|
@ -3518,7 +3522,7 @@ void Qst_RemoveOneQstFromDB (long CrsCod,long QstCod)
|
|||
|
||||
/***** Remove the question from all the tables *****/
|
||||
/* Remove answers and tags from this test question */
|
||||
Qst_RemAnsFromQst (QstCod);
|
||||
Qst_DB_RemAnsFromQst (QstCod);
|
||||
Tag_DB_RemTagsFromQst (QstCod);
|
||||
Tag_DB_RemoveUnusedTagsFromCrs (CrsCod);
|
||||
|
||||
|
@ -3694,7 +3698,7 @@ void Qst_InsertOrUpdateQstIntoDB (struct Qst_Question *Question)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/* Remove answers and tags from this test question */
|
||||
Qst_RemAnsFromQst (Question->QstCod);
|
||||
Qst_DB_RemAnsFromQst (Question->QstCod);
|
||||
Tag_DB_RemTagsFromQst (Question->QstCod);
|
||||
}
|
||||
}
|
||||
|
@ -3823,7 +3827,7 @@ void Qst_RemoveCrsQsts (long CrsCod)
|
|||
/******************** Remove answers from a test question ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Qst_RemAnsFromQst (long QstCod)
|
||||
void Qst_DB_RemAnsFromQst (long QstCod)
|
||||
{
|
||||
/***** Remove answers *****/
|
||||
DB_QueryDELETE ("can not remove the answers of a question",
|
||||
|
@ -4519,3 +4523,32 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get stats about test questions **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Qst_GetTestStats (Qst_AnswerType_t AnsType,struct Qst_Stats *Stats)
|
||||
{
|
||||
Stats->NumQsts = 0;
|
||||
Stats->NumCoursesWithQuestions = Stats->NumCoursesWithPluggableQuestions = 0;
|
||||
Stats->AvgQstsPerCourse = 0.0;
|
||||
Stats->NumHits = 0L;
|
||||
Stats->AvgHitsPerCourse = 0.0;
|
||||
Stats->AvgHitsPerQuestion = 0.0;
|
||||
Stats->TotalScore = 0.0;
|
||||
Stats->AvgScorePerQuestion = 0.0;
|
||||
|
||||
if (Qst_GetNumQuestions (Gbl.Scope.Current,AnsType,Stats))
|
||||
{
|
||||
if ((Stats->NumCoursesWithQuestions = Qst_GetNumCoursesWithQuestions (Gbl.Scope.Current,AnsType)) != 0)
|
||||
{
|
||||
Stats->NumCoursesWithPluggableQuestions = Qst_GetNumCoursesWithPluggableQuestions (Gbl.Scope.Current,AnsType);
|
||||
Stats->AvgQstsPerCourse = (double) Stats->NumQsts / (double) Stats->NumCoursesWithQuestions;
|
||||
Stats->AvgHitsPerCourse = (double) Stats->NumHits / (double) Stats->NumCoursesWithQuestions;
|
||||
}
|
||||
Stats->AvgHitsPerQuestion = (double) Stats->NumHits / (double) Stats->NumQsts;
|
||||
if (Stats->NumHits)
|
||||
Stats->AvgScorePerQuestion = Stats->TotalScore / (double) Stats->NumHits;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ void Qst_WriteQuestionRowForSelection (unsigned QstInd,
|
|||
|
||||
void Qst_PutParamsEditQst (void *Questions);
|
||||
|
||||
unsigned Qst_GetNumAnswersQst (long QstCod);
|
||||
unsigned Qst_DB_GetNumAnswersQst (long QstCod);
|
||||
void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res,
|
||||
bool Shuffle);
|
||||
|
||||
|
@ -273,7 +273,7 @@ void Qst_InsertOrUpdateQstIntoDB (struct Qst_Question *Question);
|
|||
void Qst_InsertAnswersIntoDB (struct Qst_Question *Question);
|
||||
|
||||
void Qst_RemoveCrsQsts (long CrsCod);
|
||||
void Qst_RemAnsFromQst (long QstCod);
|
||||
void Qst_DB_RemAnsFromQst (long QstCod);
|
||||
void Qst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod);
|
||||
void Qst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod);
|
||||
void Qst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod);
|
||||
|
@ -286,4 +286,6 @@ unsigned Qst_GetNumQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType,stru
|
|||
unsigned Qst_GetNumCoursesWithQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType);
|
||||
unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType);
|
||||
|
||||
void Qst_GetTestStats (Qst_AnswerType_t AnsType,struct Qst_Stats *Stats);
|
||||
|
||||
#endif
|
||||
|
|
41
swad_test.c
41
swad_test.c
|
@ -96,8 +96,8 @@ static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print);
|
|||
static bool Tst_CheckIfNextTstAllowed (void);
|
||||
static unsigned Tst_GetNumTstExamsGeneratedByMe (void);
|
||||
|
||||
static void Tst_IncreaseMyNumTstExams (void);
|
||||
static void Tst_UpdateLastAccTst (unsigned NumQsts);
|
||||
static void Tst_DB_IncreaseMyNumTstExams (void);
|
||||
static void Tst_DB_UpdateLastAccTst (unsigned NumQsts);
|
||||
|
||||
static void Tst_PutIconsTests (__attribute__((unused)) void *Args);
|
||||
|
||||
|
@ -242,7 +242,7 @@ void Tst_ShowNewTest (void)
|
|||
if (Print.NumQsts.All)
|
||||
{
|
||||
/***** Increase number of exams generated (answered or not) by me *****/
|
||||
Tst_IncreaseMyNumTstExams ();
|
||||
Tst_DB_IncreaseMyNumTstExams ();
|
||||
NumTstExamsGeneratedByMe = Tst_GetNumTstExamsGeneratedByMe ();
|
||||
|
||||
/***** Create new test exam in database *****/
|
||||
|
@ -255,7 +255,7 @@ void Tst_ShowNewTest (void)
|
|||
|
||||
/***** Update date-time of my next allowed access to test *****/
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
||||
Tst_UpdateLastAccTst (Questions.NumQsts);
|
||||
Tst_DB_UpdateLastAccTst (Questions.NumQsts);
|
||||
}
|
||||
else // No questions found
|
||||
{
|
||||
|
@ -544,7 +544,7 @@ static unsigned Tst_GetNumTstExamsGeneratedByMe (void)
|
|||
/*********** Update my number of accesses to test in this course *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Tst_IncreaseMyNumTstExams (void)
|
||||
static void Tst_DB_IncreaseMyNumTstExams (void)
|
||||
{
|
||||
/***** Trivial check *****/
|
||||
if (!Gbl.Usrs.Me.IBelongToCurrentCrs)
|
||||
|
@ -564,7 +564,7 @@ static void Tst_IncreaseMyNumTstExams (void)
|
|||
/************ Update date-time of my next allowed access to test *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Tst_UpdateLastAccTst (unsigned NumQsts)
|
||||
static void Tst_DB_UpdateLastAccTst (unsigned NumQsts)
|
||||
{
|
||||
/***** Update date-time and number of questions of this test *****/
|
||||
DB_QueryUPDATE ("can not update time and number of questions of this test",
|
||||
|
@ -1273,32 +1273,3 @@ void Tst_RemoveCrsTests (long CrsCod)
|
|||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get stats about test questions **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Tst_GetTestStats (Qst_AnswerType_t AnsType,struct Qst_Stats *Stats)
|
||||
{
|
||||
Stats->NumQsts = 0;
|
||||
Stats->NumCoursesWithQuestions = Stats->NumCoursesWithPluggableQuestions = 0;
|
||||
Stats->AvgQstsPerCourse = 0.0;
|
||||
Stats->NumHits = 0L;
|
||||
Stats->AvgHitsPerCourse = 0.0;
|
||||
Stats->AvgHitsPerQuestion = 0.0;
|
||||
Stats->TotalScore = 0.0;
|
||||
Stats->AvgScorePerQuestion = 0.0;
|
||||
|
||||
if (Qst_GetNumQuestions (Gbl.Scope.Current,AnsType,Stats))
|
||||
{
|
||||
if ((Stats->NumCoursesWithQuestions = Qst_GetNumCoursesWithQuestions (Gbl.Scope.Current,AnsType)) != 0)
|
||||
{
|
||||
Stats->NumCoursesWithPluggableQuestions = Qst_GetNumCoursesWithPluggableQuestions (Gbl.Scope.Current,AnsType);
|
||||
Stats->AvgQstsPerCourse = (double) Stats->NumQsts / (double) Stats->NumCoursesWithQuestions;
|
||||
Stats->AvgHitsPerCourse = (double) Stats->NumHits / (double) Stats->NumCoursesWithQuestions;
|
||||
}
|
||||
Stats->AvgHitsPerQuestion = (double) Stats->NumHits / (double) Stats->NumQsts;
|
||||
if (Stats->NumHits)
|
||||
Stats->AvgScorePerQuestion = Stats->TotalScore / (double) Stats->NumHits;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,4 @@ unsigned Tst_CountNumQuestionsInList (const char *ListQuestions);
|
|||
|
||||
void Tst_RemoveCrsTests (long CrsCod);
|
||||
|
||||
void Tst_GetTestStats (Qst_AnswerType_t AnsType,struct Qst_Stats *Stats);
|
||||
|
||||
unsigned Qst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Question *Question);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue