From f24974157bc240d90593f9a92a7bf7905f6cff07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 30 Sep 2019 12:45:45 +0200 Subject: [PATCH] Version19.26 --- swad_changelog.h | 5 +- swad_game.c | 227 +++++++++++++++++++++++------------------------ swad_text.c | 5 +- 3 files changed, 116 insertions(+), 121 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 9af7fc6cf..8549d4aca 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -456,6 +456,8 @@ Lo de mutear anuncios, en principio prefiero hacer una opci // TODO: URGENTE: Reportado por Javier Fernández Baldomero. Al pasar lista con SWADroid, los estudiantes sin foto no salen en la lista de alumnos de SWADroid. +// TODO: No repintar los botones de matches del profesor durante el refresco AJAX + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ @@ -474,10 +476,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.25.3 (2019-09-30)" +#define Log_PLATFORM_VERSION "SWAD 19.26 (2019-09-30)" #define CSS_FILE "swad19.15.css" #define JS_FILE "swad19.15.js" /* + Version 19.26: Sep 30, 2019 Changes in edition of games. (246743 lines) Version 19.25.3: Sep 30, 2019 Fixed bug: students should not see icon to add a match. (246745 lines) Version 19.25.2: Sep 30, 2019 Fixed bug in match results. (246744 lines) Version 19.25.1: Sep 30, 2019 Fixed bug in match results. (246743 lines) diff --git a/swad_game.c b/swad_game.c index 32b585698..365521d3d 100644 --- a/swad_game.c +++ b/swad_game.c @@ -114,7 +114,8 @@ static void Gam_RemAnswersOfAQuestion (long GamCod,unsigned QstInd); static unsigned Gam_GetMaxQuestionIndexInGame (long GamCod); static void Gam_ListGameQuestions (struct Game *Game); static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, - MYSQL_RES *mysql_res); + MYSQL_RES *mysql_res, + bool ICanEditQuestions); static void Gam_PutIconToAddNewQuestions (void); static void Gam_PutButtonToAddNewQuestions (void); @@ -573,8 +574,7 @@ static void Gam_PutFormsToRemEditOneGame (const struct Game *Game, Ico_PutContextualIconToHide (ActHidGam,Anchor,Gam_PutParams); /***** Put icon to edit game *****/ - if (!Game->NumMchs) // Edit only if match has no matches - Ico_PutContextualIconToEdit (ActEdiOneGam,Gam_PutParams); + Ico_PutContextualIconToEdit (ActEdiOneGam,Gam_PutParams); } /*****************************************************************************/ @@ -1085,95 +1085,88 @@ void Gam_RequestCreatOrEditGame (void) /***** Get parameters *****/ Game.GamCod = Gam_GetParams (); - /***** Check if game has matches *****/ - if (Gam_GetNumMchsGameAndCheckIfEditable (&Game)) + /***** Get from the database the data of the game *****/ + ItsANewGame = (Game.GamCod < 0); + if (ItsANewGame) { - /***** Get from the database the data of the game *****/ - ItsANewGame = (Game.GamCod < 0); - if (ItsANewGame) - { - /***** Put link (form) to create new game *****/ - if (!Gam_CheckIfICanEditGames ()) - Act_NoPermissionExit (); + /***** Put link (form) to create new game *****/ + if (!Gam_CheckIfICanEditGames ()) + Act_NoPermissionExit (); - /* Initialize to empty game */ - Gam_ResetGame (&Game); - } - else - { - /* Get data of the game from database */ - Gam_GetDataOfGameByCod (&Game); - if (!Gam_CheckIfICanEditGames ()) - Act_NoPermissionExit (); + /* Initialize to empty game */ + Gam_ResetGame (&Game); + } + else + { + /* Get data of the game from database */ + Gam_GetDataOfGameByCod (&Game); + if (!Gam_CheckIfICanEditGames ()) + Act_NoPermissionExit (); - /* Get text of the game from database */ - Gam_GetGameTxtFromDB (Game.GamCod,Txt); - } - - /***** Start form *****/ - Gam_SetParamCurrentGamCod (Game.GamCod); // Used to pass parameter - Frm_StartForm (ItsANewGame ? ActNewGam : - ActChgGam); - Gam_PutParams (); - - /***** Start box and table *****/ - if (ItsANewGame) - Box_StartBoxTable (NULL,Txt_New_game,NULL, - Hlp_ASSESSMENT_Games_new_game,Box_NOT_CLOSABLE,2); - else - Box_StartBoxTable (NULL, - Game.Title[0] ? Game.Title : - Txt_Edit_game, - NULL, - Hlp_ASSESSMENT_Games_edit_game,Box_NOT_CLOSABLE,2); - - /***** Game title *****/ - fprintf (Gbl.F.Out,"" - "" - "" - "" - "" - "" - "" - "", - The_ClassFormInBox[Gbl.Prefs.Theme], - Txt_Title, - Gam_MAX_CHARS_TITLE,Game.Title); - - /***** Game text *****/ - fprintf (Gbl.F.Out,"" - "" - "" - "" - "" - "" - "" - ""); - - /***** End table, send button and end box *****/ - if (ItsANewGame) - Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_game); - else - Box_EndBoxTableWithButton (Btn_CONFIRM_BUTTON,Txt_Save_changes); - - /***** End form *****/ - Frm_EndForm (); - - /***** Show questions of the game ready to be edited *****/ - if (!ItsANewGame) - Gam_ListGameQuestions (&Game); + /* Get text of the game from database */ + Gam_GetGameTxtFromDB (Game.GamCod,Txt); } - /***** Show all games *****/ - Gam_ListAllGames (); + /***** Start form *****/ + Gam_SetParamCurrentGamCod (Game.GamCod); // Used to pass parameter + Frm_StartForm (ItsANewGame ? ActNewGam : + ActChgGam); + Gam_PutParams (); + + /***** Start box and table *****/ + if (ItsANewGame) + Box_StartBoxTable (NULL,Txt_New_game,NULL, + Hlp_ASSESSMENT_Games_new_game,Box_NOT_CLOSABLE,2); + else + Box_StartBoxTable (NULL, + Game.Title[0] ? Game.Title : + Txt_Edit_game, + NULL, + Hlp_ASSESSMENT_Games_edit_game,Box_NOT_CLOSABLE,2); + + /***** Game title *****/ + fprintf (Gbl.F.Out,"" + "" + "" + "" + "" + "" + "" + "", + The_ClassFormInBox[Gbl.Prefs.Theme], + Txt_Title, + Gam_MAX_CHARS_TITLE,Game.Title); + + /***** Game text *****/ + fprintf (Gbl.F.Out,"" + "" + "" + "" + "" + "" + "" + ""); + + /***** End table, send button and end box *****/ + if (ItsANewGame) + Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_game); + else + Box_EndBoxTableWithButton (Btn_CONFIRM_BUTTON,Txt_Save_changes); + + /***** End form *****/ + Frm_EndForm (); + + /***** Show questions of the game ready to be edited *****/ + if (!ItsANewGame) + Gam_ListGameQuestions (&Game); } /*****************************************************************************/ @@ -1554,9 +1547,7 @@ static void Gam_ListGameQuestions (struct Game *Game) extern const char *Txt_This_game_has_no_questions; MYSQL_RES *mysql_res; unsigned NumQsts; - 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 - bool ICanEditGames = Gam_CheckIfICanEditGames (); + bool ICanEditQuestions = Gam_GetNumMchsGameAndCheckIfEditable (Game); /***** Get data of questions from database *****/ NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get data of a question", @@ -1574,19 +1565,19 @@ static void Gam_ListGameQuestions (struct Game *Game) /***** Start box *****/ Gam_SetParamCurrentGamCod (Game->GamCod); // Used to pass parameter - Box_StartBox (NULL,Txt_Questions,ICanEditGames ? Gam_PutIconToAddNewQuestions : - NULL, + Box_StartBox (NULL,Txt_Questions,ICanEditQuestions ? Gam_PutIconToAddNewQuestions : + NULL, Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE); if (NumQsts) /***** Show the table with the questions *****/ - Gam_ListOneOrMoreQuestionsForEdition (Game->GamCod,NumQsts,mysql_res); + Gam_ListOneOrMoreQuestionsForEdition (Game->GamCod,NumQsts,mysql_res, + ICanEditQuestions); else // This game has no questions Ale_ShowAlert (Ale_INFO,Txt_This_game_has_no_questions); - if (ICanEditGames && // I can edit - (!NumQsts || // This game has no questions - Editing)) // I am editing + if (ICanEditQuestions && // I can edit questions + !NumQsts) // This game has no questions /***** Put button to add a new question in this game *****/ Gam_PutButtonToAddNewQuestions (); @@ -1602,7 +1593,8 @@ static void Gam_ListGameQuestions (struct Game *Game) /*****************************************************************************/ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, - MYSQL_RES *mysql_res) + MYSQL_RES *mysql_res, + bool ICanEditQuestions) { extern const char *Txt_Questions; extern const char *Txt_No_INDEX; @@ -1617,7 +1609,6 @@ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, MYSQL_ROW row; unsigned QstInd; unsigned MaxQstInd; - long QstCod; char StrQstInd[10 + 1]; /***** Get maximum question index *****/ @@ -1671,7 +1662,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, QstInd); /* Get question code (row[1]) */ - QstCod = Str_ConvertStrCodToLongCod (row[1]); + Gbl.Test.QstCod = Str_ConvertStrCodToLongCod (row[1]); /***** Icons *****/ Gam_SetParamCurrentGamCod (GamCod); // Used to pass parameter @@ -1680,14 +1671,19 @@ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, "",Gbl.RowEvenOdd); /* Put icon to remove the question */ - Frm_StartForm (ActReqRemGamQst); - Gam_PutParams (); - Gam_PutParamQstInd (QstInd); - Ico_PutIconRemove (); - Frm_EndForm (); + if (ICanEditQuestions) + { + Frm_StartForm (ActReqRemGamQst); + Gam_PutParams (); + Gam_PutParamQstInd (QstInd); + Ico_PutIconRemove (); + Frm_EndForm (); + } + else + Ico_PutIconRemovalNotAllowed (); /* Put icon to move up the question */ - if (QstInd > 1) + if (ICanEditQuestions && QstInd > 1) { snprintf (Gbl.Title,sizeof (Gbl.Title), Txt_Move_up_X, @@ -1700,7 +1696,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, Ico_PutIconOff ("arrow-up.svg",Txt_Movement_not_allowed); /* Put icon to move down the question */ - if (QstInd < MaxQstInd) + if (ICanEditQuestions && QstInd < MaxQstInd) { snprintf (Gbl.Title,sizeof (Gbl.Title), Txt_Move_down_X, @@ -1713,8 +1709,8 @@ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts, Ico_PutIconOff ("arrow-down.svg",Txt_Movement_not_allowed); /* Put icon to edit the question */ - Gbl.Test.QstCod = QstCod; - Ico_PutContextualIconToEdit (ActEdiOneTstQst,Tst_PutParamQstCod); + if (ICanEditQuestions) + Ico_PutContextualIconToEdit (ActEdiOneTstQst,Tst_PutParamQstCod); fprintf (Gbl.F.Out,""); @@ -2181,20 +2177,17 @@ static void Gam_ExchangeQuestions (long GamCod, /*********** Get number of matches and check is edition is possible **********/ /*****************************************************************************/ // Games with matches should not be edited -// Return true if no matches (if game is editable) static bool Gam_GetNumMchsGameAndCheckIfEditable (struct Game *Game) { - extern const char *Txt_You_can_not_edit_a_game_with_matches; + /***** Get number of matches *****/ + Game->NumMchs = Mch_GetNumMchsInGame (Game->GamCod); - /***** Check if game has matches *****/ - if ((Game->NumMchs = Mch_GetNumMchsInGame (Game->GamCod))) - { - Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_edit_a_game_with_matches); - return false; // It has matches ==> it's not editable - } + if (Gam_CheckIfICanEditGames ()) + /***** Questions are editable only if game has no matches *****/ + return (bool) (Game->NumMchs == 0); else - return true; // It has no matches ==> it's editable + return false; // Questions are not editable } /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index 12a6c7c18..2d1dd7d68 100644 --- a/swad_text.c +++ b/swad_text.c @@ -54242,7 +54242,7 @@ const char *Txt_You_can_not_disable_file_uploading_once_folders_have_been_create "Você não pode desativar o upload de arquivos," " uma vez diretórios foram criados."; #endif - +/* const char *Txt_You_can_not_edit_a_game_with_matches = #if L==1 // ca "No es pot editar un joc amb partides."; @@ -54263,8 +54263,7 @@ const char *Txt_You_can_not_edit_a_game_with_matches = #elif L==9 // pt "Você não pode editar um jogo com partidas."; #endif - - +*/ const char *Txt_You_can_not_leave_empty_intermediate_answers = #if L==1 // ca "No puede dejar respuestas intermedias sin rellenar."; // Necessita traduccio