diff --git a/css/swad18.112.1.css b/css/swad18.122.3.css similarity index 99% rename from css/swad18.112.1.css rename to css/swad18.122.3.css index 13704f1c3..96f7a3df9 100644 --- a/css/swad18.112.1.css +++ b/css/swad18.122.3.css @@ -2565,6 +2565,7 @@ a:hover img.CENTRE_PHOTO_SHOW box-sizing:border-box; display:table; margin:5%; + width:90%; } .GAM_PLAY_NUM_QST { @@ -2575,7 +2576,7 @@ a:hover img.CENTRE_PHOTO_SHOW color:#808080; font-size:48pt; font-weight:bold; - } + } .GAM_PLAY_QST_CONTAINER { width:80%; diff --git a/sql/swad.sql b/sql/swad.sql index c1a39afef..cebb54749 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -633,8 +633,8 @@ CREATE TABLE IF NOT EXISTS gam_grp ( -- CREATE TABLE IF NOT EXISTS gam_playing ( GamCod INT NOT NULL, - QstCod INT NOT NULL DEFAULT -1, QstInd INT NOT NULL DEFAULT 0, + QstCod INT NOT NULL DEFAULT -1, ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N', GamStart DATETIME NOT NULL, QstStart DATETIME NOT NULL, diff --git a/swad_action.c b/swad_action.c index cfb6e8eeb..09893a935 100644 --- a/swad_action.c +++ b/swad_action.c @@ -610,6 +610,7 @@ Assessment: 456. ActGamTch1stQst Show first question when playing a game (by a teacher) 457. ActGamTchNxtQst Show next question when playing a game (by a teacher) 458. ActGamTchAns Show answers of current question when playing a game (by a teacher) + NEW. ActGamTchEnd End playing a game (by a teacher) NEW. ActPlyGamStd Play a game (by a student) NEW. ActGamStdCurQst Show current question when playing a game (by a student) @@ -2141,9 +2142,10 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActSeeGam */{1650,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_SeeOneGame ,NULL}, /* ActStrGamTch */{1670,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_StartGameTch ,NULL}, - /* ActGamTch1stQst */{1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_GameTchNextQuestion ,NULL}, + /* ActGamTch1stQst */{1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_GameTchFirstQuestion ,NULL}, /* ActGamTchNxtQst */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_GameTchNextQuestion ,NULL}, /* ActGamTchAns */{1673,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_GameTchShowAnswers ,NULL}, + /* ActGamTchEnd */{1781,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_GameTchEnd ,NULL}, /* ActPlyGamStd */{1779,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_PlayGameStd ,NULL}, /* ActGamStdCurQst */{1780,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_GameStdCurrentQuestion ,NULL}, @@ -4978,6 +4980,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActUnlAllPrj, // #1778 ActPlyGamStd, // #1779 ActGamStdCurQst, // #1780 + ActGamTchEnd, // #1781 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 682462d30..cf0df921a 100644 --- a/swad_action.h +++ b/swad_action.h @@ -64,9 +64,9 @@ typedef enum typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (1 + 8 + 61 + 38 + 12 + 42 + 36 + 19 + 110 + 165 + 437 + 176 + 169 + 15 + 67) +#define Act_NUM_ACTIONS (1 + 8 + 61 + 38 + 12 + 42 + 36 + 19 + 110 + 166 + 437 + 176 + 169 + 15 + 67) -#define Act_MAX_ACTION_COD 1780 +#define Act_MAX_ACTION_COD 1781 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 @@ -612,54 +612,55 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActStrGamTch (ActChgCrsTT1stDay + 117) #define ActGamTch1stQst (ActChgCrsTT1stDay + 118) #define ActGamTchNxtQst (ActChgCrsTT1stDay + 119) -#define ActGamTchAns (ActChgCrsTT1stDay + 120) -#define ActPlyGamStd (ActChgCrsTT1stDay + 121) -#define ActGamStdCurQst (ActChgCrsTT1stDay + 122) -#define ActAnsGam (ActChgCrsTT1stDay + 123) -#define ActFrmNewGam (ActChgCrsTT1stDay + 124) -#define ActEdiOneGam (ActChgCrsTT1stDay + 125) -#define ActNewGam (ActChgCrsTT1stDay + 126) -#define ActChgGam (ActChgCrsTT1stDay + 127) -#define ActReqRemGam (ActChgCrsTT1stDay + 128) -#define ActRemGam (ActChgCrsTT1stDay + 129) -#define ActReqRstGam (ActChgCrsTT1stDay + 130) -#define ActRstGam (ActChgCrsTT1stDay + 131) -#define ActHidGam (ActChgCrsTT1stDay + 132) -#define ActShoGam (ActChgCrsTT1stDay + 133) -#define ActAddOneGamQst (ActChgCrsTT1stDay + 134) -#define ActGamLstTstQst (ActChgCrsTT1stDay + 135) -#define ActAddTstQstToGam (ActChgCrsTT1stDay + 136) -#define ActReqRemGamQst (ActChgCrsTT1stDay + 137) -#define ActRemGamQst (ActChgCrsTT1stDay + 138) -#define ActUp_GamQst (ActChgCrsTT1stDay + 139) -#define ActDwnGamQst (ActChgCrsTT1stDay + 140) +#define ActGamTchEnd (ActChgCrsTT1stDay + 120) +#define ActGamTchAns (ActChgCrsTT1stDay + 121) +#define ActPlyGamStd (ActChgCrsTT1stDay + 122) +#define ActGamStdCurQst (ActChgCrsTT1stDay + 123) +#define ActAnsGam (ActChgCrsTT1stDay + 124) +#define ActFrmNewGam (ActChgCrsTT1stDay + 125) +#define ActEdiOneGam (ActChgCrsTT1stDay + 126) +#define ActNewGam (ActChgCrsTT1stDay + 127) +#define ActChgGam (ActChgCrsTT1stDay + 128) +#define ActReqRemGam (ActChgCrsTT1stDay + 129) +#define ActRemGam (ActChgCrsTT1stDay + 130) +#define ActReqRstGam (ActChgCrsTT1stDay + 131) +#define ActRstGam (ActChgCrsTT1stDay + 132) +#define ActHidGam (ActChgCrsTT1stDay + 133) +#define ActShoGam (ActChgCrsTT1stDay + 134) +#define ActAddOneGamQst (ActChgCrsTT1stDay + 135) +#define ActGamLstTstQst (ActChgCrsTT1stDay + 136) +#define ActAddTstQstToGam (ActChgCrsTT1stDay + 137) +#define ActReqRemGamQst (ActChgCrsTT1stDay + 138) +#define ActRemGamQst (ActChgCrsTT1stDay + 139) +#define ActUp_GamQst (ActChgCrsTT1stDay + 140) +#define ActDwnGamQst (ActChgCrsTT1stDay + 141) -#define ActSeeSvy (ActChgCrsTT1stDay + 141) -#define ActAnsSvy (ActChgCrsTT1stDay + 142) -#define ActFrmNewSvy (ActChgCrsTT1stDay + 143) -#define ActEdiOneSvy (ActChgCrsTT1stDay + 144) -#define ActNewSvy (ActChgCrsTT1stDay + 145) -#define ActChgSvy (ActChgCrsTT1stDay + 146) -#define ActReqRemSvy (ActChgCrsTT1stDay + 147) -#define ActRemSvy (ActChgCrsTT1stDay + 148) -#define ActReqRstSvy (ActChgCrsTT1stDay + 149) -#define ActRstSvy (ActChgCrsTT1stDay + 150) -#define ActHidSvy (ActChgCrsTT1stDay + 151) -#define ActShoSvy (ActChgCrsTT1stDay + 152) -#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 153) -#define ActRcvSvyQst (ActChgCrsTT1stDay + 154) -#define ActReqRemSvyQst (ActChgCrsTT1stDay + 155) -#define ActRemSvyQst (ActChgCrsTT1stDay + 156) +#define ActSeeSvy (ActChgCrsTT1stDay + 142) +#define ActAnsSvy (ActChgCrsTT1stDay + 143) +#define ActFrmNewSvy (ActChgCrsTT1stDay + 144) +#define ActEdiOneSvy (ActChgCrsTT1stDay + 145) +#define ActNewSvy (ActChgCrsTT1stDay + 146) +#define ActChgSvy (ActChgCrsTT1stDay + 147) +#define ActReqRemSvy (ActChgCrsTT1stDay + 148) +#define ActRemSvy (ActChgCrsTT1stDay + 149) +#define ActReqRstSvy (ActChgCrsTT1stDay + 150) +#define ActRstSvy (ActChgCrsTT1stDay + 151) +#define ActHidSvy (ActChgCrsTT1stDay + 152) +#define ActShoSvy (ActChgCrsTT1stDay + 153) +#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 154) +#define ActRcvSvyQst (ActChgCrsTT1stDay + 155) +#define ActReqRemSvyQst (ActChgCrsTT1stDay + 156) +#define ActRemSvyQst (ActChgCrsTT1stDay + 157) -#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 157) -#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 158) -#define ActEdiExaAnn (ActChgCrsTT1stDay + 159) -#define ActRcvExaAnn (ActChgCrsTT1stDay + 160) -#define ActPrnExaAnn (ActChgCrsTT1stDay + 161) -#define ActReqRemExaAnn (ActChgCrsTT1stDay + 162) -#define ActRemExaAnn (ActChgCrsTT1stDay + 163) -#define ActHidExaAnn (ActChgCrsTT1stDay + 164) -#define ActShoExaAnn (ActChgCrsTT1stDay + 165) +#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 158) +#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 159) +#define ActEdiExaAnn (ActChgCrsTT1stDay + 160) +#define ActRcvExaAnn (ActChgCrsTT1stDay + 161) +#define ActPrnExaAnn (ActChgCrsTT1stDay + 162) +#define ActReqRemExaAnn (ActChgCrsTT1stDay + 163) +#define ActRemExaAnn (ActChgCrsTT1stDay + 164) +#define ActHidExaAnn (ActChgCrsTT1stDay + 165) +#define ActShoExaAnn (ActChgCrsTT1stDay + 166) /*****************************************************************************/ /******************************** Files tab **********************************/ diff --git a/swad_button.c b/swad_button.c index 6b4c93a9f..683e95cc2 100644 --- a/swad_button.c +++ b/swad_button.c @@ -149,3 +149,14 @@ void Btn_PutRemoveButtonInline (const char *TxtButton) "", TxtButton); } + +void Btn_PutCloseButton (const char *TxtButton) + { + fprintf (Gbl.F.Out,"
" + "" + "
", + TxtButton); + } diff --git a/swad_button.h b/swad_button.h index 5398c4fbb..dd9270354 100644 --- a/swad_button.h +++ b/swad_button.h @@ -55,5 +55,6 @@ void Btn_PutConfirmButton (const char *TxtButton); void Btn_PutConfirmButtonInline (const char *TxtButton); void Btn_PutRemoveButton (const char *TxtButton); void Btn_PutRemoveButtonInline (const char *TxtButton); +void Btn_PutCloseButton (const char *TxtButton); #endif diff --git a/swad_changelog.h b/swad_changelog.h index a94709156..f3f3d7372 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -448,14 +448,20 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.122.2 (2019-05-18)" -#define CSS_FILE "swad18.112.1.css" +#define Log_PLATFORM_VERSION "SWAD 18.122.3 (2019-05-20)" +#define CSS_FILE "swad18.122.3.css" #define JS_FILE "swad18.116.5.js" /* + Version 18.122.3: May 20, 2019 Changes in games. (242558 lines) + Copy the following icon to icon public directory: +sudo cp icon/flag-checkered.svg /var/www/html/swad/icon/ + 1 change necessary in database: +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1781','es','N','Finalizar juego'); + Version 18.122.2: May 20, 2019 New action to show current question (in a game beeing played) to a student. (242378 lines) 2 changes necessary in database: INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1780','es','N','Mostrar juego a estudiante'); -CREATE TABLE IF NOT EXISTS gam_playing (GamCod INT NOT NULL,QstCod INT NOT NULL DEFAULT -1,QstInd INT NOT NULL DEFAULT 0,ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N',GamStart DATETIME NOT NULL,QstStart DATETIME NOT NULL,UNIQUE INDEX(GamCod)); +CREATE TABLE IF NOT EXISTS gam_playing (GamCod INT NOT NULL,QstInd INT NOT NULL DEFAULT 0,QstCod INT NOT NULL DEFAULT -1,ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N',GamStart DATETIME NOT NULL,QstStart DATETIME NOT NULL,UNIQUE INDEX(GamCod)); Version 18.122.1: May 20, 2019 New action to play game by a student. (242257 lines) 2 changes necessary in database: diff --git a/swad_database.c b/swad_database.c index 8e09ef325..f624a171a 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1377,8 +1377,8 @@ mysql> DESCRIBE gam_playing; | Field | Type | Null | Key | Default | Extra | +----------------+---------------+------+-----+---------+-------+ | GamCod | int(11) | NO | PRI | NULL | | -| QstCod | int(11) | NO | | -1 | | | QstInd | int(11) | NO | | 0 | | +| QstCod | int(11) | NO | | -1 | | | ShowingAnswers | enum('N','Y') | NO | | N | | | GamStart | datetime | NO | | NULL | | | QstStart | datetime | NO | | NULL | | @@ -1387,8 +1387,8 @@ mysql> DESCRIBE gam_playing; */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_playing (" "GamCod INT NOT NULL," - "QstCod INT NOT NULL DEFAULT -1," "QstInd INT NOT NULL DEFAULT 0," + "QstCod INT NOT NULL DEFAULT -1," "ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N'," "GamStart DATETIME NOT NULL," "QstStart DATETIME NOT NULL," diff --git a/swad_game.c b/swad_game.c index 7873d3a93..27f5581b9 100644 --- a/swad_game.c +++ b/swad_game.c @@ -156,9 +156,16 @@ static void Gam_ExchangeQuestions (long GamCod, static void Gam_PutBigButtonToStartGameTch (long GamCod); static void Gam_PutBigButtonToPlayGameStd (long GamCod); -static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers); +static bool Gam_CheckIfGameIsBeeingPlayed (long GamCod); +static void Gam_UpdateGameQstBeeingPlayed (long GamCod,unsigned QstInd,long QstCod,bool ShowingAnswers); +static void Gam_RemoveGameBeeingPlayed (long GamCod); + +static void Gam_PlayGameShowQuestionAndAnswers (long GamCod, + unsigned QstInd, + bool ShowAnswers); static void Gam_PutBigButtonToContinue (Act_Action_t NextAction, long GamCod,unsigned QstInd); +static void Gam_PutBigButtonToEnd (long GamCod); static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod); static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd); @@ -2628,8 +2635,6 @@ static void Gam_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs) Txt_of_PART_OF_A_TOTAL,MaxUsrs); /***** Draw bar with a with proportional to the number of clicks *****/ - fprintf (Gbl.F.Out,"", - Gam_MAX_BAR_WIDTH + 125); if (NumUsrs && MaxUsrs) BarWidth = (unsigned) ((((float) NumUsrs * (float) Gam_MAX_BAR_WIDTH) / (float) MaxUsrs) + 0.5); @@ -2646,7 +2651,7 @@ static void Gam_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs) BarWidth); /***** Write the number of users *****/ - fprintf (Gbl.F.Out,"%s",Gbl.Title); + fprintf (Gbl.F.Out,"%s",Gbl.Title); } /*****************************************************************************/ @@ -3012,12 +3017,103 @@ static void Gam_PutBigButtonToPlayGameStd (long GamCod) } /*****************************************************************************/ -/**************** Show next question when playing a game *********************/ +/********* Show first question when playing a game (by a teacher) ************/ +/*****************************************************************************/ + +void Gam_GameTchFirstQuestion (void) + { + long GamCod; + + /***** Get parameters *****/ + /* Get game code */ + if ((GamCod = Gam_GetParamGameCod ()) == -1L) + Lay_ShowErrorAndExit ("Code of game is missing."); + + /***** Check that the game is not being played *****/ + if (Gam_CheckIfGameIsBeeingPlayed (GamCod)) + Ale_ShowAlert (Ale_WARNING,"Este juego ya está jugándose."); // TODO: Need translation!!!!!! + else + /***** Show questions and possible answers *****/ + Gam_PlayGameShowQuestionAndAnswers (GamCod,0, + false); // Don't show answers + } + +/*****************************************************************************/ +/******************** Check if I have answered a game ************************/ +/*****************************************************************************/ + +static bool Gam_CheckIfGameIsBeeingPlayed (long GamCod) + { + /***** Get if game is being played from database *****/ + return (DB_QueryCOUNT ("can not check if game is being played", + "SELECT COUNT(*) FROM gam_playing" + " WHERE GamCod=%ld", + GamCod) != 0); + } + +/*****************************************************************************/ +/********************** Insert/update game being played **********************/ +/*****************************************************************************/ + +static void Gam_UpdateGameQstBeeingPlayed (long GamCod,unsigned QstInd,long QstCod,bool ShowingAnswers) + { + if (ShowingAnswers) // Show a question previously shown and its answers + DB_QueryUPDATE ("can not update game beeing played", + "UPDATE gam_playing" + " SET ShowingAnswers='Y'" + " WHERE GamCod=%ld AND QstInd=%u AND QstCod=%ld", + GamCod,QstInd,QstCod); + else // Show a question without answers + { + if (QstInd == 0) // 1st question beeing shown + DB_QueryINSERT ("can not update game beeing played", + "INSERT gam_playing" + " (GamCod,QstInd,QstCod,ShowingAnswers,GamStart,QstStart)" + " VALUES" + " (%ld,0,%ld,'N',NOW(),NOW())", + GamCod,QstCod); + else // 2nd, 3rd... question beeing shown + DB_QueryUPDATE ("can not update game beeing played", + "UPDATE gam_playing" + " SET QstInd=%u,QstCod=%ld,ShowingAnswers='N',QstStart=NOW()" + " WHERE GamCod=%ld", + QstInd,QstCod,GamCod); + } + } + +/*****************************************************************************/ +/******************** Remove game from games being played ********************/ +/*****************************************************************************/ + +static void Gam_RemoveGameBeeingPlayed (long GamCod) + { + /***** Remove game being played from database *****/ + DB_QueryDELETE ("can not remove game being played", + "DELETE FROM gam_playing" + " WHERE GamCod=%ld", + GamCod); + } + +/*****************************************************************************/ +/********* Show next question when playing a game (by a teacher) *************/ /*****************************************************************************/ void Gam_GameTchNextQuestion (void) { - Gam_PlayGameShowQuestionAndAnswers (false); // Don't show answers + long GamCod; + unsigned QstInd; + + /***** Get parameters *****/ + /* Get game code */ + if ((GamCod = Gam_GetParamGameCod ()) == -1L) + Lay_ShowErrorAndExit ("Code of game is missing."); + + /* Get question index */ + QstInd = Gam_GetParamQstInd (); + + /***** Show questions and possible answers *****/ + Gam_PlayGameShowQuestionAndAnswers (GamCod,QstInd, + false); // Don't show answers } /*****************************************************************************/ @@ -3026,31 +3122,38 @@ void Gam_GameTchNextQuestion (void) void Gam_GameTchShowAnswers (void) { - Gam_PlayGameShowQuestionAndAnswers (true); // Show answers + long GamCod; + unsigned QstInd; + + /***** Get parameters *****/ + /* Get game code */ + if ((GamCod = Gam_GetParamGameCod ()) == -1L) + Lay_ShowErrorAndExit ("Code of game is missing."); + + /* Get question index */ + QstInd = Gam_GetParamQstInd (); + + /***** Show questions and possible answers *****/ + Gam_PlayGameShowQuestionAndAnswers (GamCod,QstInd, + true); // Show answers } /*****************************************************************************/ /************ Show question and its answers when playing a game **************/ /*****************************************************************************/ -static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers) +static void Gam_PlayGameShowQuestionAndAnswers (long GamCod, + unsigned QstInd, + bool ShowAnswers) { MYSQL_RES *mysql_res; MYSQL_ROW row; - struct Game Game; - unsigned QstInd; int NxtQstInd; long QstCod; - - /***** Get parameters *****/ - /* Get game code */ - if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L) - Lay_ShowErrorAndExit ("Code of game is missing."); - - /* Get question index */ - QstInd = Gam_GetParamQstInd (); + struct Game Game; /***** Get data of question from database *****/ + Game.GamCod = GamCod; if (!DB_QuerySELECT (&mysql_res,"can not get data of a question", "SELECT tst_questions.QstCod," // row[0] "tst_questions.AnsType," // row[1] @@ -3074,6 +3177,10 @@ static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers) fprintf (Gbl.F.Out,"
"); + /* Get question code (row[0]) */ + if ((QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) + Lay_ShowErrorAndExit ("Error: wrong question code."); + /* Write stem (row[2]) */ Tst_WriteQstStem (row[2],"GAM_PLAY_QST"); @@ -3089,10 +3196,6 @@ static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers) /* Write answers? */ if (ShowAnswers) { - /* Get question code (row[0]) */ - if ((QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) - Lay_ShowErrorAndExit ("Error: wrong question code."); - /* Get answer type (row[1]) */ Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); @@ -3111,9 +3214,12 @@ static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers) { /* Get index of the next question */ NxtQstInd = Gam_GetNextQuestionIndexInGame (Game.GamCod,QstInd); - if (NxtQstInd > 0) + if (NxtQstInd >= 0) // Not last question /* Put button to show next question */ Gam_PutBigButtonToContinue (ActGamTchNxtQst,Game.GamCod,(unsigned) NxtQstInd); + else // Last question + /* Put button to end */ + Gam_PutBigButtonToEnd (Game.GamCod); } else /* Put button to show answers */ @@ -3122,6 +3228,9 @@ static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers) /***** End container for question *****/ fprintf (Gbl.F.Out,"
"); + + /***** Insert/update game in table of games currently being played *****/ + Gam_UpdateGameQstBeeingPlayed (GamCod,QstInd,QstCod,ShowAnswers); } /*****************************************************************************/ @@ -3147,8 +3256,9 @@ static void Gam_PutBigButtonToContinue (Act_Action_t NextAction, " alt=\"%s\" title=\"%s\" class=\"ICO64x64\" />" "
" "%s", - Cfg_URL_ICON_PUBLIC,Txt_Continue,Txt_Continue, - Txt_Continue); + Cfg_URL_ICON_PUBLIC, + Txt_Continue,Txt_Continue, + Txt_Continue); fprintf (Gbl.F.Out,""); /***** End form *****/ @@ -3158,6 +3268,63 @@ static void Gam_PutBigButtonToContinue (Act_Action_t NextAction, fprintf (Gbl.F.Out,""); } + +/*****************************************************************************/ +/************************* Put a big button to end ***************************/ +/*****************************************************************************/ + +static void Gam_PutBigButtonToEnd (long GamCod) + { + extern const char *Txt_Finish; + + /***** Start container *****/ + fprintf (Gbl.F.Out,"
"); + + /***** Start form *****/ + Frm_StartForm (ActGamTchEnd); + Gam_PutParamGameCod (GamCod); + + /***** Put icon with link *****/ + Frm_LinkFormSubmit (Txt_Finish,"GAM_PLAY_CONTINUE ICO_HIGHLIGHT",NULL); + fprintf (Gbl.F.Out,"\"%s\"" + "
" + "%s", + Cfg_URL_ICON_PUBLIC, + Txt_Finish,Txt_Finish, + Txt_Finish); + fprintf (Gbl.F.Out,""); + + /***** End form *****/ + Frm_EndForm (); + + /***** End container *****/ + fprintf (Gbl.F.Out,"
"); + } + +/*****************************************************************************/ +/******************** End playing a game (by a teacher) **********************/ +/*****************************************************************************/ + +void Gam_GameTchEnd (void) + { + long GamCod; + + /***** Get parameters *****/ + /* Get game code */ + if ((GamCod = Gam_GetParamGameCod ()) == -1L) + Lay_ShowErrorAndExit ("Code of game is missing."); + + /***** Remove game being played *****/ + Gam_RemoveGameBeeingPlayed (GamCod); + + /***** Show alert *****/ + Ale_ShowAlert (Ale_INFO,"Juego finalizado."); // TODO: Need translation!!!!! + + /***** Button to close *****/ + Btn_PutCloseButton ("Cerrar"); // TODO: Need translation!!!!! + } + /*****************************************************************************/ /***** Show current question to a student when he/she is playing a game ******/ /*****************************************************************************/ diff --git a/swad_game.h b/swad_game.h index 200d4c7ad..7ad318252 100644 --- a/swad_game.h +++ b/swad_game.h @@ -122,8 +122,10 @@ void Gam_StartGameTch (void); void Gam_PlayGameStd (void); void Gam_ReceiveGameAnswers (void); +void Gam_GameTchFirstQuestion (void); void Gam_GameTchNextQuestion (void); void Gam_GameTchShowAnswers (void); +void Gam_GameTchEnd (void); void Gam_GameStdCurrentQuestion (void); diff --git a/swad_layout.c b/swad_layout.c index dd97c267f..08ec8eb33 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -686,7 +686,6 @@ static void Lay_WriteScriptInit (void) if ((Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN)) // Right column visible Con_WriteScriptClockConnected (); - // Put the focus on login form fprintf (Gbl.F.Out," ActionAJAX = \"%s\";\n" " setTimeout(\"refreshConnected()\",%lu);\n", Lan_STR_LANG_ID[Gbl.Prefs.Language], diff --git a/swad_test.c b/swad_test.c index 290842df3..c1022fdc9 100644 --- a/swad_test.c +++ b/swad_test.c @@ -4122,16 +4122,17 @@ static void Tst_WriteChoiceAnsViewGame (struct Game *Game, ""); /***** Show result (number of users who answered? *****/ - fprintf (Gbl.F.Out,"" - ""); if (ShowResult) + { + fprintf (Gbl.F.Out,"" + "" + ""); /* Get number of users who selected this answer and draw proportional bar */ Gam_GetAndDrawBarNumUsrsWhoAnswered (Game,QstCod,AnsInd); - else - fprintf (Gbl.F.Out," "); - fprintf (Gbl.F.Out,"" - ""); + fprintf (Gbl.F.Out,"" + ""); + } } /***** End table *****/ diff --git a/swad_text.c b/swad_text.c index e74d2e660..9f83ce77a 100644 --- a/swad_text.c +++ b/swad_text.c @@ -12205,6 +12205,27 @@ const char *Txt_Filter = // As a noun "Filtro"; #endif +const char *Txt_Finish = +#if L==1 // ca + "Acabar"; +#elif L==2 // de + "Fertig"; +#elif L==3 // en + "Finish"; +#elif L==4 // es + "Terminar"; +#elif L==5 // fr + "Terminer"; +#elif L==6 // gn + "Momba"; +#elif L==7 // it + "Finire"; +#elif L==8 // pl + "Koniec"; +#elif L==9 // pt + "Terminar"; +#endif + const char *Txt_First_day_of_the_week = #if L==1 // ca "Primer dia de la setmana";