From d7fa488e471c39950e79388bdd2ce1de548b6255 Mon Sep 17 00:00:00 2001 From: acanas Date: Sat, 1 Oct 2022 13:19:05 +0200 Subject: [PATCH] Version 22.37: Oct 01, 2022 Code refactoring and changes in layout of games. --- swad_API.c | 1 - swad_changelog.h | 3 +- swad_exam.c | 25 +-- swad_exam_type.h | 1 - swad_game.c | 448 +++++++++++++++++++++----------------------- swad_game.h | 44 +++-- swad_match.c | 65 +++---- swad_match.h | 2 - swad_match_result.c | 91 +++++---- swad_text_action.c | 76 ++++---- 10 files changed, 344 insertions(+), 412 deletions(-) diff --git a/swad_API.c b/swad_API.c index dc20e545..a960966c 100644 --- a/swad_API.c +++ b/swad_API.c @@ -4463,7 +4463,6 @@ int swad__answerMatchQuestion (struct soap *soap, struct swad__answerMatchQuestionOutput *answerMatchQuestionOut) // output { int ReturnCode; - // unsigned NumOpt; struct Gam_Game Game; struct Mch_Match Match; unsigned QstInd; // 0 means that the game has not started. First question has index 1. diff --git a/swad_changelog.h b/swad_changelog.h index 647143c6..d87e232b 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate TODO: Attach pdf files in multimedia. */ -#define Log_PLATFORM_VERSION "SWAD 22.36.1 (2022-09-30)" +#define Log_PLATFORM_VERSION "SWAD 22.37 (2022-10-01)" #define CSS_FILE "swad22.35.css" #define JS_FILE "swad21.100.js" /* + Version 22.37: Oct 01, 2022 Code refactoring and changes in layout of games. (? lines) Version 22.36.1: Sep 30, 2022 Changes in layout of exams. (332596 lines) Version 22.36: Sep 30, 2022 Code refactoring in exams. (332589 lines) Version 22.35: Sep 30, 2022 Changes in layout of projects. (332690 lines) diff --git a/swad_exam.c b/swad_exam.c index d9dbdfef..81a8a348 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -628,28 +628,9 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,bool ShowOnlyThisExam) static void Exa_PutIconsOneExam (void *Exams) { char *Anchor; - /* - static const Act_Action_t NextAction[Rol_NUM_ROLES] = - { - [Rol_STD ] = ActSeeMyExaResExa, - [Rol_NET ] = ActSeeUsrExaResExa, - [Rol_TCH ] = ActSeeUsrExaResExa, - [Rol_SYS_ADM] = ActSeeUsrExaResExa, - }; - */ if (Exams) { - /***** Put icon to view results of sessions in exam *****/ - // if (NextAction[Gbl.Usrs.Me.Role.Logged]) - // Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],ExaRes_RESULTS_BOX_ID, - // Exa_PutParams,Exams); - - /***** Link to get resource link *****/ - // if (PrgRsc_CheckIfICanGetLink ()) - // Ico_PutContextualIconToGetLink (ActReqLnkExa,NULL, - // Exa_PutParams,Exams); - /***** Build anchor string *****/ Frm_SetAnchorStr (((struct Exa_Exams *) Exams)->Exam.ExaCod,&Anchor); @@ -691,7 +672,7 @@ static void Exa_PutIconsToRemEditOneExam (struct Exa_Exams *Exams, [false] = ActHidExa, // Visible ==> action to hide [true ] = ActUnhExa, // Hidden ==> action to unhide }; - static const Act_Action_t NextAction[Rol_NUM_ROLES] = + static const Act_Action_t ActionShowResults[Rol_NUM_ROLES] = { [Rol_STD ] = ActSeeMyExaResExa, [Rol_NET ] = ActSeeUsrExaResExa, @@ -713,8 +694,8 @@ static void Exa_PutIconsToRemEditOneExam (struct Exa_Exams *Exams, Exa_PutParams,Exams); /***** Put icon to view results of sessions in exam *****/ - if (NextAction[Gbl.Usrs.Me.Role.Logged]) - Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],ExaRes_RESULTS_BOX_ID, + if (ActionShowResults[Gbl.Usrs.Me.Role.Logged]) + Ico_PutContextualIconToShowResults (ActionShowResults[Gbl.Usrs.Me.Role.Logged],ExaRes_RESULTS_BOX_ID, Exa_PutParams,Exams); /***** Link to get resource link *****/ diff --git a/swad_exam_type.h b/swad_exam_type.h index f51165ff..bf55b41c 100644 --- a/swad_exam_type.h +++ b/swad_exam_type.h @@ -93,7 +93,6 @@ struct Exa_Exams char *ListQuestions; char *ExaCodsSelected; // String with selected exam codes separated by separator multiple struct Exa_Exam Exam; // Selected/current exam - // long ExaCod; // Selected/current exam code long SetCod; // Selected/current set code long SesCod; // Selected/current session code unsigned SetInd; // Current set index diff --git a/swad_game.c b/swad_game.c index 5e7f8774..4ef28b52 100644 --- a/swad_game.c +++ b/swad_game.c @@ -113,16 +113,15 @@ static void Gam_PutIconToCreateNewGame (struct Gam_Games *Games); static void Gam_PutButtonToCreateNewGame (struct Gam_Games *Games); static void Gam_PutParamsToCreateNewGame (void *Games); -static void Gam_ShowOneGame (struct Gam_Games *Games, - struct Gam_Game *Game,bool ShowOnlyThisGame); +static void Gam_ShowGameMainData (struct Gam_Games *Games, + bool ShowOnlyThisGame); static void Gam_PutIconsOneGame (void *Games); static void Gam_WriteAuthor (struct Gam_Game *Game); static void Gam_PutHiddenParamGameOrder (Gam_Order_t SelectedOrder); -static void Gam_PutFormsToRemEditOneGame (struct Gam_Games *Games, - const struct Gam_Game *Game, +static void Gam_PutIconsToRemEditOneGame (struct Gam_Games *Games, const char *Anchor); static void Gam_PutParamsOneQst (void *Games); @@ -132,7 +131,6 @@ static Gam_Order_t Gam_GetParamOrder (void); static void Gam_RemoveGameFromAllTables (long GamCod); static void Gam_PutFormsEditionGame (struct Gam_Games *Games, - struct Gam_Game *Game, char Txt[Cns_MAX_BYTES_TEXT + 1], bool ItsANewGame); static void Gam_ReceiveGameFieldsFromForm (struct Gam_Game *Game, @@ -142,7 +140,7 @@ static bool Gam_CheckGameFieldsReceivedFromForm (const struct Gam_Game *Game); static void Gam_CreateGame (struct Gam_Game *Game,const char *Txt); static void Gam_UpdateGame (struct Gam_Game *Game,const char *Txt); -static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game); +static void Gam_ListGameQuestions (struct Gam_Games *Games); static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, long GamCod,unsigned NumQsts, MYSQL_RES *mysql_res, @@ -173,7 +171,7 @@ void Gam_ResetGames (struct Gam_Games *Games) Games->CurrentPage = 0; Games->ListQuestions = NULL; Games->GamCodsSelected = NULL; // String with selected game codes separated by separator multiple - Games->GamCod = -1L; // Current/selected game code + Games->Game.GamCod = -1L; // Current/selected game code Games->MchCod.Current = Games->MchCod.Selected = -1L; // Current/selected match code Games->QstInd = 0; // Current question index @@ -233,10 +231,9 @@ void Gam_ListAllGames (struct Gam_Games *Games) Gam_Order_t Order; struct Pagination Pagination; unsigned NumGame; - struct Gam_Game Game; /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games->Game); /***** Get number of groups in current course *****/ if (!Gbl.Crs.Grps.NumGrps) @@ -307,13 +304,12 @@ void Gam_ListAllGames (struct Gam_Games *Games) NumGame++) { /* Get data of this game */ - Game.GamCod = Games->Lst[NumGame - 1].GamCod; - Gam_GetDataOfGameByCod (&Game); + Games->Game.GamCod = Games->Lst[NumGame - 1].GamCod; + Gam_GetDataOfGameByCod (&Games->Game); - /* Show game */ - Gam_ShowOneGame (Games, - &Game, - false); // Do not show only this game + /* Show a pair of rows with the main data of this game */ + Gam_ShowGameMainData (Games, + false); // Do not show only this game } /***** End table *****/ @@ -369,7 +365,7 @@ static bool Gam_CheckIfICanListGameQuestions (void) } /*****************************************************************************/ -/***************** Put contextual icons in list of games *******************/ +/****************** Put contextual icons in list of games ********************/ /*****************************************************************************/ static void Gam_PutIconsListGames (void *Games) @@ -404,7 +400,7 @@ static void Gam_PutIconsListGames (void *Games) } /*****************************************************************************/ -/********************** Put icon to create a new game **********************/ +/*********************** Put icon to create a new game ***********************/ /*****************************************************************************/ static void Gam_PutIconToCreateNewGame (struct Gam_Games *Games) @@ -414,7 +410,7 @@ static void Gam_PutIconToCreateNewGame (struct Gam_Games *Games) } /*****************************************************************************/ -/********************* Put button to create a new game *********************/ +/********************* Put button to create a new game ***********************/ /*****************************************************************************/ static void Gam_PutButtonToCreateNewGame (struct Gam_Games *Games) @@ -430,7 +426,7 @@ static void Gam_PutButtonToCreateNewGame (struct Gam_Games *Games) } /*****************************************************************************/ -/******************* Put parameters to create a new game *******************/ +/******************** Put parameters to create a new game ********************/ /*****************************************************************************/ static void Gam_PutParamsToCreateNewGame (void *Games) @@ -443,27 +439,26 @@ static void Gam_PutParamsToCreateNewGame (void *Games) } /*****************************************************************************/ -/****************************** Show one game ******************************/ +/******************************* Show one game *******************************/ /*****************************************************************************/ void Gam_SeeOneGame (void) { struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Show game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions false); // Do not put form to start new match } @@ -473,16 +468,14 @@ void Gam_SeeOneGame (void) /*****************************************************************************/ void Gam_ShowOnlyOneGame (struct Gam_Games *Games, - struct Gam_Game *Game, bool ListGameQuestions, bool PutFormNewMatch) { - Gam_ShowOnlyOneGameBegin (Games,Game,ListGameQuestions,PutFormNewMatch); + Gam_ShowOnlyOneGameBegin (Games,ListGameQuestions,PutFormNewMatch); Gam_ShowOnlyOneGameEnd (); } void Gam_ShowOnlyOneGameBegin (struct Gam_Games *Games, - struct Gam_Game *Game, bool ListGameQuestions, bool PutFormNewMatch) { @@ -490,22 +483,20 @@ void Gam_ShowOnlyOneGameBegin (struct Gam_Games *Games, extern const char *Txt_Game; /***** Begin box *****/ - Games->GamCod = Game->GamCod; Box_BoxBegin (NULL,Txt_Game, Gam_PutIconsOneGame,Games, Hlp_ASSESSMENT_Games,Box_NOT_CLOSABLE); - /***** Show game *****/ - Gam_ShowOneGame (Games, - Game, - true); // Show only this game + /***** Show main data of this game *****/ + Gam_ShowGameMainData (Games, + true); // Show only this game if (ListGameQuestions) - /***** Write questions of this game *****/ - Gam_ListGameQuestions (Games,Game); + /***** Write questions of this game *****/ + Gam_ListGameQuestions (Games); else /***** List matches *****/ - Mch_ListMatches (Games,Game,PutFormNewMatch); + Mch_ListMatches (Games,PutFormNewMatch); } void Gam_ShowOnlyOneGameEnd (void) @@ -514,8 +505,12 @@ void Gam_ShowOnlyOneGameEnd (void) Box_BoxEnd (); } -static void Gam_ShowOneGame (struct Gam_Games *Games, - struct Gam_Game *Game,bool ShowOnlyThisGame) +/*****************************************************************************/ +/********** Show a pair of rows with the main data of a given game ***********/ +/*****************************************************************************/ + +static void Gam_ShowGameMainData (struct Gam_Games *Games, + bool ShowOnlyThisGame) { extern const char *Txt_View_game; extern const char *Txt_Number_of_questions; @@ -528,11 +523,9 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, Dat_StartEndTime_t StartEndTime; const char *Color; char Txt[Cns_MAX_BYTES_TEXT + 1]; - bool ICanEditGames = Gam_CheckIfICanEditGames (); - bool ICanListQuestions = Gam_CheckIfICanListGameQuestions (); /***** Set anchor string *****/ - Frm_SetAnchorStr (Game->GamCod,&Anchor); + Frm_SetAnchorStr (Games->Game.GamCod,&Anchor); /***** Begin box and table *****/ if (ShowOnlyThisGame) @@ -542,27 +535,15 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, HTM_TR_Begin (NULL); /***** Icons related to this game *****/ - if (ICanEditGames || - ICanListQuestions) - { - Games->GamCod = Game->GamCod; - - if (ShowOnlyThisGame) - HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL\""); - else + if (!ShowOnlyThisGame) + if (Gam_CheckIfICanEditGames () || + Gam_CheckIfICanListGameQuestions ()) + { HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL %s\"", The_GetColorRows ()); - - if (ICanEditGames) - /* Icons to remove/edit this game */ - Gam_PutFormsToRemEditOneGame (Games,Game,Anchor); - else - /* Put icon to view game listing its questions */ - Ico_PutContextualIconToView (ActLstOneGam,NULL, - Gam_PutParams,Games); - - HTM_TD_End (); - } + Gam_PutIconsToRemEditOneGame (Games,Anchor); + HTM_TD_End (); + } /***** Start/end date/time *****/ UniqueId++; @@ -572,18 +553,18 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, { if (asprintf (&Id,"gam_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) Err_NotEnoughMemoryExit (); - Color = Game->NumUnfinishedMchs ? (Game->Hidden ? "DATE_GREEN_LIGHT": - "DATE_GREEN") : - (Game->Hidden ? "DATE_RED_LIGHT": - "DATE_RED"); + Color = Games->Game.NumUnfinishedMchs ? (Games->Game.Hidden ? "DATE_GREEN_LIGHT": + "DATE_GREEN") : + (Games->Game.Hidden ? "DATE_RED_LIGHT": + "DATE_RED"); if (ShowOnlyThisGame) HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"", Id,Color,The_GetSuffix ()); else HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"", Id,Color,The_GetSuffix (),The_GetColorRows ()); - if (Game->TimeUTC[Dat_STR_TIME]) - Dat_WriteLocalDateHMSFromUTC (Id,Game->TimeUTC[StartEndTime], + if (Games->Game.TimeUTC[Dat_STR_TIME]) + Dat_WriteLocalDateHMSFromUTC (Id,Games->Game.TimeUTC[StartEndTime], Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, true,true,true,0x7); HTM_TD_End (); @@ -597,32 +578,31 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, HTM_TD_Begin ("class=\"LT %s\"",The_GetColorRows ()); /* Game title */ - Games->GamCod = Game->GamCod; HTM_ARTICLE_Begin (Anchor); Frm_BeginForm (ActSeeGam); Gam_PutParams (Games); HTM_BUTTON_Submit_Begin (Txt_View_game,"class=\"LT BT_LINK %s_%s\"", - Game->Hidden ? "ASG_TITLE_LIGHT": - "ASG_TITLE", + Games->Game.Hidden ? "ASG_TITLE_LIGHT": + "ASG_TITLE", The_GetSuffix ()); - HTM_Txt (Game->Title); + HTM_Txt (Games->Game.Title); HTM_BUTTON_End (); Frm_EndForm (); HTM_ARTICLE_End (); /* Number of questions, maximum grade, visibility of results */ HTM_DIV_Begin ("class=\"%s_%s\"", - Game->Hidden ? "ASG_GRP_LIGHT" : + Games->Game.Hidden ? "ASG_GRP_LIGHT" : "ASG_GRP", The_GetSuffix ()); HTM_TxtColonNBSP (Txt_Number_of_questions); - HTM_Unsigned (Game->NumQsts); + HTM_Unsigned (Games->Game.NumQsts); HTM_BR (); HTM_TxtColonNBSP (Txt_Maximum_grade); - HTM_Double (Game->MaxGrade); + HTM_Double (Games->Game.MaxGrade); HTM_BR (); HTM_TxtColonNBSP (Txt_Result_visibility); - TstVis_ShowVisibilityIcons (Game->Visibility,Game->Hidden); + TstVis_ShowVisibilityIcons (Games->Game.Visibility,Games->Game.Hidden); HTM_DIV_End (); /***** Number of matches in game *****/ @@ -631,16 +611,15 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, else HTM_TD_Begin ("class=\"RT %s\"",The_GetColorRows ()); - Games->GamCod = Game->GamCod; Frm_BeginForm (ActSeeGam); Gam_PutParams (Games); HTM_BUTTON_Submit_Begin (Txt_Matches,"class=\"LT BT_LINK %s_%s\"", - Game->Hidden ? "ASG_TITLE_LIGHT": - "ASG_TITLE", + Games->Game.Hidden ? "ASG_TITLE_LIGHT": + "ASG_TITLE", The_GetSuffix ()); if (ShowOnlyThisGame) HTM_TxtColonNBSP (Txt_Matches); - HTM_Unsigned (Game->NumMchs); + HTM_Unsigned (Games->Game.NumMchs); HTM_BUTTON_End (); Frm_EndForm (); @@ -658,7 +637,7 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, else HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"", The_GetColorRows ()); - Gam_WriteAuthor (Game); + Gam_WriteAuthor (&Games->Game); HTM_TD_End (); /***** Text of the game *****/ @@ -667,13 +646,13 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, else HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"", The_GetColorRows ()); - Gam_DB_GetGameTxt (Game->GamCod,Txt); + Gam_DB_GetGameTxt (Games->Game.GamCod,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links HTM_DIV_Begin ("class=\"PAR %s_%s\"", - Game->Hidden ? "DAT_LIGHT" : - "DAT", + Games->Game.Hidden ? "DAT_LIGHT" : + "DAT", The_GetSuffix ()); HTM_Txt (Txt); HTM_DIV_End (); @@ -693,30 +672,23 @@ static void Gam_ShowOneGame (struct Gam_Games *Games, } /*****************************************************************************/ -/************* Put icon to show results of matches in a game *****************/ +/******************** Put icons to remove/edit one game **********************/ /*****************************************************************************/ static void Gam_PutIconsOneGame (void *Games) { - static const Act_Action_t NextAction[Rol_NUM_ROLES] = - { - [Rol_STD ] = ActSeeMyMchResGam, - [Rol_NET ] = ActSeeUsrMchResGam, - [Rol_TCH ] = ActSeeUsrMchResGam, - [Rol_SYS_ADM] = ActSeeUsrMchResGam, - }; + char *Anchor = NULL; if (Games) { - /***** Put icon to view matches results *****/ - if (NextAction[Gbl.Usrs.Me.Role.Logged]) - Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],MchRes_RESULTS_BOX_ID, - Gam_PutParams,Games); + /***** Set anchor string *****/ + Frm_SetAnchorStr (((struct Gam_Games *) Games)->Game.GamCod,&Anchor); - /***** Link to get resource link *****/ - if (PrgRsc_CheckIfICanGetLink ()) - Ico_PutContextualIconToGetLink (ActReqLnkGam,NULL, - Gam_PutParams,Games); + /***** Icons to remove/edit this game *****/ + Gam_PutIconsToRemEditOneGame (Games,Anchor); + + /***** Free anchor string *****/ + Frm_FreeAnchorStr (Anchor); } } @@ -739,11 +711,10 @@ static void Gam_PutHiddenParamGameOrder (Gam_Order_t SelectedOrder) } /*****************************************************************************/ -/******************** Put a link (form) to edit one game *********************/ +/******************** Put icons to remove/edit one game **********************/ /*****************************************************************************/ -static void Gam_PutFormsToRemEditOneGame (struct Gam_Games *Games, - const struct Gam_Game *Game, +static void Gam_PutIconsToRemEditOneGame (struct Gam_Games *Games, const char *Anchor) { static Act_Action_t ActionHideUnhide[2] = @@ -751,19 +722,45 @@ static void Gam_PutFormsToRemEditOneGame (struct Gam_Games *Games, [false] = ActHidGam, // Visible ==> action to hide [true ] = ActUnhGam, // Hidden ==> action to unhide }; + static const Act_Action_t ActionShowResults[Rol_NUM_ROLES] = + { + [Rol_STD ] = ActSeeMyMchResGam, + [Rol_NET ] = ActSeeUsrMchResGam, + [Rol_TCH ] = ActSeeUsrMchResGam, + [Rol_SYS_ADM] = ActSeeUsrMchResGam, + }; - /***** Icon to remove game *****/ - Ico_PutContextualIconToRemove (ActReqRemGam,NULL, - Gam_PutParams,Games); + if (Gam_CheckIfICanEditGames ()) + { + /***** Icon to remove game *****/ + Ico_PutContextualIconToRemove (ActReqRemGam,NULL, + Gam_PutParams,Games); - /***** Icon to unhide/hide game *****/ - Ico_PutContextualIconToHideUnhide (ActionHideUnhide,Anchor, - Gam_PutParams,Games, - Game->Hidden); + /***** Icon to unhide/hide game *****/ + Ico_PutContextualIconToHideUnhide (ActionHideUnhide,Anchor, + Gam_PutParams,Games, + Games->Game.Hidden); + + /***** Icon to edit game *****/ + Ico_PutContextualIconToEdit (ActEdiOneGam,NULL, + Gam_PutParams,Games); + } + + if (Gam_CheckIfICanListGameQuestions ()) + /***** Icon to view game listing its questions *****/ + Ico_PutContextualIconToView (ActLstOneGam,NULL, + Gam_PutParams,Games); + + /***** Put icon to view matches results *****/ + if (ActionShowResults[Gbl.Usrs.Me.Role.Logged]) + Ico_PutContextualIconToShowResults (ActionShowResults[Gbl.Usrs.Me.Role.Logged],MchRes_RESULTS_BOX_ID, + Gam_PutParams,Games); + + /***** Link to get resource link *****/ + if (PrgRsc_CheckIfICanGetLink ()) + Ico_PutContextualIconToGetLink (ActReqLnkGam,NULL, + Gam_PutParams,Games); - /***** Icon to edit game *****/ - Ico_PutContextualIconToEdit (ActEdiOneGam,NULL, - Gam_PutParams,Games); } /*****************************************************************************/ @@ -789,8 +786,8 @@ void Gam_PutParams (void *Games) if (Games) { - if (((struct Gam_Games *) Games)->GamCod > 0) - Gam_PutParamGameCod (((struct Gam_Games *) Games)->GamCod); + if (((struct Gam_Games *) Games)->Game.GamCod > 0) + Gam_PutParamGameCod (((struct Gam_Games *) Games)->Game.GamCod); Gam_PutHiddenParamOrder (((struct Gam_Games *) Games)->SelectedOrder); WhichGroups = Grp_GetParamWhichGroups (); Grp_PutParamWhichGroups (&WhichGroups); @@ -1065,30 +1062,28 @@ void Gam_AskRemGame (void) extern const char *Txt_Do_you_really_want_to_remove_the_game_X; extern const char *Txt_Remove_game; struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); /***** Get data of the game from database *****/ - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); if (!Gam_CheckIfICanEditGames ()) Err_NoPermissionExit (); /***** Show question and button to remove game *****/ - Games.GamCod = Game.GamCod; Ale_ShowAlertAndButton (ActRemGam,NULL,NULL, Gam_PutParams,&Games, Btn_REMOVE_BUTTON,Txt_Remove_game, Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_game_X, - Game.Title); + Games.Game.Title); /***** Show games again *****/ Gam_ListAllGames (&Games); @@ -1102,29 +1097,28 @@ void Gam_RemoveGame (void) { extern const char *Txt_Game_X_removed; struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get game code *****/ - if ((Game.GamCod = Gam_GetParamGameCod ()) <= 0) + if ((Games.Game.GamCod = Gam_GetParamGameCod ()) <= 0) Err_WrongGameExit (); /***** Get data of the game from database *****/ - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); if (!Gam_CheckIfICanEditGames ()) Err_NoPermissionExit (); /***** Remove game from all tables *****/ - Gam_RemoveGameFromAllTables (Game.GamCod); + Gam_RemoveGameFromAllTables (Games.Game.GamCod); /***** Write message to show the change made *****/ Ale_ShowAlert (Ale_SUCCESS,Txt_Game_X_removed, - Game.Title); + Games.Game.Title); /***** Show games again *****/ Gam_ListAllGames (&Games); @@ -1169,25 +1163,24 @@ void Gam_RemoveCrsGames (long CrsCod) void Gam_HideGame (void) { struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); /***** Get data of the game from database *****/ - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); if (!Gam_CheckIfICanEditGames ()) Err_NoPermissionExit (); /***** Hide game *****/ - Gam_DB_HideOrUnhideGame (Game.GamCod,true); + Gam_DB_HideOrUnhideGame (Games.Game.GamCod,true); /***** Show games again *****/ Gam_ListAllGames (&Games); @@ -1200,25 +1193,24 @@ void Gam_HideGame (void) void Gam_UnhideGame (void) { struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); /***** Get data of the game from database *****/ - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); if (!Gam_CheckIfICanEditGames ()) Err_NoPermissionExit (); /***** Unhide game *****/ - Gam_DB_HideOrUnhideGame (Game.GamCod,false); + Gam_DB_HideOrUnhideGame (Games.Game.GamCod,false); /***** Show games again *****/ Gam_ListAllGames (&Games); @@ -1231,29 +1223,28 @@ void Gam_UnhideGame (void) void Gam_ListGame (void) { struct Gam_Games Games; - struct Gam_Game Game; char Txt[Cns_MAX_BYTES_TEXT + 1]; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Check if I can list game questions *****/ if (!Gam_CheckIfICanListGameQuestions ()) Err_NoPermissionExit (); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); /***** Get game data *****/ - Gam_GetDataOfGameByCod (&Game); - Gam_DB_GetGameTxt (Game.GamCod,Txt); + Gam_GetDataOfGameByCod (&Games.Game); + Gam_DB_GetGameTxt (Games.Game.GamCod,Txt); /***** Show game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, true, // List game questions false); // Do not put form to start new match } @@ -1265,7 +1256,6 @@ void Gam_ListGame (void) void Gam_RequestCreatOrEditGame (void) { struct Gam_Games Games; - struct Gam_Game Game; bool ItsANewGame; char Txt[Cns_MAX_BYTES_TEXT + 1]; @@ -1273,31 +1263,31 @@ void Gam_RequestCreatOrEditGame (void) Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Check if I can edit games *****/ if (!Gam_CheckIfICanEditGames ()) Err_NoPermissionExit (); /***** Get parameters *****/ - ItsANewGame = ((Game.GamCod = Gam_GetParams (&Games)) <= 0); + ItsANewGame = ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0); /***** Get game data *****/ if (ItsANewGame) { /* Initialize to empty game */ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Txt[0] = '\0'; } else { /* Get game data from database */ - Gam_GetDataOfGameByCod (&Game); - Gam_DB_GetGameTxt (Game.GamCod,Txt); + Gam_GetDataOfGameByCod (&Games.Game); + Gam_DB_GetGameTxt (Games.Game.GamCod,Txt); } /***** Put forms to create/edit a game *****/ - Gam_PutFormsEditionGame (&Games,&Game,Txt,ItsANewGame); + Gam_PutFormsEditionGame (&Games,Txt,ItsANewGame); /***** Show games or questions *****/ if (ItsANewGame) @@ -1305,7 +1295,7 @@ void Gam_RequestCreatOrEditGame (void) Gam_ListAllGames (&Games); else /* Show questions of the game ready to be edited */ - Gam_ListGameQuestions (&Games,&Game); + Gam_ListGameQuestions (&Games); } /*****************************************************************************/ @@ -1313,7 +1303,6 @@ void Gam_RequestCreatOrEditGame (void) /*****************************************************************************/ static void Gam_PutFormsEditionGame (struct Gam_Games *Games, - struct Gam_Game *Game, char Txt[Cns_MAX_BYTES_TEXT + 1], bool ItsANewGame) { @@ -1329,7 +1318,6 @@ static void Gam_PutFormsEditionGame (struct Gam_Games *Games, extern const char *Txt_Save_changes; /***** Begin form *****/ - Games->GamCod = Game->GamCod; Frm_BeginForm (ItsANewGame ? ActNewGam : ActChgGam); Gam_PutParams (Games); @@ -1341,8 +1329,8 @@ static void Gam_PutFormsEditionGame (struct Gam_Games *Games, Hlp_ASSESSMENT_Games_new_game,Box_NOT_CLOSABLE,2); else Box_BoxTableBegin (NULL, - Game->Title[0] ? Game->Title : - Txt_Edit_game, + Games->Game.Title[0] ? Games->Game.Title : + Txt_Edit_game, NULL,NULL, Hlp_ASSESSMENT_Games_edit_game,Box_NOT_CLOSABLE,2); @@ -1354,7 +1342,7 @@ static void Gam_PutFormsEditionGame (struct Gam_Games *Games, /* Data */ HTM_TD_Begin ("class=\"LT\""); - HTM_INPUT_TEXT ("Title",Gam_MAX_CHARS_TITLE,Game->Title, + HTM_INPUT_TEXT ("Title",Gam_MAX_CHARS_TITLE,Games->Game.Title, HTM_DONT_SUBMIT_ON_CHANGE, "id=\"Title\"" " class=\"TITLE_DESCRIPTION_WIDTH INPUT_%s\"" @@ -1372,7 +1360,7 @@ static void Gam_PutFormsEditionGame (struct Gam_Games *Games, HTM_TD_End (); HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_FLOAT ("MaxGrade",0.0,DBL_MAX,0.01,Game->MaxGrade,false, + HTM_INPUT_FLOAT ("MaxGrade",0.0,DBL_MAX,0.01,Games->Game.MaxGrade,false, " class=\"INPUT_%s\" required=\"required\"", The_GetSuffix ()); HTM_TD_End (); @@ -1387,7 +1375,7 @@ static void Gam_PutFormsEditionGame (struct Gam_Games *Games, HTM_TD_End (); HTM_TD_Begin ("class=\"LB\""); - TstVis_PutVisibilityCheckboxes (Game->Visibility); + TstVis_PutVisibilityCheckboxes (Games->Game.Visibility); HTM_TD_End (); HTM_TR_End (); @@ -1426,7 +1414,6 @@ static void Gam_PutFormsEditionGame (struct Gam_Games *Games, void Gam_ReceiveFormGame (void) { struct Gam_Games Games; - struct Gam_Game Game; bool ItsANewGame; char Txt[Cns_MAX_BYTES_TEXT + 1]; @@ -1434,38 +1421,38 @@ void Gam_ReceiveFormGame (void) Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Check if I can edit games *****/ if (!Gam_CheckIfICanEditGames ()) Err_NoPermissionExit (); /***** Get parameters *****/ - ItsANewGame = ((Game.GamCod = Gam_GetParams (&Games)) <= 0); + ItsANewGame = ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0); /***** If I can edit games ==> receive game from form *****/ if (Gam_CheckIfICanEditGames ()) { - Gam_ReceiveGameFieldsFromForm (&Game,Txt); - if (Gam_CheckGameFieldsReceivedFromForm (&Game)) + Gam_ReceiveGameFieldsFromForm (&Games.Game,Txt); + if (Gam_CheckGameFieldsReceivedFromForm (&Games.Game)) { /***** Create a new game or update an existing one *****/ if (ItsANewGame) - Gam_CreateGame (&Game,Txt); // Add new game to database + Gam_CreateGame (&Games.Game,Txt); // Add new game to database else - Gam_UpdateGame (&Game,Txt); // Update game data in database + Gam_UpdateGame (&Games.Game,Txt); // Update game data in database /***** Put forms to edit the game created or updated *****/ - Gam_PutFormsEditionGame (&Games,&Game,Txt, + Gam_PutFormsEditionGame (&Games,Txt, false); // No new game /***** Show questions of the game ready to be edited ******/ - Gam_ListGameQuestions (&Games,&Game); + Gam_ListGameQuestions (&Games); } else { /***** Put forms to create/edit the game *****/ - Gam_PutFormsEditionGame (&Games,&Game,Txt,ItsANewGame); + Gam_PutFormsEditionGame (&Games,Txt,ItsANewGame); /***** Show games or questions *****/ if (ItsANewGame) @@ -1473,7 +1460,7 @@ void Gam_ReceiveFormGame (void) Gam_ListAllGames (&Games); else /* Show questions of the game ready to be edited */ - Gam_ListGameQuestions (&Games,&Game); + Gam_ListGameQuestions (&Games); } } else @@ -1565,29 +1552,27 @@ static void Gam_UpdateGame (struct Gam_Game *Game,const char *Txt) void Gam_ReqSelectQstsToAddToGame (void) { struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Check if game has matches *****/ - if (!Gam_CheckIfEditable (&Game)) + if (!Gam_CheckIfEditable (&Games.Game)) Err_NoPermissionExit (); /***** Show form to create a new question in this game *****/ - Games.GamCod = Game.GamCod; Qst_RequestSelectQstsForGame (&Games); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, true, // List game questions false); // Do not put form to start new match } @@ -1599,25 +1584,23 @@ void Gam_ReqSelectQstsToAddToGame (void) void Gam_ListQstsToAddToGame (void) { struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Check if game has matches *****/ - if (!Gam_CheckIfEditable (&Game)) + if (!Gam_CheckIfEditable (&Games.Game)) Err_NoPermissionExit (); /***** List several test questions for selection *****/ - Games.GamCod = Game.GamCod; Qst_ListQuestionsToSelectForGame (&Games); } @@ -1648,19 +1631,18 @@ unsigned Gam_GetParamQstInd (void) /************************ List the questions of a game ***********************/ /*****************************************************************************/ -static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game) +static void Gam_ListGameQuestions (struct Gam_Games *Games) { extern const char *Hlp_ASSESSMENT_Games_questions; extern const char *Txt_Questions; MYSQL_RES *mysql_res; unsigned NumQsts; - bool ICanEditQuestions = Gam_CheckIfEditable (Game); + bool ICanEditQuestions = Gam_CheckIfEditable (&Games->Game); /***** Get data of questions from database *****/ - NumQsts = Gam_DB_GetGameQuestionsBasic (&mysql_res,Game->GamCod); + NumQsts = Gam_DB_GetGameQuestionsBasic (&mysql_res,Games->Game.GamCod); /***** Begin box *****/ - Games->GamCod = Game->GamCod; if (ICanEditQuestions) Box_BoxBegin (NULL,Txt_Questions, Gam_PutIconToAddNewQuestions,Games, @@ -1673,7 +1655,7 @@ static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game /***** Show table with questions *****/ if (NumQsts) Gam_ListOneOrMoreQuestionsForEdition (Games, - Game->GamCod,NumQsts,mysql_res, + Games->Game.GamCod,NumQsts,mysql_res, ICanEditQuestions); /***** Put button to add a new question in this game *****/ @@ -1751,8 +1733,8 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, snprintf (StrQstInd,sizeof (StrQstInd),"%u",QstInd); /* Initialize context */ - Games->GamCod = GamCod; - Games->QstInd = QstInd; + Games->Game.GamCod = GamCod; + Games->QstInd = QstInd; /***** Build anchor string *****/ Frm_SetAnchorStr (Question.QstCod,&Anchor); @@ -1848,7 +1830,6 @@ void Gam_AddQstsToGame (void) extern const char *Txt_A_question_has_been_added; extern const char *Txt_X_questions_have_been_added; struct Gam_Games Games; - struct Gam_Game Game; const char *Ptr; char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1]; long QstCod; @@ -1859,15 +1840,15 @@ void Gam_AddQstsToGame (void) Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Check if game has matches *****/ - if (!Gam_CheckIfEditable (&Game)) + if (!Gam_CheckIfEditable (&Games.Game)) Err_NoPermissionExit (); /***** Get selected questions *****/ @@ -1892,13 +1873,13 @@ void Gam_AddQstsToGame (void) Err_WrongQuestionExit (); /* Check if question is already present in game */ - if (Gam_DB_GetQstIndFromQstCod (Game.GamCod,QstCod) == 0) // This question is not yet in this game + if (Gam_DB_GetQstIndFromQstCod (Games.Game.GamCod,QstCod) == 0) // This question is not yet in this game { /* Get current maximum index */ - MaxQstInd = Gam_DB_GetMaxQuestionIndexInGame (Game.GamCod); // 0 is no questions in game + MaxQstInd = Gam_DB_GetMaxQuestionIndexInGame (Games.Game.GamCod); // 0 is no questions in game /* Insert question in the table of questions */ - Gam_DB_InsertQstInGame (Game.GamCod,MaxQstInd + 1,QstCod); + Gam_DB_InsertQstInGame (Games.Game.GamCod,MaxQstInd + 1,QstCod); NumQstsAdded++; } @@ -1917,7 +1898,7 @@ void Gam_AddQstsToGame (void) Gam_FreeListsSelectedQuestions (&Games); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, true, // List game questions false); // Do not put form to start new match } @@ -1958,29 +1939,27 @@ void Gam_RequestRemoveQstFromGame (void) extern const char *Txt_Do_you_really_want_to_remove_the_question_X; extern const char *Txt_Remove_question; struct Gam_Games Games; - struct Gam_Game Game; unsigned QstInd; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Check if game has matches *****/ - if (!Gam_CheckIfEditable (&Game)) + if (!Gam_CheckIfEditable (&Games.Game)) Err_NoPermissionExit (); /***** Get question index *****/ QstInd = Gam_GetParamQstInd (); /***** Show question and button to remove question *****/ - Games.GamCod = Game.GamCod; Games.QstInd = QstInd; Ale_ShowAlertAndButton (ActRemGamQst,NULL,NULL, Gam_PutParamsOneQst,&Games, @@ -1989,7 +1968,7 @@ void Gam_RequestRemoveQstFromGame (void) QstInd); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, true, // List game questions false); // Do not put form to start new match } @@ -2002,22 +1981,21 @@ void Gam_RemoveQstFromGame (void) { extern const char *Txt_Question_removed; struct Gam_Games Games; - struct Gam_Game Game; unsigned QstInd; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Check if game has matches *****/ - if (!Gam_CheckIfEditable (&Game)) + if (!Gam_CheckIfEditable (&Games.Game)) Err_NoPermissionExit (); /***** Get question index *****/ @@ -2025,20 +2003,20 @@ void Gam_RemoveQstFromGame (void) /***** Remove the question from all tables *****/ /* Remove answers from this test question */ - Mch_DB_RemUsrAnswersOfAQuestion (Game.GamCod,QstInd); + Mch_DB_RemUsrAnswersOfAQuestion (Games.Game.GamCod,QstInd); /* Remove the question itself */ - Gam_DB_RemoveQstFromGame (Game.GamCod,QstInd); + Gam_DB_RemoveQstFromGame (Games.Game.GamCod,QstInd); /* Change indexes of questions greater than this */ - Mch_DB_UpdateIndexesOfQstsGreaterThan (Game.GamCod,QstInd); - Gam_DB_UpdateIndexesOfQstsGreaterThan (Game.GamCod,QstInd); + Mch_DB_UpdateIndexesOfQstsGreaterThan (Games.Game.GamCod,QstInd); + Gam_DB_UpdateIndexesOfQstsGreaterThan (Games.Game.GamCod,QstInd); /***** Write message *****/ Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, true, // List game questions false); // Do not put form to start new match } @@ -2051,7 +2029,6 @@ void Gam_MoveUpQst (void) { extern const char *Txt_Movement_not_allowed; struct Gam_Games Games; - struct Gam_Game Game; unsigned QstIndTop; unsigned QstIndBottom; @@ -2059,15 +2036,15 @@ void Gam_MoveUpQst (void) Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Check if game has matches *****/ - if (!Gam_CheckIfEditable (&Game)) + if (!Gam_CheckIfEditable (&Games.Game)) Err_NoPermissionExit (); /***** Get question index *****/ @@ -2077,18 +2054,18 @@ void Gam_MoveUpQst (void) if (QstIndBottom > 1) // 2, 3, 4... { /* Indexes of questions to be exchanged */ - QstIndTop = Gam_DB_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom); + QstIndTop = Gam_DB_GetPrevQuestionIndexInGame (Games.Game.GamCod,QstIndBottom); if (QstIndTop == 0) Err_WrongQuestionIndexExit (); /* Exchange questions */ - Gam_ExchangeQuestions (Game.GamCod,QstIndTop,QstIndBottom); + Gam_ExchangeQuestions (Games.Game.GamCod,QstIndTop,QstIndBottom); } else Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, true, // List game questions false); // Do not put form to start new match } @@ -2101,7 +2078,6 @@ void Gam_MoveDownQst (void) { extern const char *Txt_Movement_not_allowed; struct Gam_Games Games; - struct Gam_Game Game; unsigned QstIndTop; unsigned QstIndBottom; unsigned MaxQstInd; // 0 if no questions @@ -2110,39 +2086,39 @@ void Gam_MoveDownQst (void) Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Check if game has matches *****/ - if (!Gam_CheckIfEditable (&Game)) + if (!Gam_CheckIfEditable (&Games.Game)) Err_NoPermissionExit (); /***** Get question index *****/ QstIndTop = Gam_GetParamQstInd (); /***** Get maximum question index *****/ - MaxQstInd = Gam_DB_GetMaxQuestionIndexInGame (Game.GamCod); // 0 is no questions in game + MaxQstInd = Gam_DB_GetMaxQuestionIndexInGame (Games.Game.GamCod); // 0 is no questions in game /***** Move down question *****/ if (QstIndTop < MaxQstInd) { /* Indexes of questions to be exchanged */ - QstIndBottom = Gam_DB_GetNextQuestionIndexInGame (Game.GamCod,QstIndTop); + QstIndBottom = Gam_DB_GetNextQuestionIndexInGame (Games.Game.GamCod,QstIndTop); if (QstIndBottom == Gam_AFTER_LAST_QUESTION) Err_WrongQuestionIndexExit (); /* Exchange questions */ - Gam_ExchangeQuestions (Game.GamCod,QstIndTop,QstIndBottom); + Gam_ExchangeQuestions (Games.Game.GamCod,QstIndTop,QstIndBottom); } else Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, true, // List game questions false); // Do not put form to start new match } @@ -2210,12 +2186,11 @@ static bool Gam_CheckIfEditable (const struct Gam_Game *Game) /********************* Put button to create a new match **********************/ /*****************************************************************************/ -void Gam_PutButtonNewMatch (struct Gam_Games *Games,long GamCod) +void Gam_PutButtonNewMatch (struct Gam_Games *Games) { extern const char *Txt_New_match; Frm_BeginFormAnchor (ActReqNewMch,Mch_NEW_MATCH_SECTION_ID); - Games->GamCod = GamCod; Gam_PutParams (Games); Btn_PutConfirmButton (Txt_New_match); @@ -2230,21 +2205,20 @@ void Gam_PutButtonNewMatch (struct Gam_Games *Games,long GamCod) void Gam_RequestNewMatch (void) { struct Gam_Games Games; - struct Gam_Game Game; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Show game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions true); // Put form to start new match } diff --git a/swad_game.h b/swad_game.h index c17ec03e..fbc22548 100644 --- a/swad_game.h +++ b/swad_game.h @@ -62,26 +62,6 @@ struct Gam_GameSelected bool Selected; // Is this game selected when seeing match results? }; -struct Gam_Games - { - bool LstIsRead; // Is the list already read from database... - // ...or it needs to be read? - unsigned Num; // Total number of games - unsigned NumSelected; // Number of games selected - struct Gam_GameSelected *Lst;// List of games - Gam_Order_t SelectedOrder; - unsigned CurrentPage; - char *ListQuestions; - char *GamCodsSelected; // String with selected game codes separated by separator multiple - long GamCod; // Selected/current game code - struct - { - long Selected; // Current match code - long Current; - } MchCod; - unsigned QstInd; // Current question index - }; - struct Gam_Game { long GamCod; // Game code @@ -99,6 +79,26 @@ struct Gam_Game unsigned NumUnfinishedMchs; // Number of unfinished matches in the game }; +struct Gam_Games + { + bool LstIsRead; // Is the list already read from database... + // ...or it needs to be read? + unsigned Num; // Total number of games + unsigned NumSelected; // Number of games selected + struct Gam_GameSelected *Lst;// List of games + Gam_Order_t SelectedOrder; + unsigned CurrentPage; + char *ListQuestions; + char *GamCodsSelected; // String with selected game codes separated by separator multiple + struct Gam_Game Game; // Selected/current game + struct + { + long Selected; // Current match code + long Current; + } MchCod; + unsigned QstInd; // Current question index + }; + /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ @@ -110,11 +110,9 @@ void Gam_SeeAllGames (void); void Gam_ListAllGames (struct Gam_Games *Games); void Gam_SeeOneGame (void); void Gam_ShowOnlyOneGame (struct Gam_Games *Games, - struct Gam_Game *Game, bool ListGameQuestions, bool PutFormNewMatch); void Gam_ShowOnlyOneGameBegin (struct Gam_Games *Games, - struct Gam_Game *Game, bool ListGameQuestions, bool PutFormNewMatch); void Gam_ShowOnlyOneGameEnd (void); @@ -158,7 +156,7 @@ void Gam_RemoveQstFromGame (void); void Gam_MoveUpQst (void); void Gam_MoveDownQst (void); -void Gam_PutButtonNewMatch (struct Gam_Games *Games,long GamCod); +void Gam_PutButtonNewMatch (struct Gam_Games *Games); void Gam_RequestNewMatch (void); void Gam_ShowTstTagsPresentInAGame (long GamCod); diff --git a/swad_match.c b/swad_match.c index be7656b8..972fce64 100644 --- a/swad_match.c +++ b/swad_match.c @@ -96,7 +96,6 @@ static void Mch_PutIconsInListOfMatches (void *Games); static void Mch_PutIconToCreateNewMatch (struct Gam_Games *Games); static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games, - const struct Gam_Game *Game, unsigned NumMatches, MYSQL_RES *mysql_res); static void Mch_ListOneOrMoreMatchesHeading (bool ICanEditMatches); @@ -258,7 +257,6 @@ void Mch_ResetMatch (struct Mch_Match *Match) /*****************************************************************************/ void Mch_ListMatches (struct Gam_Games *Games, - struct Gam_Game *Game, bool PutFormNewMatch) { extern const char *Hlp_ASSESSMENT_Games_matches; @@ -267,10 +265,9 @@ void Mch_ListMatches (struct Gam_Games *Games, unsigned NumMatches; /***** Get data of matches from database *****/ - NumMatches = Mch_DB_GetMatchesInGame (&mysql_res,Game->GamCod); + NumMatches = Mch_DB_GetMatchesInGame (&mysql_res,Games->Game.GamCod); /***** Begin box *****/ - Games->GamCod = Game->GamCod; Box_BoxBegin ("100%",Txt_Matches, Mch_PutIconsInListOfMatches,Games, Hlp_ASSESSMENT_Games_matches,Box_NOT_CLOSABLE); @@ -295,7 +292,7 @@ void Mch_ListMatches (struct Gam_Games *Games, /***** Show the table with the matches *****/ if (NumMatches) - Mch_ListOneOrMoreMatches (Games,Game,NumMatches,mysql_res); + Mch_ListOneOrMoreMatches (Games,NumMatches,mysql_res); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -307,9 +304,9 @@ void Mch_ListMatches (struct Gam_Games *Games, case Rol_TCH: case Rol_SYS_ADM: if (PutFormNewMatch) - Mch_PutFormNewMatch (Game); // Form to fill in data and start playing a new match + Mch_PutFormNewMatch (&Games->Game); // Form to fill in data and start playing a new match else - Gam_PutButtonNewMatch (Games,Game->GamCod); // Button to create a new match + Gam_PutButtonNewMatch (Games); // Button to create a new match break; default: break; @@ -371,7 +368,6 @@ static void Mch_PutIconToCreateNewMatch (struct Gam_Games *Games) /*****************************************************************************/ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games, - const struct Gam_Game *Game, unsigned NumMatches, MYSQL_RES *mysql_res) { @@ -429,7 +425,7 @@ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games, Mch_ListOneOrMoreMatchesNumPlayers (&Match); /* Match status */ - Mch_ListOneOrMoreMatchesStatus (&Match,Game->NumQsts); + Mch_ListOneOrMoreMatchesStatus (&Match,Games->Game.NumQsts); /* Match result visible? */ Mch_ListOneOrMoreMatchesResult (Games,&Match); @@ -558,7 +554,7 @@ static void Mch_ListOneOrMoreMatchesIcons (struct Gam_Games *Games, if (Mch_CheckIfICanEditThisMatch (Match)) { - Games->GamCod = Match->GamCod; + Games->Game.GamCod = Match->GamCod; Games->MchCod.Current = Match->MchCod; /***** Put icon to remove the match *****/ @@ -783,7 +779,7 @@ static void Mch_ListOneOrMoreMatchesResultStd (struct Gam_Games *Games, if (Match->Status.ShowUsrResults) { /* Result is visible by me */ - Games->GamCod = Match->GamCod; + Games->Game.GamCod = Match->GamCod; Games->MchCod.Current = Match->MchCod; Lay_PutContextualLinkOnlyIcon (ActSeeMyMchResMch,MchRes_RESULTS_BOX_ID, Mch_PutParamsEdit,Games, @@ -800,7 +796,7 @@ static void Mch_ListOneOrMoreMatchesResultTch (struct Gam_Games *Games, extern const char *Txt_Visible_results; extern const char *Txt_Hidden_results; - Games->GamCod = Match->GamCod; + Games->Game.GamCod = Match->GamCod; Games->MchCod.Current = Match->MchCod; /***** Show match results *****/ @@ -839,18 +835,17 @@ static void Mch_ListOneOrMoreMatchesResultTch (struct Gam_Games *Games, void Mch_ToggleVisResultsMchUsr (void) { struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get and check parameters *****/ - Mch_GetAndCheckParameters (&Games,&Game,&Match); + Mch_GetAndCheckParameters (&Games,&Match); /***** Check if visibility of match results can be changed *****/ if (!Mch_CheckIfVisibilityOfResultsCanBeChanged (&Match)) @@ -861,7 +856,7 @@ void Mch_ToggleVisResultsMchUsr (void) Mch_DB_UpdateVisResultsMchUsr (Match.MchCod,Match.Status.ShowUsrResults); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions false); // Do not put form to start new match } @@ -961,18 +956,17 @@ void Mch_RequestRemoveMatch (void) extern const char *Txt_Do_you_really_want_to_remove_the_match_X; extern const char *Txt_Remove_match; struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get and check parameters *****/ - Mch_GetAndCheckParameters (&Games,&Game,&Match); + Mch_GetAndCheckParameters (&Games,&Match); /***** Show question and button to remove question *****/ Ale_ShowAlertAndButton (ActRemMch,NULL,NULL, @@ -982,7 +976,7 @@ void Mch_RequestRemoveMatch (void) Match.Title); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions false); // Do not put form to start new match } @@ -995,18 +989,17 @@ void Mch_RemoveMatch (void) { extern const char *Txt_Match_X_removed; struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get and check parameters *****/ - Mch_GetAndCheckParameters (&Games,&Game,&Match); + Mch_GetAndCheckParameters (&Games,&Match); /***** Check if I can remove this match *****/ if (!Mch_CheckIfICanEditThisMatch (&Match)) @@ -1020,7 +1013,7 @@ void Mch_RemoveMatch (void) Match.Title); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions false); // Do not put form to start new match } @@ -1094,25 +1087,24 @@ void Mch_RemoveMatchesMadeByUsrInCrs (long UsrCod,long CrsCod) void Mch_EditMatch (void) { struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get and check parameters *****/ - Mch_GetAndCheckParameters (&Games,&Game,&Match); + Mch_GetAndCheckParameters (&Games,&Match); /***** Check if I can edit this match *****/ if (!Mch_CheckIfICanEditThisMatch (&Match)) Err_NoPermissionExit (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions false); // Do not put form to start new match } @@ -1157,15 +1149,14 @@ static void Mch_PutParamMchCod (long MchCod) /*****************************************************************************/ void Mch_GetAndCheckParameters (struct Gam_Games *Games, - struct Gam_Game *Game, struct Mch_Match *Match) { /***** Get parameters *****/ /* Get parameters of game */ - if ((Game->GamCod = Gam_GetParams (Games)) <= 0) + if ((Games->Game.GamCod = Gam_GetParams (Games)) <= 0) Err_WrongGameExit (); Grp_GetParamWhichGroups (); - Gam_GetDataOfGameByCod (Game); + Gam_GetDataOfGameByCod (&Games->Game); /* Get match code */ if ((Match->MchCod = Mch_GetParamMchCod ()) <= 0) @@ -1173,13 +1164,12 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games, Mch_GetDataOfMatchByCod (Match); /***** Ensure parameters are correct *****/ - if (Game->GamCod != Match->GamCod) + if (Games->Game.GamCod != Match->GamCod) Err_WrongGameExit (); - if (Game->CrsCod != Gbl.Hierarchy.Crs.CrsCod) + if (Games->Game.CrsCod != Gbl.Hierarchy.Crs.CrsCod) Err_WrongGameExit (); /***** Initialize context *****/ - Games->GamCod = Game->GamCod; Games->MchCod.Current = Games->MchCod.Selected = Match->MchCod; } @@ -1409,18 +1399,17 @@ void Mch_CreateNewMatch (void) void Mch_ChangeMatch (void) { struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get and check parameters *****/ - Mch_GetAndCheckParameters (&Games,&Game,&Match); + Mch_GetAndCheckParameters (&Games,&Match); /***** Check if I can update this match *****/ if (!Mch_CheckIfICanEditThisMatch (&Match)) @@ -1440,7 +1429,7 @@ void Mch_ChangeMatch (void) Grp_FreeListCodSelectedGrps (); /***** Show current game *****/ - Gam_ShowOnlyOneGame (&Games,&Game, + Gam_ShowOnlyOneGame (&Games, false, // Do not list game questions false); // Do not put form to start new match } diff --git a/swad_match.h b/swad_match.h index 5d6254a4..a50d3a4f 100644 --- a/swad_match.h +++ b/swad_match.h @@ -95,7 +95,6 @@ long Mch_GetMchCodBeingPlayed (void); void Mch_ResetMatch (struct Mch_Match *Match); void Mch_ListMatches (struct Gam_Games *Games, - struct Gam_Game *Game, bool PutFormNewMatch); void Mch_GetDataOfMatchByCod (struct Mch_Match *Match); void Mch_ListOneOrMoreMatchesAuthor (const struct Mch_Match *Match); @@ -116,7 +115,6 @@ void Mch_EditMatch (void); void Mch_PutParamsEdit (void *Games); void Mch_GetAndCheckParameters (struct Gam_Games *Games, - struct Gam_Game *Game, struct Mch_Match *Match); long Mch_GetParamMchCod (void); diff --git a/swad_match_result.c b/swad_match_result.c index 135c1fd5..2b81916c 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -70,11 +70,11 @@ struct MchRes_ICanView static void MchRes_PutFormToSelUsrsToViewMchResults (void *Games); static void MchRes_ListMyMchResultsInCrs (struct Gam_Games *Games); -static void MchRes_ListMyMchResultsInGam (struct Gam_Games *Games,long GamCod); +static void MchRes_ListMyMchResultsInGam (struct Gam_Games *Games); static void MchRes_ListMyMchResultsInMch (struct Gam_Games *Games,long MchCod); static void MchRes_ShowAllMchResultsInSelectedGames (void *Games); static void MchRes_ListAllMchResultsInSelectedGames (struct Gam_Games *Games); -static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games,long GamCod); +static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games); static void MchRes_ListAllMchResultsInMch (struct Gam_Games *Games,long MchCod); static void MchRes_ShowResultsBegin (struct Gam_Games *Games, @@ -149,45 +149,44 @@ void MchRes_ShowMyMchResultsInGam (void) { extern const char *Txt_Results_of_game_X; struct Gam_Games Games; - struct Gam_Game Game; char *Title; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Game begin *****/ - Gam_ShowOnlyOneGameBegin (&Games,&Game, + Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions false); // Do not put form to start new match /***** List my matches results in game *****/ - if (asprintf (&Title,Txt_Results_of_game_X,Game.Title) < 0) + if (asprintf (&Title,Txt_Results_of_game_X,Games.Game.Title) < 0) Err_NotEnoughMemoryExit (); MchRes_ShowResultsBegin (&Games,Title,false); // Do not list games to select free (Title); - MchRes_ListMyMchResultsInGam (&Games,Game.GamCod); + MchRes_ListMyMchResultsInGam (&Games); MchRes_ShowResultsEnd (); /***** Game end *****/ Gam_ShowOnlyOneGameEnd (); } -static void MchRes_ListMyMchResultsInGam (struct Gam_Games *Games,long GamCod) +static void MchRes_ListMyMchResultsInGam (struct Gam_Games *Games) { /***** Table header *****/ MchRes_ShowHeaderMchResults (Usr_ME); /***** List my matches results in game *****/ TstCfg_GetConfig (); // Get feedback type - MchRes_ShowMchResults (Games,Usr_ME,-1L,GamCod,NULL); + MchRes_ShowMchResults (Games,Usr_ME,-1L,Games->Game.GamCod,NULL); } /*****************************************************************************/ @@ -198,7 +197,6 @@ void MchRes_ShowMyMchResultsInMch (void) { extern const char *Txt_Results_of_match_X; struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; char *Title; @@ -206,19 +204,19 @@ void MchRes_ShowMyMchResultsInMch (void) Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0) Err_WrongMatchExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); Mch_GetDataOfMatchByCod (&Match); /***** Game begin *****/ - Gam_ShowOnlyOneGameBegin (&Games,&Game, + Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions false); // Do not put form to start new match @@ -356,38 +354,37 @@ void MchRes_ShowAllMchResultsInGam (void) { extern const char *Txt_Results_of_game_X; struct Gam_Games Games; - struct Gam_Game Game; char *Title; /***** Reset games context *****/ Gam_ResetGames (&Games); /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); /***** Game begin *****/ - Gam_ShowOnlyOneGameBegin (&Games,&Game, + Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions false); // Do not put form to start new match /***** List matches results in game *****/ - if (asprintf (&Title,Txt_Results_of_game_X,Game.Title) < 0) + if (asprintf (&Title,Txt_Results_of_game_X,Games.Game.Title) < 0) Err_NotEnoughMemoryExit (); MchRes_ShowResultsBegin (&Games,Title,false); // Do not list games to select free (Title); - MchRes_ListAllMchResultsInGam (&Games,Game.GamCod); + MchRes_ListAllMchResultsInGam (&Games); MchRes_ShowResultsEnd (); /***** Game end *****/ Gam_ShowOnlyOneGameEnd (); } -static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games,long GamCod) +static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games) { MYSQL_RES *mysql_res; unsigned NumUsrs; @@ -397,7 +394,7 @@ static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games,long GamCod) MchRes_ShowHeaderMchResults (Usr_OTHER); /***** Get all users who have answered any match question in this game *****/ - NumUsrs = Mch_DB_GetUsrsWhoHavePlayedGam (&mysql_res,GamCod); + NumUsrs = Mch_DB_GetUsrsWhoHavePlayedGam (&mysql_res,Games->Game.GamCod); /***** List matches results for each user *****/ for (NumUsr = 0; @@ -412,7 +409,7 @@ static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games,long GamCod) { /***** Show matches results *****/ Gbl.Usrs.Other.UsrDat.Accepted = Enr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); - MchRes_ShowMchResults (Games,Usr_OTHER,-1L,GamCod,NULL); + MchRes_ShowMchResults (Games,Usr_OTHER,-1L,Games->Game.GamCod,NULL); } /***** Free structure that stores the query result *****/ @@ -427,7 +424,6 @@ void MchRes_ShowAllMchResultsInMch (void) { extern const char *Txt_Results_of_match_X; struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; char *Title; @@ -435,19 +431,19 @@ void MchRes_ShowAllMchResultsInMch (void) Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get parameters *****/ - if ((Game.GamCod = Gam_GetParams (&Games)) <= 0) + if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0) Err_WrongGameExit (); if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0) Err_WrongMatchExit (); - Gam_GetDataOfGameByCod (&Game); + Gam_GetDataOfGameByCod (&Games.Game); Mch_GetDataOfMatchByCod (&Match); /***** Game begin *****/ - Gam_ShowOnlyOneGameBegin (&Games,&Game, + Gam_ShowOnlyOneGameBegin (&Games, false, // Do not list game questions false); // Do not put form to start new match @@ -541,10 +537,9 @@ static void MchRes_ListGamesToSelect (struct Gam_Games *Games) extern const char *Txt_Update_results; unsigned UniqueId; unsigned NumGame; - struct Gam_Game Game; /***** Reset game *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games->Game); /***** Begin box *****/ Box_BoxBegin (NULL,Txt_Games, @@ -572,8 +567,8 @@ static void MchRes_ListGamesToSelect (struct Gam_Games *Games) NumGame++, UniqueId++, The_ChangeRowColor ()) { /* Get data of this game */ - Game.GamCod = Games->Lst[NumGame].GamCod; - Gam_GetDataOfGameByCod (&Game); + Games->Game.GamCod = Games->Lst[NumGame].GamCod; + Gam_GetDataOfGameByCod (&Games->Game); /* Write a row for this event */ HTM_TR_Begin (NULL); @@ -599,7 +594,7 @@ static void MchRes_ListGamesToSelect (struct Gam_Games *Games) HTM_TD_Begin ("class=\"LT DAT_%s %s\"", The_GetSuffix (), The_GetColorRows ()); - HTM_Txt (Game.Title); + HTM_Txt (Games->Game.Title); HTM_TD_End (); HTM_TR_End (); @@ -727,7 +722,6 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games, struct MchPrn_Print Print; unsigned NumQstsBlank; struct Mch_Match Match; - struct Gam_Game Game; double Grade; struct MchPrn_NumQuestions NumTotalQsts; double TotalScore; @@ -769,11 +763,11 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games, /* Get data of match and game */ Match.MchCod = Print.MchCod; Mch_GetDataOfMatchByCod (&Match); - Game.GamCod = Match.GamCod; - Gam_GetDataOfGameByCod (&Game); + Games->Game.GamCod = Match.GamCod; + Gam_GetDataOfGameByCod (&Games->Game); /* Check if I can view this match result and score */ - MchRes_CheckIfICanSeeMatchResult (&Game,&Match,UsrDat->UsrCod,&ICanView); + MchRes_CheckIfICanSeeMatchResult (&Games->Game,&Match,UsrDat->UsrCod,&ICanView); if (NumResult) HTM_TR_Begin (NULL); @@ -885,8 +879,8 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games, The_GetColorRows ()); if (ICanView.Score) { - Grade = TstPrn_ComputeGrade (Print.NumQsts.All,Print.Score,Game.MaxGrade); - TstPrn_ShowGrade (Grade,Game.MaxGrade); + Grade = TstPrn_ComputeGrade (Print.NumQsts.All,Print.Score,Games->Game.MaxGrade); + TstPrn_ShowGrade (Grade,Games->Game.MaxGrade); TotalGrade += Grade; } else @@ -898,7 +892,7 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games, The_GetColorRows ()); if (ICanView.Result) { - Games->GamCod = Match.GamCod; + Games->Game.GamCod = Match.GamCod; Games->MchCod.Current = Match.MchCod; switch (MeOrOther) { @@ -1073,7 +1067,6 @@ void MchRes_ShowOneMchResult (void) [PhoSha_SHAPE_RECTANGLE] = "PHOTOR45x60", }; struct Gam_Games Games; - struct Gam_Game Game; struct Mch_Match Match; Usr_MeOrOther_t MeOrOther; struct Usr_Data *UsrDat; @@ -1086,11 +1079,11 @@ void MchRes_ShowOneMchResult (void) Gam_ResetGames (&Games); /***** Reset game and match *****/ - Gam_ResetGame (&Game); + Gam_ResetGame (&Games.Game); Mch_ResetMatch (&Match); /***** Get and check parameters *****/ - Mch_GetAndCheckParameters (&Games,&Game,&Match); + Mch_GetAndCheckParameters (&Games,&Match); /***** Pointer to user's data *****/ MeOrOther = (Gbl.Action.Act == ActSeeOneMchResMe) ? Usr_ME : @@ -1113,7 +1106,7 @@ void MchRes_ShowOneMchResult (void) MchPrn_GetMatchPrintDataByMchCodAndUsrCod (&Print); /***** Check if I can view this match result and score *****/ - MchRes_CheckIfICanSeeMatchResult (&Game,&Match,UsrDat->UsrCod,&ICanView); + MchRes_CheckIfICanSeeMatchResult (&Games.Game,&Match,UsrDat->UsrCod,&ICanView); if (ICanView.Result) // I am allowed to view this match result { @@ -1260,7 +1253,7 @@ void MchRes_ShowOneMchResult (void) if (ICanView.Score) { HTM_STRONG_Begin (); - TstPrn_ComputeAndShowGrade (Print.NumQsts.All,Print.Score,Game.MaxGrade); + TstPrn_ComputeAndShowGrade (Print.NumQsts.All,Print.Score,Games.Game.MaxGrade); HTM_STRONG_End (); } else @@ -1289,7 +1282,7 @@ void MchRes_ShowOneMchResult (void) Print.NumQsts.All, Print.PrintedQuestions, Print.TimeUTC, - Game.Visibility); + Games.Game.Visibility); /***** End table *****/ HTM_TABLE_End (); diff --git a/swad_text_action.c b/swad_text_action.c index d725b42b..f28f7661 100644 --- a/swad_text_action.c +++ b/swad_text_action.c @@ -13243,48 +13243,48 @@ const char *Txt_Actions[Act_NUM_ACTIONS] = , [ActSeeMyMchResGam] = #if L==1 // ca - "See all my matches results in a given game" // Necessita traducció + "See all my matches results in game" // Necessita traducció #elif L==2 // de - "See all my matches results in a given game" // Need Übersetzung + "See all my matches results in game" // Need Übersetzung #elif L==3 // en - "See all my matches results in a given game" + "See all my matches results in game" #elif L==4 // es - "Ver todos mis resultados en partidas de un juego" + "Ver todos mis resultados en partidas de juego" #elif L==5 // fr - "See all my matches results in a given game" // Besoin de traduction + "See all my matches results in game" // Besoin de traduction #elif L==6 // gn - "Ver todos mis resultados en partidas de un juego" // Okoteve traducción + "Ver todos mis resultados en partidas de juego" // Okoteve traducción #elif L==7 // it - "See all my matches results in a given game" // Bisogno di traduzione + "See all my matches results in game" // Bisogno di traduzione #elif L==8 // pl - "See all my matches results in a given game" // Potrzebujesz tlumaczenie + "See all my matches results in game" // Potrzebujesz tlumaczenie #elif L==9 // pt - "See all my matches results in a given game" // Precisa de tradução + "See all my matches results in game" // Precisa de tradução #elif L==10 // tr - "See all my matches results in a given game" // Çeviri lazim! + "See all my matches results in game" // Çeviri lazim! #endif , [ActSeeMyMchResMch] = #if L==1 // ca - "See my results in a given match" // Necessita traducció + "See my results in match" // Necessita traducció #elif L==2 // de - "See my results in a given match" // Need Übersetzung + "See my results in match" // Need Übersetzung #elif L==3 // en - "See my results in a given match" + "See my results in match" #elif L==4 // es - "Ver mis resultados en una partida" + "Ver mis resultados en partida" #elif L==5 // fr - "See my results in a given match" // Besoin de traduction + "See my results in match" // Besoin de traduction #elif L==6 // gn - "Ver mis resultados en una partida" // Okoteve traducción + "Ver mis resultados en partida" // Okoteve traducción #elif L==7 // it - "See my results in a given match" // Bisogno di traduzione + "See my results in match" // Bisogno di traduzione #elif L==8 // pl - "See my results in a given match" // Potrzebujesz tlumaczenie + "See my results in match" // Potrzebujesz tlumaczenie #elif L==9 // pt - "See my results in a given match" // Precisa de tradução + "See my results in match" // Precisa de tradução #elif L==10 // tr - "See my results in a given match" // Çeviri lazim! + "See my results in match" // Çeviri lazim! #endif , [ActSeeOneMchResMe] = @@ -13358,48 +13358,48 @@ const char *Txt_Actions[Act_NUM_ACTIONS] = , [ActSeeUsrMchResGam] = #if L==1 // ca - "See all matches results in a given game" // Necessita traducció + "See all matches results in game" // Necessita traducció #elif L==2 // de - "See all matches results in a given game" // Need Übersetzung + "See all matches results in game" // Need Übersetzung #elif L==3 // en - "See all matches results in a given game" + "See all matches results in game" #elif L==4 // es "Ver resultados de todas las partidas de un juego" #elif L==5 // fr - "See all matches results in a given game" // Besoin de traduction + "See all matches results in game" // Besoin de traduction #elif L==6 // gn "Ver resultados de todas las partidas de un juego" // Okoteve traducción #elif L==7 // it - "See all matches results in a given game" // Bisogno di traduzione + "See all matches results in game" // Bisogno di traduzione #elif L==8 // pl - "See all matches results in a given game" // Potrzebujesz tlumaczenie + "See all matches results in game" // Potrzebujesz tlumaczenie #elif L==9 // pt - "See all matches results in a given game" // Precisa de tradução + "See all matches results in game" // Precisa de tradução #elif L==10 // tr - "See all matches results in a given game" // Çeviri lazim! + "See all matches results in game" // Çeviri lazim! #endif , [ActSeeUsrMchResMch] = #if L==1 // ca - "See results de usuario in a given match" // Necessita traducció + "See user's results in match" // Necessita traducció #elif L==2 // de - "See results de usuario in a given match" // Need Übersetzung + "See user's results in match" // Need Übersetzung #elif L==3 // en - "See results de usuario in a given match" + "See user's results in match" #elif L==4 // es - "Ver los resultados de usuario en una partida" + "Ver resultados de usuario en partida" #elif L==5 // fr - "See results de usuario in a given match" // Besoin de traduction + "See user's results in match" // Besoin de traduction #elif L==6 // gn - "Ver los resultados de usuario en una partida" // Okoteve traducción + "Ver resultados de usuario en partida" // Okoteve traducción #elif L==7 // it - "See results de usuario in a given match" // Bisogno di traduzione + "See user's results in match" // Bisogno di traduzione #elif L==8 // pl - "See results de usuario in a given match" // Potrzebujesz tlumaczenie + "See user's results in match" // Potrzebujesz tlumaczenie #elif L==9 // pt - "See results de usuario in a given match" // Precisa de tradução + "See user's results in match" // Precisa de tradução #elif L==10 // tr - "See results de usuario in a given match" // Çeviri lazim! + "See user's results in match" // Çeviri lazim! #endif , [ActSeeOneMchResOth] =