diff --git a/Makefile b/Makefile
index d5bf2854..47aa5990 100644
--- a/Makefile
+++ b/Makefile
@@ -55,9 +55,9 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \
swad_group_database.o swad_help.o swad_hierarchy.o \
swad_hierarchy_config.o swad_hierarchy_database.o swad_holiday.o \
swad_holiday_database.o swad_HTML.o \
- swad_icon.o swad_ID.o swad_ID_database.o swad_indicator.o swad_info.o \
- swad_institution.o swad_institution_config.o \
- swad_institution_database.o \
+ swad_icon.o swad_ID.o swad_ID_database.o swad_indicator.o \
+ swad_indicator_database.o swad_info.o swad_institution.o \
+ swad_institution_config.o swad_institution_database.o \
swad_language.o swad_layout.o swad_link.o swad_log.o swad_logo.o \
swad_MAC.o swad_mail.o swad_main.o swad_maintenance.o swad_map.o \
swad_mark.o swad_match.o swad_match_print.o swad_match_result.o \
diff --git a/swad_changelog.h b/swad_changelog.h
index e9542090..6fb9ddf8 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -602,13 +602,17 @@ 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.1 (2021-09-20)"
+#define Log_PLATFORM_VERSION "SWAD 21.10 (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
+TODO: Un profesor no puede confirmar DNIs
+TODO: Al cambiar un estudiante en una asignatura, dice que el rol ha cambiado de desconocido a estudiante
+
+ Version 21.10: Sep 20, 2021 New module swad_indicator_database for database queries related to course indicators. (316112 lines)
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)
diff --git a/swad_indicator.c b/swad_indicator.c
index 22db511d..9268c6eb 100644
--- a/swad_indicator.c
+++ b/swad_indicator.c
@@ -41,6 +41,7 @@
#include "swad_hierarchy_level.h"
#include "swad_HTML.h"
#include "swad_indicator.h"
+#include "swad_indicator_database.h"
#include "swad_message.h"
#include "swad_parameter.h"
#include "swad_theme.h"
@@ -71,8 +72,6 @@ typedef enum
static void Ind_GetParamsIndicators (struct Ind_Indicators *Indicators);
static void Ind_GetParamNumIndicators (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);
static void Ind_PutButtonToConfirmIWantToSeeBigList (struct Ind_Indicators *Indicators,
@@ -88,7 +87,6 @@ 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_DB_StoreIndicatorsCrs (long CrsCod,unsigned NumIndicators);
/*****************************************************************************/
/******************* Request showing statistics of courses *******************/
@@ -179,7 +177,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_DB_GetTableOfCourses (&Indicators,&mysql_res);
+ NumCrss = Ind_DB_GetTableOfCourses (&mysql_res,&Indicators);
/***** Get vector with numbers of courses with 0, 1, 2... indicators set to yes *****/
Ind_GetNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,mysql_res);
@@ -273,7 +271,7 @@ void Ind_ShowIndicatorsCourses (void)
Ind_GetParamsIndicators (&Indicators);
/***** Get courses from database *****/
- NumCrss = Ind_DB_GetTableOfCourses (&Indicators,&mysql_res);
+ NumCrss = Ind_DB_GetTableOfCourses (&mysql_res,&Indicators);
/***** Get vector with numbers of courses with 0, 1, 2... indicators set to yes *****/
Ind_GetNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,mysql_res);
@@ -336,313 +334,6 @@ static void Ind_GetParamNumIndicators (struct Ind_Indicators *Indicators)
Indicators->IndicatorsSelected[Ind] = true;
}
-/*****************************************************************************/
-/******************* Build query to get table of courses *********************/
-/*****************************************************************************/
-// Return the number of courses found
-
-static unsigned Ind_DB_GetTableOfCourses (const struct Ind_Indicators *Indicators,
- MYSQL_RES **mysql_res)
- {
- unsigned NumCrss = 0; // Initialized to avoid warning
-
- switch (Gbl.Scope.Current)
- {
- case HieLvl_SYS:
- if (Indicators->DptCod >= 0) // 0 means another department
- {
- if (Indicators->DegTypCod > 0)
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT DISTINCTROW "
- "deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses,"
- "crs_users,"
- "usr_data"
- " WHERE deg_degrees.DegTypCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " AND crs_courses.CrsCod=crs_users.CrsCod"
- " AND crs_users.Role=%u"
- " AND crs_users.UsrCod=usr_data.UsrCod"
- " AND usr_data.DptCod=%ld"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Indicators->DegTypCod,
- (unsigned) Rol_TCH,
- Indicators->DptCod);
- else
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT DISTINCTROW "
- "deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses,"
- "crs_users,"
- "usr_data"
- " WHERE deg_degrees.DegCod=crs_courses.DegCod"
- " AND crs_courses.CrsCod=crs_users.CrsCod"
- " AND crs_users.Role=%u"
- " AND crs_users.UsrCod=usr_data.UsrCod"
- " AND usr_data.DptCod=%ld"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- (unsigned) Rol_TCH,
- Indicators->DptCod);
- }
- else
- {
- if (Indicators->DegTypCod > 0)
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses"
- " WHERE deg_degrees.DegTypCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Indicators->DegTypCod);
- else
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses"
- " WHERE deg_degrees.DegCod=crs_courses.DegCod"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName");
- }
- break;
- case HieLvl_CTY:
- if (Indicators->DptCod >= 0) // 0 means another department
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT DISTINCTROW "
- "deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM ins_instits,"
- "ctr_centers,"
- "deg_degrees,"
- "crs_courses,"
- "crs_users,"
- "usr_data"
- " WHERE ins_instits.CtyCod=%ld"
- " AND ins_instits.InsCod=ctr_centers.InsCod"
- " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " AND crs_courses.CrsCod=crs_users.CrsCod"
- " AND crs_users.Role=%u"
- " AND crs_users.UsrCod=usr_data.UsrCod"
- " AND usr_data.DptCod=%ld"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Cty.CtyCod,
- (unsigned) Rol_TCH,
- Indicators->DptCod);
- else
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM ins_instits,"
- "ctr_centers,"
- "deg_degrees,"
- "crs_courses"
- " WHERE ins_instits.CtyCod=%ld"
- " AND ins_instits.InsCod=ctr_centers.InsCod"
- " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Cty.CtyCod);
- break;
- case HieLvl_INS:
- if (Indicators->DptCod >= 0) // 0 means another department
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT DISTINCTROW "
- "deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM ctr_centers,"
- "deg_degrees,"
- "crs_courses,"
- "crs_users,"
- "usr_data"
- " WHERE ctr_centers.InsCod=%ld"
- " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " AND crs_courses.CrsCod=crs_users.CrsCod"
- " AND crs_users.Role=%u"
- " AND crs_users.UsrCod=usr_data.UsrCod"
- " AND usr_data.DptCod=%ld"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Ins.InsCod,
- (unsigned) Rol_TCH,
- Indicators->DptCod);
- else
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM ctr_centers,"
- "deg_degrees,"
- "crs_courses"
- " WHERE ctr_centers.InsCod=%ld"
- " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Ins.InsCod);
- break;
- case HieLvl_CTR:
- if (Indicators->DptCod >= 0) // 0 means another department
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT DISTINCTROW "
- "deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses,"
- "crs_users,"
- "usr_data"
- " WHERE deg_degrees.CtrCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " AND crs_courses.CrsCod=crs_users.CrsCod"
- " AND crs_users.Role=%u"
- " AND crs_users.UsrCod=usr_data.UsrCod"
- " AND usr_data.DptCod=%ld"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Ctr.CtrCod,
- (unsigned) Rol_TCH,
- Indicators->DptCod);
- else
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses"
- " WHERE deg_degrees.CtrCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Ctr.CtrCod);
- break;
- case HieLvl_DEG:
- if (Indicators->DptCod >= 0) // 0 means another department
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT DISTINCTROW "
- "deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses,"
- "crs_users,"
- "usr_data"
- " WHERE deg_degrees.DegCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " AND crs_courses.CrsCod=crs_users.CrsCod"
- " AND crs_users.Role=%u"
- " AND crs_users.UsrCod=usr_data.UsrCod"
- " AND usr_data.DptCod=%ld"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Deg.DegCod,
- (unsigned) Rol_TCH,
- Indicators->DptCod);
- else
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses"
- " WHERE deg_degrees.DegCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Deg.DegCod);
- break;
- case HieLvl_CRS:
- if (Indicators->DptCod >= 0) // 0 means another department
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT DISTINCTROW "
- "deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses,"
- "crs_users,"
- "usr_data"
- " WHERE crs_courses.CrsCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " AND crs_courses.CrsCod=crs_users.CrsCod"
- " AND crs_users.CrsCod=%ld"
- " AND crs_users.Role=%u"
- " AND crs_users.UsrCod=usr_data.UsrCod"
- " AND usr_data.DptCod=%ld"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Crs.CrsCod,
- Gbl.Hierarchy.Crs.CrsCod,
- (unsigned) Rol_TCH,
- Indicators->DptCod);
- else
- NumCrss = (unsigned)
- DB_QuerySELECT (mysql_res,"can not get courses",
- "SELECT deg_degrees.FullName," // row[0]
- "crs_courses.FullName," // row[1]
- "crs_courses.CrsCod," // row[2]
- "crs_courses.InsCrsCod" // row[3]
- " FROM deg_degrees,"
- "crs_courses"
- " WHERE crs_courses.CrsCod=%ld"
- " AND deg_degrees.DegCod=crs_courses.DegCod"
- " ORDER BY deg_degrees.FullName,"
- "crs_courses.FullName",
- Gbl.Hierarchy.Crs.CrsCod);
- break;
- default:
- Err_WrongScopeExit ();
- break;
- }
-
- return NumCrss;
- }
-
/*****************************************************************************/
/******* Show form to confirm that I want to see a big list of courses *******/
/*****************************************************************************/
@@ -1374,11 +1065,7 @@ int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
int NumIndicatorsFromDB = -1; // -1 means not yet calculated
/***** Get number of indicators of a course from database *****/
- if (DB_QuerySELECT (&mysql_res,"can not get number of indicators",
- "SELECT NumIndicators" // row[0]
- " FROM crs_courses"
- " WHERE CrsCod=%ld",
- CrsCod))
+ if (Ind_DB_GetNumIndicatorsCrs (&mysql_res,CrsCod))
{
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
@@ -1394,21 +1081,6 @@ int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
return NumIndicatorsFromDB;
}
-/*****************************************************************************/
-/************ Store number of indicators of a course in database *************/
-/*****************************************************************************/
-
-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",
- "UPDATE crs_courses"
- " SET NumIndicators=%u"
- " WHERE CrsCod=%ld",
- NumIndicators,
- CrsCod);
- }
-
/*****************************************************************************/
/********************* Compute indicators of a course ************************/
/*****************************************************************************/
diff --git a/swad_indicator.h b/swad_indicator.h
index 230e789a..3828da79 100644
--- a/swad_indicator.h
+++ b/swad_indicator.h
@@ -27,6 +27,8 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
+#include "swad_info.h"
+
/*****************************************************************************/
/************************** Public types and constants ***********************/
/*****************************************************************************/
diff --git a/swad_indicator_database.c b/swad_indicator_database.c
new file mode 100644
index 00000000..d5ea8f26
--- /dev/null
+++ b/swad_indicator_database.c
@@ -0,0 +1,391 @@
+// swad_indicators_database.c: indicators of courses, operations with database
+
+/*
+ SWAD (Shared Workspace At a Distance),
+ is a web platform developed at the University of Granada (Spain),
+ and used to support university teaching.
+
+ This file is part of SWAD core.
+ Copyright (C) 1999-2021 Antonio Caņas Vargas
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+/*****************************************************************************/
+/********************************* Headers ***********************************/
+/*****************************************************************************/
+
+// #include // For NULL
+#include // To access MySQL databases
+
+// #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"
+// #include "swad_form.h"
+// #include "swad_forum_database.h"
+#include "swad_global.h"
+// #include "swad_hierarchy_level.h"
+// #include "swad_HTML.h"
+#include "swad_indicator.h"
+// #include "swad_message.h"
+// #include "swad_parameter.h"
+// #include "swad_theme.h"
+
+/*****************************************************************************/
+/************** External global variables from others modules ****************/
+/*****************************************************************************/
+
+extern struct Globals Gbl;
+
+/*****************************************************************************/
+/**************************** Private constants ******************************/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/******************************* Private types *******************************/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/***************************** Private prototypes ****************************/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/************ Store number of indicators of a course in database *************/
+/*****************************************************************************/
+
+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",
+ "UPDATE crs_courses"
+ " SET NumIndicators=%u"
+ " WHERE CrsCod=%ld",
+ NumIndicators,
+ CrsCod);
+ }
+
+/*****************************************************************************/
+/************ Get number of indicators of a course from database *************/
+/*****************************************************************************/
+// This function returns -1 if number of indicators is not yet calculated
+
+unsigned Ind_DB_GetNumIndicatorsCrs (MYSQL_RES **mysql_res,long CrsCod)
+ {
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get number of indicators",
+ "SELECT NumIndicators" // row[0]
+ " FROM crs_courses"
+ " WHERE CrsCod=%ld",
+ CrsCod);
+ }
+
+/*****************************************************************************/
+/******************* Build query to get table of courses *********************/
+/*****************************************************************************/
+// Return the number of courses found
+
+unsigned Ind_DB_GetTableOfCourses (MYSQL_RES **mysql_res,
+ const struct Ind_Indicators *Indicators)
+ {
+ switch (Gbl.Scope.Current)
+ {
+ case HieLvl_SYS:
+ if (Indicators->DptCod >= 0) // 0 means another department
+ {
+ if (Indicators->DegTypCod > 0)
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT DISTINCTROW "
+ "deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses,"
+ "crs_users,"
+ "usr_data"
+ " WHERE deg_degrees.DegTypCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " AND crs_courses.CrsCod=crs_users.CrsCod"
+ " AND crs_users.Role=%u"
+ " AND crs_users.UsrCod=usr_data.UsrCod"
+ " AND usr_data.DptCod=%ld"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Indicators->DegTypCod,
+ (unsigned) Rol_TCH,
+ Indicators->DptCod);
+ else
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT DISTINCTROW "
+ "deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses,"
+ "crs_users,"
+ "usr_data"
+ " WHERE deg_degrees.DegCod=crs_courses.DegCod"
+ " AND crs_courses.CrsCod=crs_users.CrsCod"
+ " AND crs_users.Role=%u"
+ " AND crs_users.UsrCod=usr_data.UsrCod"
+ " AND usr_data.DptCod=%ld"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ (unsigned) Rol_TCH,
+ Indicators->DptCod);
+ }
+ else
+ {
+ if (Indicators->DegTypCod > 0)
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses"
+ " WHERE deg_degrees.DegTypCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Indicators->DegTypCod);
+ else
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses"
+ " WHERE deg_degrees.DegCod=crs_courses.DegCod"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName");
+ }
+ case HieLvl_CTY:
+ if (Indicators->DptCod >= 0) // 0 means another department
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT DISTINCTROW "
+ "deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM ins_instits,"
+ "ctr_centers,"
+ "deg_degrees,"
+ "crs_courses,"
+ "crs_users,"
+ "usr_data"
+ " WHERE ins_instits.CtyCod=%ld"
+ " AND ins_instits.InsCod=ctr_centers.InsCod"
+ " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " AND crs_courses.CrsCod=crs_users.CrsCod"
+ " AND crs_users.Role=%u"
+ " AND crs_users.UsrCod=usr_data.UsrCod"
+ " AND usr_data.DptCod=%ld"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Cty.CtyCod,
+ (unsigned) Rol_TCH,
+ Indicators->DptCod);
+ else
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM ins_instits,"
+ "ctr_centers,"
+ "deg_degrees,"
+ "crs_courses"
+ " WHERE ins_instits.CtyCod=%ld"
+ " AND ins_instits.InsCod=ctr_centers.InsCod"
+ " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Cty.CtyCod);
+ case HieLvl_INS:
+ if (Indicators->DptCod >= 0) // 0 means another department
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT DISTINCTROW "
+ "deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM ctr_centers,"
+ "deg_degrees,"
+ "crs_courses,"
+ "crs_users,"
+ "usr_data"
+ " WHERE ctr_centers.InsCod=%ld"
+ " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " AND crs_courses.CrsCod=crs_users.CrsCod"
+ " AND crs_users.Role=%u"
+ " AND crs_users.UsrCod=usr_data.UsrCod"
+ " AND usr_data.DptCod=%ld"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Ins.InsCod,
+ (unsigned) Rol_TCH,
+ Indicators->DptCod);
+ else
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM ctr_centers,"
+ "deg_degrees,"
+ "crs_courses"
+ " WHERE ctr_centers.InsCod=%ld"
+ " AND ctr_centers.CtrCod=deg_degrees.CtrCod"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Ins.InsCod);
+ case HieLvl_CTR:
+ if (Indicators->DptCod >= 0) // 0 means another department
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT DISTINCTROW "
+ "deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses,"
+ "crs_users,"
+ "usr_data"
+ " WHERE deg_degrees.CtrCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " AND crs_courses.CrsCod=crs_users.CrsCod"
+ " AND crs_users.Role=%u"
+ " AND crs_users.UsrCod=usr_data.UsrCod"
+ " AND usr_data.DptCod=%ld"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Ctr.CtrCod,
+ (unsigned) Rol_TCH,
+ Indicators->DptCod);
+ else
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses"
+ " WHERE deg_degrees.CtrCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Ctr.CtrCod);
+ case HieLvl_DEG:
+ if (Indicators->DptCod >= 0) // 0 means another department
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT DISTINCTROW "
+ "deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses,"
+ "crs_users,"
+ "usr_data"
+ " WHERE deg_degrees.DegCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " AND crs_courses.CrsCod=crs_users.CrsCod"
+ " AND crs_users.Role=%u"
+ " AND crs_users.UsrCod=usr_data.UsrCod"
+ " AND usr_data.DptCod=%ld"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Deg.DegCod,
+ (unsigned) Rol_TCH,
+ Indicators->DptCod);
+ else
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses"
+ " WHERE deg_degrees.DegCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Deg.DegCod);
+ case HieLvl_CRS:
+ if (Indicators->DptCod >= 0) // 0 means another department
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT DISTINCTROW "
+ "deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses,"
+ "crs_users,"
+ "usr_data"
+ " WHERE crs_courses.CrsCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " AND crs_courses.CrsCod=crs_users.CrsCod"
+ " AND crs_users.CrsCod=%ld"
+ " AND crs_users.Role=%u"
+ " AND crs_users.UsrCod=usr_data.UsrCod"
+ " AND usr_data.DptCod=%ld"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Crs.CrsCod,
+ Gbl.Hierarchy.Crs.CrsCod,
+ (unsigned) Rol_TCH,
+ Indicators->DptCod);
+ else
+ return (unsigned)
+ DB_QuerySELECT (mysql_res,"can not get courses",
+ "SELECT deg_degrees.FullName," // row[0]
+ "crs_courses.FullName," // row[1]
+ "crs_courses.CrsCod," // row[2]
+ "crs_courses.InsCrsCod" // row[3]
+ " FROM deg_degrees,"
+ "crs_courses"
+ " WHERE crs_courses.CrsCod=%ld"
+ " AND deg_degrees.DegCod=crs_courses.DegCod"
+ " ORDER BY deg_degrees.FullName,"
+ "crs_courses.FullName",
+ Gbl.Hierarchy.Crs.CrsCod);
+ default:
+ Err_WrongScopeExit ();
+ return 0; // Not reached
+ }
+ }
diff --git a/swad_indicator_database.h b/swad_indicator_database.h
new file mode 100644
index 00000000..58d556c2
--- /dev/null
+++ b/swad_indicator_database.h
@@ -0,0 +1,44 @@
+// swad_indicator_database.h: indicators of courses, operations with database
+
+#ifndef _SWAD_IND_DB
+#define _SWAD_IND_DB
+/*
+ SWAD (Shared Workspace At a Distance in Spanish),
+ is a web platform developed at the University of Granada (Spain),
+ and used to support university teaching.
+
+ This file is part of SWAD core.
+ Copyright (C) 1999-2021 Antonio Caņas Vargas
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+*/
+/*****************************************************************************/
+/********************************* Headers ***********************************/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/************************** Public types and constants ***********************/
+/*****************************************************************************/
+
+/*****************************************************************************/
+/***************************** Public prototypes *****************************/
+/*****************************************************************************/
+
+void Ind_DB_StoreIndicatorsCrs (long CrsCod,unsigned NumIndicators);
+unsigned Ind_DB_GetNumIndicatorsCrs (MYSQL_RES **mysql_res,long CrsCod);
+
+unsigned Ind_DB_GetTableOfCourses (MYSQL_RES **mysql_res,
+ const struct Ind_Indicators *Indicators);
+
+#endif