From c62b4b5f14d437afa6e7dbb0667c5bd8feeeb4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 26 Sep 2019 00:43:50 +0200 Subject: [PATCH] Version19.14.2 --- swad_changelog.h | 4 +-- swad_match.c | 88 ++++++++++++++++++++++++++++++------------------ 2 files changed, 58 insertions(+), 34 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 0a9750d21..69e09dc6a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -470,14 +470,14 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.14.1 (2019-09-25)" +#define Log_PLATFORM_VERSION "SWAD 19.14.2 (2019-09-26)" #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 el resultado de una partida cuando está oculto + Version 19.14.2: Sep 26, 2019 Student can not see a match result if hidden. (246227 lines) Version 19.14.1: Sep 25, 2019 Student can not see match results if hidden. (246207 lines) Version 19.14: Sep 25, 2019 New actions to show/hide match results. (246152 lines) 5 changes necessary in database: diff --git a/swad_match.c b/swad_match.c index 57cb48148..0a7169f08 100644 --- a/swad_match.c +++ b/swad_match.c @@ -146,7 +146,8 @@ static void Mch_ListOneOrMoreMatchesNumPlayers (const struct Match *Match); static void Mch_ListOneOrMoreMatchesStatus (const struct Match *Match,unsigned NumQsts); static void Mch_ListOneOrMoreMatchesResult (const struct Match *Match); -static bool Mch_GetIfShowUsrResults (long MchCod); +static bool Mch_CheckIfICanSeeMatchResult (long MchCod,long UsrCod); +static bool Mch_GetVisibilityMchResultFromDB (long MchCod); static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res, struct Match *Match); @@ -792,18 +793,52 @@ void Mch_ToggleVisibilResultsMchUsr (void) false); // Do not put form to start new match } +/*****************************************************************************/ +/********************* Get if I can see match result ************************/ +/*****************************************************************************/ + +static bool Mch_CheckIfICanSeeMatchResult (long MchCod,long UsrCod) + { + bool ItsMe; + bool ShowResultThisMatch; + + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_STD: + ItsMe = Usr_ItsMe (UsrCod); + if (ItsMe && Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING) + ShowResultThisMatch = Mch_GetVisibilityMchResultFromDB (MchCod); + else + ShowResultThisMatch = false; + break; + case Rol_NET: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + ShowResultThisMatch = true; + break; + default: + ShowResultThisMatch = false; + break; + } + + return ShowResultThisMatch; + } + /*****************************************************************************/ /********************* Get visibility of match result ************************/ /*****************************************************************************/ -static bool Mch_GetIfShowUsrResults (long MchCod) +static bool Mch_GetVisibilityMchResultFromDB (long MchCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRows; bool ShowUsrResults; - /***** Get data of match from database *****/ + /***** Get visibility of match result from database *****/ NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get if show result", "SELECT ShowUsrResults" // row[0] " FROM mch_matches" @@ -3196,7 +3231,6 @@ static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther) MYSQL_RES *mysql_res; MYSQL_ROW row; struct UsrData *UsrDat; - bool ItsMe; bool ShowResultThisMatch; bool ShowSummaryResults = true; unsigned NumResults; @@ -3256,28 +3290,8 @@ static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther) if ((MchCod = Str_ConvertStrCodToLongCod (row[0])) < 0) Lay_ShowErrorAndExit ("Wrong code of match."); - /* Show results? */ - switch (Gbl.Usrs.Me.Role.Logged) - { - case Rol_STD: - ItsMe = Usr_ItsMe (UsrDat->UsrCod); - if (ItsMe && Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING) - ShowResultThisMatch = Mch_GetIfShowUsrResults (MchCod); - else - ShowResultThisMatch = false; - break; - case Rol_NET: - case Rol_TCH: - case Rol_DEG_ADM: - case Rol_CTR_ADM: - case Rol_INS_ADM: - case Rol_SYS_ADM: - ShowResultThisMatch = true; - break; - default: - ShowResultThisMatch = false; - break; - } + /* Show match result? */ + ShowResultThisMatch = Mch_CheckIfICanSeeMatchResult (MchCod,UsrDat->UsrCod); ShowSummaryResults = ShowSummaryResults && ShowResultThisMatch; if (NumResult) @@ -3538,15 +3552,25 @@ void Mch_ShowOneMchResult (void) switch (Gbl.Usrs.Me.Role.Logged) { case Rol_STD: - ICanViewResult = ItsMe; - if (ItsMe) + switch (MeOrOther) { - Tst_GetConfigTstFromDB (); // To get feedback type - ICanViewScore = Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING; + case Usr_ME: + ICanViewResult = ItsMe && Match.Status.ShowUsrResults; + if (ICanViewResult) + { + Tst_GetConfigTstFromDB (); // To get feedback type + ICanViewScore = Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING; + } + else + ICanViewScore = false; + break; + default: + ICanViewResult = + ICanViewScore = false; + break; } - else - ICanViewScore = false; break; + case Rol_NET: case Rol_TCH: case Rol_DEG_ADM: case Rol_CTR_ADM: