From bea194144a8ef6bc482349489bc5f54b1cda0f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 12 Sep 2019 23:53:00 +0200 Subject: [PATCH] Version19.0 --- sql/swad.sql | 3 +- swad_action.c | 28 ++- swad_action.h | 103 +++++---- swad_changelog.h | 8 +- swad_database.c | 34 ++- swad_game.c | 541 ++++++++++++++++++++--------------------------- swad_game.h | 12 +- swad_layout.c | 14 +- swad_survey.c | 4 +- swad_test.c | 4 +- swad_text.c | 74 ++++--- 11 files changed, 380 insertions(+), 445 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index 2cfc8ba85..431963c38 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -639,8 +639,7 @@ CREATE TABLE IF NOT EXISTS gam_matches ( QstInd INT NOT NULL DEFAULT 0, QstCod INT NOT NULL DEFAULT -1, QstStartTime DATETIME NOT NULL, - ShowResults ENUM('N','Y') NOT NULL DEFAULT 'N', - Showing ENUM('stem','answers','results') NOT NULL DEFAULT 'stem', + Showing ENUM('wording','answers','request','results') NOT NULL DEFAULT 'wording', UNIQUE INDEX(MchCod), INDEX(GamCod)); -- diff --git a/swad_action.c b/swad_action.c index fe84a3a20..8be1911a8 100644 --- a/swad_action.c +++ b/swad_action.c @@ -613,12 +613,11 @@ Assessment: NEW. ActResMchTch Resume an unfinished match showing current question in a new browser tab (by a teacher) NEW. ActPauMchTch Pause current match (by a teacher) NEW. ActPlyMchTch Play/resume current match (by a teacher) - NEW. ActShoSteMchTch Show stem of current question, hiding answers, when playing a match (by a teacher) - NEW. ActShoAnsMchTch Show full current question, including answers, 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) NEW. ActShoResMchTch Show results when playing a match (by a teacher) - NEW. ActPrvQstMchTch Show previous question when playing a match (by a teacher) - 457. ActNxtQstMchTch Show next question when playing a match (by a teacher) - NEW. ActChgShoResMchTch Change display of results when playing a match (by a teacher) + NEW. ActRefMchTch Refresh current question when playing a match (as teacher) NEW. ActShoMchTch Show finished match results @@ -2160,12 +2159,9 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActResMchTch */{1785,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_GetMatchBeingPlayed ,Gam_RequestStartResumeMatchTch ,NULL}, /* ActPauMchTch */{1791,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_PauseMatchTch ,NULL}, /* ActPlyMchTch */{1789,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_ResumeMatchTch ,NULL}, - /* ActShoSteMchTch */{1792,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowStemQstMatchTch ,NULL}, - /* ActShoAnsMchTch */{1793,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowAnssQstMatchTch ,NULL}, - /* ActShoResMchTch */{1795,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowRessQstMatchTch ,NULL}, - /* ActPrvQstMchTch */{1790,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_PrevQstMatchTch ,NULL}, - /* ActNxtQstMchTch */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_NextQstMatchTch ,NULL}, - /* ActChgShoResMchTch*/{1794,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_CurrQstMatchTch ,NULL}, + /* ActBckMchTch */{1790,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_BackMatchTch ,NULL}, + /* ActFwdMchTch */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_ForwardMatchTch ,NULL}, + /* ActShoResMchTch */{1795,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowResultsQstMatchTch ,NULL}, /* ActRefMchTch */{1788,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Gam_GetMatchBeingPlayed ,Gam_RefreshMatchTch ,NULL}, /* ActShoMchTch */{1786,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ShowFinishedMatchResults ,NULL}, @@ -4895,7 +4891,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActDwnGamQst, // #1669 ActReqNewMchTch, // #1670 ActNewMchTch, // #1671 - ActNxtQstMchTch, // #1672 + ActFwdMchTch, // #1672 -1, // #1673 (obsolete action) ActSeePrj, // #1674 ActFrmNewPrj, // #1675 @@ -5013,11 +5009,11 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActCreMyAcc, // #1787 ActRefMchTch, // #1788 ActPlyMchTch, // #1789 - ActPrvQstMchTch, // #1790 + ActBckMchTch, // #1790 ActPauMchTch, // #1791 - ActShoSteMchTch, // #1792 - ActShoAnsMchTch, // #1793 - ActChgShoResMchTch, // #1794 + -1, // #1792 (obsolete action) + -1, // #1793 (obsolete action) + -1, // #1794 (obsolete action) ActShoResMchTch, // #1795 }; diff --git a/swad_action.h b/swad_action.h index 64651f3c7..ee9981806 100644 --- a/swad_action.h +++ b/swad_action.h @@ -64,7 +64,7 @@ typedef enum typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (1 + 4 + 64 + 38 + 12 + 42 + 36 + 19 + 110 + 176 + 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 @@ -614,61 +614,58 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActResMchTch (ActChgCrsTT1stDay + 121) #define ActPauMchTch (ActChgCrsTT1stDay + 122) #define ActPlyMchTch (ActChgCrsTT1stDay + 123) -#define ActShoSteMchTch (ActChgCrsTT1stDay + 124) -#define ActShoAnsMchTch (ActChgCrsTT1stDay + 125) +#define ActBckMchTch (ActChgCrsTT1stDay + 124) +#define ActFwdMchTch (ActChgCrsTT1stDay + 125) #define ActShoResMchTch (ActChgCrsTT1stDay + 126) -#define ActPrvQstMchTch (ActChgCrsTT1stDay + 127) -#define ActNxtQstMchTch (ActChgCrsTT1stDay + 128) -#define ActChgShoResMchTch (ActChgCrsTT1stDay + 129) -#define ActRefMchTch (ActChgCrsTT1stDay + 130) -#define ActShoMchTch (ActChgCrsTT1stDay + 131) -#define ActPlyMchStd (ActChgCrsTT1stDay + 132) -#define ActRefMchStd (ActChgCrsTT1stDay + 133) -#define ActAnsMchQstStd (ActChgCrsTT1stDay + 134) -#define ActFrmNewGam (ActChgCrsTT1stDay + 135) -#define ActEdiOneGam (ActChgCrsTT1stDay + 136) -#define ActNewGam (ActChgCrsTT1stDay + 137) -#define ActChgGam (ActChgCrsTT1stDay + 138) -#define ActReqRemGam (ActChgCrsTT1stDay + 139) -#define ActRemGam (ActChgCrsTT1stDay + 140) -#define ActReqRstGam (ActChgCrsTT1stDay + 141) -#define ActRstGam (ActChgCrsTT1stDay + 142) -#define ActHidGam (ActChgCrsTT1stDay + 143) -#define ActShoGam (ActChgCrsTT1stDay + 144) -#define ActAddOneGamQst (ActChgCrsTT1stDay + 145) -#define ActGamLstTstQst (ActChgCrsTT1stDay + 146) -#define ActAddTstQstToGam (ActChgCrsTT1stDay + 147) -#define ActReqRemGamQst (ActChgCrsTT1stDay + 148) -#define ActRemGamQst (ActChgCrsTT1stDay + 149) -#define ActUp_GamQst (ActChgCrsTT1stDay + 150) -#define ActDwnGamQst (ActChgCrsTT1stDay + 151) +#define ActRefMchTch (ActChgCrsTT1stDay + 127) +#define ActShoMchTch (ActChgCrsTT1stDay + 128) +#define ActPlyMchStd (ActChgCrsTT1stDay + 129) +#define ActRefMchStd (ActChgCrsTT1stDay + 130) +#define ActAnsMchQstStd (ActChgCrsTT1stDay + 131) +#define ActFrmNewGam (ActChgCrsTT1stDay + 132) +#define ActEdiOneGam (ActChgCrsTT1stDay + 133) +#define ActNewGam (ActChgCrsTT1stDay + 134) +#define ActChgGam (ActChgCrsTT1stDay + 135) +#define ActReqRemGam (ActChgCrsTT1stDay + 136) +#define ActRemGam (ActChgCrsTT1stDay + 137) +#define ActReqRstGam (ActChgCrsTT1stDay + 138) +#define ActRstGam (ActChgCrsTT1stDay + 139) +#define ActHidGam (ActChgCrsTT1stDay + 140) +#define ActShoGam (ActChgCrsTT1stDay + 141) +#define ActAddOneGamQst (ActChgCrsTT1stDay + 142) +#define ActGamLstTstQst (ActChgCrsTT1stDay + 143) +#define ActAddTstQstToGam (ActChgCrsTT1stDay + 144) +#define ActReqRemGamQst (ActChgCrsTT1stDay + 145) +#define ActRemGamQst (ActChgCrsTT1stDay + 146) +#define ActUp_GamQst (ActChgCrsTT1stDay + 147) +#define ActDwnGamQst (ActChgCrsTT1stDay + 148) -#define ActSeeSvy (ActChgCrsTT1stDay + 152) -#define ActAnsSvy (ActChgCrsTT1stDay + 153) -#define ActFrmNewSvy (ActChgCrsTT1stDay + 154) -#define ActEdiOneSvy (ActChgCrsTT1stDay + 155) -#define ActNewSvy (ActChgCrsTT1stDay + 156) -#define ActChgSvy (ActChgCrsTT1stDay + 157) -#define ActReqRemSvy (ActChgCrsTT1stDay + 158) -#define ActRemSvy (ActChgCrsTT1stDay + 159) -#define ActReqRstSvy (ActChgCrsTT1stDay + 160) -#define ActRstSvy (ActChgCrsTT1stDay + 161) -#define ActHidSvy (ActChgCrsTT1stDay + 162) -#define ActShoSvy (ActChgCrsTT1stDay + 163) -#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 164) -#define ActRcvSvyQst (ActChgCrsTT1stDay + 165) -#define ActReqRemSvyQst (ActChgCrsTT1stDay + 166) -#define ActRemSvyQst (ActChgCrsTT1stDay + 167) +#define ActSeeSvy (ActChgCrsTT1stDay + 149) +#define ActAnsSvy (ActChgCrsTT1stDay + 150) +#define ActFrmNewSvy (ActChgCrsTT1stDay + 151) +#define ActEdiOneSvy (ActChgCrsTT1stDay + 152) +#define ActNewSvy (ActChgCrsTT1stDay + 153) +#define ActChgSvy (ActChgCrsTT1stDay + 154) +#define ActReqRemSvy (ActChgCrsTT1stDay + 155) +#define ActRemSvy (ActChgCrsTT1stDay + 156) +#define ActReqRstSvy (ActChgCrsTT1stDay + 157) +#define ActRstSvy (ActChgCrsTT1stDay + 158) +#define ActHidSvy (ActChgCrsTT1stDay + 159) +#define ActShoSvy (ActChgCrsTT1stDay + 160) +#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 161) +#define ActRcvSvyQst (ActChgCrsTT1stDay + 162) +#define ActReqRemSvyQst (ActChgCrsTT1stDay + 163) +#define ActRemSvyQst (ActChgCrsTT1stDay + 164) -#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 168) -#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 169) -#define ActEdiExaAnn (ActChgCrsTT1stDay + 170) -#define ActRcvExaAnn (ActChgCrsTT1stDay + 171) -#define ActPrnExaAnn (ActChgCrsTT1stDay + 172) -#define ActReqRemExaAnn (ActChgCrsTT1stDay + 173) -#define ActRemExaAnn (ActChgCrsTT1stDay + 174) -#define ActHidExaAnn (ActChgCrsTT1stDay + 175) -#define ActShoExaAnn (ActChgCrsTT1stDay + 176) +#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 165) +#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 166) +#define ActEdiExaAnn (ActChgCrsTT1stDay + 167) +#define ActRcvExaAnn (ActChgCrsTT1stDay + 168) +#define ActPrnExaAnn (ActChgCrsTT1stDay + 169) +#define ActReqRemExaAnn (ActChgCrsTT1stDay + 170) +#define ActRemExaAnn (ActChgCrsTT1stDay + 171) +#define ActHidExaAnn (ActChgCrsTT1stDay + 172) +#define ActShoExaAnn (ActChgCrsTT1stDay + 173) /*****************************************************************************/ /******************************** Files tab **********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index b12dec6d4..cc357f085 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -460,10 +460,16 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.144 (2019-09-10)" +#define Log_PLATFORM_VERSION "SWAD 19.0 (2019-09-12)" #define CSS_FILE "swad18.138.css" #define JS_FILE "swad18.130.2.js" /* + Version 19.0: Sep 12, 2019 Changes in behaviour of matches. (244585 lines) + 3 changes necessary in database: +ALTER TABLE gam_matches DROP COLUMN ShowResults,DROP COLUMN Showing; +ALTER TABLE gam_matches ADD COLUMN Showing ENUM('wording','answers','request','results') NOT NULL DEFAULT 'wording' AFTER QstStartTime; +UPDATE actions SET Obsolete='Y' WHERE ActCod IN (1792,1793,1794); + Version 18.144: Sep 10, 2019 Show question results in match. (244641 lines) 3 changes necessary in database: ALTER TABLE gam_matches DROP COLUMN ShowingAnswers,DROP COLUMN ShowResults; diff --git a/swad_database.c b/swad_database.c index 82691bb66..d49e76b43 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1369,22 +1369,21 @@ mysql> DESCRIBE gam_grp; /***** Table gam_matches *****/ /* mysql> DESCRIBE gam_matches; -+--------------+----------------------------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+--------------+----------------------------------+------+-----+---------+----------------+ -| MchCod | int(11) | NO | PRI | NULL | auto_increment | -| GamCod | int(11) | NO | MUL | NULL | | -| UsrCod | int(11) | NO | | NULL | | -| StartTime | datetime | NO | | NULL | | -| EndTime | datetime | NO | | NULL | | -| Title | varchar(2047) | NO | | NULL | | -| QstInd | int(11) | NO | | 0 | | -| QstCod | int(11) | NO | | -1 | | -| QstStartTime | datetime | NO | | NULL | | -| ShowResults | enum('N','Y') | NO | | N | | -| Showing | enum('stem','answers','results') | NO | | stem | | -+--------------+----------------------------------+------+-----+---------+----------------+ -11 rows in set (0.00 sec) ++--------------+-----------------------------------------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++--------------+-----------------------------------------------+------+-----+---------+----------------+ +| MchCod | int(11) | NO | PRI | NULL | auto_increment | +| GamCod | int(11) | NO | MUL | NULL | | +| UsrCod | int(11) | NO | | NULL | | +| StartTime | datetime | NO | | NULL | | +| EndTime | datetime | NO | | NULL | | +| Title | varchar(2047) | NO | | NULL | | +| QstInd | int(11) | NO | | 0 | | +| QstCod | int(11) | NO | | -1 | | +| QstStartTime | datetime | NO | | NULL | | +| Showing | enum('wording','answers','request','results') | NO | | wording | | ++--------------+-----------------------------------------------+------+-----+---------+----------------+ +10 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_matches (" "MchCod INT NOT NULL AUTO_INCREMENT," @@ -1396,8 +1395,7 @@ mysql> DESCRIBE gam_matches; "QstInd INT NOT NULL DEFAULT 0," "QstCod INT NOT NULL DEFAULT -1," "QstStartTime DATETIME NOT NULL," - "ShowResults ENUM('N','Y') NOT NULL DEFAULT 'N'," - "Showing ENUM('stem','answers','results') NOT NULL DEFAULT 'stem'," + "Showing ENUM('wording','answers','request','results') NOT NULL DEFAULT 'wording'," "UNIQUE INDEX(MchCod)," "INDEX(GamCod)"); diff --git a/swad_game.c b/swad_game.c index e6e0ac66b..e99e79a3d 100644 --- a/swad_game.c +++ b/swad_game.c @@ -75,39 +75,32 @@ const char *Gam_StrAnswerTypesDB[Gam_NUM_ANS_TYPES] = #define Gam_NEW_MATCH_SECTION_ID "new_match" #define Gam_AFTER_LAST_QUESTION ((unsigned)((1UL << 31) - 1)) // 2^31 - 1, don't change this number because it is used in database to indicate that a match is finished -/* -#define Gam_ICON_CLOSE "❎" // Alternatives: "✕" "❌" "×" -#define Gam_ICON_PLAY "🏁" // Alternatives: "‣" "⏩" "▶" "▸" "⇥" "▸" -#define Gam_ICON_STEM "⏪" // Alternatives: "⇤" -#define Gam_ICON_START "⏪" // Alternatives: "⇤" -#define Gam_ICON_PREVIOUS "⏪" // Alternatives: "⇤" -#define Gam_ICON_FINISH "⏩" // Alternatives: "🏁" "⇥" -#define Gam_ICON_NEXT "⏩" // Alternatives: "⇥" -#define Gam_ICON_ANSWERS "⏩" // Alternatives: "⇥" -*/ + #define Gam_ICON_CLOSE "fas fa-times" #define Gam_ICON_PLAY "fas fa-play" #define Gam_ICON_PAUSE "fas fa-pause" #define Gam_ICON_PREVIOUS "fas fa-step-backward" #define Gam_ICON_NEXT "fas fa-step-forward" +#define Gam_ICON_RESULTS "fas fa-chart-bar" /*****************************************************************************/ /******************************* Private types *******************************/ /*****************************************************************************/ -#define Gam_NUM_SHOWING 3 +#define Gam_NUM_SHOWING 4 typedef enum { - Gam_SHOWING_WORDING, // Showing only the question wording - Gam_SHOWING_ANSWERS, // Showing the question wording and the answers - Gam_REQUEST_RESULTS, // Requesting confirmation to show the results - Gam_SHOWING_RESULTS, // Showing the results + Gam_WORDING, // Showing only the question wording + Gam_ANSWERS, // Showing the question wording and the answers + Gam_REQUEST, // Requesting confirmation to show the results + Gam_RESULTS, // Showing the results } Gam_Showing_t; -#define Gam_SHOWING_DEFAULT Gam_SHOWING_WORDING +#define Gam_SHOWING_DEFAULT Gam_WORDING const char *Gam_ShowingStringsDB[Gam_NUM_SHOWING] = { - "stem", + "wording", "answers", + "request", "results", }; @@ -120,10 +113,9 @@ struct Match char Title[Gam_MAX_BYTES_TITLE + 1]; struct { - unsigned QstInd; // 0 means that the game has not started. First question has index 0. + unsigned QstInd; // 0 means that the game has not started. First question has index 1. long QstCod; time_t QstStartTimeUTC; - bool ShowResults; Gam_Showing_t Showing; bool BeingPlayed; unsigned NumPlayers; @@ -229,14 +221,14 @@ static void Gam_GetElapsedTimeInMatch (struct Match *Match, static void Gam_GetElapsedTime (unsigned NumRows,MYSQL_RES *mysql_res, struct Time *Time); -static void Gam_SetMatchStatusToPrevQuestion (struct Match *Match); -static void Gam_SetMatchStatusToNextQuestion (struct Match *Match); +static void Gam_SetMatchStatusToPrev (struct Match *Match); +static void Gam_SetMatchStatusToNext (struct Match *Match); static void Gam_ShowMatchStatusForTch (struct Match *Match); static void Gam_ShowMatchStatusForStd (struct Match *Match); static void Gam_ShowLeftColumnTch (struct Match *Match); static void Gam_ShowLeftColumnStd (struct Match *Match); static void Gam_PutMatchControlButtons (struct Match *Match); -static void Gam_PutCheckboxResult (struct Match *Match); +// static void Gam_PutCheckboxResult (struct Match *Match); static void Gam_ShowNumQstInGame (struct Match *Match); static void Gam_ShowNumPlayers (struct Match *Match); static void Gam_ShowMatchTitle (struct Match *Match); @@ -2722,17 +2714,16 @@ static void Gam_ListMatches (struct Game *Game,bool PutFormNewMatch) /* Make query */ NumMatches = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches", - "SELECT MchCod," // row[ 0] - "GamCod," // row[ 1] - "UsrCod," // row[ 2] - "UNIX_TIMESTAMP(StartTime)," // row[ 3] - "UNIX_TIMESTAMP(EndTime)," // row[ 4] - "Title," // row[ 5] - "ShowResults," // row[ 6] - "QstInd," // row[ 7] - "QstCod," // row[ 8] - "UNIX_TIMESTAMP(QstStartTime)," // row[ 9] - "Showing" // row[10] + "SELECT MchCod," // row[0] + "GamCod," // row[1] + "UsrCod," // row[2] + "UNIX_TIMESTAMP(StartTime)," // row[3] + "UNIX_TIMESTAMP(EndTime)," // row[4] + "Title," // row[5] + "QstInd," // row[6] + "QstCod," // row[7] + "UNIX_TIMESTAMP(QstStartTime)," // row[8] + "Showing" // row[9] " FROM gam_matches" " WHERE GamCod=%ld%s" " ORDER BY MchCod", @@ -2784,17 +2775,16 @@ void Gam_GetDataOfMatchByCod (struct Match *Match) /***** Get data of match from database *****/ NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches", - "SELECT MchCod," // row[ 0] - "GamCod," // row[ 1] - "UsrCod," // row[ 2] - "UNIX_TIMESTAMP(StartTime)," // row[ 3] - "UNIX_TIMESTAMP(EndTime)," // row[ 4] - "Title," // row[ 5] - "ShowResults," // row[ 6] - "QstInd," // row[ 7] - "QstCod," // row[ 8] - "UNIX_TIMESTAMP(QstStartTime)," // row[ 9] - "Showing" // row[10] + "SELECT MchCod," // row[0] + "GamCod," // row[1] + "UsrCod," // row[2] + "UNIX_TIMESTAMP(StartTime)," // row[3] + "UNIX_TIMESTAMP(EndTime)," // row[4] + "Title," // row[5] + "QstInd," // row[6] + "QstCod," // row[7] + "UNIX_TIMESTAMP(QstStartTime)," // row[8] + "Showing" // row[9] " FROM gam_matches" " WHERE MchCod=%ld" " AND GamCod IN" // Extra check @@ -2817,8 +2807,7 @@ void Gam_GetDataOfMatchByCod (struct Match *Match) Match->Status.QstInd = 0; Match->Status.QstCod = -1L; Match->Status.QstStartTimeUTC = (time_t) 0; - Match->Status.ShowResults = false; - Match->Status.Showing = Gam_SHOWING_WORDING; + Match->Status.Showing = Gam_WORDING; Match->Status.BeingPlayed = false; } @@ -3022,13 +3011,12 @@ static void Gam_GetMatchDataFromRow (MYSQL_RES *mysql_res, /***** Get match data *****/ row = mysql_fetch_row (mysql_res); /* - row[ 0] MchCod - row[ 1] GamCod - row[ 2] UsrCod - row[ 3] UNIX_TIMESTAMP(StartTime) - row[ 4] UNIX_TIMESTAMP(EndTime) - row[ 5] Title - row[ 6] ShowResults + row[0] MchCod + row[1] GamCod + row[2] UsrCod + row[3] UNIX_TIMESTAMP(StartTime) + row[4] UNIX_TIMESTAMP(EndTime) + row[5] Title */ /***** Get match data *****/ /* Code of the match (row[0]) */ @@ -3055,27 +3043,24 @@ static void Gam_GetMatchDataFromRow (MYSQL_RES *mysql_res, else Match->Title[0] = '\0'; - /* Get whether to show results or not (row(6)) */ - Match->Status.ShowResults = (row[6][0] == 'Y'); - /***** Get current match status *****/ /* - row[ 7] QstInd - row[ 8] QstCod - row[ 9] UNIX_TIMESTAMP(QstStartTime) - row[10] Showing + row[6] QstInd + row[7] QstCod + row[8] UNIX_TIMESTAMP(QstStartTime) + row[9] Showing */ - /* Current question index (row[7]) */ - Match->Status.QstInd = Gam_GetQstIndFromStr (row[7]); + /* Current question index (row[6]) */ + Match->Status.QstInd = Gam_GetQstIndFromStr (row[6]); - /* Current question code (row[8]) */ - Match->Status.QstCod = Str_ConvertStrCodToLongCod (row[8]); + /* Current question code (row[7]) */ + Match->Status.QstCod = Str_ConvertStrCodToLongCod (row[7]); - /* Get question start date (row[9] holds the start UTC time) */ - Match->Status.QstStartTimeUTC = Dat_GetUNIXTimeFromStr (row[9]); + /* Get question start date (row[8] holds the start UTC time) */ + Match->Status.QstStartTimeUTC = Dat_GetUNIXTimeFromStr (row[8]); - /* Get what to show (stem, answers, results) (row(10)) */ - Match->Status.Showing = Gam_GetShowingFromStr (row[10]); + /* Get what to show (stem, answers, results) (row(9)) */ + Match->Status.Showing = Gam_GetShowingFromStr (row[9]); /***** Get whether the match is being played or not *****/ if (Match->Status.QstInd >= Gam_AFTER_LAST_QUESTION) // Finished @@ -3557,7 +3542,7 @@ void Gam_ResumeMatchTch (void) if (Match.Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished { if (Match.Status.QstInd == 0) // Match has been created, but it has not started - Gam_SetMatchStatusToNextQuestion (&Match); + Gam_SetMatchStatusToNext (&Match); Match.Status.BeingPlayed = true; // Start/resume match } @@ -3573,64 +3558,64 @@ void Gam_ResumeMatchTch (void) /*****************************************************************************/ /** Show stem, hiding answers, of current question in a match (by a teacher) */ /*****************************************************************************/ - +/* void Gam_ShowStemQstMatchTch (void) { struct Match Match; - /***** Remove old players. - This function must be called before getting match status. *****/ + ***** Remove old players. + This function must be called before getting match status. ***** Gam_RemoveOldPlayers (); - /***** Get data of the match from database *****/ + ***** Get data of the match from database ***** Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); - /***** Update status *****/ - Match.Status.Showing = Gam_SHOWING_WORDING; // Show only the stem + ***** Update status ***** + Match.Status.Showing = Gam_WORDING; // Show only the stem - /***** Update match status in database *****/ + ***** Update match status in database ***** Gam_UpdateMatchStatusInDB (&Match); - /***** Show current match status *****/ + ***** Show current match status ***** fprintf (Gbl.F.Out,"
"); Gam_ShowMatchStatusForTch (&Match); fprintf (Gbl.F.Out,"
"); } - +*/ /*****************************************************************************/ /**** Show stem and answers of current question in a match (by a teacher) ****/ /*****************************************************************************/ - +/* void Gam_ShowAnssQstMatchTch (void) { struct Match Match; - /***** Remove old players. - This function must be called before getting match status. *****/ + ***** Remove old players. + This function must be called before getting match status. ***** Gam_RemoveOldPlayers (); - /***** Get data of the match from database *****/ + ***** Get data of the match from database ***** Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); - /***** Update status *****/ - Match.Status.Showing = Gam_SHOWING_ANSWERS; // Show answers + ***** Update status ***** + Match.Status.Showing = Gam_ANSWERS; // Show answers - /***** Update match status in database *****/ + ***** Update match status in database ***** Gam_UpdateMatchStatusInDB (&Match); - /***** Show current match status *****/ + ***** Show current match status ***** fprintf (Gbl.F.Out,"
"); Gam_ShowMatchStatusForTch (&Match); fprintf (Gbl.F.Out,"
"); } - +*/ /*****************************************************************************/ /******** Show results of current question in a match (by a teacher) *********/ /*****************************************************************************/ -void Gam_ShowRessQstMatchTch (void) +void Gam_ShowResultsQstMatchTch (void) { struct Match Match; @@ -3643,7 +3628,7 @@ void Gam_ShowRessQstMatchTch (void) Gam_GetDataOfMatchByCod (&Match); /***** Update status *****/ - Match.Status.Showing = Gam_REQUEST_RESULTS; // Show results + Match.Status.Showing = Gam_RESULTS; // Show results /***** Update match status in database *****/ Gam_UpdateMatchStatusInDB (&Match); @@ -3658,7 +3643,7 @@ void Gam_ShowRessQstMatchTch (void) /************* Show previous question in a match (by a teacher) **************/ /*****************************************************************************/ -void Gam_PrevQstMatchTch (void) +void Gam_BackMatchTch (void) { struct Match Match; @@ -3671,7 +3656,7 @@ void Gam_PrevQstMatchTch (void) Gam_GetDataOfMatchByCod (&Match); /***** Update status *****/ - Gam_SetMatchStatusToPrevQuestion (&Match); + Gam_SetMatchStatusToPrev (&Match); /***** Update match status in database *****/ Gam_UpdateMatchStatusInDB (&Match); @@ -3686,7 +3671,7 @@ void Gam_PrevQstMatchTch (void) /*************** Show next question in a match (by a teacher) ****************/ /*****************************************************************************/ -void Gam_NextQstMatchTch (void) +void Gam_ForwardMatchTch (void) { struct Match Match; @@ -3699,7 +3684,7 @@ void Gam_NextQstMatchTch (void) Gam_GetDataOfMatchByCod (&Match); /***** Update status *****/ - Gam_SetMatchStatusToNextQuestion (&Match); + Gam_SetMatchStatusToNext (&Match); /***** Update match status in database *****/ Gam_UpdateMatchStatusInDB (&Match); @@ -3713,79 +3698,99 @@ void Gam_NextQstMatchTch (void) /*****************************************************************************/ /************** Show current question in a match (by a teacher) **************/ /*****************************************************************************/ - +/* void Gam_CurrQstMatchTch (void) { struct Match Match; - /***** Remove old players. - This function must be called before getting match status. *****/ + ***** Remove old players. + This function must be called before getting match status. ***** Gam_RemoveOldPlayers (); - /***** Get data of the match from database *****/ + ***** Get data of the match from database ***** Match.MchCod = Gbl.Games.MchCodBeingPlayed; Gam_GetDataOfMatchByCod (&Match); - /***** Toggle display of results *****/ + ***** Toggle display of results ***** Match.Status.ShowResults = !Match.Status.ShowResults; - /***** Update match status in database *****/ + ***** Update match status in database ***** Gam_UpdateMatchStatusInDB (&Match); - /***** Show current match status *****/ + ***** Show current match status ***** fprintf (Gbl.F.Out,"
"); Gam_ShowMatchStatusForTch (&Match); fprintf (Gbl.F.Out,"
"); } - +*/ /*****************************************************************************/ -/******************* Set match status to previous question *******************/ +/************** Set match status to previous (backward) status ***************/ /*****************************************************************************/ -static void Gam_SetMatchStatusToPrevQuestion (struct Match *Match) +static void Gam_SetMatchStatusToPrev (struct Match *Match) { - /***** Get index of the previous question *****/ - Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, - Match->Status.QstInd); - if (Match->Status.QstInd == 0) // Start of questions has been reached - { - Match->Status.QstCod = -1L; // No previous questions - Match->Status.BeingPlayed = false; // Match is not being played - } - else - Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod, - Match->Status.QstInd); - /***** What to show *****/ - if (Match->Status.BeingPlayed) + switch (Match->Status.Showing) { - if (Match->Status.ShowResults) - Match->Status.Showing = Gam_REQUEST_RESULTS; // Show results - else - Match->Status.Showing = Gam_SHOWING_ANSWERS; // Show answers + case Gam_WORDING: + Match->Status.Showing = Gam_REQUEST; + + /***** Get index of the previous question *****/ + Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, + Match->Status.QstInd); + if (Match->Status.QstInd == 0) // Start of questions has been reached + { + Match->Status.QstCod = -1L; // No previous questions + Match->Status.BeingPlayed = false; // Match is not being played + } + else + Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod, + Match->Status.QstInd); + break; + case Gam_ANSWERS: + Match->Status.Showing = Gam_WORDING; + break; + case Gam_REQUEST: + Match->Status.Showing = Gam_ANSWERS; + break; + case Gam_RESULTS: + Match->Status.Showing = Gam_REQUEST; + break; } - else - Match->Status.Showing = Gam_SHOWING_WORDING; // Show only stem } /*****************************************************************************/ -/********************* Set match status to next question *********************/ +/**************** Set match status to next (forward) status ******************/ /*****************************************************************************/ -static void Gam_SetMatchStatusToNextQuestion (struct Match *Match) +static void Gam_SetMatchStatusToNext (struct Match *Match) { - /***** Get index of the next question *****/ - Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, - Match->Status.QstInd); - if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished - Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod, - Match->Status.QstInd); - else // Finished + /***** What to show *****/ + switch (Match->Status.Showing) { - Match->Status.QstCod = -1L; // No more questions - Match->Status.BeingPlayed = false; + case Gam_WORDING: + Match->Status.Showing = Gam_ANSWERS; + break; + case Gam_ANSWERS: + Match->Status.Showing = Gam_REQUEST; + break; + case Gam_REQUEST: + case Gam_RESULTS: + Match->Status.Showing = Gam_WORDING; + + /***** Get index of the next question *****/ + Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, + Match->Status.QstInd); + if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished + Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod, + Match->Status.QstInd); + else // Finished + { + Match->Status.QstCod = -1L; // No more questions + Match->Status.BeingPlayed = false; + } + break; } - Match->Status.Showing = Gam_SHOWING_WORDING; // Show only the stem } /*****************************************************************************/ @@ -3794,8 +3799,6 @@ static void Gam_SetMatchStatusToNextQuestion (struct Match *Match) static void Gam_ShowMatchStatusForTch (struct Match *Match) { - extern const char *Txt_MATCH_Paused; - /***** Get current number of players *****/ Gam_GetNumPlayers (Match); @@ -3806,15 +3809,11 @@ static void Gam_ShowMatchStatusForTch (struct Match *Match) /* Start right container */ fprintf (Gbl.F.Out,"
"); - /* Top row */ + /* Top row: match title */ Gam_ShowMatchTitle (Match); - /* Bottom row */ - if (Match->Status.BeingPlayed) - /* Show current question and possible answers */ - Gam_ShowQuestionAndAnswersTch (Match); - else // Not being played - Gam_ShowWaitImage (Txt_MATCH_Paused); + /* Bottom row: current question and possible answers */ + Gam_ShowQuestionAndAnswersTch (Match); /* End right container */ fprintf (Gbl.F.Out,"
"); @@ -3910,7 +3909,7 @@ static void Gam_ShowLeftColumnTch (struct Match *Match) Gam_PutMatchControlButtons (Match); /***** Checkbox to show results *****/ - Gam_PutCheckboxResult (Match); + // Gam_PutCheckboxResult (Match); /***** Number of players *****/ Gam_ShowNumPlayers (Match); @@ -3956,95 +3955,43 @@ static void Gam_ShowLeftColumnStd (struct Match *Match) static void Gam_PutMatchControlButtons (struct Match *Match) { - extern const char *Txt_Stem; - extern const char *Txt_MATCH_Start; - extern const char *Txt_Previous_QUESTION; + extern const char *Txt_Go_back; + extern const char *Txt_Go_forward; extern const char *Txt_Pause; extern const char *Txt_Start; extern const char *Txt_Resume; - extern const char *Txt_Next_QUESTION; - extern const char *Txt_Answers; - extern const char *Txt_View_results; - extern const char *Txt_Finish; - unsigned PrvQstInd; // Previous question index - unsigned NxtQstInd; // Next question index /***** Start buttons container *****/ fprintf (Gbl.F.Out,"
"); /***** Left button *****/ fprintf (Gbl.F.Out,"
"); - if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished - { - if (Match->Status.BeingPlayed) - { - switch (Match->Status.Showing) - { - case Gam_SHOWING_WORDING: - /* Put button to show stem of current question, hiding answers */ - Gam_PutBigButton (ActPrvQstMchTch,Match->MchCod, - Gam_ICON_PREVIOUS,Txt_Previous_QUESTION); - break; - case Gam_SHOWING_ANSWERS: - /* Put button to show stem of current question, hiding answers */ - Gam_PutBigButton (ActShoSteMchTch,Match->MchCod, - Gam_ICON_PREVIOUS,Txt_Stem); - break; - case Gam_REQUEST_RESULTS: - /* Put button to show stem of current question, hiding answers */ - Gam_PutBigButton (ActShoAnsMchTch,Match->MchCod, - Gam_ICON_PREVIOUS,Txt_Stem); - break; - } - } - else if (Match->Status.QstInd == 0) - { - if (Match->Status.BeingPlayed) - /* Put button to go to start of match before first question */ - Gam_PutBigButton (ActPrvQstMchTch,Match->MchCod, - Gam_ICON_PREVIOUS,Txt_MATCH_Start); - else // Not being played - /* Put button to close browser tab */ - Gam_PutBigButtonClose (); - } - else - { - /* Get index of the previous question */ - PrvQstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, - Match->Status.QstInd); - if (PrvQstInd == 0) // There is not a previous question - /* Put button to resume match before first question */ - Gam_PutBigButton (ActPrvQstMchTch,Match->MchCod, - Gam_ICON_PREVIOUS,Txt_MATCH_Start); - else // There is a previous question - /* Put button to show previous question */ - Gam_PutBigButton (ActPrvQstMchTch,Match->MchCod, - Gam_ICON_PREVIOUS,Txt_Previous_QUESTION); - } - } - else // Finished - /* Put button to show last question */ - Gam_PutBigButton (ActPrvQstMchTch,Match->MchCod, - Gam_ICON_PREVIOUS,Txt_Previous_QUESTION); - + if (Match->Status.QstInd == 0) + /* Put button to close browser tab */ + Gam_PutBigButtonClose (); + else + /* Put button to go back */ + Gam_PutBigButton (ActBckMchTch,Match->MchCod, + Gam_ICON_PREVIOUS,Txt_Go_back); fprintf (Gbl.F.Out,"
"); /***** Center button *****/ fprintf (Gbl.F.Out,"
"); - if (Match->Status.BeingPlayed) + if (Match->Status.BeingPlayed) // Being played /* Put button to pause match */ Gam_PutBigButton (ActPauMchTch, Match->MchCod, Gam_ICON_PAUSE,Txt_Pause); - else + else // Paused { if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Not finished - /* Put button to resume match */ + /* Put button to play match */ Gam_PutBigButton (ActPlyMchTch, Match->MchCod, Gam_ICON_PLAY,Match->Status.QstInd == 0 ? Txt_Start : Txt_Resume); else // Finished + /* Put disabled button to play match */ Gam_PutBigButtonOff (Gam_ICON_PLAY); } fprintf (Gbl.F.Out,"
"); @@ -4055,103 +4002,15 @@ static void Gam_PutMatchControlButtons (struct Match *Match) /* Put button to close browser tab */ Gam_PutBigButtonClose (); else - { - /* Get index of the next question */ - NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, - Match->Status.QstInd); - if (Match->Status.BeingPlayed) // Being played - { - if (Match->Status.Showing == Gam_SHOWING_WORDING) // Not showing answers - { - if (Match->Status.QstInd == 0) - /* Put button to show first question */ - Gam_PutBigButton (ActNxtQstMchTch,Match->MchCod, - Gam_ICON_NEXT,Txt_Next_QUESTION); - else - /* Put button to show answers */ - Gam_PutBigButton (ActShoAnsMchTch,Match->MchCod, - Gam_ICON_NEXT,Txt_Answers); - } - else // Showing answers - { - if (Match->Status.ShowResults) // Show results - { - /* Put button to show results */ - Gam_PutBigButton (ActShoResMchTch,Match->MchCod, - Gam_ICON_NEXT,Txt_View_results); - } - else // Don't show results - { - if (NxtQstInd >= Gam_AFTER_LAST_QUESTION) // No more questions - /* Put button to finish */ - Gam_PutBigButton (ActNxtQstMchTch,Match->MchCod, - Gam_ICON_NEXT,Txt_Finish); - else // There are more questions - /* Put button to show next question */ - Gam_PutBigButton (ActNxtQstMchTch,Match->MchCod, - Gam_ICON_NEXT,Txt_Next_QUESTION); - } - } - } - else // Not being played - { - if (NxtQstInd >= Gam_AFTER_LAST_QUESTION) // No more questions - /* Put button to finish */ - Gam_PutBigButton (ActNxtQstMchTch,Match->MchCod, - Gam_ICON_NEXT,Txt_Finish); - else // There are more questions - /* Put button to show next question */ - Gam_PutBigButton (ActNxtQstMchTch,Match->MchCod, - Gam_ICON_NEXT,Txt_Next_QUESTION); - } - } + /* Put button to show answers */ + Gam_PutBigButton (ActFwdMchTch,Match->MchCod, + Gam_ICON_NEXT,Txt_Go_forward); fprintf (Gbl.F.Out,"
"); /***** End buttons container *****/ fprintf (Gbl.F.Out,""); } -/*****************************************************************************/ -/***************** Put checkbox to select if show results ********************/ -/*****************************************************************************/ - -static void Gam_PutCheckboxResult (struct Match *Match) - { - extern const char *Txt_View_results; - - /***** Start container *****/ - fprintf (Gbl.F.Out,"
"); - - /***** Start form *****/ - Frm_StartForm (ActChgShoResMchTch); - Gam_PutParamMatchCod (Match->MchCod); // Current match being played - - /***** 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,"", - 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,"
"); - } - /*****************************************************************************/ /********************* Show number of question in game ***********************/ /*****************************************************************************/ @@ -4203,11 +4062,14 @@ static void Gam_ShowMatchTitle (struct Match *Match) static void Gam_ShowQuestionAndAnswersTch (struct Match *Match) { + extern const char *Txt_MATCH_Paused; + extern const char *Txt_View_results; MYSQL_RES *mysql_res; MYSQL_ROW row; - /***** Trivial check: Question index should be > 0 *****/ - if (Match->Status.QstInd == 0) + /***** Trivial check: question index should be correct *****/ + if (Match->Status.QstInd == 0 || + Match->Status.QstInd >= Gam_AFTER_LAST_QUESTION) return; /***** Get data of question from database *****/ @@ -4241,16 +4103,77 @@ static void Gam_ShowQuestionAndAnswersTch (struct Match *Match) "TEST_MED_EDIT_LIST_STEM"); /* Write answers? */ - if (Match->Status.Showing == Gam_SHOWING_ANSWERS) - /* Write answers */ - Tst_WriteAnswersGameResult (Match->GamCod, - Match->Status.QstInd, - Match->Status.QstCod, - "MATCH_TCH_QST",false); // Don't show result + switch (Match->Status.Showing) + { + case Gam_WORDING: + /* Don't write anything */ + break; + case Gam_ANSWERS: + if (Match->Status.BeingPlayed) + /* Write answers */ + Tst_WriteAnswersGameResult (Match->GamCod, + Match->Status.QstInd, + Match->Status.QstCod, + "MATCH_TCH_QST",false); // Don't show result + else // Not being played + Gam_ShowWaitImage (Txt_MATCH_Paused); + break; + case Gam_REQUEST: + /* Write button to request viewing results */ + Gam_PutBigButton (ActShoResMchTch,Match->MchCod, + Gam_ICON_RESULTS,Txt_View_results); + break; + case Gam_RESULTS: + /* Show results */ + fprintf (Gbl.F.Out,"%s","Resultados aquí"); // TODO: Show results here + break; + } fprintf (Gbl.F.Out,""); } +/*****************************************************************************/ +/************************ Put button to show results *************************/ +/*****************************************************************************/ +/* +static void Gam_PutCheckboxResult (struct Match *Match) + { + extern const char *Txt_View_results; + + ***** Start container ***** + fprintf (Gbl.F.Out,"
"); + + ***** Start form ***** + Frm_StartForm (ActChgShoResMchTch); + Gam_PutParamMatchCod (Match->MchCod); // Current match being played + + ***** 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,"", + 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,"
"); + } +*/ + /*****************************************************************************/ /***** Show question and its answers when playing a match (as a student) *****/ /*****************************************************************************/ @@ -4268,7 +4191,7 @@ static void Gam_ShowQuestionAndAnswersStd (struct Match *Match) /***** Show question *****/ /* Write buttons for answers? */ - if (Match->Status.Showing == Gam_SHOWING_ANSWERS) + if (Match->Status.Showing == Gam_ANSWERS) { if (Tst_CheckIfQuestionIsValidForGame (Match->Status.QstCod)) { diff --git a/swad_game.h b/swad_game.h index 4d86a3771..6806899b4 100644 --- a/swad_game.h +++ b/swad_game.h @@ -123,12 +123,12 @@ void Gam_CreateNewMatchTch (void); void Gam_RequestStartResumeMatchTch (void); void Gam_PauseMatchTch (void); void Gam_ResumeMatchTch (void); -void Gam_ShowStemQstMatchTch (void); -void Gam_ShowAnssQstMatchTch (void); -void Gam_ShowRessQstMatchTch (void); -void Gam_PrevQstMatchTch (void); -void Gam_NextQstMatchTch (void); -void Gam_CurrQstMatchTch (void); +// void Gam_ShowStemQstMatchTch (void); +// void Gam_ShowAnssQstMatchTch (void); +void Gam_ShowResultsQstMatchTch (void); +void Gam_BackMatchTch (void); +void Gam_ForwardMatchTch (void); +// void Gam_CurrQstMatchTch (void); void Gam_ShowFinishedMatchResults (void); diff --git a/swad_layout.c b/swad_layout.c index 807a4083c..f937b643a 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -698,12 +698,9 @@ static void Lay_WriteScriptInit (void) case ActResMchTch: case ActPauMchTch: case ActPlyMchTch: - case ActShoSteMchTch: - case ActShoAnsMchTch: + case ActBckMchTch: + case ActFwdMchTch: case ActShoResMchTch: - case ActPrvQstMchTch: - case ActNxtQstMchTch: - case ActChgShoResMchTch: case ActPlyMchStd: case ActAnsMchQstStd: RefreshGame = true; @@ -824,12 +821,9 @@ static void Lay_WriteScriptParamsAJAX (void) case ActResMchTch: case ActPauMchTch: case ActPlyMchTch: - case ActShoSteMchTch: - case ActShoAnsMchTch: + case ActBckMchTch: + case ActFwdMchTch: case ActShoResMchTch: - case ActPrvQstMchTch: - case ActNxtQstMchTch: - case ActChgShoResMchTch: fprintf (Gbl.F.Out,"var RefreshParamNxtActGam = \"act=%ld\";\n" "var RefreshParamMchCod = \"MchCod=%ld\";\n", Act_GetActCod (ActRefMchTch), diff --git a/swad_survey.c b/swad_survey.c index 7b91cd934..4699b95b8 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -2576,7 +2576,7 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst, extern const char *The_ClassFormInBox[The_NUM_THEMES]; extern const char *Txt_Question; extern const char *Txt_New_question; - extern const char *Txt_Stem; + extern const char *Txt_Wording; extern const char *Txt_Type; extern const char *Txt_SURVEY_STR_ANSWER_TYPES[Svy_NUM_ANS_TYPES]; extern const char *Txt_Save_changes; @@ -2674,7 +2674,7 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst, "" "" "", - The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Stem, + The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Wording, Txt); /***** Type of answer *****/ diff --git a/swad_test.c b/swad_test.c index 9fc82f015..8fc802792 100644 --- a/swad_test.c +++ b/swad_test.c @@ -4932,7 +4932,7 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1], extern const char *Txt_New_question; extern const char *Txt_Tags; extern const char *Txt_new_tag; - extern const char *Txt_Stem; + extern const char *Txt_Wording; extern const char *Txt_Feedback; extern const char *Txt_optional; extern const char *Txt_Type; @@ -5069,7 +5069,7 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1], "%s" "
", The_ClassFormInBox[Gbl.Prefs.Theme], - Txt_Stem, + Txt_Wording, Stem); Tst_PutFormToEditQstMedia (&Gbl.Test.Media,-1, false); diff --git a/swad_text.c b/swad_text.c index 8f0b7d16d..1e2f3e7b7 100644 --- a/swad_text.c +++ b/swad_text.c @@ -12225,7 +12225,7 @@ const char *Txt_Filter = // As a noun #elif L==9 // pt "Filtro"; #endif - +/* const char *Txt_Finish = #if L==1 // ca "Acabar"; @@ -12246,6 +12246,7 @@ const char *Txt_Finish = #elif L==9 // pt "Terminar"; #endif +*/ /* const char *Txt_Finished_match = #if L==1 // ca @@ -13888,6 +13889,27 @@ const char *Txt_Go_back = "Voltar"; #endif +const char *Txt_Go_forward = +#if L==1 // ca + "Anar endavant"; +#elif L==2 // de + "Vorwärts gehen"; +#elif L==3 // en + "Go forward"; +#elif L==4 // es + "Avanzar"; +#elif L==5 // fr + "Aller de l'avant"; +#elif L==6 // gn + "Avanzar"; // Okoteve traducción +#elif L==7 // it + "Avanzare"; +#elif L==8 // pl + "Idź napród"; +#elif L==9 // pt + "Avançar"; +#endif + const char *Txt_Go_to_X = // Warning: it is very important to include %s in the following sentences #if L==1 // ca "Ir a %s"; // Necessita traduccio @@ -24463,7 +24485,7 @@ const char *Txt_NEW_YEAR_GREETING = // Warning: it is very important to include #elif L==9 // pt "Feliz %u!"; #endif - +/* const char *Txt_Next_QUESTION = #if L==1 // ca "Següent"; @@ -24484,7 +24506,7 @@ const char *Txt_Next_QUESTION = #elif L==9 // pt "Seguinte"; #endif - +*/ const char *Txt_nick_email_or_ID = #if L==1 // ca "@sobrenom, correu o ID (DNI/cèdula)"; @@ -29751,7 +29773,7 @@ const char *Txt_Presents = #elif L==9 // pt "Presentes"; #endif - +/* const char *Txt_Previous_QUESTION = #if L==1 // ca "Anterior"; @@ -29772,7 +29794,7 @@ const char *Txt_Previous_QUESTION = #elif L==9 // pt "Anterior"; #endif - +*/ const char *Txt_Print = #if L==1 // ca "Imprimir"; @@ -41476,27 +41498,6 @@ const char *Txt_Stay_connected_with_SWADroid = "Fique ligado/a com SWADroid."; #endif -const char *Txt_Stem = // Stem of a test question -#if L==1 // ca - "Enunciat"; -#elif L==2 // de - "Stamm"; -#elif L==3 // en - "Stem"; -#elif L==4 // es - "Enunciado"; -#elif L==5 // fr - "Question"; -#elif L==6 // gn - "Enunciado"; // Okoteve traducción -#elif L==7 // it - "Domanda"; -#elif L==8 // pl - "Stem"; // Potrzebujesz tlumaczenie -#elif L==9 // pt - "Questão"; -#endif - const char *Txt_Step_1_Provide_a_list_of_users = #if L==1 // ca "Paso 1: Proporcione una lista de usuarios"; // Necessita traduccio @@ -53311,6 +53312,27 @@ const char *Txt_works_ZIP_FILE_NAME = // Name (without extension) of the ZIP fil "trabalhos"; #endif +const char *Txt_Wording = // Statement of a question +#if L==1 // ca + "Enunciat"; +#elif L==2 // de + "Aussage"; +#elif L==3 // en + "Wording"; +#elif L==4 // es + "Enunciado"; +#elif L==5 // fr + "Énoncé"; +#elif L==6 // gn + "Enunciado"; // Okoteve traducción +#elif L==7 // it + "Formulazione"; +#elif L==8 // pl + "Sformułowanie"; +#elif L==9 // pt + "Redação"; +#endif + const char *Txt_Works_area = #if L==1 // ca "Zona d'altres treballs";