Version19.19.5

This commit is contained in:
Antonio Cañas Vargas 2019-09-29 20:00:54 +02:00
parent 97096702d3
commit 572efcafac
3 changed files with 33 additions and 60 deletions

View File

@ -471,10 +471,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.19.4 (2019-09-29)" #define Log_PLATFORM_VERSION "SWAD 19.19.5 (2019-09-29)"
#define CSS_FILE "swad19.15.css" #define CSS_FILE "swad19.15.css"
#define JS_FILE "swad19.15.js" #define JS_FILE "swad19.15.js"
/* /*
Version 19.19.5: Sep 29, 2019 Code refactoring in games. (246612 lines)
Version 19.19.4: Sep 29, 2019 Code refactoring in games. (246638 lines) Version 19.19.4: Sep 29, 2019 Code refactoring in games. (246638 lines)
Version 19.19.3: Sep 29, 2019 Students will not see matches results for groups to which they don't belong. (246645 lines) Version 19.19.3: Sep 29, 2019 Students will not see matches results for groups to which they don't belong. (246645 lines)
Version 19.19.2: Sep 29, 2019 Students will not see icons to remove matches. (246619 lines) Version 19.19.2: Sep 29, 2019 Students will not see icons to remove matches. (246619 lines)

View File

@ -402,7 +402,7 @@ void Gam_ShowOneGame (long GamCod,
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
/***** Icons related to this game *****/ /***** Icons related to this game *****/
if (Game.Status.ICanEdit) if (Gam_CheckIfICanEditGames ())
{ {
fprintf (Gbl.F.Out,"<td rowspan=\"2\" class=\"CONTEXT_COL"); fprintf (Gbl.F.Out,"<td rowspan=\"2\" class=\"CONTEXT_COL");
if (!ShowOnlyThisGame) if (!ShowOnlyThisGame)
@ -423,8 +423,8 @@ void Gam_ShowOneGame (long GamCod,
{ {
fprintf (Gbl.F.Out,"<td id=\"gam_date_%u_%u\" class=\"%s LEFT_TOP", fprintf (Gbl.F.Out,"<td id=\"gam_date_%u_%u\" class=\"%s LEFT_TOP",
(unsigned) StartEndTime,UniqueId, (unsigned) StartEndTime,UniqueId,
Game.Status.Visible ? "DATE_GREEN" : Game.Hidden ? "DATE_GREEN_LIGHT":
"DATE_GREEN_LIGHT"); "DATE_GREEN");
if (!ShowOnlyThisGame) if (!ShowOnlyThisGame)
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
fprintf (Gbl.F.Out,"\">"); fprintf (Gbl.F.Out,"\">");
@ -451,8 +451,8 @@ void Gam_ShowOneGame (long GamCod,
Frm_StartForm (ActSeeGam); Frm_StartForm (ActSeeGam);
Gam_PutParams (); Gam_PutParams ();
Frm_LinkFormSubmit (Txt_View_game, Frm_LinkFormSubmit (Txt_View_game,
Game.Status.Visible ? "ASG_TITLE" : Game.Hidden ? "ASG_TITLE_LIGHT":
"ASG_TITLE_LIGHT",NULL); "ASG_TITLE",NULL);
fprintf (Gbl.F.Out,"%s</a>", fprintf (Gbl.F.Out,"%s</a>",
Game.Title); Game.Title);
Frm_EndForm (); Frm_EndForm ();
@ -460,8 +460,8 @@ void Gam_ShowOneGame (long GamCod,
/* Number of questions */ /* Number of questions */
fprintf (Gbl.F.Out,"<div class=\"%s\">%s: %u</div>", fprintf (Gbl.F.Out,"<div class=\"%s\">%s: %u</div>",
Game.Status.Visible ? "ASG_GRP" : Game.Hidden ? "ASG_GRP_LIGHT" :
"ASG_GRP_LIGHT", "ASG_GRP",
Txt_No_of_questions, Txt_No_of_questions,
Game.NumQsts); Game.NumQsts);
@ -477,8 +477,8 @@ void Gam_ShowOneGame (long GamCod,
Frm_StartForm (ActSeeGam); Frm_StartForm (ActSeeGam);
Gam_PutParams (); Gam_PutParams ();
Frm_LinkFormSubmit (Txt_Matches, Frm_LinkFormSubmit (Txt_Matches,
Game.Status.Visible ? "ASG_TITLE" : Game.Hidden ? "ASG_TITLE_LIGHT" :
"ASG_TITLE_LIGHT",NULL); "ASG_TITLE",NULL);
if (ShowOnlyThisGame) if (ShowOnlyThisGame)
fprintf (Gbl.F.Out,"%s:&nbsp;",Txt_Matches); fprintf (Gbl.F.Out,"%s:&nbsp;",Txt_Matches);
fprintf (Gbl.F.Out,"%u</a>",Game.NumMchs); fprintf (Gbl.F.Out,"%u</a>",Game.NumMchs);
@ -511,8 +511,8 @@ void Gam_ShowOneGame (long GamCod,
Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
fprintf (Gbl.F.Out,"<div class=\"PAR %s\">%s</div>" fprintf (Gbl.F.Out,"<div class=\"PAR %s\">%s</div>"
"</td>", "</td>",
Game.Status.Visible ? "DAT" : Game.Hidden ? "DAT_LIGHT" :
"DAT_LIGHT", "DAT",
Txt); Txt);
/***** End 2nd row of this game *****/ /***** End 2nd row of this game *****/
@ -547,7 +547,7 @@ void Gam_ShowOneGame (long GamCod,
static void Gam_WriteAuthor (struct Game *Game) static void Gam_WriteAuthor (struct Game *Game)
{ {
Usr_WriteAuthor1Line (Game->UsrCod,!Game->Status.Visible); Usr_WriteAuthor1Line (Game->UsrCod,Game->Hidden);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -569,11 +569,11 @@ static void Gam_PutFormsToRemEditOneGame (const struct Game *Game,
/***** Put icon to remove game *****/ /***** Put icon to remove game *****/
Ico_PutContextualIconToRemove (ActReqRemGam,Gam_PutParams); Ico_PutContextualIconToRemove (ActReqRemGam,Gam_PutParams);
/***** Put icon to hide/show game *****/ /***** Put icon to unhide/hide game *****/
if (Game->Status.Visible) if (Game->Hidden)
Ico_PutContextualIconToHide (ActHidGam,Anchor,Gam_PutParams);
else
Ico_PutContextualIconToUnhide (ActShoGam,Anchor,Gam_PutParams); Ico_PutContextualIconToUnhide (ActShoGam,Anchor,Gam_PutParams);
else
Ico_PutContextualIconToHide (ActHidGam,Anchor,Gam_PutParams);
/***** Put icon to edit game *****/ /***** Put icon to edit game *****/
if (!Game->NumMchs) // Edit only if match has no matches if (!Game->NumMchs) // Edit only if match has no matches
@ -754,7 +754,7 @@ void Gam_GetDataOfGameByCod (struct Game *Game)
Game->CrsCod = Str_ConvertStrCodToLongCod (row[1]); Game->CrsCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get whether the game is hidden (row[2]) */ /* Get whether the game is hidden (row[2]) */
Game->Status.Visible = (row[2][0] == 'N'); Game->Hidden = (row[2][0] == 'Y');
/* Get author of the game (row[3]) */ /* Get author of the game (row[3]) */
Game->UsrCod = Str_ConvertStrCodToLongCod (row[3]); Game->UsrCod = Str_ConvertStrCodToLongCod (row[3]);
@ -768,30 +768,6 @@ void Gam_GetDataOfGameByCod (struct Game *Game)
/* Get number of matches */ /* Get number of matches */
Game->NumMchs = Mch_GetNumMchsInGame (Game->GamCod); Game->NumMchs = Mch_GetNumMchsInGame (Game->GamCod);
/* Can I view results of the game?
Can I edit game? */
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD:
Game->Status.ICanEdit = false;
break;
case Rol_NET:
Game->Status.ICanEdit = false;
break;
case Rol_TCH:
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
Game->Status.ICanEdit = true;
break;
case Rol_SYS_ADM:
Game->Status.ICanEdit = true;
break;
default:
Game->Status.ICanEdit = false;
break;
}
} }
else else
/* Initialize to empty game */ /* Initialize to empty game */
@ -846,8 +822,7 @@ static void Gam_ResetGame (struct Game *Game)
Game->Title[0] = '\0'; Game->Title[0] = '\0';
Game->NumQsts = 0; Game->NumQsts = 0;
Game->NumMchs = 0; Game->NumMchs = 0;
Game->Status.Visible = true; Game->Hidden = false;
Game->Status.ICanEdit = false;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -934,7 +909,7 @@ void Gam_AskRemGame (void)
/***** Get data of the game from database *****/ /***** Get data of the game from database *****/
Gam_GetDataOfGameByCod (&Game); Gam_GetDataOfGameByCod (&Game);
if (!Game.Status.ICanEdit) if (!Gam_CheckIfICanEditGames ())
Lay_ShowErrorAndExit ("You can not remove this game."); Lay_ShowErrorAndExit ("You can not remove this game.");
/***** Show question and button to remove game *****/ /***** Show question and button to remove game *****/
@ -963,7 +938,7 @@ void Gam_RemoveGame (void)
/***** Get data of the game from database *****/ /***** Get data of the game from database *****/
Gam_GetDataOfGameByCod (&Game); Gam_GetDataOfGameByCod (&Game);
if (!Game.Status.ICanEdit) if (!Gam_CheckIfICanEditGames ())
Lay_ShowErrorAndExit ("You can not remove this game."); Lay_ShowErrorAndExit ("You can not remove this game.");
/***** Remove game from all tables *****/ /***** Remove game from all tables *****/
@ -1035,7 +1010,7 @@ void Gam_HideGame (void)
/***** Get data of the game from database *****/ /***** Get data of the game from database *****/
Gam_GetDataOfGameByCod (&Game); Gam_GetDataOfGameByCod (&Game);
if (!Game.Status.ICanEdit) if (!Gam_CheckIfICanEditGames ())
Lay_ShowErrorAndExit ("You can not hide this game."); Lay_ShowErrorAndExit ("You can not hide this game.");
/***** Hide game *****/ /***** Hide game *****/
@ -1061,7 +1036,7 @@ void Gam_UnhideGame (void)
/***** Get data of the game from database *****/ /***** Get data of the game from database *****/
Gam_GetDataOfGameByCod (&Game); Gam_GetDataOfGameByCod (&Game);
if (!Game.Status.ICanEdit) if (!Gam_CheckIfICanEditGames ())
Lay_ShowErrorAndExit ("You can not unhide this game."); Lay_ShowErrorAndExit ("You can not unhide this game.");
/***** Show game *****/ /***** Show game *****/
@ -1128,7 +1103,7 @@ void Gam_RequestCreatOrEditGame (void)
{ {
/* Get data of the game from database */ /* Get data of the game from database */
Gam_GetDataOfGameByCod (&Game); Gam_GetDataOfGameByCod (&Game);
if (!Game.Status.ICanEdit) if (!Gam_CheckIfICanEditGames ())
Lay_ShowErrorAndExit ("You can not update this game."); Lay_ShowErrorAndExit ("You can not update this game.");
/* Get text of the game from database */ /* Get text of the game from database */
@ -1227,7 +1202,7 @@ void Gam_RecFormGame (void)
/* Get data of the old (current) game from database */ /* Get data of the old (current) game from database */
OldGame.GamCod = NewGame.GamCod; OldGame.GamCod = NewGame.GamCod;
Gam_GetDataOfGameByCod (&OldGame); Gam_GetDataOfGameByCod (&OldGame);
if (!OldGame.Status.ICanEdit) if (!Gam_CheckIfICanEditGames ())
Lay_ShowErrorAndExit ("You can not update this game."); Lay_ShowErrorAndExit ("You can not update this game.");
} }
@ -1581,6 +1556,7 @@ static void Gam_ListGameQuestions (struct Game *Game)
unsigned NumQsts; unsigned NumQsts;
bool Editing = (Gbl.Action.Act == ActEdiOneGam || bool Editing = (Gbl.Action.Act == ActEdiOneGam ||
Gbl.Action.Act == ActAddOneGamQst); // TODO: Ampliar casos en los que se está editando para que se muestre el botón de Añadir preguntas Gbl.Action.Act == ActAddOneGamQst); // TODO: Ampliar casos en los que se está editando para que se muestre el botón de Añadir preguntas
bool ICanEditGames = Gam_CheckIfICanEditGames ();
/***** Get data of questions from database *****/ /***** Get data of questions from database *****/
NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get data of a question", NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get data of a question",
@ -1598,8 +1574,8 @@ static void Gam_ListGameQuestions (struct Game *Game)
/***** Start box *****/ /***** Start box *****/
Gam_CurrentGamCod = Game->GamCod; Gam_CurrentGamCod = Game->GamCod;
Box_StartBox (NULL,Txt_Questions,Game->Status.ICanEdit ? Gam_PutIconToAddNewQuestions : Box_StartBox (NULL,Txt_Questions,ICanEditGames ? Gam_PutIconToAddNewQuestions :
NULL, NULL,
Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE); Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE);
if (NumQsts) if (NumQsts)
@ -1608,9 +1584,9 @@ static void Gam_ListGameQuestions (struct Game *Game)
else // This game has no questions else // This game has no questions
Ale_ShowAlert (Ale_INFO,Txt_This_game_has_no_questions); Ale_ShowAlert (Ale_INFO,Txt_This_game_has_no_questions);
if (Game->Status.ICanEdit && // I can edit if (ICanEditGames && // I can edit
(!NumQsts || // This game has no questions (!NumQsts || // This game has no questions
Editing)) // I am editing Editing)) // I am editing
/***** Put button to add a new question in this game *****/ /***** Put button to add a new question in this game *****/
Gam_PutButtonToAddNewQuestions (); Gam_PutButtonToAddNewQuestions ();

View File

@ -44,13 +44,9 @@ struct Game
long UsrCod; // Author code long UsrCod; // Author code
char Title[Gam_MAX_BYTES_TITLE + 1]; char Title[Gam_MAX_BYTES_TITLE + 1];
time_t TimeUTC[Dat_NUM_START_END_TIME]; time_t TimeUTC[Dat_NUM_START_END_TIME];
bool Hidden; // Game is hidden
unsigned NumQsts; // Number of questions in the game unsigned NumQsts; // Number of questions in the game
unsigned NumMchs; // Number of matches in the game unsigned NumMchs; // Number of matches in the game
struct
{
bool Visible; // Game is not hidden
bool ICanEdit;
} Status;
}; };
#define Gam_NUM_ORDERS 3 #define Gam_NUM_ORDERS 3