diff --git a/swad_action.c b/swad_action.c index 61a2d329..fc92085d 100644 --- a/swad_action.c +++ b/swad_action.c @@ -631,14 +631,17 @@ Assessment: 478. ActAnsMchQstStd Answer a match question (as student) 479. ActRefMchStd Refresh current question when playing a game (as student) - 481. ActSeeAllMyMchRes Show all my matches results - NEW. ActSeeGamMyMchRes Show my matches results in a given game + NEW. ActSeeMyMchResCrs Show all my matches results in the current course + NEW. ActSeeMyMchResGam Show all my matches results in a given game + NEW. ActSeeMyMchResMch Show all my matches results in a given match + 484. ActSeeOneMchResMe Show one match result of me as student 482. ActReqSeeAllMchRes Select users and range of dates to see matches results - 483. ActSeeAllMchRes Show matches results of several users in a given game - NEW. ActSeeGamMchRes Show matches results of several users - 484. ActSeeOneMchResMe Show one match result of me as student + NEW. ActSeeAllMchResCrs Show all matches results of selected users in the current course + NEW. ActSeeAllMchResGam Show all matches results in a given game + NEW. ActSeeAllMchResMch Show all matches results in a given game 485. ActSeeOneMchResOth Show one match result of other user + 476. ActChgVisResMchUsr Change visibility of match results for students 487. ActFrmNewGam Form to create a new game @@ -2167,14 +2170,17 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActAnsMchQstStd ] = {1651,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ReceiveQuestionAnswer ,NULL}, [ActRefMchStd ] = {1782,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Mch_GetMatchBeingPlayed ,Mch_RefreshMatchStd ,NULL}, - [ActSeeAllMyMchRes ] = {1796,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowMyMchRes ,NULL}, - [ActSeeGamMyMchRes ] = {1810,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowMyMchResInGame ,NULL}, + [ActSeeMyMchResCrs ] = {1796,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowMyMchResultsInCrs ,NULL}, + [ActSeeMyMchResGam ] = {1810,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowMyMchResultsInGam ,NULL}, + [ActSeeMyMchResMch ] = {1812,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowMyMchResultsInMch ,NULL}, [ActSeeOneMchResMe ] = {1797,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowOneMchResult ,NULL}, - [ActReqSeeAllMchRes ] = {1798,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,McR_SelUsrsToViewUsrsMchRes ,NULL}, - [ActSeeAllMchRes ] = {1799,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_GetUsrsAndShowMchRes ,NULL}, - [ActSeeGamMchRes ] = {1811,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowUsrsMchResultsInGame ,NULL}, + [ActReqSeeAllMchRes ] = {1798,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,McR_SelUsrsToViewMchResults ,NULL}, + [ActSeeAllMchResCrs ] = {1799,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowAllMchResultsInCrs ,NULL}, + [ActSeeAllMchResGam ] = {1811,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowAllMchResultsInGam ,NULL}, + [ActSeeAllMchResMch ] = {1813,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowAllMchResultsInMch ,NULL}, [ActSeeOneMchResOth ] = {1800,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowOneMchResult ,NULL}, + [ActChgVisResMchUsr ] = {1801,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_ToggleVisibilResultsMchUsr ,NULL}, [ActFrmNewGam ] = {1652,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestCreatOrEditGame ,NULL}, @@ -5021,10 +5027,10 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un -1, // #1793 (obsolete action) ActChgVisResMchQst, // #1794 -1, // #1795 - ActSeeAllMyMchRes, // #1796 + ActSeeMyMchResCrs, // #1796 ActSeeOneMchResMe, // #1797 ActReqSeeAllMchRes, // #1798 - ActSeeAllMchRes, // #1799 + ActSeeAllMchResCrs, // #1799 ActSeeOneMchResOth, // #1800 ActChgVisResMchUsr, // #1801 ActChgNumColMch, // #1802 @@ -5035,8 +5041,10 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActShoHidSocComUsr, // #1807 ActSeeMchAnsQstStd, // #1808 ActRemMchAnsQstStd, // #1809 - ActSeeGamMyMchRes, // #1810 - ActSeeGamMchRes, // #1811 + ActSeeMyMchResGam, // #1810 + ActSeeAllMchResGam, // #1811 + ActSeeMyMchResMch, // #1812 + ActSeeAllMchResMch, // #1813 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 1e1e48c6..b30389b4 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 + 66 + 38 + 12 + 42 + 36 + 19 + 110 + 183 + 437 + 176 + 169 + 16 + 68) +#define Act_NUM_ACTIONS (1 + 4 + 66 + 38 + 12 + 42 + 36 + 19 + 110 + 185 + 437 + 176 + 169 + 16 + 68) -#define Act_MAX_ACTION_COD 1811 +#define Act_MAX_ACTION_COD 1813 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 @@ -630,58 +630,61 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActAnsMchQstStd (ActChgCrsTT1stDay + 134) #define ActRefMchStd (ActChgCrsTT1stDay + 135) -#define ActSeeAllMyMchRes (ActChgCrsTT1stDay + 136) -#define ActSeeGamMyMchRes (ActChgCrsTT1stDay + 137) -#define ActSeeOneMchResMe (ActChgCrsTT1stDay + 138) +#define ActSeeMyMchResCrs (ActChgCrsTT1stDay + 136) +#define ActSeeMyMchResGam (ActChgCrsTT1stDay + 137) +#define ActSeeMyMchResMch (ActChgCrsTT1stDay + 138) +#define ActSeeOneMchResMe (ActChgCrsTT1stDay + 139) -#define ActReqSeeAllMchRes (ActChgCrsTT1stDay + 139) -#define ActSeeAllMchRes (ActChgCrsTT1stDay + 140) -#define ActSeeGamMchRes (ActChgCrsTT1stDay + 141) -#define ActSeeOneMchResOth (ActChgCrsTT1stDay + 142) -#define ActChgVisResMchUsr (ActChgCrsTT1stDay + 143) +#define ActReqSeeAllMchRes (ActChgCrsTT1stDay + 140) +#define ActSeeAllMchResCrs (ActChgCrsTT1stDay + 141) +#define ActSeeAllMchResGam (ActChgCrsTT1stDay + 142) +#define ActSeeAllMchResMch (ActChgCrsTT1stDay + 143) +#define ActSeeOneMchResOth (ActChgCrsTT1stDay + 144) -#define ActFrmNewGam (ActChgCrsTT1stDay + 144) -#define ActEdiOneGam (ActChgCrsTT1stDay + 145) -#define ActNewGam (ActChgCrsTT1stDay + 146) -#define ActChgGam (ActChgCrsTT1stDay + 147) -#define ActReqRemGam (ActChgCrsTT1stDay + 148) -#define ActRemGam (ActChgCrsTT1stDay + 149) -#define ActHidGam (ActChgCrsTT1stDay + 150) -#define ActShoGam (ActChgCrsTT1stDay + 151) -#define ActAddOneGamQst (ActChgCrsTT1stDay + 152) -#define ActGamLstTstQst (ActChgCrsTT1stDay + 153) -#define ActAddTstQstToGam (ActChgCrsTT1stDay + 154) -#define ActReqRemGamQst (ActChgCrsTT1stDay + 155) -#define ActRemGamQst (ActChgCrsTT1stDay + 156) -#define ActUp_GamQst (ActChgCrsTT1stDay + 157) -#define ActDwnGamQst (ActChgCrsTT1stDay + 158) +#define ActChgVisResMchUsr (ActChgCrsTT1stDay + 145) -#define ActSeeSvy (ActChgCrsTT1stDay + 159) -#define ActAnsSvy (ActChgCrsTT1stDay + 160) -#define ActFrmNewSvy (ActChgCrsTT1stDay + 161) -#define ActEdiOneSvy (ActChgCrsTT1stDay + 162) -#define ActNewSvy (ActChgCrsTT1stDay + 163) -#define ActChgSvy (ActChgCrsTT1stDay + 164) -#define ActReqRemSvy (ActChgCrsTT1stDay + 165) -#define ActRemSvy (ActChgCrsTT1stDay + 166) -#define ActReqRstSvy (ActChgCrsTT1stDay + 167) -#define ActRstSvy (ActChgCrsTT1stDay + 168) -#define ActHidSvy (ActChgCrsTT1stDay + 169) -#define ActShoSvy (ActChgCrsTT1stDay + 170) -#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 171) -#define ActRcvSvyQst (ActChgCrsTT1stDay + 172) -#define ActReqRemSvyQst (ActChgCrsTT1stDay + 173) -#define ActRemSvyQst (ActChgCrsTT1stDay + 174) +#define ActFrmNewGam (ActChgCrsTT1stDay + 146) +#define ActEdiOneGam (ActChgCrsTT1stDay + 147) +#define ActNewGam (ActChgCrsTT1stDay + 148) +#define ActChgGam (ActChgCrsTT1stDay + 149) +#define ActReqRemGam (ActChgCrsTT1stDay + 150) +#define ActRemGam (ActChgCrsTT1stDay + 151) +#define ActHidGam (ActChgCrsTT1stDay + 152) +#define ActShoGam (ActChgCrsTT1stDay + 153) +#define ActAddOneGamQst (ActChgCrsTT1stDay + 154) +#define ActGamLstTstQst (ActChgCrsTT1stDay + 155) +#define ActAddTstQstToGam (ActChgCrsTT1stDay + 156) +#define ActReqRemGamQst (ActChgCrsTT1stDay + 157) +#define ActRemGamQst (ActChgCrsTT1stDay + 158) +#define ActUp_GamQst (ActChgCrsTT1stDay + 159) +#define ActDwnGamQst (ActChgCrsTT1stDay + 160) -#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 175) -#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 176) -#define ActEdiExaAnn (ActChgCrsTT1stDay + 177) -#define ActRcvExaAnn (ActChgCrsTT1stDay + 178) -#define ActPrnExaAnn (ActChgCrsTT1stDay + 179) -#define ActReqRemExaAnn (ActChgCrsTT1stDay + 180) -#define ActRemExaAnn (ActChgCrsTT1stDay + 181) -#define ActHidExaAnn (ActChgCrsTT1stDay + 182) -#define ActShoExaAnn (ActChgCrsTT1stDay + 183) +#define ActSeeSvy (ActChgCrsTT1stDay + 161) +#define ActAnsSvy (ActChgCrsTT1stDay + 162) +#define ActFrmNewSvy (ActChgCrsTT1stDay + 163) +#define ActEdiOneSvy (ActChgCrsTT1stDay + 164) +#define ActNewSvy (ActChgCrsTT1stDay + 165) +#define ActChgSvy (ActChgCrsTT1stDay + 166) +#define ActReqRemSvy (ActChgCrsTT1stDay + 167) +#define ActRemSvy (ActChgCrsTT1stDay + 168) +#define ActReqRstSvy (ActChgCrsTT1stDay + 169) +#define ActRstSvy (ActChgCrsTT1stDay + 170) +#define ActHidSvy (ActChgCrsTT1stDay + 171) +#define ActShoSvy (ActChgCrsTT1stDay + 172) +#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 173) +#define ActRcvSvyQst (ActChgCrsTT1stDay + 174) +#define ActReqRemSvyQst (ActChgCrsTT1stDay + 175) +#define ActRemSvyQst (ActChgCrsTT1stDay + 176) + +#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 177) +#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 178) +#define ActEdiExaAnn (ActChgCrsTT1stDay + 179) +#define ActRcvExaAnn (ActChgCrsTT1stDay + 180) +#define ActPrnExaAnn (ActChgCrsTT1stDay + 181) +#define ActReqRemExaAnn (ActChgCrsTT1stDay + 182) +#define ActRemExaAnn (ActChgCrsTT1stDay + 183) +#define ActHidExaAnn (ActChgCrsTT1stDay + 184) +#define ActShoExaAnn (ActChgCrsTT1stDay + 185) /*****************************************************************************/ /******************************** Files tab **********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 8aa886e0..450447fb 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -490,14 +490,15 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.87.5 (2019-12-07)" +#define Log_PLATFORM_VERSION "SWAD 19.88.1 (2019-12-08)" #define CSS_FILE "swad19.85.css" #define JS_FILE "swad19.70.js" /* // TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.) // TODO: Impedir la creación y edición de proyectos si no son editables. -// TODO: En cada partida, poder listar los resultados en una tabla como la de resultados globales + Version 19.88.1: Dec 08, 2019 Changes in layoout of matches results. (248219 lines) + Version 19.88: Dec 08, 2019 Show matches results in a match. (248151 lines) Version 19.87.5: Dec 08, 2019 Results of a game are integrated in the box of that game. (248008 lines) Version 19.87.4: Dec 08, 2019 Code refactoring in games. (247989 lines) Version 19.87.3: Dec 08, 2019 Changes in layout of matches results. (247997 lines) diff --git a/swad_game.c b/swad_game.c index 0fa03a38..291b3d8e 100644 --- a/swad_game.c +++ b/swad_game.c @@ -162,7 +162,7 @@ static void Gam_ExchangeQuestions (long GamCod, static bool Gam_GetNumMchsGameAndCheckIfEditable (struct Game *Game); -static long Gam_GetParamCurrentGamCod (void); +static long Gam_GetCurrentGamCod (void); /*****************************************************************************/ /***************************** List all games ********************************/ @@ -319,7 +319,7 @@ static void Gam_PutIconsListGames (void) switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: - Ico_PutContextualIconToShowResults (ActSeeAllMyMchRes,NULL,NULL); + Ico_PutContextualIconToShowResults (ActSeeMyMchResCrs,NULL,NULL); break; case Rol_NET: case Rol_TCH: @@ -377,14 +377,15 @@ static void Gam_PutParamsToCreateNewGame (void) void Gam_SeeOneGame (void) { - long GamCod; + struct Game Game; /***** Get parameters *****/ - if ((GamCod = Gam_GetParams ()) == -1L) + if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Show game *****/ - Gam_ShowOnlyOneGame (GamCod, + Gam_ShowOnlyOneGame (&Game, false, // Do not list game questions false); // Do not put form to start new match } @@ -393,41 +394,36 @@ void Gam_SeeOneGame (void) /******************************* Show one game *******************************/ /*****************************************************************************/ -void Gam_ShowOnlyOneGame (long GamCod, +void Gam_ShowOnlyOneGame (struct Game *Game, bool ListGameQuestions, bool PutFormNewMatch) { - Gam_ShowOnlyOneGameBegin (GamCod,ListGameQuestions,PutFormNewMatch); + Gam_ShowOnlyOneGameBegin (Game,ListGameQuestions,PutFormNewMatch); Gam_ShowOnlyOneGameEnd (); } -void Gam_ShowOnlyOneGameBegin (long GamCod, +void Gam_ShowOnlyOneGameBegin (struct Game *Game, bool ListGameQuestions, bool PutFormNewMatch) { extern const char *Hlp_ASSESSMENT_Games; extern const char *Txt_Game; - struct Game Game; - - /***** Get data of this game *****/ - Game.GamCod = GamCod; - Gam_GetDataOfGameByCod (&Game); /***** Begin box *****/ - Gam_SetParamCurrentGamCod (GamCod); + Gam_SetCurrentGamCod (Game->GamCod); Box_BoxBegin (NULL,Txt_Game,Gam_PutIconToShowResultsOfGame, Hlp_ASSESSMENT_Games,Box_NOT_CLOSABLE); /***** Show game *****/ - Gam_ShowOneGame (&Game, + Gam_ShowOneGame (Game, true); // Show only this game if (ListGameQuestions) /***** Write questions of this game *****/ - Gam_ListGameQuestions (&Game); + Gam_ListGameQuestions (Game); else /***** List matches *****/ - Mch_ListMatches (&Game,PutFormNewMatch); + Mch_ListMatches (Game,PutFormNewMatch); } void Gam_ShowOnlyOneGameEnd (void) @@ -504,7 +500,7 @@ static void Gam_ShowOneGame (struct Game *Game,bool ShowOnlyThisGame) HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); /* Game title */ - Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game->GamCod); // Used to pass parameter HTM_ARTICLE_Begin (Anchor); Frm_StartForm (ActSeeGam); Gam_PutParams (); @@ -533,7 +529,7 @@ static void Gam_ShowOneGame (struct Game *Game,bool ShowOnlyThisGame) else HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game->GamCod); // Used to pass parameter Frm_StartForm (ActSeeGam); Gam_PutParams (); HTM_BUTTON_SUBMIT_Begin (Txt_Matches, @@ -600,12 +596,12 @@ static void Gam_PutIconToShowResultsOfGame (void) switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: - Ico_PutContextualIconToShowResults (ActSeeGamMyMchRes,McR_RESULTS_TABLE_ID,Gam_PutParams); + Ico_PutContextualIconToShowResults (ActSeeMyMchResGam,McR_RESULTS_TABLE_ID,Gam_PutParams); break; case Rol_NET: case Rol_TCH: case Rol_SYS_ADM: - Ico_PutContextualIconToShowResults (ActSeeGamMchRes,McR_RESULTS_TABLE_ID,Gam_PutParams); + Ico_PutContextualIconToShowResults (ActSeeAllMchResGam,McR_RESULTS_TABLE_ID,Gam_PutParams); break; default: break; @@ -637,7 +633,7 @@ void Gam_PutHiddenParamGameOrder (void) static void Gam_PutFormsToRemEditOneGame (const struct Game *Game, const char *Anchor) { - Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game->GamCod); // Used to pass parameter /***** Put icon to remove game *****/ Ico_PutContextualIconToRemove (ActReqRemGam,Gam_PutParams); @@ -670,7 +666,7 @@ void Gam_PutParams (void) static void Gam_PutParamCurrentGamCod (void) { - long CurrentGamCod = Gam_GetParamCurrentGamCod (); + long CurrentGamCod = Gam_GetCurrentGamCod (); if (CurrentGamCod > 0) Gam_PutParamGameCod (CurrentGamCod); @@ -1065,7 +1061,7 @@ void Gam_AskRemGame (void) Lay_NoPermissionExit (); /***** Show question and button to remove game *****/ - Gam_SetParamCurrentGamCod (Game.GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game.GamCod); // Used to pass parameter Ale_ShowAlertAndButton (ActRemGam,NULL,NULL,Gam_PutParams, Btn_REMOVE_BUTTON,Txt_Remove_game, Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_game_X, @@ -1269,7 +1265,7 @@ static void Gam_PutFormsEditionGame (struct Game *Game,bool ItsANewGame) } /***** Begin form *****/ - Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game->GamCod); // Used to pass parameter Frm_StartForm (ItsANewGame ? ActNewGam : ActChgGam); Gam_PutParams (); @@ -1515,19 +1511,20 @@ void Gam_RequestNewQuestion (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) { /***** Show form to create a new question in this game *****/ - Gam_SetParamCurrentGamCod (Game.GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game.GamCod); // Used to pass parameter Tst_ShowFormAskSelectTstsForGame (); } else Lay_NoPermissionExit (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Game.GamCod, + Gam_ShowOnlyOneGame (&Game, true, // List game questions false); // Do not put form to start new match } @@ -1548,7 +1545,7 @@ void Gam_ListTstQuestionsToSelect (void) if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) { /***** List several test questions for selection *****/ - Gam_SetParamCurrentGamCod (Game.GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game.GamCod); // Used to pass parameter Tst_ListQuestionsToSelect (); } else @@ -1757,7 +1754,7 @@ static void Gam_ListGameQuestions (struct Game *Game) Game->GamCod); /***** Begin box *****/ - Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game->GamCod); // Used to pass parameter Box_BoxBegin (NULL,Txt_Questions,ICanEditQuestions ? Gam_PutIconToAddNewQuestions : NULL, Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE); @@ -1848,7 +1845,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, Gbl.Test.QstCod = Str_ConvertStrCodToLongCod (row[1]); /***** Icons *****/ - Gam_SetParamCurrentGamCod (GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (GamCod); // Used to pass parameter Gam_CurrentQstInd = QstInd; HTM_TR_Begin (NULL); @@ -1996,6 +1993,7 @@ void Gam_AddTstQuestionsToGame (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) @@ -2042,7 +2040,7 @@ void Gam_AddTstQuestionsToGame (void) Lay_NoPermissionExit (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Game.GamCod, + Gam_ShowOnlyOneGame (&Game, true, // List game questions false); // Do not put form to start new match } @@ -2121,6 +2119,7 @@ void Gam_RequestRemoveQst (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) @@ -2129,7 +2128,7 @@ void Gam_RequestRemoveQst (void) QstInd = Gam_GetParamQstInd (); /***** Show question and button to remove question *****/ - Gam_SetParamCurrentGamCod (Game.GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game.GamCod); // Used to pass parameter Gam_CurrentQstInd = QstInd; Ale_ShowAlertAndButton (ActRemGamQst,NULL,NULL,Gam_PutParamsOneQst, Btn_REMOVE_BUTTON,Txt_Remove_question, @@ -2140,7 +2139,7 @@ void Gam_RequestRemoveQst (void) Lay_NoPermissionExit (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Game.GamCod, + Gam_ShowOnlyOneGame (&Game, true, // List game questions false); // Do not put form to start new match } @@ -2158,6 +2157,7 @@ void Gam_RemoveQst (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) @@ -2197,7 +2197,7 @@ void Gam_RemoveQst (void) Lay_NoPermissionExit (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Game.GamCod, + Gam_ShowOnlyOneGame (&Game, true, // List game questions false); // Do not put form to start new match } @@ -2217,6 +2217,7 @@ void Gam_MoveUpQst (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) @@ -2245,7 +2246,7 @@ void Gam_MoveUpQst (void) Lay_NoPermissionExit (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Game.GamCod, + Gam_ShowOnlyOneGame (&Game, true, // List game questions false); // Do not put form to start new match } @@ -2267,6 +2268,7 @@ void Gam_MoveDownQst (void) /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Check if game has matches *****/ if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) @@ -2303,7 +2305,7 @@ void Gam_MoveDownQst (void) Lay_NoPermissionExit (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Game.GamCod, + Gam_ShowOnlyOneGame (&Game, true, // List game questions false); // Do not put form to start new match } @@ -2385,7 +2387,7 @@ void Gam_PutButtonNewMatch (long GamCod) { extern const char *Txt_New_match; - Gam_SetParamCurrentGamCod (GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (GamCod); // Used to pass parameter Frm_StartFormAnchor (ActReqNewMch,Mch_NEW_MATCH_SECTION_ID); Gam_PutParams (); Btn_PutConfirmButton (Txt_New_match); @@ -2398,14 +2400,15 @@ void Gam_PutButtonNewMatch (long GamCod) void Gam_RequestNewMatch (void) { - long GamCod; + struct Game Game; /***** Get parameters *****/ - if ((GamCod = Gam_GetParams ()) == -1L) + if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); /***** Show game *****/ - Gam_ShowOnlyOneGame (GamCod, + Gam_ShowOnlyOneGame (&Game, false, // Do not list game questions true); // Put form to start new match } @@ -2699,12 +2702,12 @@ void Gam_ShowTstTagsPresentInAGame (long GamCod) /**************** Access to variable used to pass parameter ******************/ /*****************************************************************************/ -void Gam_SetParamCurrentGamCod (long GamCod) +void Gam_SetCurrentGamCod (long GamCod) { Gam_CurrentGamCod = GamCod; } -static long Gam_GetParamCurrentGamCod (void) +static long Gam_GetCurrentGamCod (void) { return Gam_CurrentGamCod; } diff --git a/swad_game.h b/swad_game.h index c6b08fb6..08e101bb 100644 --- a/swad_game.h +++ b/swad_game.h @@ -81,10 +81,10 @@ typedef enum void Gam_SeeAllGames (void); void Gam_SeeOneGame (void); -void Gam_ShowOnlyOneGame (long GamCod, +void Gam_ShowOnlyOneGame (struct Game *Game, bool ListGameQuestions, bool PutFormNewMatch); -void Gam_ShowOnlyOneGameBegin (long GamCod, +void Gam_ShowOnlyOneGameBegin (struct Game *Game, bool ListGameQuestions, bool PutFormNewMatch); void Gam_ShowOnlyOneGameEnd (void); @@ -140,7 +140,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope); void Gam_ShowTstTagsPresentInAGame (long GamCod); -void Gam_SetParamCurrentGamCod (long GamCod); +void Gam_SetCurrentGamCod (long GamCod); void Gam_GetScoreRange (long GamCod,double *MinScore,double *MaxScore); diff --git a/swad_match.c b/swad_match.c index 21f98a56..220d778a 100644 --- a/swad_match.c +++ b/swad_match.c @@ -213,7 +213,7 @@ static unsigned Mch_GetNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsi static unsigned Mch_GetNumUsrsWhoHaveAnswerMch (long MchCod); static void Mch_DrawBarNumUsrs (unsigned NumAnswerersAns,unsigned NumAnswerersQst,bool Correct); -static long Mch_GetParamCurrentMchCod (void); +static long Mch_GetCurrentMchCod (void); /*****************************************************************************/ /************************* List the matches of a game ************************/ @@ -271,7 +271,7 @@ void Mch_ListMatches (struct Game *Game,bool PutFormNewMatch) free (SubQuery); /***** Begin box *****/ - Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter + Gam_SetCurrentGamCod (Game->GamCod); // Used to pass parameter Box_BoxBegin ("100%",Txt_Matches,Mch_PutIconsInListOfMatches, Hlp_ASSESSMENT_Games_matches,Box_NOT_CLOSABLE); @@ -534,8 +534,8 @@ static void Mch_ListOneOrMoreMatchesIcons (const struct Match *Match) /***** Put icon to remove the match *****/ if (Mch_CheckIfICanEditThisMatch (Match)) { - Gam_SetParamCurrentGamCod (Match->GamCod); // Used to pass parameter - Mch_SetParamCurrentMchCod (Match->MchCod); // Used to pass parameter + Gam_SetCurrentGamCod (Match->GamCod); // Used to pass parameter + Mch_SetCurrentMchCod (Match->MchCod); // Used to pass parameter Frm_StartForm (ActReqRemMch); Mch_PutParamsEdit (); Ico_PutIconRemove (); @@ -599,7 +599,7 @@ static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Match *Match) HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); /***** Match title *****/ - Mch_SetParamCurrentMchCod (Match->MchCod); // Used to pass parameter + Mch_SetCurrentMchCod (Match->MchCod); // Used to pass parameter Frm_StartForm (Gbl.Usrs.Me.Role.Logged == Rol_STD ? ActJoiMch : ActResMch); Mch_PutParamsPlay (); @@ -712,7 +712,7 @@ static void Mch_ListOneOrMoreMatchesStatus (const struct Match *Match,unsigned N } /* Icon to join match or resume match */ - Mch_SetParamCurrentMchCod (Match->MchCod); // Used to pass parameter + Mch_SetCurrentMchCod (Match->MchCod); // Used to pass parameter Lay_PutContextualLinkOnlyIcon (Gbl.Usrs.Me.Role.Logged == Rol_STD ? ActJoiMch : ActResMch, NULL, @@ -753,49 +753,57 @@ static void Mch_ListOneOrMoreMatchesResult (const struct Match *Match) static void Mch_ListOneOrMoreMatchesResultStd (const struct Match *Match) { - extern const char *Txt_Match_result; - extern const char *Txt_Hidden_result; + extern const char *Txt_Hidden_results; + extern const char *Txt_Results; /***** Is match result visible or hidden? *****/ if (Match->Status.ShowUsrResults) { /* Result is visible by me */ - Gam_SetParamCurrentGamCod (Match->GamCod); // Used to pass parameter - Mch_SetParamCurrentMchCod (Match->MchCod); // Used to pass parameter - Frm_StartForm (ActSeeOneMchResMe); - Mch_PutParamsEdit (); - Ico_PutIconLink ("tasks.svg",Txt_Match_result); - Frm_EndForm (); + Gam_SetCurrentGamCod (Match->GamCod); // Used to pass parameter + Mch_SetCurrentMchCod (Match->MchCod); // Used to pass parameter + Lay_PutContextualLinkOnlyIcon (ActSeeMyMchResMch,McR_RESULTS_TABLE_ID, + Mch_PutParamsEdit, + "trophy.svg", + Txt_Results); } else /* Result is forbidden to me */ - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results); } static void Mch_ListOneOrMoreMatchesResultTch (const struct Match *Match) { - extern const char *Txt_Hidden_result; - extern const char *Txt_Visible_result; + extern const char *Txt_Visible_results; + extern const char *Txt_Hidden_results; + extern const char *Txt_Results; /***** Can I edit match vivibility? *****/ if (Mch_CheckIfICanEditThisMatch (Match)) { + Gam_SetCurrentGamCod (Match->GamCod); // Used to pass parameter + Mch_SetCurrentMchCod (Match->MchCod); // Used to pass parameter + + /* Show match results */ + Lay_PutContextualLinkOnlyIcon (ActSeeAllMchResMch,McR_RESULTS_TABLE_ID, + Mch_PutParamsEdit, + "trophy.svg", + Txt_Results); + /* I can edit visibility */ - Gam_SetParamCurrentGamCod (Match->GamCod); // Used to pass parameter - Mch_SetParamCurrentMchCod (Match->MchCod); // Used to pass parameter Lay_PutContextualLinkOnlyIcon (ActChgVisResMchUsr,NULL, Mch_PutParamsEdit, Match->Status.ShowUsrResults ? "eye.svg" : "eye-slash.svg", - Match->Status.ShowUsrResults ? Txt_Visible_result : - Txt_Hidden_result); + Match->Status.ShowUsrResults ? Txt_Visible_results : + Txt_Hidden_results); } else /* I can not edit visibility */ Ico_PutIconOff (Match->Status.ShowUsrResults ? "eye.svg" : "eye-slash.svg", - Match->Status.ShowUsrResults ? Txt_Visible_result : - Txt_Hidden_result); + Match->Status.ShowUsrResults ? Txt_Visible_results : + Txt_Hidden_results); } /*****************************************************************************/ @@ -825,7 +833,7 @@ void Mch_ToggleVisibilResultsMchUsr (void) Match.MchCod); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Match.GamCod, + Gam_ShowOnlyOneGame (&Game, false, // Do not list game questions false); // Do not put form to start new match } @@ -945,15 +953,15 @@ void Mch_RequestRemoveMatch (void) Mch_GetAndCheckParameters (&Game,&Match); /***** Show question and button to remove question *****/ - Gam_SetParamCurrentGamCod (Match.GamCod); // Used to pass parameter - Mch_SetParamCurrentMchCod (Match.MchCod); // Used to pass parameter + Gam_SetCurrentGamCod (Match.GamCod); // Used to pass parameter + Mch_SetCurrentMchCod (Match.MchCod); // Used to pass parameter Ale_ShowAlertAndButton (ActRemMch,NULL,NULL,Mch_PutParamsEdit, Btn_REMOVE_BUTTON,Txt_Remove_match, Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_match_X, Match.Title); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Match.GamCod, + Gam_ShowOnlyOneGame (&Game, false, // Do not list game questions false); // Do not put form to start new match } @@ -983,7 +991,7 @@ void Mch_RemoveMatch (void) Match.Title); /***** Show current game *****/ - Gam_ShowOnlyOneGame (Match.GamCod, + Gam_ShowOnlyOneGame (&Game, false, // Do not list game questions false); // Do not put form to start new match } @@ -1140,7 +1148,7 @@ void Mch_PutParamsEdit (void) static void Mch_PutParamsPlay (void) { - long CurrentMchCod = Mch_GetParamCurrentMchCod (); + long CurrentMchCod = Mch_GetCurrentMchCod (); if (CurrentMchCod > 0) Mch_PutParamMchCod (CurrentMchCod); @@ -3549,12 +3557,12 @@ static void Mch_DrawBarNumUsrs (unsigned NumAnswerersAns,unsigned NumAnswerersQs /**************** Access to variable used to pass parameter ******************/ /*****************************************************************************/ -void Mch_SetParamCurrentMchCod (long MchCod) +void Mch_SetCurrentMchCod (long MchCod) { Mch_CurrentMchCod = MchCod; } -static long Mch_GetParamCurrentMchCod (void) +static long Mch_GetCurrentMchCod (void) { return Mch_CurrentMchCod; } diff --git a/swad_match.h b/swad_match.h index 8bc0d629..a3a5f754 100644 --- a/swad_match.h +++ b/swad_match.h @@ -127,6 +127,6 @@ void Mch_GetAndDrawBarNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsig unsigned NumAnswerersQst,bool Correct); unsigned Mch_GetNumUsrsWhoHaveAnswerQst (long MchCod,unsigned QstInd); -void Mch_SetParamCurrentMchCod (long MchCod); +void Mch_SetCurrentMchCod (long MchCod); #endif diff --git a/swad_match_result.c b/swad_match_result.c index b84055d3..7b6dd157 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -69,13 +69,25 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void McR_ShowUsrsMchResults (void); +static void McR_ListMyMchResultsInCrs (void); +static void McR_ListMyMchResultsInGam (long GamCod); +static void McR_ListMyMchResultsInMch (long MchCod); +static void McR_ShowAllMchResultsInSelectedGames (void); +static void McR_ListAllMchResultsInSelectedGames (void); +static void McR_ListAllMchResultsInGam (long GamCod); +static void McR_ListAllMchResultsInMch (long MchCod); + +static void McR_ShowResultsBegin (const char *Title,bool ListGamesToSelect); +static void McR_ShowResultsEnd (void); + static void McR_ListGamesToSelect (void); static void McR_ShowHeaderMchResults (Usr_MeOrOther_t MeOrOther); static void McR_BuildGamesSelectedCommas (char **GamesSelectedCommas); static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, - const char *GamesSelectedSeparatedByCommas); + long MchCod, // <= 0 ==> any + long GamCod, // <= 0 ==> any + const char *GamesSelectedCommas); static void McR_ShowMchResultsSummaryRow (unsigned NumResults, unsigned NumTotalQsts, unsigned NumTotalQstsNotBlank, @@ -94,7 +106,7 @@ static bool McR_GetVisibilityMchResultFromDB (long MchCod); /*********** Select users and dates to show their matches results ************/ /*****************************************************************************/ -void McR_SelUsrsToViewUsrsMchRes (void) +void McR_SelUsrsToViewMchResults (void) { extern const char *Hlp_ASSESSMENT_Games_results; extern const char *The_ClassFormInBox[The_NUM_THEMES]; @@ -138,7 +150,7 @@ void McR_SelUsrsToViewUsrsMchRes (void) Usr_ShowFormsToSelectUsrListType (NULL); /***** Begin form *****/ - Frm_StartForm (ActSeeAllMchRes); + Frm_StartForm (ActSeeAllMchResCrs); Grp_PutParamsCodGrps (); /***** Put list of users to select some of them *****/ @@ -194,137 +206,167 @@ void McR_SelUsrsToViewUsrsMchRes (void) /*************************** Show my matches results *************************/ /*****************************************************************************/ -void McR_ShowMyMchRes (void) +void McR_ShowMyMchResultsInCrs (void) { - extern const char *Hlp_ASSESSMENT_Games_results; - extern const char *Hlp_ASSESSMENT_Games_results; extern const char *Txt_Results; - char *GamesSelectedCommas = NULL; // Initialized to avoid warning /***** Get list of games *****/ Gam_GetListGames (Gam_ORDER_BY_TITLE); Gam_GetListSelectedGamCods (); - McR_BuildGamesSelectedCommas (&GamesSelectedCommas); - /***** Begin box *****/ - Box_BoxBegin ("100%",Txt_Results,NULL, - Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); - - /***** List games to select *****/ - McR_ListGamesToSelect (); - - /***** Start section with match results table *****/ - HTM_SECTION_Begin (McR_RESULTS_TABLE_ID); - HTM_TABLE_BeginWidePadding (2); - McR_ShowHeaderMchResults (Usr_ME); - - /***** List my matches results *****/ - Tst_GetConfigTstFromDB (); // Get feedback type - McR_ShowMchResults (Usr_ME,GamesSelectedCommas); - - /***** End section with match results table *****/ - HTM_TABLE_End (); - HTM_SECTION_End (); - - /***** End box *****/ - Box_BoxEnd (); + /***** List my matches results in the current course *****/ + McR_ShowResultsBegin (Txt_Results,true); // List games to select + McR_ListMyMchResultsInCrs (); + McR_ShowResultsEnd (); /***** Free list of games *****/ - free (GamesSelectedCommas); free (Gbl.Games.GamCodsSelected); Gam_FreeListGames (); } +static void McR_ListMyMchResultsInCrs (void) + { + char *GamesSelectedCommas = NULL; // Initialized to avoid warning + + /***** Table header *****/ + McR_ShowHeaderMchResults (Usr_ME); + + /***** List my matches results in the current course *****/ + Tst_GetConfigTstFromDB (); // Get feedback type + McR_BuildGamesSelectedCommas (&GamesSelectedCommas); + McR_ShowMchResults (Usr_ME,-1L,-1L,GamesSelectedCommas); + free (GamesSelectedCommas); + } + /*****************************************************************************/ /***************** Show my matches results in a given game *******************/ /*****************************************************************************/ -void McR_ShowMyMchResInGame (void) +void McR_ShowMyMchResultsInGam (void) { - extern const char *Hlp_ASSESSMENT_Games_results; - extern const char *Hlp_ASSESSMENT_Games_results; - extern const char *Txt_Results; + extern const char *Txt_Results_of_game_X; struct Game Game; - char *GamesSelectedCommas; /***** Get parameters *****/ if ((Game.GamCod = Gam_GetParams ()) == -1L) Lay_ShowErrorAndExit ("Code of game is missing."); - if (asprintf (&GamesSelectedCommas,"%ld",Game.GamCod) < 0) - Lay_NotEnoughMemoryExit (); + Gam_GetDataOfGameByCod (&Game); /***** Game begin *****/ - Gam_ShowOnlyOneGameBegin (Game.GamCod, + Gam_ShowOnlyOneGameBegin (&Game, false, // Do not list game questions false); // Do not put form to start new match - /***** Begin box *****/ - Box_BoxBegin ("100%",Txt_Results,NULL, - Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); - - /***** Start section with match results table *****/ - HTM_SECTION_Begin (McR_RESULTS_TABLE_ID); - HTM_TABLE_BeginWidePadding (2); - McR_ShowHeaderMchResults (Usr_ME); - - /***** List my matches results *****/ - Tst_GetConfigTstFromDB (); // Get feedback type - McR_ShowMchResults (Usr_ME,GamesSelectedCommas); - - /***** End section with match results table *****/ - HTM_TABLE_End (); - HTM_SECTION_End (); - - /***** End box *****/ - Box_BoxEnd (); + /***** List my matches results in game *****/ + snprintf (Gbl.Title,sizeof (Gbl.Title), + Txt_Results_of_game_X, + Game.Title); + McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ListMyMchResultsInGam (Game.GamCod); + McR_ShowResultsEnd (); /***** Game end *****/ Gam_ShowOnlyOneGameEnd (); + } - /***** Free string with list of selected games separated by commas *****/ - free (GamesSelectedCommas); +static void McR_ListMyMchResultsInGam (long GamCod) + { + /***** Table header *****/ + McR_ShowHeaderMchResults (Usr_ME); + + /***** List my matches results in game *****/ + Tst_GetConfigTstFromDB (); // Get feedback type + McR_ShowMchResults (Usr_ME,-1L,GamCod,NULL); + } + +/*****************************************************************************/ +/***************** Show my matches results in a given match ******************/ +/*****************************************************************************/ + +void McR_ShowMyMchResultsInMch (void) + { + extern const char *Txt_Results_of_match_X; + struct Game Game; + struct Match Match; + + /***** Get parameters *****/ + if ((Game.GamCod = Gam_GetParams ()) == -1L) + Lay_ShowErrorAndExit ("Code of game is missing."); + if ((Match.MchCod = Mch_GetParamMchCod ()) == -1L) + Lay_ShowErrorAndExit ("Code of match is missing."); + Gam_GetDataOfGameByCod (&Game); + Mch_GetDataOfMatchByCod (&Match); + + /***** Game begin *****/ + Gam_ShowOnlyOneGameBegin (&Game, + false, // Do not list game questions + false); // Do not put form to start new match + + /***** List my matches results in match *****/ + snprintf (Gbl.Title,sizeof (Gbl.Title), + Txt_Results_of_match_X, + Match.Title); + McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ListMyMchResultsInMch (Match.MchCod); + McR_ShowResultsEnd (); + + /***** Game end *****/ + Gam_ShowOnlyOneGameEnd (); + } + +static void McR_ListMyMchResultsInMch (long MchCod) + { + /***** Table header *****/ + McR_ShowHeaderMchResults (Usr_ME); + + /***** List my matches results in game *****/ + Tst_GetConfigTstFromDB (); // Get feedback type + McR_ShowMchResults (Usr_ME,MchCod,-1L,NULL); } /*****************************************************************************/ /****************** Get users and show their matches results *****************/ /*****************************************************************************/ -void McR_GetUsrsAndShowMchRes (void) +void McR_ShowAllMchResultsInCrs (void) { Usr_GetSelectedUsrsAndGoToAct (&Gbl.Usrs.Selected, - McR_ShowUsrsMchResults, - McR_SelUsrsToViewUsrsMchRes); + McR_ShowAllMchResultsInSelectedGames, + McR_SelUsrsToViewMchResults); } /*****************************************************************************/ /****************** Show matches results for several users *******************/ /*****************************************************************************/ -static void McR_ShowUsrsMchResults (void) +static void McR_ShowAllMchResultsInSelectedGames (void) { - extern const char *Hlp_ASSESSMENT_Games_results; extern const char *Txt_Results; - char *GamesSelectedCommas = NULL; // Initialized to avoid warning - const char *Ptr; /***** Get list of games *****/ Gam_GetListGames (Gam_ORDER_BY_TITLE); Gam_GetListSelectedGamCods (); - McR_BuildGamesSelectedCommas (&GamesSelectedCommas); - /***** Begin box *****/ - Box_BoxBegin ("100%",Txt_Results,NULL, - Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); + /***** List the matches results of the selected users *****/ + McR_ShowResultsBegin (Txt_Results,true); // List games to select + McR_ListAllMchResultsInSelectedGames (); + McR_ShowResultsEnd (); - /***** List games to select *****/ - McR_ListGamesToSelect (); + /***** Free list of games *****/ + free (Gbl.Games.GamCodsSelected); + Gam_FreeListGames (); + } - /***** Start section with match results table *****/ - HTM_SECTION_Begin (McR_RESULTS_TABLE_ID); - HTM_TABLE_BeginWidePadding (2); +static void McR_ListAllMchResultsInSelectedGames (void) + { + char *GamesSelectedCommas = NULL; // Initialized to avoid warning + const char *Ptr; + + /***** Table head *****/ McR_ShowHeaderMchResults (Usr_OTHER); /***** List the matches results of the selected users *****/ + McR_BuildGamesSelectedCommas (&GamesSelectedCommas); Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; while (*Ptr) { @@ -336,68 +378,67 @@ static void McR_ShowUsrsMchResults (void) { /***** Show matches results *****/ Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); - McR_ShowMchResults (Usr_OTHER,GamesSelectedCommas); + McR_ShowMchResults (Usr_OTHER,-1L,-1L,GamesSelectedCommas); } } - - /***** End section with match results table *****/ - HTM_TABLE_End (); - HTM_SECTION_End (); - - /***** End box *****/ - Box_BoxEnd (); - - /***** Free list of games *****/ free (GamesSelectedCommas); - free (Gbl.Games.GamCodsSelected); - Gam_FreeListGames (); } /*****************************************************************************/ -/** Show matches results of a game for the users who answered in that game ***/ +/*** Show matches results of a game for the users who answered in that game **/ /*****************************************************************************/ -void McR_ShowUsrsMchResultsInGame (void) +void McR_ShowAllMchResultsInGam (void) { - extern const char *Hlp_ASSESSMENT_Games_results; - extern const char *Txt_Results; + extern const char *Txt_Results_of_game_X; struct Game Game; - char *GamesSelectedCommas; + + /***** Get parameters *****/ + if ((Game.GamCod = Gam_GetParams ()) == -1L) + Lay_ShowErrorAndExit ("Code of game is missing."); + Gam_GetDataOfGameByCod (&Game); + + /***** Game begin *****/ + Gam_ShowOnlyOneGameBegin (&Game, + false, // Do not list game questions + false); // Do not put form to start new match + + /***** List matches results in game *****/ + snprintf (Gbl.Title,sizeof (Gbl.Title), + Txt_Results_of_game_X, + Game.Title); + McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ListAllMchResultsInGam (Game.GamCod); + McR_ShowResultsEnd (); + + /***** Game end *****/ + Gam_ShowOnlyOneGameEnd (); + } + +static void McR_ListAllMchResultsInGam (long GamCod) + { MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumUsrs; unsigned long NumUsr; - /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams ()) == -1L) - Lay_ShowErrorAndExit ("Code of game is missing."); - if (asprintf (&GamesSelectedCommas,"%ld",Game.GamCod) < 0) - Lay_NotEnoughMemoryExit (); + /***** Table head *****/ + McR_ShowHeaderMchResults (Usr_OTHER); - /***** Game begin *****/ - Gam_ShowOnlyOneGameBegin (Game.GamCod, - false, // Do not list game questions - false); // Do not put form to start new match - - /***** Begin box *****/ - Box_BoxBegin ("100%",Txt_Results,NULL, - Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); - - /***** Make database query *****/ + /***** Get all users who have answered any match question in this game *****/ NumUsrs = DB_QuerySELECT (&mysql_res,"can not get matches results of a user", - "SELECT DISTINCT mch_answers.UsrCod" // row[0] - " FROM mch_matches,mch_answers" + "SELECT mch_results.UsrCod" // row[0] + " FROM mch_results,mch_matches,gam_games" " WHERE mch_matches.GamCod=%ld" - " AND mch_matches.MchCod=mch_answers.MchCod" - " ORDER BY mch_answers.UsrCod", // TODO: Order by name - Game.GamCod); + " AND mch_matches.MchCod=mch_results.MchCod" + " AND mch_matches.GamCod=gam_games.GamCod" + " AND gam_games.CrsCod=%ld" // Extra check + " ORDER BY mch_results.UsrCod", // TODO: Order by name + GamCod, + Gbl.Hierarchy.Crs.CrsCod); if (NumUsrs) { - /***** Start section with match results table *****/ - HTM_SECTION_Begin (McR_RESULTS_TABLE_ID); - HTM_TABLE_BeginWidePadding (2); - McR_ShowHeaderMchResults (Usr_OTHER); - + /***** List matches results for each user *****/ for (NumUsr = 0; NumUsr < NumUsrs; NumUsr++) @@ -411,26 +452,125 @@ void McR_ShowUsrsMchResultsInGame (void) { /***** Show matches results *****/ Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); - McR_ShowMchResults (Usr_OTHER,GamesSelectedCommas); + McR_ShowMchResults (Usr_OTHER,-1L,GamCod,NULL); } } - - /***** End section with match results table *****/ - HTM_TABLE_End (); - HTM_SECTION_End (); } /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); + } - /***** End box *****/ - Box_BoxEnd (); +/*****************************************************************************/ +/** Show matches results of a match for the users who answered in that match */ +/*****************************************************************************/ + +void McR_ShowAllMchResultsInMch (void) + { + extern const char *Txt_Results_of_match_X; + struct Game Game; + struct Match Match; + + /***** Get parameters *****/ + if ((Game.GamCod = Gam_GetParams ()) == -1L) + Lay_ShowErrorAndExit ("Code of game is missing."); + if ((Match.MchCod = Mch_GetParamMchCod ()) == -1L) + Lay_ShowErrorAndExit ("Code of match is missing."); + Gam_GetDataOfGameByCod (&Game); + Mch_GetDataOfMatchByCod (&Match); + + /***** Game begin *****/ + Gam_ShowOnlyOneGameBegin (&Game, + false, // Do not list game questions + false); // Do not put form to start new match + + /***** List matches results in match *****/ + snprintf (Gbl.Title,sizeof (Gbl.Title), + Txt_Results_of_match_X, + Match.Title); + McR_ShowResultsBegin (Gbl.Title,false); // Do not list games to select + McR_ListAllMchResultsInMch (Match.MchCod); + McR_ShowResultsEnd (); /***** Game end *****/ Gam_ShowOnlyOneGameEnd (); + } - /***** Free string with list of selected games separated by commas *****/ - free (GamesSelectedCommas); +static void McR_ListAllMchResultsInMch (long MchCod) + { + MYSQL_RES *mysql_res; + MYSQL_ROW row; + unsigned long NumUsrs; + unsigned long NumUsr; + + /***** Table head *****/ + McR_ShowHeaderMchResults (Usr_OTHER); + + /***** Get all users who have answered any match question in this game *****/ + NumUsrs = DB_QuerySELECT (&mysql_res,"can not get matches results of a user", + "SELECT mch_results.UsrCod" // row[0] + " FROM mch_results,mch_matches,gam_games" + " WHERE mch_results.MchCod=%ld" + " AND mch_results.MchCod=mch_matches.MchCod" + " AND mch_matches.GamCod=gam_games.GamCod" + " AND gam_games.CrsCod=%ld" // Extra check + " ORDER BY mch_results.UsrCod", // TODO: Order by name + MchCod, + Gbl.Hierarchy.Crs.CrsCod); + if (NumUsrs) + { + /***** List matches results for each user *****/ + for (NumUsr = 0; + NumUsr < NumUsrs; + NumUsr++) + { + row = mysql_fetch_row (mysql_res); + + /* Get match code (row[0]) */ + if ((Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0])) > 0) + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) + if (Usr_CheckIfICanViewMch (&Gbl.Usrs.Other.UsrDat)) + { + /***** Show matches results *****/ + Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); + McR_ShowMchResults (Usr_OTHER,MchCod,-1L,NULL); + } + } + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + +/*****************************************************************************/ +/************************ Show results (begin / end) *************************/ +/*****************************************************************************/ + +static void McR_ShowResultsBegin (const char *Title,bool ListGamesToSelect) + { + extern const char *Hlp_ASSESSMENT_Games_results; + + /***** Begin box *****/ + Box_BoxBegin ("100%",Title,NULL, + Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE); + + /***** List games to select *****/ + if (ListGamesToSelect) + McR_ListGamesToSelect (); + + /***** Start section with match results table *****/ + HTM_SECTION_Begin (McR_RESULTS_TABLE_ID); + HTM_TABLE_BeginWidePadding (2); + } + +static void McR_ShowResultsEnd (void) + { + /***** End section with match results table *****/ + HTM_TABLE_End (); + HTM_SECTION_End (); + + /***** End box *****/ + Box_BoxEnd (); } /*****************************************************************************/ @@ -589,10 +729,14 @@ static void McR_BuildGamesSelectedCommas (char **GamesSelectedCommas) /*****************************************************************************/ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, + long MchCod, // <= 0 ==> any + long GamCod, // <= 0 ==> any const char *GamesSelectedCommas) { extern const char *Txt_Match_result; - extern const char *Txt_Hidden_result; + extern const char *Txt_Hidden_results; + char *MchSubQuery; + char *GamSubQuery; MYSQL_RES *mysql_res; MYSQL_ROW row; struct UsrData *UsrDat; @@ -615,16 +759,39 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, double TotalGrade = 0.0; time_t TimeUTC[Dat_NUM_START_END_TIME]; - /***** Trivial check: there should be games selected *****/ - if (!GamesSelectedCommas) - return; - if (!GamesSelectedCommas[0]) - return; - /***** Set user *****/ UsrDat = (MeOrOther == Usr_ME) ? &Gbl.Usrs.Me.UsrDat : &Gbl.Usrs.Other.UsrDat; + /***** Build matches subquery *****/ + if (MchCod > 0) + { + if (asprintf (&MchSubQuery," AND mch_results.MchCod=%ld",MchCod) < 0) + Lay_NotEnoughMemoryExit (); + } + else + { + if (asprintf (&MchSubQuery,"%s","") < 0) + Lay_NotEnoughMemoryExit (); + } + + /***** Build games subquery *****/ + if (GamCod > 0) + { + if (asprintf (&GamSubQuery," AND mch_matches.GamCod=%ld",GamCod) < 0) + Lay_NotEnoughMemoryExit (); + } + else if (GamesSelectedCommas) + { + if (asprintf (&GamSubQuery," AND mch_matches.GamCod IN (%s)",GamesSelectedCommas) < 0) + Lay_NotEnoughMemoryExit (); + } + else + { + if (asprintf (&GamSubQuery,"%s","") < 0) + Lay_NotEnoughMemoryExit (); + } + /***** Make database query *****/ NumResults = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches results of a user", @@ -637,14 +804,18 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, "gam_games.MaxGrade" // row[6] " FROM mch_results,mch_matches,gam_games" " WHERE mch_results.UsrCod=%ld" + "%s" // Match subquery " AND mch_results.MchCod=mch_matches.MchCod" + "%s" // Games subquery " AND mch_matches.GamCod=gam_games.GamCod" " AND gam_games.CrsCod=%ld" // Extra check - " AND gam_games.GamCod IN (%s)" " ORDER BY mch_matches.Title", UsrDat->UsrCod, - Gbl.Hierarchy.Crs.CrsCod, - GamesSelectedCommas); + MchSubQuery, + GamSubQuery, + Gbl.Hierarchy.Crs.CrsCod); + free (GamSubQuery); + free (MchSubQuery); /***** Show user's data *****/ HTM_TR_Begin (NULL); @@ -725,7 +896,7 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, if (ShowResultThisMatch) HTM_Unsigned (NumQstsInThisResult); else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results); HTM_TD_End (); /* Write number of questions not blank */ @@ -733,7 +904,7 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, if (ShowResultThisMatch) HTM_Unsigned (NumQstsNotBlankInThisResult); else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results); HTM_TD_End (); /* Write score */ @@ -741,7 +912,7 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, if (ShowResultThisMatch) HTM_Double (ScoreInThisResult); else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results); HTM_TD_End (); /* Write average score per question */ @@ -751,7 +922,7 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, (double) NumQstsInThisResult : 0.0); else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results); HTM_TD_End (); /* Write grade over maximum grade */ @@ -763,15 +934,15 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, TotalGrade += Grade; } else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results); HTM_TD_End (); /* Link to show this result */ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); if (ShowResultThisMatch) { - Gam_SetParamCurrentGamCod (Match.GamCod); // Used to pass parameter - Mch_SetParamCurrentMchCod (Match.MchCod); // Used to pass parameter + Gam_SetCurrentGamCod (Match.GamCod); // Used to pass parameter + Mch_SetCurrentMchCod (Match.MchCod); // Used to pass parameter switch (MeOrOther) { case Usr_ME: @@ -788,7 +959,7 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, Frm_EndForm (); } else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results); HTM_TD_End (); HTM_TR_End (); @@ -876,7 +1047,6 @@ static void McR_ShowMchResultsSummaryRow (unsigned NumResults, void McR_ShowOneMchResult (void) { extern const char *Hlp_ASSESSMENT_Games_results; - extern const char *Txt_Match_result; extern const char *Txt_The_user_does_not_exist; extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME]; diff --git a/swad_match_result.h b/swad_match_result.h index 9dce8bcb..3a84f7a9 100644 --- a/swad_match_result.h +++ b/swad_match_result.h @@ -37,12 +37,15 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void McR_SelUsrsToViewUsrsMchRes (void); +void McR_SelUsrsToViewMchResults (void); -void McR_ShowMyMchRes (void); -void McR_ShowMyMchResInGame (void); -void McR_GetUsrsAndShowMchRes (void); -void McR_ShowUsrsMchResultsInGame (void); +void McR_ShowMyMchResultsInCrs (void); +void McR_ShowMyMchResultsInGam (void); +void McR_ShowMyMchResultsInMch (void); + +void McR_ShowAllMchResultsInCrs (void); +void McR_ShowAllMchResultsInGam (void); +void McR_ShowAllMchResultsInMch (void); void McR_ShowOneMchResult (void); void McR_GetMatchResultQuestionsFromDB (long MchCod,long UsrCod, diff --git a/swad_text.c b/swad_text.c index 7092438b..dcb8dd4a 100644 --- a/swad_text.c +++ b/swad_text.c @@ -14519,25 +14519,25 @@ const char *Txt_hidden_documents = "documentos ocultos"; #endif -const char *Txt_Hidden_result = +const char *Txt_Hidden_results = #if L==1 // ca - "Resultat ocult"; + "Resultats ocults"; #elif L==2 // de - "Ausgeblendet Ergebnis"; + "Ausgeblendet Ergebnisse"; #elif L==3 // en - "Hidden result"; + "Hidden results"; #elif L==4 // es - "Resultado oculto"; + "Resultados ocultos"; #elif L==5 // fr - "Résultat caché"; + "Résultats cachés"; #elif L==6 // gn - "Resultado oculto"; // Okoteve traducción + "Resultados ocultos"; // Okoteve traducción #elif L==7 // it - "Risultato nascosto"; + "Risultati nascosti"; #elif L==8 // pl - "Ukryte wynik"; + "Ukryte wyników"; #elif L==9 // pt - "Resultado oculto"; + "Resultados ocultos"; #endif const char *Txt_Hidden_survey = @@ -33360,6 +33360,48 @@ const char *Txt_Results = "Resultados"; #endif +const char *Txt_Results_of_game_X = // Warning: it is very important to include %s in the following sentences +#if L==1 // ca + "Resultats del joc %s"; +#elif L==2 // de + "Ergebnisse von Spiel %s"; +#elif L==3 // en + "Results of game %s"; +#elif L==4 // es + "Resultados del juego %s"; +#elif L==5 // fr + "Résultats du jeu %s"; +#elif L==6 // gn + "Resultados del juego %s"; // Okoteve traducción +#elif L==7 // it + "Risultati del gioco %s"; +#elif L==8 // pl + "Wyniki gry %s"; +#elif L==9 // pt + "Resultados do jogo %s"; +#endif + +const char *Txt_Results_of_match_X = // Warning: it is very important to include %s in the following sentences +#if L==1 // ca + "Resultats de la partida %s"; +#elif L==2 // de + "Ergebnisse von Spiel %s"; +#elif L==3 // en + "Results of match %s"; +#elif L==4 // es + "Resultados de la partida %s"; +#elif L==5 // fr + "Résultats du match %s"; +#elif L==6 // gn + "Resultados de la partida %s"; // Okoteve traducción +#elif L==7 // it + "Risultati della partita %s"; +#elif L==8 // pl + "Wyniki mecz %s"; +#elif L==9 // pt + "Resultados do jogo %s"; +#endif + const char *Txt_results_per_page = #if L==1 // ca "resultats per pàgina"; @@ -52989,25 +53031,25 @@ const char *Txt_Visible_by_BR_the_student = "Visível pelo
estudante?"; #endif -const char *Txt_Visible_result = +const char *Txt_Visible_results = #if L==1 // ca - "Resultat visible"; + "Resultats visibles"; #elif L==2 // de - "Sichtbare Ergebnis"; + "Sichtbar Ergebnisse"; #elif L==3 // en - "Visible result"; + "Visible results"; #elif L==4 // es - "Resultado visible"; + "Resultados visibles"; #elif L==5 // fr - "Résultat visible"; + "Résultats visible"; #elif L==6 // gn - "Resultado visible"; // Okoteve traducción + "Resultados visibles"; // Okoteve traducción #elif L==7 // it - "Risultato visibile"; + "Risultati visibili"; #elif L==8 // pl - "Widoczny wynik"; + "Widoczne wyników"; #elif L==9 // pt - "Resultado visível"; + "Resultados visíveis"; #endif const char *Txt_Visible_MALE_PLURAL =