Version19.2

This commit is contained in:
Antonio Cañas Vargas 2019-09-14 19:46:26 +02:00
parent 9d4d1da3ec
commit 2b1f20f48a
9 changed files with 168 additions and 103 deletions

View File

@ -2647,6 +2647,7 @@ a:hover img.CENTRE_PHOTO_SHOW
display:table; display:table;
box-sizing:border-box; box-sizing:border-box;
width:100%; width:100%;
padding:20px 0;
} }
.MATCH_BUTTON_LEFT_CONTAINER .MATCH_BUTTON_LEFT_CONTAINER
{ {
@ -2675,7 +2676,7 @@ a:hover img.CENTRE_PHOTO_SHOW
box-sizing:border-box; box-sizing:border-box;
display:table; display:table;
width:100%; width:100%;
height:128px; height:64px;
font-size:36pt; font-size:36pt;
} }
.MATCH_BUTTON_CONTAINER a .MATCH_BUTTON_CONTAINER a
@ -2718,7 +2719,7 @@ a:hover img.CENTRE_PHOTO_SHOW
.MATCH_WAIT_IMAGE .MATCH_WAIT_IMAGE
{ {
box-sizing:border-box; box-sizing:border-box;
width:50%; width:25%;
} }
.MATCH_STD_QST .MATCH_STD_QST

View File

@ -639,7 +639,8 @@ CREATE TABLE IF NOT EXISTS gam_matches (
QstInd INT NOT NULL DEFAULT 0, QstInd INT NOT NULL DEFAULT 0,
QstCod INT NOT NULL DEFAULT -1, QstCod INT NOT NULL DEFAULT -1,
QstStartTime DATETIME NOT NULL, QstStartTime DATETIME NOT NULL,
Showing ENUM('wording','answers','request','results') NOT NULL DEFAULT 'wording', ShowResults ENUM('N','Y') NOT NULL DEFAULT 'N',
Showing ENUM('wording','answers','results') NOT NULL DEFAULT 'wording',
UNIQUE INDEX(MchCod), UNIQUE INDEX(MchCod),
INDEX(GamCod)); INDEX(GamCod));
-- --

View File

@ -617,7 +617,7 @@ Assessment:
NEW. ActBckMchTch Go back when playing a match (by a teacher) NEW. ActBckMchTch Go back when playing a match (by a teacher)
457. ActFwdMchTch Go forward when playing a match (by a teacher) 457. ActFwdMchTch Go forward when playing a match (by a teacher)
NEW. ActShoResMchTch Show results when playing a match (by a teacher) NEW. ActChgDisResMchTch Change display of results when playing a match (by a teacher)
NEW. ActRefMchTch Refresh current question when playing a match (as teacher) NEW. ActRefMchTch Refresh current question when playing a match (as teacher)
NEW. ActShoMchTch Show finished match results NEW. ActShoMchTch Show finished match results
@ -2162,7 +2162,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActPlyMchTch */{1789,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ResumeMatchTch ,NULL}, /* ActPlyMchTch */{1789,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ResumeMatchTch ,NULL},
/* ActBckMchTch */{1790,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_BackMatchTch ,NULL}, /* ActBckMchTch */{1790,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_BackMatchTch ,NULL},
/* ActFwdMchTch */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ForwardMatchTch ,NULL}, /* ActFwdMchTch */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ForwardMatchTch ,NULL},
/* ActShoResMchTch */{1795,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ShowResultsQstMatchTch ,NULL}, /* ActChgDisResMchTch*/{1794,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ToggleDisplayResultsMatchTch,NULL},
/* ActRefMchTch */{1788,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Mch_GetMatchBeingPlayed ,Mch_RefreshMatchTch ,NULL}, /* ActRefMchTch */{1788,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Mch_GetMatchBeingPlayed ,Mch_RefreshMatchTch ,NULL},
/* ActShoMchTch */{1786,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_ShowFinishedMatchResults ,NULL}, /* ActShoMchTch */{1786,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_ShowFinishedMatchResults ,NULL},
@ -5014,8 +5014,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActPauMchTch, // #1791 ActPauMchTch, // #1791
-1, // #1792 (obsolete action) -1, // #1792 (obsolete action)
-1, // #1793 (obsolete action) -1, // #1793 (obsolete action)
-1, // #1794 (obsolete action) ActChgDisResMchTch, // #1794
ActShoResMchTch, // #1795
}; };
/*****************************************************************************/ /*****************************************************************************/

View File

@ -66,7 +66,7 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define Act_NUM_ACTIONS (1 + 4 + 64 + 38 + 12 + 42 + 36 + 19 + 110 + 173 + 437 + 176 + 169 + 16 + 68) #define Act_NUM_ACTIONS (1 + 4 + 64 + 38 + 12 + 42 + 36 + 19 + 110 + 173 + 437 + 176 + 169 + 16 + 68)
#define Act_MAX_ACTION_COD 1795 #define Act_MAX_ACTION_COD 1794
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
@ -616,7 +616,7 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActPlyMchTch (ActChgCrsTT1stDay + 123) #define ActPlyMchTch (ActChgCrsTT1stDay + 123)
#define ActBckMchTch (ActChgCrsTT1stDay + 124) #define ActBckMchTch (ActChgCrsTT1stDay + 124)
#define ActFwdMchTch (ActChgCrsTT1stDay + 125) #define ActFwdMchTch (ActChgCrsTT1stDay + 125)
#define ActShoResMchTch (ActChgCrsTT1stDay + 126) #define ActChgDisResMchTch (ActChgCrsTT1stDay + 126)
#define ActRefMchTch (ActChgCrsTT1stDay + 127) #define ActRefMchTch (ActChgCrsTT1stDay + 127)
#define ActShoMchTch (ActChgCrsTT1stDay + 128) #define ActShoMchTch (ActChgCrsTT1stDay + 128)
#define ActPlyMchStd (ActChgCrsTT1stDay + 129) #define ActPlyMchStd (ActChgCrsTT1stDay + 129)

View File

@ -460,10 +460,19 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.1 (2019-09-14)" #define Log_PLATFORM_VERSION "SWAD 19.2 (2019-09-14)"
#define CSS_FILE "swad18.138.css" #define CSS_FILE "swad18.138.css"
#define JS_FILE "swad18.130.2.js" #define JS_FILE "swad18.130.2.js"
/* /*
Version 19.2: Sep 14, 2019 Changes in match buttons. (244627 lines)
6 changes necessary in database:
ALTER TABLE gam_matches DROP COLUMN Showing;
ALTER TABLE gam_matches ADD COLUMN ShowResults ENUM('N','Y') NOT NULL DEFAULT 'N' AFTER QstStartTime;
ALTER TABLE gam_matches ADD COLUMN Showing ENUM('wording','answers','results') NOT NULL DEFAULT 'wording' AFTER ShowResults;
DELETE FROM actions WHERE ActCod='1794';
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1794','es','N','Cambiar presentación de resultados en partida (como profesor)');
UPDATE actions SET Obsolete='Y' WHERE ActCod=1795;
Version 19.1: Sep 14, 2019 Game module splitted into game and match modules. (244572 lines) Version 19.1: Sep 14, 2019 Game module splitted into game and match modules. (244572 lines)
Version 19.0.1: Sep 13, 2019 Show results of questions in matches. (244583 lines) Version 19.0.1: Sep 13, 2019 Show results of questions in matches. (244583 lines)
Version 19.0: Sep 12, 2019 Changes in behaviour of matches. (244585 lines) Version 19.0: Sep 12, 2019 Changes in behaviour of matches. (244585 lines)

View File

@ -1369,9 +1369,9 @@ mysql> DESCRIBE gam_grp;
/***** Table gam_matches *****/ /***** Table gam_matches *****/
/* /*
mysql> DESCRIBE gam_matches; mysql> DESCRIBE gam_matches;
+--------------+-----------------------------------------------+------+-----+---------+----------------+ +--------------+-------------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+--------------+-----------------------------------------------+------+-----+---------+----------------+ +--------------+-------------------------------------+------+-----+---------+----------------+
| MchCod | int(11) | NO | PRI | NULL | auto_increment | | MchCod | int(11) | NO | PRI | NULL | auto_increment |
| GamCod | int(11) | NO | MUL | NULL | | | GamCod | int(11) | NO | MUL | NULL | |
| UsrCod | int(11) | NO | | NULL | | | UsrCod | int(11) | NO | | NULL | |
@ -1381,9 +1381,10 @@ mysql> DESCRIBE gam_matches;
| QstInd | int(11) | NO | | 0 | | | QstInd | int(11) | NO | | 0 | |
| QstCod | int(11) | NO | | -1 | | | QstCod | int(11) | NO | | -1 | |
| QstStartTime | datetime | NO | | NULL | | | QstStartTime | datetime | NO | | NULL | |
| Showing | enum('wording','answers','request','results') | NO | | wording | | | ShowResults | enum('N','Y') | NO | | N | |
+--------------+-----------------------------------------------+------+-----+---------+----------------+ | Showing | enum('wording','answers','results') | NO | | wording | |
10 rows in set (0.00 sec) +--------------+-------------------------------------+------+-----+---------+----------------+
11 rows in set (0.01 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_matches (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_matches ("
"MchCod INT NOT NULL AUTO_INCREMENT," "MchCod INT NOT NULL AUTO_INCREMENT,"
@ -1395,6 +1396,7 @@ mysql> DESCRIBE gam_matches;
"QstInd INT NOT NULL DEFAULT 0," "QstInd INT NOT NULL DEFAULT 0,"
"QstCod INT NOT NULL DEFAULT -1," "QstCod INT NOT NULL DEFAULT -1,"
"QstStartTime DATETIME NOT NULL," "QstStartTime DATETIME NOT NULL,"
"ShowResults ENUM('N','Y') NOT NULL DEFAULT 'N',"
"Showing ENUM('wording','answers','request','results') NOT NULL DEFAULT 'wording'," "Showing ENUM('wording','answers','request','results') NOT NULL DEFAULT 'wording',"
"UNIQUE INDEX(MchCod)," "UNIQUE INDEX(MchCod),"
"INDEX(GamCod)"); "INDEX(GamCod)");

View File

@ -700,7 +700,7 @@ static void Lay_WriteScriptInit (void)
case ActPlyMchTch: case ActPlyMchTch:
case ActBckMchTch: case ActBckMchTch:
case ActFwdMchTch: case ActFwdMchTch:
case ActShoResMchTch: case ActChgDisResMchTch:
case ActPlyMchStd: case ActPlyMchStd:
case ActAnsMchQstStd: case ActAnsMchQstStd:
RefreshGame = true; RefreshGame = true;
@ -823,7 +823,7 @@ static void Lay_WriteScriptParamsAJAX (void)
case ActPlyMchTch: case ActPlyMchTch:
case ActBckMchTch: case ActBckMchTch:
case ActFwdMchTch: case ActFwdMchTch:
case ActShoResMchTch: case ActChgDisResMchTch:
fprintf (Gbl.F.Out,"var RefreshParamNxtActGam = \"act=%ld\";\n" fprintf (Gbl.F.Out,"var RefreshParamNxtActGam = \"act=%ld\";\n"
"var RefreshParamMchCod = \"MchCod=%ld\";\n", "var RefreshParamMchCod = \"MchCod=%ld\";\n",
Act_GetActCod (ActRefMchTch), Act_GetActCod (ActRefMchTch),

View File

@ -68,12 +68,11 @@ extern struct Globals Gbl;
/******************************* Private types *******************************/ /******************************* Private types *******************************/
/*****************************************************************************/ /*****************************************************************************/
#define Mch_NUM_SHOWING 4 #define Mch_NUM_SHOWING 3
typedef enum typedef enum
{ {
Mch_WORDING, // Showing only the question wording Mch_WORDING, // Showing only the question wording
Mch_ANSWERS, // Showing the question wording and the answers Mch_ANSWERS, // Showing the question wording and the answers
Mch_REQUEST, // Requesting confirmation to show the results
Mch_RESULTS, // Showing the results Mch_RESULTS, // Showing the results
} Mch_Showing_t; } Mch_Showing_t;
#define Mch_SHOWING_DEFAULT Mch_WORDING #define Mch_SHOWING_DEFAULT Mch_WORDING
@ -90,6 +89,7 @@ struct Match
unsigned QstInd; // 0 means that the game has not started. First question has index 1. unsigned QstInd; // 0 means that the game has not started. First question has index 1.
long QstCod; long QstCod;
time_t QstStartTimeUTC; time_t QstStartTimeUTC;
bool ShowResults;
Mch_Showing_t Showing; Mch_Showing_t Showing;
bool BeingPlayed; bool BeingPlayed;
unsigned NumPlayers; unsigned NumPlayers;
@ -104,7 +104,6 @@ const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
{ {
"wording", "wording",
"answers", "answers",
"request",
"results", "results",
}; };
@ -157,8 +156,9 @@ static void Mch_ShowMatchStatusForStd (struct Match *Match);
static bool Mch_CheckIfIPlayThisMatchBasedOnGrps (long MchCod); static bool Mch_CheckIfIPlayThisMatchBasedOnGrps (long MchCod);
static void Mch_ShowLeftColumnTch (struct Match *Match); static void Mch_ShowLeftColumnTch (struct Match *Match);
static void Mch_ShowLeftColumnStd (struct Match *Match); static void Mch_ShowLeftColumnStd (struct Match *Match);
static void Mch_PutMatchControlButtons (struct Match *Match);
static void Mch_ShowNumQstInMatch (struct Match *Match); static void Mch_ShowNumQstInMatch (struct Match *Match);
static void Mch_PutMatchControlButtons (struct Match *Match);
static void Mch_PutCheckboxResult (struct Match *Match);
static void Mch_ShowNumPlayers (struct Match *Match); static void Mch_ShowNumPlayers (struct Match *Match);
static void Mch_ShowMatchTitle (struct Match *Match); static void Mch_ShowMatchTitle (struct Match *Match);
static void Mch_ShowQuestionAndAnswersTch (struct Match *Match); static void Mch_ShowQuestionAndAnswersTch (struct Match *Match);
@ -222,16 +222,17 @@ void Mch_ListMatches (struct Game *Game,bool PutFormNewMatch)
/* Make query */ /* Make query */
NumMatches = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches", NumMatches = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches",
"SELECT MchCod," // row[0] "SELECT MchCod," // row[ 0]
"GamCod," // row[1] "GamCod," // row[ 1]
"UsrCod," // row[2] "UsrCod," // row[ 2]
"UNIX_TIMESTAMP(StartTime)," // row[3] "UNIX_TIMESTAMP(StartTime)," // row[ 3]
"UNIX_TIMESTAMP(EndTime)," // row[4] "UNIX_TIMESTAMP(EndTime)," // row[ 4]
"Title," // row[5] "Title," // row[ 5]
"QstInd," // row[6] "QstInd," // row[ 6]
"QstCod," // row[7] "QstCod," // row[ 7]
"UNIX_TIMESTAMP(QstStartTime)," // row[8] "UNIX_TIMESTAMP(QstStartTime)," // row[ 8]
"Showing" // row[9] "ShowResults," // row[ 9]
"Showing" // row[10]
" FROM gam_matches" " FROM gam_matches"
" WHERE GamCod=%ld%s" " WHERE GamCod=%ld%s"
" ORDER BY MchCod", " ORDER BY MchCod",
@ -283,16 +284,17 @@ static void Mch_GetDataOfMatchByCod (struct Match *Match)
/***** Get data of match from database *****/ /***** Get data of match from database *****/
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches", NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches",
"SELECT MchCod," // row[0] "SELECT MchCod," // row[ 0]
"GamCod," // row[1] "GamCod," // row[ 1]
"UsrCod," // row[2] "UsrCod," // row[ 2]
"UNIX_TIMESTAMP(StartTime)," // row[3] "UNIX_TIMESTAMP(StartTime)," // row[ 3]
"UNIX_TIMESTAMP(EndTime)," // row[4] "UNIX_TIMESTAMP(EndTime)," // row[ 4]
"Title," // row[5] "Title," // row[ 5]
"QstInd," // row[6] "QstInd," // row[ 6]
"QstCod," // row[7] "QstCod," // row[ 7]
"UNIX_TIMESTAMP(QstStartTime)," // row[8] "UNIX_TIMESTAMP(QstStartTime)," // row[ 8]
"Showing" // row[9] "ShowResults," // row[ 9]
"Showing" // row[10]
" FROM gam_matches" " FROM gam_matches"
" WHERE MchCod=%ld" " WHERE MchCod=%ld"
" AND GamCod IN" // Extra check " AND GamCod IN" // Extra check
@ -315,6 +317,7 @@ static void Mch_GetDataOfMatchByCod (struct Match *Match)
Match->Status.QstInd = 0; Match->Status.QstInd = 0;
Match->Status.QstCod = -1L; Match->Status.QstCod = -1L;
Match->Status.QstStartTimeUTC = (time_t) 0; Match->Status.QstStartTimeUTC = (time_t) 0;
Match->Status.ShowResults = true;
Match->Status.Showing = Mch_WORDING; Match->Status.Showing = Mch_WORDING;
Match->Status.BeingPlayed = false; Match->Status.BeingPlayed = false;
} }
@ -583,12 +586,12 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
/***** Get match data *****/ /***** Get match data *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* /*
row[0] MchCod row[ 0] MchCod
row[1] GamCod row[ 1] GamCod
row[2] UsrCod row[ 2] UsrCod
row[3] UNIX_TIMESTAMP(StartTime) row[ 3] UNIX_TIMESTAMP(StartTime)
row[4] UNIX_TIMESTAMP(EndTime) row[ 4] UNIX_TIMESTAMP(EndTime)
row[5] Title row[ 5] Title
*/ */
/***** Get match data *****/ /***** Get match data *****/
/* Code of the match (row[0]) */ /* Code of the match (row[0]) */
@ -617,10 +620,11 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
/***** Get current match status *****/ /***** Get current match status *****/
/* /*
row[6] QstInd row[ 6] QstInd
row[7] QstCod row[ 7] QstCod
row[8] UNIX_TIMESTAMP(QstStartTime) row[ 8] UNIX_TIMESTAMP(QstStartTime)
row[9] Showing row[ 9] ShowResults
row[10] Showing
*/ */
/* Current question index (row[6]) */ /* Current question index (row[6]) */
Match->Status.QstInd = Gam_GetQstIndFromStr (row[6]); Match->Status.QstInd = Gam_GetQstIndFromStr (row[6]);
@ -631,8 +635,11 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
/* Get question start date (row[8] holds the start UTC time) */ /* Get question start date (row[8] holds the start UTC time) */
Match->Status.QstStartTimeUTC = Dat_GetUNIXTimeFromStr (row[8]); Match->Status.QstStartTimeUTC = Dat_GetUNIXTimeFromStr (row[8]);
/* Get what to show (stem, answers, results) (row(9)) */ /* Get whether to show results or not (row(9)) */
Match->Status.Showing = Mch_GetShowingFromStr (row[9]); Match->Status.ShowResults = (row[9][0] == 'Y');
/* Get what to show (stem, answers, results) (row(10)) */
Match->Status.Showing = Mch_GetShowingFromStr (row[10]);
/***** Get whether the match is being played or not *****/ /***** Get whether the match is being played or not *****/
if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished
@ -1058,11 +1065,13 @@ static void Mch_UpdateMatchStatusInDB (struct Match *Match)
"gam_matches.QstInd=%u," "gam_matches.QstInd=%u,"
"gam_matches.QstCod=%ld," "gam_matches.QstCod=%ld,"
"gam_matches.QstStartTime=NOW()," "gam_matches.QstStartTime=NOW(),"
"gam_matches.ShowResults='%c',"
"gam_matches.Showing='%s'" "gam_matches.Showing='%s'"
" WHERE gam_matches.MchCod=%ld" " WHERE gam_matches.MchCod=%ld"
" AND gam_matches.GamCod=games.GamCod" " AND gam_matches.GamCod=games.GamCod"
" AND games.CrsCod=%ld", // Extra check " AND games.CrsCod=%ld", // Extra check
Match->Status.QstInd,Match->Status.QstCod, Match->Status.QstInd,Match->Status.QstCod,
Match->Status.ShowResults ? 'Y' : 'N',
Mch_ShowingStringsDB[Match->Status.Showing], Mch_ShowingStringsDB[Match->Status.Showing],
Match->MchCod,Gbl.Hierarchy.Crs.CrsCod); Match->MchCod,Gbl.Hierarchy.Crs.CrsCod);
@ -1231,10 +1240,10 @@ void Mch_ResumeMatchTch (void)
} }
/*****************************************************************************/ /*****************************************************************************/
/******** Show results of current question in a match (by a teacher) *********/ /********* Toggle the display of results in a match (by a teacher) ***********/
/*****************************************************************************/ /*****************************************************************************/
void Mch_ShowResultsQstMatchTch (void) void Mch_ToggleDisplayResultsMatchTch (void)
{ {
struct Match Match; struct Match Match;
@ -1247,7 +1256,10 @@ void Mch_ShowResultsQstMatchTch (void)
Mch_GetDataOfMatchByCod (&Match); Mch_GetDataOfMatchByCod (&Match);
/***** Update status *****/ /***** Update status *****/
Match.Status.Showing = Mch_RESULTS; // Show results Match.Status.ShowResults = !Match.Status.ShowResults; // Toggle display
if (!Match.Status.ShowResults &&
Match.Status.Showing == Mch_RESULTS)
Match.Status.Showing = Mch_ANSWERS; // Hide results
/***** Update match status in database *****/ /***** Update match status in database *****/
Mch_UpdateMatchStatusInDB (&Match); Mch_UpdateMatchStatusInDB (&Match);
@ -1324,7 +1336,8 @@ static void Mch_SetMatchStatusToPrev (struct Match *Match)
switch (Match->Status.Showing) switch (Match->Status.Showing)
{ {
case Mch_WORDING: case Mch_WORDING:
Match->Status.Showing = Mch_REQUEST; Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
Mch_ANSWERS;
/***** Get index of the previous question *****/ /***** Get index of the previous question *****/
Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod,
@ -1341,11 +1354,8 @@ static void Mch_SetMatchStatusToPrev (struct Match *Match)
case Mch_ANSWERS: case Mch_ANSWERS:
Match->Status.Showing = Mch_WORDING; Match->Status.Showing = Mch_WORDING;
break; break;
case Mch_REQUEST:
Match->Status.Showing = Mch_ANSWERS;
break;
case Mch_RESULTS: case Mch_RESULTS:
Match->Status.Showing = Mch_REQUEST; Match->Status.Showing = Mch_ANSWERS;
break; break;
} }
} }
@ -1363,12 +1373,17 @@ static void Mch_SetMatchStatusToNext (struct Match *Match)
Match->Status.Showing = Mch_ANSWERS; Match->Status.Showing = Mch_ANSWERS;
break; break;
case Mch_ANSWERS: case Mch_ANSWERS:
Match->Status.Showing = Mch_REQUEST; Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
Mch_WORDING;
break; break;
case Mch_REQUEST:
case Mch_RESULTS: case Mch_RESULTS:
Match->Status.Showing = Mch_WORDING; Match->Status.Showing = Mch_WORDING;
break;
}
/***** Go to next question? *****/
if (Match->Status.Showing == Mch_WORDING)
{
/***** Get index of the next question *****/ /***** Get index of the next question *****/
Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
Match->Status.QstInd); Match->Status.QstInd);
@ -1380,7 +1395,6 @@ static void Mch_SetMatchStatusToNext (struct Match *Match)
Match->Status.QstCod = -1L; // No more questions Match->Status.QstCod = -1L; // No more questions
Match->Status.BeingPlayed = false; Match->Status.BeingPlayed = false;
} }
break;
} }
} }
@ -1516,6 +1530,9 @@ static void Mch_ShowLeftColumnTch (struct Match *Match)
/***** Buttons *****/ /***** Buttons *****/
Mch_PutMatchControlButtons (Match); Mch_PutMatchControlButtons (Match);
/***** Write button to request viewing results *****/
Mch_PutCheckboxResult (Match);
/***** Number of players *****/ /***** Number of players *****/
Mch_ShowNumPlayers (Match); Mch_ShowNumPlayers (Match);
@ -1554,6 +1571,26 @@ static void Mch_ShowLeftColumnStd (struct Match *Match)
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
} }
/*****************************************************************************/
/********************* Show number of question in game ***********************/
/*****************************************************************************/
static void Mch_ShowNumQstInMatch (struct Match *Match)
{
extern const char *Txt_MATCH_Start;
extern const char *Txt_MATCH_End;
unsigned NumQsts = Gam_GetNumQstsGame (Match->GamCod);
fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_QST\">");
if (Match->Status.QstInd == 0) // Not started
fprintf (Gbl.F.Out,"%s",Txt_MATCH_Start);
else if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished
fprintf (Gbl.F.Out,"%s",Txt_MATCH_End);
else
fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts);
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/ /*****************************************************************************/
/********************** Put buttons to control a match ***********************/ /********************** Put buttons to control a match ***********************/
/*****************************************************************************/ /*****************************************************************************/
@ -1617,22 +1654,43 @@ static void Mch_PutMatchControlButtons (struct Match *Match)
} }
/*****************************************************************************/ /*****************************************************************************/
/********************* Show number of question in game ***********************/ /***************** Put checkbox to select if show results ********************/
/*****************************************************************************/ /*****************************************************************************/
static void Mch_ShowNumQstInMatch (struct Match *Match) static void Mch_PutCheckboxResult (struct Match *Match)
{ {
extern const char *Txt_MATCH_Start; extern const char *Txt_View_results;
extern const char *Txt_MATCH_End;
unsigned NumQsts = Gam_GetNumQstsGame (Match->GamCod);
fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_QST\">"); /***** Start container *****/
if (Match->Status.QstInd == 0) // Not started fprintf (Gbl.F.Out,"<div class=\"MATCH_SHOW_RESULTS\">");
fprintf (Gbl.F.Out,"%s",Txt_MATCH_Start);
else if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished /***** Start form *****/
fprintf (Gbl.F.Out,"%s",Txt_MATCH_End); Frm_StartForm (ActChgDisResMchTch);
else Mch_PutParamMatchCod (Match->MchCod); // Current match being played
fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts);
/***** Put icon with link *****/
/* Submitting onmousedown instead of default onclick
is necessary in order to be fast
and not lose clicks due to refresh */
fprintf (Gbl.F.Out,"<div class=\"CONTEXT_OPT\">"
"<a href=\"\" class=\"ICO_HIGHLIGHT\""
" title=\"%s\" "
" onmousedown=\"document.getElementById('%s').submit();"
" return false;\">"
"<i class=\"%s\"></i>"
"&nbsp;%s"
"</a>"
"</div>",
Txt_View_results,
Gbl.Form.Id,
Match->Status.ShowResults ? "fas fa-toggle-on" :
"fas fa-toggle-off",
Txt_View_results);
/***** End form *****/
Frm_EndForm ();
/***** End container *****/
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
} }
@ -1723,11 +1781,6 @@ static void Mch_ShowQuestionAndAnswersTch (struct Match *Match)
else // Not being played else // Not being played
Mch_ShowWaitImage (Txt_MATCH_Paused); Mch_ShowWaitImage (Txt_MATCH_Paused);
break; break;
case Mch_REQUEST:
/* Write button to request viewing results */
Mch_PutBigButton (ActShoResMchTch,Match->MchCod,
Mch_ICON_RESULTS,Txt_View_results);
break;
case Mch_RESULTS: case Mch_RESULTS:
/* Write answers with results */ /* Write answers with results */
Tst_WriteAnswersMatchResult (Match->MchCod, Tst_WriteAnswersMatchResult (Match->MchCod,

View File

@ -50,7 +50,7 @@ void Mch_CreateNewMatchTch (void);
void Mch_RequestStartResumeMatchTch (void); void Mch_RequestStartResumeMatchTch (void);
void Mch_PauseMatchTch (void); void Mch_PauseMatchTch (void);
void Mch_ResumeMatchTch (void); void Mch_ResumeMatchTch (void);
void Mch_ShowResultsQstMatchTch (void); void Mch_ToggleDisplayResultsMatchTch (void);
void Mch_BackMatchTch (void); void Mch_BackMatchTch (void);
void Mch_ForwardMatchTch (void); void Mch_ForwardMatchTch (void);