mirror of https://github.com/acanas/swad-core.git
Version 20.85: May 28, 2021 Queries moved to module swad_degree_database.
This commit is contained in:
parent
615a786535
commit
96e80a87b7
|
@ -35,6 +35,7 @@
|
||||||
#include "swad_call_for_exam.h"
|
#include "swad_call_for_exam.h"
|
||||||
#include "swad_config.h"
|
#include "swad_config.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
#include "swad_degree_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_form.h"
|
#include "swad_form.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
@ -1798,7 +1799,7 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call
|
||||||
Deg_GetDataOfDegreeByCod (&Hie.Deg);
|
Deg_GetDataOfDegreeByCod (&Hie.Deg);
|
||||||
|
|
||||||
/***** Get data of institution *****/
|
/***** Get data of institution *****/
|
||||||
Hie.Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Hie.Deg.DegCod);
|
Hie.Ins.InsCod = Deg_DB_GetInsCodOfDegreeByCod (Hie.Deg.DegCod);
|
||||||
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
Ins_GetDataOfInstitutionByCod (&Hie.Ins);
|
||||||
|
|
||||||
/***** Convert struct date to a date string *****/
|
/***** Convert struct date to a date string *****/
|
||||||
|
|
|
@ -1245,6 +1245,9 @@ void Ctr_RemoveCenter (void)
|
||||||
(unsigned) Ctr_EditingCtr->CtrCod);
|
(unsigned) Ctr_EditingCtr->CtrCod);
|
||||||
Fil_RemoveTree (PathCtr);
|
Fil_RemoveTree (PathCtr);
|
||||||
|
|
||||||
|
/***** Remove administrators of this center *****/
|
||||||
|
Enr_DB_RemAdmins (HieLvl_CTR,Ctr_EditingCtr->CtrCod);
|
||||||
|
|
||||||
/***** Remove center *****/
|
/***** Remove center *****/
|
||||||
DB_QueryDELETE ("can not remove a center",
|
DB_QueryDELETE ("can not remove a center",
|
||||||
"DELETE FROM ctr_centers"
|
"DELETE FROM ctr_centers"
|
||||||
|
|
|
@ -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.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.84 (2021-05-27)"
|
#define Log_PLATFORM_VERSION "SWAD 20.85 (2021-05-28)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 20.85: May 28, 2021 Queries moved to module swad_degree_database. (312319 lines)
|
||||||
Version 20.84: May 27, 2021 New module swad_degree_database for database queries related to degrees. (312216 lines)
|
Version 20.84: May 27, 2021 New module swad_degree_database for database queries related to degrees. (312216 lines)
|
||||||
Version 20.83.1: May 27, 2021 Database function moved from swad_date to swad_setting. (311993 lines)
|
Version 20.83.1: May 27, 2021 Database function moved from swad_date to swad_setting. (311993 lines)
|
||||||
Version 20.83: May 27, 2021 New module swad_course_database for database queries related to courses. (311982 lines)
|
Version 20.83: May 27, 2021 New module swad_course_database for database queries related to courses. (311982 lines)
|
||||||
|
|
|
@ -80,6 +80,20 @@ void Crs_DB_CreateCourse (struct Crs_Course *Crs,unsigned Status)
|
||||||
Crs->FullName);
|
Crs->FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************* Get courses of a degree from database *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Crs_DB_GetCrssInDeg (MYSQL_RES **mysql_res,long DegCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get courses of a degree",
|
||||||
|
"SELECT CrsCod"
|
||||||
|
" FROM crs_courses"
|
||||||
|
" WHERE DegCod=%ld",
|
||||||
|
DegCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Get courses in current degree *********************/
|
/******************** Get courses in current degree *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
void Crs_DB_CreateCourse (struct Crs_Course *Crs,unsigned Status);
|
void Crs_DB_CreateCourse (struct Crs_Course *Crs,unsigned Status);
|
||||||
|
|
||||||
|
unsigned Crs_DB_GetCrssInDeg (MYSQL_RES **mysql_res,long DegCod);
|
||||||
unsigned Crs_DB_GetCrssInCurrentDegBasic (MYSQL_RES **mysql_res);
|
unsigned Crs_DB_GetCrssInCurrentDegBasic (MYSQL_RES **mysql_res);
|
||||||
unsigned Crs_DB_GetCrssInCurrentDegFull (MYSQL_RES **mysql_res);
|
unsigned Crs_DB_GetCrssInCurrentDegFull (MYSQL_RES **mysql_res);
|
||||||
unsigned Crs_DB_GetDataOfCourseByCod (MYSQL_RES **mysql_res,long CrsCod);
|
unsigned Crs_DB_GetDataOfCourseByCod (MYSQL_RES **mysql_res,long CrsCod);
|
||||||
|
|
216
swad_degree.c
216
swad_degree.c
|
@ -30,6 +30,7 @@
|
||||||
#include <stdlib.h> // For free
|
#include <stdlib.h> // For free
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
|
#include "swad_course_database.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_degree.h"
|
#include "swad_degree.h"
|
||||||
#include "swad_degree_config.h"
|
#include "swad_degree_config.h"
|
||||||
|
@ -98,8 +99,6 @@ static void Deg_PutParamOtherDegCod (void *DegCod);
|
||||||
|
|
||||||
static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row);
|
static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row);
|
||||||
|
|
||||||
static void Deg_DB_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName);
|
|
||||||
|
|
||||||
static void Deg_ShowAlertAndButtonToGoToDeg (void);
|
static void Deg_ShowAlertAndButtonToGoToDeg (void);
|
||||||
static void Deg_PutParamGoToDeg (void *DegCod);
|
static void Deg_PutParamGoToDeg (void *DegCod);
|
||||||
|
|
||||||
|
@ -241,7 +240,7 @@ void Deg_WriteSelectorOfDegree (void)
|
||||||
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
|
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get degrees belonging to the current center from database *****/
|
/***** Get degrees belonging to the current center from database *****/
|
||||||
NumDegs = Deg_DB_GetDegsOfCurrentCtr (&mysql_res);
|
NumDegs = Deg_DB_GetDegsOfCurrentCtrBasic (&mysql_res);
|
||||||
|
|
||||||
/***** Get degrees of this center *****/
|
/***** Get degrees of this center *****/
|
||||||
for (NumDeg = 0;
|
for (NumDeg = 0;
|
||||||
|
@ -1020,27 +1019,7 @@ void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs)
|
||||||
unsigned NumDeg;
|
unsigned NumDeg;
|
||||||
|
|
||||||
/***** Get degrees admin by me from database *****/
|
/***** Get degrees admin by me from database *****/
|
||||||
Degs->Num = (unsigned)
|
if ((Degs->Num = Deg_DB_GetDegsWithStds (&mysql_res))) // Degrees found...
|
||||||
DB_QuerySELECT (&mysql_res,"can not get degrees admin by you",
|
|
||||||
"SELECT DISTINCTROW "
|
|
||||||
"deg_degrees.DegCod," // row[0]
|
|
||||||
"deg_degrees.CtrCod," // row[1]
|
|
||||||
"deg_degrees.DegTypCod," // row[2]
|
|
||||||
"deg_degrees.Status," // row[3]
|
|
||||||
"deg_degrees.RequesterUsrCod," // row[4]
|
|
||||||
"deg_degrees.ShortName," // row[5]
|
|
||||||
"deg_degrees.FullName," // row[6]
|
|
||||||
"deg_degrees.WWW" // row[7]
|
|
||||||
" FROM deg_degrees,"
|
|
||||||
"crs_courses,"
|
|
||||||
"crs_users"
|
|
||||||
" WHERE deg_degrees.DegCod=crs_courses.DegCod"
|
|
||||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
|
||||||
" AND crs_users.Role=%u"
|
|
||||||
" ORDER BY deg_degrees.ShortName",
|
|
||||||
(unsigned) Rol_STD);
|
|
||||||
|
|
||||||
if (Degs->Num) // Degrees found...
|
|
||||||
{
|
{
|
||||||
/***** Create list with degrees *****/
|
/***** Create list with degrees *****/
|
||||||
if ((Degs->Lst = calloc (Degs->Num,sizeof (*Degs->Lst))) == NULL)
|
if ((Degs->Lst = calloc (Degs->Num,sizeof (*Degs->Lst))) == NULL)
|
||||||
|
@ -1075,20 +1054,7 @@ void Deg_GetListDegsInCurrentCtr (void)
|
||||||
struct Deg_Degree *Deg;
|
struct Deg_Degree *Deg;
|
||||||
|
|
||||||
/***** Get degrees of the current center from database *****/
|
/***** Get degrees of the current center from database *****/
|
||||||
Gbl.Hierarchy.Degs.Num = (unsigned)
|
Gbl.Hierarchy.Degs.Num = Deg_DB_GetDegsOfCurrentCtrFull (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get degrees of a center",
|
|
||||||
"SELECT DegCod," // row[0]
|
|
||||||
"CtrCod," // row[1]
|
|
||||||
"DegTypCod," // row[2]
|
|
||||||
"Status," // row[3]
|
|
||||||
"RequesterUsrCod," // row[4]
|
|
||||||
"ShortName," // row[5]
|
|
||||||
"FullName," // row[6]
|
|
||||||
"WWW" // row[7]
|
|
||||||
" FROM deg_degrees"
|
|
||||||
" WHERE CtrCod=%ld"
|
|
||||||
" ORDER BY FullName",
|
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
|
||||||
|
|
||||||
/***** Count number of rows in result *****/
|
/***** Count number of rows in result *****/
|
||||||
if (Gbl.Hierarchy.Degs.Num) // Degrees found...
|
if (Gbl.Hierarchy.Degs.Num) // Degrees found...
|
||||||
|
@ -1170,11 +1136,9 @@ static void Deg_ReceiveFormRequestOrCreateDeg (unsigned Status)
|
||||||
/* Set degree center */
|
/* Set degree center */
|
||||||
Deg_EditingDeg->CtrCod = Gbl.Hierarchy.Ctr.CtrCod;
|
Deg_EditingDeg->CtrCod = Gbl.Hierarchy.Ctr.CtrCod;
|
||||||
|
|
||||||
/* Get degree short name */
|
/* Get degree short name and full name */
|
||||||
Par_GetParToText ("ShortName",Deg_EditingDeg->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
Par_GetParToText ("ShortName",Deg_EditingDeg->ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||||
|
Par_GetParToText ("FullName" ,Deg_EditingDeg->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
||||||
/* Get degree full name */
|
|
||||||
Par_GetParToText ("FullName",Deg_EditingDeg->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
|
||||||
|
|
||||||
/* Get degree type */
|
/* Get degree type */
|
||||||
Deg_EditingDeg->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1);
|
Deg_EditingDeg->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1);
|
||||||
|
@ -1336,10 +1300,8 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row)
|
||||||
if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||||
Err_WrongDegreeExit ();
|
Err_WrongDegreeExit ();
|
||||||
|
|
||||||
/***** Get center code (row[1]) *****/
|
/***** Get center code (row[1]) and code of the degree type (row[2]) *****/
|
||||||
Deg->CtrCod = Str_ConvertStrCodToLongCod (row[1]);
|
Deg->CtrCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
|
||||||
/***** Get the code of the degree type (row[2]) *****/
|
|
||||||
Deg->DegTypCod = Str_ConvertStrCodToLongCod (row[2]);
|
Deg->DegTypCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||||
|
|
||||||
/* Get course status (row[3]) */
|
/* Get course status (row[3]) */
|
||||||
|
@ -1355,26 +1317,6 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row)
|
||||||
Str_Copy (Deg->WWW ,row[7],sizeof (Deg->WWW ) - 1);
|
Str_Copy (Deg->WWW ,row[7],sizeof (Deg->WWW ) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********** Get the institution code of a degree from its code ***************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
long Deg_GetInsCodOfDegreeByCod (long DegCod)
|
|
||||||
{
|
|
||||||
/***** Trivial check: degree code should be > 0 *****/
|
|
||||||
if (DegCod <= 0)
|
|
||||||
return -1L;
|
|
||||||
|
|
||||||
/***** Get the institution code of a degree from database *****/
|
|
||||||
return DB_QuerySELECTCode ("can not get the institution of a degree",
|
|
||||||
"SELECT ctr_centers.InsCod"
|
|
||||||
" FROM deg_degrees,"
|
|
||||||
"ctr_centers"
|
|
||||||
" WHERE deg_degrees.DegCod=%ld"
|
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod",
|
|
||||||
DegCod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Remove a degree *******************************/
|
/***************************** Remove a degree *******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1387,15 +1329,8 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
||||||
long CrsCod;
|
long CrsCod;
|
||||||
char PathDeg[PATH_MAX + 1];
|
char PathDeg[PATH_MAX + 1];
|
||||||
|
|
||||||
/***** Get courses of a degree from database *****/
|
/***** Get courses of a degree and remove them *****/
|
||||||
NumCrss = (unsigned)
|
NumCrss = Crs_DB_GetCrssInDeg (&mysql_res,DegCod);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
|
||||||
"SELECT CrsCod"
|
|
||||||
" FROM crs_courses"
|
|
||||||
" WHERE DegCod=%ld",
|
|
||||||
DegCod);
|
|
||||||
|
|
||||||
/* Get courses in this degree */
|
|
||||||
for (NumCrs = 0;
|
for (NumCrs = 0;
|
||||||
NumCrs < NumCrss;
|
NumCrs < NumCrss;
|
||||||
NumCrs++)
|
NumCrs++)
|
||||||
|
@ -1428,18 +1363,10 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
||||||
Fil_RemoveTree (PathDeg);
|
Fil_RemoveTree (PathDeg);
|
||||||
|
|
||||||
/***** Remove administrators of this degree *****/
|
/***** Remove administrators of this degree *****/
|
||||||
DB_QueryDELETE ("can not remove administrators of a degree",
|
Enr_DB_RemAdmins (HieLvl_DEG,DegCod);
|
||||||
"DELETE FROM usr_admins"
|
|
||||||
" WHERE Scope='%s'"
|
|
||||||
" AND Cod=%ld",
|
|
||||||
Sco_GetDBStrFromScope (HieLvl_DEG),
|
|
||||||
DegCod);
|
|
||||||
|
|
||||||
/***** Remove the degree *****/
|
/***** Remove the degree *****/
|
||||||
DB_QueryDELETE ("can not remove a degree",
|
Deg_DB_RemoveDeg (DegCod);
|
||||||
"DELETE FROM deg_degrees"
|
|
||||||
" WHERE DegCod=%ld",
|
|
||||||
DegCod);
|
|
||||||
|
|
||||||
/***** Flush caches *****/
|
/***** Flush caches *****/
|
||||||
Crs_FlushCacheNumCrssInDeg ();
|
Crs_FlushCacheNumCrssInDeg ();
|
||||||
|
@ -1545,42 +1472,6 @@ void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullNam
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********************* Check if the name of degree exists ********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
|
||||||
long DegCod,long CtrCod)
|
|
||||||
{
|
|
||||||
/***** Get number of degrees with a type and a name from database *****/
|
|
||||||
return (DB_QueryCOUNT ("can not check if the name of a degree"
|
|
||||||
" already existed",
|
|
||||||
"SELECT COUNT(*)"
|
|
||||||
" FROM deg_degrees"
|
|
||||||
" WHERE CtrCod=%ld"
|
|
||||||
" AND %s='%s'"
|
|
||||||
" AND DegCod<>%ld",
|
|
||||||
CtrCod,
|
|
||||||
FieldName,Name,
|
|
||||||
DegCod) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/***************** Update degree name in table of degrees ********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void Deg_DB_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName)
|
|
||||||
{
|
|
||||||
/***** Update degree changing old name by new name *****/
|
|
||||||
DB_QueryUPDATE ("can not update the name of a degree",
|
|
||||||
"UPDATE deg_degrees"
|
|
||||||
" SET %s='%s'"
|
|
||||||
" WHERE DegCod=%ld",
|
|
||||||
FieldName,
|
|
||||||
NewDegName,
|
|
||||||
DegCod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************ Change the type of a degree ************************/
|
/************************ Change the type of a degree ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1604,12 +1495,7 @@ void Deg_ChangeDegreeType (void)
|
||||||
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
|
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
|
||||||
|
|
||||||
/***** Update the table of degrees changing old type by new type *****/
|
/***** Update the table of degrees changing old type by new type *****/
|
||||||
DB_QueryUPDATE ("can not update the type of a degree",
|
Deg_DB_UpdateDegTyp (Deg_EditingDeg->DegCod,NewDegTypCod);
|
||||||
"UPDATE deg_degrees"
|
|
||||||
" SET DegTypCod=%ld"
|
|
||||||
" WHERE DegCod=%ld",
|
|
||||||
NewDegTypCod,
|
|
||||||
Deg_EditingDeg->DegCod);
|
|
||||||
Deg_EditingDeg->DegTypCod = NewDegTypCod;
|
Deg_EditingDeg->DegTypCod = NewDegTypCod;
|
||||||
|
|
||||||
/***** Create alert to show the change made
|
/***** Create alert to show the change made
|
||||||
|
@ -1658,21 +1544,6 @@ void Deg_ChangeDegWWW (void)
|
||||||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**************** Update database changing old WWW by new WWW ****************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Deg_DB_UpdateDegWWW (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
|
|
||||||
{
|
|
||||||
/***** Update database changing old WWW by new WWW *****/
|
|
||||||
DB_QueryUPDATE ("can not update the web of a degree",
|
|
||||||
"UPDATE deg_degrees"
|
|
||||||
" SET WWW='%s'"
|
|
||||||
" WHERE DegCod=%ld",
|
|
||||||
NewWWW,
|
|
||||||
DegCod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********************** Change the status of a degree ***********************/
|
/*********************** Change the status of a degree ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1705,12 +1576,7 @@ void Deg_ChangeDegStatus (void)
|
||||||
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
|
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);
|
||||||
|
|
||||||
/***** Update status in table of degrees *****/
|
/***** Update status in table of degrees *****/
|
||||||
DB_QueryUPDATE ("can not update the status of a degree",
|
Deg_DB_UpdateDegStatus (Deg_EditingDeg->DegCod,Status);
|
||||||
"UPDATE deg_degrees"
|
|
||||||
" SET Status=%u"
|
|
||||||
" WHERE DegCod=%ld",
|
|
||||||
(unsigned) Status,
|
|
||||||
Deg_EditingDeg->DegCod);
|
|
||||||
Deg_EditingDeg->Status = Status;
|
Deg_EditingDeg->Status = Status;
|
||||||
|
|
||||||
/***** Write alert to show the change made
|
/***** Write alert to show the change made
|
||||||
|
@ -1835,16 +1701,7 @@ unsigned Deg_GetNumDegsInCty (long CtyCod)
|
||||||
|
|
||||||
/***** 3. Slow: number of degrees in a country from database *****/
|
/***** 3. Slow: number of degrees in a country from database *****/
|
||||||
Gbl.Cache.NumDegsInCty.CtyCod = CtyCod;
|
Gbl.Cache.NumDegsInCty.CtyCod = CtyCod;
|
||||||
Gbl.Cache.NumDegsInCty.NumDegs = (unsigned)
|
Gbl.Cache.NumDegsInCty.NumDegs = Deg_DB_GetNumDegsInCty (CtyCod);
|
||||||
DB_QueryCOUNT ("can not get the number of degrees in a country",
|
|
||||||
"SELECT COUNT(*)"
|
|
||||||
" FROM ins_instits,"
|
|
||||||
"ctr_centers,"
|
|
||||||
"deg_degrees"
|
|
||||||
" WHERE ins_instits.CtyCod=%ld"
|
|
||||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
|
||||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
|
||||||
CtyCod);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,HieLvl_CTY,Gbl.Cache.NumDegsInCty.CtyCod,
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,HieLvl_CTY,Gbl.Cache.NumDegsInCty.CtyCod,
|
||||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCty.NumDegs);
|
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCty.NumDegs);
|
||||||
return Gbl.Cache.NumDegsInCty.NumDegs;
|
return Gbl.Cache.NumDegsInCty.NumDegs;
|
||||||
|
@ -1885,14 +1742,7 @@ unsigned Deg_GetNumDegsInIns (long InsCod)
|
||||||
|
|
||||||
/***** 3. Slow: number of degrees in an institution from database *****/
|
/***** 3. Slow: number of degrees in an institution from database *****/
|
||||||
Gbl.Cache.NumDegsInIns.InsCod = InsCod;
|
Gbl.Cache.NumDegsInIns.InsCod = InsCod;
|
||||||
Gbl.Cache.NumDegsInIns.NumDegs = (unsigned)
|
Gbl.Cache.NumDegsInIns.NumDegs = Deg_DB_GetNumDegsInIns (InsCod);
|
||||||
DB_QueryCOUNT ("can not get the number of degrees in an institution",
|
|
||||||
"SELECT COUNT(*)"
|
|
||||||
" FROM ctr_centers,"
|
|
||||||
"deg_degrees"
|
|
||||||
" WHERE ctr_centers.InsCod=%ld"
|
|
||||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
|
||||||
InsCod);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,HieLvl_INS,Gbl.Cache.NumDegsInIns.InsCod,
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,HieLvl_INS,Gbl.Cache.NumDegsInIns.InsCod,
|
||||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInIns.NumDegs);
|
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInIns.NumDegs);
|
||||||
return Gbl.Cache.NumDegsInIns.NumDegs;
|
return Gbl.Cache.NumDegsInIns.NumDegs;
|
||||||
|
@ -1933,12 +1783,7 @@ unsigned Deg_GetNumDegsInCtr (long CtrCod)
|
||||||
|
|
||||||
/***** 3. Slow: number of degrees in a center from database *****/
|
/***** 3. Slow: number of degrees in a center from database *****/
|
||||||
Gbl.Cache.NumDegsInCtr.CtrCod = CtrCod;
|
Gbl.Cache.NumDegsInCtr.CtrCod = CtrCod;
|
||||||
Gbl.Cache.NumDegsInCtr.NumDegs = (unsigned)
|
Gbl.Cache.NumDegsInCtr.NumDegs = Deg_DB_GetNumDegsInCtr (CtrCod);
|
||||||
DB_QueryCOUNT ("can not get the number of degrees in a center",
|
|
||||||
"SELECT COUNT(*)"
|
|
||||||
" FROM deg_degrees"
|
|
||||||
" WHERE CtrCod=%ld",
|
|
||||||
CtrCod);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,HieLvl_CTR,Gbl.Cache.NumDegsInCtr.CtrCod,
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,HieLvl_CTR,Gbl.Cache.NumDegsInCtr.CtrCod,
|
||||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCtr.NumDegs);
|
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCtr.NumDegs);
|
||||||
return Gbl.Cache.NumDegsInCtr.NumDegs;
|
return Gbl.Cache.NumDegsInCtr.NumDegs;
|
||||||
|
@ -1971,17 +1816,7 @@ unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery,
|
||||||
FigCch_UNSIGNED,&NumDegsWithCrss))
|
FigCch_UNSIGNED,&NumDegsWithCrss))
|
||||||
{
|
{
|
||||||
/***** Get current number of degrees with courses from database and update cache *****/
|
/***** Get current number of degrees with courses from database and update cache *****/
|
||||||
NumDegsWithCrss = (unsigned)
|
NumDegsWithCrss = Deg_DB_GetNumDegsWithCrss (SubQuery);
|
||||||
DB_QueryCOUNT ("can not get number of degrees with courses",
|
|
||||||
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
|
||||||
" FROM ins_instits,"
|
|
||||||
"ctr_centers,"
|
|
||||||
"deg_degrees,"
|
|
||||||
"crs_courses"
|
|
||||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
|
||||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
|
||||||
SubQuery);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS_WITH_CRSS,Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS_WITH_CRSS,Scope,Cod,
|
||||||
FigCch_UNSIGNED,&NumDegsWithCrss);
|
FigCch_UNSIGNED,&NumDegsWithCrss);
|
||||||
}
|
}
|
||||||
|
@ -2009,20 +1844,7 @@ unsigned Deg_GetCachedNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
||||||
FigCch_UNSIGNED,&NumDegsWithUsrs))
|
FigCch_UNSIGNED,&NumDegsWithUsrs))
|
||||||
{
|
{
|
||||||
/***** Get current number of degrees with users from database and update cache *****/
|
/***** Get current number of degrees with users from database and update cache *****/
|
||||||
NumDegsWithUsrs = (unsigned)
|
NumDegsWithUsrs = Deg_DB_GetNumDegsWithUsrs (Role,SubQuery);
|
||||||
DB_QueryCOUNT ("can not get number of degrees with users",
|
|
||||||
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
|
||||||
" FROM ins_instits,"
|
|
||||||
"ctr_centers,"
|
|
||||||
"deg_degrees,"
|
|
||||||
"crs_courses,"
|
|
||||||
"crs_users"
|
|
||||||
" WHERE %sinstitutions.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",
|
|
||||||
SubQuery,(unsigned) Role);
|
|
||||||
FigCch_UpdateFigureIntoCache (FigureDegs[Role],Scope,Cod,
|
FigCch_UpdateFigureIntoCache (FigureDegs[Role],Scope,Cod,
|
||||||
FigCch_UNSIGNED,&NumDegsWithUsrs);
|
FigCch_UNSIGNED,&NumDegsWithUsrs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,16 +115,12 @@ void Deg_PutParamDegCod (long DegCod);
|
||||||
long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed);
|
long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed);
|
||||||
|
|
||||||
bool Deg_GetDataOfDegreeByCod (struct Deg_Degree *Deg);
|
bool Deg_GetDataOfDegreeByCod (struct Deg_Degree *Deg);
|
||||||
long Deg_GetInsCodOfDegreeByCod (long DegCod);
|
|
||||||
void Deg_RemoveDegreeCompletely (long DegCod);
|
void Deg_RemoveDegreeCompletely (long DegCod);
|
||||||
void Deg_RenameDegreeShort (void);
|
void Deg_RenameDegreeShort (void);
|
||||||
void Deg_RenameDegreeFull (void);
|
void Deg_RenameDegreeFull (void);
|
||||||
void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName);
|
void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName);
|
||||||
bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
|
||||||
long DegCod,long CtrCod);
|
|
||||||
void Deg_ChangeDegreeType (void);
|
void Deg_ChangeDegreeType (void);
|
||||||
void Deg_ChangeDegWWW (void);
|
void Deg_ChangeDegWWW (void);
|
||||||
void Deg_DB_UpdateDegWWW (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
|
|
||||||
void Deg_ChangeDegStatus (void);
|
void Deg_ChangeDegStatus (void);
|
||||||
void Deg_ContEditAfterChgDeg (void);
|
void Deg_ContEditAfterChgDeg (void);
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,26 @@ unsigned Deg_DB_GetDataOfDegreeByCod (MYSQL_RES **mysql_res,long DegCod)
|
||||||
DegCod);
|
DegCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********** Get the institution code of a degree from its code ***************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
long Deg_DB_GetInsCodOfDegreeByCod (long DegCod)
|
||||||
|
{
|
||||||
|
/***** Trivial check: degree code should be > 0 *****/
|
||||||
|
if (DegCod <= 0)
|
||||||
|
return -1L;
|
||||||
|
|
||||||
|
/***** Get the institution code of a degree from database *****/
|
||||||
|
return DB_QuerySELECTCode ("can not get the institution of a degree",
|
||||||
|
"SELECT ctr_centers.InsCod"
|
||||||
|
" FROM deg_degrees,"
|
||||||
|
"ctr_centers"
|
||||||
|
" WHERE deg_degrees.DegCod=%ld"
|
||||||
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod",
|
||||||
|
DegCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************* Get the center code of a degree from its code *****************/
|
/************* Get the center code of a degree from its code *****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -342,7 +362,7 @@ unsigned Deg_DB_GetDegsOfType (MYSQL_RES **mysql_res,long DegTypCod)
|
||||||
/********* Get degrees belonging to the current center from database *********/
|
/********* Get degrees belonging to the current center from database *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Deg_DB_GetDegsOfCurrentCtr (MYSQL_RES **mysql_res)
|
unsigned Deg_DB_GetDegsOfCurrentCtrBasic (MYSQL_RES **mysql_res)
|
||||||
{
|
{
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get degrees of a center",
|
DB_QuerySELECT (mysql_res,"can not get degrees of a center",
|
||||||
|
@ -354,6 +374,28 @@ unsigned Deg_DB_GetDegsOfCurrentCtr (MYSQL_RES **mysql_res)
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********* Get degrees belonging to the current center from database *********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Deg_DB_GetDegsOfCurrentCtrFull (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get degrees of a center",
|
||||||
|
"SELECT DegCod," // row[0]
|
||||||
|
"CtrCod," // row[1]
|
||||||
|
"DegTypCod," // row[2]
|
||||||
|
"Status," // row[3]
|
||||||
|
"RequesterUsrCod," // row[4]
|
||||||
|
"ShortName," // row[5]
|
||||||
|
"FullName," // row[6]
|
||||||
|
"WWW" // row[7]
|
||||||
|
" FROM deg_degrees"
|
||||||
|
" WHERE CtrCod=%ld"
|
||||||
|
" ORDER BY FullName",
|
||||||
|
Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Get degrees with pending courses ***********************/
|
/******************** Get degrees with pending courses ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -399,11 +441,148 @@ unsigned Deg_DB_GetDegsWithPendingCrss (MYSQL_RES **mysql_res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Get degrees that have students **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Deg_DB_GetDegsWithStds (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get degrees with students",
|
||||||
|
"SELECT DISTINCTROW "
|
||||||
|
"deg_degrees.DegCod," // row[0]
|
||||||
|
"deg_degrees.CtrCod," // row[1]
|
||||||
|
"deg_degrees.DegTypCod," // row[2]
|
||||||
|
"deg_degrees.Status," // row[3]
|
||||||
|
"deg_degrees.RequesterUsrCod," // row[4]
|
||||||
|
"deg_degrees.ShortName," // row[5]
|
||||||
|
"deg_degrees.FullName," // row[6]
|
||||||
|
"deg_degrees.WWW" // row[7]
|
||||||
|
" FROM deg_degrees,"
|
||||||
|
"crs_courses,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
|
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||||
|
" AND crs_users.Role=%u"
|
||||||
|
" ORDER BY deg_degrees.ShortName",
|
||||||
|
(unsigned) Rol_STD);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************* Check if the name of degree exists ********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
||||||
|
long DegCod,long CtrCod)
|
||||||
|
{
|
||||||
|
/***** Get number of degrees with a type and a name from database *****/
|
||||||
|
return (DB_QueryCOUNT ("can not check if the name of a degree"
|
||||||
|
" already existed",
|
||||||
|
"SELECT COUNT(*)"
|
||||||
|
" FROM deg_degrees"
|
||||||
|
" WHERE CtrCod=%ld"
|
||||||
|
" AND %s='%s'"
|
||||||
|
" AND DegCod<>%ld",
|
||||||
|
CtrCod,
|
||||||
|
FieldName,Name,
|
||||||
|
DegCod) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************** Get current number of degrees with courses ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Deg_DB_GetNumDegsWithCrss (const char *SubQuery)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get number of degrees with courses",
|
||||||
|
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
||||||
|
" FROM ins_instits,"
|
||||||
|
"ctr_centers,"
|
||||||
|
"deg_degrees,"
|
||||||
|
"crs_courses"
|
||||||
|
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||||
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||||
|
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||||
|
SubQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**************** Get current number of degrees with users *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get number of degrees with users",
|
||||||
|
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
||||||
|
" FROM ins_instits,"
|
||||||
|
"ctr_centers,"
|
||||||
|
"deg_degrees,"
|
||||||
|
"crs_courses,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE %sinstitutions.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",
|
||||||
|
SubQuery,(unsigned) Role);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Get number of degrees in a country *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Deg_DB_GetNumDegsInCty (long CtyCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get the number of degrees in a country",
|
||||||
|
"SELECT COUNT(*)"
|
||||||
|
" FROM ins_instits,"
|
||||||
|
"ctr_centers,"
|
||||||
|
"deg_degrees"
|
||||||
|
" WHERE ins_instits.CtyCod=%ld"
|
||||||
|
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||||
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||||
|
CtyCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************** Get number of degrees in an institution *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Deg_DB_GetNumDegsInIns (long InsCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get the number of degrees in an institution",
|
||||||
|
"SELECT COUNT(*)"
|
||||||
|
" FROM ctr_centers,"
|
||||||
|
"deg_degrees"
|
||||||
|
" WHERE ctr_centers.InsCod=%ld"
|
||||||
|
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||||
|
InsCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Get number of degrees in a center **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Deg_DB_GetNumDegsInCtr (long CtrCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QueryCOUNT ("can not get the number of degrees in a center",
|
||||||
|
"SELECT COUNT(*)"
|
||||||
|
" FROM deg_degrees"
|
||||||
|
" WHERE CtrCod=%ld",
|
||||||
|
CtrCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************* Update degree type name ***************************/
|
/************************* Update degree type name ***************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Deg_DB_UpdateDegTypName (long DegTypCod,const char NewNameDegTyp[DegTyp_MAX_BYTES_DEGREE_TYPE_NAME + 1])
|
void Deg_DB_UpdateDegTypName (long DegTypCod,
|
||||||
|
const char NewNameDegTyp[DegTyp_MAX_BYTES_DEGREE_TYPE_NAME + 1])
|
||||||
{
|
{
|
||||||
DB_QueryUPDATE ("can not update the type of a degree",
|
DB_QueryUPDATE ("can not update the type of a degree",
|
||||||
"UPDATE deg_types"
|
"UPDATE deg_types"
|
||||||
|
@ -414,16 +593,74 @@ void Deg_DB_UpdateDegTypName (long DegTypCod,const char NewNameDegTyp[DegTyp_MAX
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************** Update degree center in table of degrees *******************/
|
/***************** Update degree name in table of degrees ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Deg_DB_UpdateDegCtr (long DegCod,long CtrCod)
|
void Deg_DB_UpdateDegNameDB (long DegCod,const char *FieldName,
|
||||||
|
const char NewDegName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1])
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not update the name of a degree",
|
||||||
|
"UPDATE deg_degrees"
|
||||||
|
" SET %s='%s'"
|
||||||
|
" WHERE DegCod=%ld",
|
||||||
|
FieldName,
|
||||||
|
NewDegName,
|
||||||
|
DegCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Update the center of a degree ***********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Deg_DB_UpdateDegCtr (long DegCod,long NewCtrCod)
|
||||||
{
|
{
|
||||||
DB_QueryUPDATE ("can not update the center of a degree",
|
DB_QueryUPDATE ("can not update the center of a degree",
|
||||||
"UPDATE deg_degrees"
|
"UPDATE deg_degrees"
|
||||||
" SET CtrCod=%ld"
|
" SET CtrCod=%ld"
|
||||||
" WHERE DegCod=%ld",
|
" WHERE DegCod=%ld",
|
||||||
CtrCod,
|
NewCtrCod,
|
||||||
|
DegCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Update the type of a degree *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Deg_DB_UpdateDegTyp (long DegCod,long NewDegTypCod)
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not update the type of a degree",
|
||||||
|
"UPDATE deg_degrees"
|
||||||
|
" SET DegTypCod=%ld"
|
||||||
|
" WHERE DegCod=%ld",
|
||||||
|
NewDegTypCod,
|
||||||
|
DegCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ Update the WWW of a degree *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Deg_DB_UpdateDegWWW (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not update the web of a degree",
|
||||||
|
"UPDATE deg_degrees"
|
||||||
|
" SET WWW='%s'"
|
||||||
|
" WHERE DegCod=%ld",
|
||||||
|
NewWWW,
|
||||||
|
DegCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Update the status of a degree ***********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Deg_DB_UpdateDegStatus (long DegCod,Deg_Status_t NewStatus)
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not update the status of a degree",
|
||||||
|
"UPDATE deg_degrees"
|
||||||
|
" SET Status=%u"
|
||||||
|
" WHERE DegCod=%ld",
|
||||||
|
(unsigned) NewStatus,
|
||||||
DegCod);
|
DegCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,3 +675,15 @@ void Deg_DB_RemoveDegTyp (long DegTypCod)
|
||||||
" WHERE DegTypCod=%ld",
|
" WHERE DegTypCod=%ld",
|
||||||
DegTypCod);
|
DegTypCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Remove the degree *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Deg_DB_RemoveDeg (long DegCod)
|
||||||
|
{
|
||||||
|
DB_QueryDELETE ("can not remove a degree",
|
||||||
|
"DELETE FROM deg_degrees"
|
||||||
|
" WHERE DegCod=%ld",
|
||||||
|
DegCod);
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
// #include "swad_action.h"
|
// #include "swad_action.h"
|
||||||
// #include "swad_constant.h"
|
// #include "swad_constant.h"
|
||||||
|
#include "swad_degree.h"
|
||||||
#include "swad_degree_type.h"
|
#include "swad_degree_type.h"
|
||||||
// #include "swad_hierarchy_level.h"
|
// #include "swad_hierarchy_level.h"
|
||||||
// #include "swad_role_type.h"
|
// #include "swad_role_type.h"
|
||||||
|
@ -55,17 +56,35 @@ unsigned Deg_DB_GetDegreeTypes (MYSQL_RES **mysql_res,
|
||||||
HieLvl_Level_t Scope,DegTyp_Order_t Order);
|
HieLvl_Level_t Scope,DegTyp_Order_t Order);
|
||||||
void Deg_DB_GetDegTypeNameByCod (struct DegreeType *DegTyp);
|
void Deg_DB_GetDegTypeNameByCod (struct DegreeType *DegTyp);
|
||||||
unsigned Deg_DB_GetDataOfDegreeByCod (MYSQL_RES **mysql_res,long DegCod);
|
unsigned Deg_DB_GetDataOfDegreeByCod (MYSQL_RES **mysql_res,long DegCod);
|
||||||
|
long Deg_DB_GetInsCodOfDegreeByCod (long DegCod);
|
||||||
long Deg_DB_GetCtrCodOfDegreeByCod (long DegCod);
|
long Deg_DB_GetCtrCodOfDegreeByCod (long DegCod);
|
||||||
void Deg_DB_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg);
|
void Deg_DB_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg);
|
||||||
bool Deg_DB_CheckIfDegreeTypeNameExists (const char *DegTypName,long DegTypCod);
|
bool Deg_DB_CheckIfDegreeTypeNameExists (const char *DegTypName,long DegTypCod);
|
||||||
unsigned Deg_DB_GetNumDegsOfType (long DegTypCod);
|
unsigned Deg_DB_GetNumDegsOfType (long DegTypCod);
|
||||||
unsigned Deg_DB_GetDegsOfType (MYSQL_RES **mysql_res,long DegTypCod);
|
unsigned Deg_DB_GetDegsOfType (MYSQL_RES **mysql_res,long DegTypCod);
|
||||||
unsigned Deg_DB_GetDegsOfCurrentCtr (MYSQL_RES **mysql_res);
|
unsigned Deg_DB_GetDegsOfCurrentCtrBasic (MYSQL_RES **mysql_res);
|
||||||
|
unsigned Deg_DB_GetDegsOfCurrentCtrFull (MYSQL_RES **mysql_res);
|
||||||
unsigned Deg_DB_GetDegsWithPendingCrss (MYSQL_RES **mysql_res);
|
unsigned Deg_DB_GetDegsWithPendingCrss (MYSQL_RES **mysql_res);
|
||||||
|
unsigned Deg_DB_GetDegsWithStds (MYSQL_RES **mysql_res);
|
||||||
|
bool Deg_DB_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
||||||
|
long DegCod,long CtrCod);
|
||||||
|
|
||||||
void Deg_DB_UpdateDegTypName (long DegTypCod,const char NewNameDegTyp[DegTyp_MAX_BYTES_DEGREE_TYPE_NAME + 1]);
|
unsigned Deg_DB_GetNumDegsWithCrss (const char *SubQuery);
|
||||||
void Deg_DB_UpdateDegCtr (long DegCod,long CtrCod);
|
unsigned Deg_DB_GetNumDegsWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
||||||
|
unsigned Deg_DB_GetNumDegsInCty (long CtyCod);
|
||||||
|
unsigned Deg_DB_GetNumDegsInIns (long InsCod);
|
||||||
|
unsigned Deg_DB_GetNumDegsInCtr (long CtrCod);
|
||||||
|
|
||||||
|
void Deg_DB_UpdateDegTypName (long DegTypCod,
|
||||||
|
const char NewNameDegTyp[DegTyp_MAX_BYTES_DEGREE_TYPE_NAME + 1]);
|
||||||
|
void Deg_DB_UpdateDegNameDB (long DegCod,const char *FieldName,
|
||||||
|
const char NewDegName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]);
|
||||||
|
void Deg_DB_UpdateDegCtr (long DegCod,long NewCtrCod);
|
||||||
|
void Deg_DB_UpdateDegTyp (long DegCod,long NewDegTypCod);
|
||||||
|
void Deg_DB_UpdateDegWWW (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
|
||||||
|
void Deg_DB_UpdateDegStatus (long DegCod,Deg_Status_t NewStatus);
|
||||||
|
|
||||||
void Deg_DB_RemoveDegTyp (long DegTypCod);
|
void Deg_DB_RemoveDegTyp (long DegTypCod);
|
||||||
|
void Deg_DB_RemoveDeg (long DegCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4453,3 +4453,17 @@ void Enr_DB_RemUsrAsAdmin (long UsrCod)
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
UsrCod);
|
UsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********* Remove administrators of an institution, center or degree *********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod)
|
||||||
|
{
|
||||||
|
DB_QueryDELETE ("can not remove administrators",
|
||||||
|
"DELETE FROM usr_admins"
|
||||||
|
" WHERE Scope='%s'"
|
||||||
|
" AND Cod=%ld",
|
||||||
|
Sco_GetDBStrFromScope (Scope),
|
||||||
|
Cod);
|
||||||
|
}
|
||||||
|
|
|
@ -151,5 +151,6 @@ void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod);
|
||||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
|
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
|
||||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
||||||
void Enr_DB_RemUsrAsAdmin (long UsrCod);
|
void Enr_DB_RemUsrAsAdmin (long UsrCod);
|
||||||
|
void Enr_DB_RemAdmins (HieLvl_Level_t Scope,long Cod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <stdlib.h> // For free
|
#include <stdlib.h> // For free
|
||||||
|
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
|
#include "swad_degree_database.h"
|
||||||
#include "swad_error.h"
|
#include "swad_error.h"
|
||||||
#include "swad_form.h"
|
#include "swad_form.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
@ -535,7 +536,7 @@ void Hie_InitHierarchy (void)
|
||||||
if (Deg_GetDataOfDegreeByCod (&Gbl.Hierarchy.Deg)) // Degree found
|
if (Deg_GetDataOfDegreeByCod (&Gbl.Hierarchy.Deg)) // Degree found
|
||||||
{
|
{
|
||||||
Gbl.Hierarchy.Ctr.CtrCod = Gbl.Hierarchy.Deg.CtrCod;
|
Gbl.Hierarchy.Ctr.CtrCod = Gbl.Hierarchy.Deg.CtrCod;
|
||||||
Gbl.Hierarchy.Ins.InsCod = Deg_GetInsCodOfDegreeByCod (Gbl.Hierarchy.Deg.DegCod);
|
Gbl.Hierarchy.Ins.InsCod = Deg_DB_GetInsCodOfDegreeByCod (Gbl.Hierarchy.Deg.DegCod);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Hie_ResetHierarchy ();
|
Hie_ResetHierarchy ();
|
||||||
|
|
|
@ -1382,6 +1382,9 @@ void Ins_RemoveInstitution (void)
|
||||||
(unsigned) Ins_EditingIns->InsCod);
|
(unsigned) Ins_EditingIns->InsCod);
|
||||||
Fil_RemoveTree (PathIns);
|
Fil_RemoveTree (PathIns);
|
||||||
|
|
||||||
|
/***** Remove administrators of this institution *****/
|
||||||
|
Enr_DB_RemAdmins (HieLvl_INS,Ins_EditingIns->InsCod);
|
||||||
|
|
||||||
/***** Remove institution *****/
|
/***** Remove institution *****/
|
||||||
DB_QueryDELETE ("can not remove an institution",
|
DB_QueryDELETE ("can not remove an institution",
|
||||||
"DELETE FROM ins_instits"
|
"DELETE FROM ins_instits"
|
||||||
|
|
|
@ -141,7 +141,7 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText,
|
||||||
{
|
{
|
||||||
Folder = Cfg_FOLDER_INS;
|
Folder = Cfg_FOLDER_INS;
|
||||||
if (Scope == HieLvl_DEG) // && !LogoFound
|
if (Scope == HieLvl_DEG) // && !LogoFound
|
||||||
InsCod = Deg_GetInsCodOfDegreeByCod (Cod);
|
InsCod = Deg_DB_GetInsCodOfDegreeByCod (Cod);
|
||||||
else if (Scope == HieLvl_CTR) // && !LogoFound
|
else if (Scope == HieLvl_CTR) // && !LogoFound
|
||||||
InsCod = Ctr_GetInsCodOfCenterByCod (Cod);
|
InsCod = Ctr_GetInsCodOfCenterByCod (Cod);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue