From 3406d8be515eb9662fc27a9938e824638bcba80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 23 Sep 2019 20:09:44 +0200 Subject: [PATCH] Version19.10.2 --- swad_changelog.h | 3 +- swad_match.c | 113 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 108 insertions(+), 8 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 9415450eb..792c3723b 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.10.1 (2019-09-23)" +#define Log_PLATFORM_VERSION "SWAD 19.10.2 (2019-09-23)" #define CSS_FILE "swad19.3.css" #define JS_FILE "swad18.130.2.js" /* + Version 19.10.2: Sep 23, 2019 View matches results. Not finished. (245812 lines) Version 19.10.1: Sep 23, 2019 View matches results. Not finished. (245724 lines) Version 19.10: Sep 23, 2019 View matches results. Not finished. (245709 lines) 1 change necessary in database: diff --git a/swad_match.c b/swad_match.c index 06778951a..0a6abdffe 100644 --- a/swad_match.c +++ b/swad_match.c @@ -201,6 +201,11 @@ static void Mch_DrawBarNumUsrs (unsigned NumAnswerersAns,unsigned NumAnswerersQs static void Mch_ShowHeaderMchResults (void); static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther); +static void Mch_ShowMchResultsSummaryRow (bool ItsMe, + unsigned NumResults, + unsigned NumTotalQsts, + unsigned NumTotalQstsNotBlank, + double TotalScoreOfAllResults); static void Mch_GetMatchResultQuestionsFromDB (long MchCod,long UsrCod); static void Mch_GetMatchResultDataByMchCod (long MchCod,long UsrCod, time_t TimeUTC[Dat_NUM_START_END_TIME], @@ -2853,6 +2858,7 @@ static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther) MYSQL_RES *mysql_res; MYSQL_ROW row; struct UsrData *UsrDat; + bool ItsMe; unsigned NumResults; unsigned NumResult; static unsigned UniqueId = 0; @@ -2870,6 +2876,7 @@ static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther) /***** Set user *****/ UsrDat = (MeOrOther == Usr_ME) ? &Gbl.Usrs.Me.UsrDat : &Gbl.Usrs.Other.UsrDat; + ItsMe = Usr_ItsMe (UsrDat->UsrCod); /***** Make database query *****/ NumResults = @@ -2937,14 +2944,12 @@ static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther) /* Get number of questions (row[3]) */ if (sscanf (row[3],"%u",&NumQstsInThisResult) != 1) NumQstsInThisResult = 0; - if (Gbl.Test.AllowTeachers) - NumTotalQsts += NumQstsInThisResult; + NumTotalQsts += NumQstsInThisResult; /* Get number of questions not blank (row[4]) */ if (sscanf (row[4],"%u",&NumQstsNotBlankInThisResult) != 1) NumQstsNotBlankInThisResult = 0; - if (Gbl.Test.AllowTeachers) - NumTotalQstsNotBlank += NumQstsNotBlankInThisResult; + NumTotalQstsNotBlank += NumQstsNotBlankInThisResult; /* Get score (row[5]) */ Str_SetDecimalPointToUS (); // To get the decimal point as a dot @@ -2999,9 +3004,9 @@ static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther) } /***** Write totals for this user *****/ - // Tst_ShowTestResultsSummaryRow (ItsMe,NumExamsVisibleByTchs, - // NumTotalQsts,NumTotalQstsNotBlank, - // TotalScoreOfAllTests); // TODO: Change to matches results + Mch_ShowMchResultsSummaryRow (ItsMe,NumResults, + NumTotalQsts,NumTotalQstsNotBlank, + TotalScoreOfAllResults); } else { @@ -3015,6 +3020,100 @@ static void Mch_ShowMchResults (Usr_MeOrOther_t MeOrOther) Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } +/*****************************************************************************/ +/************** Show row with summary of user's matches results **************/ +/*****************************************************************************/ + +static void Mch_ShowMchResultsSummaryRow (bool ItsMe, + unsigned NumResults, + unsigned NumTotalQsts, + unsigned NumTotalQstsNotBlank, + double TotalScoreOfAllResults) + { + extern const char *Txt_Matches; + bool ICanViewTotalScore; + + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_STD: + ICanViewTotalScore = ItsMe && + Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING; + break; + case Rol_NET: + case Rol_TCH: + case Rol_DEG_ADM: + case Rol_CTR_ADM: + case Rol_INS_ADM: + ICanViewTotalScore = ItsMe || + NumResults; + break; + case Rol_SYS_ADM: + ICanViewTotalScore = true; + break; + default: + ICanViewTotalScore = false; + break; + } + + /***** Start row *****/ + fprintf (Gbl.F.Out,""); + + /***** Row title *****/ + fprintf (Gbl.F.Out,"" + "%s: %u" + "", + Gbl.RowEvenOdd, + Txt_Matches,NumResults); + + /***** Write total number of questions *****/ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + if (NumResults) + fprintf (Gbl.F.Out,"%u",NumTotalQsts); + fprintf (Gbl.F.Out,""); + + /***** Write total number of questions not blank *****/ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + if (NumResults) + fprintf (Gbl.F.Out,"%u",NumTotalQstsNotBlank); + fprintf (Gbl.F.Out,""); + + /***** Write total score *****/ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + if (ICanViewTotalScore) + fprintf (Gbl.F.Out,"%.2lf",TotalScoreOfAllResults); + fprintf (Gbl.F.Out,""); + + /***** Write average score per question *****/ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + if (ICanViewTotalScore) + fprintf (Gbl.F.Out,"%.2lf", + NumTotalQsts ? TotalScoreOfAllResults / (double) NumTotalQsts : + 0.0); + fprintf (Gbl.F.Out,""); + + /***** Write score over Tst_SCORE_MAX *****/ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + if (ICanViewTotalScore) + fprintf (Gbl.F.Out,"%.2lf", + NumTotalQsts ? TotalScoreOfAllResults * Tst_SCORE_MAX / + (double) NumTotalQsts : + 0.0); + fprintf (Gbl.F.Out,""); + + /***** Last cell *****/ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + + /***** End row *****/ + fprintf (Gbl.F.Out,""); + } + /*****************************************************************************/ /******************* Show one match result of another user *******************/ /*****************************************************************************/