");
/***** Start form *****/
Frm_StartForm (ActChgVisResMchQst);
Mch_PutParamMchCod (Match->MchCod); // Current match being played
/***** Put icon with link *****/
fprintf (Gbl.F.Out,"
",
Txt_View_results,
Gbl.Form.Id,
Match->Status.ShowQstResults ? "fas fa-toggle-on" :
"fas fa-toggle-off",
Txt_View_results);
/***** End form *****/
Frm_EndForm ();
/***** End container *****/
fprintf (Gbl.F.Out,"
");
}
/*****************************************************************************/
/***************************** Show match title ******************************/
/*****************************************************************************/
static void Mch_ShowMatchTitle (struct Match *Match)
{
/***** Match title *****/
HTM_DIV_Begin ("class=\"MCH_TOP\"");
fprintf (Gbl.F.Out,"%s",Match->Title);
HTM_DIV_End ();
}
/*****************************************************************************/
/***** Show question and its answers when playing a match (as a teacher) *****/
/*****************************************************************************/
static void Mch_ShowQuestionAndAnswersTch (struct Match *Match)
{
extern const char *Txt_MATCH_Paused;
MYSQL_RES *mysql_res;
MYSQL_ROW row;
/***** Trivial check: question index should be correct *****/
if (Match->Status.QstInd == 0 ||
Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION)
return;
/***** Get data of question from database *****/
if (!DB_QuerySELECT (&mysql_res,"can not get data of a question",
"SELECT AnsType," // row[0]
"Stem," // row[1]
"MedCod" // row[2]
" FROM tst_questions"
" WHERE QstCod=%ld",
Match->Status.QstCod))
Ale_ShowAlert (Ale_ERROR,"Question doesn't exist.");
row = mysql_fetch_row (mysql_res);
/***** Show question *****/
/* Get answer type (row[0]) */
Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]);
if (Gbl.Test.AnswerType != Tst_ANS_UNIQUE_CHOICE)
Lay_ShowErrorAndExit ("Wrong answer type.");
HTM_DIV_Begin ("class=\"MCH_BOTTOM\""); // Bottom
/* Write stem (row[1]) */
Tst_WriteQstStem (row[1],"MCH_TCH_STEM");
/* Get media (row[2]) */
Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[2]);
Med_GetMediaDataByCod (&Gbl.Test.Media);
/* Show media */
Med_ShowMedia (&Gbl.Test.Media,
"TEST_MED_EDIT_LIST_STEM_CONTAINER",
"TEST_MED_EDIT_LIST_STEM");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** Write answers? *****/
switch (Match->Status.Showing)
{
case Mch_NOTHING:
case Mch_STEM:
/* Don't write anything */
break;
case Mch_ANSWERS:
if (Match->Status.Playing) // Being played
/* Write answers */
Mch_WriteAnswersMatchResult (Match,
"MCH_TCH_ANS",
false); // Don't show result
else // Not being played
Mch_ShowWaitImage (Txt_MATCH_Paused);
break;
case Mch_RESULTS:
/* Write answers with results */
Mch_WriteAnswersMatchResult (Match,
"MCH_TCH_ANS",
true); // Show result
break;
}
HTM_DIV_End (); // Bottom
}
/*****************************************************************************/
/************* Write answers of a question when viewing a match **************/
/*****************************************************************************/
static void Mch_WriteAnswersMatchResult (struct Match *Match,
const char *Class,bool ShowResult)
{
/***** Write answer depending on type *****/
if (Gbl.Test.AnswerType == Tst_ANS_UNIQUE_CHOICE)
Tst_WriteChoiceAnsViewMatch (Match->MchCod,Match->Status.QstInd,Match->Status.QstCod,
Match->Status.NumCols,Class,ShowResult);
else
Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game.");
}
/*****************************************************************************/
/***** Show question and its answers when playing a match (as a student) *****/
/*****************************************************************************/
static void Mch_ShowQuestionAndAnswersStd (struct Match *Match)
{
struct Mch_UsrAnswer UsrAnswer;
unsigned NumOptions;
unsigned NumOpt;
/***** Show question *****/
/* Write buttons for answers? */
if (Match->Status.Showing == Mch_ANSWERS)
{
if (Tst_CheckIfQuestionIsValidForGame (Match->Status.QstCod))
{
/***** Get student's answer to this question
(<0 ==> no answer) *****/
Mch_GetQstAnsFromDB (Match->MchCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
Match->Status.QstInd,
&UsrAnswer);
/***** Get number of options in this question *****/
NumOptions = Tst_GetNumAnswersQst (Match->Status.QstCod);
/***** Begin table *****/
HTM_TABLE_BeginWidePadding (8);
for (NumOpt = 0;
NumOpt < NumOptions;
NumOpt++)
{
/***** Start row *****/
HTM_TR_Begin (NULL);
/***** Write letter for this option *****/
/* Begin table cell */
HTM_TD_Begin ("class=\"MCH_STD_CELL\"");
/* Form with button.
Sumitting onmousedown instead of default onclick
is necessary in order to be fast
and not lose clicks due to refresh */
Frm_StartForm (ActAnsMchQstStd);
Mch_PutParamMchCod (Match->MchCod); // Current match being played
Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown
Mch_PutParamNumOpt (NumOpt); // Number of button
fprintf (Gbl.F.Out,"