");
- }
+ for (NumOpt = 0;
+ NumOpt < NumOptions;
+ NumOpt++)
+ {
+ /***** Get next answer *****/
+ row = mysql_fetch_row (mysql_res);
- /***** End table *****/
- Tbl_EndTable ();
- }
- else
- Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game.");
- }
+ /***** Assign index (row[0]).
+ Index is 0,1,2,3... if no shuffle
+ or 1,3,0,2... (example) if shuffle *****/
+ if (sscanf (row[0],"%u",&Index) == 1)
+ {
+ if (Index >= Tst_MAX_OPTIONS_PER_QUESTION)
+ ErrorInIndex = true;
+ }
+ else
+ ErrorInIndex = true;
+ if (ErrorInIndex)
+ Lay_ShowErrorAndExit ("Wrong index of answer when showing a test.");
+
+ /***** Start row *****/
+ // if (NumOpt % 2 == 0)
+ fprintf (Gbl.F.Out,"
");
+
+ /***** Write letter for this option *****/
+ /* Start table cell */
+ fprintf (Gbl.F.Out,"
");
+
+ /* Form with button */
+ Frm_StartForm (ActAnsMchQstStd);
+ Gam_PutParamMatchCod (Match->MchCod); // Current match being played
+ Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown
+ Par_PutHiddenParamUnsigned ("Ans",Index); // Index for this option
+ fprintf (Gbl.F.Out,"",
+ 'A' + (char) NumOpt,
+ 'a' + (char) NumOpt);
+ Frm_EndForm ();
+
+ /* End table cell */
+ fprintf (Gbl.F.Out,"
");
+
+ /***** End row *****/
+ // if (NumOpt % 2 == 1)
+ fprintf (Gbl.F.Out,"
");
+ }
+
+ /***** End table *****/
+ Tbl_EndTable ();
+ }
+ else
+ Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game.");
+ }
fprintf (Gbl.F.Out,"
");
}
@@ -3691,44 +3737,31 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
}
/*****************************************************************************/
-/************************ Receive answers of a game ************************/
+/********* Receive question answer from student when playing a match *********/
/*****************************************************************************/
-void Gam_ReceiveGameAnswers (void)
+void Gam_ReceiveQstAnsFromStd (void)
{
- extern const char *Txt_You_already_played_this_game_before;
extern const char *Txt_Thanks_for_playing_the_game;
- struct Game Game;
+ struct Match Match;
- /***** Get game code *****/
- if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L)
- Lay_ShowErrorAndExit ("Code of game is missing.");
+ /***** Get match code *****/
+ if ((Match.MchCod = Gam_GetParamMatchCod ()) == -1L)
+ Lay_ShowErrorAndExit ("Code of match is missing.");
- /***** Get data of the game from database *****/
- Gam_GetDataOfGameByCod (&Game);
+ /***** Get data of the match from database *****/
+ Gam_GetDataOfMatchByCod (&Match);
- /***** Check if I have no answered this game formerly *****/
- if (Game.Status.IHaveAnswered)
- Ale_ShowAlert (Ale_WARNING,Txt_You_already_played_this_game_before);
- else
- {
- /***** Receive and store user's answers *****/
- Gam_ReceiveAndStoreUserAnswersToAGame (Game.GamCod);
- Ale_ShowAlert (Ale_INFO,Txt_Thanks_for_playing_the_game);
- }
-
- /***** Show current game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- true, // List game questions
- false); // Do not put form to start new match
+ /***** Receive and store user's answer *****/
+ Gam_ReceiveAndStoreStdAnswerToQst (&Match);
+ Ale_ShowAlert (Ale_INFO,Txt_Thanks_for_playing_the_game);
}
/*****************************************************************************/
-/**************** Get and store user's answers to a game *******************/
+/************* Get and store user's answer to a match question ***************/
/*****************************************************************************/
-static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod)
+static void Gam_ReceiveAndStoreStdAnswerToQst (struct Match *Match)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
@@ -3741,11 +3774,17 @@ static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod)
char UnsignedStr[10 + 1];
unsigned AnsInd;
- /***** Get questions of this game from database *****/
+ /***** Get question index from form *****/
+
+
+ /***** Check that question index is the current one being played *****/
+
+
+ /***** Get question of this game from database *****/
NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get questions of a game",
"SELECT QstCod FROM gam_questions"
" WHERE GamCod=%ld ORDER BY QstCod",
- GamCod);
+ Match->GamCod);
if (NumQsts) // The game has questions
{
/***** Get questions *****/
@@ -3784,7 +3823,7 @@ static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod)
DB_FreeMySQLResult (&mysql_res);
/***** Register that you have answered this game *****/
- Gam_RegisterIHaveAnsweredGame (GamCod);
+ // Gam_RegisterIHaveAnsweredGame (GamCod);
}
/*****************************************************************************/
@@ -3804,7 +3843,7 @@ static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
/*****************************************************************************/
/******************* Register that I have answered a game ********************/
/*****************************************************************************/
-
+/*
static void Gam_RegisterIHaveAnsweredGame (long GamCod)
{
DB_QueryINSERT ("can not register that you have answered the game",
@@ -3814,7 +3853,7 @@ static void Gam_RegisterIHaveAnsweredGame (long GamCod)
" (%ld,%ld)",
GamCod,Gbl.Usrs.Me.UsrDat.UsrCod);
}
-
+*/
/*****************************************************************************/
/******************** Check if I have answered a game ************************/
/*****************************************************************************/
diff --git a/swad_game.h b/swad_game.h
index 2dbb54a5c..d4c462ffd 100644
--- a/swad_game.h
+++ b/swad_game.h
@@ -123,7 +123,7 @@ void Gam_RemoveMatch (void);
void Gam_RequestNewMatch (void);
// void Gam_PlayMatchStd (void);
-void Gam_ReceiveGameAnswers (void);
+void Gam_ReceiveQstAnsFromStd (void);
void Gam_CreateNewMatch (void);
void Gam_ResumeUnfinishedMatch (void);
void Gam_NextStatusMatch (void);
diff --git a/swad_text.c b/swad_text.c
index e658bd70a..705cfea77 100644
--- a/swad_text.c
+++ b/swad_text.c
@@ -53741,7 +53741,7 @@ const char *Txt_You_already_answered_this_survey_before =
#elif L==9 // pt
"Você já respondeu a esso inquérito antes.";
#endif
-
+/*
const char *Txt_You_already_played_this_game_before =
#if L==1 // ca
"Vostè ja ha jugat aquest joc abans.";
@@ -53762,7 +53762,7 @@ const char *Txt_You_already_played_this_game_before =
#elif L==9 // pt
"Você já jogou este jogo antes.";
#endif
-
+*/
const char *Txt_You_are_now_LOGGED_IN_as_X = // Warning: it is very important to include two %s in the following sentences
#if L==1 // ca
"Vostè està ara %s com a %s.";