From cfe0560b60d857df9f3d8102b1b20006e1bfb916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 18 Jul 2019 22:10:54 +0200 Subject: [PATCH] Version18.136.1 --- css/swad18.136.css | 2 + swad_changelog.h | 3 +- swad_config.h | 2 +- swad_game.c | 124 ++++++++++++++++++++++++++++++--------------- swad_text.c | 42 +++++++++++++++ 5 files changed, 131 insertions(+), 42 deletions(-) diff --git a/css/swad18.136.css b/css/swad18.136.css index 086300253..59f6c43eb 100644 --- a/css/swad18.136.css +++ b/css/swad18.136.css @@ -2576,6 +2576,8 @@ a:hover img.CENTRE_PHOTO_SHOW box-sizing:border-box; display:table; width:100%; + padding-bottom:12pt; + font-size:18pt; border:1px solid pink; } .MATCH_TOP_LEFT diff --git a/swad_changelog.h b/swad_changelog.h index 017cab1e8..dd18777f6 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -458,10 +458,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.136 (2019-07-17)" +#define Log_PLATFORM_VERSION "SWAD 18.136.1 (2019-07-18)" #define CSS_FILE "swad18.136.css" #define JS_FILE "swad18.130.2.js" /* + Version 18.136.1: Jul 18, 2019 Changes in layout of match. (243853 lines) Version 18.136: Jul 18, 2019 Changes in layout of match. (243767 lines) Version 18.135.7: Jul 17, 2019 CSS refactoring and translation in match playing. (243699 lines) Version 18.135.6: Jul 17, 2019 Code refactoring in match playing. (243654 lines) diff --git a/swad_config.h b/swad_config.h index a55dbb8e8..a00767e37 100644 --- a/swad_config.h +++ b/swad_config.h @@ -503,7 +503,7 @@ #define Cfg_TIME_TO_REFRESH_TIMELINE ((time_t)( 2UL * 1000UL)) // Initial refresh period of social timeline in miliseconds // This delay is increased 1 second on each refresh -#define Cfg_SECONDS_TO_REFRESH_GAME 60 // Refresh period of game being played in seconds +#define Cfg_SECONDS_TO_REFRESH_GAME 1 // Refresh period of game being played in seconds #define Cfg_TIME_TO_REFRESH_GAME ((time_t)(Cfg_SECONDS_TO_REFRESH_GAME * 1000UL)) // Refresh period of game being played in miliseconds #define Cfg_TIME_TO_REFRESH_LAST_CLICKS ((time_t)( 1UL * 1000UL)) // Refresh period of last clicks in miliseconds diff --git a/swad_game.c b/swad_game.c index 4ca09fc9a..45f48b408 100644 --- a/swad_game.c +++ b/swad_game.c @@ -183,7 +183,7 @@ static void Gam_PutButtonNewMatch (long GamCod); static void Gam_PutFormNewMatch (struct Game *Game); static long Gam_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1]); -static void Gam_UpdateMatchStatus (struct Match *Match); +static void Gam_UpdateMatchStatusInDB (struct Match *Match); static void Gam_SetMatchStatusToNextQuestion (struct Match *Match); static void Gam_ShowMatchStatusForTch (struct Match *Match); @@ -192,6 +192,7 @@ static void Gam_ShowBottonLeftColumnTch (struct Match *Match); static void Gam_ShowQuestionAndAnswersTch (struct Match *Match); static void Gam_PutBigButton (Act_Action_t NextAction,long MchCod, const char *Icon,const char *Txt); +static void Gam_PutBigButtonClose (void); static void Gam_RemoveOldPlayers (void); static void Gam_UpdateMatchAsBeingPlayed (long MchCod); @@ -3265,6 +3266,10 @@ void Gam_RequestStartResumeMatchTch (void) { struct Match Match; + /***** Remove old players. + This function must be called before getting match status. *****/ + Gam_RemoveOldPlayers (); + /***** Get data of the match from database *****/ Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); @@ -3314,7 +3319,7 @@ static long Gam_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1]) /***************** Insert/update a game match being played *******************/ /*****************************************************************************/ -static void Gam_UpdateMatchStatus (struct Match *Match) +static void Gam_UpdateMatchStatusInDB (struct Match *Match) { /***** Update match status in database *****/ DB_QueryUPDATE ("can not update match being played", @@ -3348,6 +3353,10 @@ void Gam_ResumeMatchTch (void) { struct Match Match; + /***** Remove old players. + This function must be called before getting match status. *****/ + Gam_RemoveOldPlayers (); + /***** Get data of the match from database *****/ Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); @@ -3362,7 +3371,7 @@ void Gam_ResumeMatchTch (void) Match.Status.BeingPlayed = true; // Resume match /* Update match status in database */ - Gam_UpdateMatchStatus (&Match); + Gam_UpdateMatchStatusInDB (&Match); } /***** Show current match status *****/ @@ -3379,6 +3388,10 @@ void Gam_NextStatusMatchTch (void) { struct Match Match; + /***** Remove old players. + This function must be called before getting match status. *****/ + Gam_RemoveOldPlayers (); + /***** Get data of the match from database *****/ Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); @@ -3400,7 +3413,7 @@ void Gam_NextStatusMatchTch (void) } /* Update match status in database */ - Gam_UpdateMatchStatus (&Match); + Gam_UpdateMatchStatusInDB (&Match); } /***** Show current match status *****/ @@ -3465,11 +3478,10 @@ static void Gam_ShowMatchStatusForTch (struct Match *Match) /* Show left column */ Gam_ShowBottonLeftColumnTch (Match); - /* Bottom content */ - if (Match->Status.Finished) - /* Show alert */ - Gam_ShowAlertFinishedMatch (); - else if (Match->Status.BeingPlayed) + /* Show right column */ + fprintf (Gbl.F.Out,"
"); + if (!Match->Status.Finished && + Match->Status.BeingPlayed) { /* Show current question and possible answers */ Gam_ShowQuestionAndAnswersTch (Match); @@ -3477,6 +3489,7 @@ static void Gam_ShowMatchStatusForTch (struct Match *Match) /* Update match as being played */ Gam_UpdateMatchAsBeingPlayed (Match->MchCod); } + fprintf (Gbl.F.Out,"
"); /* End bottom container */ fprintf (Gbl.F.Out,""); @@ -3504,23 +3517,36 @@ static void Gam_ShowAlertFinishedMatch (void) static void Gam_ShowBottonLeftColumnTch (struct Match *Match) { - extern const char *Txt_Continue; + extern const char *Txt_End; + extern const char *Txt_Next_QUESTION; extern const char *Txt_Finish; + extern const char *Txt_Answers; extern const char *Txt_Start_match; extern const char *Txt_Resume_match; unsigned NxtQstInd; + unsigned NumQsts; /***** Start bottom left container *****/ fprintf (Gbl.F.Out,"
"); - if (Match->Status.BeingPlayed) - { - /***** Write number of question *****/ - fprintf (Gbl.F.Out,"
%u
", - Match->Status.QstInd); + /***** Write number of question *****/ + NumQsts = Gam_GetNumQstsGame (Match->GamCod); + fprintf (Gbl.F.Out,"
"); + if (Match->Status.Finished) + fprintf (Gbl.F.Out,"%s",Txt_End); + else + fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts); + fprintf (Gbl.F.Out,"
"); - /***** Put button to continue *****/ - fprintf (Gbl.F.Out,"
"); + /***** Button *****/ + fprintf (Gbl.F.Out,"
" + "
"); + if (Match->Status.Finished) + /* Put button to close browser tab */ + Gam_PutBigButtonClose (); + else if (Match->Status.BeingPlayed) + { + /* Put button to continue */ if (Match->Status.ShowingAnswers) { /* Get index of the next question */ @@ -3529,7 +3555,7 @@ static void Gam_ShowBottonLeftColumnTch (struct Match *Match) if (NxtQstInd) // Not last question /* Put button to show next question */ Gam_PutBigButton (ActNxtMchTch,Match->MchCod, - "step-forward.svg",Txt_Continue); + "step-forward.svg",Txt_Next_QUESTION); else // Last question /* Put button to finish */ Gam_PutBigButton (ActNxtMchTch,Match->MchCod, @@ -3538,20 +3564,17 @@ static void Gam_ShowBottonLeftColumnTch (struct Match *Match) else /* Put button to show answers */ Gam_PutBigButton (ActNxtMchTch,Match->MchCod, - "step-forward.svg",Txt_Continue); - fprintf (Gbl.F.Out,"
"); + "step-forward.svg",Txt_Answers); } else - { - fprintf (Gbl.F.Out,"
"); /* Put button to start / resume match */ Gam_PutBigButton (ActCurMchTch, Match->MchCod, "play.svg", Match->Status.QstInd == 0 ? Txt_Start_match : Txt_Resume_match); - fprintf (Gbl.F.Out,"
"); - } + fprintf (Gbl.F.Out,"
" + "
"); /***** End bottom left container *****/ fprintf (Gbl.F.Out,"
"); @@ -3582,8 +3605,6 @@ static void Gam_ShowQuestionAndAnswersTch (struct Match *Match) row = mysql_fetch_row (mysql_res); /***** Show question *****/ - fprintf (Gbl.F.Out,"
"); - /* Get answer type (row[0]) */ Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]); // TODO: Check that answer type is correct (unique choice) @@ -3607,26 +3628,30 @@ static void Gam_ShowQuestionAndAnswersTch (struct Match *Match) Match->Status.QstInd, Match->Status.QstCod, "MATCH_TCH_QST",false); // Don't show result - - fprintf (Gbl.F.Out,"
"); } /*****************************************************************************/ -/************************** Put a big button to start ************************/ +/*********************** Put a big button to do action ***********************/ /*****************************************************************************/ static void Gam_PutBigButton (Act_Action_t NextAction,long MchCod, const char *Icon,const char *Txt) { - /***** Start container for button *****/ - fprintf (Gbl.F.Out,"
"); - /***** Start form *****/ Frm_StartForm (NextAction); Gam_PutParamMatchCod (MchCod); /***** Put icon with link *****/ - Frm_LinkFormSubmit (Txt,"MATCH_TCH_CONTINUE ICO_HIGHLIGHT",NULL); + /* Submitting onmousedown instead of default onclick + is necessary in order to be fast + and not lose clicks due to refresh */ + fprintf (Gbl.F.Out,"", + Gbl.Form.Id); fprintf (Gbl.F.Out,"\"%s\"" "
" @@ -3638,13 +3663,32 @@ static void Gam_PutBigButton (Act_Action_t NextAction,long MchCod, /***** End form *****/ Frm_EndForm (); + } - /***** End container for button *****/ - fprintf (Gbl.F.Out,"
"); +static void Gam_PutBigButtonClose (void) + { + extern const char *Txt_Close; + + /***** Put icon with link *****/ + /* onmousedown instead of default onclick + is necessary in order to be fast + and not lose clicks due to refresh */ + fprintf (Gbl.F.Out,""); + fprintf (Gbl.F.Out,"\"%s\"" + "
" + "%s", + Cfg_URL_ICON_PUBLIC, + Txt_Close,Txt_Close, + Txt_Close); + fprintf (Gbl.F.Out,"
"); } /*****************************************************************************/ -/*********************** Get number of players in a match ********************/ +/**************************** Remove old players *****************************/ /*****************************************************************************/ static void Gam_RemoveOldPlayers (void) @@ -3708,9 +3752,6 @@ static void Gam_GetAndShowNumPlayersInMatch (long MchCod) extern const char *Txt_Players; unsigned NumPlayers; - /***** Remove old players *****/ - Gam_RemoveOldPlayers (); - /***** Get number of players (students who have joined this match) *****/ NumPlayers = Gam_GetNumPlayers (MchCod); @@ -3777,6 +3818,10 @@ void Gam_RefreshMatchTch (void) if (!Gbl.Session.IsOpen) // If session has been closed, do not write anything return; + /***** Remove old players. + This function must be called before getting match status. *****/ + Gam_RemoveOldPlayers (); + /***** Get data of the match from database *****/ Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); @@ -3837,7 +3882,6 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match) else // Unfinished match { /***** Update players ******/ - Gam_RemoveOldPlayers (); Gam_RegisterMeAsPlayerInMatch (Match->MchCod); if (Match->Status.BeingPlayed) diff --git a/swad_text.c b/swad_text.c index 6269d4cb4..fea97047f 100644 --- a/swad_text.c +++ b/swad_text.c @@ -10451,6 +10451,27 @@ const char *Txt_Email_X_removed = // Warning: it is very important to include %s "Email %s removido."; #endif +const char *Txt_End = +#if L==1 // ca + "Final"; +#elif L==2 // de + "Ende"; +#elif L==3 // en + "End"; +#elif L==4 // es + "Final"; +#elif L==5 // fr + "Fin"; +#elif L==6 // gn + "Paha"; +#elif L==7 // it + "Fine"; +#elif L==8 // pl + "Koniec"; +#elif L==9 // pt + "Fim"; +#endif + const char *Txt_End_date = #if L==1 // ca "Data final"; @@ -24380,6 +24401,27 @@ const char *Txt_NEW_YEAR_GREETING = // Warning: it is very important to include "Feliz %u!"; #endif +const char *Txt_Next_QUESTION = +#if L==1 // ca + "Següent"; +#elif L==2 // de + "Nächste"; +#elif L==3 // en + "Next"; +#elif L==4 // es + "Siguiente"; +#elif L==5 // fr + "Suivante"; +#elif L==6 // gn + "Siguiente"; // Okoteve traducción +#elif L==7 // it + "Successiva"; +#elif L==8 // pl + "Następne"; +#elif L==9 // pt + "Seguinte"; +#endif + const char *Txt_nick_email_or_ID = #if L==1 // ca "@sobrenom, correu o ID (DNI/cèdula)";