From 03a88663d5ae92f6f3558d52f8b201df733da092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 30 May 2019 13:46:57 +0200 Subject: [PATCH] Version18.126.2 --- swad_changelog.h | 3 +- swad_game.c | 75 ++++++++++++++++++++++++++++++++++++++---------- swad_text.c | 21 ++++++++++++++ 3 files changed, 83 insertions(+), 16 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 01680a2c7..da36f894d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -453,10 +453,11 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.126.1 (2019-05-29)" +#define Log_PLATFORM_VERSION "SWAD 18.126.2 (2019-05-29)" #define CSS_FILE "swad18.123.css" #define JS_FILE "swad18.123.js" /* + Version 18.126.2: May 30, 2019 New column in list of matches for match status. (? lines) Version 18.126.1: May 30, 2019 New option to resume an unfinished match. (243415 lines) 11 changes necessary in database: UPDATE actions SET Txt='Preparar partida (como profesor)' WHERE ActCod='1670' AND Language='es'; diff --git a/swad_game.c b/swad_game.c index 0464192c1..0679a3557 100644 --- a/swad_game.c +++ b/swad_game.c @@ -146,6 +146,7 @@ static void Gam_RemAnswersOfAQuestion (long GamCod,unsigned QstInd); static long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd); static unsigned Gam_GetMaxQuestionIndexInGame (long GamCod); +static unsigned Gam_GetFirstQuestionIndexInGame (long GamCod); static unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd); static unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd); static void Gam_ListGameQuestions (struct Game *Game); @@ -2047,11 +2048,21 @@ static unsigned Gam_GetMaxQuestionIndexInGame (long GamCod) return QstInd; } +/*****************************************************************************/ +/******************** Get first question index in a game *********************/ +/*****************************************************************************/ + +static unsigned Gam_GetFirstQuestionIndexInGame (long GamCod) + { + return Gam_GetNextQuestionIndexInGame (GamCod, + 0); // First index > 0 + } + /*****************************************************************************/ /*********** Get previous question index to a given index in a game **********/ /*****************************************************************************/ -// Question index can be 1, 2, 3... -// Return 0 if no previous question +// Input question index can be 1, 2, 3... n-1 +// Return question index will be 1, 2, 3... n if previous question exists, or 0 if no previous question static unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd) { @@ -2083,8 +2094,8 @@ static unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd) /*****************************************************************************/ /************* Get next question index to a given index in a game ************/ /*****************************************************************************/ -// Question index can be 1, 2, 3... -// Return 0 if no next question +// Input question index can be 0, 1, 2, 3... n-1 +// Return question index will be 1, 2, 3... n if next question exists, or 0 if no next question static unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd) { @@ -2996,8 +3007,10 @@ static void Gam_ListOneOrMoreMatchesForEdition (unsigned NumMatches, extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME]; extern const char *Txt_Match; + extern const char *Txt_Status; extern const char *Txt_Resume; extern const char *Txt_Today; + extern const char *Txt_Finished_match; unsigned NumMatch; unsigned UniqueId; struct Match Match; @@ -3021,12 +3034,16 @@ static void Gam_ListOneOrMoreMatchesForEdition (unsigned NumMatches, "" "%s" "" + "" + "%s" + "" "", Txt_No_INDEX, Txt_ROLES_SINGUL_Abc[Rol_TCH][Usr_SEX_UNKNOWN], Txt_START_END_TIME[Gam_ORDER_BY_START_DATE], Txt_START_END_TIME[Gam_ORDER_BY_END_DATE], - Txt_Match); + Txt_Match, + Txt_Status); /***** Write rows *****/ for (NumMatch = 0, UniqueId = 1; @@ -3061,11 +3078,8 @@ static void Gam_ListOneOrMoreMatchesForEdition (unsigned NumMatches, fprintf (Gbl.F.Out,""); /***** Number of match ******/ - fprintf (Gbl.F.Out,"" - "
%u
" - "", - Gbl.RowEvenOdd, - NumMatch + 1); + fprintf (Gbl.F.Out,"%u", + Gbl.RowEvenOdd,NumMatch + 1); /***** Match player *****/ fprintf (Gbl.F.Out,"", @@ -3116,6 +3130,20 @@ static void Gam_ListOneOrMoreMatchesForEdition (unsigned NumMatches, fprintf (Gbl.F.Out,""); + /***** Match status ******/ + fprintf (Gbl.F.Out,"",Gbl.RowEvenOdd); + if (Match.Status.Finished) + Ico_PutIconOff ("flag-checkered.svg",Txt_Finished_match); + else // Unfinished match + { + Gam_CurrentMchCod = Match.MchCod; + Lay_PutContextualLinkOnlyIcon (ActResMch,NULL, + Gam_PutParamCurrentMchCod, + "play.svg", + Txt_Resume); + } + fprintf (Gbl.F.Out,""); + fprintf (Gbl.F.Out,""); } @@ -3439,6 +3467,7 @@ static void Gam_PutBigButtonToPlayMatchStd (long MchCod) void Gam_CreateAndStartNewMatch (void) { struct Match Match; + unsigned QstInd; /***** Get form parameters *****/ /* Get game code */ @@ -3458,8 +3487,9 @@ void Gam_CreateAndStartNewMatch (void) Grp_FreeListCodSelectedGrps (); /***** Show questions and possible answers *****/ + QstInd = Gam_GetFirstQuestionIndexInGame (Match.GamCod); Gam_PlayGameShowQuestionAndAnswers (Match.MchCod, - 0, // First question (index is 0) + QstInd, // First question false); // Don't show answers } @@ -3496,7 +3526,9 @@ static long Gam_CreateMatch (struct Match *Match) void Gam_ResumeUnfinishedMatch (void) { + extern const char *Txt_Finished_match; struct Match Match; + unsigned QstInd; /***** Get parameters *****/ /* Get match code */ @@ -3509,16 +3541,28 @@ void Gam_ResumeUnfinishedMatch (void) if (Match.Status.Finished) { /***** Show alert *****/ - Ale_ShowAlert (Ale_WARNING,"Partida finalizada."); // TODO: Need translation!!!!! + Ale_ShowAlert (Ale_WARNING,Txt_Finished_match); /***** Button to close browser tab *****/ Btn_PutCloseButton ("Cerrar"); // TODO: Need translation!!!!! } else // Unfinished match + { + /***** In what question do we resume the match? *****/ + if (Match.Status.QstInd == 0) + /* If current question index is 0 ==> + start playing the first question */ + QstInd = Gam_GetFirstQuestionIndexInGame (Match.GamCod); + else + /* If current question index is >0 ==> + show again current question, without answers */ + QstInd = Match.Status.QstInd; + /***** Show questions and possible answers *****/ Gam_PlayGameShowQuestionAndAnswers (Match.MchCod, - Match.Status.QstInd, // Resume last question index shown - Match.Status.ShowAnswers); // Show answers? + QstInd, + false); // Don't show answers + } } /*****************************************************************************/ @@ -3766,6 +3810,7 @@ static void Gam_PutBigButtonToFinishMatch (long MchCod) void Gam_MatchTchEnd (void) { + extern const char *Txt_Finished_match; long MchCod; /***** Get match code *****/ @@ -3783,7 +3828,7 @@ void Gam_MatchTchEnd (void) MchCod,Gbl.Hierarchy.Crs.CrsCod); /***** Show alert *****/ - Ale_ShowAlert (Ale_INFO,"Partida finalizada."); // TODO: Need translation!!!!! + Ale_ShowAlert (Ale_INFO,Txt_Finished_match); /***** Button to close browser tab *****/ Btn_PutCloseButton ("Cerrar"); // TODO: Need translation!!!!! diff --git a/swad_text.c b/swad_text.c index a0ffc5ac6..ee80a59d4 100644 --- a/swad_text.c +++ b/swad_text.c @@ -12247,6 +12247,27 @@ const char *Txt_Finish = "Terminar"; #endif +const char *Txt_Finished_match = +#if L==1 // ca + "Partida finalitzada"; +#elif L==2 // de + "Spiel beendet"; +#elif L==3 // en + "Finished match"; +#elif L==4 // es + "Partida finalizada"; +#elif L==5 // fr + "Match terminé"; +#elif L==6 // gn + "Partida finalizada"; // Okoteve traducción +#elif L==7 // it + "Partita finita"; +#elif L==8 // pl + "Zakończony mecz"; +#elif L==9 // pt + "Jogo terminado"; +#endif + const char *Txt_First_day_of_the_week = #if L==1 // ca "Primer dia de la setmana";