diff --git a/swad_API.c b/swad_API.c index 2c476684..c9698415 100644 --- a/swad_API.c +++ b/swad_API.c @@ -4240,12 +4240,12 @@ static int API_GetTstQuestions (struct soap *soap, long CrsCod,long BeginTime, struct swad__getTestsOutput *getTestsOut) { - extern const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES]; + extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumRow; unsigned NumRows; - Tst_AnswerType_t AnswerType; + Qst_AnswerType_t AnswerType; /***** Get recent test questions from database *****/ // DISTINCTROW is necessary to not repeat questions @@ -4301,7 +4301,7 @@ static int API_GetTstQuestions (struct soap *soap, getTestsOut->questionsArray.__ptr[NumRow].questionCode = (int) Str_ConvertStrCodToLongCod (row[0]); /* Get answer type (row[1]) */ - AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); + AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); getTestsOut->questionsArray.__ptr[NumRow].answerType = soap_malloc (soap,Tst_MAX_BYTES_ANSWER_TYPE + 1); Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].answerType, @@ -4340,7 +4340,7 @@ static int API_GetTstAnswers (struct soap *soap, long CrsCod,long BeginTime, struct swad__getTestsOutput *getTestsOut) { - extern const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES]; + extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumRow,NumRows; @@ -4440,7 +4440,7 @@ static int API_GetTstQuestionTags (struct soap *soap, long CrsCod,long BeginTime, struct swad__getTestsOutput *getTestsOut) { - extern const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES]; + extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumRow,NumRows; @@ -4527,7 +4527,7 @@ int swad__getTrivialQuestion (struct soap *soap, char *wsKey,char *degrees,float lowerScore,float upperScore, // input struct swad__getTrivialQuestionOutput *getTrivialQuestionOut) // output { - extern const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES]; + extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES]; int ReturnCode; const char *Ptr; char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1]; @@ -4541,7 +4541,7 @@ int swad__getTrivialQuestion (struct soap *soap, unsigned NumRow; unsigned NumRows; long QstCod = -1L; - Tst_AnswerType_t AnswerType; + Qst_AnswerType_t AnswerType; unsigned Index; /***** Initializations *****/ @@ -4649,7 +4649,7 @@ int swad__getTrivialQuestion (struct soap *soap, getTrivialQuestionOut->question.questionCode = (int) QstCod; /* Get answer type (row[1]) */ - AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); + AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); getTrivialQuestionOut->question.answerType = soap_malloc (soap,Tst_MAX_BYTES_ANSWER_TYPE + 1); Str_Copy (getTrivialQuestionOut->question.answerType, @@ -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) Tst_GetNumAnswersQst (Match.Status.QstCod); + getMatchStatusOut->numAnswers = (int) Qst_GetNumAnswersQst (Match.Status.QstCod); Mch_GetQstAnsFromDB (Match.MchCod, Gbl.Usrs.Me.UsrDat.UsrCod, Match.Status.QstInd, diff --git a/swad_action.c b/swad_action.c index 18d33ac0..3723b28c 100644 --- a/swad_action.c +++ b/swad_action.c @@ -557,7 +557,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActSeeAsg ] = { 801, 1,TabAss,ActSeeAsg ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Asg_SeeAssignments ,"edit" }, [ActSeePrj ] = {1674, 2,TabAss,ActSeePrj ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prj_SeeProjects ,"file-invoice" }, [ActSeeAllExaAnn ] = { 85, 3,TabAss,ActSeeAllExaAnn ,0x3F8,0x3C7, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cfe_ListCallsForExamsSee ,"bullhorn" }, - [ActEdiTstQst ] = { 104, 4,TabAss,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,Tst_RequestEditTests ,"tasks" }, + [ActEdiTstQst ] = { 104, 4,TabAss,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,Qst_RequestEditQsts ,"tasks" }, [ActReqTst ] = { 103, 5,TabAss,ActReqTst ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_RequestTest ,"check" }, [ActSeeAllExa ] = {1848, 6,TabAss,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_SeeAllExams ,"file-signature" }, [ActSeeAllGam ] = {1649, 7,TabAss,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_SeeAllGames ,"gamepad" }, @@ -668,16 +668,16 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActHidCfe ] = {1620,-1,TabUnk,ActSeeAllExaAnn ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Cfe_HideCallForExam ,Cfe_ListCallsForExamsEdit ,NULL}, [ActUnhCfe ] = {1621,-1,TabUnk,ActSeeAllExaAnn ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Cfe_UnhideCallForExam ,Cfe_ListCallsForExamsEdit ,NULL}, - [ActEdiOneTstQst ] = { 105,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_ShowFormEditOneQst ,NULL}, + [ActEdiOneTstQst ] = { 105,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_ShowFormEditOneQst ,NULL}, [ActReqImpTstQst ] = {1007,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TsI_ShowFormImportQstsFromXML ,NULL}, [ActImpTstQst ] = {1008,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,TsI_ImportQstsFromXML ,NULL}, - [ActLstTstQst ] = { 132,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_ListQuestionsToEdit ,NULL}, - [ActRcvTstQst ] = { 126,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,Tst_ReceiveQst ,NULL}, - [ActReqRemSevTstQst ] = {1835,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_RequestRemoveSelectedQsts ,NULL}, - [ActRemSevTstQst ] = {1836,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_RemoveSelectedQsts ,NULL}, - [ActReqRemOneTstQst ] = {1523,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_RequestRemoveOneQst ,NULL}, - [ActRemOneTstQst ] = { 133,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_RemoveOneQst ,NULL}, - [ActChgShfTstQst ] = { 455,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_ChangeShuffleQst ,NULL}, + [ActLstTstQst ] = { 132,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_ListQuestionsToEdit ,NULL}, + [ActRcvTstQst ] = { 126,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,Qst_ReceiveQst ,NULL}, + [ActReqRemSevTstQst ] = {1835,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_RequestRemoveSelectedQsts ,NULL}, + [ActRemSevTstQst ] = {1836,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_RemoveSelectedQsts ,NULL}, + [ActReqRemOneTstQst ] = {1523,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_RequestRemoveOneQst ,NULL}, + [ActRemOneTstQst ] = { 133,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_RemoveOneQst ,NULL}, + [ActChgShfTstQst ] = { 455,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_ChangeShuffleQst ,NULL}, [ActEdiTag ] = {1907,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tag_ShowFormEditTags ,NULL}, [ActEnaTag ] = { 453,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tag_EnableTag ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index 235a25eb..8ea86bbf 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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.41.2 (2021-10-24)" +#define Log_PLATFORM_VERSION "SWAD 21.42 (2021-10-24)" #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.42: Oct 24, 2021 Code refactoring in test questions. (320782 lines) Version 21.41.2: Oct 24, 2021 Query moved to module swad_setting_database. (320777 lines) Version 21.41.1: Oct 24, 2021 Queries moved to module swad_tag_database. (320767 lines) Version 21.41: Oct 24, 2021 New module swad_tag_database for database queries related to question tags. (320721 lines) diff --git a/swad_exam_database.c b/swad_exam_database.c index f17234e3..0704a6ac 100644 --- a/swad_exam_database.c +++ b/swad_exam_database.c @@ -859,13 +859,13 @@ void Exa_DB_RemoveAllSetsFromCrs (long CrsCod) /******************* Insert question in table of questions *******************/ /*****************************************************************************/ -long Exa_DB_AddQuestionToSet (long SetCod,const struct Tst_Question *Question,long MedCod) +long Exa_DB_AddQuestionToSet (long SetCod,const struct Qst_Question *Question,long MedCod) { - extern const char *Tst_StrAnswerTypesDB[Tst_NUM_ANS_TYPES]; - static char CharInvalid[Tst_NUM_VALIDITIES] = + extern const char *Tst_StrAnswerTypesDB[Qst_NUM_ANS_TYPES]; + static char CharInvalid[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = 'Y', - [Tst_VALID_QUESTION ] = 'N' + [Qst_INVALID_QUESTION] = 'Y', + [Qst_VALID_QUESTION ] = 'N' }; return @@ -891,12 +891,12 @@ long Exa_DB_AddQuestionToSet (long SetCod,const struct Tst_Question *Question,lo /*****************************************************************************/ void Exa_DB_ChangeValidityQst (long QstCod,long SetCod,long ExaCod,long CrsCod, - Tst_Validity_t Validity) + Qst_Validity_t Validity) { - static char CharInvalid[Tst_NUM_VALIDITIES] = + static char CharInvalid[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = 'Y', - [Tst_VALID_QUESTION ] = 'N' + [Qst_INVALID_QUESTION] = 'Y', + [Qst_VALID_QUESTION ] = 'N' }; DB_QueryUPDATE ("can not validate question", @@ -1974,9 +1974,9 @@ unsigned Exa_DB_GetPrintQuestions (MYSQL_RES **mysql_res,long PrnCod) /*****************************************************************************/ void Exa_DB_GetAnswersFromQstInPrint (long PrnCod,long QstCod, - char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]) + char StrAnswers[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]) { - DB_QuerySELECTString (StrAnswers,Tst_MAX_BYTES_ANSWERS_ONE_QST, + DB_QuerySELECTString (StrAnswers,Qst_MAX_BYTES_ANSWERS_ONE_QST, "can not get answer in an exam print", "SELECT Answers" " FROM exa_print_questions" diff --git a/swad_exam_database.h b/swad_exam_database.h index 019d5f9f..644436d7 100644 --- a/swad_exam_database.h +++ b/swad_exam_database.h @@ -82,9 +82,9 @@ void Exa_DB_RemoveAllSetsFromExam (long ExaCod); void Exa_DB_RemoveAllSetsFromCrs (long CrsCod); //------------------------------ Set questions -------------------------------- -long Exa_DB_AddQuestionToSet (long SetCod,const struct Tst_Question *Question,long MedCod); +long Exa_DB_AddQuestionToSet (long SetCod,const struct Qst_Question *Question,long MedCod); void Exa_DB_ChangeValidityQst (long QstCod,long SetCod,long ExaCod,long CrsCod, - Tst_Validity_t Validity); + Qst_Validity_t Validity); unsigned Exa_DB_GetNumQstsInSet (long SetCod); unsigned Exa_DB_GetQstsFromSet (MYSQL_RES **mysql_res,long SetCod); unsigned Exa_DB_GetSomeQstsFromSetToPrint (MYSQL_RES **mysql_res, @@ -154,7 +154,7 @@ void Exa_DB_StoreOneQstOfPrint (const struct ExaPrn_Print *Print, unsigned QstInd); unsigned Exa_DB_GetPrintQuestions (MYSQL_RES **mysql_res,long PrnCod); void Exa_DB_GetAnswersFromQstInPrint (long PrnCod,long QstCod, - char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]); + char StrAnswers[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]); unsigned Exa_DB_GetNumQstsNotBlankInPrint (long PrnCod); double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod); void Exa_DB_RemovePrintQstsMadeByUsrInAllCrss (long UsrCod); diff --git a/swad_exam_print.c b/swad_exam_print.c index 0e788bbf..faf075ce 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -89,27 +89,27 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams, const struct ExaPrn_Print *Print); static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question); + struct Qst_Question *Question); static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question); + struct Qst_Question *Question); //----------------------------------------------------------------------------- static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question); + struct Qst_Question *Question); static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); //----------------------------------------------------------------------------- static void ExaPrn_WriteJSToUpdateExamPrint (const struct ExaPrn_Print *Print, @@ -125,21 +125,21 @@ static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Pri //----------------------------------------------------------------------------- static void ExaPrn_GetCorrectAndComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void ExaPrn_GetCorrectAndComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void ExaPrn_GetCorrectAndComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void ExaPrn_GetCorrectAndComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void ExaPrn_GetCorrectAndComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); //----------------------------------------------------------------------------- -static void ExaPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question); -static void ExaPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question); -static void ExaPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question); -static void ExaPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question); -static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question); +static void ExaPrn_GetCorrectIntAnswerFromDB (struct Qst_Question *Question); +static void ExaPrn_GetCorrectFltAnswerFromDB (struct Qst_Question *Question); +static void ExaPrn_GetCorrectTF_AnswerFromDB (struct Qst_Question *Question); +static void ExaPrn_GetCorrectChoAnswerFromDB (struct Qst_Question *Question); +static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Qst_Question *Question); //----------------------------------------------------------------------------- /*****************************************************************************/ @@ -392,7 +392,7 @@ static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print, MYSQL_ROW row; unsigned NumQstsInSet; unsigned NumQstInSet; - Tst_AnswerType_t AnswerType; + Qst_AnswerType_t AnswerType; bool Shuffle; /***** Get questions from database *****/ @@ -422,7 +422,7 @@ static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print, Print->PrintedQuestions[*NumQstsInPrint].SetCod = Set->SetCod; /* Get answer type (row[1]) */ - AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); + AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); /* Get shuffle (row[2]) */ Shuffle = (row[2][0] == 'Y'); @@ -430,14 +430,14 @@ static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print, /* Set indexes of answers */ switch (AnswerType) { - case Tst_ANS_INT: - case Tst_ANS_FLOAT: - case Tst_ANS_TRUE_FALSE: - case Tst_ANS_TEXT: + case Qst_ANS_INT: + case Qst_ANS_FLOAT: + case Qst_ANS_TRUE_FALSE: + case Qst_ANS_TEXT: Print->PrintedQuestions[*NumQstsInPrint].StrIndexes[0] = '\0'; break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: /* If answer type is unique or multiple option, generate indexes of answers depending on shuffle */ ExaPrn_GenerateChoiceIndexes (&Print->PrintedQuestions[*NumQstsInPrint],Shuffle); @@ -466,7 +466,7 @@ static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print, static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion, bool Shuffle) { - struct Tst_Question Question; + struct Qst_Question Question; unsigned NumOpt; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -475,7 +475,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed char StrInd[1 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = PrintedQuestion->QstCod; /***** Get answers of question from database *****/ @@ -502,7 +502,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed ErrorInIndex = false; if (sscanf (row[0],"%u",&Index) == 1) { - if (Index >= Tst_MAX_OPTIONS_PER_QUESTION) + if (Index >= Qst_MAX_OPTIONS_PER_QUESTION) ErrorInIndex = true; } else @@ -522,7 +522,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed DB_FreeMySQLResult (&mysql_res); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /*****************************************************************************/ @@ -663,7 +663,7 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams, { extern const char *Txt_I_have_finished; unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (10); @@ -674,7 +674,7 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams, QstInd++) { /* Create test question */ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; /* Get question from database */ @@ -684,7 +684,7 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams, ExaPrn_WriteQstAndAnsToFill (Print,QstInd,&Question); /* Destroy test question */ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /***** End table *****/ @@ -703,7 +703,7 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams, static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question) + struct Qst_Question *Question) { static struct ExaSet_Set CurrentSet = { @@ -733,15 +733,15 @@ static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print, /***** Number of question and answer type *****/ HTM_TD_Begin ("class=\"RT\""); - Tst_WriteNumQst (QstInd + 1,"BIG_INDEX"); - Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); + Qst_WriteNumQst (QstInd + 1,"BIG_INDEX"); + Qst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); HTM_TD_End (); /***** Stem, media and answers *****/ HTM_TD_Begin ("class=\"LT\""); /* Stem */ - Tst_WriteQstStem (Question->Stem,"TEST_TXT",true); + Qst_WriteQstStem (Question->Stem,"TEST_TXT",true); /* Media */ Med_ShowMedia (&Question->Media, @@ -765,18 +765,18 @@ static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print, static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question) + struct Qst_Question *Question) { - void (*ExaPrn_WriteAnsToFill[Tst_NUM_ANS_TYPES]) (const struct ExaPrn_Print *Print, + void (*ExaPrn_WriteAnsToFill[Qst_NUM_ANS_TYPES]) (const struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question) = + struct Qst_Question *Question) = { - [Tst_ANS_INT ] = ExaPrn_WriteIntAnsToFill, - [Tst_ANS_FLOAT ] = ExaPrn_WriteFltAnsToFill, - [Tst_ANS_TRUE_FALSE ] = ExaPrn_WriteTF_AnsToFill, - [Tst_ANS_UNIQUE_CHOICE ] = ExaPrn_WriteChoAnsToFill, - [Tst_ANS_MULTIPLE_CHOICE] = ExaPrn_WriteChoAnsToFill, - [Tst_ANS_TEXT ] = ExaPrn_WriteTxtAnsToFill, + [Qst_ANS_INT ] = ExaPrn_WriteIntAnsToFill, + [Qst_ANS_FLOAT ] = ExaPrn_WriteFltAnsToFill, + [Qst_ANS_TRUE_FALSE ] = ExaPrn_WriteTF_AnsToFill, + [Qst_ANS_UNIQUE_CHOICE ] = ExaPrn_WriteChoAnsToFill, + [Qst_ANS_MULTIPLE_CHOICE] = ExaPrn_WriteChoAnsToFill, + [Qst_ANS_TEXT ] = ExaPrn_WriteTxtAnsToFill, }; /***** Write answers *****/ @@ -789,7 +789,7 @@ static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print, static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" @@ -808,7 +808,7 @@ static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print, static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" @@ -816,7 +816,7 @@ static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print, snprintf (Id,sizeof (Id),"Ans%010u",QstInd); HTM_TxtF ("PrintedQuestions[QstInd].StrAnswers); ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,-1); HTM_Txt (" />"); @@ -828,7 +828,7 @@ static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print, static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { extern const char *Txt_TF_QST[2]; char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" @@ -853,15 +853,15 @@ static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print, static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question) + struct Qst_Question *Question) { unsigned NumOpt; - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question - bool UsrAnswers[Tst_MAX_OPTIONS_PER_QUESTION]; + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question + bool UsrAnswers[Qst_MAX_OPTIONS_PER_QUESTION]; char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Get indexes for this question from string *****/ TstPrn_GetIndexesFromStr (Print->PrintedQuestions[QstInd].StrIndexes,Indexes); @@ -887,7 +887,7 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print, HTM_TD_Begin ("class=\"LT\""); snprintf (Id,sizeof (Id),"Ans%010u",QstInd); HTM_TxtF ("Answer.Type == Tst_ANS_UNIQUE_CHOICE ? "radio" : + Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE ? "radio" : "checkbox", Id,NumOpt,Indexes[NumOpt], UsrAnswers[Indexes[NumOpt]] ? " checked=\"checked\"" : @@ -925,7 +925,7 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print, static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" @@ -933,7 +933,7 @@ static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print, snprintf (Id,sizeof (Id),"Ans%010u",QstInd); HTM_TxtF ("PrintedQuestions[QstInd].StrAnswers); ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,-1); HTM_Txt (" />"); @@ -1062,7 +1062,7 @@ static void ExaPrn_GetAnswerFromForm (struct ExaPrn_Print *Print,unsigned QstInd { /***** Get answers selected by user for this question *****/ Par_GetParToText ("Ans",Print->PrintedQuestions[QstInd].StrAnswers, - Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */ + Qst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */ } /*****************************************************************************/ @@ -1086,19 +1086,19 @@ static unsigned ExaPrn_GetParamQstInd (void) static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Print, unsigned QstInd) { - struct Tst_Question Question; - char CurrentStrAnswersInDB[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user + struct Qst_Question Question; + char CurrentStrAnswersInDB[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user /***** Compute question score *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; Question.Answer.Type = ExaSet_GetAnswerType (Question.QstCod); ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question); - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); /***** If type is unique choice and the option (radio button) is checked ==> uncheck it by deleting answer *****/ - if (Question.Answer.Type == Tst_ANS_UNIQUE_CHOICE) + if (Question.Answer.Type == Qst_ANS_UNIQUE_CHOICE) { Exa_DB_GetAnswersFromQstInPrint (Print->PrnCod,Print->PrintedQuestions[QstInd].QstCod, CurrentStrAnswersInDB); @@ -1121,17 +1121,17 @@ static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Pri /*****************************************************************************/ void ExaPrn_ComputeAnswerScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { - void (*ExaPrn_GetCorrectAndComputeAnsScore[Tst_NUM_ANS_TYPES]) (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) = + void (*ExaPrn_GetCorrectAndComputeAnsScore[Qst_NUM_ANS_TYPES]) (struct TstPrn_PrintedQuestion *PrintedQuestion, + struct Qst_Question *Question) = { - [Tst_ANS_INT ] = ExaPrn_GetCorrectAndComputeIntAnsScore, - [Tst_ANS_FLOAT ] = ExaPrn_GetCorrectAndComputeFltAnsScore, - [Tst_ANS_TRUE_FALSE ] = ExaPrn_GetCorrectAndComputeTF_AnsScore, - [Tst_ANS_UNIQUE_CHOICE ] = ExaPrn_GetCorrectAndComputeChoAnsScore, - [Tst_ANS_MULTIPLE_CHOICE] = ExaPrn_GetCorrectAndComputeChoAnsScore, - [Tst_ANS_TEXT ] = ExaPrn_GetCorrectAndComputeTxtAnsScore, + [Qst_ANS_INT ] = ExaPrn_GetCorrectAndComputeIntAnsScore, + [Qst_ANS_FLOAT ] = ExaPrn_GetCorrectAndComputeFltAnsScore, + [Qst_ANS_TRUE_FALSE ] = ExaPrn_GetCorrectAndComputeTF_AnsScore, + [Qst_ANS_UNIQUE_CHOICE ] = ExaPrn_GetCorrectAndComputeChoAnsScore, + [Qst_ANS_MULTIPLE_CHOICE] = ExaPrn_GetCorrectAndComputeChoAnsScore, + [Qst_ANS_TEXT ] = ExaPrn_GetCorrectAndComputeTxtAnsScore, }; /***** Get correct answer and compute answer score depending on type *****/ @@ -1143,7 +1143,7 @@ void ExaPrn_ComputeAnswerScore (struct TstPrn_PrintedQuestion *PrintedQuestion, /*****************************************************************************/ static void ExaPrn_GetCorrectAndComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get the numerical value of the correct answer, and compute score *****/ @@ -1152,7 +1152,7 @@ static void ExaPrn_GetCorrectAndComputeIntAnsScore (struct TstPrn_PrintedQuestio } static void ExaPrn_GetCorrectAndComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get the numerical value of the minimum and maximum correct answers, and compute score *****/ @@ -1161,7 +1161,7 @@ static void ExaPrn_GetCorrectAndComputeFltAnsScore (struct TstPrn_PrintedQuestio } static void ExaPrn_GetCorrectAndComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get answer true or false, and compute score *****/ @@ -1170,7 +1170,7 @@ static void ExaPrn_GetCorrectAndComputeTF_AnsScore (struct TstPrn_PrintedQuestio } static void ExaPrn_GetCorrectAndComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get correct options of test question from database, and compute score *****/ @@ -1179,7 +1179,7 @@ static void ExaPrn_GetCorrectAndComputeChoAnsScore (struct TstPrn_PrintedQuestio } static void ExaPrn_GetCorrectAndComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get correct text answers for this question from database, and compute score *****/ @@ -1191,7 +1191,7 @@ static void ExaPrn_GetCorrectAndComputeTxtAnsScore (struct TstPrn_PrintedQuestio /***************** Get correct answer for each type of answer ****************/ /*****************************************************************************/ -static void ExaPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) +static void ExaPrn_GetCorrectIntAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1200,7 +1200,7 @@ static void ExaPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) Question->Answer.NumOptions = Exa_DB_GetQstAnswersTextFromSet (&mysql_res,Question->QstCod); /***** Check if number of rows is correct *****/ - Tst_CheckIfNumberOfAnswersIsOne (Question); + Qst_CheckIfNumberOfAnswersIsOne (Question); /***** Get correct answer *****/ row = mysql_fetch_row (mysql_res); @@ -1211,7 +1211,7 @@ static void ExaPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void ExaPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question) +static void ExaPrn_GetCorrectFltAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1246,7 +1246,7 @@ static void ExaPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void ExaPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question) +static void ExaPrn_GetCorrectTF_AnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1255,7 +1255,7 @@ static void ExaPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question) Question->Answer.NumOptions = Exa_DB_GetQstAnswersTextFromSet (&mysql_res,Question->QstCod); /***** Check if number of rows is correct *****/ - Tst_CheckIfNumberOfAnswersIsOne (Question); + Qst_CheckIfNumberOfAnswersIsOne (Question); /***** Get answer *****/ row = mysql_fetch_row (mysql_res); @@ -1265,7 +1265,7 @@ static void ExaPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void ExaPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question) +static void ExaPrn_GetCorrectChoAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1288,7 +1288,7 @@ static void ExaPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question) +static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1306,7 +1306,7 @@ static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question) row = mysql_fetch_row (mysql_res); /***** Allocate memory for text in this choice answer *****/ - if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) + if (!Qst_AllocateTextChoiceAnswer (Question,NumOpt)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -1316,7 +1316,7 @@ static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question) } /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); diff --git a/swad_exam_print.h b/swad_exam_print.h index a8c60149..93a04d0c 100644 --- a/swad_exam_print.h +++ b/swad_exam_print.h @@ -88,6 +88,6 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print); void ExaPrn_ReceivePrintAnswer (void); void ExaPrn_ComputeAnswerScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); #endif diff --git a/swad_exam_result.c b/swad_exam_result.c index e23fd8f6..30c987ad 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -144,7 +144,7 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat, static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat, struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question, + struct Qst_Question *Question, unsigned Visibility); /*****************************************************************************/ @@ -1428,7 +1428,7 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print) MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; bool QuestionExists; /***** Initialize score valid *****/ @@ -1453,11 +1453,11 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print) row = mysql_fetch_row (mysql_res); /* Get whether the question is invalid (row[0]) */ - Question.Validity = (row[0][0] == 'Y') ? Tst_INVALID_QUESTION : - Tst_VALID_QUESTION; + Question.Validity = (row[0][0] == 'Y') ? Qst_INVALID_QUESTION : + Qst_VALID_QUESTION; /* Get the type of answer (row[1]) */ - Question.Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); + Question.Answer.Type = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); } /* Free structure that stores the query result */ @@ -1465,7 +1465,7 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print) /***** Compute answer score *****/ if (QuestionExists) - if (Question.Validity == Tst_VALID_QUESTION) + if (Question.Validity == Qst_VALID_QUESTION) { ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question); switch (Print->PrintedQuestions[QstInd].AnswerIsCorrect) @@ -1763,7 +1763,7 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat, unsigned Visibility) { unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; for (QstInd = 0; QstInd < Print->NumQsts.All; @@ -1772,7 +1772,7 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat, Gbl.RowEvenOdd = QstInd % 2; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; /***** Get question data *****/ @@ -1782,7 +1782,7 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat, ExaRes_WriteQstAndAnsExam (UsrDat,Print,QstInd,&Question,Visibility); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } } @@ -1793,31 +1793,31 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat, static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat, struct ExaPrn_Print *Print, unsigned QstInd, - struct Tst_Question *Question, + struct Qst_Question *Question, unsigned Visibility) { extern const char *Txt_Score; extern const char *Txt_Invalid_question; bool ICanView[TstVis_NUM_ITEMS_VISIBILITY]; - static char *ClassNumQst[Tst_NUM_VALIDITIES] = + static char *ClassNumQst[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "BIG_INDEX_RED", - [Tst_VALID_QUESTION ] = "BIG_INDEX", + [Qst_INVALID_QUESTION] = "BIG_INDEX_RED", + [Qst_VALID_QUESTION ] = "BIG_INDEX", }; - static char *ClassAnswerType[Tst_NUM_VALIDITIES] = + static char *ClassAnswerType[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "DAT_SMALL_RED", - [Tst_VALID_QUESTION ] = "DAT_SMALL", + [Qst_INVALID_QUESTION] = "DAT_SMALL_RED", + [Qst_VALID_QUESTION ] = "DAT_SMALL", }; - static char *ClassTxt[Tst_NUM_VALIDITIES] = + static char *ClassTxt[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "TEST_TXT_RED", - [Tst_VALID_QUESTION ] = "TEST_TXT", + [Qst_INVALID_QUESTION] = "TEST_TXT_RED", + [Qst_VALID_QUESTION ] = "TEST_TXT", }; - static char *ClassFeedback[Tst_NUM_VALIDITIES] = + static char *ClassFeedback[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "TEST_TXT_LIGHT_RED", - [Tst_VALID_QUESTION ] = "TEST_TXT_LIGHT", + [Qst_INVALID_QUESTION] = "TEST_TXT_LIGHT_RED", + [Qst_VALID_QUESTION ] = "TEST_TXT_LIGHT", }; /***** Check if I can view each part of the question *****/ @@ -1853,15 +1853,15 @@ static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat, /***** Number of question and answer type *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd + 1,ClassNumQst[Question->Validity]); - Tst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); + Qst_WriteNumQst (QstInd + 1,ClassNumQst[Question->Validity]); + Qst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); HTM_TD_End (); /***** Stem, media and answers *****/ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); /* Stem */ - Tst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], + Qst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], ICanView[TstVis_VISIBLE_QST_ANS_TXT]); /* Media */ @@ -1888,7 +1888,7 @@ static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat, "ANS_BAD") : // Wrong "ANS_0"); // Blank answer HTM_Double2Decimals (Print->PrintedQuestions[QstInd].Score); - if (Question->Validity == Tst_INVALID_QUESTION) + if (Question->Validity == Qst_INVALID_QUESTION) HTM_TxtF (" (%s)",Txt_Invalid_question); HTM_SPAN_End (); HTM_DIV_End (); @@ -1896,7 +1896,7 @@ static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat, /* Question feedback */ if (ICanView[TstVis_VISIBLE_FEEDBACK_TXT]) - Tst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); + Qst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); HTM_TD_End (); diff --git a/swad_exam_set.c b/swad_exam_set.c index 8860514e..7f03930f 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -108,7 +108,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, unsigned NumQsts, MYSQL_RES *mysql_res, bool ICanEditQuestions); -static void ExaSet_ListQuestionForEdition (struct Tst_Question *Question, +static void ExaSet_ListQuestionForEdition (struct Qst_Question *Question, unsigned QstInd,const char *Anchor); static void ExaSet_AllocateListSelectedQuestions (struct Exa_Exams *Exams); @@ -119,7 +119,7 @@ static void ExaSet_CopyQstFromBankToExamSet (const struct ExaSet_Set *Set,long Q static void ExaSet_RemoveMediaFromStemOfQst (long QstCod,long SetCod); static void ExaSet_RemoveMediaFromAllAnsOfQst (long QstCod,long SetCod); -static void ExaSet_ChangeValidityQst (Tst_Validity_t Valid); +static void ExaSet_ChangeValidityQst (Qst_Validity_t Valid); static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams, struct Exa_Exam *Exam, @@ -255,7 +255,7 @@ static void ExaSet_PutFormNewSet (struct Exa_Exams *Exams, /***** Index *****/ HTM_TD_Begin ("class=\"RM\""); - Tst_WriteNumQst (MaxSetInd + 1,"BIG_INDEX"); + Qst_WriteNumQst (MaxSetInd + 1,"BIG_INDEX"); HTM_TD_End (); /***** Title *****/ @@ -577,7 +577,7 @@ void ExaSet_ReqSelectQstsToAddToSet (void) ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set); /***** Show form to select questions for set *****/ - Tst_RequestSelectTestsForSet (&Exams); + Qst_RequestSelectQstsForExamSet (&Exams); /***** Show current exam and its sets *****/ Exa_PutFormsOneExam (&Exams,&Exam,&Set, @@ -818,7 +818,7 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, /***** Index *****/ HTM_TD_Begin ("rowspan=\"2\" class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (Set.SetInd,"BIG_INDEX"); + Qst_WriteNumQst (Set.SetInd,"BIG_INDEX"); HTM_TD_End (); /***** Title *****/ @@ -947,22 +947,22 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, extern const char *Txt_No_INDEX; extern const char *Txt_Question; unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; char *Anchor; - static Act_Action_t NextAction[Tst_NUM_VALIDITIES] = + static Act_Action_t NextAction[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = ActValSetQst, // Validate question (set it as valid question) - [Tst_VALID_QUESTION ] = ActInvSetQst, // Invalidated question (set it as canceled question) + [Qst_INVALID_QUESTION] = ActValSetQst, // Validate question (set it as valid question) + [Qst_VALID_QUESTION ] = ActInvSetQst, // Invalidated question (set it as canceled question) }; - static const char *Icon[Tst_NUM_VALIDITIES] = + static const char *Icon[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "times-red.svg", - [Tst_VALID_QUESTION ] = "check-green.svg", + [Qst_INVALID_QUESTION] = "times-red.svg", + [Qst_VALID_QUESTION ] = "check-green.svg", }; - const char *Title[Tst_NUM_VALIDITIES] = + const char *Title[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = Txt_Invalid_question, - [Tst_VALID_QUESTION ] = Txt_Valid_question, + [Qst_INVALID_QUESTION] = Txt_Invalid_question, + [Qst_VALID_QUESTION ] = Txt_Valid_question, }; /***** Begin table *****/ @@ -986,7 +986,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, Gbl.RowEvenOdd = QstInd % 2; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); /***** Get question data *****/ /* Get question code */ @@ -1027,7 +1027,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, Frm_FreeAnchorStr (Anchor); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /***** End table *****/ @@ -1038,11 +1038,11 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, /*************** Get answer type of a question from database *****************/ /*****************************************************************************/ -Tst_AnswerType_t ExaSet_GetAnswerType (long QstCod) +Qst_AnswerType_t ExaSet_GetAnswerType (long QstCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; - Tst_AnswerType_t AnswerType; + Qst_AnswerType_t AnswerType; /***** Get type of answer from database *****/ if (!Exa_DB_GetAnswerType (&mysql_res,QstCod)) @@ -1050,7 +1050,7 @@ Tst_AnswerType_t ExaSet_GetAnswerType (long QstCod) /* Get type of answer */ row = mysql_fetch_row (mysql_res); - AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]); + AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[0]); /* Free structure that stores the query result */ DB_FreeMySQLResult (&mysql_res); @@ -1062,7 +1062,7 @@ Tst_AnswerType_t ExaSet_GetAnswerType (long QstCod) /*************** Get data of a question in a set from database ***************/ /*****************************************************************************/ -void ExaSet_GetQstDataFromDB (struct Tst_Question *Question) +void ExaSet_GetQstDataFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1075,11 +1075,11 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question) row = mysql_fetch_row (mysql_res); /* Get whether the question is invalid (row[0]) */ - Question->Validity = (row[0][0] == 'Y') ? Tst_INVALID_QUESTION : - Tst_VALID_QUESTION; + Question->Validity = (row[0][0] == 'Y') ? Qst_INVALID_QUESTION : + Qst_VALID_QUESTION; /* Get the type of answer (row[1]) */ - Question->Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); + Question->Answer.Type = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); /* Get shuffle (row[2]) */ Question->Answer.Shuffle = (row[2][0] == 'Y'); @@ -1121,28 +1121,28 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question) row = mysql_fetch_row (mysql_res); switch (Question->Answer.Type) { - case Tst_ANS_INT: - Tst_CheckIfNumberOfAnswersIsOne (Question); - Question->Answer.Integer = Tst_GetIntAnsFromStr (row[1]); + case Qst_ANS_INT: + Qst_CheckIfNumberOfAnswersIsOne (Question); + Question->Answer.Integer = Qst_GetIntAnsFromStr (row[1]); break; - case Tst_ANS_FLOAT: + case Qst_ANS_FLOAT: if (Question->Answer.NumOptions != 2) Err_WrongAnswerExit (); Question->Answer.FloatingPoint[NumOpt] = Str_GetDoubleFromStr (row[1]); break; - case Tst_ANS_TRUE_FALSE: - Tst_CheckIfNumberOfAnswersIsOne (Question); + case Qst_ANS_TRUE_FALSE: + Qst_CheckIfNumberOfAnswersIsOne (Question); Question->Answer.TF = row[1][0]; break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: - case Tst_ANS_TEXT: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_TEXT: /* Check number of options */ - if (Question->Answer.NumOptions > Tst_MAX_OPTIONS_PER_QUESTION) + if (Question->Answer.NumOptions > Qst_MAX_OPTIONS_PER_QUESTION) Err_WrongAnswerExit (); /* Allocate space for text and feedback */ - if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) + if (!Qst_AllocateTextChoiceAnswer (Question,NumOpt)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -1184,34 +1184,34 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question) /********************* List question in set for edition **********************/ /*****************************************************************************/ -static void ExaSet_ListQuestionForEdition (struct Tst_Question *Question, +static void ExaSet_ListQuestionForEdition (struct Qst_Question *Question, unsigned QstInd,const char *Anchor) { - static char *ClassNumQst[Tst_NUM_VALIDITIES] = + static char *ClassNumQst[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "BIG_INDEX_RED", - [Tst_VALID_QUESTION ] = "BIG_INDEX", + [Qst_INVALID_QUESTION] = "BIG_INDEX_RED", + [Qst_VALID_QUESTION ] = "BIG_INDEX", }; - static char *ClassAnswerType[Tst_NUM_VALIDITIES] = + static char *ClassAnswerType[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "DAT_SMALL_RED", - [Tst_VALID_QUESTION ] = "DAT_SMALL", + [Qst_INVALID_QUESTION] = "DAT_SMALL_RED", + [Qst_VALID_QUESTION ] = "DAT_SMALL", }; - static char *ClassTxt[Tst_NUM_VALIDITIES] = + static char *ClassTxt[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "TEST_TXT_RED", - [Tst_VALID_QUESTION ] = "TEST_TXT", + [Qst_INVALID_QUESTION] = "TEST_TXT_RED", + [Qst_VALID_QUESTION ] = "TEST_TXT", }; - static char *ClassFeedback[Tst_NUM_VALIDITIES] = + static char *ClassFeedback[Qst_NUM_VALIDITIES] = { - [Tst_INVALID_QUESTION] = "TEST_TXT_LIGHT_RED", - [Tst_VALID_QUESTION ] = "TEST_TXT_LIGHT", + [Qst_INVALID_QUESTION] = "TEST_TXT_LIGHT_RED", + [Qst_VALID_QUESTION ] = "TEST_TXT_LIGHT", }; /***** Number of question and answer type (row[1]) *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd,ClassNumQst[Question->Validity]); - Tst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); + Qst_WriteNumQst (QstInd,ClassNumQst[Question->Validity]); + Qst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); HTM_TD_End (); /***** Write stem (row[3]) and media *****/ @@ -1219,7 +1219,7 @@ static void ExaSet_ListQuestionForEdition (struct Tst_Question *Question, HTM_ARTICLE_Begin (Anchor); /* Write stem */ - Tst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], + Qst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], true); // Visible /* Show media */ @@ -1228,10 +1228,10 @@ static void ExaSet_ListQuestionForEdition (struct Tst_Question *Question, "TEST_MED_EDIT_LIST"); /* Show feedback */ - Tst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); + Qst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); /* Show answers */ - Tst_WriteAnswersBank (Question, + Qst_WriteAnswersBank (Question, ClassTxt[Question->Validity], ClassFeedback[Question->Validity]); @@ -1333,7 +1333,7 @@ static void ExaSet_FreeListsSelectedQuestions (struct Exa_Exams *Exams) static void ExaSet_CopyQstFromBankToExamSet (const struct ExaSet_Set *Set,long QstCod) { extern const char *Txt_Question_removed; - struct Tst_Question Question; + struct Qst_Question Question; long CloneMedCod; long QstCodInSet; unsigned NumOpt; @@ -1341,11 +1341,11 @@ static void ExaSet_CopyQstFromBankToExamSet (const struct ExaSet_Set *Set,long Q MYSQL_ROW row; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = QstCod; /***** Get data of question from database *****/ - if (Tst_GetQstDataFromDB (&Question)) + if (Qst_GetQstDataFromDB (&Question)) { /***** Clone media *****/ CloneMedCod = Med_CloneMedia (&Question.Media); @@ -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 *****/ - Tst_GetAnswersQst (&Question,&mysql_res, + Qst_GetAnswersQst (&Question,&mysql_res, false); // Don't shuffle /* row[0] AnsInd @@ -1392,7 +1392,7 @@ static void ExaSet_CopyQstFromBankToExamSet (const struct ExaSet_Set *Set,long Q Ale_ShowAlert (Ale_WARNING,Txt_Question_removed); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /*****************************************************************************/ @@ -1691,15 +1691,15 @@ static void ExaSet_RemoveMediaFromAllAnsOfQst (long QstCod,long SetCod) void ExaSet_ValidateQst (void) { - ExaSet_ChangeValidityQst (Tst_VALID_QUESTION); + ExaSet_ChangeValidityQst (Qst_VALID_QUESTION); } void ExaSet_InvalidateQst (void) { - ExaSet_ChangeValidityQst (Tst_INVALID_QUESTION); + ExaSet_ChangeValidityQst (Qst_INVALID_QUESTION); } -static void ExaSet_ChangeValidityQst (Tst_Validity_t Validity) +static void ExaSet_ChangeValidityQst (Qst_Validity_t Validity) { struct Exa_Exams Exams; struct Exa_Exam Exam; diff --git a/swad_exam_set.h b/swad_exam_set.h index ad4d2dfc..67176652 100644 --- a/swad_exam_set.h +++ b/swad_exam_set.h @@ -58,8 +58,8 @@ void ExaSet_ListExamSets (struct Exa_Exams *Exams, void ExaSet_ResetSet (struct ExaSet_Set *Set); -Tst_AnswerType_t ExaSet_GetAnswerType (long QstCod); -void ExaSet_GetQstDataFromDB (struct Tst_Question *Question); +Qst_AnswerType_t ExaSet_GetAnswerType (long QstCod); +void ExaSet_GetQstDataFromDB (struct Qst_Question *Question); void ExaSet_AddQstsToSet (void); diff --git a/swad_figure.c b/swad_figure.c index b941aa38..44066dfa 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -1985,9 +1985,9 @@ static void Fig_GetAndShowTestsStats (void) extern const char *Txt_Average_BR_number_of_BR_times_that_BR_questions_BR_have_been_BR_responded_BR_per_course; extern const char *Txt_Average_BR_number_of_BR_times_that_BR_a_question_BR_has_been_BR_responded; extern const char *Txt_Average_BR_score_BR_per_question; - extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; + extern const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES]; extern const char *Txt_Total; - Tst_AnswerType_t AnsType; + Qst_AnswerType_t AnsType; struct Tst_Stats Stats; /***** Begin box and table *****/ @@ -2008,8 +2008,8 @@ static void Fig_GetAndShowTestsStats (void) HTM_TH (1,1,"RM",Txt_Average_BR_score_BR_per_question); HTM_TR_End (); - for (AnsType = (Tst_AnswerType_t) 0; - AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1); + for (AnsType = (Qst_AnswerType_t) 0; + AnsType <= (Qst_AnswerType_t) (Qst_NUM_ANS_TYPES - 1); AnsType++) { /***** Get the stats about test questions from this location *****/ @@ -2062,7 +2062,7 @@ static void Fig_GetAndShowTestsStats (void) } /***** Get the stats about test questions from this location *****/ - Tst_GetTestStats (Tst_ANS_UNKNOWN,&Stats); + Tst_GetTestStats (Qst_ANS_UNKNOWN,&Stats); /***** Write number of assignments *****/ HTM_TR_Begin (NULL); diff --git a/swad_game.c b/swad_game.c index af95dce3..19872d9f 100644 --- a/swad_game.c +++ b/swad_game.c @@ -1582,7 +1582,7 @@ void Gam_ReqSelectQstsToAddToGame (void) /***** Show form to create a new question in this game *****/ Games.GamCod = Game.GamCod; - Tst_RequestSelectTestsForGame (&Games); + Qst_RequestSelectQstsForGame (&Games); /***** Show current game *****/ Gam_ShowOnlyOneGame (&Games,&Game, @@ -1704,7 +1704,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, extern const char *Txt_Movement_not_allowed; unsigned NumQst; MYSQL_ROW row; - struct Tst_Question Question; + struct Qst_Question Question; unsigned QstInd; unsigned MaxQstInd; char StrQstInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; @@ -1739,7 +1739,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, Gbl.RowEvenOdd = NumQst % 2; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); /***** Get question data *****/ row = mysql_fetch_row (mysql_res); @@ -1803,13 +1803,13 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, /* Put icon to edit the question */ if (ICanEditQuestions) Ico_PutContextualIconToEdit (ActEdiOneTstQst,NULL, - Tst_PutParamQstCod,&Question.QstCod); + Qst_PutParamQstCod,&Question.QstCod); HTM_TD_End (); /***** Question *****/ - QuestionExists = Tst_GetQstDataFromDB (&Question); - Tst_ListQuestionForEdition (&Question,QstInd,QuestionExists,Anchor); + QuestionExists = Qst_GetQstDataFromDB (&Question); + Qst_ListQuestionForEdition (&Question,QstInd,QuestionExists,Anchor); /***** End row *****/ HTM_TR_End (); @@ -1818,7 +1818,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, Frm_FreeAnchorStr (Anchor); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /***** End table *****/ @@ -2277,7 +2277,7 @@ void Gam_ShowTstTagsPresentInAGame (long GamCod) /***** Get all tags of questions in this game *****/ NumTags = Gam_DB_GetTstTagsPresentInAGame (&mysql_res,GamCod); - Tst_ShowTagList (NumTags,mysql_res); + Tag_ShowTagList (NumTags,mysql_res); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); diff --git a/swad_match.c b/swad_match.c index 487c92d7..ec3c14f9 100644 --- a/swad_match.c +++ b/swad_match.c @@ -141,7 +141,7 @@ static void Mch_UpdateMatchTitleAndGrps (const struct Mch_Match *Match); static long Mch_CreateMatch (long GamCod,char Title[Mch_MAX_BYTES_TITLE + 1]); static void Mch_CreateIndexes (long GamCod,long MchCod); static void Mch_ReorderAnswer (long MchCod,unsigned QstInd, - const struct Tst_Question *Question); + const struct Qst_Question *Question); static void Mch_CreateGrps (long MchCod); static void Mch_UpdateMatchStatusInDB (const struct Mch_Match *Match); @@ -193,10 +193,10 @@ static void Mch_PutIfAnswered (const struct Mch_Match *Match,bool Answered); static void Mch_PutIconToRemoveMyAnswer (const struct Mch_Match *Match); static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match); static void Mch_WriteAnswersMatchResult (const struct Mch_Match *Match, - struct Tst_Question *Question, + struct Qst_Question *Question, const char *Class,bool ShowResult); static void Mch_WriteChoiceAnsViewMatch (const struct Mch_Match *Match, - struct Tst_Question *Question, + struct Qst_Question *Question, const char *Class,bool ShowResult); static void Mch_ShowQuestionAndAnswersStd (const struct Mch_Match *Match, const struct Mch_UsrAnswer *UsrAnswer, @@ -1560,7 +1560,7 @@ static void Mch_CreateIndexes (long GamCod,long MchCod) MYSQL_ROW row; unsigned NumQsts; unsigned NumQst; - struct Tst_Question Question; + struct Qst_Question Question; unsigned QstInd; /***** Get questions of the game *****/ @@ -1572,7 +1572,7 @@ static void Mch_CreateIndexes (long GamCod,long MchCod) NumQst++) { /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); /***** Get question data *****/ row = mysql_fetch_row (mysql_res); @@ -1591,8 +1591,8 @@ static void Mch_CreateIndexes (long GamCod,long MchCod) QstInd = Str_ConvertStrToUnsigned (row[1]); /* Get answer type (row[2]) */ - Question.Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[2]); - if (Question.Answer.Type != Tst_ANS_UNIQUE_CHOICE) + Question.Answer.Type = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[2]); + if (Question.Answer.Type != Qst_ANS_UNIQUE_CHOICE) Err_WrongAnswerExit (); /* Get shuffle (row[3]) */ @@ -1602,7 +1602,7 @@ static void Mch_CreateIndexes (long GamCod,long MchCod) Mch_ReorderAnswer (MchCod,QstInd,&Question); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /***** Free structure that stores the query result *****/ @@ -1614,7 +1614,7 @@ static void Mch_CreateIndexes (long GamCod,long MchCod) /*****************************************************************************/ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd, - const struct Tst_Question *Question) + const struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1622,13 +1622,13 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd, unsigned NumAns; unsigned AnsInd; char StrOneAnswer[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; - char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; + char StrAnswersOneQst[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; /***** Initialize list of answers to empty string *****/ StrAnswersOneQst[0] = '\0'; /***** Get suffled/not-shuffled answers indexes of question *****/ - NumAnss = Tst_DB_GetShuffledAnswersIndexes (&mysql_res,Question); + NumAnss = Qst_DB_GetShuffledAnswersIndexes (&mysql_res,Question); /***** For each answer in question... *****/ for (NumAns = 0; @@ -1659,9 +1659,9 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd, /*****************************************************************************/ void Mch_GetIndexes (long MchCod,unsigned QstInd, - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]) + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]) { - char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES_ONE_QST + 1]; + char StrIndexesOneQst[Qst_MAX_BYTES_INDEXES_ONE_QST + 1]; /***** Get indexes for a question from database *****/ Mch_DB_GetIndexes (MchCod,QstInd,StrIndexesOneQst); @@ -2829,10 +2829,10 @@ static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match) { extern const char *Txt_MATCH_Paused; extern const char *Txt_Question_removed; - struct Tst_Question Question; + struct Qst_Question Question; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Match->Status.QstCod; /***** Trivial check: do not show anything on match start and end *****/ @@ -2846,18 +2846,18 @@ static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match) } /***** Get data of question from database *****/ - if (Tst_GetQstDataFromDB (&Question)) + if (Qst_GetQstDataFromDB (&Question)) { /***** Show question *****/ /* Check answer type */ - if (Question.Answer.Type != Tst_ANS_UNIQUE_CHOICE) + if (Question.Answer.Type != Qst_ANS_UNIQUE_CHOICE) Err_WrongAnswerExit (); /* Begin container */ HTM_DIV_Begin ("class=\"MCH_BOTTOM\""); // Bottom /* Write stem */ - Tst_WriteQstStem (Question.Stem,"MCH_TCH_STEM", + Qst_WriteQstStem (Question.Stem,"MCH_TCH_STEM", true); // Visible /* Show media */ @@ -2897,7 +2897,7 @@ static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match) Ale_ShowAlert (Ale_WARNING,Txt_Question_removed); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /*****************************************************************************/ @@ -2905,11 +2905,11 @@ static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match) /*****************************************************************************/ static void Mch_WriteAnswersMatchResult (const struct Mch_Match *Match, - struct Tst_Question *Question, + struct Qst_Question *Question, const char *Class,bool ShowResult) { /***** Write answer depending on type *****/ - if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE) + if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE) Mch_WriteChoiceAnsViewMatch (Match, Question, Class,ShowResult); @@ -2922,20 +2922,20 @@ static void Mch_WriteAnswersMatchResult (const struct Mch_Match *Match, /*****************************************************************************/ static void Mch_WriteChoiceAnsViewMatch (const struct Mch_Match *Match, - struct Tst_Question *Question, + struct Qst_Question *Question, const char *Class,bool ShowResult) { unsigned NumOpt; bool RowIsOpen = false; unsigned NumRespondersQst; unsigned NumRespondersAns; - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question /***** Get number of users who have answered this question from database *****/ NumRespondersQst = Mch_DB_GetNumUsrsWhoAnsweredQst (Match->MchCod,Match->Status.QstInd); /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Get indexes for this question in match *****/ Mch_GetIndexes (Match->MchCod,Match->Status.QstInd,Indexes); @@ -3018,7 +3018,7 @@ static void Mch_ShowQuestionAndAnswersStd (const struct Mch_Match *Match, char *Class; /***** Get number of options in this question *****/ - NumOptions = Tst_GetNumAnswersQst (Match->Status.QstCod); + NumOptions = Qst_GetNumAnswersQst (Match->Status.QstCod); /***** Begin table *****/ HTM_TABLE_BeginWidePadding (8); @@ -3658,7 +3658,7 @@ void Mch_ReceiveQuestionAnswer (void) void Mch_StoreQuestionAnswer (const struct Mch_Match *Match,unsigned QstInd, struct Mch_UsrAnswer *UsrAnswer) { - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]; + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]; struct Mch_UsrAnswer PreviousUsrAnswer; /***** Check that teacher's screen is showing answers @@ -3763,16 +3763,16 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print) void Mch_ComputeScore (struct MchPrn_Print *Print) { unsigned NumQst; - struct Tst_Question Question; + struct Qst_Question Question; for (NumQst = 0, Print->Score = 0.0; NumQst < Print->NumQsts.All; NumQst++) { /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[NumQst].QstCod; - Question.Answer.Type = Tst_ANS_UNIQUE_CHOICE; + Question.Answer.Type = Qst_ANS_UNIQUE_CHOICE; /***** Compute score for this answer ******/ TstPrn_ComputeAnswerScore (&Print->PrintedQuestions[NumQst],&Question); @@ -3781,7 +3781,7 @@ void Mch_ComputeScore (struct MchPrn_Print *Print) Print->Score += Print->PrintedQuestions[NumQst].Score; /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } } diff --git a/swad_match.h b/swad_match.h index a9991b65..c909627c 100644 --- a/swad_match.h +++ b/swad_match.h @@ -121,7 +121,7 @@ void Mch_CreateNewMatch (void); void Mch_ChangeMatch (void); void Mch_ResumeMatch (void); void Mch_GetIndexes (long MchCod,unsigned QstInd, - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]); + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]); void Mch_PlayPauseMatch (void); void Mch_ChangeNumColsMch (void); diff --git a/swad_match_database.c b/swad_match_database.c index a9906f5e..3b80edae 100644 --- a/swad_match_database.c +++ b/swad_match_database.c @@ -691,7 +691,7 @@ void Mch_DB_RemUsrAnswersOfAQuestion (long GamCod,unsigned QstInd) /*****************************************************************************/ void Mch_DB_CreateQstIndexes (long MchCod,unsigned QstInd, - const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]) + const char StrAnswersOneQst[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]) { DB_QueryINSERT ("can not create indexes of a question", "INSERT INTO mch_indexes" @@ -708,9 +708,9 @@ void Mch_DB_CreateQstIndexes (long MchCod,unsigned QstInd, /*****************************************************************************/ void Mch_DB_GetIndexes (long MchCod,unsigned QstInd, - char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES_ONE_QST + 1]) + char StrIndexesOneQst[Qst_MAX_BYTES_INDEXES_ONE_QST + 1]) { - DB_QuerySELECTString (StrIndexesOneQst,Tst_MAX_BYTES_INDEXES_ONE_QST, + DB_QuerySELECTString (StrIndexesOneQst,Qst_MAX_BYTES_INDEXES_ONE_QST, "can not get indexes of a question", "SELECT Indexes" // row[0] " FROM mch_indexes" diff --git a/swad_match_database.h b/swad_match_database.h index 161254a3..54c7bd8e 100644 --- a/swad_match_database.h +++ b/swad_match_database.h @@ -87,9 +87,9 @@ void Mch_DB_RemUsrAnswersOfAQuestion (long GamCod,unsigned QstInd); //----------------------------- Answers indexes ------------------------------- void Mch_DB_CreateQstIndexes (long MchCod,unsigned QstInd, - const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]); + const char StrAnswersOneQst[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]); void Mch_DB_GetIndexes (long MchCod,unsigned QstInd, - char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES_ONE_QST + 1]); + char StrIndexesOneQst[Qst_MAX_BYTES_INDEXES_ONE_QST + 1]); //-------------------------- Matches being played ----------------------------- void Mch_DB_UpdateMatchAsBeingPlayed (long MchCod); diff --git a/swad_tag.c b/swad_tag.c index df2b4109..fba3effe 100644 --- a/swad_tag.c +++ b/swad_tag.c @@ -489,3 +489,70 @@ static void Tag_PutIconDisable (long TagCod,const char *TagTxt) Frm_EndForm (); HTM_TD_End (); } + +/*****************************************************************************/ +/******************** Get and write tags of a test question ******************/ +/*****************************************************************************/ + +void Tag_GetAndWriteTagsQst (long QstCod) + { + extern const char *Txt_no_tags; + unsigned NumTags; + unsigned NumTag; + MYSQL_RES *mysql_res; + MYSQL_ROW row; + + if ((NumTags = Tag_DB_GetTagsQst (&mysql_res,QstCod))) + { + /***** Write the tags *****/ + HTM_UL_Begin ("class=\"TEST_TAG_LIST DAT_SMALL\""); + for (NumTag = 0; + NumTag < NumTags; + NumTag++) + { + row = mysql_fetch_row (mysql_res); + HTM_LI_Begin (NULL); + HTM_Txt (row[0]); + HTM_LI_End (); + } + HTM_UL_End (); + } + else + { + HTM_SPAN_Begin ("class=\"DAT_SMALL\""); + HTM_TxtF ("(%s)",Txt_no_tags); + HTM_SPAN_End (); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + +/*****************************************************************************/ +/************************ Show list of question tags *************************/ +/*****************************************************************************/ + +void Tag_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res) + { + extern const char *Txt_no_tags; + MYSQL_ROW row; + unsigned NumTag; + + if (NumTags) + { + /***** Write the tags *****/ + HTM_UL_Begin (NULL); + for (NumTag = 0; + NumTag < NumTags; + NumTag++) + { + row = mysql_fetch_row (mysql_res); + HTM_LI_Begin (NULL); + HTM_Txt (row[0]); + HTM_LI_End (); + } + HTM_UL_End (); + } + else + HTM_Txt (Txt_no_tags); + } diff --git a/swad_tag.h b/swad_tag.h index a5e926d5..daa11b4e 100644 --- a/swad_tag.h +++ b/swad_tag.h @@ -72,4 +72,7 @@ void Tag_ShowFormSelTags (const struct Tag_Tags *Tags, bool ShowOnlyEnabledTags); void Tag_ShowFormEditTags (void); +void Tag_GetAndWriteTagsQst (long QstCod); +void Tag_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res); + #endif diff --git a/swad_tag_database.c b/swad_tag_database.c index 1b68637b..ae8b24f9 100644 --- a/swad_tag_database.c +++ b/swad_tag_database.c @@ -192,6 +192,25 @@ void Tag_DB_EnableOrDisableTag (long TagCod,bool TagHidden) Gbl.Hierarchy.Crs.CrsCod); } +/*****************************************************************************/ +/************************* Get tags of a test question ***********************/ +/*****************************************************************************/ + +unsigned Tag_DB_GetTagsQst (MYSQL_RES **mysql_res,long QstCod) + { + return (unsigned) + DB_QuerySELECT (mysql_res,"can not get the tags of a question", + "SELECT tst_tags.TagTxt" // row[0] + " FROM tst_question_tags," + "tst_tags" + " WHERE tst_question_tags.QstCod=%ld" + " AND tst_question_tags.TagCod=tst_tags.TagCod" + " AND tst_tags.CrsCod=%ld" + " ORDER BY tst_question_tags.TagInd", + QstCod, + Gbl.Hierarchy.Crs.CrsCod); + } + /*****************************************************************************/ /********* Get all (enabled or disabled) test tags for this course ***********/ /*****************************************************************************/ diff --git a/swad_tag_database.h b/swad_tag_database.h index e1018f6e..1bb2bcb2 100644 --- a/swad_tag_database.h +++ b/swad_tag_database.h @@ -29,7 +29,8 @@ #include // To access MySQL databases #include // For boolean type -// #include "swad_string.h" + +#include "swad_tag.h" /*****************************************************************************/ /***************************** Public constants ******************************/ @@ -52,6 +53,7 @@ void Tag_DB_SimplexRenameTag (const char OldTagTxt[Tag_MAX_BYTES_TAG + 1], const char NewTagTxt[Tag_MAX_BYTES_TAG + 1]); void Tag_DB_EnableOrDisableTag (long TagCod,bool TagHidden); +unsigned Tag_DB_GetTagsQst (MYSQL_RES **mysql_res,long QstCod); unsigned Tag_DB_GetAllTagsFromCurrentCrs (MYSQL_RES **mysql_res); unsigned Tag_DB_GetEnabledTagsFromThisCrs (MYSQL_RES **mysql_res); bool Tag_DB_CheckIfCurrentCrsHasTestTags (void); diff --git a/swad_test.c b/swad_test.c index fd708636..dc67d64a 100644 --- a/swad_test.c +++ b/swad_test.c @@ -67,24 +67,24 @@ /*****************************************************************************/ // strings are limited to Tst_MAX_BYTES_ANSWER_TYPE characters -const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES] = +const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES] = { - [Tst_ANS_INT ] = "int", - [Tst_ANS_FLOAT ] = "float", - [Tst_ANS_TRUE_FALSE ] = "TF", - [Tst_ANS_UNIQUE_CHOICE ] = "uniqueChoice", - [Tst_ANS_MULTIPLE_CHOICE] = "multipleChoice", - [Tst_ANS_TEXT ] = "text", + [Qst_ANS_INT ] = "int", + [Qst_ANS_FLOAT ] = "float", + [Qst_ANS_TRUE_FALSE ] = "TF", + [Qst_ANS_UNIQUE_CHOICE ] = "uniqueChoice", + [Qst_ANS_MULTIPLE_CHOICE] = "multipleChoice", + [Qst_ANS_TEXT ] = "text", }; -const char *Tst_StrAnswerTypesDB[Tst_NUM_ANS_TYPES] = +const char *Tst_StrAnswerTypesDB[Qst_NUM_ANS_TYPES] = { - [Tst_ANS_INT ] = "int", - [Tst_ANS_FLOAT ] = "float", - [Tst_ANS_TRUE_FALSE ] = "true_false", - [Tst_ANS_UNIQUE_CHOICE ] = "unique_choice", - [Tst_ANS_MULTIPLE_CHOICE] = "multiple_choice", - [Tst_ANS_TEXT ] = "text", + [Qst_ANS_INT ] = "int", + [Qst_ANS_FLOAT ] = "float", + [Qst_ANS_TRUE_FALSE ] = "true_false", + [Qst_ANS_UNIQUE_CHOICE ] = "unique_choice", + [Qst_ANS_MULTIPLE_CHOICE] = "multiple_choice", + [Qst_ANS_TEXT ] = "text", }; /*****************************************************************************/ @@ -132,14 +132,14 @@ static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedi static void Tst_IncreaseMyNumAccessTst (void); static void Tst_UpdateLastAccTst (unsigned NumQsts); -static void Tst_ShowFormRequestEditTests (struct Tst_Test *Test); +static void Qst_ShowFormRequestEditQsts (struct Tst_Test *Test); static void Tst_ShowFormRequestSelectTestsForSet (struct Exa_Exams *Exams, struct Tst_Test *Test); static void Tst_ShowFormRequestSelectTestsForGame (struct Gam_Games *Games, struct Tst_Test *Test); -static bool Tst_CheckIfICanEditTests (void); -static void Tst_PutIconsRequestBankQsts (__attribute__((unused)) void *Args); -static void Tst_PutIconsEditBankQsts (void *Test); +static bool Qst_CheckIfICanEditQsts (void); +static void Qst_PutIconsRequestBankQsts (__attribute__((unused)) void *Args); +static void Qst_PutIconsEditBankQsts (void *Test); static void Tst_PutIconsTests (__attribute__((unused)) void *Args); static void Tst_PutButtonToAddQuestion (void); @@ -149,7 +149,7 @@ static void Tst_PutInputFieldNumQst (const char *Field,const char *Label, unsigned Value); static void Tst_ShowFormAnswerTypes (const struct Tst_AnswerTypes *AnswerTypes); -static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res); +static void Qst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res); static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test, struct TstPrn_Print *Print); @@ -166,20 +166,20 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam MYSQL_RES *mysql_res); static void Tst_PutCheckboxToSelectAllQuestions (void); static void Tst_WriteQuestionRowForSelection (unsigned QstInd, - struct Tst_Question *Question); + struct Qst_Question *Question); //----------------------------------------------------------------------------- -static void Tst_WriteIntAnsBank (struct Tst_Question *Question, +static void Tst_WriteIntAnsBank (struct Qst_Question *Question, const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback); -static void Tst_WriteFltAnsBank (struct Tst_Question *Question, +static void Tst_WriteFltAnsBank (struct Qst_Question *Question, const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback); -static void Tst_WriteTF_AnsBank (struct Tst_Question *Question, +static void Tst_WriteTF_AnsBank (struct Qst_Question *Question, const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback); -static void Tst_WriteChoAnsBank (struct Tst_Question *Question, +static void Tst_WriteChoAnsBank (struct Qst_Question *Question, const char *ClassTxt, const char *ClassFeedback); @@ -192,45 +192,45 @@ static unsigned Tst_GetParamNumQsts (void); static unsigned Tst_CountNumTagsInList (const struct Tag_Tags *Tags); static int Tst_CountNumAnswerTypesInList (const struct Tst_AnswerTypes *AnswerTypes); -static void Tst_PutFormEditOneQst (struct Tst_Question *Question); -static void Tst_PutFloatInputField (const char *Label,const char *Field, - const struct Tst_Question *Question, +static void Qst_PutFormEditOneQst (struct Qst_Question *Question); +static void Qst_PutFloatInputField (const char *Label,const char *Field, + const struct Qst_Question *Question, unsigned Index); -static void Tst_PutTFInputField (const struct Tst_Question *Question, +static void Qst_PutTFInputField (const struct Qst_Question *Question, const char *Label,char Value); -static void Tst_FreeTextChoiceAnswers (struct Tst_Question *Question); -static void Tst_FreeTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt); +static void Qst_FreeTextChoiceAnswers (struct Qst_Question *Question); +static void Qst_FreeTextChoiceAnswer (struct Qst_Question *Question,unsigned NumOpt); -static void Tst_ResetMediaOfQuestion (struct Tst_Question *Question); -static void Tst_FreeMediaOfQuestion (struct Tst_Question *Question); +static void Qst_ResetMediaOfQuestion (struct Qst_Question *Question); +static void Qst_FreeMediaOfQuestion (struct Qst_Question *Question); -static long Tst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt); +static long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt); static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt, struct Med_Media *Media); -static Tst_AnswerType_t Tst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr); -static void Tst_GetQstFromForm (struct Tst_Question *Question); -static void Tst_MoveMediaToDefinitiveDirectories (struct Tst_Question *Question); +static Qst_AnswerType_t Qst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr); +static void Qst_GetQstFromForm (struct Qst_Question *Question); +static void Qst_MoveMediaToDefinitiveDirectories (struct Qst_Question *Question); -static void Tst_PutIconToRemoveOneQst (void *QstCod); -static void Tst_PutParamsRemoveOnlyThisQst (void *QstCod); -static void Tst_RemoveOneQstFromDB (long CrsCod,long QstCod); +static void Qst_PutIconToRemoveOneQst (void *QstCod); +static void Qst_PutParamsRemoveOnlyThisQst (void *QstCod); +static void Qst_RemoveOneQstFromDB (long CrsCod,long QstCod); -static void Tst_InsertOrUpdateQstIntoDB (struct Tst_Question *Question); -static void Tst_InsertAnswersIntoDB (struct Tst_Question *Question); +static void Qst_InsertOrUpdateQstIntoDB (struct Qst_Question *Question); +static void Qst_InsertAnswersIntoDB (struct Qst_Question *Question); -static void Tst_RemAnsFromQst (long QstCod); +static void Qst_RemAnsFromQst (long QstCod); -static void Tst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod); -static void Tst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod); +static void Qst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod); +static void Qst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod); -static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod); -static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod); +static void Qst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod); +static void Qst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod); -static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t AnsType,struct Tst_Stats *Stats); -static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t AnsType); -static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t AnsType); +static unsigned Qst_GetNumQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType,struct Tst_Stats *Stats); +static unsigned Qst_GetNumCoursesWithQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType); +static unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType); /*****************************************************************************/ /********************* Request a self-assessment test ************************/ @@ -267,7 +267,7 @@ static void Tst_TstConstructor (struct Tst_Test *Test) Test->SelectedOrder = Tst_DEFAULT_ORDER; /***** Question constructor *****/ - Tst_QstConstructor (&Test->Question); + Qst_QstConstructor (&Test->Question); } /*****************************************************************************/ @@ -277,7 +277,7 @@ static void Tst_TstConstructor (struct Tst_Test *Test) static void Tst_TstDestructor (struct Tst_Test *Test) { /***** Question destructor *****/ - Tst_QstDestructor (&Test->Question); + Qst_QstDestructor (&Test->Question); /***** Free tag list *****/ Tag_FreeTagsList (&Test->Tags); @@ -304,57 +304,57 @@ static void Tst_ShowFormRequestTest (struct Tst_Test *Test) Tst_PutIconsTests,NULL, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - /***** Get tags *****/ - if ((Test->Tags.Num = Tag_DB_GetEnabledTagsFromThisCrs (&mysql_res)) != 0) - { - /***** Check if minimum date-time of next access to test is older than now *****/ - if (Tst_CheckIfNextTstAllowed ()) - { - Frm_BeginForm (ActSeeTst); + /***** Get tags *****/ + if ((Test->Tags.Num = Tag_DB_GetEnabledTagsFromThisCrs (&mysql_res)) != 0) + { + /***** Check if minimum date-time of next access to test is older than now *****/ + if (Tst_CheckIfNextTstAllowed ()) + { + Frm_BeginForm (ActSeeTst); - HTM_TABLE_BeginPadding (2); + HTM_TABLE_BeginPadding (2); - /***** Selection of tags *****/ - Tag_ShowFormSelTags (&Test->Tags,mysql_res,true); + /***** Selection of tags *****/ + Tag_ShowFormSelTags (&Test->Tags,mysql_res,true); - /***** Selection of types of answers *****/ - Tst_ShowFormAnswerTypes (&Test->AnswerTypes); + /***** Selection of types of answers *****/ + Tst_ShowFormAnswerTypes (&Test->AnswerTypes); - /***** Number of questions to generate ****/ - HTM_TR_Begin (NULL); + /***** Number of questions to generate ****/ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","NumQst",Txt_Number_of_questions); + /* Label */ + Frm_LabelColumn ("RT","NumQst",Txt_Number_of_questions); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_INPUT_LONG ("NumQst", - (long) TstCfg_GetConfigMin (), - (long) TstCfg_GetConfigMax (), - (long) TstCfg_GetConfigDef (), - HTM_DONT_SUBMIT_ON_CHANGE, - TstCfg_GetConfigMin () == TstCfg_GetConfigMax (), - "id=\"NumQst\""); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_INPUT_LONG ("NumQst", + (long) TstCfg_GetConfigMin (), + (long) TstCfg_GetConfigMax (), + (long) TstCfg_GetConfigDef (), + HTM_DONT_SUBMIT_ON_CHANGE, + TstCfg_GetConfigMin () == TstCfg_GetConfigMax (), + "id=\"NumQst\""); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - HTM_TABLE_End (); + HTM_TABLE_End (); - /***** Send button *****/ - Btn_PutConfirmButton (Txt_Generate_test); - Frm_EndForm (); - } - } - else - { - /***** Warning message *****/ - Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); + /***** Send button *****/ + Btn_PutConfirmButton (Txt_Generate_test); + Frm_EndForm (); + } + } + else + { + /***** Warning message *****/ + Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); - /***** Button to create a new question *****/ - if (Tst_CheckIfICanEditTests ()) - Tst_PutButtonToAddQuestion (); - } + /***** Button to create a new question *****/ + if (Qst_CheckIfICanEditQsts ()) + Tst_PutButtonToAddQuestion (); + } /***** End box *****/ Box_BoxEnd (); @@ -527,33 +527,33 @@ void Tst_AssessTest (void) Box_BoxBegin (NULL,Txt_Result, NULL,NULL, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (false,false, - Gbl.Hierarchy.Ins.InsCod, - Gbl.Hierarchy.Deg.DegCod, - Gbl.Hierarchy.Crs.CrsCod); + Lay_WriteHeaderClassPhoto (false,false, + Gbl.Hierarchy.Ins.InsCod, + Gbl.Hierarchy.Deg.DegCod, + Gbl.Hierarchy.Crs.CrsCod); - /***** Header *****/ - if (Gbl.Usrs.Me.IBelongToCurrentCrs) - { - HTM_DIV_Begin ("class=\"TEST_SUBTITLE\""); - HTM_TxtF (Txt_Test_No_X_that_you_make_in_this_course,NumTst); - HTM_DIV_End (); - } + /***** Header *****/ + if (Gbl.Usrs.Me.IBelongToCurrentCrs) + { + HTM_DIV_Begin ("class=\"TEST_SUBTITLE\""); + HTM_TxtF (Txt_Test_No_X_that_you_make_in_this_course,NumTst); + HTM_DIV_End (); + } - /***** Write answers and solutions *****/ - TstPrn_ShowPrintAfterAssess (&Print); + /***** Write answers and solutions *****/ + TstPrn_ShowPrintAfterAssess (&Print); - /***** Write total score and grade *****/ - if (TstVis_IsVisibleTotalScore (TstCfg_GetConfigVisibility ())) - { - HTM_DIV_Begin ("class=\"DAT_N_BOLD CM\""); - HTM_TxtColonNBSP (Txt_Score); - HTM_Double2Decimals (Print.Score); - HTM_BR (); - HTM_TxtColonNBSP (Txt_Grade); - TstPrn_ComputeAndShowGrade (Print.NumQsts.All,Print.Score,Tst_SCORE_MAX); - HTM_DIV_End (); - } + /***** Write total score and grade *****/ + if (TstVis_IsVisibleTotalScore (TstCfg_GetConfigVisibility ())) + { + HTM_DIV_Begin ("class=\"DAT_N_BOLD CM\""); + HTM_TxtColonNBSP (Txt_Score); + HTM_Double2Decimals (Print.Score); + HTM_BR (); + HTM_TxtColonNBSP (Txt_Grade); + TstPrn_ComputeAndShowGrade (Print.NumQsts.All,Print.Score,Tst_SCORE_MAX); + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); @@ -577,7 +577,7 @@ static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print) /* Get answers selected by user for this question */ snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd); Par_GetParMultiToText (StrAns,Print->PrintedQuestions[QstInd].StrAnswers, - Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */ + Qst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */ Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[QstInd].StrAnswers); } } @@ -689,40 +689,11 @@ static unsigned Tst_GetNumExamsGeneratedByMe (void) return NumExamsGeneratedByMe; } -/*****************************************************************************/ -/************************** Show list of test tags ***************************/ -/*****************************************************************************/ - -void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res) - { - extern const char *Txt_no_tags; - MYSQL_ROW row; - unsigned NumTag; - - if (NumTags) - { - /***** Write the tags *****/ - HTM_UL_Begin (NULL); - for (NumTag = 0; - NumTag < NumTags; - NumTag++) - { - row = mysql_fetch_row (mysql_res); - HTM_LI_Begin (NULL); - HTM_Txt (row[0]); - HTM_LI_End (); - } - HTM_UL_End (); - } - else - HTM_Txt (Txt_no_tags); - } - /*****************************************************************************/ /********************* List game question for edition ************************/ /*****************************************************************************/ -void Tst_ListQuestionForEdition (struct Tst_Question *Question, +void Qst_ListQuestionForEdition (struct Qst_Question *Question, unsigned QstInd,bool QuestionExists, const char *Anchor) { @@ -730,9 +701,9 @@ void Tst_ListQuestionForEdition (struct Tst_Question *Question, /***** Number of question and answer type (row[1]) *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd,"BIG_INDEX"); + Qst_WriteNumQst (QstInd,"BIG_INDEX"); if (QuestionExists) - Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); + Qst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); HTM_TD_End (); /***** Write question code *****/ @@ -743,7 +714,7 @@ void Tst_ListQuestionForEdition (struct Tst_Question *Question, /***** Write the question tags *****/ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); if (QuestionExists) - Tst_GetAndWriteTagsQst (Question->QstCod); + Tag_GetAndWriteTagsQst (Question->QstCod); HTM_TD_End (); /***** Write stem (row[3]) and media *****/ @@ -752,7 +723,7 @@ void Tst_ListQuestionForEdition (struct Tst_Question *Question, if (QuestionExists) { /* Write stem */ - Tst_WriteQstStem (Question->Stem,"TEST_TXT", + Qst_WriteQstStem (Question->Stem,"TEST_TXT", true); // Visible /* Show media */ @@ -761,10 +732,10 @@ void Tst_ListQuestionForEdition (struct Tst_Question *Question, "TEST_MED_EDIT_LIST"); /* Show feedback */ - Tst_WriteQstFeedback (Question->Feedback,"TEST_TXT_LIGHT"); + Qst_WriteQstFeedback (Question->Feedback,"TEST_TXT_LIGHT"); /* Show answers */ - Tst_WriteAnswersBank (Question,"TEST_TXT","TEST_TXT_LIGHT"); + Qst_WriteAnswersBank (Question,"TEST_TXT","TEST_TXT_LIGHT"); } else { @@ -781,10 +752,10 @@ void Tst_ListQuestionForEdition (struct Tst_Question *Question, /*****************************************************************************/ // Number of question should be 1, 2, 3... -void Tst_WriteNumQst (unsigned NumQst,const char *Class) +void Qst_WriteNumQst (unsigned NumQst,const char *Class) { HTM_DIV_Begin ("class=\"%s\"",Class); - HTM_Unsigned (NumQst); + HTM_Unsigned (NumQst); HTM_DIV_End (); } @@ -792,12 +763,12 @@ void Tst_WriteNumQst (unsigned NumQst,const char *Class) /************************** Write the type of answer *************************/ /*****************************************************************************/ -void Tst_WriteAnswerType (Tst_AnswerType_t AnswerType,const char *Class) +void Qst_WriteAnswerType (Qst_AnswerType_t AnswerType,const char *Class) { - extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; + extern const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES]; HTM_DIV_Begin ("class=\"%s\"",Class); - HTM_Txt (Txt_TST_STR_ANSWER_TYPES[AnswerType]); + HTM_Txt (Txt_TST_STR_ANSWER_TYPES[AnswerType]); HTM_DIV_End (); } @@ -805,7 +776,7 @@ void Tst_WriteAnswerType (Tst_AnswerType_t AnswerType,const char *Class) /********************* Write the stem of a test question *********************/ /*****************************************************************************/ -void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible) +void Qst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible) { unsigned long StemLength; char *StemRigorousHTML; @@ -813,29 +784,29 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible) /***** DIV begin *****/ HTM_DIV_Begin ("class=\"%s\"",ClassStem); - /***** Write stem *****/ - if (Stem && Visible) - { - if (Stem[0]) + /***** Write stem *****/ + if (Stem && Visible) { - /* Convert the stem, that is in HTML, to rigorous HTML */ - StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR; - if ((StemRigorousHTML = malloc (StemLength + 1)) == NULL) - Err_NotEnoughMemoryExit (); - Str_Copy (StemRigorousHTML,Stem,StemLength); + if (Stem[0]) + { + /* Convert the stem, that is in HTML, to rigorous HTML */ + StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR; + if ((StemRigorousHTML = malloc (StemLength + 1)) == NULL) + Err_NotEnoughMemoryExit (); + Str_Copy (StemRigorousHTML,Stem,StemLength); - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - StemRigorousHTML,StemLength,false); + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + StemRigorousHTML,StemLength,false); - /* Write stem text */ - HTM_Txt (StemRigorousHTML); + /* Write stem text */ + HTM_Txt (StemRigorousHTML); - /* Free memory allocated for the stem */ - free (StemRigorousHTML); + /* Free memory allocated for the stem */ + free (StemRigorousHTML); + } } - } - else - Ico_PutIconNotVisible (); + else + Ico_PutIconNotVisible (); /***** DIV end *****/ HTM_DIV_End (); @@ -863,39 +834,39 @@ static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedi /***** Begin container *****/ HTM_DIV_Begin ("class=\"TEST_MED_EDIT_FORM\""); - /***** Choice 1: No media *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_RADIO (ParamUploadMedia.Action,false, - "value=\"%u\"%s", - (unsigned) Med_ACTION_NO_MEDIA, - OptionsDisabled ? " disabled=\"disabled\"" : ""); - HTM_Txt (Txt_No_image_video); - HTM_LABEL_End (); - HTM_BR (); + /***** Choice 1: No media *****/ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_INPUT_RADIO (ParamUploadMedia.Action,false, + "value=\"%u\"%s", + (unsigned) Med_ACTION_NO_MEDIA, + OptionsDisabled ? " disabled=\"disabled\"" : ""); + HTM_Txt (Txt_No_image_video); + HTM_LABEL_End (); + HTM_BR (); - /***** Choice 2: Current media *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_RADIO (ParamUploadMedia.Action,false, - "value=\"%u\"%s checked=\"checked\"", - (unsigned) Med_ACTION_KEEP_MEDIA, - OptionsDisabled ? " disabled=\"disabled\"" : ""); - HTM_Txt (Txt_Current_image_video); - HTM_LABEL_End (); - Med_ShowMedia (Media, - "TEST_MED_EDIT_ONE_CONT", - "TEST_MED_EDIT_ONE"); + /***** Choice 2: Current media *****/ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_INPUT_RADIO (ParamUploadMedia.Action,false, + "value=\"%u\"%s checked=\"checked\"", + (unsigned) Med_ACTION_KEEP_MEDIA, + OptionsDisabled ? " disabled=\"disabled\"" : ""); + HTM_Txt (Txt_Current_image_video); + HTM_LABEL_End (); + Med_ShowMedia (Media, + "TEST_MED_EDIT_ONE_CONT", + "TEST_MED_EDIT_ONE"); - /***** Choice 3: Change media *****/ - UniqueId++; - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_RADIO (ParamUploadMedia.Action,false, - "id=\"chg_img_%u\" value=\"%u\"%s", - UniqueId, - (unsigned) Med_ACTION_NEW_MEDIA, - OptionsDisabled ? " disabled=\"disabled\"" : ""); - HTM_TxtColonNBSP (Txt_Change_image_video); - HTM_LABEL_End (); - Med_PutMediaUploader (NumMedia,"TEST_MED_INPUT"); + /***** Choice 3: Change media *****/ + UniqueId++; + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_INPUT_RADIO (ParamUploadMedia.Action,false, + "id=\"chg_img_%u\" value=\"%u\"%s", + UniqueId, + (unsigned) Med_ACTION_NEW_MEDIA, + OptionsDisabled ? " disabled=\"disabled\"" : ""); + HTM_TxtColonNBSP (Txt_Change_image_video); + HTM_LABEL_End (); + Med_PutMediaUploader (NumMedia,"TEST_MED_INPUT"); /***** End container *****/ HTM_DIV_End (); @@ -909,7 +880,7 @@ static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedi /******************* Write the feedback of a test question *******************/ /*****************************************************************************/ -void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback) +void Qst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback) { unsigned long FeedbackLength; char *FeedbackRigorousHTML; @@ -927,7 +898,7 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback) /***** Write the feedback *****/ HTM_DIV_Begin ("class=\"%s\"",ClassFeedback); - HTM_Txt (FeedbackRigorousHTML); + HTM_Txt (FeedbackRigorousHTML); HTM_DIV_End (); /***** Free memory allocated for the feedback *****/ @@ -977,7 +948,7 @@ static void Tst_UpdateLastAccTst (unsigned NumQsts) /*********************** Request the edition of tests ************************/ /*****************************************************************************/ -void Tst_RequestEditTests (void) +void Qst_RequestEditQsts (void) { struct Tst_Test Test; @@ -985,7 +956,7 @@ void Tst_RequestEditTests (void) Tst_TstConstructor (&Test); /***** Show form to generate a self-assessment test *****/ - Tst_ShowFormRequestEditTests (&Test); + Qst_ShowFormRequestEditQsts (&Test); /***** Destroy test *****/ Tst_TstDestructor (&Test); @@ -995,7 +966,7 @@ void Tst_RequestEditTests (void) /******* Select tags and dates for edition of the self-assessment test *******/ /*****************************************************************************/ -static void Tst_ShowFormRequestEditTests (struct Tst_Test *Test) +static void Qst_ShowFormRequestEditQsts (struct Tst_Test *Test) { extern const char *Hlp_ASSESSMENT_Questions_editing_questions; extern const char *Txt_No_test_questions; @@ -1010,40 +981,41 @@ static void Tst_ShowFormRequestEditTests (struct Tst_Test *Test) /***** Begin box *****/ Box_BoxBegin (NULL,Txt_Question_bank, - Tst_PutIconsRequestBankQsts,NULL, + Qst_PutIconsRequestBankQsts,NULL, Hlp_ASSESSMENT_Questions_editing_questions,Box_NOT_CLOSABLE); - /***** Get tags already present in the table of questions *****/ - if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res))) - { - Frm_BeginForm (ActLstTstQst); - Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Tst_DEFAULT_ORDER); + /***** Get tags already present in the table of questions *****/ + if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res))) + { + Frm_BeginForm (ActLstTstQst); + Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Tst_DEFAULT_ORDER); - HTM_TABLE_BeginPadding (2); + HTM_TABLE_BeginPadding (2); - /***** Selection of tags *****/ - Tag_ShowFormSelTags (&Test->Tags,mysql_res,false); + /***** Selection of tags *****/ + Tag_ShowFormSelTags (&Test->Tags,mysql_res,false); - /***** Selection of types of answers *****/ - Tst_ShowFormAnswerTypes (&Test->AnswerTypes); + /***** Selection of types of answers *****/ + Tst_ShowFormAnswerTypes (&Test->AnswerTypes); - /***** Starting and ending dates in the search *****/ - Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); + /***** Starting and ending dates in the search *****/ + Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); - HTM_TABLE_End (); + HTM_TABLE_End (); - /***** Send button *****/ - Btn_PutConfirmButton (Txt_Show_questions); - Frm_EndForm (); - } - else // No test questions - { - /***** Warning message *****/ - Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); + /***** Send button *****/ + Btn_PutConfirmButton (Txt_Show_questions); - /***** Button to create a new question *****/ - Tst_PutButtonToAddQuestion (); - } + Frm_EndForm (); + } + else // No test questions + { + /***** Warning message *****/ + Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); + + /***** Button to create a new question *****/ + Tst_PutButtonToAddQuestion (); + } /***** End box *****/ Box_BoxEnd (); @@ -1056,7 +1028,7 @@ static void Tst_ShowFormRequestEditTests (struct Tst_Test *Test) /******************* Select test questions for a game ************************/ /*****************************************************************************/ -void Tst_RequestSelectTestsForSet (struct Exa_Exams *Exams) +void Qst_RequestSelectQstsForExamSet (struct Exa_Exams *Exams) { struct Tst_Test Test; @@ -1074,7 +1046,7 @@ void Tst_RequestSelectTestsForSet (struct Exa_Exams *Exams) /******************* Select test questions for a game ************************/ /*****************************************************************************/ -void Tst_RequestSelectTestsForGame (struct Gam_Games *Games) +void Qst_RequestSelectQstsForGame (struct Gam_Games *Games) { struct Tst_Test Test; @@ -1111,37 +1083,38 @@ static void Tst_ShowFormRequestSelectTestsForSet (struct Exa_Exams *Exams, NULL,NULL, Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE); - /***** Get tags already present in the table of questions *****/ - if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res))) - { - Frm_BeginForm (ActLstTstQstForSet); - ExaSet_PutParamsOneSet (Exams); + /***** Get tags already present in the table of questions *****/ + if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res))) + { + Frm_BeginForm (ActLstTstQstForSet); + ExaSet_PutParamsOneSet (Exams); - HTM_TABLE_BeginPadding (2); + HTM_TABLE_BeginPadding (2); - /***** Selection of tags *****/ - Tag_ShowFormSelTags (&Test->Tags,mysql_res,false); + /***** Selection of tags *****/ + Tag_ShowFormSelTags (&Test->Tags,mysql_res,false); - /***** Selection of types of answers *****/ - Tst_ShowFormAnswerTypes (&Test->AnswerTypes); + /***** Selection of types of answers *****/ + Tst_ShowFormAnswerTypes (&Test->AnswerTypes); - /***** Starting and ending dates in the search *****/ - Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); + /***** Starting and ending dates in the search *****/ + Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); - HTM_TABLE_End (); + HTM_TABLE_End (); - /***** Send button *****/ - Btn_PutConfirmButton (Txt_Show_questions); - Frm_EndForm (); - } - else // No test questions - { - /***** Warning message *****/ - Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); + /***** Send button *****/ + Btn_PutConfirmButton (Txt_Show_questions); - /***** Button to create a new question *****/ - Tst_PutButtonToAddQuestion (); - } + Frm_EndForm (); + } + else // No test questions + { + /***** Warning message *****/ + Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); + + /***** Button to create a new question *****/ + Tst_PutButtonToAddQuestion (); + } /***** End box *****/ Box_BoxEnd (); @@ -1173,34 +1146,35 @@ static void Tst_ShowFormRequestSelectTestsForGame (struct Gam_Games *Games, NULL,NULL, Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE); - /***** Get tags already present in the table of questions *****/ - if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res))) - { - Frm_BeginForm (ActGamLstTstQst); - Gam_PutParams (Games); + /***** Get tags already present in the table of questions *****/ + if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res))) + { + Frm_BeginForm (ActGamLstTstQst); + Gam_PutParams (Games); - HTM_TABLE_BeginPadding (2); + HTM_TABLE_BeginPadding (2); - /***** Selection of tags *****/ - Tag_ShowFormSelTags (&Test->Tags,mysql_res,false); + /***** Selection of tags *****/ + Tag_ShowFormSelTags (&Test->Tags,mysql_res,false); - /***** Starting and ending dates in the search *****/ - Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); + /***** Starting and ending dates in the search *****/ + Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (SetHMS); - HTM_TABLE_End (); + HTM_TABLE_End (); - /***** Send button *****/ - Btn_PutConfirmButton (Txt_Show_questions); - Frm_EndForm (); - } - else // No test questions - { - /***** Warning message *****/ - Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); + /***** Send button *****/ + Btn_PutConfirmButton (Txt_Show_questions); - /***** Button to create a new question *****/ - Tst_PutButtonToAddQuestion (); - } + Frm_EndForm (); + } + else // No test questions + { + /***** Warning message *****/ + Ale_ShowAlert (Ale_INFO,Txt_No_test_questions); + + /***** Button to create a new question *****/ + Tst_PutButtonToAddQuestion (); + } /***** End box *****/ Box_BoxEnd (); @@ -1210,10 +1184,10 @@ static void Tst_ShowFormRequestSelectTestsForGame (struct Gam_Games *Games, } /*****************************************************************************/ -/************************* Check if I can edit tests *************************/ +/*********************** Check if I can edit questions ***********************/ /*****************************************************************************/ -static bool Tst_CheckIfICanEditTests (void) +static bool Qst_CheckIfICanEditQsts (void) { return (bool) (Gbl.Usrs.Me.Role.Logged == Rol_TCH || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); @@ -1223,7 +1197,7 @@ static bool Tst_CheckIfICanEditTests (void) /********************* Put contextual icons in tests *************************/ /*****************************************************************************/ -static void Tst_PutIconsRequestBankQsts (__attribute__((unused)) void *Args) +static void Qst_PutIconsRequestBankQsts (__attribute__((unused)) void *Args) { extern const char *Txt_New_question; @@ -1246,7 +1220,7 @@ static void Tst_PutIconsRequestBankQsts (__attribute__((unused)) void *Args) /********************* Put contextual icons in tests *************************/ /*****************************************************************************/ -static void Tst_PutIconsEditBankQsts (void *Test) +static void Qst_PutIconsEditBankQsts (void *Test) { extern const char *Txt_New_question; @@ -1259,7 +1233,7 @@ static void Tst_PutIconsEditBankQsts (void *Test) case ActRemOneTstQst: // Remove a question case ActChgShfTstQst: // Change shuffle of a question Ico_PutContextualIconToRemove (ActReqRemSevTstQst,NULL, - Tst_PutParamsEditQst,Test); + Qst_PutParamsEditQst,Test); break; default: break; @@ -1327,7 +1301,7 @@ static void Tst_PutButtonToAddQuestion (void) extern const char *Txt_New_question; Frm_BeginForm (ActEdiOneTstQst); - Btn_PutConfirmButton (Txt_New_question); + Btn_PutConfirmButton (Txt_New_question); Frm_EndForm (); } @@ -1430,94 +1404,94 @@ static void Tst_ShowFormConfigTst (void) Tst_PutIconsTests,NULL, Hlp_ASSESSMENT_Tests_configuring_tests,Box_NOT_CLOSABLE); - /***** Begin form *****/ - Frm_BeginForm (ActRcvCfgTst); + /***** Begin form *****/ + Frm_BeginForm (ActRcvCfgTst); - /***** Tests are visible from plugins? *****/ - HTM_TABLE_BeginCenterPadding (2); - HTM_TR_Begin (NULL); + /***** Tests are visible from plugins? *****/ + HTM_TABLE_BeginCenterPadding (2); + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Plugins); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Plugins); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LB\""); - for (Pluggable = TstCfg_PLUGGABLE_NO; - Pluggable <= TstCfg_PLUGGABLE_YES; - Pluggable++) - { - HTM_LABEL_Begin ("class=\"DAT\""); - HTM_INPUT_RADIO ("Pluggable",false, - "value=\"%u\"%s", - (unsigned) Pluggable, - Pluggable == TstCfg_GetConfigPluggable () ? " checked=\"checked\"" : - ""); - HTM_Txt (Txt_TST_PLUGGABLE[Pluggable]); - HTM_LABEL_End (); - HTM_BR (); - } - HTM_TD_End (); + HTM_TD_Begin ("class=\"LB\""); + for (Pluggable = TstCfg_PLUGGABLE_NO; + Pluggable <= TstCfg_PLUGGABLE_YES; + Pluggable++) + { + HTM_LABEL_Begin ("class=\"DAT\""); + HTM_INPUT_RADIO ("Pluggable",false, + "value=\"%u\"%s", + (unsigned) Pluggable, + Pluggable == TstCfg_GetConfigPluggable () ? " checked=\"checked\"" : + ""); + HTM_Txt (Txt_TST_PLUGGABLE[Pluggable]); + HTM_LABEL_End (); + HTM_BR (); + } + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Number of questions *****/ - HTM_TR_Begin (NULL); + /***** Number of questions *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Number_of_questions); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Number_of_questions); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LB\""); - HTM_TABLE_BeginPadding (2); - Tst_PutInputFieldNumQst ("NumQstMin",Txt_minimum, - TstCfg_GetConfigMin ()); // Minimum number of questions - Tst_PutInputFieldNumQst ("NumQstDef",Txt_default, - TstCfg_GetConfigDef ()); // Default number of questions - Tst_PutInputFieldNumQst ("NumQstMax",Txt_maximum, - TstCfg_GetConfigMax ()); // Maximum number of questions - HTM_TABLE_End (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LB\""); + HTM_TABLE_BeginPadding (2); + Tst_PutInputFieldNumQst ("NumQstMin",Txt_minimum, + TstCfg_GetConfigMin ()); // Minimum number of questions + Tst_PutInputFieldNumQst ("NumQstDef",Txt_default, + TstCfg_GetConfigDef ()); // Default number of questions + Tst_PutInputFieldNumQst ("NumQstMax",Txt_maximum, + TstCfg_GetConfigMax ()); // Maximum number of questions + HTM_TABLE_End (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Minimum time between consecutive tests, per question *****/ - HTM_TR_Begin (NULL); + /***** Minimum time between consecutive tests, per question *****/ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","MinTimeNxtTstPerQst", - Txt_Minimum_time_seconds_per_question_between_two_tests); + /* Label */ + Frm_LabelColumn ("RT","MinTimeNxtTstPerQst", + Txt_Minimum_time_seconds_per_question_between_two_tests); - /* Data */ - HTM_TD_Begin ("class=\"LB\""); - snprintf (StrMinTimeNxtTstPerQst,sizeof (StrMinTimeNxtTstPerQst),"%lu", - TstCfg_GetConfigMinTimeNxtTstPerQst ()); - HTM_INPUT_TEXT ("MinTimeNxtTstPerQst",Cns_MAX_DECIMAL_DIGITS_ULONG,StrMinTimeNxtTstPerQst, - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"MinTimeNxtTstPerQst\" size=\"7\" required=\"required\""); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LB\""); + snprintf (StrMinTimeNxtTstPerQst,sizeof (StrMinTimeNxtTstPerQst),"%lu", + TstCfg_GetConfigMinTimeNxtTstPerQst ()); + HTM_INPUT_TEXT ("MinTimeNxtTstPerQst",Cns_MAX_DECIMAL_DIGITS_ULONG,StrMinTimeNxtTstPerQst, + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"MinTimeNxtTstPerQst\" size=\"7\" required=\"required\""); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Visibility of test exams *****/ - HTM_TR_Begin (NULL); + /***** Visibility of test exams *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Result_visibility); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Result_visibility); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LB\""); - TstVis_PutVisibilityCheckboxes (TstCfg_GetConfigVisibility ()); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LB\""); + TstVis_PutVisibilityCheckboxes (TstCfg_GetConfigVisibility ()); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - HTM_TABLE_End (); + HTM_TABLE_End (); - /***** Send button *****/ - Btn_PutConfirmButton (Txt_Save_changes); + /***** Send button *****/ + Btn_PutConfirmButton (Txt_Save_changes); - /***** End form *****/ - Frm_EndForm (); + /***** End form *****/ + Frm_EndForm (); /***** End box *****/ Box_BoxEnd (); @@ -1537,18 +1511,18 @@ static void Tst_PutInputFieldNumQst (const char *Field,const char *Label, HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"RM\""); - HTM_LABEL_Begin ("for=\"%s\" class=\"DAT\"",Field); - HTM_Txt (Label); - HTM_LABEL_End (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"RM\""); + HTM_LABEL_Begin ("for=\"%s\" class=\"DAT\"",Field); + HTM_Txt (Label); + HTM_LABEL_End (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LM\""); - snprintf (StrValue,sizeof (StrValue),"%u",Value); - HTM_INPUT_TEXT (Field,Cns_MAX_DECIMAL_DIGITS_UINT,StrValue, - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"%s\" size=\"3\" required=\"required\"",Field); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LM\""); + snprintf (StrValue,sizeof (StrValue),"%u",Value); + HTM_INPUT_TEXT (Field,Cns_MAX_DECIMAL_DIGITS_UINT,StrValue, + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"%s\" size=\"3\" required=\"required\"",Field); + HTM_TD_End (); HTM_TR_End (); } @@ -1562,71 +1536,71 @@ static void Tst_ShowFormAnswerTypes (const struct Tst_AnswerTypes *AnswerTypes) extern const char *The_ClassFormInBox[The_NUM_THEMES]; extern const char *Txt_Types_of_answers; extern const char *Txt_All_types_of_answers; - extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; - Tst_AnswerType_t AnsType; + extern const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES]; + Qst_AnswerType_t AnsType; bool Checked; char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; const char *Ptr; HTM_TR_Begin (NULL); - /***** Label *****/ - HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Types_of_answers); - HTM_TD_End (); - - /***** Select all types of answers *****/ - HTM_TD_Begin ("class=\"LT\""); - HTM_TABLE_BeginPadding (2); - - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"LM\""); - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_CHECKBOX ("AllAnsTypes",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"Y\"%s onclick=\"togglecheckChildren(this,'AnswerType');\"", - AnswerTypes->All ? " checked=\"checked\"" : - ""); - HTM_TxtF (" %s",Txt_All_types_of_answers); - HTM_LABEL_End (); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Type of answer *****/ - for (AnsType = (Tst_AnswerType_t) 0; - AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1); - AnsType++) - { - HTM_TR_Begin (NULL); - - Checked = false; - Ptr = AnswerTypes->List; - while (*Ptr) - { - Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT); - if (Tst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr) == AnsType) - { - Checked = true; - break; - } - } - HTM_TD_Begin ("class=\"LM\""); - HTM_LABEL_Begin ("class=\"DAT\""); - HTM_INPUT_CHECKBOX ("AnswerType",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"%u\"%s onclick=\"checkParent(this,'AllAnsTypes');\"", - (unsigned) AnsType, - Checked ? " checked=\"checked\"" : - ""); - HTM_TxtF (" %s",Txt_TST_STR_ANSWER_TYPES[AnsType]); - HTM_LABEL_End (); + /***** Label *****/ + HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Types_of_answers); HTM_TD_End (); - HTM_TR_End (); - } + /***** Select all types of answers *****/ + HTM_TD_Begin ("class=\"LT\""); + HTM_TABLE_BeginPadding (2); - HTM_TABLE_End (); - HTM_TD_End (); + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"LM\""); + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_INPUT_CHECKBOX ("AllAnsTypes",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"Y\"%s onclick=\"togglecheckChildren(this,'AnswerType');\"", + AnswerTypes->All ? " checked=\"checked\"" : + ""); + HTM_TxtF (" %s",Txt_All_types_of_answers); + HTM_LABEL_End (); + HTM_TD_End (); + + HTM_TR_End (); + + /***** Type of answer *****/ + for (AnsType = (Qst_AnswerType_t) 0; + AnsType <= (Qst_AnswerType_t) (Qst_NUM_ANS_TYPES - 1); + AnsType++) + { + HTM_TR_Begin (NULL); + + Checked = false; + Ptr = AnswerTypes->List; + while (*Ptr) + { + Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT); + if (Qst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr) == AnsType) + { + Checked = true; + break; + } + } + HTM_TD_Begin ("class=\"LM\""); + HTM_LABEL_Begin ("class=\"DAT\""); + HTM_INPUT_CHECKBOX ("AnswerType",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"%u\"%s onclick=\"checkParent(this,'AllAnsTypes');\"", + (unsigned) AnsType, + Checked ? " checked=\"checked\"" : + ""); + HTM_TxtF (" %s",Txt_TST_STR_ANSWER_TYPES[AnsType]); + HTM_LABEL_End (); + HTM_TD_End (); + + HTM_TR_End (); + } + + HTM_TABLE_End (); + HTM_TD_End (); HTM_TR_End (); } @@ -1634,7 +1608,7 @@ static void Tst_ShowFormAnswerTypes (const struct Tst_AnswerTypes *AnswerTypes) /***************** List several test questions for edition *******************/ /*****************************************************************************/ -void Tst_ListQuestionsToEdit (void) +void Qst_ListQuestionsToEdit (void) { struct Tst_Test Test; MYSQL_RES *mysql_res; @@ -1646,7 +1620,7 @@ void Tst_ListQuestionsToEdit (void) if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters from the form { /***** Get question codes from database *****/ - Tst_GetQuestions (&Test,&mysql_res); // Query database + Qst_GetQuestions (&Test,&mysql_res); // Query database if (Test.NumQsts) { /* Contextual menu */ @@ -1667,7 +1641,7 @@ void Tst_ListQuestionsToEdit (void) } else /* Show the form again */ - Tst_ShowFormRequestEditTests (&Test); + Qst_ShowFormRequestEditQsts (&Test); /***** Destroy test *****/ Tst_TstDestructor (&Test); @@ -1688,7 +1662,7 @@ void Tst_ListQuestionsToSelectForSet (struct Exa_Exams *Exams) /***** Get parameters, query the database and list the questions *****/ if (Tst_GetParamsTst (&Test,Tst_SELECT_QUESTIONS_FOR_EXAM)) // Get parameters from the form { - Tst_GetQuestions (&Test,&mysql_res); // Query database + Qst_GetQuestions (&Test,&mysql_res); // Query database if (Test.NumQsts) /* Show the table with the questions */ Tst_ListOneOrMoreQuestionsForSelectionForSet (Exams,Test.NumQsts,mysql_res); @@ -1719,7 +1693,7 @@ void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games) /***** Get parameters, query the database and list the questions *****/ if (Tst_GetParamsTst (&Test,Tst_SELECT_QUESTIONS_FOR_GAME)) // Get parameters from the form { - Tst_GetQuestions (&Test,&mysql_res); // Query database + Qst_GetQuestions (&Test,&mysql_res); // Query database if (Test.NumQsts) /* Show the table with the questions */ Tst_ListOneOrMoreQuestionsForSelectionForGame (Games,Test.NumQsts,mysql_res); @@ -1741,7 +1715,7 @@ void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games) #define Tst_MAX_BYTES_QUERY_TEST (16 * 1024 - 1) -static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res) +static void Qst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res) { extern const char *Txt_No_questions_found_matching_your_search_criteria; char *Query = NULL; @@ -1751,7 +1725,7 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res) char TagText[Tag_MAX_BYTES_TAG + 1]; char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1]; char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; - Tst_AnswerType_t AnsType; + Qst_AnswerType_t AnsType; char CrsCodStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1]; /***** Allocate space for query *****/ @@ -1818,7 +1792,7 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res) while (*Ptr) { Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Tag_MAX_BYTES_TAG); - AnsType = Tst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr); + AnsType = Qst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr); LengthQuery = LengthQuery + 35 + strlen (Tst_StrAnswerTypesDB[AnsType]) + 1; if (LengthQuery > Tst_MAX_BYTES_QUERY_TEST - 256) Err_ShowErrorAndExit ("Query size exceed."); @@ -1889,7 +1863,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test, const char *Ptr; char TagText[Tag_MAX_BYTES_TAG + 1]; char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; - Tst_AnswerType_t AnswerType; + Qst_AnswerType_t AnswerType; bool Shuffle; char StrNumQsts[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; unsigned QstInd; @@ -1959,7 +1933,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test, while (*Ptr) { Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Tag_MAX_BYTES_TAG); - AnswerType = Tst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr); + AnswerType = Qst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr); LengthQuery = LengthQuery + 35 + strlen (Tst_StrAnswerTypesDB[AnswerType]) + 1; if (LengthQuery > Tst_MAX_BYTES_QUERY_TEST - 128) Err_ShowErrorAndExit ("Query size exceed."); @@ -2006,7 +1980,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test, Err_ShowErrorAndExit ("Wrong code of question."); /* Get answer type (row[1]) */ - AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); + AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); /* Get shuffle (row[2]) */ Shuffle = (row[2][0] == 'Y'); @@ -2014,14 +1988,14 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test, /* Set indexes of answers */ switch (AnswerType) { - case Tst_ANS_INT: - case Tst_ANS_FLOAT: - case Tst_ANS_TRUE_FALSE: - case Tst_ANS_TEXT: + case Qst_ANS_INT: + case Qst_ANS_FLOAT: + case Qst_ANS_TRUE_FALSE: + case Qst_ANS_TEXT: Print->PrintedQuestions[QstInd].StrIndexes[0] = '\0'; break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: /* If answer type is unique or multiple option, generate indexes of answers depending on shuffle */ Tst_GenerateChoiceIndexes (&Print->PrintedQuestions[QstInd],Shuffle); @@ -2048,7 +2022,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test, void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion, bool Shuffle) { - struct Tst_Question Question; + struct Qst_Question Question; unsigned NumOpt; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2057,11 +2031,11 @@ void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion, char StrInd[1 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = PrintedQuestion->QstCod; /***** Get answers of question from database *****/ - Tst_GetAnswersQst (&Question,&mysql_res,Shuffle); + Qst_GetAnswersQst (&Question,&mysql_res,Shuffle); /* row[0] AnsInd row[1] Answer @@ -2083,7 +2057,7 @@ void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion, ErrorInIndex = false; if (sscanf (row[0],"%u",&Index) == 1) { - if (Index >= Tst_MAX_OPTIONS_PER_QUESTION) + if (Index >= Qst_MAX_OPTIONS_PER_QUESTION) ErrorInIndex = true; } else @@ -2101,7 +2075,7 @@ void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion, DB_FreeMySQLResult (&mysql_res); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /*****************************************************************************/ @@ -2118,21 +2092,23 @@ static void Tst_ListOneQstToEdit (struct Tst_Test *Test) /***** Begin box *****/ Box_BoxBegin (NULL,Txt_Questions, - Tst_PutIconsEditBankQsts,Test, + Qst_PutIconsEditBankQsts,Test, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - /***** Write the heading *****/ - HTM_TABLE_BeginWideMarginPadding (5); - Tst_WriteHeadingRowQuestionsForEdition (Test); + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (5); - /***** Write question row *****/ - Tst_WriteQuestionListing (Test,0); + /***** Write the heading *****/ + Tst_WriteHeadingRowQuestionsForEdition (Test); - /***** End table *****/ - HTM_TABLE_End (); + /***** Write question row *****/ + Tst_WriteQuestionListing (Test,0); - /***** Button to add a new question *****/ - Tst_PutButtonToAddQuestion (); + /***** End table *****/ + HTM_TABLE_End (); + + /***** Button to add a new question *****/ + Tst_PutButtonToAddQuestion (); /***** End box *****/ Box_BoxEnd (); @@ -2152,40 +2128,42 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test, /***** Begin box *****/ Box_BoxBegin (NULL,Txt_Questions, - Tst_PutIconsEditBankQsts,Test, + Qst_PutIconsEditBankQsts,Test, Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); - /***** Write the heading *****/ - HTM_TABLE_BeginWideMarginPadding (5); - Tst_WriteHeadingRowQuestionsForEdition (Test); + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (5); - /***** Write rows *****/ - for (QstInd = 0; - QstInd < Test->NumQsts; - QstInd++) - { - Gbl.RowEvenOdd = QstInd % 2; + /***** Write the heading *****/ + Tst_WriteHeadingRowQuestionsForEdition (Test); - /***** Create test question *****/ - Tst_QstConstructor (&Test->Question); + /***** Write rows *****/ + for (QstInd = 0; + QstInd < Test->NumQsts; + QstInd++) + { + Gbl.RowEvenOdd = QstInd % 2; - /***** Get question code (row[0]) *****/ - row = mysql_fetch_row (mysql_res); - if ((Test->Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Err_WrongQuestionExit (); + /***** Create test question *****/ + Qst_QstConstructor (&Test->Question); - /***** Write question row *****/ - Tst_WriteQuestionListing (Test,QstInd); + /***** Get question code (row[0]) *****/ + row = mysql_fetch_row (mysql_res); + if ((Test->Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Err_WrongQuestionExit (); - /***** Destroy test question *****/ - Tst_QstDestructor (&Test->Question); - } + /***** Write question row *****/ + Tst_WriteQuestionListing (Test,QstInd); - /***** End table *****/ - HTM_TABLE_End (); + /***** Destroy test question *****/ + Qst_QstDestructor (&Test->Question); + } - /***** Button to add a new question *****/ - Tst_PutButtonToAddQuestion (); + /***** End table *****/ + HTM_TABLE_End (); + + /***** Button to add a new question *****/ + Tst_PutButtonToAddQuestion (); /***** End box *****/ Box_BoxEnd (); @@ -2209,44 +2187,44 @@ static void Tst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test) /***** Begin row *****/ HTM_TR_Begin (NULL); - /***** First columns *****/ - HTM_TH_Empty (1); - HTM_TH (1,1,"CT",Txt_No_INDEX); - HTM_TH (1,1,"CT",Txt_Code); - HTM_TH (1,1,"CT",Txt_Date); - HTM_TH (1,1,"CT",Txt_Tags); - HTM_TH (1,1,"CT",Txt_Shuffle); + /***** First columns *****/ + HTM_TH_Empty (1); + HTM_TH (1,1,"CT",Txt_No_INDEX); + HTM_TH (1,1,"CT",Txt_Code); + HTM_TH (1,1,"CT",Txt_Date); + HTM_TH (1,1,"CT",Txt_Tags); + HTM_TH (1,1,"CT",Txt_Shuffle); - /***** Columns which data can be ordered *****/ - /* Stem and answers of question */ - /* Number of times that the question has been answered */ - /* Average score */ - for (Order = (Tst_QuestionsOrder_t) 0; - Order <= (Tst_QuestionsOrder_t) (Tst_NUM_TYPES_ORDER_QST - 1); - Order++) - { - HTM_TH_Begin (1,1,"LT"); + /***** Columns which data can be ordered *****/ + /* Stem and answers of question */ + /* Number of times that the question has been answered */ + /* Average score */ + for (Order = (Tst_QuestionsOrder_t) 0; + Order <= (Tst_QuestionsOrder_t) (Tst_NUM_TYPES_ORDER_QST - 1); + Order++) + { + HTM_TH_Begin (1,1,"LT"); - if (Test->NumQsts > 1) - { - Frm_BeginForm (ActLstTstQst); - Tst_PutParamsEditQst (Test); - Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); - HTM_BUTTON_SUBMIT_Begin (Txt_TST_STR_ORDER_FULL[Order],"BT_LINK TIT_TBL",NULL); - if (Order == Test->SelectedOrder) - HTM_U_Begin (); - } - HTM_Txt (Txt_TST_STR_ORDER_SHORT[Order]); - if (Test->NumQsts > 1) - { - if (Order == Test->SelectedOrder) - HTM_U_End (); - HTM_BUTTON_End (); - Frm_EndForm (); - } + if (Test->NumQsts > 1) + { + Frm_BeginForm (ActLstTstQst); + Qst_PutParamsEditQst (Test); + Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); + HTM_BUTTON_SUBMIT_Begin (Txt_TST_STR_ORDER_FULL[Order],"BT_LINK TIT_TBL",NULL); + if (Order == Test->SelectedOrder) + HTM_U_Begin (); + } + HTM_Txt (Txt_TST_STR_ORDER_SHORT[Order]); + if (Test->NumQsts > 1) + { + if (Order == Test->SelectedOrder) + HTM_U_End (); + HTM_BUTTON_End (); + Frm_EndForm (); + } - HTM_TH_End (); - } + HTM_TH_End (); + } /***** End row *****/ HTM_TR_End (); @@ -2262,109 +2240,109 @@ static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd) char *Id; /***** Get and show question data *****/ - if (Tst_GetQstDataFromDB (&Test->Question)) + if (Qst_GetQstDataFromDB (&Test->Question)) { /***** Begin table row *****/ HTM_TR_Begin (NULL); - /***** Icons *****/ - HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); + /***** Icons *****/ + HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); - /* Write icon to remove the question */ - Ico_PutContextualIconToRemove (ActReqRemOneTstQst,NULL, - Tst_PutParamsEditQst,Test); + /* Write icon to remove the question */ + Ico_PutContextualIconToRemove (ActReqRemOneTstQst,NULL, + Qst_PutParamsEditQst,Test); - /* Write icon to edit the question */ - Ico_PutContextualIconToEdit (ActEdiOneTstQst,NULL, - Tst_PutParamQstCod,&Test->Question.QstCod); + /* Write icon to edit the question */ + Ico_PutContextualIconToEdit (ActEdiOneTstQst,NULL, + Qst_PutParamQstCod,&Test->Question.QstCod); - HTM_TD_End (); + HTM_TD_End (); - /* Number of question and answer type */ - HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd + 1,"BIG_INDEX"); - Tst_WriteAnswerType (Test->Question.Answer.Type,"DAT_SMALL"); - HTM_TD_End (); + /* Number of question and answer type */ + HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + Qst_WriteNumQst (QstInd + 1,"BIG_INDEX"); + Qst_WriteAnswerType (Test->Question.Answer.Type,"DAT_SMALL"); + HTM_TD_End (); - /* Question code */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TxtF ("%ld ",Test->Question.QstCod); - HTM_TD_End (); + /* Question code */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TxtF ("%ld ",Test->Question.QstCod); + HTM_TD_End (); - /* Date (row[0] has the UTC date-time) */ - if (asprintf (&Id,"tst_date_%u",++UniqueId) < 0) - Err_NotEnoughMemoryExit (); - HTM_TD_Begin ("id=\"%s\" class=\"DAT_SMALL CT COLOR%u\"", - Id,Gbl.RowEvenOdd); - Dat_WriteLocalDateHMSFromUTC (Id,Test->Question.EditTime, - Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, - true,true,false,0x7); - HTM_TD_End (); - free (Id); + /* Date (row[0] has the UTC date-time) */ + if (asprintf (&Id,"tst_date_%u",++UniqueId) < 0) + Err_NotEnoughMemoryExit (); + HTM_TD_Begin ("id=\"%s\" class=\"DAT_SMALL CT COLOR%u\"", + Id,Gbl.RowEvenOdd); + Dat_WriteLocalDateHMSFromUTC (Id,Test->Question.EditTime, + Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, + true,true,false,0x7); + HTM_TD_End (); + free (Id); - /* Question tags */ - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Tst_GetAndWriteTagsQst (Test->Question.QstCod); - HTM_TD_End (); + /* Question tags */ + HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + Tag_GetAndWriteTagsQst (Test->Question.QstCod); + HTM_TD_End (); - /* Shuffle (row[2]) */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - if (Test->Question.Answer.Type == Tst_ANS_UNIQUE_CHOICE || - Test->Question.Answer.Type == Tst_ANS_MULTIPLE_CHOICE) - { - Frm_BeginForm (ActChgShfTstQst); - Tst_PutParamsEditQst (Test); - Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Test->SelectedOrder); - HTM_INPUT_CHECKBOX ("Shuffle",HTM_SUBMIT_ON_CHANGE, - "value=\"Y\"%s", - Test->Question.Answer.Shuffle ? " checked=\"checked\"" : - ""); - Frm_EndForm (); - } - HTM_TD_End (); + /* Shuffle (row[2]) */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + if (Test->Question.Answer.Type == Qst_ANS_UNIQUE_CHOICE || + Test->Question.Answer.Type == Qst_ANS_MULTIPLE_CHOICE) + { + Frm_BeginForm (ActChgShfTstQst); + Qst_PutParamsEditQst (Test); + Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Test->SelectedOrder); + HTM_INPUT_CHECKBOX ("Shuffle",HTM_SUBMIT_ON_CHANGE, + "value=\"Y\"%s", + Test->Question.Answer.Shuffle ? " checked=\"checked\"" : + ""); + Frm_EndForm (); + } + HTM_TD_End (); - /* Stem (row[3]) */ - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteQstStem (Test->Question.Stem,"TEST_TXT", - true); // Visible + /* Stem (row[3]) */ + HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + Qst_WriteQstStem (Test->Question.Stem,"TEST_TXT", + true); // Visible - /***** Get and show media (row[5]) *****/ - Med_ShowMedia (&Test->Question.Media, - "TEST_MED_EDIT_LIST_CONT", - "TEST_MED_EDIT_LIST"); + /***** Get and show media (row[5]) *****/ + Med_ShowMedia (&Test->Question.Media, + "TEST_MED_EDIT_LIST_CONT", + "TEST_MED_EDIT_LIST"); - /* Feedback (row[4]) and answers */ - Tst_WriteQstFeedback (Test->Question.Feedback,"TEST_TXT_LIGHT"); - Tst_WriteAnswersBank (&Test->Question,"TEST_TXT","TEST_TXT_LIGHT"); - HTM_TD_End (); + /* Feedback (row[4]) and answers */ + Qst_WriteQstFeedback (Test->Question.Feedback,"TEST_TXT_LIGHT"); + Qst_WriteAnswersBank (&Test->Question,"TEST_TXT","TEST_TXT_LIGHT"); + HTM_TD_End (); - /* Number of times this question has been answered */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_UnsignedLong (Test->Question.NumHits); - HTM_TD_End (); + /* Number of times this question has been answered */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_UnsignedLong (Test->Question.NumHits); + HTM_TD_End (); - /* Average score */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - if (Test->Question.NumHits) - HTM_Double2Decimals (Test->Question.Score / - (double) Test->Question.NumHits); - else - HTM_Txt ("N.A."); - HTM_TD_End (); + /* Average score */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + if (Test->Question.NumHits) + HTM_Double2Decimals (Test->Question.Score / + (double) Test->Question.NumHits); + else + HTM_Txt ("N.A."); + HTM_TD_End (); - /* Number of times this question has been answered (not blank) */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_UnsignedLong (Test->Question.NumHitsNotBlank); - HTM_TD_End (); + /* Number of times this question has been answered (not blank) */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_UnsignedLong (Test->Question.NumHitsNotBlank); + HTM_TD_End (); - /* Average score (not blank) */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - if (Test->Question.NumHitsNotBlank) - HTM_Double2Decimals (Test->Question.Score / - (double) Test->Question.NumHitsNotBlank); - else - HTM_Txt ("N.A."); - HTM_TD_End (); + /* Average score (not blank) */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + if (Test->Question.NumHitsNotBlank) + HTM_Double2Decimals (Test->Question.Score / + (double) Test->Question.NumHitsNotBlank); + else + HTM_Txt ("N.A."); + HTM_TD_End (); /***** End table row *****/ HTM_TR_End (); @@ -2391,7 +2369,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam extern const char *Txt_Question; extern const char *Txt_Add_questions; unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; MYSQL_ROW row; /***** Begin box *****/ @@ -2399,59 +2377,61 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam NULL,NULL, Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE); - /***** Begin form *****/ - Frm_BeginForm (ActAddQstToExa); - ExaSet_PutParamsOneSet (Exams); + /***** Begin form *****/ + Frm_BeginForm (ActAddQstToExa); + ExaSet_PutParamsOneSet (Exams); - /***** Select all questions *****/ - Tst_PutCheckboxToSelectAllQuestions (); + /***** Select all questions *****/ + Tst_PutCheckboxToSelectAllQuestions (); - /***** Write the heading *****/ - HTM_TABLE_BeginWideMarginPadding (5); - HTM_TR_Begin (NULL); + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (5); - HTM_TH_Empty (1); + /***** Write the heading *****/ + HTM_TR_Begin (NULL); - HTM_TH (1,1,"CT",Txt_No_INDEX); - HTM_TH (1,1,"CT",Txt_Code); - HTM_TH (1,1,"CT",Txt_Date); - HTM_TH (1,1,"LT",Txt_Tags); - HTM_TH (1,1,"CT",Txt_Type); - HTM_TH (1,1,"CT",Txt_Shuffle); - HTM_TH (1,1,"CT",Txt_Question); + HTM_TH_Empty (1); - HTM_TR_End (); + HTM_TH (1,1,"CT",Txt_No_INDEX); + HTM_TH (1,1,"CT",Txt_Code); + HTM_TH (1,1,"CT",Txt_Date); + HTM_TH (1,1,"LT",Txt_Tags); + HTM_TH (1,1,"CT",Txt_Type); + HTM_TH (1,1,"CT",Txt_Shuffle); + HTM_TH (1,1,"CT",Txt_Question); - /***** Write rows *****/ - for (QstInd = 0; - QstInd < NumQsts; - QstInd++) - { - Gbl.RowEvenOdd = QstInd % 2; + HTM_TR_End (); - /* Create test question */ - Tst_QstConstructor (&Question); + /***** Write rows *****/ + for (QstInd = 0; + QstInd < NumQsts; + QstInd++) + { + Gbl.RowEvenOdd = QstInd % 2; - /* Get question code (row[0]) */ - row = mysql_fetch_row (mysql_res); - if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Err_WrongQuestionExit (); + /* Create test question */ + Qst_QstConstructor (&Question); - /* Write question row */ - Tst_WriteQuestionRowForSelection (QstInd,&Question); + /* Get question code (row[0]) */ + row = mysql_fetch_row (mysql_res); + if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Err_WrongQuestionExit (); - /* Destroy test question */ - Tst_QstDestructor (&Question); - } + /* Write question row */ + Tst_WriteQuestionRowForSelection (QstInd,&Question); - /***** End table *****/ - HTM_TABLE_End (); + /* Destroy test question */ + Qst_QstDestructor (&Question); + } - /***** Button to add questions *****/ - Btn_PutCreateButton (Txt_Add_questions); + /***** End table *****/ + HTM_TABLE_End (); - /***** End form *****/ - Frm_EndForm (); + /***** Button to add questions *****/ + Btn_PutCreateButton (Txt_Add_questions); + + /***** End form *****/ + Frm_EndForm (); /***** End box *****/ Box_BoxEnd (); @@ -2476,7 +2456,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam extern const char *Txt_Question; extern const char *Txt_Add_questions; unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; MYSQL_ROW row; /***** Begin box *****/ @@ -2484,59 +2464,60 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam NULL,NULL, Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE); - /***** Begin form *****/ - Frm_BeginForm (ActAddTstQstToGam); - Gam_PutParams (Games); + /***** Begin form *****/ + Frm_BeginForm (ActAddTstQstToGam); + Gam_PutParams (Games); - /***** Select all questions *****/ - Tst_PutCheckboxToSelectAllQuestions (); + /***** Select all questions *****/ + Tst_PutCheckboxToSelectAllQuestions (); - /***** Write the heading *****/ - HTM_TABLE_BeginWideMarginPadding (5); - HTM_TR_Begin (NULL); + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (5); - HTM_TH_Empty (1); + /***** Write the heading *****/ + HTM_TR_Begin (NULL); - HTM_TH (1,1,"CT",Txt_No_INDEX); - HTM_TH (1,1,"CT",Txt_Code); - HTM_TH (1,1,"CT",Txt_Date); - HTM_TH (1,1,"LT",Txt_Tags); - HTM_TH (1,1,"CT",Txt_Type); - HTM_TH (1,1,"CT",Txt_Shuffle); - HTM_TH (1,1,"CT",Txt_Question); + HTM_TH_Empty (1); + HTM_TH (1,1,"CT",Txt_No_INDEX); + HTM_TH (1,1,"CT",Txt_Code); + HTM_TH (1,1,"CT",Txt_Date); + HTM_TH (1,1,"LT",Txt_Tags); + HTM_TH (1,1,"CT",Txt_Type); + HTM_TH (1,1,"CT",Txt_Shuffle); + HTM_TH (1,1,"CT",Txt_Question); - HTM_TR_End (); + HTM_TR_End (); - /***** Write rows *****/ - for (QstInd = 0; - QstInd < NumQsts; - QstInd++) - { - Gbl.RowEvenOdd = QstInd % 2; + /***** Write rows *****/ + for (QstInd = 0; + QstInd < NumQsts; + QstInd++) + { + Gbl.RowEvenOdd = QstInd % 2; - /* Create test question */ - Tst_QstConstructor (&Question); + /* Create test question */ + Qst_QstConstructor (&Question); - /* Get question code (row[0]) */ - row = mysql_fetch_row (mysql_res); - if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Err_WrongQuestionExit (); + /* Get question code (row[0]) */ + row = mysql_fetch_row (mysql_res); + if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Err_WrongQuestionExit (); - /* Write question row */ - Tst_WriteQuestionRowForSelection (QstInd,&Question); + /* Write question row */ + Tst_WriteQuestionRowForSelection (QstInd,&Question); - /* Destroy test question */ - Tst_QstDestructor (&Question); - } + /* Destroy test question */ + Qst_QstDestructor (&Question); + } - /***** End table *****/ - HTM_TABLE_End (); + /***** End table *****/ + HTM_TABLE_End (); - /***** Button to add questions *****/ - Btn_PutCreateButton (Txt_Add_questions); + /***** Button to add questions *****/ + Btn_PutCreateButton (Txt_Add_questions); - /***** End form *****/ - Frm_EndForm (); + /***** End form *****/ + Frm_EndForm (); /***** End box *****/ Box_BoxEnd (); @@ -2553,9 +2534,9 @@ static void Tst_PutCheckboxToSelectAllQuestions (void) /***** Checkbox to select all listed questions *****/ HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_CHECKBOX ("AllQsts",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"Y\" onclick=\"togglecheckChildren(this,'QstCods');\""); - HTM_TxtF (" %s",Txt_All_questions); + HTM_INPUT_CHECKBOX ("AllQsts",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"Y\" onclick=\"togglecheckChildren(this,'QstCods');\""); + HTM_TxtF (" %s",Txt_All_questions); HTM_LABEL_End (); } @@ -2564,81 +2545,80 @@ static void Tst_PutCheckboxToSelectAllQuestions (void) /*****************************************************************************/ static void Tst_WriteQuestionRowForSelection (unsigned QstInd, - struct Tst_Question *Question) + struct Qst_Question *Question) { - extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; + extern const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES]; static unsigned UniqueId = 0; char *Id; /***** Get and show questvoidion data *****/ - if (Tst_GetQstDataFromDB (Question)) + if (Qst_GetQstDataFromDB (Question)) { /***** Begin table row *****/ HTM_TR_Begin (NULL); - /***** Icons *****/ - HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); + /* Write checkbox to select the question */ + HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); + HTM_INPUT_CHECKBOX ("QstCods",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"%ld\" onclick=\"checkParent(this,'AllQsts');\"", + Question->QstCod); + HTM_TD_End (); - /* Write checkbox to select the question */ - HTM_INPUT_CHECKBOX ("QstCods",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"%ld\" onclick=\"checkParent(this,'AllQsts');\"", - Question->QstCod); + /* Write number of question */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TxtF ("%u ",QstInd + 1); + HTM_TD_End (); - /* Write number of question */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TxtF ("%u ",QstInd + 1); - HTM_TD_End (); + /* Write question code */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TxtF ("%ld ",Question->QstCod); + HTM_TD_End (); - /* Write question code */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TxtF ("%ld ",Question->QstCod); - HTM_TD_End (); + /* Write the date (row[0] has the UTC date-time) */ + if (asprintf (&Id,"tst_date_%u",++UniqueId) < 0) + Err_NotEnoughMemoryExit (); + HTM_TD_Begin ("id=\"%s\" class=\"DAT_SMALL CT COLOR%u\">", + Id,Gbl.RowEvenOdd); + Dat_WriteLocalDateHMSFromUTC (Id,Question->EditTime, + Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, + true,true,false,0x7); + HTM_TD_End (); + free (Id); - /* Write the date (row[0] has the UTC date-time) */ - if (asprintf (&Id,"tst_date_%u",++UniqueId) < 0) - Err_NotEnoughMemoryExit (); - HTM_TD_Begin ("id=\"%s\" class=\"DAT_SMALL CT COLOR%u\">", - Id,Gbl.RowEvenOdd); - Dat_WriteLocalDateHMSFromUTC (Id,Question->EditTime, - Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, - true,true,false,0x7); - HTM_TD_End (); - free (Id); + /* Write the question tags */ + HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + Tag_GetAndWriteTagsQst (Question->QstCod); + HTM_TD_End (); - /* Write the question tags */ - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Tst_GetAndWriteTagsQst (Question->QstCod); - HTM_TD_End (); + /* Write the question type */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TxtF ("%s ",Txt_TST_STR_ANSWER_TYPES[Question->Answer.Type]); + HTM_TD_End (); - /* Write the question type */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TxtF ("%s ",Txt_TST_STR_ANSWER_TYPES[Question->Answer.Type]); - HTM_TD_End (); + /* Write if shuffle is enabled */ + HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_INPUT_CHECKBOX ("Shuffle",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"Y\"%s disabled=\"disabled\"", + Question->Answer.Shuffle ? " checked=\"checked\"" : + ""); + HTM_TD_End (); - /* Write if shuffle is enabled */ - HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_INPUT_CHECKBOX ("Shuffle",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"Y\"%s disabled=\"disabled\"", - Question->Answer.Shuffle ? " checked=\"checked\"" : - ""); - HTM_TD_End (); + /* Write stem */ + HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + Qst_WriteQstStem (Question->Stem,"TEST_TXT", + true); // Visible - /* Write stem */ - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteQstStem (Question->Stem,"TEST_TXT", - true); // Visible + /***** Get and show media *****/ + Med_ShowMedia (&Question->Media, + "TEST_MED_EDIT_LIST_CONT", + "TEST_MED_EDIT_LIST"); - /***** Get and show media *****/ - Med_ShowMedia (&Question->Media, - "TEST_MED_EDIT_LIST_CONT", - "TEST_MED_EDIT_LIST"); + /* Write feedback */ + Qst_WriteQstFeedback (Question->Feedback,"TEST_TXT_LIGHT"); - /* Write feedback */ - Tst_WriteQstFeedback (Question->Feedback,"TEST_TXT_LIGHT"); - - /* Write answers */ - Tst_WriteAnswersBank (Question,"TEST_TXT","TEST_TXT_LIGHT"); - HTM_TD_End (); + /* Write answers */ + Qst_WriteAnswersBank (Question,"TEST_TXT","TEST_TXT_LIGHT"); + HTM_TD_End (); /***** End table row *****/ HTM_TR_End (); @@ -2649,7 +2629,7 @@ static void Tst_WriteQuestionRowForSelection (unsigned QstInd, /************ Put hidden parameters for edition of test questions ************/ /*****************************************************************************/ -void Tst_PutParamsEditQst (void *Test) +void Qst_PutParamsEditQst (void *Test) { if (Test) { @@ -2661,7 +2641,7 @@ void Tst_PutParamsEditQst (void *Test) 'N'); Par_PutHiddenParamString (NULL,"AnswerType",((struct Tst_Test *) Test)->AnswerTypes.List); - Tst_PutParamQstCod (&((struct Tst_Test *) Test)->Question.QstCod); + Qst_PutParamQstCod (&((struct Tst_Test *) Test)->Question.QstCod); // if (Test->NumQsts == 1) // Par_PutHiddenParamChar ("OnlyThisQst",'Y'); // If there are only one row, don't list again after removing Dat_WriteParamsIniEndDates (); @@ -2672,7 +2652,7 @@ void Tst_PutParamsEditQst (void *Test) /*************** Get answers of a test question from database ****************/ /*****************************************************************************/ -unsigned Tst_GetNumAnswersQst (long QstCod) +unsigned Qst_GetNumAnswersQst (long QstCod) { return (unsigned) DB_QueryCOUNT ("can not get number of answers of a question", @@ -2682,7 +2662,7 @@ unsigned Tst_GetNumAnswersQst (long QstCod) QstCod); } -void Tst_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res, +void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res, bool Shuffle) { /***** Get answers of a question from database *****/ @@ -2707,7 +2687,7 @@ void Tst_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res, /***************** Change format of answers text / feedback ******************/ /*****************************************************************************/ -void Tst_ChangeFormatAnswersText (struct Tst_Question *Question) +void Qst_ChangeFormatAnswersText (struct Qst_Question *Question) { unsigned NumOpt; @@ -2722,7 +2702,7 @@ void Tst_ChangeFormatAnswersText (struct Tst_Question *Question) Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false); } -void Tst_ChangeFormatAnswersFeedback (struct Tst_Question *Question) +void Qst_ChangeFormatAnswersFeedback (struct Qst_Question *Question) { unsigned NumOpt; @@ -2742,20 +2722,20 @@ void Tst_ChangeFormatAnswersFeedback (struct Tst_Question *Question) /**************** Get and write the answers of a test question ***************/ /*****************************************************************************/ -void Tst_WriteAnswersBank (struct Tst_Question *Question, +void Qst_WriteAnswersBank (struct Qst_Question *Question, const char *ClassTxt, const char *ClassFeedback) { - void (*Tst_WriteAnsBank[Tst_NUM_ANS_TYPES]) (struct Tst_Question *Question, + void (*Tst_WriteAnsBank[Qst_NUM_ANS_TYPES]) (struct Qst_Question *Question, const char *ClassTxt, const char *ClassFeedback) = { - [Tst_ANS_INT ] = Tst_WriteIntAnsBank, - [Tst_ANS_FLOAT ] = Tst_WriteFltAnsBank, - [Tst_ANS_TRUE_FALSE ] = Tst_WriteTF_AnsBank, - [Tst_ANS_UNIQUE_CHOICE ] = Tst_WriteChoAnsBank, - [Tst_ANS_MULTIPLE_CHOICE] = Tst_WriteChoAnsBank, - [Tst_ANS_TEXT ] = Tst_WriteChoAnsBank, + [Qst_ANS_INT ] = Tst_WriteIntAnsBank, + [Qst_ANS_FLOAT ] = Tst_WriteFltAnsBank, + [Qst_ANS_TRUE_FALSE ] = Tst_WriteTF_AnsBank, + [Qst_ANS_UNIQUE_CHOICE ] = Tst_WriteChoAnsBank, + [Qst_ANS_MULTIPLE_CHOICE] = Tst_WriteChoAnsBank, + [Qst_ANS_TEXT ] = Tst_WriteChoAnsBank, }; /***** Write answers *****/ @@ -2766,7 +2746,7 @@ void Tst_WriteAnswersBank (struct Tst_Question *Question, /****************** Write integer answer when editing a test *****************/ /*****************************************************************************/ -static void Tst_WriteIntAnsBank (struct Tst_Question *Question, +static void Tst_WriteIntAnsBank (struct Qst_Question *Question, const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback) { @@ -2779,7 +2759,7 @@ static void Tst_WriteIntAnsBank (struct Tst_Question *Question, /****************** Write float answer when editing a test *******************/ /*****************************************************************************/ -static void Tst_WriteFltAnsBank (struct Tst_Question *Question, +static void Tst_WriteFltAnsBank (struct Qst_Question *Question, const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback) { @@ -2796,14 +2776,14 @@ static void Tst_WriteFltAnsBank (struct Tst_Question *Question, /*********** Write false / true answer when listing test questions ***********/ /*****************************************************************************/ -static void Tst_WriteTF_AnsBank (struct Tst_Question *Question, +static void Tst_WriteTF_AnsBank (struct Qst_Question *Question, const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback) { /***** Write answer *****/ HTM_SPAN_Begin ("class=\"%s\"",ClassTxt); HTM_Txt ("("); - Tst_WriteAnsTF (Question->Answer.TF); + Qst_WriteAnsTF (Question->Answer.TF); HTM_Txt (")"); HTM_SPAN_End (); } @@ -2812,7 +2792,7 @@ static void Tst_WriteTF_AnsBank (struct Tst_Question *Question, /**** Write single or multiple choice answer when listing test questions *****/ /*****************************************************************************/ -static void Tst_WriteChoAnsBank (struct Tst_Question *Question, +static void Tst_WriteChoAnsBank (struct Qst_Question *Question, const char *ClassTxt, const char *ClassFeedback) { @@ -2820,10 +2800,10 @@ static void Tst_WriteChoAnsBank (struct Tst_Question *Question, unsigned NumOpt; /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Change format of answers feedback *****/ - Tst_ChangeFormatAnswersFeedback (Question); + Qst_ChangeFormatAnswersFeedback (Question); HTM_TABLE_BeginPadding (2); for (NumOpt = 0; @@ -2869,7 +2849,7 @@ static void Tst_WriteChoAnsBank (struct Tst_Question *Question, /************** Write false / true answer when seeing a test *****************/ /*****************************************************************************/ -void Tst_WriteAnsTF (char AnsTF) +void Qst_WriteAnsTF (char AnsTF) { extern const char *Txt_TF_QST[2]; @@ -2891,7 +2871,7 @@ void Tst_WriteAnsTF (char AnsTF) /*************** Write parameter with the code of a question *****************/ /*****************************************************************************/ -void Tst_WriteParamQstCod (unsigned QstInd,long QstCod) +void Qst_WriteParamQstCod (unsigned QstInd,long QstCod) { char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" @@ -2903,70 +2883,12 @@ void Tst_WriteParamQstCod (unsigned QstInd,long QstCod) /********************* Check if number of answers is one *********************/ /*****************************************************************************/ -void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question) +void Qst_CheckIfNumberOfAnswersIsOne (const struct Qst_Question *Question) { if (Question->Answer.NumOptions != 1) Err_WrongAnswerExit (); } -/*****************************************************************************/ -/************************* Get tags of a test question ***********************/ -/*****************************************************************************/ - -unsigned Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res) - { - /***** Get the tags of a question from database *****/ - return (unsigned) - DB_QuerySELECT (mysql_res,"can not get the tags of a question", - "SELECT tst_tags.TagTxt" // row[0] - " FROM tst_question_tags," - "tst_tags" - " WHERE tst_question_tags.QstCod=%ld" - " AND tst_question_tags.TagCod=tst_tags.TagCod" - " AND tst_tags.CrsCod=%ld" - " ORDER BY tst_question_tags.TagInd", - QstCod, - Gbl.Hierarchy.Crs.CrsCod); - } - -/*****************************************************************************/ -/******************** Get and write tags of a test question ******************/ -/*****************************************************************************/ - -void Tst_GetAndWriteTagsQst (long QstCod) - { - extern const char *Txt_no_tags; - unsigned NumTags; - unsigned NumTag; - MYSQL_RES *mysql_res; - MYSQL_ROW row; - - if ((NumTags = Tst_GetTagsQst (QstCod,&mysql_res))) - { - /***** Write the tags *****/ - HTM_UL_Begin ("class=\"TEST_TAG_LIST DAT_SMALL\""); - for (NumTag = 0; - NumTag < NumTags; - NumTag++) - { - row = mysql_fetch_row (mysql_res); - HTM_LI_Begin (NULL); - HTM_Txt (row[0]); - HTM_LI_End (); - } - HTM_UL_End (); - } - else - { - HTM_SPAN_Begin ("class=\"DAT_SMALL\""); - HTM_TxtF ("(%s)",Txt_no_tags); - HTM_SPAN_End (); - } - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - } - /*****************************************************************************/ /************ Get parameters for the selection of test questions *************/ /*****************************************************************************/ @@ -3008,7 +2930,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test, Test->AnswerTypes.All = Par_GetParToBool ("AllAnsTypes"); /* Get types of answer */ - Par_GetParMultiToText ("AnswerType",Test->AnswerTypes.List,Tst_MAX_BYTES_LIST_ANSWER_TYPES); + Par_GetParMultiToText ("AnswerType",Test->AnswerTypes.List,Qst_MAX_BYTES_LIST_ANSWER_TYPES); /* Check number of types of answer */ if (Tst_CountNumAnswerTypesInList (&Test->AnswerTypes) == 0) // If no types of answer selected... @@ -3021,7 +2943,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test, /* The unique allowed type of answer in a game is unique choice */ Test->AnswerTypes.All = false; snprintf (Test->AnswerTypes.List,sizeof (Test->AnswerTypes.List),"%u", - (unsigned) Tst_ANS_UNIQUE_CHOICE); + (unsigned) Qst_ANS_UNIQUE_CHOICE); break; default: break; @@ -3128,7 +3050,7 @@ static int Tst_CountNumAnswerTypesInList (const struct Tst_AnswerTypes *AnswerTy while (*Ptr) { Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT); - Tst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr); + Qst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr); NumAnsTypes++; } return NumAnsTypes; @@ -3161,30 +3083,30 @@ unsigned Tst_CountNumQuestionsInList (const char *ListQuestions) /******************** Show form to edit one test question ********************/ /*****************************************************************************/ -void Tst_ShowFormEditOneQst (void) +void Qst_ShowFormEditOneQst (void) { extern const char *Txt_Question_removed; - struct Tst_Question Question; + struct Qst_Question Question; bool PutFormToEditQuestion; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); /***** Get question data *****/ - Question.QstCod = Tst_GetParamQstCod (); + Question.QstCod = Qst_GetParamQstCod (); if (Question.QstCod > 0) // Question already exists in the database - PutFormToEditQuestion = Tst_GetQstDataFromDB (&Question); + PutFormToEditQuestion = Qst_GetQstDataFromDB (&Question); else // New question PutFormToEditQuestion = true; /***** Put form to edit question *****/ if (PutFormToEditQuestion) - Tst_PutFormEditOneQst (&Question); + Qst_PutFormEditOneQst (&Question); else Ale_ShowAlert (Ale_WARNING,Txt_Question_removed); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /*****************************************************************************/ @@ -3196,7 +3118,7 @@ void Tst_ShowFormEditOneQst (void) // 2. By clicking "Edit" icon in a listing of existing questions // 3. From the action associated to reception of a question, on error in the parameters received from the form -static void Tst_PutFormEditOneQst (struct Tst_Question *Question) +static void Qst_PutFormEditOneQst (struct Qst_Question *Question) { extern const char *Hlp_ASSESSMENT_Questions_writing_a_question; extern const char *The_ClassFormInBox[The_NUM_THEMES]; @@ -3208,7 +3130,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question) extern const char *Txt_Feedback; extern const char *Txt_optional; extern const char *Txt_Type; - extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; + extern const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES]; extern const char *Txt_Answers; extern const char *Txt_Integer_number; extern const char *Txt_Real_number_between_A_and_B_1; @@ -3225,7 +3147,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question) unsigned IndTag; unsigned NumTag; unsigned NumOpt; - Tst_AnswerType_t AnsType; + Qst_AnswerType_t AnsType; bool IsThisTag; bool TagFound; bool OptionsDisabled; @@ -3239,7 +3161,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question) if (Question->QstCod > 0) // The question already has assigned a code { Box_BoxBegin (NULL,Str_BuildStringLong (Txt_Question_code_X,Question->QstCod), - Tst_PutIconToRemoveOneQst,&Question->QstCod, + Qst_PutIconToRemoveOneQst,&Question->QstCod, Hlp_ASSESSMENT_Questions_writing_a_question,Box_NOT_CLOSABLE); Str_FreeString (); } @@ -3250,349 +3172,349 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question) /***** Begin form *****/ Frm_BeginForm (ActRcvTstQst); - Tst_PutParamQstCod (&Question->QstCod); + Qst_PutParamQstCod (&Question->QstCod); - /***** Begin table *****/ - HTM_TABLE_BeginPadding (2); // Table for this question + /***** Begin table *****/ + HTM_TABLE_BeginPadding (2); // Table for this question - /***** Help for text editor *****/ - HTM_TR_Begin (NULL); - HTM_TD_Begin ("colspan=\"2\""); - Lay_HelpPlainEditor (); - HTM_TD_End (); - HTM_TR_End (); + /***** Help for text editor *****/ + HTM_TR_Begin (NULL); + HTM_TD_Begin ("colspan=\"2\""); + Lay_HelpPlainEditor (); + HTM_TD_End (); + HTM_TR_End (); - /***** Get tags already existing for questions in current course *****/ - NumTags = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res); + /***** Get tags already existing for questions in current course *****/ + NumTags = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res); - /***** Write the tags *****/ - HTM_TR_Begin (NULL); + /***** Write the tags *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Tags); - HTM_TD_End (); + HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Tags); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LT\""); - HTM_TABLE_BeginPadding (2); // Table for tags + HTM_TD_Begin ("class=\"LT\""); + HTM_TABLE_BeginPadding (2); // Table for tags - for (IndTag = 0; - IndTag < Tag_MAX_TAGS_PER_QUESTION; - IndTag++) - { - HTM_TR_Begin (NULL); + for (IndTag = 0; + IndTag < Tag_MAX_TAGS_PER_QUESTION; + IndTag++) + { + HTM_TR_Begin (NULL); - /***** Write the tags already existing in a selector *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"SelTag%u\" name=\"SelTag%u\"" - " class=\"TAG_SEL\" onchange=\"changeTxtTag('%u')\"", - IndTag,IndTag,IndTag); - HTM_OPTION (HTM_Type_STRING,"",false,false," "); - mysql_data_seek (mysql_res,0); - TagFound = false; - for (NumTag = 1; - NumTag <= NumTags; - NumTag++) - { - row = mysql_fetch_row (mysql_res); - /* - row[0] TagCod - row[1] TagTxt - row[2] TagHidden - */ - IsThisTag = false; - if (!strcasecmp (Question->Tags.Txt[IndTag],row[1])) - { - HTM_Txt (" selected=\"selected\""); - IsThisTag = true; - TagFound = true; - } - HTM_OPTION (HTM_Type_STRING,row[1], - IsThisTag,false, - "%s",row[1]); - } - /* If it's a new tag received from the form */ - if (!TagFound && Question->Tags.Txt[IndTag][0]) - HTM_OPTION (HTM_Type_STRING,Question->Tags.Txt[IndTag], - true,false, - "%s",Question->Tags.Txt[IndTag]); - HTM_OPTION (HTM_Type_STRING,"", - false,false, - "[%s]",Txt_new_tag); - HTM_SELECT_End (); - HTM_TD_End (); + /***** Write the tags already existing in a selector *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"SelTag%u\" name=\"SelTag%u\"" + " class=\"TAG_SEL\" onchange=\"changeTxtTag('%u')\"", + IndTag,IndTag,IndTag); + HTM_OPTION (HTM_Type_STRING,"",false,false," "); + mysql_data_seek (mysql_res,0); + TagFound = false; + for (NumTag = 1; + NumTag <= NumTags; + NumTag++) + { + row = mysql_fetch_row (mysql_res); + /* + row[0] TagCod + row[1] TagTxt + row[2] TagHidden + */ + IsThisTag = false; + if (!strcasecmp (Question->Tags.Txt[IndTag],row[1])) + { + HTM_Txt (" selected=\"selected\""); + IsThisTag = true; + TagFound = true; + } + HTM_OPTION (HTM_Type_STRING,row[1], + IsThisTag,false, + "%s",row[1]); + } + /* If it's a new tag received from the form */ + if (!TagFound && Question->Tags.Txt[IndTag][0]) + HTM_OPTION (HTM_Type_STRING,Question->Tags.Txt[IndTag], + true,false, + "%s",Question->Tags.Txt[IndTag]); + HTM_OPTION (HTM_Type_STRING,"", + false,false, + "[%s]",Txt_new_tag); + HTM_SELECT_End (); + HTM_TD_End (); - /***** Input of a new tag *****/ - HTM_TD_Begin ("class=\"RM\""); - snprintf (StrTagTxt,sizeof (StrTagTxt),"TagTxt%u",IndTag); - HTM_INPUT_TEXT (StrTagTxt,Tag_MAX_CHARS_TAG,Question->Tags.Txt[IndTag], - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"%s\" class=\"TAG_TXT\" onchange=\"changeSelTag('%u')\"", - StrTagTxt,IndTag); - HTM_TD_End (); + /***** Input of a new tag *****/ + HTM_TD_Begin ("class=\"RM\""); + snprintf (StrTagTxt,sizeof (StrTagTxt),"TagTxt%u",IndTag); + HTM_INPUT_TEXT (StrTagTxt,Tag_MAX_CHARS_TAG,Question->Tags.Txt[IndTag], + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"%s\" class=\"TAG_TXT\" onchange=\"changeSelTag('%u')\"", + StrTagTxt,IndTag); + HTM_TD_End (); - HTM_TR_End (); - } + HTM_TR_End (); + } - HTM_TABLE_End (); // Table for tags - HTM_TD_End (); + HTM_TABLE_End (); // Table for tags + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_res); + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_res); - /***** Stem and image *****/ - HTM_TR_Begin (NULL); + /***** Stem and image *****/ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Stem",Txt_Wording); + /* Label */ + Frm_LabelColumn ("RT","Stem",Txt_Wording); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_TEXTAREA_Begin ("id=\"Stem\" name=\"Stem\" class=\"STEM_TEXTAREA\"" - " rows=\"5\" required=\"required\""); - HTM_Txt (Question->Stem); - HTM_TEXTAREA_End (); - HTM_BR (); - Tst_PutFormToEditQstMedia (&Question->Media,-1, - false); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_TEXTAREA_Begin ("id=\"Stem\" name=\"Stem\" class=\"STEM_TEXTAREA\"" + " rows=\"5\" required=\"required\""); + HTM_Txt (Question->Stem); + HTM_TEXTAREA_End (); + HTM_BR (); + Tst_PutFormToEditQstMedia (&Question->Media,-1, + false); - /***** Feedback *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtF ("%s (%s):",Txt_Feedback,Txt_optional); - HTM_BR (); - HTM_TEXTAREA_Begin ("name=\"Feedback\" class=\"STEM_TEXTAREA\" rows=\"2\""); - if (Question->Feedback[0]) - HTM_Txt (Question->Feedback); - HTM_TEXTAREA_End (); - HTM_LABEL_End (); - HTM_TD_End (); + /***** Feedback *****/ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtF ("%s (%s):",Txt_Feedback,Txt_optional); + HTM_BR (); + HTM_TEXTAREA_Begin ("name=\"Feedback\" class=\"STEM_TEXTAREA\" rows=\"2\""); + if (Question->Feedback[0]) + HTM_Txt (Question->Feedback); + HTM_TEXTAREA_End (); + HTM_LABEL_End (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Type of answer *****/ - HTM_TR_Begin (NULL); + /***** Type of answer *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Type); - HTM_TD_End (); + HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Type); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s LT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - for (AnsType = (Tst_AnswerType_t) 0; - AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1); - AnsType++) - { - HTM_LABEL_Begin (NULL); - HTM_INPUT_RADIO ("AnswerType",false, - "value=\"%u\"%s onclick=\"enableDisableAns(this.form);\"", - (unsigned) AnsType, - AnsType == Question->Answer.Type ? " checked=\"checked\"" : - ""); - HTM_TxtF ("%s ",Txt_TST_STR_ANSWER_TYPES[AnsType]); - HTM_LABEL_End (); - HTM_BR (); - } - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s LT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + for (AnsType = (Qst_AnswerType_t) 0; + AnsType <= (Qst_AnswerType_t) (Qst_NUM_ANS_TYPES - 1); + AnsType++) + { + HTM_LABEL_Begin (NULL); + HTM_INPUT_RADIO ("AnswerType",false, + "value=\"%u\"%s onclick=\"enableDisableAns(this.form);\"", + (unsigned) AnsType, + AnsType == Question->Answer.Type ? " checked=\"checked\"" : + ""); + HTM_TxtF ("%s ",Txt_TST_STR_ANSWER_TYPES[AnsType]); + HTM_LABEL_End (); + HTM_BR (); + } + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Answers *****/ - /* Integer answer */ - HTM_TR_Begin (NULL); + /***** Answers *****/ + /* Integer answer */ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Answers); - HTM_TD_End (); + HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Answers); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LT\""); - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColonNBSP (Txt_Integer_number); - snprintf (StrInteger,sizeof (StrInteger),"%ld",Question->Answer.Integer); - HTM_INPUT_TEXT ("AnsInt",Cns_MAX_DECIMAL_DIGITS_LONG,StrInteger, - HTM_DONT_SUBMIT_ON_CHANGE, - "size=\"11\" required=\"required\"%s", - Question->Answer.Type == Tst_ANS_INT ? "" : - " disabled=\"disabled\""); - HTM_LABEL_End (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LT\""); + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColonNBSP (Txt_Integer_number); + snprintf (StrInteger,sizeof (StrInteger),"%ld",Question->Answer.Integer); + HTM_INPUT_TEXT ("AnsInt",Cns_MAX_DECIMAL_DIGITS_LONG,StrInteger, + HTM_DONT_SUBMIT_ON_CHANGE, + "size=\"11\" required=\"required\"%s", + Question->Answer.Type == Qst_ANS_INT ? "" : + " disabled=\"disabled\""); + HTM_LABEL_End (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /* Floating point answer */ - HTM_TR_Begin (NULL); - HTM_TD_Empty (1); - HTM_TD_Begin ("class=\"LT\""); - Tst_PutFloatInputField (Txt_Real_number_between_A_and_B_1,"AnsFloatMin", - Question,0); - Tst_PutFloatInputField (Txt_Real_number_between_A_and_B_2,"AnsFloatMax", - Question,1); - HTM_TD_End (); - HTM_TR_End (); + /* Floating point answer */ + HTM_TR_Begin (NULL); + HTM_TD_Empty (1); + HTM_TD_Begin ("class=\"LT\""); + Qst_PutFloatInputField (Txt_Real_number_between_A_and_B_1,"AnsFloatMin", + Question,0); + Qst_PutFloatInputField (Txt_Real_number_between_A_and_B_2,"AnsFloatMax", + Question,1); + HTM_TD_End (); + HTM_TR_End (); - /* T/F answer */ - HTM_TR_Begin (NULL); - HTM_TD_Empty (1); - HTM_TD_Begin ("class=\"LT\""); - Tst_PutTFInputField (Question,Txt_TF_QST[0],'T'); - Tst_PutTFInputField (Question,Txt_TF_QST[1],'F'); - HTM_TD_End (); - HTM_TR_End (); + /* T/F answer */ + HTM_TR_Begin (NULL); + HTM_TD_Empty (1); + HTM_TD_Begin ("class=\"LT\""); + Qst_PutTFInputField (Question,Txt_TF_QST[0],'T'); + Qst_PutTFInputField (Question,Txt_TF_QST[1],'F'); + HTM_TD_End (); + HTM_TR_End (); - /* Questions can be shuffled? */ - HTM_TR_Begin (NULL); + /* Questions can be shuffled? */ + HTM_TR_Begin (NULL); - HTM_TD_Empty (1); + HTM_TD_Empty (1); - HTM_TD_Begin ("class=\"LT\""); - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_CHECKBOX ("Shuffle",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"Y\"%s%s", - Question->Answer.Shuffle ? " checked=\"checked\"" : - "", - Question->Answer.Type != Tst_ANS_UNIQUE_CHOICE && - Question->Answer.Type != Tst_ANS_MULTIPLE_CHOICE ? " disabled=\"disabled\"" : - ""); - HTM_Txt (Txt_Shuffle); - HTM_LABEL_End (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LT\""); + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_INPUT_CHECKBOX ("Shuffle",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"Y\"%s%s", + Question->Answer.Shuffle ? " checked=\"checked\"" : + "", + Question->Answer.Type != Qst_ANS_UNIQUE_CHOICE && + Question->Answer.Type != Qst_ANS_MULTIPLE_CHOICE ? " disabled=\"disabled\"" : + ""); + HTM_Txt (Txt_Shuffle); + HTM_LABEL_End (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /* Simple or multiple choice answers */ - HTM_TR_Begin (NULL); - HTM_TD_Empty (1); - HTM_TD_Begin ("class=\"LT\""); - HTM_TABLE_BeginPadding (2); // Table with choice answers + /* Simple or multiple choice answers */ + HTM_TR_Begin (NULL); + HTM_TD_Empty (1); + HTM_TD_Begin ("class=\"LT\""); + HTM_TABLE_BeginPadding (2); // Table with choice answers - OptionsDisabled = Question->Answer.Type != Tst_ANS_UNIQUE_CHOICE && - Question->Answer.Type != Tst_ANS_MULTIPLE_CHOICE && - Question->Answer.Type != Tst_ANS_TEXT; - for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; - NumOpt++) - { - Gbl.RowEvenOdd = NumOpt % 2; + OptionsDisabled = Question->Answer.Type != Qst_ANS_UNIQUE_CHOICE && + Question->Answer.Type != Qst_ANS_MULTIPLE_CHOICE && + Question->Answer.Type != Qst_ANS_TEXT; + for (NumOpt = 0; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; + NumOpt++) + { + Gbl.RowEvenOdd = NumOpt % 2; - AnswerHasContent = false; - if (Question->Answer.Options[NumOpt].Text) - if (Question->Answer.Options[NumOpt].Text[0] || // Text - Question->Answer.Options[NumOpt].Media.Type != Med_TYPE_NONE) // or media - AnswerHasContent = true; - DisplayRightColumn = NumOpt < 2 || // Display at least the two first options - AnswerHasContent; + AnswerHasContent = false; + if (Question->Answer.Options[NumOpt].Text) + if (Question->Answer.Options[NumOpt].Text[0] || // Text + Question->Answer.Options[NumOpt].Media.Type != Med_TYPE_NONE) // or media + AnswerHasContent = true; + DisplayRightColumn = NumOpt < 2 || // Display at least the two first options + AnswerHasContent; - HTM_TR_Begin (NULL); + HTM_TR_Begin (NULL); - /***** Left column: selectors *****/ - HTM_TD_Begin ("class=\"TEST_EDI_ANS_LEFT_COL COLOR%u\"",Gbl.RowEvenOdd); + /***** Left column: selectors *****/ + HTM_TD_Begin ("class=\"TEST_EDI_ANS_LEFT_COL COLOR%u\"",Gbl.RowEvenOdd); - /* Radio selector for unique choice answers */ - HTM_INPUT_RADIO ("AnsUni",false, - "value=\"%u\"%s%s%s onclick=\"enableDisableAns(this.form);\"", - NumOpt, - Question->Answer.Options[NumOpt].Correct ? " checked=\"checked\"" : - "", - NumOpt < 2 ? " required=\"required\"" : // First or second options required - "", - Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE ? "" : - " disabled=\"disabled\""); + /* Radio selector for unique choice answers */ + HTM_INPUT_RADIO ("AnsUni",false, + "value=\"%u\"%s%s%s onclick=\"enableDisableAns(this.form);\"", + NumOpt, + Question->Answer.Options[NumOpt].Correct ? " checked=\"checked\"" : + "", + NumOpt < 2 ? " required=\"required\"" : // First or second options required + "", + Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE ? "" : + " disabled=\"disabled\""); - /* Checkbox for multiple choice answers */ - HTM_INPUT_CHECKBOX ("AnsMulti",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"%u\"%s%s", - NumOpt, - Question->Answer.Options[NumOpt].Correct ? " checked=\"checked\"" : - "", - Question->Answer.Type == Tst_ANS_MULTIPLE_CHOICE ? "" : - " disabled=\"disabled\""); + /* Checkbox for multiple choice answers */ + HTM_INPUT_CHECKBOX ("AnsMulti",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"%u\"%s%s", + NumOpt, + Question->Answer.Options[NumOpt].Correct ? " checked=\"checked\"" : + "", + Question->Answer.Type == Qst_ANS_MULTIPLE_CHOICE ? "" : + " disabled=\"disabled\""); - HTM_TD_End (); + HTM_TD_End (); - /***** Center column: letter of the answer and expand / contract icon *****/ - HTM_TD_Begin ("class=\"%s TEST_EDI_ANS_CENTER_COL COLOR%u\"", - The_ClassFormInBox[Gbl.Prefs.Theme],Gbl.RowEvenOdd); - HTM_TxtF ("%c)",'a' + (char) NumOpt); + /***** Center column: letter of the answer and expand / contract icon *****/ + HTM_TD_Begin ("class=\"%s TEST_EDI_ANS_CENTER_COL COLOR%u\"", + The_ClassFormInBox[Gbl.Prefs.Theme],Gbl.RowEvenOdd); + HTM_TxtF ("%c)",'a' + (char) NumOpt); - /* Icon to expand (show the answer) */ - HTM_A_Begin ("href=\"\" id=\"exp_%u\"%s" - " onclick=\"toggleAnswer('%u');return false;\"", - NumOpt, - DisplayRightColumn ? " style=\"display:none;\"" : // Answer does have content ==> Hide icon - "", - NumOpt); - if (asprintf (&Title,"%s %c)",Txt_Expand,'a' + (char) NumOpt) < 0) - Err_NotEnoughMemoryExit (); - Ico_PutIcon ("caret-right.svg",Title,"ICO16x16"); - free (Title); - HTM_A_End (); + /* Icon to expand (show the answer) */ + HTM_A_Begin ("href=\"\" id=\"exp_%u\"%s" + " onclick=\"toggleAnswer('%u');return false;\"", + NumOpt, + DisplayRightColumn ? " style=\"display:none;\"" : // Answer does have content ==> Hide icon + "", + NumOpt); + if (asprintf (&Title,"%s %c)",Txt_Expand,'a' + (char) NumOpt) < 0) + Err_NotEnoughMemoryExit (); + Ico_PutIcon ("caret-right.svg",Title,"ICO16x16"); + free (Title); + HTM_A_End (); - /* Icon to contract (hide the answer) */ - HTM_A_Begin ("href=\"\" id=\"con_%u\"%s" - " onclick=\"toggleAnswer(%u);return false;\"", - NumOpt, - DisplayRightColumn ? "" : - " style=\"display:none;\"", // Answer does not have content ==> Hide icon - NumOpt); - if (asprintf (&Title,"%s %c)",Txt_Contract,'a' + (char) NumOpt) < 0) - Err_NotEnoughMemoryExit (); - Ico_PutIcon ("caret-down.svg",Title,"ICO16x16"); - free (Title); - HTM_A_End (); + /* Icon to contract (hide the answer) */ + HTM_A_Begin ("href=\"\" id=\"con_%u\"%s" + " onclick=\"toggleAnswer(%u);return false;\"", + NumOpt, + DisplayRightColumn ? "" : + " style=\"display:none;\"", // Answer does not have content ==> Hide icon + NumOpt); + if (asprintf (&Title,"%s %c)",Txt_Contract,'a' + (char) NumOpt) < 0) + Err_NotEnoughMemoryExit (); + Ico_PutIcon ("caret-down.svg",Title,"ICO16x16"); + free (Title); + HTM_A_End (); - HTM_TD_End (); + HTM_TD_End (); - /***** Right column: content of the answer *****/ - HTM_TD_Begin ("class=\"TEST_EDI_ANS_RIGHT_COL COLOR%u\"",Gbl.RowEvenOdd); - HTM_DIV_Begin ("id=\"ans_%u\"%s", - NumOpt, - DisplayRightColumn ? "" : - " style=\"display:none;\""); // Answer does not have content ==> Hide column + /***** Right column: content of the answer *****/ + HTM_TD_Begin ("class=\"TEST_EDI_ANS_RIGHT_COL COLOR%u\"",Gbl.RowEvenOdd); + HTM_DIV_Begin ("id=\"ans_%u\"%s", + NumOpt, + DisplayRightColumn ? "" : + " style=\"display:none;\""); // Answer does not have content ==> Hide column - /* Answer text */ - HTM_TEXTAREA_Begin ("name=\"AnsStr%u\" class=\"ANSWER_TEXTAREA\" rows=\"5\"%s", - NumOpt,OptionsDisabled ? " disabled=\"disabled\"" : - ""); - if (AnswerHasContent) - HTM_Txt (Question->Answer.Options[NumOpt].Text); - HTM_TEXTAREA_End (); + /* Answer text */ + HTM_TEXTAREA_Begin ("name=\"AnsStr%u\" class=\"ANSWER_TEXTAREA\" rows=\"5\"%s", + NumOpt,OptionsDisabled ? " disabled=\"disabled\"" : + ""); + if (AnswerHasContent) + HTM_Txt (Question->Answer.Options[NumOpt].Text); + HTM_TEXTAREA_End (); - /* Media */ - Tst_PutFormToEditQstMedia (&Question->Answer.Options[NumOpt].Media, - (int) NumOpt, - OptionsDisabled); + /* Media */ + Tst_PutFormToEditQstMedia (&Question->Answer.Options[NumOpt].Media, + (int) NumOpt, + OptionsDisabled); - /* Feedback */ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtF ("%s (%s):",Txt_Feedback,Txt_optional); - HTM_BR (); - HTM_TEXTAREA_Begin ("name=\"FbStr%u\" class=\"ANSWER_TEXTAREA\" rows=\"2\"%s", - NumOpt,OptionsDisabled ? " disabled=\"disabled\"" : - ""); - if (Question->Answer.Options[NumOpt].Feedback) - if (Question->Answer.Options[NumOpt].Feedback[0]) - HTM_Txt (Question->Answer.Options[NumOpt].Feedback); - HTM_TEXTAREA_End (); - HTM_LABEL_End (); + /* Feedback */ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtF ("%s (%s):",Txt_Feedback,Txt_optional); + HTM_BR (); + HTM_TEXTAREA_Begin ("name=\"FbStr%u\" class=\"ANSWER_TEXTAREA\" rows=\"2\"%s", + NumOpt,OptionsDisabled ? " disabled=\"disabled\"" : + ""); + if (Question->Answer.Options[NumOpt].Feedback) + if (Question->Answer.Options[NumOpt].Feedback[0]) + HTM_Txt (Question->Answer.Options[NumOpt].Feedback); + HTM_TEXTAREA_End (); + HTM_LABEL_End (); - /* End of right column */ - HTM_DIV_End (); - HTM_TD_End (); + /* End of right column */ + HTM_DIV_End (); + HTM_TD_End (); - HTM_TR_End (); - } - HTM_TABLE_End (); // Table with choice answers - HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); + } + HTM_TABLE_End (); // Table with choice answers + HTM_TD_End (); + HTM_TR_End (); - /***** End table *****/ - HTM_TABLE_End (); // Table for this question + /***** End table *****/ + HTM_TABLE_End (); // Table for this question - /***** Send button *****/ - if (Question->QstCod > 0) // The question already has assigned a code - Btn_PutConfirmButton (Txt_Save_changes); - else - Btn_PutCreateButton (Txt_Create_question); + /***** Send button *****/ + if (Question->QstCod > 0) // The question already has assigned a code + Btn_PutConfirmButton (Txt_Save_changes); + else + Btn_PutCreateButton (Txt_Create_question); /***** End form *****/ Frm_EndForm (); @@ -3605,22 +3527,22 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question) /********************* Put input field for floating answer *******************/ /*****************************************************************************/ -static void Tst_PutFloatInputField (const char *Label,const char *Field, - const struct Tst_Question *Question, +static void Qst_PutFloatInputField (const char *Label,const char *Field, + const struct Qst_Question *Question, unsigned Index) { extern const char *The_ClassFormInBox[The_NUM_THEMES]; char StrDouble[32]; HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtF ("%s ",Label); - snprintf (StrDouble,sizeof (StrDouble),"%.15lg", - Question->Answer.FloatingPoint[Index]); - HTM_INPUT_TEXT (Field,Tst_MAX_BYTES_FLOAT_ANSWER,StrDouble, - HTM_DONT_SUBMIT_ON_CHANGE, - "size=\"11\" required=\"required\"%s", - Question->Answer.Type == Tst_ANS_FLOAT ? "" : - " disabled=\"disabled\""); + HTM_TxtF ("%s ",Label); + snprintf (StrDouble,sizeof (StrDouble),"%.15lg", + Question->Answer.FloatingPoint[Index]); + HTM_INPUT_TEXT (Field,Qst_MAX_BYTES_FLOAT_ANSWER,StrDouble, + HTM_DONT_SUBMIT_ON_CHANGE, + "size=\"11\" required=\"required\"%s", + Question->Answer.Type == Qst_ANS_FLOAT ? "" : + " disabled=\"disabled\""); HTM_LABEL_End (); } @@ -3628,20 +3550,20 @@ static void Tst_PutFloatInputField (const char *Label,const char *Field, /*********************** Put input field for T/F answer **********************/ /*****************************************************************************/ -static void Tst_PutTFInputField (const struct Tst_Question *Question, +static void Qst_PutTFInputField (const struct Qst_Question *Question, const char *Label,char Value) { extern const char *The_ClassFormInBox[The_NUM_THEMES]; HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_RADIO ("AnsTF",false, - "value=\"%c\"%s%s required=\"required\"", - Value, - Question->Answer.TF == Value ? " checked=\"checked\"" : - "", - Question->Answer.Type == Tst_ANS_TRUE_FALSE ? "" : - " disabled=\"disabled\""); - HTM_Txt (Label); + HTM_INPUT_RADIO ("AnsTF",false, + "value=\"%c\"%s%s required=\"required\"", + Value, + Question->Answer.TF == Value ? " checked=\"checked\"" : + "", + Question->Answer.Type == Qst_ANS_TRUE_FALSE ? "" : + " disabled=\"disabled\""); + HTM_Txt (Label); HTM_LABEL_End (); } @@ -3649,7 +3571,7 @@ static void Tst_PutTFInputField (const struct Tst_Question *Question, /********************* Initialize a new question to zero *********************/ /*****************************************************************************/ -void Tst_QstConstructor (struct Tst_Question *Question) +void Qst_QstConstructor (struct Qst_Question *Question) { unsigned NumOpt; @@ -3669,7 +3591,7 @@ void Tst_QstConstructor (struct Tst_Question *Question) Question->Feedback[0] = '\0'; /***** Initialize answers *****/ - Question->Answer.Type = Tst_ANS_UNIQUE_CHOICE; + Question->Answer.Type = Qst_ANS_UNIQUE_CHOICE; Question->Answer.NumOptions = 0; Question->Answer.Shuffle = false; Question->Answer.TF = ' '; @@ -3679,7 +3601,7 @@ void Tst_QstConstructor (struct Tst_Question *Question) /* Initialize options */ for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) { Question->Answer.Options[NumOpt].Correct = false; @@ -3699,17 +3621,17 @@ void Tst_QstConstructor (struct Tst_Question *Question) Question->Score = 0.0; /***** Mark question as valid *****/ - Question->Validity = Tst_VALID_QUESTION; + Question->Validity = Qst_VALID_QUESTION; } /*****************************************************************************/ /***************** Free memory allocated for test question *******************/ /*****************************************************************************/ -void Tst_QstDestructor (struct Tst_Question *Question) +void Qst_QstDestructor (struct Qst_Question *Question) { - Tst_FreeTextChoiceAnswers (Question); - Tst_FreeMediaOfQuestion (Question); + Qst_FreeTextChoiceAnswers (Question); + Qst_FreeMediaOfQuestion (Question); if (Question->Feedback) { free (Question->Feedback); @@ -3727,7 +3649,7 @@ void Tst_QstDestructor (struct Tst_Question *Question) /*****************************************************************************/ // Return false on error -bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt) +bool Qst_AllocateTextChoiceAnswer (struct Qst_Question *Question,unsigned NumOpt) { if ((Question->Answer.Options[NumOpt].Text = malloc (Tst_MAX_BYTES_ANSWER_OR_FEEDBACK + 1)) == NULL) @@ -3753,21 +3675,21 @@ bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt /******************** Free memory of all choice answers **********************/ /*****************************************************************************/ -static void Tst_FreeTextChoiceAnswers (struct Tst_Question *Question) +static void Qst_FreeTextChoiceAnswers (struct Qst_Question *Question) { unsigned NumOpt; for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) - Tst_FreeTextChoiceAnswer (Question,NumOpt); + Qst_FreeTextChoiceAnswer (Question,NumOpt); } /*****************************************************************************/ /********************** Free memory of a choice answer ***********************/ /*****************************************************************************/ -static void Tst_FreeTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt) +static void Qst_FreeTextChoiceAnswer (struct Qst_Question *Question,unsigned NumOpt) { if (Question->Answer.Options[NumOpt].Text) { @@ -3785,7 +3707,7 @@ static void Tst_FreeTextChoiceAnswer (struct Tst_Question *Question,unsigned Num /***************** Initialize images of a question to zero *******************/ /*****************************************************************************/ -static void Tst_ResetMediaOfQuestion (struct Tst_Question *Question) +static void Qst_ResetMediaOfQuestion (struct Qst_Question *Question) { unsigned NumOpt; @@ -3794,7 +3716,7 @@ static void Tst_ResetMediaOfQuestion (struct Tst_Question *Question) /***** Reset media for every answer option *****/ for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) Med_ResetMedia (&Question->Answer.Options[NumOpt].Media); } @@ -3803,13 +3725,13 @@ static void Tst_ResetMediaOfQuestion (struct Tst_Question *Question) /*********************** Free images of a question ***************************/ /*****************************************************************************/ -static void Tst_FreeMediaOfQuestion (struct Tst_Question *Question) +static void Qst_FreeMediaOfQuestion (struct Qst_Question *Question) { unsigned NumOpt; Med_MediaDestructor (&Question->Media); for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) Med_MediaDestructor (&Question->Answer.Options[NumOpt].Media); } @@ -3818,7 +3740,7 @@ static void Tst_FreeMediaOfQuestion (struct Tst_Question *Question) /*************** Get answer type of a question from database *****************/ /*****************************************************************************/ -Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod) +Qst_AnswerType_t Qst_GetQstAnswerTypeFromDB (long QstCod) { char StrAnsTypeDB[256]; @@ -3829,14 +3751,14 @@ Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod) " FROM tst_questions" " WHERE QstCod=%ld", QstCod); - return Tst_ConvertFromStrAnsTypDBToAnsTyp (StrAnsTypeDB); + return Qst_ConvertFromStrAnsTypDBToAnsTyp (StrAnsTypeDB); } /*****************************************************************************/ /****************** Get data of a question from database *********************/ /*****************************************************************************/ -bool Tst_GetQstDataFromDB (struct Tst_Question *Question) +bool Qst_GetQstDataFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -3870,7 +3792,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) Question->EditTime = Dat_GetUNIXTimeFromStr (row[0]); /* Get the type of answer (row[1]) */ - Question->Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); + Question->Answer.Type = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); /* Get shuffle (row[2]) */ Question->Answer.Shuffle = (row[2][0] == 'Y'); @@ -3911,7 +3833,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); /***** Get the tags from the database *****/ - NumTags = Tst_GetTagsQst (Question->QstCod,&mysql_res); + NumTags = Tag_DB_GetTagsQst (&mysql_res,Question->QstCod); for (NumTag = 0; NumTag < NumTags; NumTag++) @@ -3925,7 +3847,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); /***** Get the answers from the database *****/ - Tst_GetAnswersQst (Question,&mysql_res, + Qst_GetAnswersQst (Question,&mysql_res, false); // Don't shuffle /* row[0] AnsInd @@ -3941,28 +3863,28 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) row = mysql_fetch_row (mysql_res); switch (Question->Answer.Type) { - case Tst_ANS_INT: - Tst_CheckIfNumberOfAnswersIsOne (Question); - Question->Answer.Integer = Tst_GetIntAnsFromStr (row[1]); + case Qst_ANS_INT: + Qst_CheckIfNumberOfAnswersIsOne (Question); + Question->Answer.Integer = Qst_GetIntAnsFromStr (row[1]); break; - case Tst_ANS_FLOAT: + case Qst_ANS_FLOAT: if (Question->Answer.NumOptions != 2) Err_WrongAnswerExit (); Question->Answer.FloatingPoint[NumOpt] = Str_GetDoubleFromStr (row[1]); break; - case Tst_ANS_TRUE_FALSE: - Tst_CheckIfNumberOfAnswersIsOne (Question); + case Qst_ANS_TRUE_FALSE: + Qst_CheckIfNumberOfAnswersIsOne (Question); Question->Answer.TF = row[1][0]; break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: - case Tst_ANS_TEXT: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_TEXT: /* Check number of options */ - if (Question->Answer.NumOptions > Tst_MAX_OPTIONS_PER_QUESTION) + if (Question->Answer.NumOptions > Qst_MAX_OPTIONS_PER_QUESTION) Err_WrongAnswerExit (); /* Allocate space for text and feedback */ - if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) + if (!Qst_AllocateTextChoiceAnswer (Question,NumOpt)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -4003,7 +3925,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) // NumOpt < 0 ==> media associated to stem // NumOpt >= 0 ==> media associated to answer -static long Tst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt) +static long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt) { /***** Trivial check: question code should be > 0 *****/ if (QstCod <= 0) @@ -4038,7 +3960,7 @@ static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt, struct Med_Media *Media) { /***** Get media *****/ - Media->MedCod = Tst_GetMedCodFromDB (CrsCod,QstCod,NumOpt); + Media->MedCod = Qst_GetMedCodFromDB (CrsCod,QstCod,NumOpt); Med_GetMediaDataByCod (Media); } @@ -4046,41 +3968,41 @@ static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt, /** Convert a string with the type of answer in database to type of answer ***/ /*****************************************************************************/ -Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB) +Qst_AnswerType_t Qst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB) { - Tst_AnswerType_t AnsType; + Qst_AnswerType_t AnsType; if (StrAnsTypeDB != NULL) if (StrAnsTypeDB[0]) - for (AnsType = (Tst_AnswerType_t) 0; - AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1); + for (AnsType = (Qst_AnswerType_t) 0; + AnsType <= (Qst_AnswerType_t) (Qst_NUM_ANS_TYPES - 1); AnsType++) if (!strcmp (StrAnsTypeDB,Tst_StrAnswerTypesDB[AnsType])) return AnsType; - return Tst_ANS_UNKNOWN; + return Qst_ANS_UNKNOWN; } /*****************************************************************************/ /************ Convert a string with an unsigned to answer type ***************/ /*****************************************************************************/ -static Tst_AnswerType_t Tst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr) +static Qst_AnswerType_t Qst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr) { unsigned AnsType; if (sscanf (UnsignedStr,"%u",&AnsType) != 1) Err_WrongAnswerExit (); - if (AnsType >= Tst_NUM_ANS_TYPES) + if (AnsType >= Qst_NUM_ANS_TYPES) Err_WrongAnswerExit (); - return (Tst_AnswerType_t) AnsType; + return (Qst_AnswerType_t) AnsType; } /*****************************************************************************/ -/*************** Receive a question of the self-assessment test **************/ +/***************************** Receive a question ****************************/ /*****************************************************************************/ -void Tst_ReceiveQst (void) +void Qst_ReceiveQst (void) { struct Tst_Test Test; @@ -4088,16 +4010,16 @@ void Tst_ReceiveQst (void) Tst_TstConstructor (&Test); /***** Get parameters of the question from form *****/ - Tst_GetQstFromForm (&Test.Question); + Qst_GetQstFromForm (&Test.Question); /***** Make sure that tags, text and answer are not empty *****/ - if (Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (&Test.Question)) + if (Qst_CheckIfQstFormatIsCorrectAndCountNumOptions (&Test.Question)) { /***** Move images to definitive directories *****/ - Tst_MoveMediaToDefinitiveDirectories (&Test.Question); + Qst_MoveMediaToDefinitiveDirectories (&Test.Question); /***** Insert or update question, tags and answer in the database *****/ - Tst_InsertOrUpdateQstTagsAnsIntoDB (&Test.Question); + Qst_InsertOrUpdateQstTagsAnsIntoDB (&Test.Question); /***** Show the question just inserted in the database *****/ snprintf (Test.AnswerTypes.List,sizeof (Test.AnswerTypes.List),"%u", @@ -4107,10 +4029,10 @@ void Tst_ReceiveQst (void) else // Question is wrong { /***** Whether images has been received or not, reset images *****/ - Tst_ResetMediaOfQuestion (&Test.Question); + Qst_ResetMediaOfQuestion (&Test.Question); /***** Put form to edit question again *****/ - Tst_PutFormEditOneQst (&Test.Question); + Qst_PutFormEditOneQst (&Test.Question); } /***** Destroy test *****/ @@ -4121,7 +4043,7 @@ void Tst_ReceiveQst (void) /**************** Get parameters of a test question from form ****************/ /*****************************************************************************/ -static void Tst_GetQstFromForm (struct Tst_Question *Question) +static void Qst_GetQstFromForm (struct Qst_Question *Question) { unsigned NumTag; unsigned NumTagRead; @@ -4130,21 +4052,21 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) char TagStr[6 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char AnsStr[6 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char FbStr[5 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; - char StrMultiAns[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; + char StrMultiAns[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; char TF[1 + 1]; // (T)rue or (F)alse const char *Ptr; unsigned NumCorrectAns; /***** Get question code *****/ - Question->QstCod = Tst_GetParamQstCod (); + Question->QstCod = Qst_GetParamQstCod (); /***** Get answer type *****/ - Question->Answer.Type = (Tst_AnswerType_t) + Question->Answer.Type = (Qst_AnswerType_t) Par_GetParToUnsignedLong ("AnswerType", 0, - Tst_NUM_ANS_TYPES - 1, - (unsigned long) Tst_ANS_UNKNOWN); - if (Question->Answer.Type == Tst_ANS_UNKNOWN) + Qst_NUM_ANS_TYPES - 1, + (unsigned long) Qst_ANS_UNKNOWN); + if (Question->Answer.Type == Qst_ANS_UNKNOWN) Err_WrongAnswerExit (); /***** Get question tags *****/ @@ -4192,46 +4114,46 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) Question->Answer.Shuffle = false; switch (Question->Answer.Type) { - case Tst_ANS_INT: - if (!Tst_AllocateTextChoiceAnswer (Question,0)) + case Qst_ANS_INT: + if (!Qst_AllocateTextChoiceAnswer (Question,0)) /* Abort on error */ Ale_ShowAlertsAndExit (); Par_GetParToText ("AnsInt",Question->Answer.Options[0].Text, Cns_MAX_DECIMAL_DIGITS_LONG); break; - case Tst_ANS_FLOAT: - if (!Tst_AllocateTextChoiceAnswer (Question,0)) + case Qst_ANS_FLOAT: + if (!Qst_AllocateTextChoiceAnswer (Question,0)) /* Abort on error */ Ale_ShowAlertsAndExit (); Par_GetParToText ("AnsFloatMin",Question->Answer.Options[0].Text, - Tst_MAX_BYTES_FLOAT_ANSWER); + Qst_MAX_BYTES_FLOAT_ANSWER); - if (!Tst_AllocateTextChoiceAnswer (Question,1)) + if (!Qst_AllocateTextChoiceAnswer (Question,1)) /* Abort on error */ Ale_ShowAlertsAndExit (); Par_GetParToText ("AnsFloatMax",Question->Answer.Options[1].Text, - Tst_MAX_BYTES_FLOAT_ANSWER); + Qst_MAX_BYTES_FLOAT_ANSWER); break; - case Tst_ANS_TRUE_FALSE: + case Qst_ANS_TRUE_FALSE: Par_GetParToText ("AnsTF",TF,1); Question->Answer.TF = TF[0]; break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: /* Get shuffle */ Question->Answer.Shuffle = Par_GetParToBool ("Shuffle"); /* falls through */ /* no break */ - case Tst_ANS_TEXT: + case Qst_ANS_TEXT: /* Get the texts of the answers */ for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) { - if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) + if (!Qst_AllocateTextChoiceAnswer (Question,NumOpt)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -4239,7 +4161,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) snprintf (AnsStr,sizeof (AnsStr),"AnsStr%u",NumOpt); Par_GetParToHTML (AnsStr,Question->Answer.Options[NumOpt].Text, Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); - if (Question->Answer.Type == Tst_ANS_TEXT) + if (Question->Answer.Type == Qst_ANS_TEXT) /* In order to compare student answer to stored answer, the text answers are stored avoiding two or more consecurive spaces */ Str_ReplaceSeveralSpacesForOne (Question->Answer.Options[NumOpt].Text); @@ -4250,8 +4172,8 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); /* Get media associated to the answer (action, file and title) */ - if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE || - Question->Answer.Type == Tst_ANS_MULTIPLE_CHOICE) + if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE || + Question->Answer.Type == Qst_ANS_MULTIPLE_CHOICE) { Question->Answer.Options[NumOpt].Media.Width = Tst_IMAGE_SAVED_MAX_WIDTH; Question->Answer.Options[NumOpt].Media.Height = Tst_IMAGE_SAVED_MAX_HEIGHT; @@ -4266,31 +4188,31 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) } /* Get the numbers of correct answers */ - if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE) + if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE) { NumCorrectAns = (unsigned) Par_GetParToUnsignedLong ("AnsUni", 0, - Tst_MAX_OPTIONS_PER_QUESTION - 1, + Qst_MAX_OPTIONS_PER_QUESTION - 1, 0); Question->Answer.Options[NumCorrectAns].Correct = true; } - else if (Question->Answer.Type == Tst_ANS_MULTIPLE_CHOICE) + else if (Question->Answer.Type == Qst_ANS_MULTIPLE_CHOICE) { - Par_GetParMultiToText ("AnsMulti",StrMultiAns,Tst_MAX_BYTES_ANSWERS_ONE_QST); + Par_GetParMultiToText ("AnsMulti",StrMultiAns,Qst_MAX_BYTES_ANSWERS_ONE_QST); Ptr = StrMultiAns; while (*Ptr) { Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT); if (sscanf (UnsignedStr,"%u",&NumCorrectAns) != 1) Err_WrongAnswerExit (); - if (NumCorrectAns >= Tst_MAX_OPTIONS_PER_QUESTION) + if (NumCorrectAns >= Qst_MAX_OPTIONS_PER_QUESTION) Err_WrongAnswerExit (); Question->Answer.Options[NumCorrectAns].Correct = true; } } else // Tst_ANS_TEXT for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) if (Question->Answer.Options[NumOpt].Text[0]) Question->Answer.Options[NumOpt].Correct = true; // All the answers are correct @@ -4314,7 +4236,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) // Counts Question->Answer.NumOptions // Computes Question->Answer.Integer and Question->Answer.FloatingPoint[0..1] -bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Question) +bool Qst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Qst_Question *Question) { extern const char *Txt_You_must_type_at_least_one_tag_for_the_question; extern const char *Txt_You_must_type_the_stem_of_the_question; @@ -4351,7 +4273,7 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Quest /***** Check answer *****/ switch (Question->Answer.Type) { - case Tst_ANS_INT: + case Qst_ANS_INT: /* First option should be filled */ if (!Question->Answer.Options[0].Text) { @@ -4364,10 +4286,10 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Quest return false; } - Question->Answer.Integer = Tst_GetIntAnsFromStr (Question->Answer.Options[0].Text); + Question->Answer.Integer = Qst_GetIntAnsFromStr (Question->Answer.Options[0].Text); Question->Answer.NumOptions = 1; break; - case Tst_ANS_FLOAT: + case Qst_ANS_FLOAT: /* First two options should be filled */ if (!Question->Answer.Options[0].Text || !Question->Answer.Options[1].Text) @@ -4396,7 +4318,7 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Quest Question->Answer.NumOptions = 2; break; - case Tst_ANS_TRUE_FALSE: + case Qst_ANS_TRUE_FALSE: /* Answer should be 'T' or 'F' */ if (Question->Answer.TF != 'T' && Question->Answer.TF != 'F') @@ -4407,11 +4329,11 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Quest Question->Answer.NumOptions = 1; break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: /* No option should be empty before a non-empty option */ for (NumOpt = 0, NumLastOpt = 0, ThereIsEndOfAnswers = false; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) if (Question->Answer.Options[NumOpt].Text) { @@ -4451,7 +4373,7 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Quest return false; } break; - case Tst_ANS_TEXT: + case Qst_ANS_TEXT: /* First option should be filled */ if (!Question->Answer.Options[0].Text) // If the first answer is empty { @@ -4466,7 +4388,7 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Quest /* No option should be empty before a non-empty option */ for (NumOpt=0, ThereIsEndOfAnswers=false; - NumOptAnswer.Options[NumOpt].Text) { @@ -4496,9 +4418,9 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Quest /*********** Check if a test question already exists in database *************/ /*****************************************************************************/ -bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question) +bool Qst_CheckIfQuestionExistsInDB (struct Qst_Question *Question) { - extern const char *Tst_StrAnswerTypesDB[Tst_NUM_ANS_TYPES]; + extern const char *Tst_StrAnswerTypesDB[Qst_NUM_ANS_TYPES]; MYSQL_RES *mysql_res_qst; MYSQL_RES *mysql_res_ans; MYSQL_ROW row; @@ -4547,11 +4469,11 @@ bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question) switch (Question->Answer.Type) { - case Tst_ANS_INT: + case Qst_ANS_INT: row = mysql_fetch_row (mysql_res_ans); - IdenticalQuestionFound = (Tst_GetIntAnsFromStr (row[0]) == Question->Answer.Integer); + IdenticalQuestionFound = (Qst_GetIntAnsFromStr (row[0]) == Question->Answer.Integer); break; - case Tst_ANS_FLOAT: + case Qst_ANS_FLOAT: for (IdenticalAnswers = true, i = 0; IdenticalAnswers && i < 2; i++) @@ -4561,13 +4483,13 @@ bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question) } IdenticalQuestionFound = IdenticalAnswers; break; - case Tst_ANS_TRUE_FALSE: + case Qst_ANS_TRUE_FALSE: row = mysql_fetch_row (mysql_res_ans); IdenticalQuestionFound = (Str_ConvertToUpperLetter (row[0][0]) == Question->Answer.TF); break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: - case Tst_ANS_TEXT: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_TEXT: if (NumOptsExistingQstInDB == Question->Answer.NumOptions) { for (IdenticalAnswers = true, NumOpt = 0; @@ -4605,26 +4527,26 @@ bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question) /* Move images associates to a test question to their definitive directories */ /*****************************************************************************/ -static void Tst_MoveMediaToDefinitiveDirectories (struct Tst_Question *Question) +static void Qst_MoveMediaToDefinitiveDirectories (struct Qst_Question *Question) { unsigned NumOpt; long CurrentMedCodInDB; /***** Media associated to question stem *****/ - CurrentMedCodInDB = Tst_GetMedCodFromDB (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod, + CurrentMedCodInDB = Qst_GetMedCodFromDB (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod, -1L); // Get current media code associated to stem Med_RemoveKeepOrStoreMedia (CurrentMedCodInDB,&Question->Media); /****** Move media associated to answers *****/ switch (Question->Answer.Type) { - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: for (NumOpt = 0; NumOpt < Question->Answer.NumOptions; NumOpt++) { - CurrentMedCodInDB = Tst_GetMedCodFromDB (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod, + CurrentMedCodInDB = Qst_GetMedCodFromDB (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod, NumOpt); // Get current media code associated to this option Med_RemoveKeepOrStoreMedia (CurrentMedCodInDB,&Question->Answer.Options[NumOpt].Media); } @@ -4638,7 +4560,7 @@ static void Tst_MoveMediaToDefinitiveDirectories (struct Tst_Question *Question) /******************** Get a integer number from a string *********************/ /*****************************************************************************/ -long Tst_GetIntAnsFromStr (char *Str) +long Qst_GetIntAnsFromStr (char *Str) { long LongNum; @@ -4659,7 +4581,7 @@ long Tst_GetIntAnsFromStr (char *Str) /***************** Request the removal of selected questions *****************/ /*****************************************************************************/ -void Tst_RequestRemoveSelectedQsts (void) +void Qst_RequestRemoveSelectedQsts (void) { extern const char *Txt_Do_you_really_want_to_remove_the_selected_questions; extern const char *Txt_Remove_questions; @@ -4673,7 +4595,7 @@ void Tst_RequestRemoveSelectedQsts (void) { /***** Show question and button to remove question *****/ Ale_ShowAlertAndButton (ActRemSevTstQst,NULL,NULL, - Tst_PutParamsEditQst,&Test, + Qst_PutParamsEditQst,&Test, Btn_REMOVE_BUTTON,Txt_Remove_questions, Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_selected_questions); } @@ -4681,7 +4603,7 @@ void Tst_RequestRemoveSelectedQsts (void) Ale_ShowAlert (Ale_ERROR,"Wrong parameters."); /***** Continue editing questions *****/ - Tst_ListQuestionsToEdit (); + Qst_ListQuestionsToEdit (); /***** Destroy test *****/ Tst_TstDestructor (&Test); @@ -4691,7 +4613,7 @@ void Tst_RequestRemoveSelectedQsts (void) /************************** Remove several questions *************************/ /*****************************************************************************/ -void Tst_RemoveSelectedQsts (void) +void Qst_RemoveSelectedQsts (void) { extern const char *Txt_Questions_removed_X; struct Tst_Test Test; @@ -4707,7 +4629,7 @@ void Tst_RemoveSelectedQsts (void) if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters { /***** Get question codes *****/ - Tst_GetQuestions (&Test,&mysql_res); // Query database + Qst_GetQuestions (&Test,&mysql_res); // Query database /***** Remove questions one by one *****/ for (NumQst = 0; @@ -4720,7 +4642,7 @@ void Tst_RemoveSelectedQsts (void) Err_WrongQuestionExit (); /* Remove test question from database */ - Tst_RemoveOneQstFromDB (Gbl.Hierarchy.Crs.CrsCod,QstCod); + Qst_RemoveOneQstFromDB (Gbl.Hierarchy.Crs.CrsCod,QstCod); } /***** Free structure that stores the query result *****/ @@ -4738,17 +4660,17 @@ void Tst_RemoveSelectedQsts (void) /********************* Put icon to remove one question ***********************/ /*****************************************************************************/ -static void Tst_PutIconToRemoveOneQst (void *QstCod) +static void Qst_PutIconToRemoveOneQst (void *QstCod) { Ico_PutContextualIconToRemove (ActReqRemOneTstQst,NULL, - Tst_PutParamsRemoveOnlyThisQst,QstCod); + Qst_PutParamsRemoveOnlyThisQst,QstCod); } /*****************************************************************************/ /******************** Request the removal of a question **********************/ /*****************************************************************************/ -void Tst_RequestRemoveOneQst (void) +void Qst_RequestRemoveOneQst (void) { extern const char *Txt_Do_you_really_want_to_remove_the_question_X; extern const char *Txt_Remove_question; @@ -4760,7 +4682,7 @@ void Tst_RequestRemoveOneQst (void) /***** Get main parameters from form *****/ /* Get the question code */ - Test.Question.QstCod = Tst_GetParamQstCod (); + Test.Question.QstCod = Qst_GetParamQstCod (); if (Test.Question.QstCod <= 0) Err_WrongQuestionExit (); @@ -4776,13 +4698,13 @@ void Tst_RequestRemoveOneQst (void) /***** Show question and button to remove question *****/ if (EditingOnlyThisQst) Ale_ShowAlertAndButton (ActRemOneTstQst,NULL,NULL, - Tst_PutParamsRemoveOnlyThisQst,&Test.Question.QstCod, + Qst_PutParamsRemoveOnlyThisQst,&Test.Question.QstCod, Btn_REMOVE_BUTTON,Txt_Remove_question, Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_question_X, Test.Question.QstCod); else Ale_ShowAlertAndButton (ActRemOneTstQst,NULL,NULL, - Tst_PutParamsEditQst,&Test, + Qst_PutParamsEditQst,&Test, Btn_REMOVE_BUTTON,Txt_Remove_question, Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_question_X, Test.Question.QstCod); @@ -4791,7 +4713,7 @@ void Tst_RequestRemoveOneQst (void) if (EditingOnlyThisQst) Tst_ListOneQstToEdit (&Test); else - Tst_ListQuestionsToEdit (); + Qst_ListQuestionsToEdit (); /***** Destroy test *****/ Tst_TstDestructor (&Test); @@ -4801,11 +4723,11 @@ void Tst_RequestRemoveOneQst (void) /***** Put parameters to remove question when editing only one question ******/ /*****************************************************************************/ -static void Tst_PutParamsRemoveOnlyThisQst (void *QstCod) +static void Qst_PutParamsRemoveOnlyThisQst (void *QstCod) { if (QstCod) { - Tst_PutParamQstCod (QstCod); + Qst_PutParamQstCod (QstCod); Par_PutHiddenParamChar ("OnlyThisQst",'Y'); } } @@ -4814,14 +4736,14 @@ static void Tst_PutParamsRemoveOnlyThisQst (void *QstCod) /***************************** Remove a question *****************************/ /*****************************************************************************/ -void Tst_RemoveOneQst (void) +void Qst_RemoveOneQst (void) { extern const char *Txt_Question_removed; long QstCod; bool EditingOnlyThisQst; /***** Get the question code *****/ - QstCod = Tst_GetParamQstCod (); + QstCod = Qst_GetParamQstCod (); if (QstCod <= 0) Err_WrongQuestionExit (); @@ -4830,29 +4752,29 @@ void Tst_RemoveOneQst (void) EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst"); /***** Remove test question from database *****/ - Tst_RemoveOneQstFromDB (Gbl.Hierarchy.Crs.CrsCod,QstCod); + Qst_RemoveOneQstFromDB (Gbl.Hierarchy.Crs.CrsCod,QstCod); /***** Write message *****/ Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed); /***** Continue editing questions *****/ if (!EditingOnlyThisQst) - Tst_ListQuestionsToEdit (); + Qst_ListQuestionsToEdit (); } /*****************************************************************************/ /********************** Remove a question from database **********************/ /*****************************************************************************/ -static void Tst_RemoveOneQstFromDB (long CrsCod,long QstCod) +static void Qst_RemoveOneQstFromDB (long CrsCod,long QstCod) { /***** Remove media associated to question *****/ - Tst_RemoveMediaFromStemOfQst (CrsCod,QstCod); - Tst_RemoveMediaFromAllAnsOfQst (CrsCod,QstCod); + Qst_RemoveMediaFromStemOfQst (CrsCod,QstCod); + Qst_RemoveMediaFromAllAnsOfQst (CrsCod,QstCod); /***** Remove the question from all the tables *****/ /* Remove answers and tags from this test question */ - Tst_RemAnsFromQst (QstCod); + Qst_RemAnsFromQst (QstCod); Tag_DB_RemTagsFromQst (QstCod); Tag_DB_RemoveUnusedTagsFromCrs (CrsCod); @@ -4869,7 +4791,7 @@ static void Tst_RemoveOneQstFromDB (long CrsCod,long QstCod) /*********************** Change the shuffle of a question ********************/ /*****************************************************************************/ -void Tst_ChangeShuffleQst (void) +void Qst_ChangeShuffleQst (void) { extern const char *Txt_The_answers_of_the_question_with_code_X_will_appear_shuffled; extern const char *Txt_The_answers_of_the_question_with_code_X_will_appear_without_shuffling; @@ -4881,7 +4803,7 @@ void Tst_ChangeShuffleQst (void) Tst_TstConstructor (&Test); /***** Get the question code *****/ - Test.Question.QstCod = Tst_GetParamQstCod (); + Test.Question.QstCod = Qst_GetParamQstCod (); if (Test.Question.QstCod <= 0) Err_WrongQuestionExit (); @@ -4912,7 +4834,7 @@ void Tst_ChangeShuffleQst (void) if (EditingOnlyThisQst) Tst_ListOneQstToEdit (&Test); else - Tst_ListQuestionsToEdit (); + Qst_ListQuestionsToEdit (); /***** Destroy test *****/ Tst_TstDestructor (&Test); @@ -4922,7 +4844,7 @@ void Tst_ChangeShuffleQst (void) /************ Get the parameter with the code of a test question *************/ /*****************************************************************************/ -long Tst_GetParamQstCod (void) +long Qst_GetParamQstCod (void) { /***** Get code of test question *****/ return Par_GetParToLong ("QstCod"); @@ -4932,7 +4854,7 @@ long Tst_GetParamQstCod (void) /************ Put parameter with question code to edit, remove... ************/ /*****************************************************************************/ -void Tst_PutParamQstCod (void *QstCod) // Should be a pointer to long +void Qst_PutParamQstCod (void *QstCod) // Should be a pointer to long { if (QstCod) if (*((long *) QstCod) > 0) // If question exists @@ -4943,10 +4865,10 @@ void Tst_PutParamQstCod (void *QstCod) // Should be a pointer to long /******** Insert or update question, tags and answer in the database *********/ /*****************************************************************************/ -void Tst_InsertOrUpdateQstTagsAnsIntoDB (struct Tst_Question *Question) +void Qst_InsertOrUpdateQstTagsAnsIntoDB (struct Qst_Question *Question) { /***** Insert or update question in the table of questions *****/ - Tst_InsertOrUpdateQstIntoDB (Question); + Qst_InsertOrUpdateQstIntoDB (Question); if (Question->QstCod > 0) { @@ -4957,7 +4879,7 @@ void Tst_InsertOrUpdateQstTagsAnsIntoDB (struct Tst_Question *Question) Tag_DB_RemoveUnusedTagsFromCrs (Gbl.Hierarchy.Crs.CrsCod); /***** Insert answers in the answers table *****/ - Tst_InsertAnswersIntoDB (Question); + Qst_InsertAnswersIntoDB (Question); } } @@ -4965,7 +4887,7 @@ void Tst_InsertOrUpdateQstTagsAnsIntoDB (struct Tst_Question *Question) /*********** Insert or update question in the table of questions *************/ /*****************************************************************************/ -static void Tst_InsertOrUpdateQstIntoDB (struct Tst_Question *Question) +static void Qst_InsertOrUpdateQstIntoDB (struct Qst_Question *Question) { if (Question->QstCod < 0) // It's a new question { @@ -5026,7 +4948,7 @@ static void Tst_InsertOrUpdateQstIntoDB (struct Tst_Question *Question) Gbl.Hierarchy.Crs.CrsCod); /* Remove answers and tags from this test question */ - Tst_RemAnsFromQst (Question->QstCod); + Qst_RemAnsFromQst (Question->QstCod); Tag_DB_RemTagsFromQst (Question->QstCod); } } @@ -5035,7 +4957,7 @@ static void Tst_InsertOrUpdateQstIntoDB (struct Tst_Question *Question) /******************* Insert answers in the answers table *********************/ /*****************************************************************************/ -static void Tst_InsertAnswersIntoDB (struct Tst_Question *Question) +static void Qst_InsertAnswersIntoDB (struct Qst_Question *Question) { unsigned NumOpt; unsigned i; @@ -5043,7 +4965,7 @@ static void Tst_InsertAnswersIntoDB (struct Tst_Question *Question) /***** Insert answers in the answers table *****/ switch (Question->Answer.Type) { - case Tst_ANS_INT: + case Qst_ANS_INT: DB_QueryINSERT ("can not create answer", "INSERT INTO tst_answers" " (QstCod,AnsInd,Answer,Feedback,MedCod,Correct)" @@ -5052,7 +4974,7 @@ static void Tst_InsertAnswersIntoDB (struct Tst_Question *Question) Question->QstCod, Question->Answer.Integer); break; - case Tst_ANS_FLOAT: + case Qst_ANS_FLOAT: Str_SetDecimalPointToUS (); // To print the floating point as a dot for (i = 0; i < 2; @@ -5067,7 +4989,7 @@ static void Tst_InsertAnswersIntoDB (struct Tst_Question *Question) Question->Answer.FloatingPoint[i]); Str_SetDecimalPointToLocal (); // Return to local system break; - case Tst_ANS_TRUE_FALSE: + case Qst_ANS_TRUE_FALSE: DB_QueryINSERT ("can not create answer", "INSERT INTO tst_answers" " (QstCod,AnsInd,Answer,Feedback,MedCod,Correct)" @@ -5076,9 +4998,9 @@ static void Tst_InsertAnswersIntoDB (struct Tst_Question *Question) Question->QstCod, Question->Answer.TF); break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: - case Tst_ANS_TEXT: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_TEXT: for (NumOpt = 0; NumOpt < Question->Answer.NumOptions; NumOpt++) @@ -5135,7 +5057,7 @@ void Tst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion) } /*****************************************************************************/ -/******************* Remove all test questions in a course *******************/ +/**************** Remove all tests and questions in a course *****************/ /*****************************************************************************/ void Tst_RemoveCrsTests (long CrsCod) @@ -5167,8 +5089,8 @@ void Tst_RemoveCrsTests (long CrsCod) CrsCod); /***** Remove media associated to test questions in the course *****/ - Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (CrsCod); - Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (CrsCod); + Qst_RemoveAllMedFilesFromStemOfAllQstsInCrs (CrsCod); + Qst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (CrsCod); /***** Remove test answers in the course *****/ DB_QueryDELETE ("can not remove answers of tests of a course", @@ -5190,7 +5112,7 @@ void Tst_RemoveCrsTests (long CrsCod) /******************** Remove answers from a test question ********************/ /*****************************************************************************/ -static void Tst_RemAnsFromQst (long QstCod) +static void Qst_RemAnsFromQst (long QstCod) { /***** Remove answers *****/ DB_QueryDELETE ("can not remove the answers of a question", @@ -5203,7 +5125,7 @@ static void Tst_RemAnsFromQst (long QstCod) /************ Remove media associated to stem of a test question *************/ /*****************************************************************************/ -static void Tst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod) +static void Qst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod) { MYSQL_RES *mysql_res; unsigned NumMedia; @@ -5228,7 +5150,7 @@ static void Tst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod) /******* Remove all media associated to all answers of a test question *******/ /*****************************************************************************/ -static void Tst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod) +static void Qst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod) { MYSQL_RES *mysql_res; unsigned NumMedia; @@ -5258,7 +5180,7 @@ static void Tst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod) /** Remove all media associated to stems of all test questions in a course ***/ /*****************************************************************************/ -static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod) +static void Qst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod) { MYSQL_RES *mysql_res; unsigned NumMedia; @@ -5282,7 +5204,7 @@ static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod) /* Remove media associated to all answers of all test questions in a course **/ /*****************************************************************************/ -static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod) +static void Qst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod) { MYSQL_RES *mysql_res; unsigned NumMedia; @@ -5308,7 +5230,7 @@ static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod) /*********************** Get stats about test questions **********************/ /*****************************************************************************/ -void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats) +void Tst_GetTestStats (Qst_AnswerType_t AnsType,struct Tst_Stats *Stats) { Stats->NumQsts = 0; Stats->NumCoursesWithQuestions = Stats->NumCoursesWithPluggableQuestions = 0; @@ -5319,11 +5241,11 @@ void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats) Stats->TotalScore = 0.0; Stats->AvgScorePerQuestion = 0.0; - if (Tst_GetNumTstQuestions (Gbl.Scope.Current,AnsType,Stats)) + if (Qst_GetNumQuestions (Gbl.Scope.Current,AnsType,Stats)) { - if ((Stats->NumCoursesWithQuestions = Tst_GetNumCoursesWithTstQuestions (Gbl.Scope.Current,AnsType)) != 0) + if ((Stats->NumCoursesWithQuestions = Qst_GetNumCoursesWithQuestions (Gbl.Scope.Current,AnsType)) != 0) { - Stats->NumCoursesWithPluggableQuestions = Tst_GetNumCoursesWithPluggableTstQuestions (Gbl.Scope.Current,AnsType); + Stats->NumCoursesWithPluggableQuestions = Qst_GetNumCoursesWithPluggableQuestions (Gbl.Scope.Current,AnsType); Stats->AvgQstsPerCourse = (double) Stats->NumQsts / (double) Stats->NumCoursesWithQuestions; Stats->AvgHitsPerCourse = (double) Stats->NumHits / (double) Stats->NumCoursesWithQuestions; } @@ -5339,7 +5261,7 @@ void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats) // Returns the number of test questions // in this location (all the platform, current degree or current course) -static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t AnsType,struct Tst_Stats *Stats) +static unsigned Qst_GetNumQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType,struct Tst_Stats *Stats) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -5348,7 +5270,7 @@ static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t An switch (Scope) { case HieLvl_SYS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*)," // row[0] "SUM(NumHits)," // row[1] @@ -5364,7 +5286,7 @@ static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t An Tst_StrAnswerTypesDB[AnsType]); break; case HieLvl_CTY: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*)," // row[0] "SUM(NumHits)," // row[1] @@ -5400,7 +5322,7 @@ static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t An Tst_StrAnswerTypesDB[AnsType]); break; case HieLvl_INS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*)," // row[0] "SUM(NumHits)," // row[1] @@ -5432,7 +5354,7 @@ static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t An Tst_StrAnswerTypesDB[AnsType]); break; case HieLvl_CTR: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*)," // row[0] "SUM(NumHits)," // row[1] @@ -5460,7 +5382,7 @@ static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t An Tst_StrAnswerTypesDB[AnsType]); break; case HieLvl_DEG: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*)," // row[0] "SUM(NumHits)," // row[1] @@ -5484,7 +5406,7 @@ static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t An Tst_StrAnswerTypesDB[AnsType]); break; case HieLvl_CRS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type DB_QuerySELECT (&mysql_res,"can not get number of test questions", "SELECT COUNT(*)," // row[0] "SUM(NumHits)," // row[1] @@ -5541,13 +5463,13 @@ static unsigned Tst_GetNumTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t An // Returns the number of courses with test questions // in this location (all the platform, current degree or current course) -static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t AnsType) +static unsigned Qst_GetNumCoursesWithQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType) { /***** Get number of courses with test questions from database *****/ switch (Scope) { case HieLvl_SYS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with test questions", "SELECT COUNT(DISTINCT CrsCod)" @@ -5560,7 +5482,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_Answ " WHERE AnsType='%s'", Tst_StrAnswerTypesDB[AnsType]); case HieLvl_CTY: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5593,7 +5515,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_Answ Gbl.Hierarchy.Cty.CtyCod, Tst_StrAnswerTypesDB[AnsType]); case HieLvl_INS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5622,7 +5544,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_Answ Gbl.Hierarchy.Ins.InsCod, Tst_StrAnswerTypesDB[AnsType]); case HieLvl_CTR: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5647,7 +5569,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_Answ Gbl.Hierarchy.Ctr.CtrCod, Tst_StrAnswerTypesDB[AnsType]); case HieLvl_DEG: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with test questions", "SELECT COUNTDISTINCT (tst_questions.CrsCod)" @@ -5668,7 +5590,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_Answ Gbl.Hierarchy.Deg.DegCod, Tst_StrAnswerTypesDB[AnsType]); case HieLvl_CRS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with test questions", "SELECT COUNT(DISTINCT CrsCod)" @@ -5695,7 +5617,7 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (HieLvl_Level_t Scope,Tst_Answ // Returns the number of courses with pluggable test questions // in this location (all the platform, current degree or current course) -static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope,Tst_AnswerType_t AnsType) +static unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType) { extern const char *TstCfg_PluggableDB[TstCfg_NUM_OPTIONS_PLUGGABLE]; @@ -5703,7 +5625,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope switch (Scope) { case HieLvl_SYS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with pluggable test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5724,7 +5646,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); case HieLvl_CTY: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with pluggable test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5765,7 +5687,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); case HieLvl_INS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with pluggable test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5802,7 +5724,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); case HieLvl_CTR: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with pluggable test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5835,7 +5757,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); case HieLvl_DEG: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with pluggable test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5864,7 +5786,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope Tst_StrAnswerTypesDB[AnsType], TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]); case HieLvl_CRS: - if (AnsType == Tst_ANS_UNKNOWN) // Any type + if (AnsType == Qst_ANS_UNKNOWN) // Any type return (unsigned) DB_QueryCOUNT ("can not get number of courses with pluggable test questions", "SELECT COUNT(DISTINCT tst_questions.CrsCod)" @@ -5897,8 +5819,8 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (HieLvl_Level_t Scope /*********** Get suffled/not-shuffled answers indexes of question ************/ /*****************************************************************************/ -unsigned Tst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res, - const struct Tst_Question *Question) +unsigned Qst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res, + const struct Qst_Question *Question) { return (unsigned) DB_QuerySELECT (mysql_res,"can not get questions of a game", diff --git a/swad_test.h b/swad_test.h index 45b2627e..ef8d9656 100644 --- a/swad_test.h +++ b/swad_test.h @@ -50,7 +50,7 @@ struct Tst_AnswerTypes { bool All; - char List[Tst_MAX_BYTES_LIST_ANSWER_TYPES + 1]; + char List[Qst_MAX_BYTES_LIST_ANSWER_TYPES + 1]; }; #define Tst_NUM_TYPES_ORDER_QST 5 @@ -70,7 +70,7 @@ struct Tst_Test struct Tst_AnswerTypes AnswerTypes; // Selected answer types Tst_QuestionsOrder_t SelectedOrder; // Order for listing questions unsigned NumQsts; // Number of questions - struct Tst_Question Question; // Selected / editing question + struct Qst_Question Question; // Selected / editing question }; typedef enum @@ -104,47 +104,42 @@ void Tst_ShowNewTest (void); void Tst_ReceiveTestDraft (void); void Tst_AssessTest (void); -void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res); - -void Tst_ListQuestionForEdition (struct Tst_Question *Question, +void Qst_ListQuestionForEdition (struct Qst_Question *Question, unsigned QstInd,bool QuestionExists, const char *Anchor); -void Tst_WriteNumQst (unsigned NumQst,const char *Class); -void Tst_WriteAnswerType (Tst_AnswerType_t AnswerType,const char *Class); -void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible); -void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback); +void Qst_WriteNumQst (unsigned NumQst,const char *Class); +void Qst_WriteAnswerType (Qst_AnswerType_t AnswerType,const char *Class); +void Qst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible); +void Qst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback); -void Tst_RequestEditTests (void); -void Tst_RequestSelectTestsForSet (struct Exa_Exams *Exams); -void Tst_RequestSelectTestsForGame (struct Gam_Games *Games); +void Qst_RequestEditQsts (void); +void Qst_RequestSelectQstsForExamSet (struct Exa_Exams *Exams); +void Qst_RequestSelectQstsForGame (struct Gam_Games *Games); -void Tst_ListQuestionsToEdit (void); +void Qst_ListQuestionsToEdit (void); void Tst_ListQuestionsToSelectForSet (struct Exa_Exams *Exams); void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games); void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion, bool Shuffle); -void Tst_PutParamsEditQst (void *Test); +void Qst_PutParamsEditQst (void *Test); -unsigned Tst_GetNumAnswersQst (long QstCod); -void Tst_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res, +unsigned Qst_GetNumAnswersQst (long QstCod); +void Qst_GetAnswersQst (struct Qst_Question *Question,MYSQL_RES **mysql_res, bool Shuffle); -void Tst_ChangeFormatAnswersText (struct Tst_Question *Question); -void Tst_ChangeFormatAnswersFeedback (struct Tst_Question *Question); +void Qst_ChangeFormatAnswersText (struct Qst_Question *Question); +void Qst_ChangeFormatAnswersFeedback (struct Qst_Question *Question); -void Tst_WriteAnswersBank (struct Tst_Question *Question, +void Qst_WriteAnswersBank (struct Qst_Question *Question, const char *ClassTxt, const char *ClassFeedback); -void Tst_WriteAnsTF (char AnsTF); +void Qst_WriteAnsTF (char AnsTF); -void Tst_WriteParamQstCod (unsigned NumQst,long QstCod); +void Qst_WriteParamQstCod (unsigned NumQst,long QstCod); -void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question); - -unsigned Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res); -void Tst_GetAndWriteTagsQst (long QstCod); +void Qst_CheckIfNumberOfAnswersIsOne (const struct Qst_Question *Question); void Tst_ShowFormConfig (void); @@ -152,42 +147,42 @@ bool Tst_CheckIfCourseHaveTestsAndPluggableIsUnknown (void); unsigned Tst_CountNumQuestionsInList (const char *ListQuestions); -void Tst_ShowFormEditOneQst (void); +void Qst_ShowFormEditOneQst (void); -void Tst_QstConstructor (struct Tst_Question *Question); -void Tst_QstDestructor (struct Tst_Question *Question); +void Qst_QstConstructor (struct Qst_Question *Question); +void Qst_QstDestructor (struct Qst_Question *Question); -bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt); +bool Qst_AllocateTextChoiceAnswer (struct Qst_Question *Question,unsigned NumOpt); -Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod); -bool Tst_GetQstDataFromDB (struct Tst_Question *Question); -Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB); -void Tst_ReceiveQst (void); -bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Question); +Qst_AnswerType_t Qst_GetQstAnswerTypeFromDB (long QstCod); +bool Qst_GetQstDataFromDB (struct Qst_Question *Question); +Qst_AnswerType_t Qst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB); +void Qst_ReceiveQst (void); +bool Qst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Qst_Question *Question); -bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question); +bool Qst_CheckIfQuestionExistsInDB (struct Qst_Question *Question); -long Tst_GetIntAnsFromStr (char *Str); +long Qst_GetIntAnsFromStr (char *Str); -void Tst_RequestRemoveSelectedQsts (void); -void Tst_RemoveSelectedQsts (void); -void Tst_RequestRemoveOneQst (void); -void Tst_RemoveOneQst (void); +void Qst_RequestRemoveSelectedQsts (void); +void Qst_RemoveSelectedQsts (void); +void Qst_RequestRemoveOneQst (void); +void Qst_RemoveOneQst (void); -void Tst_ChangeShuffleQst (void); +void Qst_ChangeShuffleQst (void); -long Tst_GetParamQstCod (void); -void Tst_PutParamQstCod (void *QstCod); +long Qst_GetParamQstCod (void); +void Qst_PutParamQstCod (void *QstCod); -void Tst_InsertOrUpdateQstTagsAnsIntoDB (struct Tst_Question *Question); +void Qst_InsertOrUpdateQstTagsAnsIntoDB (struct Qst_Question *Question); void Tst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion); void Tst_RemoveCrsTests (long CrsCod); -void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats); +void Tst_GetTestStats (Qst_AnswerType_t AnsType,struct Tst_Stats *Stats); -unsigned Tst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res, - const struct Tst_Question *Question); +unsigned Qst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res, + const struct Qst_Question *Question); #endif diff --git a/swad_test_import.c b/swad_test_import.c index 910cc72b..80df89cb 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -37,6 +37,7 @@ #include "swad_global.h" #include "swad_HTML.h" #include "swad_parameter.h" +#include "swad_tag_database.h" #include "swad_test.h" #include "swad_xml.h" @@ -69,20 +70,20 @@ extern struct Globals Gbl; static void TsI_PutParamsExportQsts (void *Test); static void TsI_PutCreateXMLParam (void); -static void TsI_ExportQuestion (struct Tst_Question *Question,FILE *FileXML); +static void TsI_ExportQuestion (struct Qst_Question *Question,FILE *FileXML); static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML); -static void TsI_WriteAnswersOfAQstXML (const struct Tst_Question *Question, +static void TsI_WriteAnswersOfAQstXML (const struct Qst_Question *Question, FILE *FileXML); static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML); static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer); -static Tst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML); +static Qst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML); static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem, - struct Tst_Question *Question); + struct Qst_Question *Question); static void TsI_WriteHeadingListImportedQst (void); static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, struct XMLElement *FeedbackElem, - const struct Tst_Question *Question, + const struct Qst_Question *Question, bool QuestionExists); /*****************************************************************************/ @@ -108,7 +109,7 @@ static void TsI_PutParamsExportQsts (void *Test) { if (Test) { - Tst_PutParamsEditQst (Test); + Qst_PutParamsEditQst (Test); Par_PutHiddenParamChar ("OnlyThisQst",'N'); Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) (((struct Tst_Test *) Test)->SelectedOrder)); TsI_PutCreateXMLParam (); @@ -190,7 +191,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res) char PathPubFile[PATH_MAX + 1]; FILE *FileXML; unsigned NumQst; - struct Tst_Question Question; + struct Qst_Question Question; MYSQL_ROW row; /***** Create a temporary public directory @@ -215,7 +216,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res) NumQst++) { /* Create test question */ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); /* Get question code (row[0]) */ row = mysql_fetch_row (mysql_res); @@ -225,7 +226,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res) TsI_ExportQuestion (&Question,FileXML); /* Destroy test question */ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /***** End XML file *****/ @@ -252,12 +253,12 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res) /****************** Write one question into the XML file *********************/ /*****************************************************************************/ -static void TsI_ExportQuestion (struct Tst_Question *Question,FILE *FileXML) +static void TsI_ExportQuestion (struct Qst_Question *Question,FILE *FileXML) { - extern const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES]; + extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES]; extern const char *Txt_NEW_LINE; - if (Tst_GetQstDataFromDB (Question)) + if (Qst_GetQstDataFromDB (Question)) { /***** Write the answer type *****/ fprintf (FileXML,"%s", @@ -280,8 +281,8 @@ static void TsI_ExportQuestion (struct Tst_Question *Question,FILE *FileXML) /***** Write the answers of this question. Shuffle can be enabled or disabled *****/ fprintf (FileXML,"Answer.Type == Tst_ANS_UNIQUE_CHOICE || - Question->Answer.Type == Tst_ANS_MULTIPLE_CHOICE) + if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE || + Question->Answer.Type == Qst_ANS_MULTIPLE_CHOICE) fprintf (FileXML," shuffle=\"%s\"", Question->Answer.Shuffle ? "yes" : "no"); @@ -307,7 +308,7 @@ static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML) MYSQL_RES *mysql_res; MYSQL_ROW row; - if ((NumTags = Tst_GetTagsQst (QstCod,&mysql_res))) // Result: TagTxt + if ((NumTags = Tag_DB_GetTagsQst (&mysql_res,QstCod))) // Result: TagTxt /***** Write the tags *****/ for (NumTag = 1; NumTag <= NumTags; @@ -326,7 +327,7 @@ static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML) /**************** Get and write the answers of a test question ***************/ /*****************************************************************************/ -static void TsI_WriteAnswersOfAQstXML (const struct Tst_Question *Question, +static void TsI_WriteAnswersOfAQstXML (const struct Qst_Question *Question, FILE *FileXML) { extern const char *Txt_NEW_LINE; @@ -335,10 +336,10 @@ static void TsI_WriteAnswersOfAQstXML (const struct Tst_Question *Question, /***** Write answers *****/ switch (Question->Answer.Type) { - case Tst_ANS_INT: + case Qst_ANS_INT: fprintf (FileXML,"%ld",Question->Answer.Integer); break; - case Tst_ANS_FLOAT: + case Qst_ANS_FLOAT: fprintf (FileXML,"%s" "%.15lg%s" "%.15lg%s", @@ -346,14 +347,14 @@ static void TsI_WriteAnswersOfAQstXML (const struct Tst_Question *Question, Question->Answer.FloatingPoint[0],Txt_NEW_LINE, Question->Answer.FloatingPoint[1],Txt_NEW_LINE); break; - case Tst_ANS_TRUE_FALSE: + case Qst_ANS_TRUE_FALSE: fprintf (FileXML,"%s", Question->Answer.TF == 'T' ? "true" : "false"); break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: - case Tst_ANS_TEXT: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_TEXT: fprintf (FileXML,"%s",Txt_NEW_LINE); for (NumOpt = 0; NumOpt < Question->Answer.NumOptions; @@ -363,7 +364,7 @@ static void TsI_WriteAnswersOfAQstXML (const struct Tst_Question *Question, fprintf (FileXML,"Answer.Type != Tst_ANS_TEXT) + if (Question->Answer.Type != Qst_ANS_TEXT) fprintf (FileXML," correct=\"%s\"", Question->Answer.Options[NumOpt].Correct ? "yes" : "no"); @@ -492,7 +493,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) struct XMLElement *FeedbackElem; struct XMLElement *AnswerElem; struct XMLAttribute *Attribute; - struct Tst_Question Question; + struct Qst_Question Question; bool QuestionExists; bool AnswerTypeFound; @@ -537,7 +538,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) if (!strcmp (QuestionElem->TagName,"question")) { /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); /* Get answer type (in mandatory attribute "type") */ AnswerTypeFound = false; @@ -614,8 +615,8 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) AnswerElem = AnswerElem->NextBrother) if (!strcmp (AnswerElem->TagName,"answer")) { - if (Question.Answer.Type == Tst_ANS_UNIQUE_CHOICE || - Question.Answer.Type == Tst_ANS_MULTIPLE_CHOICE) + if (Question.Answer.Type == Qst_ANS_UNIQUE_CHOICE || + Question.Answer.Type == Qst_ANS_MULTIPLE_CHOICE) /* Get whether shuffle answers (in attribute "shuffle") */ for (Attribute = AnswerElem->FirstAttribute; Attribute != NULL; @@ -632,10 +633,10 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) TsI_GetAnswerFromXML (AnswerElem,&Question); /* Make sure that tags, text and answer are not empty */ - if (Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (&Question)) + if (Qst_CheckIfQstFormatIsCorrectAndCountNumOptions (&Question)) { /* Check if question already exists in database */ - QuestionExists = Tst_CheckIfQuestionExistsInDB (&Question); + QuestionExists = Qst_CheckIfQuestionExistsInDB (&Question); /* Write row with this imported question */ TsI_WriteRowImportedQst (StemElem,FeedbackElem, @@ -645,7 +646,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) if (!QuestionExists) { Question.QstCod = -1L; - Tst_InsertOrUpdateQstTagsAnsIntoDB (&Question); + Qst_InsertOrUpdateQstTagsAnsIntoDB (&Question); if (Question.QstCod <= 0) Err_ShowErrorAndExit ("Can not create question."); } @@ -655,7 +656,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) Err_WrongAnswerExit (); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } } @@ -675,21 +676,21 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer) /***** Convert a string with the type of answer in XML to type of answer *****/ /*****************************************************************************/ -static Tst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML) +static Qst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML) { - extern const char *Tst_StrAnswerTypesXML[Tst_NUM_ANS_TYPES]; - Tst_AnswerType_t AnsType; + extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES]; + Qst_AnswerType_t AnsType; if (StrAnsTypeXML != NULL) - for (AnsType = (Tst_AnswerType_t) 0; - AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1); + for (AnsType = (Qst_AnswerType_t) 0; + AnsType <= (Qst_AnswerType_t) (Qst_NUM_ANS_TYPES - 1); AnsType++) // comparison must be case insensitive, because users can edit XML if (!strcasecmp (StrAnsTypeXML,Tst_StrAnswerTypesXML[AnsType])) return AnsType; Err_WrongAnswerExit (); - return (Tst_AnswerType_t) 0; // Not reached + return (Qst_AnswerType_t) 0; // Not reached } /*****************************************************************************/ @@ -698,7 +699,7 @@ static Tst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsT // Answer is mandatory static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem, - struct Tst_Question *Question) + struct Qst_Question *Question) { struct XMLElement *OptionElem; struct XMLElement *TextElem; @@ -709,8 +710,8 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem, switch (Question->Answer.Type) { - case Tst_ANS_INT: - if (!Tst_AllocateTextChoiceAnswer (Question,0)) + case Qst_ANS_INT: + if (!Qst_AllocateTextChoiceAnswer (Question,0)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -718,11 +719,11 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem, Str_Copy (Question->Answer.Options[0].Text,AnswerElem->Content, Tst_MAX_BYTES_ANSWER_OR_FEEDBACK); break; - case Tst_ANS_FLOAT: - if (!Tst_AllocateTextChoiceAnswer (Question,0)) + case Qst_ANS_FLOAT: + if (!Qst_AllocateTextChoiceAnswer (Question,0)) /* Abort on error */ Ale_ShowAlertsAndExit (); - if (!Tst_AllocateTextChoiceAnswer (Question,1)) + if (!Qst_AllocateTextChoiceAnswer (Question,1)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -749,7 +750,7 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem, break; // Only first element "upper" } break; - case Tst_ANS_TRUE_FALSE: + case Qst_ANS_TRUE_FALSE: // Comparisons must be case insensitive, because users can edit XML if (!AnswerElem->Content) Question->Answer.TF = ' '; @@ -766,16 +767,16 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem, else Question->Answer.TF = ' '; break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: - case Tst_ANS_TEXT: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_TEXT: /* Get options */ for (OptionElem = AnswerElem->FirstChild, NumOpt = 0; - OptionElem != NULL && NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + OptionElem != NULL && NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; OptionElem = OptionElem->NextBrother, NumOpt++) if (!strcmp (OptionElem->TagName,"option")) { - if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) + if (!Qst_AllocateTextChoiceAnswer (Question,NumOpt)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -817,7 +818,7 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem, break; // Only first element "feedback" } - if (Question->Answer.Type == Tst_ANS_TEXT) + if (Question->Answer.Type == Qst_ANS_TEXT) Question->Answer.Options[NumOpt].Correct = true; else /* Check if option is correct or wrong */ @@ -868,13 +869,13 @@ static void TsI_WriteHeadingListImportedQst (void) static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, struct XMLElement *FeedbackElem, - const struct Tst_Question *Question, + const struct Qst_Question *Question, bool QuestionExists) { extern const char *Txt_Existing_question; extern const char *Txt_New_question; extern const char *Txt_no_tags; - extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; + extern const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES]; extern const char *Txt_TST_Answer_given_by_the_teachers; static unsigned NumQst = 0; static unsigned NumNonExistingQst = 0; @@ -953,8 +954,8 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, /***** Write if shuffle is enabled *****/ HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd); - if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE || - Question->Answer.Type == Tst_ANS_MULTIPLE_CHOICE) + if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE || + Question->Answer.Type == Qst_ANS_MULTIPLE_CHOICE) /* Put an icon that indicates whether shuffle is enabled or not */ if (Question->Answer.Shuffle) Ico_PutIcon ("check.svg",Txt_TST_Answer_given_by_the_teachers, @@ -964,17 +965,17 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, /***** Write the stem and the answers *****/ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteQstStem (Stem,ClassStem, + Qst_WriteQstStem (Stem,ClassStem, true); // Visible - Tst_WriteQstFeedback (Feedback,"TEST_TXT_LIGHT"); + Qst_WriteQstFeedback (Feedback,"TEST_TXT_LIGHT"); switch (Question->Answer.Type) { - case Tst_ANS_INT: + case Qst_ANS_INT: HTM_SPAN_Begin ("class=\"%s\"",ClassStem); HTM_TxtF ("(%ld)",Question->Answer.Integer); HTM_SPAN_End (); break; - case Tst_ANS_FLOAT: + case Qst_ANS_FLOAT: HTM_SPAN_Begin ("class=\"%s\"",ClassStem); HTM_Txt ("(["); HTM_Double (Question->Answer.FloatingPoint[0]); @@ -983,16 +984,16 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem, HTM_Txt ("])"); HTM_SPAN_End (); break; - case Tst_ANS_TRUE_FALSE: + case Qst_ANS_TRUE_FALSE: HTM_SPAN_Begin ("class=\"%s\"",ClassStem); HTM_Txt ("("); - Tst_WriteAnsTF (Question->Answer.TF); + Qst_WriteAnsTF (Question->Answer.TF); HTM_Txt (")"); HTM_SPAN_End (); break; - case Tst_ANS_UNIQUE_CHOICE: - case Tst_ANS_MULTIPLE_CHOICE: - case Tst_ANS_TEXT: + case Qst_ANS_UNIQUE_CHOICE: + case Qst_ANS_MULTIPLE_CHOICE: + case Qst_ANS_TEXT: HTM_TABLE_Begin (NULL); for (NumOpt = 0; NumOpt < Question->Answer.NumOptions; diff --git a/swad_test_print.c b/swad_test_print.c index 43b918a2..b35ab870 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -81,27 +81,27 @@ static void TstPrn_ResetPrintExceptPrnCod (struct TstPrn_Print *Print); static void TstPrn_WriteQstAndAnsToFill (struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - struct Tst_Question *Question); + struct Qst_Question *Question); static void TstPrn_WriteAnswersToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - struct Tst_Question *Question); + struct Qst_Question *Question); //----------------------------------------------------------------------------- static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); static void TstPrn_WriteTF_AnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - struct Tst_Question *Question); + struct Qst_Question *Question); static void TstPrn_WriteTxtAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question); + __attribute__((unused)) struct Qst_Question *Question); //----------------------------------------------------------------------------- static void TstPrn_PutCheckBoxAllowTeachers (bool AllowTeachers); @@ -110,55 +110,55 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat, struct TstPrn_PrintedQuestion PrintedQuestions[TstCfg_MAX_QUESTIONS_PER_TEST], unsigned QstInd, time_t TimeUTC[Dat_NUM_START_END_TIME], - struct Tst_Question *Question, + struct Qst_Question *Question, bool QuestionExists, unsigned Visibility); //----------------------------------------------------------------------------- static void TstPrn_GetCorrectAndComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void TstPrn_GetCorrectAndComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void TstPrn_GetCorrectAndComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void TstPrn_GetCorrectAndComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); static void TstPrn_GetCorrectAndComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); //----------------------------------------------------------------------------- -static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question); -static void TstPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question); -static void TstPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question); -static void TstPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question); -static void TstPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question); +static void TstPrn_GetCorrectIntAnswerFromDB (struct Qst_Question *Question); +static void TstPrn_GetCorrectFltAnswerFromDB (struct Qst_Question *Question); +static void TstPrn_GetCorrectTF_AnswerFromDB (struct Qst_Question *Question); +static void TstPrn_GetCorrectChoAnswerFromDB (struct Qst_Question *Question); +static void TstPrn_GetCorrectTxtAnswerFromDB (struct Qst_Question *Question); //----------------------------------------------------------------------------- static void TstPrn_WriteIntAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback); static void TstPrn_WriteFltAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback); static void TstPrn_WriteTF_AnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback); static void TstPrn_WriteChoAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], const char *ClassTxt, const char *ClassFeedback); static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback); @@ -271,7 +271,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print, extern const char *Txt_Continue; extern const char *Txt_Send; unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; static const Act_Action_t Action[Tst_NUM_REQUEST_OR_CONFIRM] = { [TstPrn_REQUEST] = ActReqAssTst, @@ -305,18 +305,18 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print, Gbl.RowEvenOdd = QstInd % 2; /* Create test question */ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; /* Show question */ - if (!Tst_GetQstDataFromDB (&Question)) // Question exists + if (!Qst_GetQstDataFromDB (&Question)) // Question exists Err_WrongQuestionExit (); /* Write question and answers */ TstPrn_WriteQstAndAnsToFill (&Print->PrintedQuestions[QstInd],QstInd,&Question); /* Destroy test question */ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /***** End table *****/ @@ -352,25 +352,25 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print, static void TstPrn_WriteQstAndAnsToFill (struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Begin row *****/ HTM_TR_Begin (NULL); /***** Number of question and answer type *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd + 1,"BIG_INDEX"); - Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); + Qst_WriteNumQst (QstInd + 1,"BIG_INDEX"); + Qst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); HTM_TD_End (); /***** Stem, media and answers *****/ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); /* Write parameter with question code */ - Tst_WriteParamQstCod (QstInd,Question->QstCod); + Qst_WriteParamQstCod (QstInd,Question->QstCod); /* Stem */ - Tst_WriteQstStem (Question->Stem,"TEST_TXT",true); + Qst_WriteQstStem (Question->Stem,"TEST_TXT",true); /* Media */ Med_ShowMedia (&Question->Media, @@ -392,18 +392,18 @@ static void TstPrn_WriteQstAndAnsToFill (struct TstPrn_PrintedQuestion *PrintedQ static void TstPrn_WriteAnswersToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - struct Tst_Question *Question) + struct Qst_Question *Question) { - void (*TstPrn_WriteAnsBank[Tst_NUM_ANS_TYPES]) (const struct TstPrn_PrintedQuestion *PrintedQuestion, + void (*TstPrn_WriteAnsBank[Qst_NUM_ANS_TYPES]) (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - struct Tst_Question *Question) = + struct Qst_Question *Question) = { - [Tst_ANS_INT ] = TstPrn_WriteIntAnsToFill, - [Tst_ANS_FLOAT ] = TstPrn_WriteFltAnsToFill, - [Tst_ANS_TRUE_FALSE ] = TstPrn_WriteTF_AnsToFill, - [Tst_ANS_UNIQUE_CHOICE ] = TstPrn_WriteChoAnsToFill, - [Tst_ANS_MULTIPLE_CHOICE] = TstPrn_WriteChoAnsToFill, - [Tst_ANS_TEXT ] = TstPrn_WriteTxtAnsToFill, + [Qst_ANS_INT ] = TstPrn_WriteIntAnsToFill, + [Qst_ANS_FLOAT ] = TstPrn_WriteFltAnsToFill, + [Qst_ANS_TRUE_FALSE ] = TstPrn_WriteTF_AnsToFill, + [Qst_ANS_UNIQUE_CHOICE ] = TstPrn_WriteChoAnsToFill, + [Qst_ANS_MULTIPLE_CHOICE] = TstPrn_WriteChoAnsToFill, + [Qst_ANS_TEXT ] = TstPrn_WriteTxtAnsToFill, }; /***** Write answers *****/ @@ -416,7 +416,7 @@ static void TstPrn_WriteAnswersToFill (const struct TstPrn_PrintedQuestion *Prin static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" @@ -433,13 +433,13 @@ static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *Print static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" /***** Write input field for the answer *****/ snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd); - HTM_INPUT_TEXT (StrAns,Tst_MAX_BYTES_FLOAT_ANSWER,PrintedQuestion->StrAnswers, + HTM_INPUT_TEXT (StrAns,Qst_MAX_BYTES_FLOAT_ANSWER,PrintedQuestion->StrAnswers, HTM_DONT_SUBMIT_ON_CHANGE, "size=\"11\""); } @@ -450,7 +450,7 @@ static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *Print static void TstPrn_WriteTF_AnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { extern const char *Txt_TF_QST[2]; @@ -472,15 +472,15 @@ static void TstPrn_WriteTF_AnsToFill (const struct TstPrn_PrintedQuestion *Print static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - struct Tst_Question *Question) + struct Qst_Question *Question) { unsigned NumOpt; - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question - bool UsrAnswers[Tst_MAX_OPTIONS_PER_QUESTION]; + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question + bool UsrAnswers[Qst_MAX_OPTIONS_PER_QUESTION]; char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Get indexes for this question from string *****/ TstPrn_GetIndexesFromStr (PrintedQuestion->StrIndexes,Indexes); @@ -506,7 +506,7 @@ static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *Print HTM_TD_Begin ("class=\"LT\""); snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd); - if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE) + if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE) HTM_INPUT_RADIO (StrAns,false, "id=\"Ans%010u_%u\" value=\"%u\"%s" " onclick=\"selectUnselectRadio(this,this.form.Ans%010u,%u);\"", @@ -554,13 +554,13 @@ static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *Print static void TstPrn_WriteTxtAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion, unsigned QstInd, - __attribute__((unused)) struct Tst_Question *Question) + __attribute__((unused)) struct Qst_Question *Question) { char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x" /***** Write input field for the answer *****/ snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd); - HTM_INPUT_TEXT (StrAns,Tst_MAX_CHARS_ANSWERS_ONE_QST,PrintedQuestion->StrAnswers, + HTM_INPUT_TEXT (StrAns,Qst_MAX_CHARS_ANSWERS_ONE_QST,PrintedQuestion->StrAnswers, HTM_DONT_SUBMIT_ON_CHANGE, "size=\"40\""); } @@ -593,7 +593,7 @@ static void TstPrn_PutCheckBoxAllowTeachers (bool AllowTeachers) void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print) { unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; bool QuestionExists; /***** Begin table *****/ @@ -610,11 +610,11 @@ void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print) Gbl.RowEvenOdd = QstInd % 2; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; /***** Get question data *****/ - QuestionExists = Tst_GetQstDataFromDB (&Question); + QuestionExists = Qst_GetQstDataFromDB (&Question); /***** Write question and answers *****/ TstPrn_WriteQstAndAnsExam (&Gbl.Usrs.Me.UsrDat, @@ -636,7 +636,7 @@ void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print) Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[QstInd]); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } /***** End table *****/ @@ -651,7 +651,7 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat, struct TstPrn_PrintedQuestion PrintedQuestions[TstCfg_MAX_QUESTIONS_PER_TEST], unsigned QstInd, time_t TimeUTC[Dat_NUM_START_END_TIME], - struct Tst_Question *Question, + struct Qst_Question *Question, bool QuestionExists, unsigned Visibility) { @@ -701,9 +701,9 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat, /***** Number of question and answer type *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd + 1,"BIG_INDEX"); + Qst_WriteNumQst (QstInd + 1,"BIG_INDEX"); if (QuestionUneditedAfterExam) - Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); + Qst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); HTM_TD_End (); /***** Stem, media and answers *****/ @@ -713,7 +713,7 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat, if (QuestionUneditedAfterExam) { /* Stem */ - Tst_WriteQstStem (Question->Stem,"TEST_TXT",ICanView[TstVis_VISIBLE_QST_ANS_TXT]); + Qst_WriteQstStem (Question->Stem,"TEST_TXT",ICanView[TstVis_VISIBLE_QST_ANS_TXT]); /* Media */ if (ICanView[TstVis_VISIBLE_QST_ANS_TXT]) @@ -750,7 +750,7 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat, /* Question feedback */ if (QuestionUneditedAfterExam) if (ICanView[TstVis_VISIBLE_FEEDBACK_TXT]) - Tst_WriteQstFeedback (Question->Feedback,"TEST_TXT_LIGHT"); + Qst_WriteQstFeedback (Question->Feedback,"TEST_TXT_LIGHT"); HTM_TD_End (); @@ -766,7 +766,7 @@ void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print, bool UpdateQstScore) { unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; /***** Initialize total score *****/ Print->Score = 0.0; @@ -778,11 +778,11 @@ void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print, QstInd++) { /* Compute question score */ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; - Question.Answer.Type = Tst_GetQstAnswerTypeFromDB (Question.QstCod); + Question.Answer.Type = Qst_GetQstAnswerTypeFromDB (Question.QstCod); TstPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question); - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); /* Store test exam question in database */ TstPrn_StoreOneQstOfPrintInDB (Print, @@ -804,17 +804,17 @@ void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print, /*****************************************************************************/ void TstPrn_ComputeAnswerScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { - void (*TstPrn_GetCorrectAndComputeAnsScore[Tst_NUM_ANS_TYPES]) (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) = + void (*TstPrn_GetCorrectAndComputeAnsScore[Qst_NUM_ANS_TYPES]) (struct TstPrn_PrintedQuestion *PrintedQuestion, + struct Qst_Question *Question) = { - [Tst_ANS_INT ] = TstPrn_GetCorrectAndComputeIntAnsScore, - [Tst_ANS_FLOAT ] = TstPrn_GetCorrectAndComputeFltAnsScore, - [Tst_ANS_TRUE_FALSE ] = TstPrn_GetCorrectAndComputeTF_AnsScore, - [Tst_ANS_UNIQUE_CHOICE ] = TstPrn_GetCorrectAndComputeChoAnsScore, - [Tst_ANS_MULTIPLE_CHOICE] = TstPrn_GetCorrectAndComputeChoAnsScore, - [Tst_ANS_TEXT ] = TstPrn_GetCorrectAndComputeTxtAnsScore, + [Qst_ANS_INT ] = TstPrn_GetCorrectAndComputeIntAnsScore, + [Qst_ANS_FLOAT ] = TstPrn_GetCorrectAndComputeFltAnsScore, + [Qst_ANS_TRUE_FALSE ] = TstPrn_GetCorrectAndComputeTF_AnsScore, + [Qst_ANS_UNIQUE_CHOICE ] = TstPrn_GetCorrectAndComputeChoAnsScore, + [Qst_ANS_MULTIPLE_CHOICE] = TstPrn_GetCorrectAndComputeChoAnsScore, + [Qst_ANS_TEXT ] = TstPrn_GetCorrectAndComputeTxtAnsScore, }; /***** Get correct answer and compute answer score depending on type *****/ @@ -826,7 +826,7 @@ void TstPrn_ComputeAnswerScore (struct TstPrn_PrintedQuestion *PrintedQuestion, /*****************************************************************************/ static void TstPrn_GetCorrectAndComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get the numerical value of the correct answer, and compute score *****/ @@ -835,7 +835,7 @@ static void TstPrn_GetCorrectAndComputeIntAnsScore (struct TstPrn_PrintedQuestio } static void TstPrn_GetCorrectAndComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get the numerical value of the minimum and maximum correct answers, and compute score *****/ @@ -844,7 +844,7 @@ static void TstPrn_GetCorrectAndComputeFltAnsScore (struct TstPrn_PrintedQuestio } static void TstPrn_GetCorrectAndComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get answer true or false, and compute score *****/ @@ -853,7 +853,7 @@ static void TstPrn_GetCorrectAndComputeTF_AnsScore (struct TstPrn_PrintedQuestio } static void TstPrn_GetCorrectAndComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get correct options of test question from database, and compute score *****/ @@ -862,7 +862,7 @@ static void TstPrn_GetCorrectAndComputeChoAnsScore (struct TstPrn_PrintedQuestio } static void TstPrn_GetCorrectAndComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question) + struct Qst_Question *Question) { /***** Get correct text answers for this question from database, and compute score *****/ @@ -874,7 +874,7 @@ static void TstPrn_GetCorrectAndComputeTxtAnsScore (struct TstPrn_PrintedQuestio /**************** Get correct answer for each type of answer *****************/ /*****************************************************************************/ -static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) +static void TstPrn_GetCorrectIntAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -888,7 +888,7 @@ static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) Question->QstCod); /***** Check if number of rows is correct *****/ - Tst_CheckIfNumberOfAnswersIsOne (Question); + Qst_CheckIfNumberOfAnswersIsOne (Question); /***** Get correct answer *****/ row = mysql_fetch_row (mysql_res); @@ -899,7 +899,7 @@ static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void TstPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question) +static void TstPrn_GetCorrectFltAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -939,7 +939,7 @@ static void TstPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void TstPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question) +static void TstPrn_GetCorrectTF_AnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -953,7 +953,7 @@ static void TstPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question) Question->QstCod); /***** Check if number of rows is correct *****/ - Tst_CheckIfNumberOfAnswersIsOne (Question); + Qst_CheckIfNumberOfAnswersIsOne (Question); /***** Get answer *****/ row = mysql_fetch_row (mysql_res); @@ -963,7 +963,7 @@ static void TstPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void TstPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question) +static void TstPrn_GetCorrectChoAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -992,7 +992,7 @@ static void TstPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question) DB_FreeMySQLResult (&mysql_res); } -static void TstPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question) +static void TstPrn_GetCorrectTxtAnswerFromDB (struct Qst_Question *Question) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1015,7 +1015,7 @@ static void TstPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question) row = mysql_fetch_row (mysql_res); /***** Allocate memory for text in this choice answer *****/ - if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt)) + if (!Qst_AllocateTextChoiceAnswer (Question,NumOpt)) /* Abort on error */ Ale_ShowAlertsAndExit (); @@ -1025,7 +1025,7 @@ static void TstPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question) } /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -1036,7 +1036,7 @@ static void TstPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question) /*****************************************************************************/ void TstPrn_ComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question) + const struct Qst_Question *Question) { long AnswerUsr; @@ -1056,7 +1056,7 @@ void TstPrn_ComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, } void TstPrn_ComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question) + const struct Qst_Question *Question) { double AnswerUsr; @@ -1079,7 +1079,7 @@ void TstPrn_ComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, } void TstPrn_ComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question) + const struct Qst_Question *Question) { PrintedQuestion->AnswerIsCorrect = TstPrn_ANSWER_IS_BLANK; PrintedQuestion->Score = 0.0; @@ -1100,10 +1100,10 @@ void TstPrn_ComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, } void TstPrn_ComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question) + const struct Qst_Question *Question) { - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question - bool UsrAnswers[Tst_MAX_OPTIONS_PER_QUESTION]; + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question + bool UsrAnswers[Qst_MAX_OPTIONS_PER_QUESTION]; unsigned NumOpt; unsigned NumOptTotInQst = 0; unsigned NumOptCorrInQst = 0; @@ -1141,7 +1141,7 @@ void TstPrn_ComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, if (NumAnsGood || NumAnsBad) // If user has answered the answer { /* Compute the score */ - if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE) + if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE) { if (NumOptTotInQst >= 2) // It should be 2 options at least { @@ -1202,11 +1202,11 @@ void TstPrn_ComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, } void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question) + const struct Qst_Question *Question) { unsigned NumOpt; - char TextAnsUsr[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; - char TextAnsOK[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; + char TextAnsUsr[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; + char TextAnsOK[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; PrintedQuestion->AnswerIsCorrect = TstPrn_ANSWER_IS_BLANK; PrintedQuestion->Score = 0.0; // Default score for blank or wrong answer @@ -1245,8 +1245,8 @@ void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, /********** Get vector of unsigned indexes from string with indexes **********/ /*****************************************************************************/ -void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES_ONE_QST + 1], // 0 1 2 3, 3 0 2 1, etc. - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]) +void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Qst_MAX_BYTES_INDEXES_ONE_QST + 1], // 0 1 2 3, 3 0 2 1, etc. + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]) { unsigned NumOpt; const char *Ptr; @@ -1254,7 +1254,7 @@ void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES /***** Get indexes from string *****/ for (NumOpt = 0, Ptr = StrIndexesOneQst; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION && *Ptr; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION && *Ptr; NumOpt++) { Par_GetNextStrUntilComma (&Ptr,StrOneIndex,Cns_MAX_DECIMAL_DIGITS_UINT); @@ -1262,13 +1262,13 @@ void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES if (sscanf (StrOneIndex,"%u",&(Indexes[NumOpt])) != 1) Err_WrongAnswerIndexExit (); - if (Indexes[NumOpt] >= Tst_MAX_OPTIONS_PER_QUESTION) + if (Indexes[NumOpt] >= Qst_MAX_OPTIONS_PER_QUESTION) Err_WrongAnswerIndexExit (); } /***** Initialize remaining to 0 *****/ for (; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) Indexes[NumOpt] = 0; } @@ -1277,8 +1277,8 @@ void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES /************ Get vector of bool answers from string with answers ************/ /*****************************************************************************/ -void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1], - bool UsrAnswers[Tst_MAX_OPTIONS_PER_QUESTION]) +void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1], + bool UsrAnswers[Qst_MAX_OPTIONS_PER_QUESTION]) { unsigned NumOpt; const char *Ptr; @@ -1287,13 +1287,13 @@ void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS /***** Initialize all answers to false *****/ for (NumOpt = 0; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION; NumOpt++) UsrAnswers[NumOpt] = false; /***** Set selected answers to true *****/ for (NumOpt = 0, Ptr = StrAnswersOneQst; - NumOpt < Tst_MAX_OPTIONS_PER_QUESTION && *Ptr; + NumOpt < Qst_MAX_OPTIONS_PER_QUESTION && *Ptr; NumOpt++) { Par_GetNextStrUntilComma (&Ptr,StrOneAnswer,Cns_MAX_DECIMAL_DIGITS_UINT); @@ -1301,7 +1301,7 @@ void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS if (sscanf (StrOneAnswer,"%u",&AnsUsr) != 1) Err_WrongAnswerExit (); - if (AnsUsr >= Tst_MAX_OPTIONS_PER_QUESTION) + if (AnsUsr >= Qst_MAX_OPTIONS_PER_QUESTION) Err_WrongAnswerExit (); UsrAnswers[AnsUsr] = true; @@ -1356,24 +1356,24 @@ void TstPrn_ShowGrade (double Grade,double MaxGrade) void TstPrn_WriteAnswersExam (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], const char *ClassTxt, const char *ClassFeedback) { - void (*TstPrn_WriteAnsExam[Tst_NUM_ANS_TYPES]) (struct UsrData *UsrDat, + void (*TstPrn_WriteAnsExam[Qst_NUM_ANS_TYPES]) (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], const char *ClassTxt, const char *ClassFeedback) = { - [Tst_ANS_INT ] = TstPrn_WriteIntAnsPrint, - [Tst_ANS_FLOAT ] = TstPrn_WriteFltAnsPrint, - [Tst_ANS_TRUE_FALSE ] = TstPrn_WriteTF_AnsPrint, - [Tst_ANS_UNIQUE_CHOICE ] = TstPrn_WriteChoAnsPrint, - [Tst_ANS_MULTIPLE_CHOICE] = TstPrn_WriteChoAnsPrint, - [Tst_ANS_TEXT ] = TstPrn_WriteTxtAnsPrint, + [Qst_ANS_INT ] = TstPrn_WriteIntAnsPrint, + [Qst_ANS_FLOAT ] = TstPrn_WriteFltAnsPrint, + [Qst_ANS_TRUE_FALSE ] = TstPrn_WriteTF_AnsPrint, + [Qst_ANS_UNIQUE_CHOICE ] = TstPrn_WriteChoAnsPrint, + [Qst_ANS_MULTIPLE_CHOICE] = TstPrn_WriteChoAnsPrint, + [Qst_ANS_TEXT ] = TstPrn_WriteTxtAnsPrint, }; /***** Get correct answer and compute answer score depending on type *****/ @@ -1387,7 +1387,7 @@ void TstPrn_WriteAnswersExam (struct UsrData *UsrDat, static void TstPrn_WriteIntAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback) @@ -1395,7 +1395,7 @@ static void TstPrn_WriteIntAnsPrint (struct UsrData *UsrDat, long IntAnswerUsr; /***** Check if number of rows is correct *****/ - Tst_CheckIfNumberOfAnswersIsOne (Question); + Qst_CheckIfNumberOfAnswersIsOne (Question); /***** Header with the title of each column *****/ HTM_TABLE_BeginPadding (2); @@ -1447,7 +1447,7 @@ static void TstPrn_WriteIntAnsPrint (struct UsrData *UsrDat, static void TstPrn_WriteFltAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback) @@ -1508,7 +1508,7 @@ static void TstPrn_WriteFltAnsPrint (struct UsrData *UsrDat, static void TstPrn_WriteTF_AnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback) @@ -1516,7 +1516,7 @@ static void TstPrn_WriteTF_AnsPrint (struct UsrData *UsrDat, char AnsTFUsr; /***** Check if number of rows is correct *****/ - Tst_CheckIfNumberOfAnswersIsOne (Question); + Qst_CheckIfNumberOfAnswersIsOne (Question); /***** Get answer true or false *****/ AnsTFUsr = PrintedQuestion->StrAnswers[0]; @@ -1535,13 +1535,13 @@ static void TstPrn_WriteTF_AnsPrint (struct UsrData *UsrDat, (AnsTFUsr == Question->Answer.TF ? "ANS_OK" : "ANS_BAD") : "ANS_0"); - Tst_WriteAnsTF (AnsTFUsr); + Qst_WriteAnsTF (AnsTFUsr); HTM_TD_End (); /***** Write the correct answer *****/ HTM_TD_Begin ("class=\"ANS_0 CM\""); if (ICanView[TstVis_VISIBLE_CORRECT_ANSWER]) - Tst_WriteAnsTF (Question->Answer.TF); + Qst_WriteAnsTF (Question->Answer.TF); else Ico_PutIconNotVisible (); HTM_TD_End (); @@ -1557,7 +1557,7 @@ static void TstPrn_WriteTF_AnsPrint (struct UsrData *UsrDat, static void TstPrn_WriteChoAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], const char *ClassTxt, const char *ClassFeedback) @@ -1565,8 +1565,8 @@ static void TstPrn_WriteChoAnsPrint (struct UsrData *UsrDat, extern const char *Txt_TST_Answer_given_by_the_user; extern const char *Txt_TST_Answer_given_by_the_teachers; unsigned NumOpt; - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question - bool UsrAnswers[Tst_MAX_OPTIONS_PER_QUESTION]; + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]; // Indexes of all answers of this question + bool UsrAnswers[Qst_MAX_OPTIONS_PER_QUESTION]; struct { char *Class; @@ -1574,11 +1574,11 @@ static void TstPrn_WriteChoAnsPrint (struct UsrData *UsrDat, } Ans; /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Change format of answers feedback *****/ if (ICanView[TstVis_VISIBLE_FEEDBACK_TXT]) - Tst_ChangeFormatAnswersFeedback (Question); + Qst_ChangeFormatAnswersFeedback (Question); /***** Get indexes for this question from string *****/ TstPrn_GetIndexesFromStr (PrintedQuestion->StrIndexes,Indexes); @@ -1694,22 +1694,22 @@ static void TstPrn_WriteChoAnsPrint (struct UsrData *UsrDat, static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], __attribute__((unused)) const char *ClassTxt, __attribute__((unused)) const char *ClassFeedback) { unsigned NumOpt; - char TextAnsUsr[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; - char TextAnsOK[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; + char TextAnsUsr[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; + char TextAnsOK[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; bool Correct = false; /***** Change format of answers text *****/ - Tst_ChangeFormatAnswersText (Question); + Qst_ChangeFormatAnswersText (Question); /***** Change format of answers feedback *****/ if (ICanView[TstVis_VISIBLE_FEEDBACK_TXT]) - Tst_ChangeFormatAnswersFeedback (Question); + Qst_ChangeFormatAnswersFeedback (Question); /***** Header with the title of each column *****/ HTM_TABLE_BeginPadding (2); @@ -2642,7 +2642,7 @@ static void TstPrn_ShowTagsPresentInAPrint (long ResCod) " WHERE TagsCods.TagCod=tst_tags.TagCod" " ORDER BY tst_tags.TagTxt", ResCod); - Tst_ShowTagList (NumTags,mysql_res); + Tag_ShowTagList (NumTags,mysql_res); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -2659,7 +2659,7 @@ void TstPrn_ShowPrintAnswers (struct UsrData *UsrDat, unsigned Visibility) { unsigned QstInd; - struct Tst_Question Question; + struct Qst_Question Question; bool QuestionExists; for (QstInd = 0; @@ -2669,11 +2669,11 @@ void TstPrn_ShowPrintAnswers (struct UsrData *UsrDat, Gbl.RowEvenOdd = QstInd % 2; /***** Create test question *****/ - Tst_QstConstructor (&Question); + Qst_QstConstructor (&Question); Question.QstCod = PrintedQuestions[QstInd].QstCod; /***** Get question data *****/ - QuestionExists = Tst_GetQstDataFromDB (&Question); + QuestionExists = Qst_GetQstDataFromDB (&Question); /***** Write questions and answers *****/ TstPrn_WriteQstAndAnsExam (UsrDat, @@ -2683,7 +2683,7 @@ void TstPrn_ShowPrintAnswers (struct UsrData *UsrDat, Visibility); /***** Destroy test question *****/ - Tst_QstDestructor (&Question); + Qst_QstDestructor (&Question); } } diff --git a/swad_test_print.h b/swad_test_print.h index dfde8c85..2c5af2dc 100644 --- a/swad_test_print.h +++ b/swad_test_print.h @@ -59,8 +59,8 @@ struct TstPrn_PrintedQuestion { long QstCod; // Question code long SetCod; // Only for exams - char StrIndexes[Tst_MAX_BYTES_INDEXES_ONE_QST + 1]; // 0 1 2 3, 3 0 2 1, etc. - char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user + char StrIndexes[Qst_MAX_BYTES_INDEXES_ONE_QST + 1]; // 0 1 2 3, 3 0 2 1, etc. + char StrAnswers[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user TstPrn_Correct_t AnswerIsCorrect; // Is question wrong, medium or correct? double Score; // Question score }; @@ -101,29 +101,29 @@ void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print); void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print, bool UpdateQstScore); void TstPrn_ComputeAnswerScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question); + struct Qst_Question *Question); //----------------------------------------------------------------------------- void TstPrn_ComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question); + const struct Qst_Question *Question); void TstPrn_ComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question); + const struct Qst_Question *Question); void TstPrn_ComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question); + const struct Qst_Question *Question); void TstPrn_ComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question); + const struct Qst_Question *Question); void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion, - const struct Tst_Question *Question); + const struct Qst_Question *Question); //----------------------------------------------------------------------------- -void Tst_ChangeFormatAnswersText (struct Tst_Question *Question); -void Tst_ChangeFormatAnswersFeedback (struct Tst_Question *Question); +void Qst_ChangeFormatAnswersText (struct Qst_Question *Question); +void Qst_ChangeFormatAnswersFeedback (struct Qst_Question *Question); -void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES_ONE_QST + 1], // 0 1 2 3, 3 0 2 1, etc. - unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]); -void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1], - bool UsrAnswers[Tst_MAX_OPTIONS_PER_QUESTION]); +void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Qst_MAX_BYTES_INDEXES_ONE_QST + 1], // 0 1 2 3, 3 0 2 1, etc. + unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]); +void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1], + bool UsrAnswers[Qst_MAX_OPTIONS_PER_QUESTION]); void TstPrn_ComputeAndShowGrade (unsigned NumQsts,double Score,double MaxGrade); double TstPrn_ComputeGrade (unsigned NumQsts,double Score,double MaxGrade); @@ -131,7 +131,7 @@ void TstPrn_ShowGrade (double Grade,double MaxGrade); void TstPrn_WriteAnswersExam (struct UsrData *UsrDat, const struct TstPrn_PrintedQuestion *PrintedQuestion, - struct Tst_Question *Question, + struct Qst_Question *Question, bool ICanView[TstVis_NUM_ITEMS_VISIBILITY], const char *ClassTxt, const char *ClassFeedback); diff --git a/swad_test_type.h b/swad_test_type.h index 7c1ba0f6..49b6f3a7 100644 --- a/swad_test_type.h +++ b/swad_test_type.h @@ -34,14 +34,14 @@ /***************************** Public constants ******************************/ /*****************************************************************************/ -#define Tst_MAX_BYTES_FLOAT_ANSWER 30 // Maximum length of the strings that store an floating point answer +#define Qst_MAX_BYTES_FLOAT_ANSWER 30 // Maximum length of the strings that store an floating point answer -#define Tst_MAX_OPTIONS_PER_QUESTION 10 +#define Qst_MAX_OPTIONS_PER_QUESTION 10 -#define Tst_MAX_BYTES_INDEXES_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (3 + 1)) +#define Qst_MAX_BYTES_INDEXES_ONE_QST (Qst_MAX_OPTIONS_PER_QUESTION * (3 + 1)) -#define Tst_MAX_CHARS_ANSWERS_ONE_QST (128 - 1) // 127 -#define Tst_MAX_BYTES_ANSWERS_ONE_QST ((Tst_MAX_CHARS_ANSWERS_ONE_QST + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 +#define Qst_MAX_CHARS_ANSWERS_ONE_QST (128 - 1) // 127 +#define Qst_MAX_BYTES_ANSWERS_ONE_QST ((Qst_MAX_CHARS_ANSWERS_ONE_QST + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Tst_SCORE_MAX 10 // Maximum score of a test (10 in Spain). Must be unsigned! // TODO: Make this configurable by teachers @@ -49,27 +49,27 @@ /******************************* Public types ********************************/ /*****************************************************************************/ -#define Tst_NUM_VALIDITIES 2 +#define Qst_NUM_VALIDITIES 2 typedef enum { - Tst_INVALID_QUESTION, - Tst_VALID_QUESTION, - } Tst_Validity_t; + Qst_INVALID_QUESTION, + Qst_VALID_QUESTION, + } Qst_Validity_t; -#define Tst_NUM_ANS_TYPES 6 -#define Tst_MAX_BYTES_LIST_ANSWER_TYPES (Tst_NUM_ANS_TYPES * (Cns_MAX_DECIMAL_DIGITS_UINT + 1)) +#define Qst_NUM_ANS_TYPES 6 +#define Qst_MAX_BYTES_LIST_ANSWER_TYPES (Qst_NUM_ANS_TYPES * (Cns_MAX_DECIMAL_DIGITS_UINT + 1)) typedef enum { - Tst_ANS_INT = 0, - Tst_ANS_FLOAT = 1, - Tst_ANS_TRUE_FALSE = 2, - Tst_ANS_UNIQUE_CHOICE = 3, - Tst_ANS_MULTIPLE_CHOICE = 4, - Tst_ANS_TEXT = 5, - Tst_ANS_UNKNOWN = 6, // Unknown/all/any type of answer - } Tst_AnswerType_t; + Qst_ANS_INT = 0, + Qst_ANS_FLOAT = 1, + Qst_ANS_TRUE_FALSE = 2, + Qst_ANS_UNIQUE_CHOICE = 3, + Qst_ANS_MULTIPLE_CHOICE = 4, + Qst_ANS_TEXT = 5, + Qst_ANS_UNKNOWN = 6, // Unknown/all/any type of answer + } Qst_AnswerType_t; -struct Tst_Question +struct Qst_Question { long QstCod; struct Tag_Tags Tags; @@ -79,7 +79,7 @@ struct Tst_Question struct Med_Media Media; struct { - Tst_AnswerType_t Type; + Qst_AnswerType_t Type; unsigned NumOptions; bool Shuffle; char TF; @@ -89,14 +89,14 @@ struct Tst_Question char *Text; char *Feedback; struct Med_Media Media; - } Options[Tst_MAX_OPTIONS_PER_QUESTION]; + } Options[Qst_MAX_OPTIONS_PER_QUESTION]; long Integer; double FloatingPoint[2]; } Answer; unsigned long NumHits; unsigned long NumHitsNotBlank; double Score; - Tst_Validity_t Validity; // If a question in an exam has been marked as invalid + Qst_Validity_t Validity; // If a question in an exam has been marked as invalid }; /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index c07021e2..69329d3e 100644 --- a/swad_text.c +++ b/swad_text.c @@ -53822,9 +53822,9 @@ const char *Txt_TST_PLUGGABLE[TstCfg_NUM_OPTIONS_PLUGGABLE] = #endif }; -const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES] = +const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES] = { - [Tst_ANS_INT] = + [Qst_ANS_INT] = #if L==1 // ca "Nombre enter" #elif L==2 // de @@ -53845,7 +53845,7 @@ const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES] = "N.º inteiro" #endif , - [Tst_ANS_FLOAT] = + [Qst_ANS_FLOAT] = #if L==1 // ca "Nombre real" #elif L==2 // de @@ -53866,7 +53866,7 @@ const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES] = "N.º real" #endif , - [Tst_ANS_TRUE_FALSE] = + [Qst_ANS_TRUE_FALSE] = #if L==1 // ca "V/F" #elif L==2 // de @@ -53887,7 +53887,7 @@ const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES] = "V/F" #endif , - [Tst_ANS_UNIQUE_CHOICE] = + [Qst_ANS_UNIQUE_CHOICE] = #if L==1 // ca "Elecció única" #elif L==2 // de @@ -53908,7 +53908,7 @@ const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES] = "Única escolha" #endif , - [Tst_ANS_MULTIPLE_CHOICE] = + [Qst_ANS_MULTIPLE_CHOICE] = #if L==1 // ca "Elecció múltiple" #elif L==2 // de @@ -53929,7 +53929,7 @@ const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES] = "Múltipla escolha" #endif , - [Tst_ANS_TEXT] = + [Qst_ANS_TEXT] = #if L==1 // ca "Text" #elif L==2 // de