mirror of https://github.com/acanas/swad-core.git
Version19.223
This commit is contained in:
parent
11aedf74b7
commit
c0b98af9a1
2043
js/swad19.193.1.js
2043
js/swad19.193.1.js
File diff suppressed because it is too large
Load Diff
|
@ -548,10 +548,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.222.2 (2020-05-10)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.223 (2020-05-11)"
|
||||
#define CSS_FILE "swad19.217.css"
|
||||
#define JS_FILE "swad19.193.1.js"
|
||||
#define JS_FILE "swad19.223.js"
|
||||
/*
|
||||
Version 19.223: May 11, 2020 Store exam answer and refresh exam print. (303024 lines)
|
||||
Version 19.222.2: May 10, 2020 Fixed bugs in exams. (302852 lines)
|
||||
Version 19.222.1: May 10, 2020 Code refactoring in exam prints. (302794 lines)
|
||||
Version 19.222: May 10, 2020 Changes in exam prints. (302787 lines)
|
||||
|
|
|
@ -3224,7 +3224,7 @@ static void ExaEvt_PutIfAnswered (const struct ExaEvt_Event *Event,bool Answered
|
|||
Event->Status.Showing == ExaEvt_ANSWERS && // Teacher's screen is showing question answers
|
||||
Answered) // I have answered this question
|
||||
{
|
||||
/* Start form */
|
||||
/* Begin form */
|
||||
Frm_StartForm (ActSeeExaEvtAnsQstStd);
|
||||
ExaEvt_PutParamEvtCod (Event->EvtCod); // Current exam event being played
|
||||
|
||||
|
@ -3265,7 +3265,7 @@ static void ExaEvt_PutIconToRemoveMyAnswer (const struct ExaEvt_Event *Event)
|
|||
/***** Start container *****/
|
||||
HTM_DIV_Begin ("class=\"EXA_REM_MY_ANS\"");
|
||||
|
||||
/***** Start form *****/
|
||||
/***** Begin form *****/
|
||||
Frm_StartForm (ActRemExaEvtAnsQstStd);
|
||||
ExaEvt_PutParamEvtCod (Event->EvtCod); // Current exam event being played
|
||||
Exa_PutParamQstInd (Event->Status.QstInd); // Current question index shown
|
||||
|
|
|
@ -94,10 +94,6 @@ static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print,
|
|||
struct ExaSet_Set *Set,
|
||||
unsigned *NumQstInPrint);
|
||||
static void ExaPrn_CreatePrintInDB (struct ExaPrn_Print *Print);
|
||||
static void ExaPrn_ComputeScoresAndStoreQuestionsOfPrint (struct ExaPrn_Print *Print,
|
||||
bool UpdateQstScore);
|
||||
static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst);
|
||||
|
||||
static void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print);
|
||||
|
||||
|
@ -122,7 +118,20 @@ static void ExaPrn_WriteChoiceAnsSeeing (const struct ExaPrn_Print *Print,
|
|||
static void ExaPrn_WriteTextAnsSeeing (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst);
|
||||
|
||||
static void ExaPrn_PutParamPrnCod (long ExaCod);
|
||||
static unsigned ExaPrn_GetAnswerFromForm (struct ExaPrn_Print *Print);
|
||||
|
||||
// static void ExaPrn_PutParamNumQst (unsigned NumQst);
|
||||
static unsigned ExaPrn_GetParamQstInd (void);
|
||||
|
||||
static void ExaPrn_ComputeScoresAndStoreQuestionsOfPrint (struct ExaPrn_Print *Print,
|
||||
bool UpdateQstScore);
|
||||
static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Print,
|
||||
unsigned NumQst);
|
||||
static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst);
|
||||
static void ExaPrn_UpdatePrintInDB (const struct ExaPrn_Print *Print);
|
||||
|
||||
// static void ExaPrn_PutParamPrnCod (long ExaCod);
|
||||
// static long ExaPrn_GetParamPrnCod (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -172,7 +181,6 @@ void ExaPrn_ShowExamPrint (void)
|
|||
Print.EvtCod = Event.EvtCod;
|
||||
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
ExaPrn_GetPrintDataByEvtCodAndUsrCod (&Print);
|
||||
Print.ExaCod = Event.ExaCod;
|
||||
|
||||
if (Print.PrnCod > 0) // Print exists
|
||||
{
|
||||
|
@ -186,6 +194,8 @@ void ExaPrn_ShowExamPrint (void)
|
|||
Ale_ShowAlert (Ale_INFO,"Examen nuevo.");
|
||||
|
||||
/***** Get questions from database *****/
|
||||
// Print doesn't exists ==> exam code is -1 ==> so initialize it
|
||||
Print.ExaCod = Exam.ExaCod;
|
||||
ExaPrn_GetQuestionsForNewPrintFromDB (&Print);
|
||||
|
||||
if (Print.NumQsts)
|
||||
|
@ -212,40 +222,51 @@ static void ExaPrn_GetPrintDataByEvtCodAndUsrCod (struct ExaPrn_Print *Print)
|
|||
|
||||
/***** Make database query *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get data of an exam print",
|
||||
"SELECT PrnCod," // row[0]
|
||||
"UNIX_TIMESTAMP(StartTime)," // row[1]
|
||||
"UNIX_TIMESTAMP(EndTime)," // row[2]
|
||||
"NumQsts," // row[3]
|
||||
"NumQstsNotBlank," // row[4]
|
||||
"Sent," // row[5]
|
||||
"Score" // row[6]
|
||||
" FROM exa_prints"
|
||||
" WHERE EvtCod=%ld AND UsrCod=%ld",
|
||||
Print->EvtCod,Print->UsrCod) == 1)
|
||||
"SELECT exa_prints.PrnCod," // row[0]
|
||||
"exa_exams.ExaCod," // row[1]
|
||||
"UNIX_TIMESTAMP(exa_prints.StartTime)," // row[2]
|
||||
"UNIX_TIMESTAMP(exa_prints.EndTime)," // row[3]
|
||||
"exa_prints.NumQsts," // row[4]
|
||||
"exa_prints.NumQstsNotBlank," // row[5]
|
||||
"exa_prints.Sent," // row[6]
|
||||
"exa_prints.Score" // row[7]
|
||||
" FROM exa_prints,exa_events,exa_exams"
|
||||
" WHERE exa_prints.EvtCod=%ld"
|
||||
" AND exa_prints.UsrCod=%ld" // Extra check: it belong to user
|
||||
" AND exa_prints.EvtCod=exa_events.EvtCod"
|
||||
" AND (NOW() BETWEEN exa_events.StartTime AND exa_events.EndTime)" // Extra check: event is open
|
||||
" AND exa_events.ExaCod=exa_exams.ExaCod"
|
||||
" AND exa_exams.CrsCod=%ld", // Extra check: it belong to current course
|
||||
Print->EvtCod,
|
||||
Print->UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod) == 1)
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get print code (row[0]) */
|
||||
Print->PrnCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/* Get date-time (row[1] and row[2] hold UTC date-time) */
|
||||
Print->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[1]);
|
||||
Print->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[2]);
|
||||
/* Get exam code (row[1]) */
|
||||
Print->ExaCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
||||
/* Get number of questions (row[3]) */
|
||||
if (sscanf (row[3],"%u",&Print->NumQsts) != 1)
|
||||
/* Get date-time (row[2] and row[3] hold UTC date-time) */
|
||||
Print->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[2]);
|
||||
Print->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[3]);
|
||||
|
||||
/* Get number of questions (row[4]) */
|
||||
if (sscanf (row[4],"%u",&Print->NumQsts) != 1)
|
||||
Print->NumQsts = 0;
|
||||
|
||||
/* Get number of questions not blank (row[4]) */
|
||||
if (sscanf (row[4],"%u",&Print->NumQstsNotBlank) != 1)
|
||||
/* Get number of questions not blank (row[5]) */
|
||||
if (sscanf (row[5],"%u",&Print->NumQstsNotBlank) != 1)
|
||||
Print->NumQstsNotBlank = 0;
|
||||
|
||||
/* Get if exam has been sent (row[5]) */
|
||||
Print->Sent = (row[5][0] == 'Y');
|
||||
/* Get if exam has been sent (row[6]) */
|
||||
Print->Sent = (row[6][0] == 'Y');
|
||||
|
||||
/* Get score (row[6]) */
|
||||
/* Get score (row[7]) */
|
||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||
if (sscanf (row[6],"%lf",&Print->Score) != 1)
|
||||
if (sscanf (row[7],"%lf",&Print->Score) != 1)
|
||||
Print->Score = 0.0;
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
@ -427,79 +448,6 @@ static void ExaPrn_CreatePrintInDB (struct ExaPrn_Print *Print)
|
|||
Print->NumQsts);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Compute score of each question and store in database ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_ComputeScoresAndStoreQuestionsOfPrint (struct ExaPrn_Print *Print,
|
||||
bool UpdateQstScore)
|
||||
{
|
||||
unsigned NumQst;
|
||||
struct Tst_Question Question;
|
||||
|
||||
/***** Initialize total score *****/
|
||||
Print->Score = 0.0;
|
||||
Print->NumQstsNotBlank = 0;
|
||||
|
||||
/***** Compute and store scores of all questions *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts;
|
||||
NumQst++)
|
||||
{
|
||||
/* Compute question score */
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.Answer.Type = Tst_GetQstAnswerType (Question.QstCod);
|
||||
TstPrn_ComputeAnswerScore (&Print->PrintedQuestions[NumQst],&Question);
|
||||
Tst_QstDestructor (&Question);
|
||||
|
||||
/* Store test exam question in database */
|
||||
ExaPrn_StoreOneQstOfPrintInDB (Print,
|
||||
NumQst); // 0, 1, 2, 3...
|
||||
|
||||
/* Accumulate total score */
|
||||
Print->Score += Print->PrintedQuestions[NumQst].Score;
|
||||
if (Print->PrintedQuestions[NumQst].AnswerIsNotBlank)
|
||||
Print->NumQstsNotBlank++;
|
||||
|
||||
/* Update the number of hits and the score of this question in tests database */
|
||||
if (UpdateQstScore)
|
||||
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[NumQst]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Store user's answers of an test exam into database ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst)
|
||||
{
|
||||
char StrIndexes[Tst_MAX_BYTES_INDEXES_ONE_QST + 1];
|
||||
char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1];
|
||||
|
||||
/***** Replace each separator of multiple parameters by a comma *****/
|
||||
/* In database commas are used as separators instead of special chars */
|
||||
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrIndexes,StrIndexes);
|
||||
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrAnswers,StrAnswers);
|
||||
|
||||
/***** Insert question and user's answers into database *****/
|
||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||
DB_QueryREPLACE ("can not update a question in an exam print",
|
||||
"REPLACE INTO exa_print_questions"
|
||||
" (PrnCod,QstCod,QstInd,SetCod,Score,Indexes,Answers)"
|
||||
" 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,
|
||||
StrIndexes,
|
||||
StrAnswers);
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Get the questions of an exam print from database **************/
|
||||
/*****************************************************************************/
|
||||
|
@ -592,14 +540,16 @@ static void ExaPrn_ShowExamPrintToFillIt (const char *Title,
|
|||
|
||||
if (Print->NumQsts)
|
||||
{
|
||||
/***** Begin form *****/
|
||||
Frm_StartForm (ActEndExaPrn);
|
||||
ExaPrn_PutParamPrnCod (Print->PrnCod);
|
||||
|
||||
/***** Show table with questions to answer *****/
|
||||
Frm_StartFormNoAction (); // Form that can not be submitted, to avoid enter key to send it
|
||||
HTM_DIV_Begin ("id=\"examprint\""); // Used for AJAX based refresh
|
||||
ExaPrn_ShowTableWithQstsToFill (Print);
|
||||
HTM_DIV_End (); // Used for AJAX based refresh
|
||||
Frm_EndForm ();
|
||||
|
||||
/***** Send button and end form *****/
|
||||
/***** Form to end/close this exam print *****/
|
||||
Frm_StartForm (ActEndExaPrn);
|
||||
// ExaEvt_PutParamEvtCod (Print->EvtCod);
|
||||
Btn_PutCreateButton ("He terminado"); // TODO: Translate!!!
|
||||
Frm_EndForm ();
|
||||
}
|
||||
|
@ -668,6 +618,7 @@ static void ExaPrn_WriteQstAndAnsToFill (struct ExaPrn_Print *Print,
|
|||
/***** Get data of this set *****/
|
||||
CurrentSet.ExaCod = Print->ExaCod;
|
||||
CurrentSet.SetCod = Print->PrintedQuestions[NumQst].SetCod;
|
||||
|
||||
ExaSet_GetDataOfSetByCod (&CurrentSet);
|
||||
|
||||
/***** Title for this set *****/
|
||||
|
@ -749,15 +700,24 @@ static void ExaPrn_WriteAnswersToFill (const struct ExaPrn_Print *Print,
|
|||
static void ExaPrn_WriteIntAnsSeeing (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst)
|
||||
{
|
||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
char Id[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
||||
/***** Write input field for the answer *****/
|
||||
snprintf (StrAns,sizeof (StrAns),
|
||||
snprintf (Id,sizeof (Id),
|
||||
"Ans%010u",
|
||||
NumQst);
|
||||
HTM_INPUT_TEXT (StrAns,11,Print->PrintedQuestions[NumQst].StrAnswers,
|
||||
HTM_SUBMIT_ON_CHANGE,
|
||||
"size=\"11\"");
|
||||
HTM_TxtF ("<input type=\"text\" id=\"%s\" name=\"%s\""
|
||||
" size=\"11\" maxlength=\"11\" value=\"%s\"",
|
||||
Id,Id,
|
||||
Print->PrintedQuestions[NumQst].StrAnswers);
|
||||
HTM_TxtF (" onchange=\"updateExamPrint('examprint','%s','%s',"
|
||||
"'act=%ld&ses=%s&EvtCod=%ld&NumQst=%u');"
|
||||
" return false;\"", // return false is necessary to not submit form
|
||||
Id,Id,
|
||||
Act_GetActCod (ActAnsExaPrn),
|
||||
Gbl.Session.Id,Print->EvtCod,NumQst);
|
||||
|
||||
HTM_Txt (" />");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -904,7 +864,207 @@ static void ExaPrn_WriteTextAnsSeeing (const struct ExaPrn_Print *Print,
|
|||
|
||||
void ExaPrn_ReceivePrintAnswer (void)
|
||||
{
|
||||
Ale_ShowAlert (Ale_INFO,"Recepción del examen contestado.");
|
||||
// struct Exa_Exams Exams;
|
||||
// struct Exa_Exam Exam;
|
||||
// struct ExaEvt_Event Event;
|
||||
struct ExaPrn_Print Print;
|
||||
unsigned NumQst;
|
||||
|
||||
/***** Reset exams context *****/
|
||||
// Exa_ResetExams (&Exams);
|
||||
// Exa_ResetExam (&Exam);
|
||||
// ExaEvt_ResetEvent (&Event);
|
||||
ExaPrn_ResetPrint (&Print);
|
||||
|
||||
/***** Get and check parameters *****/
|
||||
Print.EvtCod = ExaEvt_GetParamEvtCod ();
|
||||
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
ExaPrn_GetPrintDataByEvtCodAndUsrCod (&Print);
|
||||
if (Print.PrnCod <= 0)
|
||||
Lay_ShowErrorAndExit ("Wrong exam print.");
|
||||
|
||||
/***** Get exam data and event from database *****/
|
||||
/*
|
||||
Exam.ExaCod = Print.ExaCod;
|
||||
Exa_GetDataOfExamByCod (Exam);
|
||||
Exams->ExaCod = Exam.ExaCod;
|
||||
|
||||
Event.EvtCod = Print.EvtCod;
|
||||
ExaEvt_GetDataOfEventByCod (Event);
|
||||
Exams->EvtCod = Event.ExaCod;
|
||||
*/
|
||||
|
||||
/***** Get questions and answers from database *****/
|
||||
ExaPrn_GetPrintQuestionsFromDB (&Print);
|
||||
|
||||
/***** Get answers from form to assess a test *****/
|
||||
NumQst = ExaPrn_GetAnswerFromForm (&Print);
|
||||
|
||||
/***** Update answer in database *****/
|
||||
/* Compute question score and store in database */
|
||||
ExaPrn_ComputeScoreAndStoreQuestionOfPrint (&Print,NumQst);
|
||||
|
||||
/* Update exam print in database */
|
||||
ExaPrn_UpdatePrintInDB (&Print);
|
||||
|
||||
/***** Show table with questions to answer *****/
|
||||
ExaPrn_ShowTableWithQstsToFill (&Print);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Get questions and answers from form to assess an exam print ********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned ExaPrn_GetAnswerFromForm (struct ExaPrn_Print *Print)
|
||||
{
|
||||
unsigned NumQst;
|
||||
char AnsName[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
||||
/***** Get question index from form *****/
|
||||
NumQst = ExaPrn_GetParamQstInd ();
|
||||
|
||||
/***** Get answers selected by user for this question *****/
|
||||
snprintf (AnsName,sizeof (AnsName),
|
||||
"Ans%010u",
|
||||
NumQst);
|
||||
Par_GetParMultiToText (AnsName,Print->PrintedQuestions[NumQst].StrAnswers,
|
||||
Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */
|
||||
|
||||
return NumQst;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Write parameter with index of question *******************/
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
static void ExaPrn_PutParamNumQst (unsigned NumQst)
|
||||
{
|
||||
Par_PutHiddenParamUnsigned (NULL,"NumQst",NumQst);
|
||||
}
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/******************* Get parameter with index of question ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned ExaPrn_GetParamQstInd (void)
|
||||
{
|
||||
long NumQst;
|
||||
|
||||
NumQst = Par_GetParToLong ("NumQst");
|
||||
if (NumQst < 0)
|
||||
Lay_ShowErrorAndExit ("Wrong number of question.");
|
||||
|
||||
return (unsigned) NumQst;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Compute score of each question and store in database ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_ComputeScoresAndStoreQuestionsOfPrint (struct ExaPrn_Print *Print,
|
||||
bool UpdateQstScore)
|
||||
{
|
||||
unsigned NumQst;
|
||||
|
||||
/***** Initialize total score *****/
|
||||
Print->Score = 0.0;
|
||||
Print->NumQstsNotBlank = 0;
|
||||
|
||||
/***** Compute and store scores of all questions *****/
|
||||
for (NumQst = 0;
|
||||
NumQst < Print->NumQsts;
|
||||
NumQst++)
|
||||
{
|
||||
/* Compute question score and store in database */
|
||||
ExaPrn_ComputeScoreAndStoreQuestionOfPrint (Print,NumQst);
|
||||
|
||||
/* Accumulate total score */
|
||||
Print->Score += Print->PrintedQuestions[NumQst].Score;
|
||||
if (Print->PrintedQuestions[NumQst].AnswerIsNotBlank)
|
||||
Print->NumQstsNotBlank++;
|
||||
|
||||
/* Update the number of hits and the score of this question in tests database */
|
||||
if (UpdateQstScore)
|
||||
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[NumQst]);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Compute score of one question and store in database *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_ComputeScoreAndStoreQuestionOfPrint (struct ExaPrn_Print *Print,
|
||||
unsigned NumQst)
|
||||
{
|
||||
struct Tst_Question Question;
|
||||
|
||||
/***** Compute question score *****/
|
||||
Tst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||
Question.Answer.Type = Tst_GetQstAnswerType (Question.QstCod);
|
||||
TstPrn_ComputeAnswerScore (&Print->PrintedQuestions[NumQst],&Question);
|
||||
Tst_QstDestructor (&Question);
|
||||
|
||||
/***** Store test exam question in database *****/
|
||||
ExaPrn_StoreOneQstOfPrintInDB (Print,
|
||||
NumQst); // 0, 1, 2, 3...
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Store user's answers of an test exam into database ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print,
|
||||
unsigned NumQst)
|
||||
{
|
||||
char StrIndexes[Tst_MAX_BYTES_INDEXES_ONE_QST + 1];
|
||||
char StrAnswers[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1];
|
||||
|
||||
/***** Replace each separator of multiple parameters by a comma *****/
|
||||
/* In database commas are used as separators instead of special chars */
|
||||
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrIndexes,StrIndexes);
|
||||
Par_ReplaceSeparatorMultipleByComma (Print->PrintedQuestions[NumQst].StrAnswers,StrAnswers);
|
||||
|
||||
/***** Insert question and user's answers into database *****/
|
||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||
DB_QueryREPLACE ("can not update a question in an exam print",
|
||||
"REPLACE INTO exa_print_questions"
|
||||
" (PrnCod,QstCod,QstInd,SetCod,Score,Indexes,Answers)"
|
||||
" 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,
|
||||
StrIndexes,
|
||||
StrAnswers);
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Update exam print in database ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_UpdatePrintInDB (const struct ExaPrn_Print *Print)
|
||||
{
|
||||
/***** Update exam print in database *****/
|
||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||
DB_QueryUPDATE ("can not update exam print",
|
||||
"UPDATE exa_prints"
|
||||
" SET EndTime=NOW(),"
|
||||
"NumQstsNotBlank=%u,"
|
||||
"Sent='%c',"
|
||||
"Score='%.15lg'"
|
||||
" WHERE PrnCod=%ld"
|
||||
" AND EvtCod=%ld AND UsrCod=%ld", // Extra checks
|
||||
Print->NumQstsNotBlank,
|
||||
Print->Sent ? 'Y' :
|
||||
'N',
|
||||
Print->Score,
|
||||
Print->PrnCod,
|
||||
Print->EvtCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -920,10 +1080,10 @@ void ExaPrn_EndPrintAnswer (void)
|
|||
/***************** Write parameter with code of exam print *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void ExaPrn_PutParamPrnCod (long ExaCod)
|
||||
{
|
||||
Par_PutHiddenParamLong (NULL,"PrnCod",ExaCod);
|
||||
}
|
||||
// static void ExaPrn_PutParamPrnCod (long ExaCod)
|
||||
// {
|
||||
// Par_PutHiddenParamLong (NULL,"PrnCod",ExaCod);
|
||||
// }
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Get parameter with code of exam print *********************/
|
||||
|
|
|
@ -1122,7 +1122,7 @@ void ExaRes_ShowOneExaResult (void)
|
|||
}
|
||||
|
||||
/***** Get event result data *****/
|
||||
TstPrn_ResetResult (&Print);
|
||||
TstPrn_ResetPrint (&Print);
|
||||
ExaRes_GetEventResultDataByEvtCod (Event.EvtCod,UsrDat->UsrCod,&Print);
|
||||
|
||||
/***** Check if I can view this event result *****/
|
||||
|
|
12
swad_form.c
12
swad_form.c
|
@ -157,6 +157,18 @@ static void Frm_StartFormInternal (Act_Action_t NextAction,bool PutParameterLoca
|
|||
}
|
||||
}
|
||||
|
||||
void Frm_StartFormNoAction (void)
|
||||
{
|
||||
if (!Gbl.Form.Inside)
|
||||
{
|
||||
/* Begin form */
|
||||
HTM_Txt ("<form accept-charset=\"windows-1252\""
|
||||
" onsubmit=\"return false;\">"); // Form that can not be submitted, to avoid enter key to send it
|
||||
|
||||
Gbl.Form.Inside = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Frm_SetParamsForm (char ParamsStr[Frm_MAX_BYTES_PARAMS_STR + 1],Act_Action_t NextAction,
|
||||
bool PutParameterLocationIfNoSesion)
|
||||
{
|
||||
|
|
|
@ -59,6 +59,7 @@ void Frm_StartFormAnchor (Act_Action_t NextAction,const char *Anchor);
|
|||
void Frm_StartFormUniqueAnchor (Act_Action_t NextAction,const char *Anchor);
|
||||
void Frm_StartFormUniqueAnchorOnSubmit (Act_Action_t NextAction,const char *Anchor,const char *OnSubmit);
|
||||
void Frm_StartFormId (Act_Action_t NextAction,const char *Id);
|
||||
void Frm_StartFormNoAction (void);
|
||||
void Frm_SetParamsForm (char ParamsStr[Frm_MAX_BYTES_PARAMS_STR],Act_Action_t NextAction,
|
||||
bool PutParameterLocationIfNoSesion);
|
||||
void Frm_EndForm (void);
|
||||
|
|
|
@ -2524,7 +2524,7 @@ static void Mch_PutFormCountdown (struct Mch_Match *Match,long Seconds,const cha
|
|||
|
||||
if (PutForm)
|
||||
{
|
||||
/***** Start form *****/
|
||||
/***** Begin form *****/
|
||||
if (asprintf (&OnSubmit,"updateMatchTch('match_left',"
|
||||
"'act=%ld&ses=%s&MchCod=%ld&Countdown=%ld');"
|
||||
" return false;", // return false is necessary to not submit form
|
||||
|
@ -2532,7 +2532,6 @@ static void Mch_PutFormCountdown (struct Mch_Match *Match,long Seconds,const cha
|
|||
Match->MchCod,Seconds) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Frm_StartFormOnSubmit (ActUnk,OnSubmit);
|
||||
|
||||
}
|
||||
|
||||
/***** Put icon *****/
|
||||
|
@ -2884,7 +2883,7 @@ static void Mch_PutIfAnswered (const struct Mch_Match *Match,bool Answered)
|
|||
Match->Status.Showing == Mch_ANSWERS && // Teacher's screen is showing question answers
|
||||
Answered) // I have answered this question
|
||||
{
|
||||
/* Start form */
|
||||
/* Begin form */
|
||||
Frm_StartForm (ActSeeMchAnsQstStd);
|
||||
Mch_PutParamMchCod (Match->MchCod); // Current match being played
|
||||
|
||||
|
@ -2922,10 +2921,10 @@ static void Mch_PutIconToRemoveMyAnswer (const struct Mch_Match *Match)
|
|||
{
|
||||
extern const char *Txt_Delete_my_answer;
|
||||
|
||||
/***** Start container *****/
|
||||
/***** Begin container *****/
|
||||
HTM_DIV_Begin ("class=\"MCH_REM_MY_ANS\"");
|
||||
|
||||
/***** Start form *****/
|
||||
/***** Begin form *****/
|
||||
Frm_StartForm (ActRemMchAnsQstStd);
|
||||
Mch_PutParamMchCod (Match->MchCod); // Current match being played
|
||||
Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown
|
||||
|
|
|
@ -1113,7 +1113,7 @@ void MchRes_ShowOneMchResult (void)
|
|||
}
|
||||
|
||||
/***** Get match result data *****/
|
||||
TstPrn_ResetResult (&Print);
|
||||
TstPrn_ResetPrint (&Print);
|
||||
MchRes_GetMatchResultDataByMchCod (Match.MchCod,UsrDat->UsrCod,&Print);
|
||||
|
||||
/***** Check if I can view this match result *****/
|
||||
|
|
20
swad_test.c
20
swad_test.c
|
@ -132,7 +132,7 @@ static void Tst_ShowFormRequestTest (struct Tst_Test *Test);
|
|||
|
||||
static void Tst_PutCheckBoxAllowTeachers (bool AllowTeachers);
|
||||
|
||||
static void Tst_GetAnswersFromForm (struct TstPrn_Print *Print);
|
||||
static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print);
|
||||
|
||||
static bool Tst_CheckIfNextTstAllowed (void);
|
||||
static unsigned Tst_GetNumExamsGeneratedByMe (void);
|
||||
|
@ -455,7 +455,7 @@ void Tst_ShowNewTest (void)
|
|||
if (Tst_GetParamsTst (&Test,Tst_SHOW_TEST_TO_ANSWER)) // Get parameters from form
|
||||
{
|
||||
/***** Get questions *****/
|
||||
TstPrn_ResetResult (&Print);
|
||||
TstPrn_ResetPrint (&Print);
|
||||
Tst_GetQuestionsForNewTestFromDB (&Test,&Print);
|
||||
if (Print.NumQsts)
|
||||
{
|
||||
|
@ -526,7 +526,7 @@ void Tst_ReceiveTestDraft (void)
|
|||
|
||||
/***** Get basic parameters of the exam *****/
|
||||
/* Get test exam code from form */
|
||||
TstPrn_ResetResult (&Print);
|
||||
TstPrn_ResetPrint (&Print);
|
||||
if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0)
|
||||
Lay_ShowErrorAndExit ("Wrong test exam.");
|
||||
|
||||
|
@ -546,12 +546,12 @@ void Tst_ReceiveTestDraft (void)
|
|||
TstPrn_GetPrintQuestionsFromDB (&Print);
|
||||
|
||||
/***** Get answers from form to assess a test *****/
|
||||
Tst_GetAnswersFromForm (&Print);
|
||||
TstPrn_GetAnswersFromForm (&Print);
|
||||
|
||||
/***** Update test exam in database *****/
|
||||
TstPrn_ComputeScoresAndStoreQuestionsOfPrint (&Print,
|
||||
false); // Don't update question score
|
||||
TstPrn_UpdateExamInDB (&Print);
|
||||
TstPrn_UpdatePrintInDB (&Print);
|
||||
|
||||
/***** Show question and button to send the test *****/
|
||||
/* Start alert */
|
||||
|
@ -582,7 +582,7 @@ void Tst_AssessTest (void)
|
|||
|
||||
/***** Get basic parameters of the exam *****/
|
||||
/* Get test exam code from form */
|
||||
TstPrn_ResetResult (&Print);
|
||||
TstPrn_ResetPrint (&Print);
|
||||
if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0)
|
||||
Lay_ShowErrorAndExit ("Wrong test exam.");
|
||||
|
||||
|
@ -602,7 +602,7 @@ void Tst_AssessTest (void)
|
|||
TstPrn_GetPrintQuestionsFromDB (&Print);
|
||||
|
||||
/***** Get answers from form to assess a test *****/
|
||||
Tst_GetAnswersFromForm (&Print);
|
||||
TstPrn_GetAnswersFromForm (&Print);
|
||||
|
||||
/***** Get if test exam will be visible by teachers *****/
|
||||
Print.Sent = true; // The exam has been finished and sent by student
|
||||
|
@ -611,7 +611,7 @@ void Tst_AssessTest (void)
|
|||
/***** Update test exam in database *****/
|
||||
TstPrn_ComputeScoresAndStoreQuestionsOfPrint (&Print,
|
||||
Gbl.Usrs.Me.Role.Logged == Rol_STD); // Update question score?
|
||||
TstPrn_UpdateExamInDB (&Print);
|
||||
TstPrn_UpdatePrintInDB (&Print);
|
||||
|
||||
/***** Begin box *****/
|
||||
Box_BoxBegin (NULL,Txt_Test_result,
|
||||
|
@ -653,10 +653,10 @@ void Tst_AssessTest (void)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Get questions and answers from form to assess a test ************/
|
||||
/****** Get questions and answers from form to assess a test exam print ******/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Tst_GetAnswersFromForm (struct TstPrn_Print *Print)
|
||||
static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print)
|
||||
{
|
||||
unsigned NumQst;
|
||||
char StrAns[3 + Cns_MAX_DECIMAL_DIGITS_UINT + 1]; // "Ansxx...x"
|
||||
|
|
|
@ -70,7 +70,7 @@ extern struct Globals Gbl;
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void TstPrn_ResetExamExceptExaCod (struct TstPrn_Print *Print);
|
||||
static void TstPrn_ResetPrintExceptPrnCod (struct TstPrn_Print *Print);
|
||||
|
||||
static void TstPrn_WriteQstAndAnsExam (struct UsrData *UsrDat,
|
||||
struct TstPrn_Print *Print,
|
||||
|
@ -148,13 +148,13 @@ static void TstPrn_ShowTagsPresentInAnExam (long ResCod);
|
|||
/******************************** Reset exam *********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TstPrn_ResetResult (struct TstPrn_Print *Print)
|
||||
void TstPrn_ResetPrint (struct TstPrn_Print *Print)
|
||||
{
|
||||
Print->PrnCod = -1L;
|
||||
TstPrn_ResetExamExceptExaCod (Print);
|
||||
TstPrn_ResetPrintExceptPrnCod (Print);
|
||||
}
|
||||
|
||||
static void TstPrn_ResetExamExceptExaCod (struct TstPrn_Print *Print)
|
||||
static void TstPrn_ResetPrintExceptPrnCod (struct TstPrn_Print *Print)
|
||||
{
|
||||
Print->TimeUTC[Dat_START_TIME] =
|
||||
Print->TimeUTC[Dat_END_TIME ] = (time_t) 0;
|
||||
|
@ -184,12 +184,12 @@ void TstPrn_CreatePrintInDB (struct TstPrn_Print *Print)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Update test exam in database *************************/
|
||||
/******************** Update test exam print in database *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TstPrn_UpdateExamInDB (const struct TstPrn_Print *Print)
|
||||
void TstPrn_UpdatePrintInDB (const struct TstPrn_Print *Print)
|
||||
{
|
||||
/***** Update score in test exam *****/
|
||||
/***** Update test exam print in database *****/
|
||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||
DB_QueryUPDATE ("can not update test exam",
|
||||
"UPDATE tst_exams"
|
||||
|
@ -1641,7 +1641,7 @@ static void TstPrn_ShowExams (struct UsrData *UsrDat)
|
|||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get test code (row[0]) */
|
||||
TstPrn_ResetResult (&Print);
|
||||
TstPrn_ResetPrint (&Print);
|
||||
if ((Print.PrnCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_ShowErrorAndExit ("Wrong code of test exam.");
|
||||
|
||||
|
@ -1921,7 +1921,7 @@ void TstPrn_ShowOneExam (void)
|
|||
bool ICanViewScore;
|
||||
|
||||
/***** Get the code of the test *****/
|
||||
TstPrn_ResetResult (&Print);
|
||||
TstPrn_ResetPrint (&Print);
|
||||
if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) == -1L)
|
||||
Lay_ShowErrorAndExit ("Code of test is missing.");
|
||||
|
||||
|
@ -2250,7 +2250,7 @@ void TstPrn_GetPrintDataByPrnCod (struct TstPrn_Print *Print)
|
|||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
else
|
||||
TstPrn_ResetExamExceptExaCod (Print);
|
||||
TstPrn_ResetPrintExceptPrnCod (Print);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
|
|
@ -66,9 +66,9 @@ struct TstPrn_Print
|
|||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TstPrn_ResetResult (struct TstPrn_Print *Print);
|
||||
void TstPrn_ResetPrint (struct TstPrn_Print *Print);
|
||||
void TstPrn_CreatePrintInDB (struct TstPrn_Print *Print);
|
||||
void TstPrn_UpdateExamInDB (const struct TstPrn_Print *Print);
|
||||
void TstPrn_UpdatePrintInDB (const struct TstPrn_Print *Print);
|
||||
|
||||
void TstPrn_ShowExamAfterAssess (struct TstPrn_Print *Print);
|
||||
|
||||
|
|
|
@ -2101,7 +2101,7 @@ static void TL_PutFormGoToAction (const struct TL_Note *SocNot,
|
|||
{
|
||||
HTM_DIV_Begin ("class=\"TL_FORM\"");
|
||||
|
||||
/***** Start form with parameters depending on the type of note *****/
|
||||
/***** Begin form with parameters depending on the type of note *****/
|
||||
switch (SocNot->NoteType)
|
||||
{
|
||||
case TL_NOTE_INS_DOC_PUB_FILE:
|
||||
|
@ -2859,7 +2859,7 @@ static void TL_FormToShowHiddenComments (Act_Action_t ActionGbl,Act_Action_t Act
|
|||
IdComments);
|
||||
|
||||
/***** Form and icon-text to show hidden comments *****/
|
||||
/* Start form */
|
||||
/* Begin form */
|
||||
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
|
||||
{
|
||||
if (asprintf (&OnSubmit,"toggleComments('%s');"
|
||||
|
|
Loading…
Reference in New Issue