From b8b10a000f4c5ff59e38de0da3e1f9ea73a34bab Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 14 Sep 2021 13:00:57 +0200 Subject: [PATCH] Version 21.1.1: Sep 14, 2021 Queries moved to module swad_enrolment_database. --- swad_browser.c | 28 +++++++--------------------- swad_changelog.h | 3 ++- swad_enrolment_database.c | 14 ++++++++++++++ swad_enrolment_database.h | 3 +++ 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/swad_browser.c b/swad_browser.c index 0b229bb59..3911b3929 100644 --- a/swad_browser.c +++ b/swad_browser.c @@ -42,6 +42,7 @@ #include "swad_browser.h" #include "swad_config.h" #include "swad_database.h" +#include "swad_enrolment_database.h" #include "swad_error.h" #include "swad_figure.h" #include "swad_file_extension.h" @@ -2680,13 +2681,8 @@ bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName) char PathFolder[PATH_MAX * 2 + 128]; bool FolderExists = false; - /***** Get all the users belonging to current course from database *****/ - NumUsrs = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get users from current course", - "SELECT UsrCod" - " FROM crs_users" - " WHERE CrsCod=%ld", - Gbl.Hierarchy.Crs.CrsCod); + /***** Get all users belonging to current course *****/ + NumUsrs = Enr_DB_GetUsrsFromCurrentCrs (&mysql_res); /***** Check folders *****/ for (NumUsr = 0; @@ -2796,13 +2792,8 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con unsigned NumUsrsError = 0; unsigned NumUsrsSuccess = 0; - /***** Get all the users belonging to current course from database *****/ - NumUsrs = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get users from current course", - "SELECT UsrCod" // row[0] - " FROM crs_users" - " WHERE CrsCod=%ld", - Gbl.Hierarchy.Crs.CrsCod); + /***** Get all users belonging to current course *****/ + NumUsrs = Enr_DB_GetUsrsFromCurrentCrs (&mysql_res); /***** Check if there exist folders with the new name *****/ for (NumUsr = 0; @@ -2913,13 +2904,8 @@ void Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (const char *FolderName) long UsrCod; char PathFolder[PATH_MAX * 2 + 128]; - /***** Get all the users belonging to current course from database *****/ - NumUsrs = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get users from current course", - "SELECT UsrCod" // row[0] - " FROM crs_users" - " WHERE CrsCod=%ld", - Gbl.Hierarchy.Crs.CrsCod); + /***** Get all users belonging to current course *****/ + NumUsrs = Enr_DB_GetUsrsFromCurrentCrs (&mysql_res); /***** Remove folders *****/ for (NumUsr = 0; diff --git a/swad_changelog.h b/swad_changelog.h index 6fb3db51c..bc2fe93d9 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 21.1 (2021-09-13)" +#define Log_PLATFORM_VERSION "SWAD 21.1.1 (2021-09-14)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 21.1.1: Sep 14, 2021 Queries moved to module swad_enrolment_database. (315050 lines) Version 21.1: Sep 13, 2021 New module swad_browser_database for database queries related to file browsers. (315050 lines) Version 21.0.2: Sep 13, 2021 Queries moved to module swad_notification. (314927 lines) Version 21.0.1: Sep 13, 2021 Queries moved to module swad_follow_database. (314910 lines) diff --git a/swad_enrolment_database.c b/swad_enrolment_database.c index 0bfc25998..ef98b370a 100644 --- a/swad_enrolment_database.c +++ b/swad_enrolment_database.c @@ -92,6 +92,20 @@ void Enr_DB_AcceptUsrInCrs (long UsrCod,long CrsCod) UsrCod); } +/*****************************************************************************/ +/*********** Get all user codes belonging to the current course **************/ +/*****************************************************************************/ + +unsigned Enr_DB_GetUsrsFromCurrentCrs (MYSQL_RES **mysql_res) + { + return (unsigned) + DB_QuerySELECT (mysql_res,"can not get users from current course", + "SELECT UsrCod" + " FROM crs_users" + " WHERE CrsCod=%ld", + Gbl.Hierarchy.Crs.CrsCod); + } + /*****************************************************************************/ /************************** Remove user from course **************************/ /*****************************************************************************/ diff --git a/swad_enrolment_database.h b/swad_enrolment_database.h index b2655be52..337d6b210 100644 --- a/swad_enrolment_database.h +++ b/swad_enrolment_database.h @@ -45,6 +45,9 @@ void Enr_DB_InsertUsrInCurrentCrs (long UsrCod,long CrsCod,Rol_Role_t NewRole, Enr_KeepOrSetAccepted_t KeepOrSetAccepted); void Enr_DB_AcceptUsrInCrs (long UsrCod,long CrsCod); + +unsigned Enr_DB_GetUsrsFromCurrentCrs (MYSQL_RES **mysql_res); + void Enr_DB_RemUsrFromCrs (long UsrCod,long CrsCod); void Enr_DB_RemUsrFromAllCrss (long UsrCod); void Enr_DB_RemAllUsrsFromCrs (long CrsCod);