From fa3cb6f77d604e56611fa3a640230d7de9b7bd90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 30 Jul 2019 15:21:29 +0200 Subject: [PATCH] Version18.138 --- css/{swad18.136.4.css => swad18.138.css} | 54 ++++--- icon/step-backward.svg | 1 + icon/step-forward.svg | 2 +- icon/step-forward320x320.png | Bin 1127 -> 0 bytes icon/step-forward64x64.png | Bin 521 -> 0 bytes swad_action.c | 7 +- swad_action.h | 103 ++++++------ swad_changelog.h | 16 +- swad_game.c | 194 ++++++++++++++++++----- swad_game.h | 1 + swad_layout.c | 2 + swad_text.c | 21 +++ 12 files changed, 284 insertions(+), 117 deletions(-) rename css/{swad18.136.4.css => swad18.138.css} (99%) create mode 100644 icon/step-backward.svg delete mode 100644 icon/step-forward320x320.png delete mode 100644 icon/step-forward64x64.png diff --git a/css/swad18.136.4.css b/css/swad18.138.css similarity index 99% rename from css/swad18.136.4.css rename to css/swad18.138.css index 64e7b7eb..a8d133c4 100644 --- a/css/swad18.136.4.css +++ b/css/swad18.138.css @@ -2641,28 +2641,46 @@ a:hover img.CENTRE_PHOTO_SHOW font-size:16pt; } -.MATCH_TCH_NXT_CONTAINER +.MATCH_BUTTONS_CONTAINER { + box-sizing:border-box; + display:table; + width:100%; + background:pink; } + +.MATCH_BUTTON_LEFT_CONTAINER + { + box-sizing:border-box; + float:left; + width:50%; + margin:0 auto; + text-align:center; + border:1px solid red; + } +.MATCH_BUTTON_RIGHT_CONTAINER + { + box-sizing:border-box; + float:left; + width:50%; + margin:0 auto; + text-align:center; + border:1px solid blue; + } +.MATCH_BUTTON_RIGHT_CONTAINER a + { + text-decoration:none; + } +.MATCH_BUTTON + { + font-size:12pt; + } + .MATCH_TCH_QST { color:#202020; font-size:24pt; } -.MATCH_TCH_CONTINUE_CONTAINER - { - clear:all; - margin:0 auto; - text-align:center; - } -.MATCH_TCH_CONTINUE_CONTAINER a - { - text-decoration:none; - } -.MATCH_TCH_CONTINUE - { - font-size:16pt; - } .MATCH_STD_WAIT_CONTAINER { @@ -2675,11 +2693,6 @@ a:hover img.CENTRE_PHOTO_SHOW width:50%; } -.MATCH_STD_QST_CONTAINER - { - width:85%; - float:left; - } .MATCH_STD_QST { color:#202020; @@ -2706,6 +2719,7 @@ a:hover img.CENTRE_PHOTO_SHOW { text-align:center; vertical-align:middle; + border:1px solid green; } .MATCH_STD_BUTTON { diff --git a/icon/step-backward.svg b/icon/step-backward.svg new file mode 100644 index 00000000..0834346e --- /dev/null +++ b/icon/step-backward.svg @@ -0,0 +1 @@ + diff --git a/icon/step-forward.svg b/icon/step-forward.svg index 48ae0d8d..e6b9eb5b 100644 --- a/icon/step-forward.svg +++ b/icon/step-forward.svg @@ -1 +1 @@ - + diff --git a/icon/step-forward320x320.png b/icon/step-forward320x320.png deleted file mode 100644 index 336ec5299ec3cdb68d1d912cc8196b05ffc37781..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1127 zcmeAS@N?(olHy`uVBq!ia0y~yU~~Xs4i=zD`pjHKAjMhW5n0T@z%2~Ij105pNH8$4 zNP4v)N40Yvv%b+il5>KUsi}8whxmjBrLdh%VrDNVy9rF( zu&itARQ3&@n3_7ytC@w}JkyCtxv`TOqgx!F5G#d8utRC0Cd&iI7h)ZUJY zxH6%>=iWA}?e+e=oLw03uE+G=&-jOBf2&Ju?WXwrnD%wk{g|nR40*lA6XpxM8Ab8G zp0ZW%b@%nSgJ;VR)X#r+Hh1^7h$pLVFs6S^l3IGc_eRZT=D4GLJAUp?*zKMZ`lg}m z;MV%TTdlAE3uNecP*s~>v2L?1gW#1kCKmw*mZ{PTO$riOm&@y*m zVRQ-D$*9Dk&~%Ddz>z^PB(H&ksbfJAGeuf}#=T<%8^i!IhZSVA2H0XokiA@BYZ*Yc zGJz}=!K3s*+Ff^n1N+SRfa-t_CqX|$E6^$?4WJJN929|8F>ry52mpFdp}`60Dn=2Y zt2h=208K?z`kmZ#cy7@P|R9j^Ppef)8j)|F8g+K2ir80aE&d6R7lvKTs)tBR(Dm znF&?M1agQl(E5(~AnWm&304Yp1G-(r8Bxgya@Q$NkbS{^U<-?wKsHVh20FKl*Pg+8 z8_2U$gh0MpJ_qEj{WJNWur>Txd)xEy*1h@+kG7ZjORs%j(D8dq>-{@b0$Wceh}SVc zD&J{0b@%bh=RT~M!&9_8t$yb2uh)NGTw5{y)%^FH{OWzU8-iCqZ?1^Wb3gX2|J*md rUpK4s<80+}_7KjSz|8y4xt^i@T6MF2UBx|M$-&_1>gTe~DWM4fH~^A3 diff --git a/icon/step-forward64x64.png b/icon/step-forward64x64.png deleted file mode 100644 index c2ea54261652714a6fa58e2b26cdd77603f9b391..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 521 zcmV+k0`~ohP)HZ~qW-03WBZ7l?^u!$LqY$OnHcjmn?DfX|DW!~<$`Tiv^3p8ocWW8ev0QPII zKUzLR#ROF%c)ECfsE>SjJif>7?6Z2OvzL$m*Q@GN`a64BeJArwp5~Varh9%+wY~-b zwlK6=Uh1gC)r;SzI}!kZM&EXFZ^KLUBLe^sx;D#KP;*s#C7~D61$h8Khjd{T0Guue z0j!`4DtJP;3o2qpv#;ps8;<&YNTa08!Uu zE+GIw)H94OD1jntVst?QfYk*V07e(20RFlVnoYq!HchwoE8Qn8yUo0UP3|X-X(erqut9WV7Qk6 zV7ccjV7li5u-)?%2)O3}h`5heAmlz4K+Jud0zvmN0HW^06$rZz1rT>1rXb$^h6KPE zA?^z->=x6vfC6ge0q(a?>66MW6naC8X(;rC#mUl<12k#UWX"); Gam_ShowMatchStatusForTch (&Match); @@ -3359,7 +3363,10 @@ static void Gam_UpdateMatchStatusInDB (struct Match *Match) 'N', Match->MchCod,Gbl.Hierarchy.Crs.CrsCod); - if (Match->Status.Finished) + if (Match->Status.BeingPlayed) + /* Update match as being played */ + Gam_UpdateMatchAsBeingPlayed (Match->MchCod); + else /* Update match as not being played */ Gam_SetMatchAsNotBeingPlayed (Match->MchCod); } @@ -3388,11 +3395,48 @@ void Gam_ResumeMatchTch (void) Match.Status.ShowingAnswers = false; // Don't show answers in any case Match.Status.BeingPlayed = true; // Resume match - - /* Update match status in database */ - Gam_UpdateMatchStatusInDB (&Match); } + /***** Update match status in database *****/ + Gam_UpdateMatchStatusInDB (&Match); + + /***** Show current match status *****/ + fprintf (Gbl.F.Out,"
"); + Gam_ShowMatchStatusForTch (&Match); + fprintf (Gbl.F.Out,"
"); + } + +/*****************************************************************************/ +/* Show previous match status (previous question, answers...) (by a teacher) */ +/*****************************************************************************/ + +void Gam_PrevStatusMatchTch (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); + + /***** If not yet finished, update status *****/ + if (!Match.Status.Finished) + { + if (Match.Status.ShowingAnswers) // Showing answers currently + { + Match.Status.Finished = false; // Match is not finished + Match.Status.ShowingAnswers = false; // Do not show answers + } + else + Gam_SetMatchStatusToPrevQuestion (&Match); + } + + /***** Update match status in database *****/ + Gam_UpdateMatchStatusInDB (&Match); + /***** Show current match status *****/ fprintf (Gbl.F.Out,"
"); Gam_ShowMatchStatusForTch (&Match); @@ -3430,17 +3474,43 @@ void Gam_NextStatusMatchTch (void) Match.Status.ShowingAnswers = true; // Show answers } } - - /* Update match status in database */ - Gam_UpdateMatchStatusInDB (&Match); } + /***** Update match status in database *****/ + Gam_UpdateMatchStatusInDB (&Match); + /***** Show current match status *****/ fprintf (Gbl.F.Out,"
"); Gam_ShowMatchStatusForTch (&Match); fprintf (Gbl.F.Out,"
"); } +/*****************************************************************************/ +/******************* Set match status to previous question *******************/ +/*****************************************************************************/ + +static void Gam_SetMatchStatusToPrevQuestion (struct Match *Match) + { + /***** Get index of the previous question *****/ + Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, + Match->Status.QstInd); + + if (Match->Status.QstInd) // Not first question + { + Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod, + Match->Status.QstInd); + Match->Status.Finished = false; // Match is not finished + } + else // No previous question + { + Match->Status.QstCod = -1L; // No previous questions + Match->Status.BeingPlayed = false; // Match is not being played + Match->Status.Finished = false; // Match is not finished + } + + Match->Status.ShowingAnswers = false; // Don't show answers + } + /*****************************************************************************/ /********************* Set match status to next question *********************/ /*****************************************************************************/ @@ -3486,20 +3556,11 @@ static void Gam_ShowMatchStatusForTch (struct Match *Match) Gam_ShowMatchTitleAndPlayers (Match); /***** Bottom row *****/ - fprintf (Gbl.F.Out,"
"); - if (!Match->Status.Finished && Match->Status.BeingPlayed) - { /* Show current question and possible answers */ Gam_ShowQuestionAndAnswersTch (Match); - /* Update match as being played */ - Gam_UpdateMatchAsBeingPlayed (Match->MchCod); - } - - fprintf (Gbl.F.Out,"
"); - /* End right container */ fprintf (Gbl.F.Out,"
"); } @@ -3533,9 +3594,10 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match) Gam_ShowMatchTitleAndPlayers (Match); /***** Bottom row *****/ - fprintf (Gbl.F.Out,"
"); if (!Match->Status.Finished) { + fprintf (Gbl.F.Out,"
"); + /***** Update players ******/ Gam_RegisterMeAsPlayerInMatch (Match->MchCod); @@ -3551,8 +3613,9 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match) Cfg_URL_ICON_PUBLIC, Txt_Please_wait_, Txt_Please_wait_); + + fprintf (Gbl.F.Out,"
"); } - fprintf (Gbl.F.Out,"
"); /* End right container */ fprintf (Gbl.F.Out,""); @@ -3565,12 +3628,16 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match) static void Gam_ShowLeftColumnTch (struct Match *Match) { extern const char *Txt_End; + extern const char *Txt_Stem; + extern const char *Txt_Previous_QUESTION; + extern const char *Txt_Start; extern const char *Txt_Next_QUESTION; extern const char *Txt_Finish; extern const char *Txt_Answers; extern const char *Txt_Start; extern const char *Txt_Resume; - unsigned NxtQstInd; + unsigned PrvQstInd; // Previous question index + unsigned NxtQstInd; // Next question index unsigned NumQsts; unsigned NumAnswerers; @@ -3589,9 +3656,44 @@ static void Gam_ShowLeftColumnTch (struct Match *Match) fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts); fprintf (Gbl.F.Out,""); - /***** Button *****/ - fprintf (Gbl.F.Out,"
" - "
"); + /***** Buttons *****/ + /* Start buttons container */ + fprintf (Gbl.F.Out,"
"); + + /* Left button */ + fprintf (Gbl.F.Out,"
"); + if (!Match->Status.Finished) // Not finished + { + if (Match->Status.BeingPlayed) + { + /* Put button to go backward */ + if (Match->Status.ShowingAnswers) + /* Put button to start current question */ + Gam_PutBigButton (ActCurMchTch,Match->MchCod, + "step-backward.svg",Txt_Stem); + else + { + /* Get index of the previous question */ + PrvQstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, + Match->Status.QstInd); + if (PrvQstInd) // There is a previous question + /* Put button to show previous question */ + Gam_PutBigButton (ActPrvMchTch,Match->MchCod, + "step-backward.svg",Txt_Previous_QUESTION); + else // There is not a previous question + /* Put button to resume match before first question */ + Gam_PutBigButton (ActPrvMchTch,Match->MchCod, + "step-backward.svg",Txt_Start); + } + } + else // Not being played + /* Put button to close browser tab */ + Gam_PutBigButtonClose (); + } + fprintf (Gbl.F.Out,"
"); + + /* Right button */ + fprintf (Gbl.F.Out,"
"); if (Match->Status.Finished) /* Put button to close browser tab */ Gam_PutBigButtonClose (); @@ -3615,7 +3717,7 @@ static void Gam_ShowLeftColumnTch (struct Match *Match) else /* Put button to show answers */ Gam_PutBigButton (ActNxtMchTch,Match->MchCod, - "list.svg",Txt_Answers); + "step-forward.svg",Txt_Answers); } else /* Put button to start / resume match */ @@ -3624,8 +3726,10 @@ static void Gam_ShowLeftColumnTch (struct Match *Match) "play.svg", Match->Status.QstInd == 0 ? Txt_Start : Txt_Resume); - fprintf (Gbl.F.Out,"
" - "
"); + fprintf (Gbl.F.Out,"
"); + + /* End buttons container */ + fprintf (Gbl.F.Out,"
"); /***** Write number of users who have answered *****/ if (!Match->Status.Finished && @@ -3668,14 +3772,23 @@ static void Gam_ShowLeftColumnStd (struct Match *Match) fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts); fprintf (Gbl.F.Out,""); - /***** Button *****/ - fprintf (Gbl.F.Out,"
" - "
"); + /***** Buttons *****/ + /* Start buttons container */ + fprintf (Gbl.F.Out,"
"); + + /* Left button */ + fprintf (Gbl.F.Out,"
" + "
"); + + /* Right button */ + fprintf (Gbl.F.Out,"
"); if (Match->Status.Finished) /* Put button to close browser tab */ Gam_PutBigButtonClose (); - fprintf (Gbl.F.Out,"
" - "
"); + fprintf (Gbl.F.Out,"
"); + + /* End buttons container */ + fprintf (Gbl.F.Out,"
"); /***** End left container *****/ fprintf (Gbl.F.Out,""); @@ -3735,6 +3848,8 @@ static void Gam_ShowQuestionAndAnswersTch (struct Match *Match) Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]); // TODO: Check that answer type is correct (unique choice) + fprintf (Gbl.F.Out,"
"); + /* Write stem (row[1]) */ Tst_WriteQstStem (row[1],"MATCH_TCH_QST"); @@ -3754,6 +3869,8 @@ 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,"
"); } /*****************************************************************************/ @@ -3772,8 +3889,6 @@ static void Gam_ShowQuestionAndAnswersStd (struct Match *Match) bool ErrorInIndex = false; /***** Show question *****/ - fprintf (Gbl.F.Out,"
"); - /* Write buttons for answers? */ if (Match->Status.ShowingAnswers) { @@ -3864,8 +3979,6 @@ static void Gam_ShowQuestionAndAnswersStd (struct Match *Match) else Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game."); } - - fprintf (Gbl.F.Out,"
"); } /*****************************************************************************/ @@ -3885,7 +3998,7 @@ static void Gam_PutBigButton (Act_Action_t NextAction,long MchCod, and not lose clicks due to refresh */ fprintf (Gbl.F.Out,"", @@ -3913,7 +4026,7 @@ static void Gam_PutBigButtonClose (void) and not lose clicks due to refresh */ fprintf (Gbl.F.Out,""); fprintf (Gbl.F.Out,"\"%s\"" @@ -3946,7 +4059,7 @@ static void Gam_RemoveOldPlayers (void) static void Gam_UpdateMatchAsBeingPlayed (long MchCod) { - /***** Insert me as match player *****/ + /***** Insert match as being played *****/ DB_QueryREPLACE ("can not set match as being played", "REPLACE gam_mch_being_played (MchCod) VALUE (%ld)", MchCod); @@ -4055,12 +4168,11 @@ void Gam_RefreshMatchTch (void) Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); + /***** Update match status in database *****/ + Gam_UpdateMatchStatusInDB (&Match); + /***** Show current match status *****/ Gam_ShowMatchStatusForTch (&Match); - - /***** Update match as being played *****/ - if (Match.Status.BeingPlayed) - Gam_UpdateMatchAsBeingPlayed (Match.MchCod); } /*****************************************************************************/ diff --git a/swad_game.h b/swad_game.h index 558a2d94..0451de25 100644 --- a/swad_game.h +++ b/swad_game.h @@ -123,6 +123,7 @@ void Gam_RequestNewMatchTch (void); void Gam_CreateNewMatchTch (void); void Gam_RequestStartResumeMatchTch (void); void Gam_ResumeMatchTch (void); +void Gam_PrevStatusMatchTch (void); void Gam_NextStatusMatchTch (void); void Gam_ShowFinishedMatchResults (void); diff --git a/swad_layout.c b/swad_layout.c index 313059b0..993ba560 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -684,6 +684,7 @@ static void Lay_WriteScriptInit (void) break; case ActNewMchTch: case ActResMchTch: + case ActPrvMchTch: case ActCurMchTch: case ActNxtMchTch: case ActPlyMchStd: @@ -804,6 +805,7 @@ static void Lay_WriteScriptParamsAJAX (void) /* Parameters related with match refreshing (for teachers) */ case ActNewMchTch: case ActResMchTch: + case ActPrvMchTch: case ActCurMchTch: case ActNxtMchTch: fprintf (Gbl.F.Out,"var RefreshParamNxtActGam = \"act=%ld\";\n" diff --git a/swad_text.c b/swad_text.c index dd9829ea..0b9d5a09 100644 --- a/swad_text.c +++ b/swad_text.c @@ -29668,6 +29668,27 @@ const char *Txt_Presents = "Presentes"; #endif +const char *Txt_Previous_QUESTION = +#if L==1 // ca + "Anterior"; +#elif L==2 // de + "Vorherige"; +#elif L==3 // en + "Previous"; +#elif L==4 // es + "Anterior"; +#elif L==5 // fr + "Précédente"; +#elif L==6 // gn + "Anterior"; // Okoteve traducción +#elif L==7 // it + "Precedente"; +#elif L==8 // pl + "Poprzednie"; +#elif L==9 // pt + "Anterior"; +#endif + const char *Txt_Print = #if L==1 // ca "Imprimir";