diff --git a/sql/swad.sql b/sql/swad.sql index f729847fb..f99690ad6 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -637,11 +637,11 @@ CREATE TABLE IF NOT EXISTS mch_matches ( StartTime DATETIME NOT NULL, EndTime DATETIME NOT NULL, Title VARCHAR(2047) NOT NULL, - VisibleResult ENUM('N','Y') NOT NULL DEFAULT 'N', QstInd INT NOT NULL DEFAULT 0, QstCod INT NOT NULL DEFAULT -1, - ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y', Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing', + ShowQstResults ENUM('N','Y') NOT NULL DEFAULT 'N', + ShowUsrResults ENUM('N','Y') NOT NULL DEFAULT 'N', UNIQUE INDEX(MchCod), INDEX(GamCod)); -- diff --git a/swad_action.c b/swad_action.c index b59331ca2..36c7b0a44 100644 --- a/swad_action.c +++ b/swad_action.c @@ -617,10 +617,10 @@ Assessment: NEW. ActBckMchTch Go back when playing a match (by a teacher) 457. ActFwdMchTch Go forward 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. ActShoMchTch Show finished match results + + NEW. ActChgVisResMchQst Change visibility of question results when playing a match + NEW. ActChgVisResMchUsr Change visibility of match results (exam with all questions for a student) NEW. ActPlyMchStd Show current question when playing a game (as student) NEW. ActRefMchStd Refresh current question when playing a game (as student) @@ -2167,9 +2167,9 @@ 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}, /* 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}, - /* 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}, - /* ActShoMchTch */{1786,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_ShowFinishedMatchResults ,NULL}, + /* ActChgVisResMchQst*/{1794,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_ToggleVisibilResultsMchQst ,NULL}, + /* ActChgVisResMchUsr*/{1801,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_ToggleVisibilResultsMchUsr ,NULL}, /* ActPlyMchStd */{1780,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Mch_GetMatchBeingPlayed ,Mch_ShowMatchToMeAsStd ,NULL}, /* ActRefMchStd */{1782,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Mch_GetMatchBeingPlayed ,Mch_RefreshMatchStd ,NULL}, @@ -5016,7 +5016,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActReqRemMchTch, // #1783 ActRemMchTch, // #1784 ActResMchTch, // #1785 - ActShoMchTch, // #1786 + -1, // #1786 (obsolete action) ActCreMyAcc, // #1787 ActRefMchTch, // #1788 ActPlyMchTch, // #1789 @@ -5024,13 +5024,14 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActPauMchTch, // #1791 -1, // #1792 (obsolete action) -1, // #1793 (obsolete action) - ActChgDisResMchTch, // #1794 + ActChgVisResMchQst, // #1794 ActReqSeeMyMchRes, // #1795 ActSeeMyMchRes, // #1796 ActSeeOneMchResMe, // #1797 ActReqSeeUsrMchRes, // #1798 ActSeeUsrMchRes, // #1799 ActSeeOneMchResOth, // #1800 + ActChgVisResMchUsr, // #1801 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 08dfa2ffc..ea1cecab2 100644 --- a/swad_action.h +++ b/swad_action.h @@ -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 + 177 + 437 + 176 + 169 + 16 + 68) -#define Act_MAX_ACTION_COD 1800 +#define Act_MAX_ACTION_COD 1801 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 @@ -616,9 +616,9 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActPlyMchTch (ActChgCrsTT1stDay + 123) #define ActBckMchTch (ActChgCrsTT1stDay + 124) #define ActFwdMchTch (ActChgCrsTT1stDay + 125) -#define ActChgDisResMchTch (ActChgCrsTT1stDay + 126) -#define ActRefMchTch (ActChgCrsTT1stDay + 127) -#define ActShoMchTch (ActChgCrsTT1stDay + 128) +#define ActRefMchTch (ActChgCrsTT1stDay + 126) +#define ActChgVisResMchQst (ActChgCrsTT1stDay + 127) +#define ActChgVisResMchUsr (ActChgCrsTT1stDay + 128) #define ActPlyMchStd (ActChgCrsTT1stDay + 129) #define ActRefMchStd (ActChgCrsTT1stDay + 130) #define ActAnsMchQstStd (ActChgCrsTT1stDay + 131) diff --git a/swad_changelog.h b/swad_changelog.h index 0da08d09f..0d672d077 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -470,12 +470,21 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.13.3 (2019-09-25)" +#define Log_PLATFORM_VERSION "SWAD 19.14 (2019-09-25)" #define CSS_FILE "swad19.3.css" #define JS_FILE "swad18.130.2.js" /* // TODO: Poner columna en listado de juegos que indique el número de partidas // TODO: Imposibilitar la edición de preguntas de un juego cuando tenga partidas +// TODO: Evitar que el estudiante vea resultados de partidas cuando están ocultos + + Version 19.14: Sep 25, 2019 New actions to show/hide match results. (246152 lines) + 5 changes necessary in database: +ALTER TABLE mch_matches DROP COLUMN VisibleResult,DROP COLUMN ShowResults; +ALTER TABLE mch_matches ADD COLUMN ShowQstResults ENUM('N','Y') NOT NULL DEFAULT 'N' AFTER Showing; +ALTER TABLE mch_matches ADD COLUMN ShowUsrResults ENUM('N','Y') NOT NULL DEFAULT 'N' AFTER ShowQstResults; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1801','es','N','Cambiar visibilidad de resultados de una partida'); +UPDATE actions SET Obsolete='Y' WHERE ActCod=1786; Version 19.13.3: Sep 25, 2019 Code refactoring in match listing. (246123 lines) Version 19.13.2: Sep 25, 2019 Code refactoring in match listing. (246086 lines) diff --git a/swad_database.c b/swad_database.c index d72aea595..20695ef1e 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1371,21 +1371,21 @@ mysql> DESCRIBE mch_groups; /***** Table mch_matches *****/ /* mysql> DESCRIBE mch_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 | | -| VisibleResult | enum('N','Y') | NO | | N | | -| QstInd | int(11) | NO | | 0 | | -| QstCod | int(11) | NO | | -1 | | -| ShowResults | enum('N','Y') | NO | | Y | | -| Showing | enum('nothing','stem','answers','results') | NO | | nothing | | -+---------------+--------------------------------------------+------+-----+---------+----------------+ ++----------------+--------------------------------------------+------+-----+---------+----------------+ +| 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 | | +| Showing | enum('nothing','stem','answers','results') | NO | | nothing | | +| ShowQstResults | enum('N','Y') | NO | | N | | +| ShowUsrResults | enum('N','Y') | NO | | N | | ++----------------+--------------------------------------------+------+-----+---------+----------------+ 11 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS mch_matches (" @@ -1395,11 +1395,11 @@ mysql> DESCRIBE mch_matches; "StartTime DATETIME NOT NULL," "EndTime DATETIME NOT NULL," "Title VARCHAR(2047) NOT NULL," // Gam_MAX_BYTES_TITLE - "VisibleResult ENUM('N','Y') NOT NULL DEFAULT 'N'," "QstInd INT NOT NULL DEFAULT 0," "QstCod INT NOT NULL DEFAULT -1," - "ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y'," "Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing'," + "ShowQstResults ENUM('N','Y') NOT NULL DEFAULT 'N'," + "ShowUsrResults ENUM('N','Y') NOT NULL DEFAULT 'N'," "UNIQUE INDEX(MchCod)," "INDEX(GamCod)"); diff --git a/swad_game.c b/swad_game.c index 70987e892..d0ac42ba5 100644 --- a/swad_game.c +++ b/swad_game.c @@ -2442,3 +2442,33 @@ float Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope) return NumQstsPerGame; } + +/*****************************************************************************/ +/************************* Show test tags in a game **************************/ +/*****************************************************************************/ + +void Gam_ShowTstTagsPresentInAGame (long GamCod) + { + MYSQL_RES *mysql_res; + unsigned long NumTags; + + /***** Get all tags of questions in this game *****/ + NumTags = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get tags" + " present in a match result", + "SELECT tst_tags.TagTxt" // row[0] + " FROM" + " (SELECT DISTINCT(tst_question_tags.TagCod)" + " FROM tst_question_tags,gam_questions" + " WHERE gam_questions.GamCod=%ld" + " AND gam_questions.QstCod=tst_question_tags.QstCod)" + " AS TagsCods,tst_tags" + " WHERE TagsCods.TagCod=tst_tags.TagCod" + " ORDER BY tst_tags.TagTxt", + GamCod); + Tst_ShowTagList (NumTags,mysql_res); + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + diff --git a/swad_game.h b/swad_game.h index ccbcba616..ab2aff075 100644 --- a/swad_game.h +++ b/swad_game.h @@ -123,4 +123,6 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope); unsigned Gam_GetNumGames (Hie_Level_t Scope); float Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope); +void Gam_ShowTstTagsPresentInAGame (long GamCod); + #endif diff --git a/swad_layout.c b/swad_layout.c index 3a6e02535..9a5191df6 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -700,7 +700,7 @@ static void Lay_WriteScriptInit (void) case ActPlyMchTch: case ActBckMchTch: case ActFwdMchTch: - case ActChgDisResMchTch: + case ActChgVisResMchQst: case ActPlyMchStd: case ActAnsMchQstStd: RefreshGame = true; @@ -823,7 +823,7 @@ static void Lay_WriteScriptParamsAJAX (void) case ActPlyMchTch: case ActBckMchTch: case ActFwdMchTch: - case ActChgDisResMchTch: + case ActChgVisResMchQst: fprintf (Gbl.F.Out,"var RefreshParamNxtActGam = \"act=%ld\";\n" "var RefreshParamMchCod = \"MchCod=%ld\";\n", Act_GetActCod (ActRefMchTch), diff --git a/swad_match.c b/swad_match.c index 5091db71a..e5531e6f3 100644 --- a/swad_match.c +++ b/swad_match.c @@ -87,17 +87,17 @@ struct Match long UsrCod; time_t TimeUTC[Dat_NUM_START_END_TIME]; char Title[Gam_MAX_BYTES_TITLE + 1]; - bool VisibleResult; struct { unsigned QstInd; // 0 means that the game has not started. First question has index 1. long QstCod; time_t QstStartTimeUTC; - bool ShowResults; // Show results while playing? - Mch_Showing_t Showing; // What is shown on teacher's screen? + Mch_Showing_t Showing; // What is shown on teacher's screen + bool ShowQstResults; // Show global results of current question while playing + bool ShowUsrResults; // Show exam with results of all questions for the student bool Playing; // Is being played now? unsigned NumPlayers; - } Status; + } Status; // Status related to match playing }; struct Mch_UsrAnswer @@ -234,7 +234,6 @@ static void Mch_GetMatchResultDataByMchCod (long MchCod,long UsrCod, unsigned *NumQsts, unsigned *NumQstsNotBlank, double *Score); -static void Mch_ShowTstTagsPresentInAMatchResult (long GamCod); /*****************************************************************************/ /************************* List the matches of a game ************************/ @@ -271,16 +270,17 @@ void Mch_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] - "QstInd," // row[6] - "QstCod," // row[7] - "ShowResults," // row[8] - "Showing" // row[9] + "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] + "Showing," // row[ 8] + "ShowQstResults," // row[ 9] + "ShowUsrResults" // row[10] " FROM mch_matches" " WHERE GamCod=%ld%s" " ORDER BY MchCod", @@ -333,16 +333,17 @@ static void Mch_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] - "QstInd," // row[6] - "QstCod," // row[7] - "ShowResults," // row[8] - "Showing" // row[9] + "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] + "Showing," // row[ 8] + "ShowQstResults," // row[ 9] + "ShowUsrResults" // row[10] " FROM mch_matches" " WHERE MchCod=%ld" " AND GamCod IN" // Extra check @@ -364,13 +365,14 @@ static void Mch_GetDataOfMatchByCod (struct Match *Match) StartEndTime++) Match->TimeUTC[StartEndTime] = (time_t) 0; Match->Title[0] = '\0'; - Match->VisibleResult = false; Match->Status.QstInd = 0; Match->Status.QstCod = -1L; Match->Status.QstStartTimeUTC = (time_t) 0; - Match->Status.ShowResults = true; Match->Status.Showing = Mch_STEM; Match->Status.Playing = false; + Match->Status.NumPlayers = 0; + Match->Status.ShowQstResults = false; + Match->Status.ShowUsrResults = false; } /***** Free structure that stores the query result *****/ @@ -484,10 +486,10 @@ static void Mch_ListOneOrMoreMatchesHeading (void) "