From 2171d7dab770246dc53284f15d3abd4af2b23e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 25 Sep 2019 00:28:57 +0200 Subject: [PATCH] Version19.13.1 --- swad_changelog.h | 3 +- swad_match.c | 178 +++++++++++++++++++++++++++-------------------- 2 files changed, 103 insertions(+), 78 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index db6bb6e9d..0d90bfe22 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.13 (2019-09-25)" +#define Log_PLATFORM_VERSION "SWAD 19.13.1 (2019-09-25)" #define CSS_FILE "swad19.3.css" #define JS_FILE "swad18.130.2.js" /* + Version 19.13.1: Sep 25, 2019 Code refactoring in match listing. (246061 lines) Version 19.13: Sep 25, 2019 Column for visibility in match listing. (246044 lines) 1 change necessary in database: ALTER TABLE mch_matches ADD COLUMN VisibleResult ENUM('N','Y') NOT NULL DEFAULT 'N' AFTER Title; diff --git a/swad_match.c b/swad_match.c index 5d30e35a9..4baa30782 100644 --- a/swad_match.c +++ b/swad_match.c @@ -134,6 +134,8 @@ static void Mch_PutIconToPlayNewMatch (void); static void Mch_ListOneOrMoreMatches (struct Game *Game, unsigned NumMatches, MYSQL_RES *mysql_res); +static void Mch_PutCellStatus (const struct Match *Match,unsigned NumQsts); +static void Mch_PutCellVisibleResult (const struct Match *Match); static void Mch_GetAndWriteNamesOfGrpsAssociatedToMatch (struct Match *Match); static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res, struct Match *Match); @@ -394,11 +396,7 @@ static void Mch_ListOneOrMoreMatches (struct Game *Game, extern const char *Txt_Players; extern const char *Txt_Status; extern const char *Txt_Result; - extern const char *Txt_Play; - extern const char *Txt_Resume; extern const char *Txt_Today; - extern const char *Txt_Visible_result; - extern const char *Txt_Hidden_result; unsigned NumMatch; unsigned UniqueId; struct Match Match; @@ -515,81 +513,10 @@ static void Mch_ListOneOrMoreMatches (struct Game *Game, Mch_GetNumUsrsWhoHaveAnswerMch (Match.MchCod)); /***** Match status ******/ - fprintf (Gbl.F.Out,"",Gbl.RowEvenOdd); - - if (Match.Status.QstInd < Mch_AFTER_LAST_QUESTION) // Unfinished match - /* Current question index / total of questions */ - fprintf (Gbl.F.Out,"
%u/%u
", - Match.Status.QstInd,Game->NumQsts); - - switch (Gbl.Usrs.Me.Role.Logged) - { - case Rol_STD: - /* Icon to play as student */ - Mch_CurrentMchCod = Match.MchCod; - Lay_PutContextualLinkOnlyIcon (ActPlyMchStd,NULL, - Mch_PutParamCurrentMchCod, - Match.Status.QstInd < Mch_AFTER_LAST_QUESTION ? "play.svg" : - "flag-checkered.svg", - Txt_Play); - break; - case Rol_NET: - case Rol_TCH: - case Rol_DEG_ADM: - case Rol_CTR_ADM: - case Rol_INS_ADM: - case Rol_SYS_ADM: - /* Icon to resume */ - Mch_CurrentMchCod = Match.MchCod; - Lay_PutContextualLinkOnlyIcon (ActResMchTch,NULL, - Mch_PutParamCurrentMchCod, - Match.Status.QstInd < Mch_AFTER_LAST_QUESTION ? "play.svg" : - "flag-checkered.svg", - Txt_Resume); - break; - default: - break; - } - - fprintf (Gbl.F.Out,""); + Mch_PutCellStatus (&Match,Game->NumQsts); /***** Match result visible? *****/ - fprintf (Gbl.F.Out,"",Gbl.RowEvenOdd); - switch (Gbl.Usrs.Me.Role.Logged) - { - case Rol_STD: - /* Match result visible or hidden? */ - if (Match.VisibleResult) - Ico_PutIconOff ("eye.svg",Txt_Visible_result); - else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); - break; - case Rol_NET: - case Rol_TCH: - case Rol_DEG_ADM: - case Rol_CTR_ADM: - case Rol_INS_ADM: - case Rol_SYS_ADM: - /* Match result visible or hidden? */ - if (Match.VisibleResult) - Ico_PutIconOff ("eye.svg",Txt_Visible_result); - else - Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); - break; - /*// TODO: Put icon to make visible / to hide - / Icon to resume / - Mch_CurrentMchCod = Match.MchCod; - Lay_PutContextualLinkOnlyIcon (ActResMchTch,NULL, - Mch_PutParamCurrentMchCod, - Match.Status.QstInd < Mch_AFTER_LAST_QUESTION ? "play.svg" : - "flag-checkered.svg", - Txt_Resume); - */ - break; - default: - break; - } - fprintf (Gbl.F.Out,""); + Mch_PutCellVisibleResult (&Match); fprintf (Gbl.F.Out,""); } @@ -598,6 +525,103 @@ static void Mch_ListOneOrMoreMatches (struct Game *Game, Tbl_EndTable (); } +/*****************************************************************************/ +/********************** Put a column for match status ************************/ +/*****************************************************************************/ + +static void Mch_PutCellStatus (const struct Match *Match,unsigned NumQsts) + { + extern const char *Txt_Play; + extern const char *Txt_Resume; + + fprintf (Gbl.F.Out,"",Gbl.RowEvenOdd); + + if (Match->Status.QstInd < Mch_AFTER_LAST_QUESTION) // Unfinished match + /* Current question index / total of questions */ + fprintf (Gbl.F.Out,"
%u/%u
", + Match->Status.QstInd,NumQsts); + + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_STD: + /* Icon to play as student */ + Mch_CurrentMchCod = Match->MchCod; + Lay_PutContextualLinkOnlyIcon (ActPlyMchStd,NULL, + Mch_PutParamCurrentMchCod, + Match->Status.QstInd < Mch_AFTER_LAST_QUESTION ? "play.svg" : + "flag-checkered.svg", + Txt_Play); + break; + case Rol_NET: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + /* Icon to resume */ + Mch_CurrentMchCod = Match->MchCod; + Lay_PutContextualLinkOnlyIcon (ActResMchTch,NULL, + Mch_PutParamCurrentMchCod, + Match->Status.QstInd < Mch_AFTER_LAST_QUESTION ? "play.svg" : + "flag-checkered.svg", + Txt_Resume); + break; + default: + break; + } + + fprintf (Gbl.F.Out,""); + } + +/*****************************************************************************/ +/**************** Put a column for visibility of match result ****************/ +/*****************************************************************************/ + +static void Mch_PutCellVisibleResult (const struct Match *Match) + { + extern const char *Txt_Visible_result; + extern const char *Txt_Hidden_result; + + fprintf (Gbl.F.Out,"",Gbl.RowEvenOdd); + + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_STD: + /* Match result visible or hidden? */ + if (Match->VisibleResult) + Ico_PutIconOff ("eye.svg",Txt_Visible_result); + else + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + break; + case Rol_NET: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + /* Match result visible or hidden? */ + if (Match->VisibleResult) + Ico_PutIconOff ("eye.svg",Txt_Visible_result); + else + Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result); + break; + /*// TODO: Put icon to make visible / to hide + / Icon to resume / + Mch_CurrentMchCod = Match.MchCod; + Lay_PutContextualLinkOnlyIcon (ActResMchTch,NULL, + Mch_PutParamCurrentMchCod, + Match.Status.QstInd < Mch_AFTER_LAST_QUESTION ? "play.svg" : + "flag-checkered.svg", + Txt_Resume); + */ + break; + default: + break; + } + + fprintf (Gbl.F.Out,""); + } + /*****************************************************************************/ /************* Get and write the names of the groups of a match **************/ /*****************************************************************************/