diff --git a/css/swad18.135.7.css b/css/swad18.136.css similarity index 99% rename from css/swad18.135.7.css rename to css/swad18.136.css index 375e28000..086300253 100644 --- a/css/swad18.135.7.css +++ b/css/swad18.136.css @@ -2571,29 +2571,65 @@ a:hover img.CENTRE_PHOTO_SHOW margin:5%; width:90%; } -.MATCH_CONT_TOP +.MATCH_TOP { box-sizing:border-box; + display:table; + width:100%; + border:1px solid pink; + } +.MATCH_TOP_LEFT + { + box-sizing:border-box; + float:left; + width:80%; + white-space:nowrap; + overflow:hidden; + text-overflow:ellipsis; + border:1px solid red; + } +.MATCH_TOP_RIGHT + { + box-sizing:border-box; + float:left; + width:20%; + text-align:right; + border:1px solid blue; + } +.MATCH_BOTTOM + { + box-sizing:border-box; + width:100%; + border:1px solid pink; + } +.MATCH_BOTTOM_LEFT + { + box-sizing:border-box; + float:left; + width:20%; + white-space:nowrap; + overflow:hidden; + text-overflow:ellipsis; + border:1px solid red; + } +.MATCH_BOTTOM_RIGHT + { + box-sizing:border-box; + float:left; + width:80%; + border:1px solid blue; } .MATCH_TCH_NUM_QST { - width:15%; - float:left; + text-align:center; padding-bottom:24pt; color:#808080; font-size:48pt; font-weight:bold; } -.MATCH_TCH_QST_CONTAINER - { - width:70%; - float:left; - } .MATCH_TCH_NXT_CONTAINER { - width:15%; - float:left; } .MATCH_TCH_QST { @@ -2603,6 +2639,7 @@ a:hover img.CENTRE_PHOTO_SHOW .MATCH_TCH_CONTINUE_CONTAINER { clear:all; + margin:0 auto; text-align:center; } .MATCH_TCH_CONTINUE_CONTAINER a diff --git a/swad_changelog.h b/swad_changelog.h index e7fc4a213..017cab1e8 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.135.7 (2019-07-17)" -#define CSS_FILE "swad18.135.7.css" +#define Log_PLATFORM_VERSION "SWAD 18.136 (2019-07-17)" +#define CSS_FILE "swad18.136.css" #define JS_FILE "swad18.130.2.js" /* + 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) Version 18.135.5: Jul 17, 2019 Changes while removing a match. (243692 lines) diff --git a/swad_config.h b/swad_config.h index a00767e37..a55dbb8e8 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 1 // Refresh period of game being played in seconds +#define Cfg_SECONDS_TO_REFRESH_GAME 60 // 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 0333f8fe0..4ca09fc9a 100644 --- a/swad_game.c +++ b/swad_game.c @@ -183,12 +183,13 @@ 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_UpdateMatchBeingPlayed (struct Match *Match); +static void Gam_UpdateMatchStatus (struct Match *Match); static void Gam_SetMatchStatusToNextQuestion (struct Match *Match); static void Gam_ShowMatchStatusForTch (struct Match *Match); static void Gam_ShowAlertFinishedMatch (void); -static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match); +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); @@ -3262,8 +3263,6 @@ void Gam_CreateNewMatchTch (void) void Gam_RequestStartResumeMatchTch (void) { - extern const char *Txt_Start_match; - extern const char *Txt_Resume_match; struct Match Match; /***** Get data of the match from database *****/ @@ -3271,22 +3270,8 @@ void Gam_RequestStartResumeMatchTch (void) Gam_GetDataOfMatchByCod (&Match); /***** Show current match status *****/ - fprintf (Gbl.F.Out,"
"); - - fprintf (Gbl.F.Out,"
"); - Gam_GetAndShowNumPlayersInMatch (Match.MchCod); - fprintf (Gbl.F.Out,"
"); - - if (Match.Status.Finished) - Gam_ShowAlertFinishedMatch (); - else // Unfinished match - /***** 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,"
"); + Gam_ShowMatchStatusForTch (&Match); fprintf (Gbl.F.Out,"
"); } @@ -3329,7 +3314,7 @@ static long Gam_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1]) /***************** Insert/update a game match being played *******************/ /*****************************************************************************/ -static void Gam_UpdateMatchBeingPlayed (struct Match *Match) +static void Gam_UpdateMatchStatus (struct Match *Match) { /***** Update match status in database *****/ DB_QueryUPDATE ("can not update match being played", @@ -3374,20 +3359,15 @@ void Gam_ResumeMatchTch (void) Gam_SetMatchStatusToNextQuestion (&Match); Match.Status.ShowingAnswers = false; // Don't show answers in any case + Match.Status.BeingPlayed = true; // Resume match /* Update match status in database */ - Gam_UpdateMatchBeingPlayed (&Match); + Gam_UpdateMatchStatus (&Match); } /***** Show current match status *****/ - fprintf (Gbl.F.Out,"
"); - - fprintf (Gbl.F.Out,"
"); - Gam_GetAndShowNumPlayersInMatch (Match.MchCod); - fprintf (Gbl.F.Out,"
"); - + fprintf (Gbl.F.Out,"
"); Gam_ShowMatchStatusForTch (&Match); - fprintf (Gbl.F.Out,"
"); } @@ -3420,18 +3400,12 @@ void Gam_NextStatusMatchTch (void) } /* Update match status in database */ - Gam_UpdateMatchBeingPlayed (&Match); + Gam_UpdateMatchStatus (&Match); } /***** Show current match status *****/ - fprintf (Gbl.F.Out,"
"); - - fprintf (Gbl.F.Out,"
"); - Gam_GetAndShowNumPlayersInMatch (Match.MchCod); - fprintf (Gbl.F.Out,"
"); - + fprintf (Gbl.F.Out,"
"); Gam_ShowMatchStatusForTch (&Match); - fprintf (Gbl.F.Out,"
"); } @@ -3466,18 +3440,46 @@ static void Gam_SetMatchStatusToNextQuestion (struct Match *Match) static void Gam_ShowMatchStatusForTch (struct Match *Match) { - /***** Show current match status *****/ + /***** Top row *****/ + /* Start top container */ + fprintf (Gbl.F.Out,"
"); + + /* Left: Match title */ + fprintf (Gbl.F.Out,"
" + "%s" + "
", + Match->Title); + + /* Right: Number of players */ + fprintf (Gbl.F.Out,"
"); + Gam_GetAndShowNumPlayersInMatch (Match->MchCod); + fprintf (Gbl.F.Out,"
"); + + /* End top container */ + fprintf (Gbl.F.Out,"
"); + + /***** Bottom row *****/ + /* Start bottom container */ + fprintf (Gbl.F.Out,"
"); + + /* Show left column */ + Gam_ShowBottonLeftColumnTch (Match); + + /* Bottom content */ if (Match->Status.Finished) /* Show alert */ Gam_ShowAlertFinishedMatch (); - else // Unfinished match + else if (Match->Status.BeingPlayed) { /* Show current question and possible answers */ - Gam_PlayGameShowQuestionAndAnswers (Match); + Gam_ShowQuestionAndAnswersTch (Match); /* Update match as being played */ Gam_UpdateMatchAsBeingPlayed (Match->MchCod); } + + /* End bottom container */ + fprintf (Gbl.F.Out,"
"); } /*****************************************************************************/ @@ -3497,16 +3499,72 @@ static void Gam_ShowAlertFinishedMatch (void) } /*****************************************************************************/ -/*********** Show question and its answers when playing a match **************/ +/******** Show left botton column when playing a match (as a teacher) ********/ /*****************************************************************************/ -static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match) +static void Gam_ShowBottonLeftColumnTch (struct Match *Match) { extern const char *Txt_Continue; extern const char *Txt_Finish; + extern const char *Txt_Start_match; + extern const char *Txt_Resume_match; + unsigned NxtQstInd; + + /***** Start bottom left container *****/ + fprintf (Gbl.F.Out,"
"); + + if (Match->Status.BeingPlayed) + { + /***** Write number of question *****/ + fprintf (Gbl.F.Out,"
%u
", + Match->Status.QstInd); + + /***** Put button to continue *****/ + fprintf (Gbl.F.Out,"
"); + if (Match->Status.ShowingAnswers) + { + /* Get index of the next question */ + NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, + Match->Status.QstInd); + if (NxtQstInd) // Not last question + /* Put button to show next question */ + Gam_PutBigButton (ActNxtMchTch,Match->MchCod, + "step-forward.svg",Txt_Continue); + else // Last question + /* Put button to finish */ + Gam_PutBigButton (ActNxtMchTch,Match->MchCod, + "flag-checkered.svg",Txt_Finish); + } + else + /* Put button to show answers */ + Gam_PutBigButton (ActNxtMchTch,Match->MchCod, + "step-forward.svg",Txt_Continue); + fprintf (Gbl.F.Out,"
"); + } + 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,"
"); + } + + /***** End bottom left container *****/ + fprintf (Gbl.F.Out,"
"); + } + +/*****************************************************************************/ +/***** Show question and its answers when playing a match (as a teacher) *****/ +/*****************************************************************************/ + +static void Gam_ShowQuestionAndAnswersTch (struct Match *Match) + { MYSQL_RES *mysql_res; MYSQL_ROW row; - unsigned NxtQstInd; /***** Trivial check: Question index should be > 0 *****/ if (Match->Status.QstInd == 0) @@ -3524,11 +3582,7 @@ static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match) row = mysql_fetch_row (mysql_res); /***** Show question *****/ - /* Write number of question */ - fprintf (Gbl.F.Out,"
%u
", - Match->Status.QstInd); - - fprintf (Gbl.F.Out,"
"); + fprintf (Gbl.F.Out,"
"); /* Get answer type (row[0]) */ Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]); @@ -3555,28 +3609,6 @@ static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match) "MATCH_TCH_QST",false); // Don't show result fprintf (Gbl.F.Out,"
"); - - /***** Put button to continue *****/ - fprintf (Gbl.F.Out,"
"); - if (Match->Status.ShowingAnswers) - { - /* Get index of the next question */ - NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, - Match->Status.QstInd); - if (NxtQstInd) // Not last question - /* Put button to show next question */ - Gam_PutBigButton (ActNxtMchTch,Match->MchCod, - "step-forward.svg",Txt_Continue); - else // Last question - /* Put button to finish */ - Gam_PutBigButton (ActNxtMchTch,Match->MchCod, - "flag-checkered.svg",Txt_Finish); - } - else - /* Put button to show answers */ - Gam_PutBigButton (ActNxtMchTch,Match->MchCod, - "step-forward.svg",Txt_Continue); - fprintf (Gbl.F.Out,"
"); } /*****************************************************************************/ @@ -3749,8 +3781,8 @@ void Gam_RefreshMatchTch (void) Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); - /***** Get and show number of players *****/ - Gam_GetAndShowNumPlayersInMatch (Match.MchCod); + /***** Show current match status *****/ + Gam_ShowMatchStatusForTch (&Match); /***** Update match as being played *****/ if (Match.Status.BeingPlayed)