mirror of https://github.com/acanas/swad-core.git
Version 20.68.1: Apr 26, 2021 Code refactoring in exams and tests.
This commit is contained in:
parent
9af6b0d4f9
commit
40a4e56125
|
@ -1654,7 +1654,7 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
|
|||
/***** Write page from file to text buffer *****/
|
||||
/* Open file */
|
||||
if ((FileHTML = fopen (PathRelFileHTML,"rb")) == NULL)
|
||||
Err_ShowErrorAndExit ("Can not open XML file.");
|
||||
Err_FileFolderNotFoundExit ();
|
||||
|
||||
/* Compute file size */
|
||||
fseek (FileHTML,0L,SEEK_END);
|
||||
|
|
|
@ -600,13 +600,14 @@ TODO: Salvador Romero Cort
|
|||
|
||||
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.68 (2021-04-26)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.68.1 (2021-04-26)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.6.2.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 20.68.1: Apr 26, 2021 Code refactoring in exams and tests. (309862 lines)
|
||||
Version 20.68: Apr 26, 2021 New module swad_error. (309853 lines)
|
||||
Version 20.67.11: Apr 26, 2021 Fixed bug in departments. (309677 lines)
|
||||
Version 20.67.10: Apr 25, 2021 Fixed bug in notification about new assignment, reported by Eva Martínez Ortigosa. (? lines)
|
||||
|
|
|
@ -79,7 +79,7 @@ void Cfg_GetConfigFromFile (void)
|
|||
/***** Read config from file to string *****/
|
||||
/* Open config file */
|
||||
if ((FileCfg = fopen (Cfg_FILE_CONFIG,"rb")) == NULL)
|
||||
Err_ShowErrorAndExit ("Can not open config file.");
|
||||
Err_FileFolderNotFoundExit ();
|
||||
|
||||
/* Compute file size */
|
||||
fseek (FileCfg,0L,SEEK_END);
|
||||
|
|
|
@ -561,7 +561,7 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
|
|||
|
||||
/***** Check if user's code is initialized *****/
|
||||
if (UsrDat->UsrCod <= 0)
|
||||
Err_ShowErrorAndExit ("Can not update user's data. Wrong user's code.");
|
||||
Err_WrongUserExit ();
|
||||
|
||||
/***** Filter some user's data before updating */
|
||||
Enr_FilterUsrDat (UsrDat);
|
||||
|
|
|
@ -202,6 +202,15 @@ void Err_WrongFileBrowserExit (void)
|
|||
Err_ShowErrorAndExit ("Wrong file browser.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Write error message and exit when file/folder does not exist ********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_FileFolderNotFoundExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("File/folder not found.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong copy source *************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -58,6 +58,7 @@ void Err_WrongItemsListExit (void);
|
|||
void Err_WrongItemExit (void);
|
||||
void Err_WrongSyllabusFormatExit (void);
|
||||
void Err_WrongFileBrowserExit (void);
|
||||
void Err_FileFolderNotFoundExit (void);
|
||||
void Err_WrongCopySrcExit (void);
|
||||
void Err_WrongNumberOfRowsExit (void);
|
||||
void Err_WrongGrpTypExit (void);
|
||||
|
|
|
@ -87,32 +87,32 @@ static void ExaPrn_GetAndWriteDescription (long ExaCod);
|
|||
static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams,
|
||||
const struct ExaPrn_Print *Print);
|
||||
static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question);
|
||||
static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question);
|
||||
static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void ExaPrn_WriteJSToUpdateExamPrint (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
const char *Id,int NumOpt);
|
||||
|
||||
static void ExaPrn_GetAnswerFromForm (struct ExaPrn_Print *Print,unsigned QstInd);
|
||||
|
@ -120,7 +120,7 @@ static void ExaPrn_GetAnswerFromForm (struct ExaPrn_Print *Print,unsigned QstInd
|
|||
static unsigned ExaPrn_GetParamQstInd (void);
|
||||
|
||||
static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Print,
|
||||
unsigned NumQst);
|
||||
unsigned QstInd);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void ExaPrn_GetCorrectAndComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
|
@ -144,7 +144,7 @@ static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question);
|
|||
static void ExaPrn_GetAnswerFromDB (struct ExaPrn_Print *Print,long QstCod,
|
||||
char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]);
|
||||
static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst);
|
||||
unsigned QstInd);
|
||||
|
||||
static void ExaPrn_GetNumQstsNotBlank (struct ExaPrn_Print *Print);
|
||||
static void ExaPrn_ComputeTotalScoreOfPrint (struct ExaPrn_Print *Print);
|
||||
|
@ -580,7 +580,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed
|
|||
|
||||
static void ExaPrn_CreatePrintInDB (struct ExaPrn_Print *Print)
|
||||
{
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
|
||||
/***** Insert new exam print into table *****/
|
||||
Print->PrnCod =
|
||||
|
@ -597,10 +597,10 @@ static void ExaPrn_CreatePrintInDB (struct ExaPrn_Print *Print)
|
|||
|
||||
/***** Store all questions (with blank answers)
|
||||
of this exam print just generated in database *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
ExaPrn_StoreOneQstOfPrintInDB (Print,NumQst);
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
ExaPrn_StoreOneQstOfPrintInDB (Print,QstInd);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -611,7 +611,7 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
|
|||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
|
||||
/***** Get questions of an exam print from database *****/
|
||||
Print->NumQsts.All = (unsigned)
|
||||
|
@ -628,33 +628,33 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
|
|||
|
||||
/***** Get questions *****/
|
||||
if (Print->NumQsts.All <= ExaPrn_MAX_QUESTIONS_PER_EXAM_PRINT)
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
if ((Print->PrintedQuestions[QstInd].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get set code (row[1]) */
|
||||
if ((Print->PrintedQuestions[NumQst].SetCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
|
||||
if ((Print->PrintedQuestions[QstInd].SetCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
|
||||
Err_WrongSetExit ();
|
||||
|
||||
/* Get score (row[2]) */
|
||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||
if (sscanf (row[2],"%lf",&Print->PrintedQuestions[NumQst].Score) != 1)
|
||||
if (sscanf (row[2],"%lf",&Print->PrintedQuestions[QstInd].Score) != 1)
|
||||
Err_ShowErrorAndExit ("Wrong question score.");
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
|
||||
/* Get indexes for this question (row[3]) */
|
||||
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[3],
|
||||
sizeof (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
|
||||
Str_Copy (Print->PrintedQuestions[QstInd].StrIndexes,row[3],
|
||||
sizeof (Print->PrintedQuestions[QstInd].StrIndexes) - 1);
|
||||
|
||||
/* Get answers selected by user for this question (row[4]) */
|
||||
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[4],
|
||||
sizeof (Print->PrintedQuestions[NumQst].StrAnswers) - 1);
|
||||
Str_Copy (Print->PrintedQuestions[QstInd].StrAnswers,row[4],
|
||||
sizeof (Print->PrintedQuestions[QstInd].StrAnswers) - 1);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
@ -740,26 +740,26 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams,
|
|||
const struct ExaPrn_Print *Print)
|
||||
{
|
||||
extern const char *Txt_I_have_finished;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWideMarginPadding (10);
|
||||
|
||||
/***** Write one row for each question *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
/* Create test question */
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
|
||||
/* Get question from database */
|
||||
ExaSet_GetQstDataFromDB (&Question);
|
||||
|
||||
/* Write question and answers */
|
||||
ExaPrn_WriteQstAndAnsToFill (Print,NumQst,&Question);
|
||||
ExaPrn_WriteQstAndAnsToFill (Print,QstInd,&Question);
|
||||
|
||||
/* Destroy test question */
|
||||
Tst_QstDestructor (&Question);
|
||||
|
@ -780,7 +780,7 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question)
|
||||
{
|
||||
static struct ExaSet_Set CurrentSet =
|
||||
|
@ -792,10 +792,10 @@ static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print,
|
|||
.Title[0] = '\0'
|
||||
};
|
||||
|
||||
if (Print->PrintedQuestions[NumQst].SetCod != CurrentSet.SetCod)
|
||||
if (Print->PrintedQuestions[QstInd].SetCod != CurrentSet.SetCod)
|
||||
{
|
||||
/***** Get data of this set *****/
|
||||
CurrentSet.SetCod = Print->PrintedQuestions[NumQst].SetCod;
|
||||
CurrentSet.SetCod = Print->PrintedQuestions[QstInd].SetCod;
|
||||
ExaSet_GetDataOfSetByCod (&CurrentSet);
|
||||
|
||||
/***** Title for this set *****/
|
||||
|
@ -811,7 +811,7 @@ static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print,
|
|||
|
||||
/***** Number of question and answer type *****/
|
||||
HTM_TD_Begin ("class=\"RT\"");
|
||||
Tst_WriteNumQst (NumQst + 1,"BIG_INDEX");
|
||||
Tst_WriteNumQst (QstInd + 1,"BIG_INDEX");
|
||||
Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL");
|
||||
HTM_TD_End ();
|
||||
|
||||
|
@ -828,7 +828,7 @@ static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print,
|
|||
|
||||
/* Answers */
|
||||
Frm_BeginFormNoAction (); // Form that can not be submitted, to avoid enter key to send it
|
||||
ExaPrn_WriteAnswersToFill (Print,NumQst,Question);
|
||||
ExaPrn_WriteAnswersToFill (Print,QstInd,Question);
|
||||
Frm_EndForm ();
|
||||
|
||||
HTM_TD_End ();
|
||||
|
@ -842,11 +842,11 @@ static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question)
|
||||
{
|
||||
void (*ExaPrn_WriteAnsToFill[Tst_NUM_ANS_TYPES]) (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question) =
|
||||
{
|
||||
[Tst_ANS_INT ] = ExaPrn_WriteIntAnsToFill,
|
||||
|
@ -858,7 +858,7 @@ static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print,
|
|||
};
|
||||
|
||||
/***** Write answers *****/
|
||||
ExaPrn_WriteAnsToFill[Question->Answer.Type] (Print,NumQst,Question);
|
||||
ExaPrn_WriteAnsToFill[Question->Answer.Type] (Print,QstInd,Question);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -866,17 +866,17 @@ static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question)
|
||||
{
|
||||
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
||||
/***** Write input field for the answer *****/
|
||||
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||
snprintf (Id,sizeof (Id),"Ans%010u",QstInd);
|
||||
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"Ans\""
|
||||
" size=\"11\" maxlength=\"11\" value=\"%s\"",
|
||||
Id,Print->PrintedQuestions[NumQst].StrAnswers);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
||||
Id,Print->PrintedQuestions[QstInd].StrAnswers);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,-1);
|
||||
HTM_Txt (" />");
|
||||
}
|
||||
|
||||
|
@ -885,18 +885,18 @@ static void ExaPrn_WriteIntAnsToFill (const struct ExaPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question)
|
||||
{
|
||||
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
||||
/***** Write input field for the answer *****/
|
||||
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||
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,
|
||||
Print->PrintedQuestions[NumQst].StrAnswers);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
||||
Print->PrintedQuestions[QstInd].StrAnswers);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,-1);
|
||||
HTM_Txt (" />");
|
||||
}
|
||||
|
||||
|
@ -905,7 +905,7 @@ static void ExaPrn_WriteFltAnsToFill (const struct ExaPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question)
|
||||
{
|
||||
extern const char *Txt_TF_QST[2];
|
||||
|
@ -915,13 +915,13 @@ static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print,
|
|||
/* Initially user has not answered the question ==> initially all the answers will be blank.
|
||||
If the user does not confirm the submission of their exam ==>
|
||||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||
snprintf (Id,sizeof (Id),"Ans%010u",QstInd);
|
||||
HTM_TxtF ("<select id=\"%s\" name=\"Ans\"",Id);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,-1);
|
||||
HTM_Txt (" />");
|
||||
HTM_OPTION (HTM_Type_STRING,"" ,Print->PrintedQuestions[NumQst].StrAnswers[0] == '\0',false," ");
|
||||
HTM_OPTION (HTM_Type_STRING,"T",Print->PrintedQuestions[NumQst].StrAnswers[0] == 'T' ,false,"%s",Txt_TF_QST[0]);
|
||||
HTM_OPTION (HTM_Type_STRING,"F",Print->PrintedQuestions[NumQst].StrAnswers[0] == 'F' ,false,"%s",Txt_TF_QST[1]);
|
||||
HTM_OPTION (HTM_Type_STRING,"" ,Print->PrintedQuestions[QstInd].StrAnswers[0] == '\0',false," ");
|
||||
HTM_OPTION (HTM_Type_STRING,"T",Print->PrintedQuestions[QstInd].StrAnswers[0] == 'T' ,false,"%s",Txt_TF_QST[0]);
|
||||
HTM_OPTION (HTM_Type_STRING,"F",Print->PrintedQuestions[QstInd].StrAnswers[0] == 'F' ,false,"%s",Txt_TF_QST[1]);
|
||||
HTM_Txt ("</select>");
|
||||
}
|
||||
|
||||
|
@ -930,7 +930,7 @@ static void ExaPrn_WriteTF_AnsToFill (const struct ExaPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question)
|
||||
{
|
||||
unsigned NumOpt;
|
||||
|
@ -942,10 +942,10 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print,
|
|||
Tst_ChangeFormatAnswersText (Question);
|
||||
|
||||
/***** Get indexes for this question from string *****/
|
||||
TstPrn_GetIndexesFromStr (Print->PrintedQuestions[NumQst].StrIndexes,Indexes);
|
||||
TstPrn_GetIndexesFromStr (Print->PrintedQuestions[QstInd].StrIndexes,Indexes);
|
||||
|
||||
/***** Get the user's answers for this question from string *****/
|
||||
TstPrn_GetAnswersFromStr (Print->PrintedQuestions[NumQst].StrAnswers,UsrAnswers);
|
||||
TstPrn_GetAnswersFromStr (Print->PrintedQuestions[QstInd].StrAnswers,UsrAnswers);
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginPadding (2);
|
||||
|
@ -963,26 +963,26 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print,
|
|||
If the user does not confirm the submission of their exam ==>
|
||||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||
HTM_TD_Begin ("class=\"LT\"");
|
||||
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||
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" :
|
||||
"checkbox",
|
||||
Id,NumOpt,Indexes[NumOpt],
|
||||
UsrAnswers[Indexes[NumOpt]] ? " checked=\"checked\"" :
|
||||
"");
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,(int) NumOpt);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,(int) NumOpt);
|
||||
HTM_Txt (" />");
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TD_Begin ("class=\"LT\"");
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",NumQst,NumOpt);
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt);
|
||||
HTM_TxtF ("%c) ",'a' + (char) NumOpt);
|
||||
HTM_LABEL_End ();
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** Write the option text *****/
|
||||
HTM_TD_Begin ("class=\"LT\"");
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",NumQst,NumOpt);
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt);
|
||||
HTM_Txt (Question->Answer.Options[Indexes[NumOpt]].Text);
|
||||
HTM_LABEL_End ();
|
||||
Med_ShowMedia (&Question->Answer.Options[Indexes[NumOpt]].Media,
|
||||
|
@ -1002,18 +1002,18 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question)
|
||||
{
|
||||
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
||||
/***** Write input field for the answer *****/
|
||||
snprintf (Id,sizeof (Id),"Ans%010u",NumQst);
|
||||
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,
|
||||
Print->PrintedQuestions[NumQst].StrAnswers);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,NumQst,Id,-1);
|
||||
Print->PrintedQuestions[QstInd].StrAnswers);
|
||||
ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,-1);
|
||||
|
||||
HTM_Txt (" />");
|
||||
}
|
||||
|
@ -1023,20 +1023,20 @@ static void ExaPrn_WriteTxtAnsToFill (const struct ExaPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_WriteJSToUpdateExamPrint (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
const char *Id,int NumOpt)
|
||||
{
|
||||
if (NumOpt < 0)
|
||||
HTM_TxtF (" onchange=\"updateExamPrint('examprint','%s','Ans',"
|
||||
"'act=%ld&ses=%s&SesCod=%ld&NumQst=%u',%u);",
|
||||
"'act=%ld&ses=%s&SesCod=%ld&QstInd=%u',%u);",
|
||||
Id,
|
||||
Act_GetActCod (ActAnsExaPrn),Gbl.Session.Id,Print->SesCod,NumQst,
|
||||
Act_GetActCod (ActAnsExaPrn),Gbl.Session.Id,Print->SesCod,QstInd,
|
||||
(unsigned) Gbl.Prefs.Language);
|
||||
else // NumOpt >= 0
|
||||
HTM_TxtF (" onclick=\"updateExamPrint('examprint','%s_%d','Ans',"
|
||||
"'act=%ld&ses=%s&SesCod=%ld&NumQst=%u',%u);",
|
||||
"'act=%ld&ses=%s&SesCod=%ld&QstInd=%u',%u);",
|
||||
Id,NumOpt,
|
||||
Act_GetActCod (ActAnsExaPrn),Gbl.Session.Id,Print->SesCod,NumQst,
|
||||
Act_GetActCod (ActAnsExaPrn),Gbl.Session.Id,Print->SesCod,QstInd,
|
||||
(unsigned) Gbl.Prefs.Language);
|
||||
HTM_Txt (" return false;\""); // return false is necessary to not submit form
|
||||
}
|
||||
|
@ -1145,18 +1145,17 @@ static void ExaPrn_GetAnswerFromForm (struct ExaPrn_Print *Print,unsigned QstInd
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get parameter with index of question ********************/
|
||||
/********************* Get parameter with question index *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned ExaPrn_GetParamQstInd (void)
|
||||
{
|
||||
long NumQst;
|
||||
long QstInd;
|
||||
|
||||
NumQst = Par_GetParToLong ("NumQst");
|
||||
if (NumQst < 0)
|
||||
Err_ShowErrorAndExit ("Wrong number of question.");
|
||||
if ((QstInd = Par_GetParToLong ("QstInd")) < 0)
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
return (unsigned) NumQst;
|
||||
return (unsigned) QstInd;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1164,36 +1163,36 @@ static unsigned ExaPrn_GetParamQstInd (void)
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Print,
|
||||
unsigned NumQst)
|
||||
unsigned QstInd)
|
||||
{
|
||||
struct Tst_Question Question;
|
||||
char CurrentStrAnswersInDB[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user
|
||||
|
||||
/***** Compute question score *****/
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
Question.Answer.Type = ExaSet_GetQstAnswerTypeFromDB (Question.QstCod);
|
||||
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[NumQst],&Question);
|
||||
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question);
|
||||
Tst_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)
|
||||
{
|
||||
ExaPrn_GetAnswerFromDB (Print,Print->PrintedQuestions[NumQst].QstCod,
|
||||
ExaPrn_GetAnswerFromDB (Print,Print->PrintedQuestions[QstInd].QstCod,
|
||||
CurrentStrAnswersInDB);
|
||||
if (!strcmp (Print->PrintedQuestions[NumQst].StrAnswers,CurrentStrAnswersInDB))
|
||||
if (!strcmp (Print->PrintedQuestions[QstInd].StrAnswers,CurrentStrAnswersInDB))
|
||||
{
|
||||
/* The answer just clicked by user
|
||||
is the same as the last one checked and stored in database */
|
||||
Print->PrintedQuestions[NumQst].StrAnswers[0] = '\0'; // Uncheck option
|
||||
Print->PrintedQuestions[NumQst].Score = 0; // Clear question score
|
||||
Print->PrintedQuestions[QstInd].StrAnswers[0] = '\0'; // Uncheck option
|
||||
Print->PrintedQuestions[QstInd].Score = 0; // Clear question score
|
||||
}
|
||||
}
|
||||
|
||||
/***** Store test exam question in database *****/
|
||||
ExaPrn_StoreOneQstOfPrintInDB (Print,
|
||||
NumQst); // 0, 1, 2, 3...
|
||||
QstInd); // 0, 1, 2, 3...
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1463,7 +1462,7 @@ static void ExaPrn_GetAnswerFromDB (struct ExaPrn_Print *Print,long QstCod,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst)
|
||||
unsigned QstInd)
|
||||
{
|
||||
/***** Insert question and user's answers into database *****/
|
||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||
|
@ -1473,12 +1472,12 @@ static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print,
|
|||
" VALUES"
|
||||
" (%ld,%ld,%u,%ld,'%.15lg','%s','%s')",
|
||||
Print->PrnCod,
|
||||
Print->PrintedQuestions[NumQst].QstCod,
|
||||
NumQst, // 0, 1, 2, 3...
|
||||
Print->PrintedQuestions[NumQst].SetCod,
|
||||
Print->PrintedQuestions[NumQst].Score,
|
||||
Print->PrintedQuestions[NumQst].StrIndexes,
|
||||
Print->PrintedQuestions[NumQst].StrAnswers);
|
||||
Print->PrintedQuestions[QstInd].QstCod,
|
||||
QstInd, // 0, 1, 2, 3...
|
||||
Print->PrintedQuestions[QstInd].SetCod,
|
||||
Print->PrintedQuestions[QstInd].Score,
|
||||
Print->PrintedQuestions[QstInd].StrIndexes,
|
||||
Print->PrintedQuestions[QstInd].StrAnswers);
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat,
|
|||
unsigned Visibility);
|
||||
static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
||||
struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question,
|
||||
unsigned Visibility);
|
||||
|
||||
|
@ -1548,7 +1548,7 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print)
|
|||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
bool QuestionExists;
|
||||
|
||||
|
@ -1561,12 +1561,12 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print)
|
|||
Print->NumQsts.Valid.Total = 0;
|
||||
Print->Score.Valid = 0.0;
|
||||
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
/***** Copy question code *****/
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
|
||||
/***** Get validity and answer type from database *****/
|
||||
QuestionExists = (DB_QuerySELECT (&mysql_res,"can not get a question",
|
||||
|
@ -1594,8 +1594,8 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print)
|
|||
if (QuestionExists)
|
||||
if (Question.Validity == Tst_VALID_QUESTION)
|
||||
{
|
||||
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[NumQst],&Question);
|
||||
switch (Print->PrintedQuestions[NumQst].AnswerIsCorrect)
|
||||
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question);
|
||||
switch (Print->PrintedQuestions[QstInd].AnswerIsCorrect)
|
||||
{
|
||||
case TstPrn_ANSWER_IS_CORRECT:
|
||||
Print->NumQsts.Valid.Correct++;
|
||||
|
@ -1614,7 +1614,7 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print)
|
|||
break;
|
||||
}
|
||||
Print->NumQsts.Valid.Total++;
|
||||
Print->Score.Valid += Print->PrintedQuestions[NumQst].Score;
|
||||
Print->Score.Valid += Print->PrintedQuestions[QstInd].Score;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1889,24 +1889,24 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat,
|
|||
struct ExaPrn_Print *Print,
|
||||
unsigned Visibility)
|
||||
{
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/***** Create test question *****/
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
|
||||
/***** Get question data *****/
|
||||
ExaSet_GetQstDataFromDB (&Question);
|
||||
|
||||
/***** Write questions and answers *****/
|
||||
ExaRes_WriteQstAndAnsExam (UsrDat,Print,NumQst,&Question,Visibility);
|
||||
ExaRes_WriteQstAndAnsExam (UsrDat,Print,QstInd,&Question,Visibility);
|
||||
|
||||
/***** Destroy test question *****/
|
||||
Tst_QstDestructor (&Question);
|
||||
|
@ -1919,7 +1919,7 @@ static void ExaRes_ShowExamAnswers (struct UsrData *UsrDat,
|
|||
|
||||
static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
||||
struct ExaPrn_Print *Print,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question,
|
||||
unsigned Visibility)
|
||||
{
|
||||
|
@ -1980,7 +1980,7 @@ static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
|||
|
||||
/***** Number of question and answer type *****/
|
||||
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
Tst_WriteNumQst (NumQst + 1,ClassNumQst[Question->Validity]);
|
||||
Tst_WriteNumQst (QstInd + 1,ClassNumQst[Question->Validity]);
|
||||
Tst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]);
|
||||
HTM_TD_End ();
|
||||
|
||||
|
@ -1998,8 +1998,8 @@ static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
|||
"TEST_MED_SHOW");
|
||||
|
||||
/* Answers */
|
||||
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[NumQst],Question);
|
||||
TstPrn_WriteAnswersExam (UsrDat,&Print->PrintedQuestions[NumQst],Question,
|
||||
ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],Question);
|
||||
TstPrn_WriteAnswersExam (UsrDat,&Print->PrintedQuestions[QstInd],Question,
|
||||
ICanView,
|
||||
ClassTxt[Question->Validity],
|
||||
ClassFeedback[Question->Validity]);
|
||||
|
@ -2010,11 +2010,11 @@ static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
|||
HTM_DIV_Begin ("class=\"DAT_SMALL LM\"");
|
||||
HTM_TxtColonNBSP (Txt_Score);
|
||||
HTM_SPAN_Begin ("class=\"%s\"",
|
||||
Print->PrintedQuestions[NumQst].StrAnswers[0] ?
|
||||
(Print->PrintedQuestions[NumQst].Score > 0 ? "ANS_OK" : // Correct/semicorrect
|
||||
Print->PrintedQuestions[QstInd].StrAnswers[0] ?
|
||||
(Print->PrintedQuestions[QstInd].Score > 0 ? "ANS_OK" : // Correct/semicorrect
|
||||
"ANS_BAD") : // Wrong
|
||||
"ANS_0"); // Blank answer
|
||||
HTM_Double2Decimals (Print->PrintedQuestions[NumQst].Score);
|
||||
HTM_Double2Decimals (Print->PrintedQuestions[QstInd].Score);
|
||||
if (Question->Validity == Tst_INVALID_QUESTION)
|
||||
HTM_TxtF (" (%s)",Txt_Invalid_question);
|
||||
HTM_SPAN_End ();
|
||||
|
|
|
@ -1223,7 +1223,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
|
|||
extern const char *Txt_Questions;
|
||||
extern const char *Txt_No_INDEX;
|
||||
extern const char *Txt_Question;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
char *Anchor;
|
||||
static Act_Action_t NextAction[Tst_NUM_VALIDITIES] =
|
||||
|
@ -1254,11 +1254,11 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
|
|||
HTM_TR_End ();
|
||||
|
||||
/***** Write rows *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < NumQsts;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < NumQsts;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/***** Create test question *****/
|
||||
Tst_QstConstructor (&Question);
|
||||
|
@ -1292,7 +1292,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
|
|||
HTM_TD_End ();
|
||||
|
||||
/***** List question *****/
|
||||
ExaSet_ListQuestionForEdition (&Question,NumQst + 1,Anchor);
|
||||
ExaSet_ListQuestionForEdition (&Question,QstInd + 1,Anchor);
|
||||
|
||||
/***** End row *****/
|
||||
HTM_TR_End ();
|
||||
|
|
|
@ -6650,7 +6650,7 @@ void Brw_RemFileFromTree (void)
|
|||
FileNameToShow);
|
||||
}
|
||||
else // File / link not found
|
||||
Err_ShowErrorAndExit ("File / link not found.");
|
||||
Err_FileFolderNotFoundExit ();
|
||||
}
|
||||
else
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_remove_this_file_or_link);
|
||||
|
@ -6703,7 +6703,7 @@ void Brw_RemFolderFromTree (void)
|
|||
Gbl.FileBrowser.FilFolLnk.Name);
|
||||
}
|
||||
else // Folder not found
|
||||
Err_ShowErrorAndExit ("Folder not found.");
|
||||
Err_FileFolderNotFoundExit ();
|
||||
}
|
||||
else
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_remove_this_folder);
|
||||
|
|
82
swad_test.c
82
swad_test.c
|
@ -155,7 +155,7 @@ static void Tst_ListOneQstToEdit (struct Tst_Test *Test);
|
|||
static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
|
||||
MYSQL_RES *mysql_res);
|
||||
static void Tst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test);
|
||||
static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned NumQst);
|
||||
static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd);
|
||||
static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exams,
|
||||
unsigned NumQsts,
|
||||
MYSQL_RES *mysql_res);
|
||||
|
@ -163,7 +163,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
|
|||
unsigned NumQsts,
|
||||
MYSQL_RES *mysql_res);
|
||||
static void Tst_PutCheckboxToSelectAllQuestions (void);
|
||||
static void Tst_WriteQuestionRowForSelection (unsigned NumQst,
|
||||
static void Tst_WriteQuestionRowForSelection (unsigned QstInd,
|
||||
struct Tst_Question *Question);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -564,19 +564,19 @@ void Tst_AssessTest (void)
|
|||
|
||||
static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print)
|
||||
{
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
||||
/***** Loop for every question getting user's answers *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
/* Get answers selected by user for this question */
|
||||
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
|
||||
Par_GetParMultiToText (StrAns,Print->PrintedQuestions[NumQst].StrAnswers,
|
||||
snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd);
|
||||
Par_GetParMultiToText (StrAns,Print->PrintedQuestions[QstInd].StrAnswers,
|
||||
Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */
|
||||
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrAnswers);
|
||||
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[QstInd].StrAnswers);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1890,7 +1890,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
Tst_AnswerType_t AnswerType;
|
||||
bool Shuffle;
|
||||
char StrNumQsts[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
|
||||
/***** Trivial check: number of questions *****/
|
||||
if (Test->NumQsts == 0 ||
|
||||
|
@ -1987,9 +1987,9 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
Query);
|
||||
|
||||
/***** Get questions and answers from database *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
/* Get question row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -2000,7 +2000,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
*/
|
||||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
if ((Print->PrintedQuestions[QstInd].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Err_ShowErrorAndExit ("Wrong code of question.");
|
||||
|
||||
/* Get answer type (row[1]) */
|
||||
|
@ -2016,13 +2016,13 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
case Tst_ANS_FLOAT:
|
||||
case Tst_ANS_TRUE_FALSE:
|
||||
case Tst_ANS_TEXT:
|
||||
Print->PrintedQuestions[NumQst].StrIndexes[0] = '\0';
|
||||
Print->PrintedQuestions[QstInd].StrIndexes[0] = '\0';
|
||||
break;
|
||||
case Tst_ANS_UNIQUE_CHOICE:
|
||||
case Tst_ANS_MULTIPLE_CHOICE:
|
||||
/* If answer type is unique or multiple option,
|
||||
generate indexes of answers depending on shuffle */
|
||||
Tst_GenerateChoiceIndexes (&Print->PrintedQuestions[NumQst],Shuffle);
|
||||
Tst_GenerateChoiceIndexes (&Print->PrintedQuestions[QstInd],Shuffle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2032,7 +2032,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
Initially user has not answered the question ==> initially all the answers will be blank.
|
||||
If the user does not confirm the submission of their exam ==>
|
||||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||
Print->PrintedQuestions[NumQst].StrAnswers[0] = '\0';
|
||||
Print->PrintedQuestions[QstInd].StrAnswers[0] = '\0';
|
||||
}
|
||||
|
||||
/***** Get if test exam will be visible by teachers *****/
|
||||
|
@ -2145,7 +2145,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
|
|||
{
|
||||
extern const char *Hlp_ASSESSMENT_Tests;
|
||||
extern const char *Txt_Questions;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
MYSQL_ROW row;
|
||||
|
||||
/***** Begin box *****/
|
||||
|
@ -2158,11 +2158,11 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
|
|||
Tst_WriteHeadingRowQuestionsForEdition (Test);
|
||||
|
||||
/***** Write rows *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Test->NumQsts;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Test->NumQsts;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/***** Create test question *****/
|
||||
Tst_QstConstructor (&Test->Question);
|
||||
|
@ -2173,7 +2173,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
|
|||
Err_WrongQuestionExit ();
|
||||
|
||||
/***** Write question row *****/
|
||||
Tst_WriteQuestionListing (Test,NumQst);
|
||||
Tst_WriteQuestionListing (Test,QstInd);
|
||||
|
||||
/***** Destroy test question *****/
|
||||
Tst_QstDestructor (&Test->Question);
|
||||
|
@ -2254,7 +2254,7 @@ static void Tst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test)
|
|||
/********** Write question row in listing of questions for edition ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned NumQst)
|
||||
static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd)
|
||||
{
|
||||
static unsigned UniqueId = 0;
|
||||
char *Id;
|
||||
|
@ -2280,7 +2280,7 @@ static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned NumQst)
|
|||
|
||||
/* Number of question and answer type */
|
||||
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
Tst_WriteNumQst (NumQst + 1,"BIG_INDEX");
|
||||
Tst_WriteNumQst (QstInd + 1,"BIG_INDEX");
|
||||
Tst_WriteAnswerType (Test->Question.Answer.Type,"DAT_SMALL");
|
||||
HTM_TD_End ();
|
||||
|
||||
|
@ -2388,7 +2388,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam
|
|||
extern const char *Txt_Shuffle;
|
||||
extern const char *Txt_Question;
|
||||
extern const char *Txt_Add_questions;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
MYSQL_ROW row;
|
||||
|
||||
|
@ -2421,11 +2421,11 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam
|
|||
HTM_TR_End ();
|
||||
|
||||
/***** Write rows *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < NumQsts;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < NumQsts;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/* Create test question */
|
||||
Tst_QstConstructor (&Question);
|
||||
|
@ -2436,7 +2436,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam
|
|||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Write question row */
|
||||
Tst_WriteQuestionRowForSelection (NumQst,&Question);
|
||||
Tst_WriteQuestionRowForSelection (QstInd,&Question);
|
||||
|
||||
/* Destroy test question */
|
||||
Tst_QstDestructor (&Question);
|
||||
|
@ -2473,7 +2473,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
|
|||
extern const char *Txt_Shuffle;
|
||||
extern const char *Txt_Question;
|
||||
extern const char *Txt_Add_questions;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
MYSQL_ROW row;
|
||||
|
||||
|
@ -2506,11 +2506,11 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
|
|||
HTM_TR_End ();
|
||||
|
||||
/***** Write rows *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < NumQsts;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < NumQsts;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/* Create test question */
|
||||
Tst_QstConstructor (&Question);
|
||||
|
@ -2521,7 +2521,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
|
|||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Write question row */
|
||||
Tst_WriteQuestionRowForSelection (NumQst,&Question);
|
||||
Tst_WriteQuestionRowForSelection (QstInd,&Question);
|
||||
|
||||
/* Destroy test question */
|
||||
Tst_QstDestructor (&Question);
|
||||
|
@ -2561,7 +2561,7 @@ static void Tst_PutCheckboxToSelectAllQuestions (void)
|
|||
/********************** Write question row for selection *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Tst_WriteQuestionRowForSelection (unsigned NumQst,
|
||||
static void Tst_WriteQuestionRowForSelection (unsigned QstInd,
|
||||
struct Tst_Question *Question)
|
||||
{
|
||||
extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES];
|
||||
|
@ -2584,7 +2584,7 @@ static void Tst_WriteQuestionRowForSelection (unsigned NumQst,
|
|||
|
||||
/* Write number of question */
|
||||
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
HTM_TxtF ("%u ",NumQst + 1);
|
||||
HTM_TxtF ("%u ",QstInd + 1);
|
||||
HTM_TD_End ();
|
||||
|
||||
/* Write question code */
|
||||
|
@ -2889,11 +2889,11 @@ void Tst_WriteAnsTF (char AnsTF)
|
|||
/*************** Write parameter with the code of a question *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Tst_WriteParamQstCod (unsigned NumQst,long QstCod)
|
||||
void Tst_WriteParamQstCod (unsigned QstInd,long QstCod)
|
||||
{
|
||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
||||
snprintf (StrAns,sizeof (StrAns),"Qst%010u",NumQst);
|
||||
snprintf (StrAns,sizeof (StrAns),"Qst%010u",QstInd);
|
||||
Par_PutHiddenParamLong (NULL,StrAns,QstCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,27 +80,27 @@ extern struct Globals Gbl;
|
|||
static void TstPrn_ResetPrintExceptPrnCod (struct TstPrn_Print *Print);
|
||||
|
||||
static void TstPrn_WriteQstAndAnsToFill (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question);
|
||||
static void TstPrn_WriteAnswersToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
static void TstPrn_WriteTF_AnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question);
|
||||
static void TstPrn_WriteTxtAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question);
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
@ -108,7 +108,7 @@ static void TstPrn_PutCheckBoxAllowTeachers (bool AllowTeachers);
|
|||
|
||||
static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
||||
struct TstPrn_PrintedQuestion PrintedQuestions[TstCfg_MAX_QUESTIONS_PER_TEST],
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
time_t TimeUTC[Dat_NUM_START_END_TIME],
|
||||
struct Tst_Question *Question,
|
||||
bool QuestionExists,
|
||||
|
@ -167,7 +167,7 @@ static void TstPrn_WriteTxtAnsPrint (struct UsrData *UsrDat,
|
|||
static void TstPrn_WriteHeadUserCorrect (struct UsrData *UsrDat);
|
||||
|
||||
static void TstPrn_StoreOneQstOfPrintInDB (const struct TstPrn_Print *Print,
|
||||
unsigned NumQst);
|
||||
unsigned QstInd);
|
||||
|
||||
static void TstPrn_PutFormToSelectUsrsToViewUsrsPrints (__attribute__((unused)) void *Args);
|
||||
|
||||
|
@ -270,7 +270,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
|
|||
extern const char *Txt_Test;
|
||||
extern const char *Txt_Continue;
|
||||
extern const char *Txt_Send;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
static const Act_Action_t Action[Tst_NUM_REQUEST_OR_CONFIRM] =
|
||||
{
|
||||
|
@ -294,49 +294,51 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
|
|||
TstPrn_PutParamPrnCod (Print->PrnCod);
|
||||
Par_PutHiddenParamUnsigned (NULL,"NumTst",NumExamsGeneratedByMe);
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWideMarginPadding (10);
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWideMarginPadding (10);
|
||||
|
||||
/***** Write one row for each question *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
/***** Write one row for each question *****/
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/* Create test question */
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
/* Create test question */
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
|
||||
/* Show question */
|
||||
if (!Tst_GetQstDataFromDB (&Question)) // Question exists
|
||||
Err_WrongQuestionExit ();
|
||||
/* Show question */
|
||||
if (!Tst_GetQstDataFromDB (&Question)) // Question exists
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Write question and answers */
|
||||
TstPrn_WriteQstAndAnsToFill (&Print->PrintedQuestions[NumQst],NumQst,&Question);
|
||||
/* Write question and answers */
|
||||
TstPrn_WriteQstAndAnsToFill (&Print->PrintedQuestions[QstInd],QstInd,&Question);
|
||||
|
||||
/* Destroy test question */
|
||||
Tst_QstDestructor (&Question);
|
||||
}
|
||||
/* Destroy test question */
|
||||
Tst_QstDestructor (&Question);
|
||||
}
|
||||
|
||||
/***** End table *****/
|
||||
HTM_TABLE_End ();
|
||||
/***** End table *****/
|
||||
HTM_TABLE_End ();
|
||||
|
||||
/***** Button *****/
|
||||
switch (RequestOrConfirm)
|
||||
{
|
||||
case TstPrn_REQUEST:
|
||||
/* Send button */
|
||||
Btn_PutConfirmButton (Txt_Continue);
|
||||
break;
|
||||
case TstPrn_CONFIRM:
|
||||
/* Will the test exam be visible by teachers? */
|
||||
TstPrn_PutCheckBoxAllowTeachers (true);
|
||||
|
||||
/* Send button */
|
||||
Btn_PutCreateButton (Txt_Send);
|
||||
break;
|
||||
}
|
||||
|
||||
/***** End form *****/
|
||||
switch (RequestOrConfirm)
|
||||
{
|
||||
case TstPrn_REQUEST:
|
||||
/* Send button */
|
||||
Btn_PutConfirmButton (Txt_Continue);
|
||||
break;
|
||||
case TstPrn_CONFIRM:
|
||||
/* Will the test exam be visible by teachers? */
|
||||
TstPrn_PutCheckBoxAllowTeachers (true);
|
||||
|
||||
/* Send button */
|
||||
Btn_PutCreateButton (Txt_Send);
|
||||
break;
|
||||
}
|
||||
Frm_EndForm ();
|
||||
}
|
||||
|
||||
|
@ -349,36 +351,36 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_WriteQstAndAnsToFill (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_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 (NumQst + 1,"BIG_INDEX");
|
||||
Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL");
|
||||
HTM_TD_End ();
|
||||
/***** Number of question and answer type *****/
|
||||
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
Tst_WriteNumQst (QstInd + 1,"BIG_INDEX");
|
||||
Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL");
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** Stem, media and answers *****/
|
||||
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
/***** Stem, media and answers *****/
|
||||
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
|
||||
/* Write parameter with question code */
|
||||
Tst_WriteParamQstCod (NumQst,Question->QstCod);
|
||||
/* Write parameter with question code */
|
||||
Tst_WriteParamQstCod (QstInd,Question->QstCod);
|
||||
|
||||
/* Stem */
|
||||
Tst_WriteQstStem (Question->Stem,"TEST_TXT",true);
|
||||
/* Stem */
|
||||
Tst_WriteQstStem (Question->Stem,"TEST_TXT",true);
|
||||
|
||||
/* Media */
|
||||
Med_ShowMedia (&Question->Media,
|
||||
"TEST_MED_SHOW_CONT",
|
||||
"TEST_MED_SHOW");
|
||||
/* Media */
|
||||
Med_ShowMedia (&Question->Media,
|
||||
"TEST_MED_SHOW_CONT",
|
||||
"TEST_MED_SHOW");
|
||||
|
||||
/* Answers */
|
||||
TstPrn_WriteAnswersToFill (PrintedQuestion,NumQst,Question);
|
||||
/* Answers */
|
||||
TstPrn_WriteAnswersToFill (PrintedQuestion,QstInd,Question);
|
||||
|
||||
HTM_TD_End ();
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** End row *****/
|
||||
HTM_TR_End ();
|
||||
|
@ -389,11 +391,11 @@ static void TstPrn_WriteQstAndAnsToFill (struct TstPrn_PrintedQuestion *PrintedQ
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_WriteAnswersToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question)
|
||||
{
|
||||
void (*TstPrn_WriteAnsBank[Tst_NUM_ANS_TYPES]) (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question) =
|
||||
{
|
||||
[Tst_ANS_INT ] = TstPrn_WriteIntAnsToFill,
|
||||
|
@ -405,7 +407,7 @@ static void TstPrn_WriteAnswersToFill (const struct TstPrn_PrintedQuestion *Prin
|
|||
};
|
||||
|
||||
/***** Write answers *****/
|
||||
TstPrn_WriteAnsBank[Question->Answer.Type] (PrintedQuestion,NumQst,Question);
|
||||
TstPrn_WriteAnsBank[Question->Answer.Type] (PrintedQuestion,QstInd,Question);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -413,13 +415,13 @@ static void TstPrn_WriteAnswersToFill (const struct TstPrn_PrintedQuestion *Prin
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_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",NumQst);
|
||||
snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd);
|
||||
HTM_INPUT_TEXT (StrAns,11,PrintedQuestion->StrAnswers,
|
||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"size=\"11\"");
|
||||
|
@ -430,13 +432,13 @@ static void TstPrn_WriteIntAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_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",NumQst);
|
||||
snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd);
|
||||
HTM_INPUT_TEXT (StrAns,Tst_MAX_BYTES_FLOAT_ANSWER,PrintedQuestion->StrAnswers,
|
||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"size=\"11\"");
|
||||
|
@ -447,7 +449,7 @@ static void TstPrn_WriteFltAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_WriteTF_AnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_Question *Question)
|
||||
{
|
||||
extern const char *Txt_TF_QST[2];
|
||||
|
@ -457,7 +459,7 @@ static void TstPrn_WriteTF_AnsToFill (const struct TstPrn_PrintedQuestion *Print
|
|||
If the user does not confirm the submission of their exam ==>
|
||||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"name=\"Ans%010u\"",NumQst);
|
||||
"name=\"Ans%010u\"",QstInd);
|
||||
HTM_OPTION (HTM_Type_STRING,"" ,PrintedQuestion->StrAnswers[0] == '\0',false," ");
|
||||
HTM_OPTION (HTM_Type_STRING,"T",PrintedQuestion->StrAnswers[0] == 'T' ,false,"%s",Txt_TF_QST[0]);
|
||||
HTM_OPTION (HTM_Type_STRING,"F",PrintedQuestion->StrAnswers[0] == 'F' ,false,"%s",Txt_TF_QST[1]);
|
||||
|
@ -469,7 +471,7 @@ static void TstPrn_WriteTF_AnsToFill (const struct TstPrn_PrintedQuestion *Print
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
struct Tst_Question *Question)
|
||||
{
|
||||
unsigned NumOpt;
|
||||
|
@ -503,20 +505,20 @@ static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
|||
==> the exam may be half filled ==> the answers displayed will be those selected by the user. */
|
||||
HTM_TD_Begin ("class=\"LT\"");
|
||||
|
||||
snprintf (StrAns,sizeof (StrAns),"Ans%010u",NumQst);
|
||||
snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd);
|
||||
if (Question->Answer.Type == Tst_ANS_UNIQUE_CHOICE)
|
||||
HTM_INPUT_RADIO (StrAns,false,
|
||||
"id=\"Ans%010u_%u\" value=\"%u\"%s"
|
||||
" onclick=\"selectUnselectRadio(this,this.form.Ans%010u,%u);\"",
|
||||
NumQst,NumOpt,
|
||||
QstInd,NumOpt,
|
||||
Indexes[NumOpt],
|
||||
UsrAnswers[Indexes[NumOpt]] ? " checked=\"checked\"" :
|
||||
"",
|
||||
NumQst,Question->Answer.NumOptions);
|
||||
QstInd,Question->Answer.NumOptions);
|
||||
else // Answer.Type == Tst_ANS_MULTIPLE_CHOICE
|
||||
HTM_INPUT_CHECKBOX (StrAns,HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"id=\"Ans%010u_%u\" value=\"%u\"%s",
|
||||
NumQst,NumOpt,
|
||||
QstInd,NumOpt,
|
||||
Indexes[NumOpt],
|
||||
UsrAnswers[Indexes[NumOpt]] ? " checked=\"checked\"" :
|
||||
"");
|
||||
|
@ -524,14 +526,14 @@ static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
|||
HTM_TD_End ();
|
||||
|
||||
HTM_TD_Begin ("class=\"LT\"");
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",NumQst,NumOpt);
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt);
|
||||
HTM_TxtF ("%c) ",'a' + (char) NumOpt);
|
||||
HTM_LABEL_End ();
|
||||
HTM_TD_End ();
|
||||
|
||||
/***** Write the option text *****/
|
||||
HTM_TD_Begin ("class=\"LT\"");
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",NumQst,NumOpt);
|
||||
HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt);
|
||||
HTM_Txt (Question->Answer.Options[Indexes[NumOpt]].Text);
|
||||
HTM_LABEL_End ();
|
||||
Med_ShowMedia (&Question->Answer.Options[Indexes[NumOpt]].Media,
|
||||
|
@ -551,13 +553,13 @@ static void TstPrn_WriteChoAnsToFill (const struct TstPrn_PrintedQuestion *Print
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_WriteTxtAnsToFill (const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
__attribute__((unused)) struct Tst_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",NumQst);
|
||||
snprintf (StrAns,sizeof (StrAns),"Ans%010u",QstInd);
|
||||
HTM_INPUT_TEXT (StrAns,Tst_MAX_CHARS_ANSWERS_ONE_QST,PrintedQuestion->StrAnswers,
|
||||
HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"size=\"40\"");
|
||||
|
@ -590,7 +592,7 @@ static void TstPrn_PutCheckBoxAllowTeachers (bool AllowTeachers)
|
|||
|
||||
void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print)
|
||||
{
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
bool QuestionExists;
|
||||
|
||||
|
@ -601,37 +603,37 @@ void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print)
|
|||
Print->NumQsts.NotBlank = 0;
|
||||
Print->Score = 0.0;
|
||||
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/***** Create test question *****/
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
|
||||
/***** Get question data *****/
|
||||
QuestionExists = Tst_GetQstDataFromDB (&Question);
|
||||
|
||||
/***** Write question and answers *****/
|
||||
TstPrn_WriteQstAndAnsExam (&Gbl.Usrs.Me.UsrDat,
|
||||
Print->PrintedQuestions,NumQst,
|
||||
Print->PrintedQuestions,QstInd,
|
||||
Print->TimeUTC,
|
||||
&Question,QuestionExists,
|
||||
TstCfg_GetConfigVisibility ());
|
||||
|
||||
/***** Store test exam question in database *****/
|
||||
TstPrn_StoreOneQstOfPrintInDB (Print,NumQst);
|
||||
TstPrn_StoreOneQstOfPrintInDB (Print,QstInd);
|
||||
|
||||
/***** Compute total score *****/
|
||||
Print->Score += Print->PrintedQuestions[NumQst].Score;
|
||||
if (Print->PrintedQuestions[NumQst].StrAnswers[0]) // User's answer is not blank
|
||||
Print->Score += Print->PrintedQuestions[QstInd].Score;
|
||||
if (Print->PrintedQuestions[QstInd].StrAnswers[0]) // User's answer is not blank
|
||||
Print->NumQsts.NotBlank++;
|
||||
|
||||
/***** Update the number of accesses and the score of this question *****/
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
|
||||
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[NumQst]);
|
||||
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[QstInd]);
|
||||
|
||||
/***** Destroy test question *****/
|
||||
Tst_QstDestructor (&Question);
|
||||
|
@ -647,7 +649,7 @@ void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print)
|
|||
|
||||
static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
||||
struct TstPrn_PrintedQuestion PrintedQuestions[TstCfg_MAX_QUESTIONS_PER_TEST],
|
||||
unsigned NumQst,
|
||||
unsigned QstInd,
|
||||
time_t TimeUTC[Dat_NUM_START_END_TIME],
|
||||
struct Tst_Question *Question,
|
||||
bool QuestionExists,
|
||||
|
@ -699,7 +701,7 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
|||
|
||||
/***** Number of question and answer type *****/
|
||||
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
Tst_WriteNumQst (NumQst + 1,"BIG_INDEX");
|
||||
Tst_WriteNumQst (QstInd + 1,"BIG_INDEX");
|
||||
if (QuestionUneditedAfterExam)
|
||||
Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL");
|
||||
HTM_TD_End ();
|
||||
|
@ -720,8 +722,8 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
|||
"TEST_MED_SHOW");
|
||||
|
||||
/* Answers */
|
||||
TstPrn_ComputeAnswerScore (&PrintedQuestions[NumQst],Question);
|
||||
TstPrn_WriteAnswersExam (UsrDat,&PrintedQuestions[NumQst],Question,
|
||||
TstPrn_ComputeAnswerScore (&PrintedQuestions[QstInd],Question);
|
||||
TstPrn_WriteAnswersExam (UsrDat,&PrintedQuestions[QstInd],Question,
|
||||
ICanView,"TEST_TXT","TEST_TXT_LIGHT");
|
||||
}
|
||||
else
|
||||
|
@ -736,11 +738,11 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
|||
HTM_DIV_Begin ("class=\"DAT_SMALL LM\"");
|
||||
HTM_TxtColonNBSP (Txt_Score);
|
||||
HTM_SPAN_Begin ("class=\"%s\"",
|
||||
PrintedQuestions[NumQst].StrAnswers[0] ?
|
||||
(PrintedQuestions[NumQst].Score > 0 ? "ANS_OK" : // Correct/semicorrect
|
||||
PrintedQuestions[QstInd].StrAnswers[0] ?
|
||||
(PrintedQuestions[QstInd].Score > 0 ? "ANS_OK" : // Correct/semicorrect
|
||||
"ANS_BAD") :// Wrong
|
||||
"ANS_0"); // Blank answer
|
||||
HTM_Double2Decimals (PrintedQuestions[NumQst].Score);
|
||||
HTM_Double2Decimals (PrintedQuestions[QstInd].Score);
|
||||
HTM_SPAN_End ();
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
@ -763,7 +765,7 @@ static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
|||
void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print,
|
||||
bool UpdateQstScore)
|
||||
{
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
|
||||
/***** Initialize total score *****/
|
||||
|
@ -771,29 +773,29 @@ void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print,
|
|||
Print->NumQsts.NotBlank = 0;
|
||||
|
||||
/***** Compute and store scores of all questions *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
QstInd++)
|
||||
{
|
||||
/* Compute question score */
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
Question.Answer.Type = Tst_GetQstAnswerTypeFromDB (Question.QstCod);
|
||||
TstPrn_ComputeAnswerScore (&Print->PrintedQuestions[NumQst],&Question);
|
||||
TstPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question);
|
||||
Tst_QstDestructor (&Question);
|
||||
|
||||
/* Store test exam question in database */
|
||||
TstPrn_StoreOneQstOfPrintInDB (Print,
|
||||
NumQst); // 0, 1, 2, 3...
|
||||
QstInd); // 0, 1, 2, 3...
|
||||
|
||||
/* Accumulate total score */
|
||||
Print->Score += Print->PrintedQuestions[NumQst].Score;
|
||||
if (Print->PrintedQuestions[NumQst].StrAnswers[0]) // User's answer is not blank
|
||||
Print->Score += Print->PrintedQuestions[QstInd].Score;
|
||||
if (Print->PrintedQuestions[QstInd].StrAnswers[0]) // User's answer is not blank
|
||||
Print->NumQsts.NotBlank++;
|
||||
|
||||
/* Update the number of hits and the score of this question in tests database */
|
||||
if (UpdateQstScore)
|
||||
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[NumQst]);
|
||||
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[QstInd]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1834,7 +1836,7 @@ static void TstPrn_WriteHeadUserCorrect (struct UsrData *UsrDat)
|
|||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_StoreOneQstOfPrintInDB (const struct TstPrn_Print *Print,
|
||||
unsigned NumQst)
|
||||
unsigned QstInd)
|
||||
{
|
||||
/***** Insert question and user's answers into database *****/
|
||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||
|
@ -1844,11 +1846,11 @@ static void TstPrn_StoreOneQstOfPrintInDB (const struct TstPrn_Print *Print,
|
|||
" VALUES"
|
||||
" (%ld,%ld,%u,'%.15lg','%s','%s')",
|
||||
Print->PrnCod,
|
||||
Print->PrintedQuestions[NumQst].QstCod,
|
||||
NumQst, // 0, 1, 2, 3...
|
||||
Print->PrintedQuestions[NumQst].Score,
|
||||
Print->PrintedQuestions[NumQst].StrIndexes,
|
||||
Print->PrintedQuestions[NumQst].StrAnswers);
|
||||
Print->PrintedQuestions[QstInd].QstCod,
|
||||
QstInd, // 0, 1, 2, 3...
|
||||
Print->PrintedQuestions[QstInd].Score,
|
||||
Print->PrintedQuestions[QstInd].StrIndexes,
|
||||
Print->PrintedQuestions[QstInd].StrAnswers);
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
||||
|
@ -2660,26 +2662,26 @@ void TstPrn_ShowPrintAnswers (struct UsrData *UsrDat,
|
|||
time_t TimeUTC[Dat_NUM_START_END_TIME],
|
||||
unsigned Visibility)
|
||||
{
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
struct Tst_Question Question;
|
||||
bool QuestionExists;
|
||||
|
||||
for (NumQst = 0;
|
||||
NumQst < NumQsts;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < NumQsts;
|
||||
QstInd++)
|
||||
{
|
||||
Gbl.RowEvenOdd = NumQst % 2;
|
||||
Gbl.RowEvenOdd = QstInd % 2;
|
||||
|
||||
/***** Create test question *****/
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = PrintedQuestions[NumQst].QstCod;
|
||||
Question.QstCod = PrintedQuestions[QstInd].QstCod;
|
||||
|
||||
/***** Get question data *****/
|
||||
QuestionExists = Tst_GetQstDataFromDB (&Question);
|
||||
|
||||
/***** Write questions and answers *****/
|
||||
TstPrn_WriteQstAndAnsExam (UsrDat,
|
||||
PrintedQuestions,NumQst,
|
||||
PrintedQuestions,QstInd,
|
||||
TimeUTC,
|
||||
&Question,QuestionExists,
|
||||
Visibility);
|
||||
|
@ -2759,7 +2761,7 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
|
|||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumQsts;
|
||||
unsigned NumQst;
|
||||
unsigned QstInd;
|
||||
|
||||
/***** Get questions of a test exam print from database *****/
|
||||
NumQsts = (unsigned)
|
||||
|
@ -2775,29 +2777,29 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
|
|||
|
||||
/***** Get questions *****/
|
||||
if (NumQsts == Print->NumQsts.All)
|
||||
for (NumQst = 0;
|
||||
NumQst < NumQsts;
|
||||
NumQst++)
|
||||
for (QstInd = 0;
|
||||
QstInd < NumQsts;
|
||||
QstInd++)
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
if ((Print->PrintedQuestions[QstInd].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get score (row[1]) */
|
||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||
if (sscanf (row[1],"%lf",&Print->PrintedQuestions[NumQst].Score) != 1)
|
||||
if (sscanf (row[1],"%lf",&Print->PrintedQuestions[QstInd].Score) != 1)
|
||||
Err_ShowErrorAndExit ("Wrong question score.");
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
|
||||
/* Get indexes for this question (row[2]) */
|
||||
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],
|
||||
sizeof (Print->PrintedQuestions[NumQst].StrIndexes) - 1);
|
||||
Str_Copy (Print->PrintedQuestions[QstInd].StrIndexes,row[2],
|
||||
sizeof (Print->PrintedQuestions[QstInd].StrIndexes) - 1);
|
||||
|
||||
/* Get answers selected by user for this question (row[3]) */
|
||||
Str_Copy (Print->PrintedQuestions[NumQst].StrAnswers,row[3],
|
||||
sizeof (Print->PrintedQuestions[NumQst].StrAnswers) - 1);
|
||||
Str_Copy (Print->PrintedQuestions[QstInd].StrAnswers,row[3],
|
||||
sizeof (Print->PrintedQuestions[QstInd].StrAnswers) - 1);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
|
Loading…
Reference in New Issue