diff --git a/.cproject b/.cproject
index b89bd6d6..0b577ed0 100644
--- a/.cproject
+++ b/.cproject
@@ -29,7 +29,7 @@
-
+
@@ -37,19 +37,37 @@
-
+
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
@@ -78,5 +96,15 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/css/swad19.85.css b/css/swad19.85.css
index 50bba774..066542c8 100644
--- a/css/swad19.85.css
+++ b/css/swad19.85.css
@@ -1773,7 +1773,7 @@ a:hover /* Default ==> underlined */
display:inline-block;
box-sizing:border-box;
margin:5px 0;
- padding:8px 12px 20px 12px;
+ padding:8px 12px 12px 12px;
background-color:white;
border-radius:2px;
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 2px 1px -2px rgba(0,0,0,0.2), 0 1px 5px 0 rgba(0,0,0,0.12);
diff --git a/swad_changelog.h b/swad_changelog.h
index e8670e41..07637b38 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -490,7 +490,7 @@ 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.3 (2019-12-07)"
+#define Log_PLATFORM_VERSION "SWAD 19.87.4 (2019-12-07)"
#define CSS_FILE "swad19.85.css"
#define JS_FILE "swad19.70.js"
/*
@@ -498,6 +498,7 @@ ps2pdf source.ps destination.pdf
// 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.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)
Copy the following icon to icon public directory:
sudo cp -a icon/trophy.svg /var/www/html/swad/icon/
diff --git a/swad_game.c b/swad_game.c
index 02b90f2b..1f70d961 100644
--- a/swad_game.c
+++ b/swad_game.c
@@ -115,6 +115,9 @@ static void Gam_PutIconsListGames (void);
static void Gam_PutIconToCreateNewGame (void);
static void Gam_PutButtonToCreateNewGame (void);
static void Gam_PutParamsToCreateNewGame (void);
+
+static void Gam_ShowOneGame (struct Game *Game,bool ShowOnlyThisGame);
+
static void Gam_PutIconToShowResultsOfGame (void);
static void Gam_WriteAuthor (struct Game *Game);
@@ -189,6 +192,7 @@ static void Gam_ListAllGames (void)
Gam_Order_t Order;
struct Pagination Pagination;
unsigned NumGame;
+ struct Game Game;
/***** Get number of groups in current course *****/
if (!Gbl.Crs.Grps.NumGrps)
@@ -251,10 +255,15 @@ static void Gam_ListAllGames (void)
for (NumGame = Pagination.FirstItemVisible;
NumGame <= Pagination.LastItemVisible;
NumGame++)
- Gam_ShowOneGame (Gbl.Games.Lst[NumGame - 1].GamCod,
- false,
- false, // Do not list game questions
- false); // Do not put form to start new match
+ {
+ /* Get data of this game */
+ Game.GamCod = Gbl.Games.Lst[NumGame - 1].GamCod;
+ Gam_GetDataOfGameByCod (&Game);
+
+ /* Show game */
+ Gam_ShowOneGame (&Game,
+ false); // Do not show only this game
+ }
/***** End table *****/
HTM_TABLE_End ();
@@ -368,30 +377,56 @@ static void Gam_PutParamsToCreateNewGame (void)
void Gam_SeeOneGame (void)
{
- struct Game Game;
+ long GamCod;
/***** Get parameters *****/
- if ((Game.GamCod = Gam_GetParams ()) == -1L)
+ if ((GamCod = Gam_GetParams ()) == -1L)
Lay_ShowErrorAndExit ("Code of game is missing.");
/***** Show game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- false, // Do not list game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (GamCod,
+ false, // Do not list game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
/******************************* Show one game *******************************/
/*****************************************************************************/
-void Gam_ShowOneGame (long GamCod,
- bool ShowOnlyThisGame,
- bool ListGameQuestions,
- bool PutFormNewMatch)
+void Gam_ShowOnlyOneGame (long GamCod,
+ 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);
+ Box_BoxBegin (NULL,Txt_Game,Gam_PutIconToShowResultsOfGame,
+ Hlp_ASSESSMENT_Games,Box_NOT_CLOSABLE);
+
+ /***** Show game *****/
+ Gam_ShowOneGame (&Game,
+ true); // Show only this game
+
+ if (ListGameQuestions)
+ /***** Write questions of this game *****/
+ Gam_ListGameQuestions (&Game);
+ else
+ /***** List matches *****/
+ Mch_ListMatches (&Game,PutFormNewMatch);
+
+ /***** End box *****/
+ Box_BoxEnd ();
+ }
+
+static void Gam_ShowOneGame (struct Game *Game,bool ShowOnlyThisGame)
+ {
extern const char *Txt_View_game;
extern const char *Txt_Maximum_grade;
extern const char *Txt_No_of_questions;
@@ -399,26 +434,13 @@ void Gam_ShowOneGame (long GamCod,
char *Anchor = NULL;
static unsigned UniqueId = 0;
char *Id;
- struct Game Game;
Dat_StartEndTime_t StartEndTime;
char Txt[Cns_MAX_BYTES_TEXT + 1];
- /***** Begin box *****/
- if (ShowOnlyThisGame)
- {
- Gam_SetParamCurrentGamCod (GamCod);
- Box_BoxBegin (NULL,Txt_Game,Gam_PutIconToShowResultsOfGame,
- Hlp_ASSESSMENT_Games,Box_NOT_CLOSABLE);
- }
-
- /***** Get data of this game *****/
- Game.GamCod = GamCod;
- Gam_GetDataOfGameByCod (&Game);
-
/***** Set anchor string *****/
- Frm_SetAnchorStr (Game.GamCod,&Anchor);
+ Frm_SetAnchorStr (Game->GamCod,&Anchor);
- /***** Begin table *****/
+ /***** Begin box and table *****/
if (ShowOnlyThisGame)
HTM_TABLE_BeginWidePadding (2);
@@ -434,7 +456,7 @@ void Gam_ShowOneGame (long GamCod,
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL COLOR%u\"",Gbl.RowEvenOdd);
/* Icons to remove/edit this game */
- Gam_PutFormsToRemEditOneGame (&Game,Anchor);
+ Gam_PutFormsToRemEditOneGame (Game,Anchor);
HTM_TD_End ();
}
@@ -449,15 +471,15 @@ void Gam_ShowOneGame (long GamCod,
Lay_NotEnoughMemoryExit ();
if (ShowOnlyThisGame)
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
- Id,Game.Hidden ? "DATE_GREEN_LIGHT":
- "DATE_GREEN");
+ Id,Game->Hidden ? "DATE_GREEN_LIGHT":
+ "DATE_GREEN");
else
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
- Id,Game.Hidden ? "DATE_GREEN_LIGHT":
- "DATE_GREEN",
+ Id,Game->Hidden ? "DATE_GREEN_LIGHT":
+ "DATE_GREEN",
Gbl.RowEvenOdd);
- if (Game.TimeUTC[Dat_START_TIME])
- Dat_WriteLocalDateHMSFromUTC (Id,Game.TimeUTC[StartEndTime],
+ if (Game->TimeUTC[Dat_START_TIME])
+ Dat_WriteLocalDateHMSFromUTC (Id,Game->TimeUTC[StartEndTime],
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
true,true,true,0x7);
HTM_TD_End ();
@@ -471,25 +493,25 @@ void Gam_ShowOneGame (long GamCod,
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
/* Game title */
- Gam_SetParamCurrentGamCod (GamCod); // Used to pass parameter
+ Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter
HTM_ARTICLE_Begin (Anchor);
Frm_StartForm (ActSeeGam);
Gam_PutParams ();
HTM_BUTTON_SUBMIT_Begin (Txt_View_game,
- Game.Hidden ? "BT_LINK ASG_TITLE_LIGHT":
- "BT_LINK ASG_TITLE",
+ Game->Hidden ? "BT_LINK ASG_TITLE_LIGHT":
+ "BT_LINK ASG_TITLE",
NULL);
- HTM_Txt (Game.Title);
+ HTM_Txt (Game->Title);
HTM_BUTTON_End ();
Frm_EndForm ();
HTM_ARTICLE_End ();
/* Number of questions and maximum grade */
- HTM_DIV_Begin ("class=\"%s\"",Game.Hidden ? "ASG_GRP_LIGHT" :
- "ASG_GRP");
- HTM_TxtF ("%s: %u",Txt_No_of_questions,Game.NumQsts);
+ HTM_DIV_Begin ("class=\"%s\"",Game->Hidden ? "ASG_GRP_LIGHT" :
+ "ASG_GRP");
+ HTM_TxtF ("%s: %u",Txt_No_of_questions,Game->NumQsts);
HTM_BR ();
- HTM_TxtF ("%s: %lg",Txt_Maximum_grade,Game.MaxGrade);
+ HTM_TxtF ("%s: %lg",Txt_Maximum_grade,Game->MaxGrade);
HTM_DIV_End ();
HTM_TD_End ();
@@ -500,16 +522,16 @@ void Gam_ShowOneGame (long GamCod,
else
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
- Gam_SetParamCurrentGamCod (GamCod); // Used to pass parameter
+ Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter
Frm_StartForm (ActSeeGam);
Gam_PutParams ();
HTM_BUTTON_SUBMIT_Begin (Txt_Matches,
- Game.Hidden ? "BT_LINK ASG_TITLE_LIGHT" :
- "BT_LINK ASG_TITLE",
+ Game->Hidden ? "BT_LINK ASG_TITLE_LIGHT" :
+ "BT_LINK ASG_TITLE",
NULL);
if (ShowOnlyThisGame)
HTM_TxtF ("%s: ",Txt_Matches);
- HTM_Unsigned (Game.NumMchs);
+ HTM_Unsigned (Game->NumMchs);
HTM_BUTTON_End ();
Frm_EndForm ();
@@ -526,7 +548,7 @@ void Gam_ShowOneGame (long GamCod,
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
else
HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
- Gam_WriteAuthor (&Game);
+ Gam_WriteAuthor (Game);
HTM_TD_End ();
/***** Text of the game *****/
@@ -534,12 +556,12 @@ void Gam_ShowOneGame (long GamCod,
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
else
HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
- Gam_GetGameTxtFromDB (Game.GamCod,Txt);
+ Gam_GetGameTxtFromDB (Game->GamCod,Txt);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
- HTM_DIV_Begin ("class=\"PAR %s\"",Game.Hidden ? "DAT_LIGHT" :
- "DAT");
+ HTM_DIV_Begin ("class=\"PAR %s\"",Game->Hidden ? "DAT_LIGHT" :
+ "DAT");
HTM_Txt (Txt);
HTM_DIV_End ();
HTM_TD_End ();
@@ -555,19 +577,6 @@ void Gam_ShowOneGame (long GamCod,
/***** Free anchor string *****/
Frm_FreeAnchorStr (Anchor);
-
- if (ShowOnlyThisGame)
- {
- if (ListGameQuestions)
- /***** Write questions of this game *****/
- Gam_ListGameQuestions (&Game);
- else
- /***** List matches *****/
- Mch_ListMatches (&Game,PutFormNewMatch);
-
- /***** End box *****/
- Box_BoxEnd ();
- }
}
/*****************************************************************************/
@@ -1507,10 +1516,9 @@ void Gam_RequestNewQuestion (void)
Lay_NoPermissionExit ();
/***** Show current game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- true, // List game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ true, // List game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -2023,10 +2031,9 @@ void Gam_AddTstQuestionsToGame (void)
Lay_NoPermissionExit ();
/***** Show current game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- true, // List game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ true, // List game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -2122,10 +2129,9 @@ void Gam_RequestRemoveQst (void)
Lay_NoPermissionExit ();
/***** Show current game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- true, // List game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ true, // List game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -2180,10 +2186,9 @@ void Gam_RemoveQst (void)
Lay_NoPermissionExit ();
/***** Show current game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- true, // List game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ true, // List game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -2229,10 +2234,9 @@ void Gam_MoveUpQst (void)
Lay_NoPermissionExit ();
/***** Show current game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- true, // List game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ true, // List game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -2288,10 +2292,9 @@ void Gam_MoveDownQst (void)
Lay_NoPermissionExit ();
/***** Show current game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- true, // List game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ true, // List game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -2391,10 +2394,9 @@ void Gam_RequestNewMatch (void)
Lay_ShowErrorAndExit ("Code of game is missing.");
/***** Show game *****/
- Gam_ShowOneGame (GamCod,
- true, // Show only this game
- false, // Do not list game questions
- true); // Put form to start new match
+ Gam_ShowOnlyOneGame (GamCod,
+ false, // Do not list game questions
+ true); // Put form to start new match
}
/*****************************************************************************/
diff --git a/swad_game.h b/swad_game.h
index 85328afc..1fcc9b33 100644
--- a/swad_game.h
+++ b/swad_game.h
@@ -81,10 +81,9 @@ typedef enum
void Gam_SeeAllGames (void);
void Gam_SeeOneGame (void);
-void Gam_ShowOneGame (long GamCod,
- bool ShowOnlyThisGame,
- bool ListGameQuestions,
- bool PutFormNewMatch);
+void Gam_ShowOnlyOneGame (long GamCod,
+ bool ListGameQuestions,
+ bool PutFormNewMatch);
void Gam_PutHiddenParamGameOrder (void);
void Gam_RequestCreatOrEditGame (void);
diff --git a/swad_match.c b/swad_match.c
index ae92fbb0..ad97c346 100644
--- a/swad_match.c
+++ b/swad_match.c
@@ -409,7 +409,7 @@ static void Mch_ListOneOrMoreMatches (const struct Game *Game,
bool ICanEditMatches = Mch_CheckIfICanEditMatches ();
/***** Write the heading *****/
- HTM_TABLE_BeginWideMarginPadding (2);
+ HTM_TABLE_BeginWidePadding (2);
Mch_ListOneOrMoreMatchesHeading (ICanEditMatches);
/***** Write rows *****/
@@ -825,10 +825,9 @@ void Mch_ToggleVisibilResultsMchUsr (void)
Match.MchCod);
/***** Show current game *****/
- Gam_ShowOneGame (Match.GamCod,
- true, // Show only this game
- false, // Do not list game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Match.GamCod,
+ false, // Do not list game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -954,10 +953,9 @@ void Mch_RequestRemoveMatch (void)
Match.Title);
/***** Show current game *****/
- Gam_ShowOneGame (Match.GamCod,
- true, // Show only this game
- false, // Do not list game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Match.GamCod,
+ false, // Do not list game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
@@ -985,10 +983,9 @@ void Mch_RemoveMatch (void)
Match.Title);
/***** Show current game *****/
- Gam_ShowOneGame (Match.GamCod,
- true, // Show only this game
- false, // Do not list game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Match.GamCod,
+ false, // Do not list game questions
+ false); // Do not put form to start new match
}
/*****************************************************************************/
diff --git a/swad_match_result.c b/swad_match_result.c
index 166c1ffe..8fa931ee 100644
--- a/swad_match_result.c
+++ b/swad_match_result.c
@@ -254,10 +254,9 @@ void McR_ShowMyMchResInGame (void)
Lay_NotEnoughMemoryExit ();
/***** Show game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- false, // Do not list game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ false, // Do not list game questions
+ false); // Do not put form to start new match
/***** Begin box *****/
Box_BoxBegin (NULL,Txt_Results,NULL,
@@ -373,10 +372,9 @@ void McR_ShowUsrsMchResultsInGame (void)
Lay_NotEnoughMemoryExit ();
/***** Show game *****/
- Gam_ShowOneGame (Game.GamCod,
- true, // Show only this game
- false, // Do not list game questions
- false); // Do not put form to start new match
+ Gam_ShowOnlyOneGame (Game.GamCod,
+ false, // Do not list game questions
+ false); // Do not put form to start new match
/***** Begin box *****/
Box_BoxBegin (NULL,Txt_Results,NULL,