mirror of https://github.com/acanas/swad-core.git
Version 21.42: Oct 24, 2021 Code refactoring in test questions.
This commit is contained in:
parent
b43d01c99f
commit
265aa7e578
18
swad_API.c
18
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,
|
||||
|
|
|
@ -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},
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
||||
" size=\"11\" maxlength=\"%u\" value=\"%s\"",
|
||||
Id,Tst_MAX_BYTES_FLOAT_ANSWER,
|
||||
Id,Qst_MAX_BYTES_FLOAT_ANSWER,
|
||||
Print->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 ("<input type=\"%s\" id=\"%s_%u\" name=\"Ans\" value=\"%u\"%s",
|
||||
Question->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 ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
||||
" size=\"40\" maxlength=\"%u\" value=\"%s\"",
|
||||
Id,Tst_MAX_CHARS_ANSWERS_ONE_QST,
|
||||
Id,Qst_MAX_CHARS_ANSWERS_ONE_QST,
|
||||
Print->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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ();
|
||||
|
||||
|
|
122
swad_exam_set.c
122
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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
16
swad_game.c
16
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);
|
||||
|
|
60
swad_match.c
60
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
|
|
67
swad_tag.c
67
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ***********/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
|
||||
#include <mysql/mysql.h> // To access MySQL databases
|
||||
#include <stdbool.h> // 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);
|
||||
|
|
2584
swad_test.c
2584
swad_test.c
File diff suppressed because it is too large
Load Diff
89
swad_test.h
89
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
|
||||
|
|
|
@ -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,"<question type=\"%s\">%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");
|
||||
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)
|
||||
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"
|
||||
"<lower>%.15lg</lower>%s"
|
||||
"<upper>%.15lg</upper>%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,"<option");
|
||||
|
||||
/* Write whether the answer is correct or not */
|
||||
if (Question->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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
14
swad_text.c
14
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
|
||||
|
|
Loading…
Reference in New Issue