From 138b24327ce8f32c71bb5ab35fbc761cb6a06d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 22 Sep 2019 14:15:38 +0200 Subject: [PATCH] Version19.8.1 --- swad_changelog.h | 3 ++- swad_match.c | 2 +- swad_user.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++- swad_user.h | 1 + 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index f0add2dd8..178f10ce3 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -468,10 +468,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.8 (2019-09-22)" +#define Log_PLATFORM_VERSION "SWAD 19.8.1 (2019-09-22)" #define CSS_FILE "swad19.3.css" #define JS_FILE "swad18.130.2.js" /* + Version 19.8.1: Sep 22, 2019 View matches results. Not finished. (245474 lines) Version 19.8: Sep 22, 2019 View matches results. Not finished. Help links related to test and match results changed. (245412 lines) 1 change necessary in database: diff --git a/swad_match.c b/swad_match.c index bb0cbccee..216c089c3 100644 --- a/swad_match.c +++ b/swad_match.c @@ -2663,7 +2663,7 @@ void Mch_ShowUsrsMchResults (void) Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get of the database the data of the user - if (Usr_CheckIfICanViewTst (&Gbl.Usrs.Other.UsrDat)) // TODO: Change to matches results + if (Usr_CheckIfICanViewMch (&Gbl.Usrs.Other.UsrDat)) /***** Show matches results *****/ Mch_ShowMchResults (&Gbl.Usrs.Other.UsrDat); } diff --git a/swad_user.c b/swad_user.c index d87405a19..89f1e9a0d 100644 --- a/swad_user.c +++ b/swad_user.c @@ -1259,7 +1259,7 @@ bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat) } /*****************************************************************************/ -/************** Check if I can view test exams of another user ***************/ +/************ Check if I can view test results of another user ***************/ /*****************************************************************************/ bool Usr_CheckIfICanViewTst (const struct UsrData *UsrDat) @@ -1307,6 +1307,55 @@ bool Usr_CheckIfICanViewTst (const struct UsrData *UsrDat) } } +/*****************************************************************************/ +/*********** Check if I can view matches results of another user *************/ +/*****************************************************************************/ + +bool Usr_CheckIfICanViewMch (const struct UsrData *UsrDat) + { + bool ItsMe; + + /***** 1. Fast check: Am I logged? *****/ + if (!Gbl.Usrs.Me.Logged) + return false; + + /***** 2. Fast check: Is it a valid user code? *****/ + if (UsrDat->UsrCod <= 0) + return false; + + /***** 3. Fast check: Is it a course selected? *****/ + if (Gbl.Hierarchy.Crs.CrsCod <= 0) + return false; + + /***** 4. Fast check: Am I a system admin? *****/ + if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) + return true; + + /***** 5. Fast check: Do I belong to the current course? *****/ + if (!Gbl.Usrs.Me.IBelongToCurrentCrs) + return false; + + /***** 6. Fast check: It's me? *****/ + ItsMe = Usr_ItsMe (UsrDat->UsrCod); + if (ItsMe) + return true; + + /***** 7. Fast check: Does he/she belong to the current course? *****/ + if (!Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat)) + return false; + + /***** 8. Fast / slow check depending on roles *****/ + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_NET: + return Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (UsrDat); + case Rol_TCH: + return true; + default: + return false; + } + } + /*****************************************************************************/ /********** Check if I can view assigments / works of another user ***********/ /*****************************************************************************/ diff --git a/swad_user.h b/swad_user.h index c7a24552f..e40d84c75 100644 --- a/swad_user.h +++ b/swad_user.h @@ -300,6 +300,7 @@ bool Usr_CheckIfUsrHasAcceptedInCurrentCrs (const struct UsrData *UsrDat); bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat); bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat); bool Usr_CheckIfICanViewTst (const struct UsrData *UsrDat); +bool Usr_CheckIfICanViewMch (const struct UsrData *UsrDat); bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat); bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat); bool Usr_CheckIfICanViewUsrAgenda (struct UsrData *UsrDat);