From 7c1b62b58452ecf22792cd78816ae49c0e105fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 17 Jul 2019 11:31:42 +0200 Subject: [PATCH] Version18.134 --- swad_action.c | 30 ++--- swad_action.h | 107 ++++++++--------- swad_changelog.h | 7 +- swad_game.c | 297 ++++++++++++++++++++++++++--------------------- swad_game.h | 8 +- swad_text.c | 20 ++-- 6 files changed, 255 insertions(+), 214 deletions(-) diff --git a/swad_action.c b/swad_action.c index 31ea6802a..490c81b6c 100644 --- a/swad_action.c +++ b/swad_action.c @@ -605,14 +605,16 @@ Assessment: 453. ActRemSvyQst Confirm the removal of a question of a survey 454. ActSeeGam Show one game - 455. ActFrmNewMchTch Put form to create a new match (by a teacher) + NEW. ActReqRemMchTch Request the removal of a match (by a teacher) - NEW. ActRemMchTch Confirm the removal of a match (by a teacher) - 456. ActNewMchTch Create a new match showing first question in a new browser tab (by a teacher) - NEW. ActResMchTch Resume an unfinished match showing current question in a new browser tab (by a teacher) - 457. ActNxtMchTch Show next question when playing a game (by a teacher) - NEW. ActRefMchTch Refresh current question when playing a game (as teacher) - NEW. ActShoMchTch Show finished match results + NEW. ActRemMchTch Confirm the removal of a match (by a teacher) + 455. ActReqNewMchTch Put form to create a new match (by a teacher) + 456. ActNewMchTch Create a new match showing first question in a new browser tab (by a teacher) + NEW. ActResMchTch Resume an unfinished match showing current question in a new browser tab (by a teacher) + NEW. ActCurMchTch Show current question when playing a match (by a teacher) + 457. ActNxtMchTch Show next question when playing a match (by a teacher) + NEW. ActRefMchTch Refresh current question when playing a match (as teacher) + NEW. ActShoMchTch Show finished match results NEW. ActPlyMchStd Show current question when playing a game (as student) NEW. ActRefMchStd Refresh current question when playing a game (as student) @@ -2145,13 +2147,14 @@ 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}, - /* ActFrmNewMchTch */{1670,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestNewMatchTch ,NULL}, /* ActReqRemMchTch */{1783,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestRemoveMatchTch ,NULL}, /* ActRemMchTch */{1784,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RemoveMatchTch ,NULL}, - /* ActNewMchTch */{1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_CreateNewMatchTch1 ,Gam_CreateNewMatchTch2 ,NULL}, - /* ActResMchTch */{1785,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_GetMatchBeingPlayed ,Gam_ResumeUnfinishedMatchTch ,NULL}, + /* ActReqNewMchTch */{1670,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestNewMatchTch ,NULL}, + /* ActNewMchTch */{1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_CreateNewMatchTch ,Gam_RequestStartResumeMatchTch ,NULL}, + /* ActResMchTch */{1785,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_GetMatchBeingPlayed ,Gam_RequestStartResumeMatchTch ,NULL}, + /* ActCurMchTch */{1789,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_CurrentStatusMatchTch ,NULL}, /* ActNxtMchTch */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_NextStatusMatchTch ,NULL}, - /* ActRefMchTch */{1788,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Gam_GetMatchBeingPlayed ,Gam_RefreshCurrentMatchTch ,NULL}, + /* ActRefMchTch */{1788,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Gam_GetMatchBeingPlayed ,Gam_RefreshNumPlayersMatchTch ,NULL}, /* ActShoMchTch */{1786,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ShowFinishedMatchResults ,NULL}, /* ActPlyMchStd */{1780,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowMatchToMeAsStd ,NULL}, @@ -4878,7 +4881,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActAddTstQstToGam, // #1667 ActUp_GamQst, // #1668 ActDwnGamQst, // #1669 - ActFrmNewMchTch, // #1670 + ActReqNewMchTch, // #1670 ActNewMchTch, // #1671 ActNxtMchTch, // #1672 -1, // #1673 (obsolete action) @@ -4991,12 +4994,13 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActPlyMchStd, // #1780 -1, // #1781 (obsolete action) ActRefMchStd, // #1782 - ActReqRemMchTch, // #1783 + ActReqRemMchTch, // #1783 ActRemMchTch, // #1784 ActResMchTch, // #1785 ActShoMchTch, // #1786 ActCreMyAcc, // #1787 ActRefMchTch, // #1788 + ActCurMchTch, // #1789 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 8b4dc2cd8..fda16fe74 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 + 4 + 64 + 38 + 12 + 42 + 36 + 19 + 110 + 169 + 437 + 176 + 169 + 16 + 68) +#define Act_NUM_ACTIONS (1 + 4 + 64 + 38 + 12 + 42 + 36 + 19 + 110 + 170 + 437 + 176 + 169 + 16 + 68) -#define Act_MAX_ACTION_COD 1788 +#define Act_MAX_ACTION_COD 1789 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 @@ -607,61 +607,62 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActSeeOneTstResOth (ActChgCrsTT1stDay + 115) #define ActSeeGam (ActChgCrsTT1stDay + 116) -#define ActFrmNewMchTch (ActChgCrsTT1stDay + 117) -#define ActReqRemMchTch (ActChgCrsTT1stDay + 118) -#define ActRemMchTch (ActChgCrsTT1stDay + 119) +#define ActReqRemMchTch (ActChgCrsTT1stDay + 117) +#define ActRemMchTch (ActChgCrsTT1stDay + 118) +#define ActReqNewMchTch (ActChgCrsTT1stDay + 119) #define ActNewMchTch (ActChgCrsTT1stDay + 120) #define ActResMchTch (ActChgCrsTT1stDay + 121) -#define ActNxtMchTch (ActChgCrsTT1stDay + 122) -#define ActRefMchTch (ActChgCrsTT1stDay + 123) -#define ActShoMchTch (ActChgCrsTT1stDay + 124) -#define ActPlyMchStd (ActChgCrsTT1stDay + 125) -#define ActRefMchStd (ActChgCrsTT1stDay + 126) -#define ActAnsMchQstStd (ActChgCrsTT1stDay + 127) -#define ActFrmNewGam (ActChgCrsTT1stDay + 128) -#define ActEdiOneGam (ActChgCrsTT1stDay + 129) -#define ActNewGam (ActChgCrsTT1stDay + 130) -#define ActChgGam (ActChgCrsTT1stDay + 131) -#define ActReqRemGam (ActChgCrsTT1stDay + 132) -#define ActRemGam (ActChgCrsTT1stDay + 133) -#define ActReqRstGam (ActChgCrsTT1stDay + 134) -#define ActRstGam (ActChgCrsTT1stDay + 135) -#define ActHidGam (ActChgCrsTT1stDay + 136) -#define ActShoGam (ActChgCrsTT1stDay + 137) -#define ActAddOneGamQst (ActChgCrsTT1stDay + 138) -#define ActGamLstTstQst (ActChgCrsTT1stDay + 139) -#define ActAddTstQstToGam (ActChgCrsTT1stDay + 140) -#define ActReqRemGamQst (ActChgCrsTT1stDay + 141) -#define ActRemGamQst (ActChgCrsTT1stDay + 142) -#define ActUp_GamQst (ActChgCrsTT1stDay + 143) -#define ActDwnGamQst (ActChgCrsTT1stDay + 144) +#define ActCurMchTch (ActChgCrsTT1stDay + 122) +#define ActNxtMchTch (ActChgCrsTT1stDay + 123) +#define ActRefMchTch (ActChgCrsTT1stDay + 124) +#define ActShoMchTch (ActChgCrsTT1stDay + 125) +#define ActPlyMchStd (ActChgCrsTT1stDay + 126) +#define ActRefMchStd (ActChgCrsTT1stDay + 127) +#define ActAnsMchQstStd (ActChgCrsTT1stDay + 128) +#define ActFrmNewGam (ActChgCrsTT1stDay + 129) +#define ActEdiOneGam (ActChgCrsTT1stDay + 130) +#define ActNewGam (ActChgCrsTT1stDay + 131) +#define ActChgGam (ActChgCrsTT1stDay + 132) +#define ActReqRemGam (ActChgCrsTT1stDay + 133) +#define ActRemGam (ActChgCrsTT1stDay + 134) +#define ActReqRstGam (ActChgCrsTT1stDay + 135) +#define ActRstGam (ActChgCrsTT1stDay + 136) +#define ActHidGam (ActChgCrsTT1stDay + 137) +#define ActShoGam (ActChgCrsTT1stDay + 138) +#define ActAddOneGamQst (ActChgCrsTT1stDay + 139) +#define ActGamLstTstQst (ActChgCrsTT1stDay + 140) +#define ActAddTstQstToGam (ActChgCrsTT1stDay + 141) +#define ActReqRemGamQst (ActChgCrsTT1stDay + 142) +#define ActRemGamQst (ActChgCrsTT1stDay + 143) +#define ActUp_GamQst (ActChgCrsTT1stDay + 144) +#define ActDwnGamQst (ActChgCrsTT1stDay + 145) -#define ActSeeSvy (ActChgCrsTT1stDay + 145) -#define ActAnsSvy (ActChgCrsTT1stDay + 146) -#define ActFrmNewSvy (ActChgCrsTT1stDay + 147) -#define ActEdiOneSvy (ActChgCrsTT1stDay + 148) -#define ActNewSvy (ActChgCrsTT1stDay + 149) -#define ActChgSvy (ActChgCrsTT1stDay + 150) -#define ActReqRemSvy (ActChgCrsTT1stDay + 151) -#define ActRemSvy (ActChgCrsTT1stDay + 152) -#define ActReqRstSvy (ActChgCrsTT1stDay + 153) -#define ActRstSvy (ActChgCrsTT1stDay + 154) -#define ActHidSvy (ActChgCrsTT1stDay + 155) -#define ActShoSvy (ActChgCrsTT1stDay + 156) -#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 157) -#define ActRcvSvyQst (ActChgCrsTT1stDay + 158) -#define ActReqRemSvyQst (ActChgCrsTT1stDay + 159) -#define ActRemSvyQst (ActChgCrsTT1stDay + 160) +#define ActSeeSvy (ActChgCrsTT1stDay + 146) +#define ActAnsSvy (ActChgCrsTT1stDay + 147) +#define ActFrmNewSvy (ActChgCrsTT1stDay + 148) +#define ActEdiOneSvy (ActChgCrsTT1stDay + 149) +#define ActNewSvy (ActChgCrsTT1stDay + 150) +#define ActChgSvy (ActChgCrsTT1stDay + 151) +#define ActReqRemSvy (ActChgCrsTT1stDay + 152) +#define ActRemSvy (ActChgCrsTT1stDay + 153) +#define ActReqRstSvy (ActChgCrsTT1stDay + 154) +#define ActRstSvy (ActChgCrsTT1stDay + 155) +#define ActHidSvy (ActChgCrsTT1stDay + 156) +#define ActShoSvy (ActChgCrsTT1stDay + 157) +#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 158) +#define ActRcvSvyQst (ActChgCrsTT1stDay + 159) +#define ActReqRemSvyQst (ActChgCrsTT1stDay + 160) +#define ActRemSvyQst (ActChgCrsTT1stDay + 161) -#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 161) -#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 162) -#define ActEdiExaAnn (ActChgCrsTT1stDay + 163) -#define ActRcvExaAnn (ActChgCrsTT1stDay + 164) -#define ActPrnExaAnn (ActChgCrsTT1stDay + 165) -#define ActReqRemExaAnn (ActChgCrsTT1stDay + 166) -#define ActRemExaAnn (ActChgCrsTT1stDay + 167) -#define ActHidExaAnn (ActChgCrsTT1stDay + 168) -#define ActShoExaAnn (ActChgCrsTT1stDay + 169) +#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 162) +#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 163) +#define ActEdiExaAnn (ActChgCrsTT1stDay + 164) +#define ActRcvExaAnn (ActChgCrsTT1stDay + 165) +#define ActPrnExaAnn (ActChgCrsTT1stDay + 166) +#define ActReqRemExaAnn (ActChgCrsTT1stDay + 167) +#define ActRemExaAnn (ActChgCrsTT1stDay + 168) +#define ActHidExaAnn (ActChgCrsTT1stDay + 169) +#define ActShoExaAnn (ActChgCrsTT1stDay + 170) /*****************************************************************************/ /******************************** Files tab **********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index b1de0b621..325e573f9 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -458,10 +458,15 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.133 (2019-07-16)" +#define Log_PLATFORM_VERSION "SWAD 18.134 (2019-07-16)" #define CSS_FILE "swad18.132.2.css" #define JS_FILE "swad18.130.2.js" /* + Version 18.134: Jul 17, 2019 Changes resuming a match. (243641 lines) + 2 changes necessary in database: +UPDATE actions SET Txt='Mostrar pregunta siguiente en partida (como profesor)' WHERE ActCod='1672' AND Language='es'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1789','es','N','Mostrar pregunta actual en partida (como profesor)'); + Version 18.133: Jul 16, 2019 Display number of players in a game. (243604 lines) 3 changes necessary in database: DROP TABLE IF EXISTS gam_players; diff --git a/swad_game.c b/swad_game.c index 8883693f1..39f739c50 100644 --- a/swad_game.c +++ b/swad_game.c @@ -132,7 +132,7 @@ static void Gam_PutParamMatchCod (long MchCod); static long Gam_GetParamMatchCod (void); static bool Gam_CheckIfSimilarGameExists (struct Game *Game); -static void Gam_ShowLstGrpsToEditMatch (void); +static void Gam_ShowLstGrpsToCreateMatch (void); static void Gam_CreateGame (struct Game *Game,const char *Txt); static void Gam_UpdateGame (struct Game *Game,const char *Txt); @@ -188,7 +188,8 @@ static void Gam_UpdateMatchBeingPlayed (struct Match *Match); static void Gam_ShowMatchStatusForTch (struct Match *Match); static void Gam_ShowAlertFinishedMatch (void); static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match); -static void Gam_PutBigButton (long MchCod,const char *Txt,const char *Icon); +static void Gam_PutBigButton (Act_Action_t NextAction,long MchCod, + const char *Icon,const char *Txt); static void Gam_RemoveOldPlayers (void); static void Gam_RemoveAllPlayersInMatch (long MchCod); @@ -466,7 +467,7 @@ static void Gam_ShowOneGame (long GamCod, if (ShowOnlyThisGame) /* Icon to start a new match */ - Lay_PutContextualLinkOnlyIcon (ActFrmNewMchTch,Gam_NEW_MATCH_SECTION_ID, + Lay_PutContextualLinkOnlyIcon (ActReqNewMchTch,Gam_NEW_MATCH_SECTION_ID, Gam_PutParams, "play.svg", Txt_New_match); @@ -1312,10 +1313,10 @@ void Gam_RequestCreatOrEditGame (void) } /*****************************************************************************/ -/******************** Show list of groups to edit a game *******************/ +/***************** Show list of groups to create a new match *****************/ /*****************************************************************************/ -static void Gam_ShowLstGrpsToEditMatch (void) +static void Gam_ShowLstGrpsToCreateMatch (void) { extern const char *The_ClassFormInBox[The_NUM_THEMES]; extern const char *Txt_Groups; @@ -1423,16 +1424,10 @@ void Gam_RecFormGame (void) /***** Create a new game or update an existing one *****/ if (NewGameIsCorrect) { - /* Get groups for this games */ - Grp_GetParCodsSeveralGrps (); - if (ItsANewGame) Gam_CreateGame (&NewGame,Txt); // Add new game to database else Gam_UpdateGame (&NewGame,Txt); - - /* Free memory for list of selected groups */ - Grp_FreeListCodSelectedGrps (); } else Gam_RequestCreatOrEditGame (); @@ -2799,7 +2794,7 @@ static void Gam_PutIconToPlayNewMatch (void) extern const char *Txt_New_match; /***** Put form to create a new question *****/ - Ico_PutContextualIconToAdd (ActFrmNewMchTch,Gam_NEW_MATCH_SECTION_ID,Gam_PutParams, + Ico_PutContextualIconToAdd (ActReqNewMchTch,Gam_NEW_MATCH_SECTION_ID,Gam_PutParams, Txt_New_match); } @@ -2817,7 +2812,7 @@ static void Gam_ListOneOrMoreMatches (struct Game *Game, extern const char *Txt_Match; extern const char *Txt_Status; extern const char *Txt_Play; - extern const char *Txt_Resume; + extern const char *Txt_Resume_match; extern const char *Txt_Today; extern const char *Txt_View_game_results; unsigned NumMatch; @@ -2965,7 +2960,7 @@ static void Gam_ListOneOrMoreMatches (struct Game *Game, Lay_PutContextualLinkOnlyIcon (ActResMchTch,NULL, Gam_PutParamCurrentMchCod, "play.svg", - Txt_Resume); + Txt_Resume_match); break; default: break; @@ -3046,13 +3041,6 @@ static void Gam_GetMatchDataFromRow (MYSQL_RES *mysql_res, /* Get whether the match is finished or not (row(10)) */ Match->Status.Finished = (row[10][0] == 'Y'); - - // /* If question index is 0 ==> the game is finished */ - // if (Match->Status.QstInd == 0) - // { - // Match->Status.QstCod = -1L; - // Match->Status.Finished = true; - // } } /*****************************************************************************/ @@ -3142,7 +3130,7 @@ static void Gam_PutButtonNewMatch (long GamCod) { extern const char *Txt_New_match; - Frm_StartFormAnchor (ActFrmNewMchTch,Gam_NEW_MATCH_SECTION_ID); + Frm_StartFormAnchor (ActReqNewMchTch,Gam_NEW_MATCH_SECTION_ID); Gam_PutParamGameCod (GamCod); Btn_PutConfirmButton (Txt_New_match); Frm_EndForm (); @@ -3212,7 +3200,7 @@ static void Gam_PutFormNewMatch (struct Game *Game) Gam_MAX_CHARS_TITLE,Game->Title); /***** Groups *****/ - Gam_ShowLstGrpsToEditMatch (); + Gam_ShowLstGrpsToCreateMatch (); /***** End table *****/ Tbl_EndTable (); @@ -3236,10 +3224,10 @@ static void Gam_PutFormNewMatch (struct Game *Game) } /*****************************************************************************/ -/********* Create a new match and show first question (by a teacher) *********/ +/********************* Create a new match (by a teacher) *********************/ /*****************************************************************************/ -void Gam_CreateNewMatchTch1 (void) +void Gam_CreateNewMatchTch (void) { long GamCod; char Title[Gam_MAX_BYTES_TITLE + 1]; @@ -3262,8 +3250,14 @@ void Gam_CreateNewMatchTch1 (void) Grp_FreeListCodSelectedGrps (); } -void Gam_CreateNewMatchTch2 (void) +/*****************************************************************************/ +/******* Show button to actually start / resume a match (by a teacher) *******/ +/*****************************************************************************/ + +void Gam_RequestStartResumeMatchTch (void) { + extern const char *Txt_Start_match; + extern const char *Txt_Resume_match; struct Match Match; /***** Get data of the match from database *****/ @@ -3277,7 +3271,15 @@ void Gam_CreateNewMatchTch2 (void) Gam_GetAndShowNumPlayersInMatch (Match.MchCod); fprintf (Gbl.F.Out,""); - Gam_ShowMatchStatusForTch (&Match); + if (Match.Status.Finished) + Gam_ShowAlertFinishedMatch (); + else // Unfinished match + /***** Put button to start / resume match *****/ + Gam_PutBigButton (ActCurMchTch, + Match.MchCod, + "play.svg", + Match.Status.QstInd == 0 ? Txt_Start_match : + Txt_Resume_match); fprintf (Gbl.F.Out,""); } @@ -3317,30 +3319,6 @@ static long Gam_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1]) return MchCod; } -/*****************************************************************************/ -/**** Resume an unfinished match and show current question (by a teacher) ****/ -/*****************************************************************************/ - -void Gam_ResumeUnfinishedMatchTch (void) - { - struct Match Match; - - /***** Get data of the match from database *****/ - Match.MchCod = Gbl.Games.MchCodBeingPlayed; - Gam_GetDataOfMatchByCod (&Match); - - /***** Show current match status *****/ - fprintf (Gbl.F.Out,"
"); - - fprintf (Gbl.F.Out,"
"); - Gam_GetAndShowNumPlayersInMatch (Match.MchCod); - fprintf (Gbl.F.Out,"
"); - - Gam_ShowMatchStatusForTch (&Match); - - fprintf (Gbl.F.Out,"
"); - } - /*****************************************************************************/ /***************** Insert/update a game match being played *******************/ /*****************************************************************************/ @@ -3368,7 +3346,63 @@ static void Gam_UpdateMatchBeingPlayed (struct Match *Match) } /*****************************************************************************/ -/*** Show next match status (show next question, answers...) (by a teacher) **/ +/** Show current match status (current question, answers...) (by a teacher) **/ +/*****************************************************************************/ + +void Gam_CurrentStatusMatchTch (void) + { + struct Match Match; + long NxtQstInd; + + /***** Get data of the match from database *****/ + Match.MchCod = Gbl.Games.MchCodBeingPlayed; + Gam_GetDataOfMatchByCod (&Match); + + /***** If not yet finished, update status *****/ + if (!Match.Status.Finished) + { + if (Match.Status.QstInd == 0) // Match has been created, but it has not started + { + /* Get index of the first question */ + NxtQstInd = Gam_GetFirstQuestionIndexInGame (Match.GamCod); + if (NxtQstInd) // Not last question + { + Match.Status.QstInd = NxtQstInd; // Go to the next question + Match.Status.QstCod = Gam_GetQstCodFromQstInd (Match.GamCod, + Match.Status.QstInd); + Match.Status.Finished = false; // Match is not finished + } + else // No more questions + { + Match.Status.QstInd = 0; // No more questions + Match.Status.QstCod = -1L; // No more questions + Match.Status.Finished = true; // Match is finished + } + Match.Status.ShowingAnswers = false; // Don't show answers + + /* Update match status in database */ + Gam_UpdateMatchBeingPlayed (&Match); + } + + /* Remove all players in this match */ + if (Match.Status.Finished) + Gam_RemoveAllPlayersInMatch (Match.MchCod); + } + + /***** Show current match status *****/ + fprintf (Gbl.F.Out,"
"); + + fprintf (Gbl.F.Out,"
"); + Gam_GetAndShowNumPlayersInMatch (Match.MchCod); + fprintf (Gbl.F.Out,"
"); + + Gam_ShowMatchStatusForTch (&Match); + + fprintf (Gbl.F.Out,"
"); + } + +/*****************************************************************************/ +/***** Show next match status (next question, answers...) (by a teacher) *****/ /*****************************************************************************/ void Gam_NextStatusMatchTch (void) @@ -3383,51 +3417,51 @@ void Gam_NextStatusMatchTch (void) /***** If not yet finished, update status *****/ if (!Match.Status.Finished) { - if (Match.Status.QstInd == 0) // Game has been created, but it has not started + if (Match.Status.QstInd == 0) // Match has been created, but it has not started { /* Get index of the first question */ NxtQstInd = Gam_GetFirstQuestionIndexInGame (Match.GamCod); if (NxtQstInd) // Not last question { - Match.Status.QstInd = NxtQstInd; // Go to the next question + Match.Status.QstInd = NxtQstInd; // Go to the next question Match.Status.QstCod = Gam_GetQstCodFromQstInd (Match.GamCod, Match.Status.QstInd); - Match.Status.Finished = false; // Game is not finished + Match.Status.Finished = false; // Match is not finished } else // No more questions { - Match.Status.QstInd = 0; // No more questions - Match.Status.QstCod = -1L; // No more questions - Match.Status.Finished = true; // Game is finished + Match.Status.QstInd = 0; // No more questions + Match.Status.QstCod = -1L; // No more questions + Match.Status.Finished = true; // Match is finished } - Match.Status.ShowingAnswers = false; // Don't show answers + Match.Status.ShowingAnswers = false; // Don't show answers } - else // Game has started + else // Match has started { - if (Match.Status.ShowingAnswers) // Showing answers currently + if (Match.Status.ShowingAnswers) // Showing answers currently { /* Get index of the next question */ NxtQstInd = Gam_GetNextQuestionIndexInGame (Match.GamCod, Match.Status.QstInd); if (NxtQstInd) // Not last question { - Match.Status.QstInd = NxtQstInd; // Go to the next question + Match.Status.QstInd = NxtQstInd; // Go to the next question Match.Status.QstCod = Gam_GetQstCodFromQstInd (Match.GamCod, Match.Status.QstInd); - Match.Status.Finished = false; // Game is not finished + Match.Status.Finished = false; // Match is not finished } else // No more questions { - Match.Status.QstInd = 0; // No more questions - Match.Status.QstCod = -1L; // No more questions - Match.Status.Finished = true; // Game is finished + Match.Status.QstInd = 0; // No more questions + Match.Status.QstCod = -1L; // No more questions + Match.Status.Finished = true; // Match is finished } Match.Status.ShowingAnswers = false; // Don't show answers } else { - Match.Status.Finished = false; // Game is not finished - Match.Status.ShowingAnswers = true; // Show answers + Match.Status.Finished = false; // Match is not finished + Match.Status.ShowingAnswers = true; // Show answers } } @@ -3486,98 +3520,95 @@ static void Gam_ShowAlertFinishedMatch (void) static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match) { - extern const char *Txt_Start_match; extern const char *Txt_Continue; extern const char *Txt_Finish; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NxtQstInd; - /***** In what question do we resume the match? *****/ - if (Match->Status.QstInd > 0) - { - /***** 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); + /***** Trivial check: Question index should be > 0 *****/ + if (Match->Status.QstInd == 0) + return; - /***** Show question *****/ - /* Write number of question */ - fprintf (Gbl.F.Out,"
%u
", - Match->Status.QstInd); + /***** 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); - fprintf (Gbl.F.Out,"
"); + /***** Show question *****/ + /* Write number of question */ + fprintf (Gbl.F.Out,"
%u
", + Match->Status.QstInd); - /* Get answer type (row[0]) */ - Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]); - // TODO: Check that answer type is correct (unique choice) + fprintf (Gbl.F.Out,"
"); - /* Write stem (row[1]) */ - Tst_WriteQstStem (row[1],"GAM_PLAY_TCH_QST"); + /* Get answer type (row[0]) */ + Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]); + // TODO: Check that answer type is correct (unique choice) - /* Get media (row[2]) */ - Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[2]); - Med_GetMediaDataByCod (&Gbl.Test.Media); + /* Write stem (row[1]) */ + Tst_WriteQstStem (row[1],"GAM_PLAY_TCH_QST"); - /* Show media */ - Med_ShowMedia (&Gbl.Test.Media, - "TEST_MED_EDIT_LIST_STEM_CONTAINER", - "TEST_MED_EDIT_LIST_STEM"); + /* Get media (row[2]) */ + Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[2]); + Med_GetMediaDataByCod (&Gbl.Test.Media); - /* Write answers? */ - if (Match->Status.ShowingAnswers) - /* Write answers */ - Tst_WriteAnswersGameResult (Match->GamCod, - Match->Status.QstInd, - Match->Status.QstCod, - "GAM_PLAY_TCH_QST",false); // Don't show result + /* Show media */ + Med_ShowMedia (&Gbl.Test.Media, + "TEST_MED_EDIT_LIST_STEM_CONTAINER", + "TEST_MED_EDIT_LIST_STEM"); - fprintf (Gbl.F.Out,"
"); - } + /* Write answers? */ + if (Match->Status.ShowingAnswers) + /* Write answers */ + Tst_WriteAnswersGameResult (Match->GamCod, + Match->Status.QstInd, + Match->Status.QstCod, + "GAM_PLAY_TCH_QST",false); // Don't show result + + fprintf (Gbl.F.Out,"
"); /***** Put button to continue *****/ - if (Match->Status.QstInd == 0) - /***** Put button to start first question *****/ - Gam_PutBigButton (Match->MchCod,Txt_Start_match,"play.svg"); - else + fprintf (Gbl.F.Out,"
"); + if (Match->Status.ShowingAnswers) { - fprintf (Gbl.F.Out,"
"); - if (Match->Status.ShowingAnswers) - { - /* Get index of the next question */ - NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, - Match->Status.QstInd); - if (NxtQstInd) // Not last question - /* Put button to show next question */ - Gam_PutBigButton (Match->MchCod,Txt_Continue,"step-forward.svg"); - else // Last question - /* Put button to finish */ - Gam_PutBigButton (Match->MchCod,Txt_Finish,"flag-checkered.svg"); - } - else - /* Put button to show answers */ - Gam_PutBigButton (Match->MchCod,Txt_Continue,"step-forward.svg"); - fprintf (Gbl.F.Out,"
"); + /* Get index of the next question */ + NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, + Match->Status.QstInd); + if (NxtQstInd) // Not last question + /* Put button to show next question */ + Gam_PutBigButton (ActNxtMchTch,Match->MchCod, + "step-forward.svg",Txt_Continue); + else // Last question + /* Put button to finish */ + Gam_PutBigButton (ActNxtMchTch,Match->MchCod, + "flag-checkered.svg",Txt_Finish); } + else + /* Put button to show answers */ + Gam_PutBigButton (ActNxtMchTch,Match->MchCod, + "step-forward.svg",Txt_Continue); + fprintf (Gbl.F.Out,"
"); } /*****************************************************************************/ /************************** Put a big button to start ************************/ /*****************************************************************************/ -static void Gam_PutBigButton (long MchCod,const char *Txt,const char *Icon) +static void Gam_PutBigButton (Act_Action_t NextAction,long MchCod, + const char *Icon,const char *Txt) { /***** Start container for button *****/ fprintf (Gbl.F.Out,"
"); /***** Start form *****/ - Frm_StartForm (ActNxtMchTch); + Frm_StartForm (NextAction); Gam_PutParamMatchCod (MchCod); /***** Put icon with link *****/ @@ -3694,10 +3725,10 @@ void Gam_ShowMatchToMeAsStd (void) } /*****************************************************************************/ -/*************** Refresh current game for a teacher via AJAX *****************/ +/************ Refresh number of players for a teacher via AJAX ***************/ /*****************************************************************************/ -void Gam_RefreshCurrentMatchTch (void) +void Gam_RefreshNumPlayersMatchTch (void) { if (!Gbl.Session.IsOpen) // If session has been closed, do not write anything return; diff --git a/swad_game.h b/swad_game.h index b57b5eb43..023a21114 100644 --- a/swad_game.h +++ b/swad_game.h @@ -121,16 +121,16 @@ void Gam_RemoveMatchTch (void); void Gam_RequestNewMatchTch (void); -void Gam_CreateNewMatchTch1 (void); -void Gam_CreateNewMatchTch2 (void); -void Gam_ResumeUnfinishedMatchTch (void); +void Gam_CreateNewMatchTch (void); +void Gam_RequestStartResumeMatchTch (void); +void Gam_CurrentStatusMatchTch (void); void Gam_NextStatusMatchTch (void); void Gam_ShowFinishedMatchResults (void); void Gam_GetMatchBeingPlayed (void); void Gam_ShowMatchToMeAsStd (void); -void Gam_RefreshCurrentMatchTch (void); +void Gam_RefreshNumPlayersMatchTch (void); void Gam_RefreshCurrentMatchStd (void); void Gam_ReceiveQstAnsFromStd (void); diff --git a/swad_text.c b/swad_text.c index a92eec13b..6191a5cc6 100644 --- a/swad_text.c +++ b/swad_text.c @@ -33109,25 +33109,25 @@ const char *Txt_results_per_page = "resultados por página"; #endif -const char *Txt_Resume = // Resume a game match +const char *Txt_Resume_match = #if L==1 // ca - "Reprendre"; + "Reprendre partida"; #elif L==2 // de - "Fortsetzen"; + "Spiel fortsetzen"; #elif L==3 // en - "Resume"; + "Resume match"; #elif L==4 // es - "Reanudar"; + "Reanudar partida"; #elif L==5 // fr - "Reprendre"; + "Reprendre le match"; #elif L==6 // gn - "Reanudar"; // Okoteve traducción + "Reanudar partida"; // Okoteve traducción #elif L==7 // it - "Riprendi"; + "Riprendi la partita"; #elif L==8 // pl - "Wznów"; + "Wznów mecz"; #elif L==9 // pt - "Retomar"; + "Retomar o jogo"; #endif const char *Txt_Retype_new_password =