Version 21.9.1: Sep 20, 2021 Queries moved to module swad_browser_database.

This commit is contained in:
acanas 2021-09-20 22:14:39 +02:00
parent 9be6a88866
commit 92d5644eca
4 changed files with 672 additions and 670 deletions

View File

@ -368,6 +368,98 @@ unsigned Brw_DB_GetNumFilesUsr (long UsrCod)
(unsigned) Brw_IS_UNKNOWN); // Unknown entries are counted as files
}
/*****************************************************************************/
/*********** Get the number of files in document zones of a course ***********/
/*****************************************************************************/
unsigned Brw_DB_GetNumFilesInDocumZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT"
" (SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u AND Cod=%ld) +"
" (SELECT COALESCE(SUM(brw_sizes.NumFiles),0)"
" FROM grp_types,"
"grp_groups,"
"brw_sizes"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
" AND brw_sizes.FileBrowser=%u"
" AND brw_sizes.Cod=grp_groups.GrpCod)",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_DOC_CRS],
CrsCod,
CrsCod,
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_DOC_GRP]);
}
/*****************************************************************************/
/*********** Get the number of files in shared zones of a course ***********/
/*****************************************************************************/
unsigned Brw_DB_GetNumFilesInShareZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT"
" (SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u AND Cod=%ld) +"
" (SELECT COALESCE(SUM(brw_sizes.NumFiles),0)"
" FROM grp_types,"
"grp_groups,"
"brw_sizes"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
" AND brw_sizes.FileBrowser=%u"
" AND brw_sizes.Cod=grp_groups.GrpCod)",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_SHR_CRS],
CrsCod,
CrsCod,
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_SHR_GRP]);
}
/*****************************************************************************/
/********* Get the number of files in assignment zones of a course ***********/
/*****************************************************************************/
unsigned Brw_DB_GetNumFilesInAssigZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u"
" AND Cod=%ld",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_ASG_USR],
CrsCod);
}
/*****************************************************************************/
/************* Get the number of files in works zones of a course ************/
/*****************************************************************************/
unsigned Brw_DB_GetNumFilesInWorksZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u"
" AND Cod=%ld",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_WRK_USR],
CrsCod);
}
/*****************************************************************************/
/**************** Remove a file or folder from the database ******************/
/*****************************************************************************/

View File

@ -55,6 +55,10 @@ unsigned Brw_DB_GetFileMetadataByPath (MYSQL_RES **mysql_res,const char *Path);
unsigned Brw_DB_GetFileMetadataByCod (MYSQL_RES **mysql_res,long FilCod);
long Brw_DB_GetPublisherOfSubtree (const char *Path);
unsigned Brw_DB_GetNumFilesUsr (long UsrCod);
unsigned Brw_DB_GetNumFilesInDocumZonesOfCrs (long CrsCod);
unsigned Brw_DB_GetNumFilesInShareZonesOfCrs (long CrsCod);
unsigned Brw_DB_GetNumFilesInAssigZonesOfCrs (long CrsCod);
unsigned Brw_DB_GetNumFilesInWorksZonesOfCrs (long CrsCod);
void Brw_DB_RemoveOneFileOrFolder (const char Path[PATH_MAX + 1]);
void Brw_DB_RemoveChildrenOfFolder (const char Path[PATH_MAX + 1]);
void Brw_DB_RemoveInsFiles (long InsCod);

View File

@ -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.9 (2021-09-20)"
#define Log_PLATFORM_VERSION "SWAD 21.9.1 (2021-09-20)"
#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.9.1: Sep 20, 2021 Queries moved to module swad_browser_database. (316023 lines)
Version 21.9: Sep 20, 2021 New module swad_ID_database for database queries related to user's IDs. (316021 lines)
Version 21.8.1: Sep 20, 2021 Queries moved to module swad_holiday_database. (315927 lines)
Version 21.8: Sep 20, 2021 New module swad_holiday_database for database queries related to holidays. (315883 lines)

View File

@ -31,6 +31,7 @@
#include "swad_action.h"
#include "swad_assignment_database.h"
#include "swad_box.h"
#include "swad_browser_database.h"
#include "swad_database.h"
#include "swad_department.h"
#include "swad_error.h"
@ -70,7 +71,7 @@ typedef enum
static void Ind_GetParamsIndicators (struct Ind_Indicators *Indicators);
static void Ind_GetParamNumIndicators (struct Ind_Indicators *Indicators);
static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators,
static unsigned Ind_DB_GetTableOfCourses (const struct Ind_Indicators *Indicators,
MYSQL_RES **mysql_res);
static bool Ind_GetIfShowBigList (struct Ind_Indicators *Indicators,
unsigned NumCrss);
@ -87,11 +88,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (const struct Ind_Indicators *I
Ind_IndicatorsLayout_t IndicatorsLayout,
unsigned NumCrss,MYSQL_RES *mysql_res);
static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod);
static void Ind_StoreIndicatorsCrsIntoDB (long CrsCod,unsigned NumIndicators);
static unsigned Brw_DB_GetNumFilesInDocumZonesOfCrs (long CrsCod);
static unsigned Brw_DB_GetNumFilesInShareZonesOfCrs (long CrsCod);
static unsigned Brw_DB_GetNumFilesInAssigZonesOfCrs (long CrsCod);
static unsigned Brw_DB_GetNumFilesInWorksZonesOfCrs (long CrsCod);
static void Ind_DB_StoreIndicatorsCrs (long CrsCod,unsigned NumIndicators);
/*****************************************************************************/
/******************* Request showing statistics of courses *******************/
@ -182,7 +179,7 @@ void Ind_ReqIndicatorsCourses (void)
If Indicators.NumIndicators >= 0 ==> only those courses in result
with Indicators.NumIndicators set to yes
will be listed */
NumCrss = Ind_GetTableOfCourses (&Indicators,&mysql_res);
NumCrss = Ind_DB_GetTableOfCourses (&Indicators,&mysql_res);
/***** Get vector with numbers of courses with 0, 1, 2... indicators set to yes *****/
Ind_GetNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,mysql_res);
@ -276,7 +273,7 @@ void Ind_ShowIndicatorsCourses (void)
Ind_GetParamsIndicators (&Indicators);
/***** Get courses from database *****/
NumCrss = Ind_GetTableOfCourses (&Indicators,&mysql_res);
NumCrss = Ind_DB_GetTableOfCourses (&Indicators,&mysql_res);
/***** Get vector with numbers of courses with 0, 1, 2... indicators set to yes *****/
Ind_GetNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,mysql_res);
@ -344,7 +341,7 @@ static void Ind_GetParamNumIndicators (struct Ind_Indicators *Indicators)
/*****************************************************************************/
// Return the number of courses found
static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators,
static unsigned Ind_DB_GetTableOfCourses (const struct Ind_Indicators *Indicators,
MYSQL_RES **mysql_res)
{
unsigned NumCrss = 0; // Initialized to avoid warning
@ -1401,7 +1398,7 @@ int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
/************ Store number of indicators of a course in database *************/
/*****************************************************************************/
static void Ind_StoreIndicatorsCrsIntoDB (long CrsCod,unsigned NumIndicators)
static void Ind_DB_StoreIndicatorsCrs (long CrsCod,unsigned NumIndicators)
{
/***** Store number of indicators of a course in database *****/
DB_QueryUPDATE ("can not store number of indicators of a course",
@ -1481,97 +1478,5 @@ void Ind_ComputeAndStoreIndicatorsCrs (long CrsCod,int NumIndicatorsFromDB,
/***** Update number of indicators into database
if different to the stored one *****/
if (NumIndicatorsFromDB != (int) IndicatorsCrs->NumIndicators)
Ind_StoreIndicatorsCrsIntoDB (CrsCod,IndicatorsCrs->NumIndicators);
}
/*****************************************************************************/
/*********** Get the number of files in document zones of a course ***********/
/*****************************************************************************/
static unsigned Brw_DB_GetNumFilesInDocumZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT"
" (SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u AND Cod=%ld) +"
" (SELECT COALESCE(SUM(brw_sizes.NumFiles),0)"
" FROM grp_types,"
"grp_groups,"
"brw_sizes"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
" AND brw_sizes.FileBrowser=%u"
" AND brw_sizes.Cod=grp_groups.GrpCod)",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_DOC_CRS],
CrsCod,
CrsCod,
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_DOC_GRP]);
}
/*****************************************************************************/
/*********** Get the number of files in shared zones of a course ***********/
/*****************************************************************************/
static unsigned Brw_DB_GetNumFilesInShareZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT"
" (SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u AND Cod=%ld) +"
" (SELECT COALESCE(SUM(brw_sizes.NumFiles),0)"
" FROM grp_types,"
"grp_groups,"
"brw_sizes"
" WHERE grp_types.CrsCod=%ld"
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
" AND brw_sizes.FileBrowser=%u"
" AND brw_sizes.Cod=grp_groups.GrpCod)",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_SHR_CRS],
CrsCod,
CrsCod,
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_SHR_GRP]);
}
/*****************************************************************************/
/********* Get the number of files in assignment zones of a course ***********/
/*****************************************************************************/
static unsigned Brw_DB_GetNumFilesInAssigZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u"
" AND Cod=%ld",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_ASG_USR],
CrsCod);
}
/*****************************************************************************/
/************* Get the number of files in works zones of a course ************/
/*****************************************************************************/
static unsigned Brw_DB_GetNumFilesInWorksZonesOfCrs (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_DB_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
/***** Get number of files in document zones of a course from database *****/
return DB_QuerySELECTUnsigned ("can not get the number of files",
"SELECT COALESCE(SUM(NumFiles),0)"
" FROM brw_sizes"
" WHERE FileBrowser=%u"
" AND Cod=%ld",
(unsigned) Brw_DB_FileBrowserForDB_files[Brw_ADMI_WRK_USR],
CrsCod);
Ind_DB_StoreIndicatorsCrs (CrsCod,IndicatorsCrs->NumIndicators);
}