Version18.136

This commit is contained in:
Antonio Cañas Vargas 2019-07-18 15:16:36 +02:00
parent 8826e77a50
commit f7d404a4fa
4 changed files with 155 additions and 85 deletions

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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,"<div class=\"MATCH_CONT\">");
fprintf (Gbl.F.Out,"<div id=\"game\" class=\"MATCH_CONT_TOP\">");
Gam_GetAndShowNumPlayersInMatch (Match.MchCod);
fprintf (Gbl.F.Out,"</div>");
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,"<div id=\"game\" class=\"MATCH_CONT\">");
Gam_ShowMatchStatusForTch (&Match);
fprintf (Gbl.F.Out,"</div>");
}
@ -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,"<div class=\"MATCH_CONT\">");
fprintf (Gbl.F.Out,"<div id=\"game\" class=\"MATCH_CONT_TOP\">");
Gam_GetAndShowNumPlayersInMatch (Match.MchCod);
fprintf (Gbl.F.Out,"</div>");
fprintf (Gbl.F.Out,"<div id=\"game\" class=\"MATCH_CONT\">");
Gam_ShowMatchStatusForTch (&Match);
fprintf (Gbl.F.Out,"</div>");
}
@ -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,"<div class=\"MATCH_CONT\">");
fprintf (Gbl.F.Out,"<div id=\"game\" class=\"MATCH_CONT_TOP\">");
Gam_GetAndShowNumPlayersInMatch (Match.MchCod);
fprintf (Gbl.F.Out,"</div>");
fprintf (Gbl.F.Out,"<div id=\"game\" class=\"MATCH_CONT\">");
Gam_ShowMatchStatusForTch (&Match);
fprintf (Gbl.F.Out,"</div>");
}
@ -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,"<div class=\"MATCH_TOP\">");
/* Left: Match title */
fprintf (Gbl.F.Out,"<div class=\"MATCH_TOP_LEFT\">"
"%s"
"</div>",
Match->Title);
/* Right: Number of players */
fprintf (Gbl.F.Out,"<div class=\"MATCH_TOP_RIGHT\">");
Gam_GetAndShowNumPlayersInMatch (Match->MchCod);
fprintf (Gbl.F.Out,"</div>");
/* End top container */
fprintf (Gbl.F.Out,"</div>");
/***** Bottom row *****/
/* Start bottom container */
fprintf (Gbl.F.Out,"<div class=\"MATCH_BOTTOM\">");
/* 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,"</div>");
}
/*****************************************************************************/
@ -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,"<div class=\"MATCH_BOTTOM_LEFT\">");
if (Match->Status.BeingPlayed)
{
/***** Write number of question *****/
fprintf (Gbl.F.Out,"<div class=\"MATCH_TCH_NUM_QST\">%u</div>",
Match->Status.QstInd);
/***** Put button to continue *****/
fprintf (Gbl.F.Out,"<div class=\"MATCH_TCH_NXT_CONTAINER\">");
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,"</div>");
}
else
{
fprintf (Gbl.F.Out,"<div class=\"MATCH_TCH_NXT_CONTAINER\">");
/* 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,"</div>");
}
/***** End bottom left container *****/
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/***** 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,"<div class=\"MATCH_TCH_NUM_QST\">%u</div>",
Match->Status.QstInd);
fprintf (Gbl.F.Out,"<div class=\"MATCH_TCH_QST_CONTAINER\">");
fprintf (Gbl.F.Out,"<div class=\"MATCH_BOTTOM_RIGHT\">");
/* 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,"</div>");
/***** Put button to continue *****/
fprintf (Gbl.F.Out,"<div class=\"MATCH_TCH_NXT_CONTAINER\">");
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,"</div>");
}
/*****************************************************************************/
@ -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)