From 851f558ee86e041168ab0836f03a3685322ddcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 24 Sep 2019 22:48:25 +0200 Subject: [PATCH] Version19.12.6 --- swad_changelog.h | 3 ++- swad_match.c | 53 ++++++++++++++++++++++++++++++++++++++++++++---- swad_test.c | 35 +++++++++++++++++++++----------- swad_test.h | 2 ++ 4 files changed, 76 insertions(+), 17 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 8ae7c06b3..04fd296e0 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -470,10 +470,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.12.5 (2019-09-24)" +#define Log_PLATFORM_VERSION "SWAD 19.12.6 (2019-09-24)" #define CSS_FILE "swad19.3.css" #define JS_FILE "swad18.130.2.js" /* + Version 19.12.6: Sep 24, 2019 View tag list in a match result. (245974 lines) Version 19.12.5: Sep 24, 2019 View matches results. (245925 lines) Version 19.12.4: Sep 24, 2019 Fixed bug in edition of games. (245963 lines) Version 19.12.3: Sep 24, 2019 View matches results. Not finished. (245979 lines) diff --git a/swad_match.c b/swad_match.c index 10adabb97..e1200d73c 100644 --- a/swad_match.c +++ b/swad_match.c @@ -222,6 +222,7 @@ 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 ************************/ @@ -3254,7 +3255,8 @@ void Mch_ShowOneMchResult (void) extern const char *Txt_non_blank_QUESTIONS; extern const char *Txt_Score; extern const char *Txt_out_of_PART_OF_A_SCORE; - long MchCod; + extern const char *Txt_Tags; + struct Match Match; Usr_MeOrOther_t MeOrOther; struct UsrData *UsrDat; time_t TimeUTC[Dat_NUM_START_END_TIME]; // Match result UTC date-time @@ -3268,9 +3270,12 @@ void Mch_ShowOneMchResult (void) bool ICanViewScore; /***** Get match code *****/ - if ((MchCod = Mch_GetParamMchCod ()) == -1L) + if ((Match.MchCod = Mch_GetParamMchCod ()) == -1L) Lay_ShowErrorAndExit ("Code of match is missing."); + /***** Get data of the match from database *****/ + Mch_GetDataOfMatchByCod (&Match); + /***** Pointer to user's data *****/ MeOrOther = (Gbl.Action.Act == ActSeeOneMchResMe) ? Usr_ME : Usr_OTHER; @@ -3287,7 +3292,7 @@ void Mch_ShowOneMchResult (void) } /***** Get test result data *****/ - Mch_GetMatchResultDataByMchCod (MchCod,UsrDat->UsrCod, + Mch_GetMatchResultDataByMchCod (Match.MchCod,UsrDat->UsrCod, TimeUTC, &NumQsts, &NumQstsNotBlank, @@ -3341,7 +3346,7 @@ void Mch_ShowOneMchResult (void) if (ICanViewResult) // I am allowed to view this match result { /***** Get questions and user's answers of the match result from database *****/ - Mch_GetMatchResultQuestionsFromDB (MchCod,UsrDat->UsrCod, + Mch_GetMatchResultQuestionsFromDB (Match.MchCod,UsrDat->UsrCod, &NumQsts,&NumQstsNotBlank); /***** Start box *****/ @@ -3446,6 +3451,17 @@ void Mch_ShowOneMchResult (void) "", Txt_out_of_PART_OF_A_SCORE,Tst_SCORE_MAX); + /* Tags present in this result */ + fprintf (Gbl.F.Out,"" + "" + "%s:" + "" + "", + Txt_Tags); + Mch_ShowTstTagsPresentInAMatchResult (Match.GamCod); + fprintf (Gbl.F.Out,"" + ""); + /***** Write answers and solutions *****/ Tst_ShowTestResult (UsrDat,NumQsts,TimeUTC[Dat_START_TIME]); @@ -3588,3 +3604,32 @@ static void Mch_GetMatchResultDataByMchCod (long MchCod,long UsrCod, /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); } + +/*****************************************************************************/ +/******************** Show test tags in this match result ********************/ +/*****************************************************************************/ + +static void Mch_ShowTstTagsPresentInAMatchResult (long GamCod) + { + MYSQL_RES *mysql_res; + unsigned long NumTags; + + /***** Get all tags of questions in this test *****/ + 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_test.c b/swad_test.c index 9ff4db4d7..7466ddbc3 100644 --- a/swad_test.c +++ b/swad_test.c @@ -872,14 +872,12 @@ static void Tst_ShowTestQuestionsWhenSeeing (MYSQL_RES *mysql_res) static void Tst_ShowTstTagsPresentInATestResult (long TstCod) { - extern const char *Txt_no_tags; MYSQL_RES *mysql_res; - MYSQL_ROW row; - unsigned long NumRows; - unsigned long NumRow; + unsigned long NumTags; /***** Get all tags of questions in this test *****/ - NumRows = DB_QuerySELECT (&mysql_res,"can not get tags" + NumTags = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get tags" " present in a test result", "SELECT tst_tags.TagTxt" // row[0] " FROM" @@ -891,13 +889,29 @@ static void Tst_ShowTstTagsPresentInATestResult (long TstCod) " WHERE TagsCods.TagCod=tst_tags.TagCod" " ORDER BY tst_tags.TagTxt", TstCod); - if (NumRows) + Tst_ShowTagList (NumTags,mysql_res); + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + +/*****************************************************************************/ +/************************** Show list of test tags ***************************/ +/*****************************************************************************/ + +void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res) + { + extern const char *Txt_no_tags; + MYSQL_ROW row; + unsigned NumTag; + + if (NumTags) { /***** Write the tags *****/ fprintf (Gbl.F.Out,"