mirror of https://github.com/acanas/swad-core.git
Version 20.83: May 27, 2021 New module swad_course_database for database queries related to courses.
This commit is contained in:
parent
ac0070c318
commit
41a08ee001
2
Makefile
2
Makefile
|
@ -37,7 +37,7 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_agenda.o \
|
|||
swad_connected.o swad_connected_database.o swad_cookie.o \
|
||||
swad_cookie_database.o swad_country.o swad_country_config.o \
|
||||
swad_country_database.o swad_course.o swad_course_config.o \
|
||||
swad_cryptography.o \
|
||||
swad_course_database.o swad_cryptography.o \
|
||||
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
|
||||
swad_degree_type.o swad_department.o swad_duplicate.o \
|
||||
swad_enrolment.o swad_error.o swad_exam.o swad_exam_log.o \
|
||||
|
|
|
@ -1840,3 +1840,17 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call
|
|||
Txt_CALL_FOR_EXAM_Other_information,CallsForExams->CallForExam.OtherInfo) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Mark all exam announcements in the course as deleted ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not remove calls for exams of a course",
|
||||
"UPDATE cfe_exams"
|
||||
" SET Status=%u"
|
||||
" WHERE CrsCod=%ld",
|
||||
(unsigned) Cfe_DELETED_CALL_FOR_EXAM,
|
||||
CrsCod);
|
||||
}
|
||||
|
|
|
@ -126,4 +126,6 @@ void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY
|
|||
char **ContentStr,
|
||||
long ExaCod,bool GetContent);
|
||||
|
||||
void Cfe_DB_MarkCallForExamsInCrsAsDeleted (long CrsCod);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1232,7 +1232,7 @@ void Ctr_RemoveCenter (void)
|
|||
Svy_RemoveSurveys (Hie_Lvl_CTR,Ctr_EditingCtr->CtrCod);
|
||||
|
||||
/***** Remove information related to files in center *****/
|
||||
Brw_RemoveCtrFilesFromDB (Ctr_EditingCtr->CtrCod);
|
||||
Brw_DB_RemoveCtrFiles (Ctr_EditingCtr->CtrCod);
|
||||
|
||||
/***** Remove all rooms in center *****/
|
||||
Roo_RemoveAllRoomsInCtr (Ctr_EditingCtr->CtrCod);
|
||||
|
|
|
@ -602,14 +602,15 @@ 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 20.82 (2021-05-23)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.83 (2021-05-27)"
|
||||
#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 20.82: May 22, 2021 Queries moved to module swad_country_database. (311702 lines)
|
||||
Version 20.83: May 27, 2021 New module swad_course_database for database queries related to courses. (311982 lines)
|
||||
Version 20.82: May 23, 2021 Queries moved to module swad_country_database. (311702 lines)
|
||||
Version 20.81: May 22, 2021 New module swad_country_database for database queries related to countries. (311632 lines)
|
||||
Version 20.80: May 20, 2021 New module swad_cookie_database for database queries related to cookies. (311497 lines)
|
||||
Version 20.79: May 20, 2021 New module swad_connected_database for database queries related to connected users. (311415 lines)
|
||||
|
|
|
@ -126,7 +126,7 @@ void Cty_SeeCtyWithPendingInss (void)
|
|||
}
|
||||
|
||||
/***** Get countries with pending institutions *****/
|
||||
if ((NumCtys = Cty_DB_GetListOfCountriesWithPendingInss (&mysql_res)))
|
||||
if ((NumCtys = Cty_DB_GetCtysWithPendingInss (&mysql_res)))
|
||||
{
|
||||
/***** Begin box and table *****/
|
||||
Box_BoxTableBegin (NULL,Txt_Countries_with_pending_institutions,
|
||||
|
@ -748,7 +748,7 @@ void Cty_GetBasicListOfCountries (void)
|
|||
return;
|
||||
|
||||
/***** Get countries from database *****/
|
||||
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetBasicListOfCountries (&mysql_res))) // Countries found...
|
||||
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetCtysBasic (&mysql_res))) // Countries found...
|
||||
{
|
||||
/***** Create list with countries *****/
|
||||
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
|
||||
|
@ -809,7 +809,7 @@ void Cty_GetFullListOfCountries (void)
|
|||
return;
|
||||
|
||||
/***** Get countries from database *****/
|
||||
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetFullListOfCountries (&mysql_res))) // Countries found...
|
||||
if ((Gbl.Hierarchy.Ctys.Num = Cty_DB_GetCtysFull (&mysql_res))) // Countries found...
|
||||
{
|
||||
/***** Create list with countries *****/
|
||||
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
|
||||
|
@ -871,15 +871,15 @@ void Cty_WriteSelectorOfCountry (void)
|
|||
/***** Begin form *****/
|
||||
Frm_BeginFormGoTo (ActSeeIns);
|
||||
|
||||
/* Begin selector of country */
|
||||
/***** Begin selector of country *****/
|
||||
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
||||
"id=\"cty\" name=\"cty\" class=\"HIE_SEL\"");
|
||||
|
||||
/* Initial disabled option */
|
||||
/***** Initial disabled option *****/
|
||||
HTM_OPTION (HTM_Type_STRING,"",Gbl.Hierarchy.Cty.CtyCod < 0,true,
|
||||
"[%s]",Txt_Country);
|
||||
|
||||
/* List countries */
|
||||
/***** List countries *****/
|
||||
for (NumCty = 0;
|
||||
NumCty < Gbl.Hierarchy.Ctys.Num;
|
||||
NumCty++)
|
||||
|
@ -887,7 +887,7 @@ void Cty_WriteSelectorOfCountry (void)
|
|||
Gbl.Hierarchy.Ctys.Lst[NumCty].CtyCod == Gbl.Hierarchy.Cty.CtyCod,false,
|
||||
"%s",Gbl.Hierarchy.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]);
|
||||
|
||||
/* End selector of country */
|
||||
/***** End selector of country *****/
|
||||
HTM_SELECT_End ();
|
||||
|
||||
/***** End form *****/
|
||||
|
|
|
@ -113,7 +113,7 @@ void Cty_DB_CreateCountry (const struct Cty_Countr *Cty)
|
|||
/********** Get basic list of countries ordered by name of country ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_DB_GetBasicListOfCountries (MYSQL_RES **mysql_res)
|
||||
unsigned Cty_DB_GetCtysBasic (MYSQL_RES **mysql_res)
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
|
||||
|
@ -131,7 +131,7 @@ unsigned Cty_DB_GetBasicListOfCountries (MYSQL_RES **mysql_res)
|
|||
/******************* Get countries with pending institutions *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_DB_GetListOfCountriesWithPendingInss (MYSQL_RES **mysql_res)
|
||||
unsigned Cty_DB_GetCtysWithPendingInss (MYSQL_RES **mysql_res)
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
|
||||
|
@ -155,7 +155,7 @@ unsigned Cty_DB_GetListOfCountriesWithPendingInss (MYSQL_RES **mysql_res)
|
|||
/********** and number of users who claim to belong to them ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Cty_DB_GetFullListOfCountries (MYSQL_RES **mysql_res)
|
||||
unsigned Cty_DB_GetCtysFull (MYSQL_RES **mysql_res)
|
||||
{
|
||||
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
|
||||
char StrField[32];
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
|
||||
void Cty_DB_CreateCountry (const struct Cty_Countr *Cty);
|
||||
|
||||
unsigned Cty_DB_GetBasicListOfCountries (MYSQL_RES **mysql_res);
|
||||
unsigned Cty_DB_GetListOfCountriesWithPendingInss (MYSQL_RES **mysql_res);
|
||||
unsigned Cty_DB_GetFullListOfCountries (MYSQL_RES **mysql_res);
|
||||
unsigned Cty_DB_GetCtysBasic (MYSQL_RES **mysql_res);
|
||||
unsigned Cty_DB_GetCtysWithPendingInss (MYSQL_RES **mysql_res);
|
||||
unsigned Cty_DB_GetCtysFull (MYSQL_RES **mysql_res);
|
||||
unsigned Cty_DB_GetDataOfCountryByCod (MYSQL_RES **mysql_res,long CtyCod);
|
||||
void Cty_DB_GetCountryName (long CtyCod,Lan_Language_t Language,
|
||||
char CtyName[Cty_MAX_BYTES_NAME + 1]);
|
||||
|
|
523
swad_course.c
523
swad_course.c
|
@ -35,6 +35,7 @@
|
|||
#include "swad_call_for_exam.h"
|
||||
#include "swad_course.h"
|
||||
#include "swad_course_config.h"
|
||||
#include "swad_course_database.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
|
@ -49,6 +50,7 @@
|
|||
#include "swad_info.h"
|
||||
#include "swad_logo.h"
|
||||
#include "swad_message.h"
|
||||
#include "swad_notice.h"
|
||||
#include "swad_project.h"
|
||||
#include "swad_search.h"
|
||||
#include "swad_survey.h"
|
||||
|
@ -80,7 +82,7 @@ static struct Crs_Course *Crs_EditingCrs = NULL; // Static variable to keep the
|
|||
|
||||
static void Crs_WriteListMyCoursesToSelectOne (void);
|
||||
|
||||
static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses);
|
||||
static void Crs_GetListCrssInCurrentDeg (void);
|
||||
static void Crs_ListCourses (void);
|
||||
static bool Crs_CheckIfICanCreateCourses (void);
|
||||
static void Crs_PutIconsListCourses (__attribute__((unused)) void *Args);
|
||||
|
@ -101,16 +103,11 @@ static void Crs_PutHeadCoursesForEdition (void);
|
|||
static void Crs_ReceiveFormRequestOrCreateCrs (unsigned Status);
|
||||
static void Crs_GetParamsNewCourse (struct Crs_Course *Crs);
|
||||
|
||||
static void Crs_CreateCourse (unsigned Status);
|
||||
static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row);
|
||||
|
||||
static void Crs_GetShortNamesByCod (long CrsCod,
|
||||
char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
|
||||
char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]);
|
||||
|
||||
static void Crs_EmptyCourseCompletely (long CrsCod);
|
||||
|
||||
static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *NewCrsName);
|
||||
static void Crs_UpdateCrsStatus (struct Crs_Course *Crs,Crs_Status_t Status);
|
||||
|
||||
static void Crs_PutButtonToGoToCrs (void);
|
||||
static void Crs_PutButtonToRegisterInCrs (void);
|
||||
|
@ -186,6 +183,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
Box_BoxBegin (NULL,Txt_My_courses,
|
||||
Crs_PutIconToSearchCourses,NULL,
|
||||
Hlp_PROFILE_Courses,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Begin list *****/
|
||||
HTM_UL_Begin ("class=\"LIST_TREE\"");
|
||||
|
||||
/***** Write link to platform *****/
|
||||
|
@ -398,8 +397,10 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
/* Free structure that stores the query result */
|
||||
DB_FreeMySQLResult (&mysql_resCty);
|
||||
|
||||
/***** End box *****/
|
||||
/***** End list *****/
|
||||
HTM_UL_End ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
}
|
||||
|
||||
|
@ -446,18 +447,7 @@ unsigned Crs_GetNumCrssInCty (long CtyCod)
|
|||
|
||||
/***** 3. Slow: number of courses in a country from database *****/
|
||||
Gbl.Cache.NumCrssInCty.CtyCod = CtyCod;
|
||||
Gbl.Cache.NumCrssInCty.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a country",
|
||||
"SELECT COUNT(*)"
|
||||
" 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",
|
||||
CtyCod);
|
||||
Gbl.Cache.NumCrssInCty.NumCrss = Crs_DB_GetNumCrssInCty (CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_CTY,Gbl.Cache.NumCrssInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInCty.NumCrss);
|
||||
return Gbl.Cache.NumCrssInCty.NumCrss;
|
||||
|
@ -498,16 +488,7 @@ unsigned Crs_GetNumCrssInIns (long InsCod)
|
|||
|
||||
/***** 3. Slow: number of courses in an institution from database *****/
|
||||
Gbl.Cache.NumCrssInIns.InsCod = InsCod;
|
||||
Gbl.Cache.NumCrssInIns.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in an institution",
|
||||
"SELECT COUNT(*)"
|
||||
" 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",
|
||||
InsCod);
|
||||
Gbl.Cache.NumCrssInIns.NumCrss = Crs_DB_GetNumCrssInIns (InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_INS,Gbl.Cache.NumCrssInIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInIns.NumCrss);
|
||||
return Gbl.Cache.NumCrssInIns.NumCrss;
|
||||
|
@ -548,14 +529,7 @@ unsigned Crs_GetNumCrssInCtr (long CtrCod)
|
|||
|
||||
/***** 3. Slow: number of courses in a center from database *****/
|
||||
Gbl.Cache.NumCrssInCtr.CtrCod = CtrCod;
|
||||
Gbl.Cache.NumCrssInCtr.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a center",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
CtrCod);
|
||||
Gbl.Cache.NumCrssInCtr.NumCrss = Crs_DB_GetNumCrssInCtr (CtrCod);
|
||||
return Gbl.Cache.NumCrssInCtr.NumCrss;
|
||||
}
|
||||
|
||||
|
@ -598,12 +572,7 @@ unsigned Crs_GetNumCrssInDeg (long DegCod)
|
|||
|
||||
/***** 3. Slow: number of courses in a degree from database *****/
|
||||
Gbl.Cache.NumCrssInDeg.DegCod = DegCod;
|
||||
Gbl.Cache.NumCrssInDeg.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a degree",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
Gbl.Cache.NumCrssInDeg.NumCrss = Crs_DB_GetNumCrssInDeg (DegCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_DEG,Gbl.Cache.NumCrssInDeg.DegCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInDeg.NumCrss);
|
||||
return Gbl.Cache.NumCrssInDeg.NumCrss;
|
||||
|
@ -642,22 +611,7 @@ unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
|||
FigCch_UNSIGNED,&NumCrssWithUsrs))
|
||||
{
|
||||
/***** Get current number of courses with users from database and update cache *****/
|
||||
NumCrssWithUsrs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with users",
|
||||
"SELECT COUNT(DISTINCT crs_courses.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users"
|
||||
" WHERE %s"
|
||||
"institutions.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);
|
||||
NumCrssWithUsrs = Crs_DB_GetNumCrssWithUsrs (Role,SubQuery);
|
||||
FigCch_UpdateFigureIntoCache (FigureCrss[Role],Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumCrssWithUsrs);
|
||||
}
|
||||
|
@ -680,6 +634,8 @@ void Crs_WriteSelectorOfCourse (void)
|
|||
|
||||
/***** Begin form *****/
|
||||
Frm_BeginFormGoTo (ActSeeCrsInf);
|
||||
|
||||
/***** Begin selector of course *****/
|
||||
if (Gbl.Hierarchy.Deg.DegCod > 0)
|
||||
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
||||
"id=\"crs\" name=\"crs\" class=\"HIE_SEL\"");
|
||||
|
@ -687,22 +643,15 @@ void Crs_WriteSelectorOfCourse (void)
|
|||
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"id=\"crs\" name=\"crs\" class=\"HIE_SEL\""
|
||||
" disabled=\"disabled\"");
|
||||
|
||||
/***** Initial disabled option *****/
|
||||
HTM_OPTION (HTM_Type_STRING,"",Gbl.Hierarchy.Crs.CrsCod < 0,true,
|
||||
"[%s]",Txt_Course);
|
||||
|
||||
if (Gbl.Hierarchy.Deg.DegCod > 0)
|
||||
{
|
||||
/***** Get courses belonging to the current degree from database *****/
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"ShortName" // row[1]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" ORDER BY ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
|
||||
/***** Get courses of this degree *****/
|
||||
NumCrss = Crs_DB_GetCrssInCurrentDegBasic (&mysql_res);
|
||||
for (NumCrs = 0;
|
||||
NumCrs < NumCrss;
|
||||
NumCrs++)
|
||||
|
@ -718,15 +667,17 @@ void Crs_WriteSelectorOfCourse (void)
|
|||
HTM_OPTION (HTM_Type_LONG,&CrsCod,
|
||||
Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected
|
||||
CrsCod == Gbl.Hierarchy.Crs.CrsCod,false,
|
||||
"%s",row[1]);
|
||||
"%s",row[1]); // Short name (row[1])
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/***** End form *****/
|
||||
/***** End selector of course *****/
|
||||
HTM_SELECT_End ();
|
||||
|
||||
/***** End form *****/
|
||||
Frm_EndForm ();
|
||||
}
|
||||
|
||||
|
@ -741,7 +692,7 @@ void Crs_ShowCrssOfCurrentDeg (void)
|
|||
return;
|
||||
|
||||
/***** Get list of courses in this degree *****/
|
||||
Crs_GetListCrssInCurrentDeg (Crs_ALL_COURSES_EXCEPT_REMOVED);
|
||||
Crs_GetListCrssInCurrentDeg ();
|
||||
|
||||
/***** Write menu to select country, institution, center and degree *****/
|
||||
Hie_WriteMenuHierarchy ();
|
||||
|
@ -757,7 +708,7 @@ void Crs_ShowCrssOfCurrentDeg (void)
|
|||
/*************** Create a list with courses in current degree ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses)
|
||||
static void Crs_GetListCrssInCurrentDeg (void)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -766,49 +717,7 @@ static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses)
|
|||
struct Crs_Course *Crs;
|
||||
|
||||
/***** Get courses of a degree from database *****/
|
||||
switch (WhatCourses)
|
||||
{
|
||||
case Crs_ACTIVE_COURSES:
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"DegCod," // row[1]
|
||||
"Year," // row[2]
|
||||
"InsCrsCod," // row[3]
|
||||
"Status," // row[4]
|
||||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND Status=0"
|
||||
" ORDER BY Year,"
|
||||
"ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Crs_ALL_COURSES_EXCEPT_REMOVED:
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"DegCod," // row[1]
|
||||
"Year," // row[2]
|
||||
"InsCrsCod," // row[3]
|
||||
"Status," // row[4]
|
||||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND (Status & %u)=0"
|
||||
" ORDER BY Year,"
|
||||
"ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
(unsigned) Crs_STATUS_BIT_REMOVED);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (NumCrss) // Courses found...
|
||||
if ((NumCrss = Crs_DB_GetCrssInCurrentDegFull (&mysql_res))) // Courses found...
|
||||
{
|
||||
/***** Create list with courses in degree *****/
|
||||
if ((Gbl.Hierarchy.Crss.Lst = calloc (NumCrss,
|
||||
|
@ -870,7 +779,7 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void)
|
|||
Frm_BeginFormGoTo (Gbl.Usrs.Me.MyCrss.Num ? ActSeeCrsInf :
|
||||
ActReqSch);
|
||||
|
||||
/***** Start selector of courses *****/
|
||||
/***** Begin selector of courses *****/
|
||||
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
|
||||
"id=\"my_courses\" name=\"crs\"");
|
||||
|
||||
|
@ -889,7 +798,7 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void)
|
|||
CrsCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod;
|
||||
DegCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].DegCod;
|
||||
|
||||
Crs_GetShortNamesByCod (CrsCod,CrsShortName,DegShortName);
|
||||
Crs_DB_GetShortNamesByCod (CrsCod,CrsShortName,DegShortName);
|
||||
|
||||
if (DegCod != LastDegCod)
|
||||
{
|
||||
|
@ -915,8 +824,10 @@ void Crs_WriteSelectorMyCoursesInBreadcrumb (void)
|
|||
HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Crs.CrsCod,true,true,
|
||||
"%s",Gbl.Hierarchy.Crs.ShrtName);
|
||||
|
||||
/***** End form *****/
|
||||
/***** End selector of courses *****/
|
||||
HTM_SELECT_End ();
|
||||
|
||||
/***** End form *****/
|
||||
Frm_EndForm ();
|
||||
}
|
||||
|
||||
|
@ -944,9 +855,11 @@ static void Crs_ListCourses (void)
|
|||
{
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWideMarginPadding (2);
|
||||
|
||||
/* Heading */
|
||||
Crs_PutHeadCoursesForSeeing ();
|
||||
|
||||
/***** List the courses *****/
|
||||
/* List the courses */
|
||||
for (Year = 1;
|
||||
Year <= Deg_MAX_YEARS_PER_DEGREE;
|
||||
Year++)
|
||||
|
@ -1141,7 +1054,7 @@ static void Crs_EditCoursesInternal (void)
|
|||
Deg_GetListDegsInCurrentCtr ();
|
||||
|
||||
/***** Get list of courses in this degree *****/
|
||||
Crs_GetListCrssInCurrentDeg (Crs_ALL_COURSES_EXCEPT_REMOVED);
|
||||
Crs_GetListCrssInCurrentDeg ();
|
||||
|
||||
/***** Write menu to select country, institution, center and degree *****/
|
||||
Hie_WriteMenuHierarchy ();
|
||||
|
@ -1205,8 +1118,10 @@ static void Crs_ListCoursesForEdition (void)
|
|||
{
|
||||
unsigned Year;
|
||||
|
||||
/***** Write heading *****/
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWidePadding (2);
|
||||
|
||||
/***** Write heading *****/
|
||||
Crs_PutHeadCoursesForEdition ();
|
||||
|
||||
/***** List the courses *****/
|
||||
|
@ -1300,7 +1215,9 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year)
|
|||
"name=\"OthCrsYear\" class=\"HIE_SEL_NARROW\"");
|
||||
for (YearAux = 0;
|
||||
YearAux <= Deg_MAX_YEARS_PER_DEGREE;
|
||||
YearAux++) // All the years are permitted because it's possible to move this course to another degree (with other active years)
|
||||
YearAux++) // All the years are permitted
|
||||
// because it's possible to move this course
|
||||
// to another degree (with other active years)
|
||||
HTM_OPTION (HTM_Type_UNSIGNED,&YearAux,
|
||||
YearAux == Crs->Year,false,
|
||||
"%s",Txt_YEAR_OF_DEGREE[YearAux]);
|
||||
|
@ -1658,19 +1575,19 @@ static void Crs_ReceiveFormRequestOrCreateCrs (unsigned Status)
|
|||
Crs_EditingCrs->FullName[0]) // If there's a course name
|
||||
{
|
||||
/***** If name of course was in database... *****/
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Crs_EditingCrs->ShrtName,
|
||||
if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Crs_EditingCrs->ShrtName,
|
||||
-1L,Crs_EditingCrs->DegCod,Crs_EditingCrs->Year))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_The_course_X_already_exists,
|
||||
Crs_EditingCrs->ShrtName);
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Crs_EditingCrs->FullName,
|
||||
else if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("FullName",Crs_EditingCrs->FullName,
|
||||
-1L,Crs_EditingCrs->DegCod,Crs_EditingCrs->Year))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_The_course_X_already_exists,
|
||||
Crs_EditingCrs->FullName);
|
||||
else // Add new requested course to database
|
||||
{
|
||||
Crs_CreateCourse (Status);
|
||||
Crs_DB_CreateCourse (Crs_EditingCrs,Status);
|
||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||
Txt_Created_new_course_X,
|
||||
Crs_EditingCrs->FullName);
|
||||
|
@ -1709,30 +1626,6 @@ static void Crs_GetParamsNewCourse (struct Crs_Course *Crs)
|
|||
Par_GetParToText ("FullName",Crs->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Add a new requested course to pending requests ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Crs_CreateCourse (unsigned Status)
|
||||
{
|
||||
/***** Insert new course into pending requests *****/
|
||||
Crs_EditingCrs->CrsCod =
|
||||
DB_QueryINSERTandReturnCode ("can not create a new course",
|
||||
"INSERT INTO crs_courses"
|
||||
" (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,"
|
||||
"ShortName,FullName)"
|
||||
" VALUES"
|
||||
" (%ld,%u,'%s',%u,%ld,"
|
||||
"'%s','%s')",
|
||||
Crs_EditingCrs->DegCod,
|
||||
Crs_EditingCrs->Year,
|
||||
Crs_EditingCrs->InstitutionalCrsCod,
|
||||
Status,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Crs_EditingCrs->ShrtName,
|
||||
Crs_EditingCrs->FullName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Remove a course ******************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1798,18 +1691,7 @@ bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs)
|
|||
if (Crs->CrsCod > 0)
|
||||
{
|
||||
/***** Get data of a course from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get data of a course",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"DegCod," // row[1]
|
||||
"Year," // row[2]
|
||||
"InsCrsCod," // row[3]
|
||||
"Status," // row[4]
|
||||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
Crs->CrsCod)) // Course found...
|
||||
if (Crs_DB_GetDataOfCourseByCod (&mysql_res,Crs->CrsCod)) // Course found...
|
||||
{
|
||||
/***** Get data of the course *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1857,42 +1739,6 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
|
|||
Str_Copy (Crs->FullName,row[7],sizeof (Crs->FullName) - 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Get the short names of degree and course from a course code *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Crs_GetShortNamesByCod (long CrsCod,
|
||||
char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
|
||||
char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1])
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
DegShortName[0] = CrsShortName[0] = '\0';
|
||||
|
||||
if (CrsCod > 0)
|
||||
{
|
||||
/***** Get the short name of a degree from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a course",
|
||||
"SELECT crs_courses.ShortName," // row[0]
|
||||
"deg_degrees.ShortName" // row[1]
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees"
|
||||
" WHERE crs_courses.CrsCod=%ld"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod",
|
||||
CrsCod) == 1)
|
||||
{
|
||||
/***** Get the course short name and degree short name *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
Str_Copy (CrsShortName,row[0],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||
Str_Copy (DegShortName,row[1],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Remove a course ******************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1905,16 +1751,10 @@ void Crs_RemoveCourseCompletely (long CrsCod)
|
|||
Crs_EmptyCourseCompletely (CrsCod);
|
||||
|
||||
/***** Remove course from table of last accesses to courses in database *****/
|
||||
DB_QueryDELETE ("can not remove a course",
|
||||
"DELETE FROM crs_last"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Crs_DB_RemoveCrsLast (CrsCod);
|
||||
|
||||
/***** Remove course from table of courses in database *****/
|
||||
DB_QueryDELETE ("can not remove a course",
|
||||
"DELETE FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Crs_DB_RemoveCrs (CrsCod);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1943,53 +1783,28 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
|
|||
Ntf_MarkNotifInCrsAsRemoved (-1L,CrsCod);
|
||||
|
||||
/***** Remove information of the course ****/
|
||||
/* Remove information of the course */
|
||||
Crs_DB_RemoveCrsInfo (CrsCod);
|
||||
|
||||
/* Remove timetable of the course */
|
||||
DB_QueryDELETE ("can not remove the timetable of a course",
|
||||
"DELETE FROM tmt_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/* Remove other information of the course */
|
||||
DB_QueryDELETE ("can not remove info sources of a course",
|
||||
"DELETE FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
DB_QueryDELETE ("can not remove info of a course",
|
||||
"DELETE FROM crs_info_txt"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Crs_DB_RemoveCrsTimetable (CrsCod);
|
||||
|
||||
/***** Remove exam announcements in the course *****/
|
||||
/* Mark all exam announcements in the course as deleted */
|
||||
DB_QueryUPDATE ("can not remove exam announcements of a course",
|
||||
"UPDATE cfe_exams"
|
||||
" SET Status=%u"
|
||||
" WHERE CrsCod=%ld",
|
||||
(unsigned) Cfe_DELETED_CALL_FOR_EXAM,
|
||||
CrsCod);
|
||||
Cfe_DB_MarkCallForExamsInCrsAsDeleted (CrsCod);
|
||||
|
||||
/***** Remove course cards of the course *****/
|
||||
/* Remove content of course cards */
|
||||
DB_QueryDELETE ("can not remove content of cards in a course",
|
||||
"DELETE FROM crs_records"
|
||||
" USING crs_record_fields,"
|
||||
"crs_records"
|
||||
" WHERE crs_record_fields.CrsCod=%ld"
|
||||
" AND crs_record_fields.FieldCod=crs_records.FieldCod",
|
||||
CrsCod);
|
||||
Rec_DB_RemoveCrsRecordContents (CrsCod);
|
||||
|
||||
/* Remove definition of fields in course cards */
|
||||
DB_QueryDELETE ("can not remove fields of cards in a course",
|
||||
"DELETE FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Rec_DB_RemoveCrsRecordFields (CrsCod);
|
||||
|
||||
/***** Remove information related to files in course,
|
||||
including groups and projects,
|
||||
so this function must be called
|
||||
before removing groups and projects *****/
|
||||
Brw_RemoveCrsFilesFromDB (CrsCod);
|
||||
Brw_DB_RemoveCrsFiles (CrsCod);
|
||||
|
||||
/***** Remove assignments of the course *****/
|
||||
Asg_RemoveCrsAssignments (CrsCod);
|
||||
|
@ -2001,25 +1816,7 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
|
|||
Att_RemoveCrsAttEvents (CrsCod);
|
||||
|
||||
/***** Remove notices in the course *****/
|
||||
/* Copy all notices from the course to table of deleted notices */
|
||||
DB_QueryINSERT ("can not remove notices in a course",
|
||||
"INSERT INTO not_deleted"
|
||||
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
||||
" SELECT NotCod,"
|
||||
"CrsCod,"
|
||||
"UsrCod,"
|
||||
"CreatTime,"
|
||||
"Content,"
|
||||
"NumNotif"
|
||||
" FROM not_notices"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/* Remove all notices from the course */
|
||||
DB_QueryDELETE ("can not remove notices in a course",
|
||||
"DELETE FROM not_notices"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Not_DB_RemoveCrsNotices (CrsCod);
|
||||
|
||||
/***** Remove all the threads and posts in forums of the course *****/
|
||||
For_RemoveForums (Hie_Lvl_CRS,CrsCod);
|
||||
|
@ -2037,47 +1834,14 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
|
|||
Tst_RemoveCrsTests (CrsCod);
|
||||
|
||||
/***** Remove groups in the course *****/
|
||||
/* Remove all the users in groups in the course */
|
||||
DB_QueryDELETE ("can not remove users from groups of a course",
|
||||
"DELETE FROM grp_users"
|
||||
" USING grp_types,"
|
||||
"grp_groups,"
|
||||
"grp_users"
|
||||
" WHERE grp_types.CrsCod=%ld"
|
||||
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
|
||||
" AND grp_groups.GrpCod=grp_users.GrpCod",
|
||||
CrsCod);
|
||||
|
||||
/* Remove all the groups in the course */
|
||||
DB_QueryDELETE ("can not remove groups of a course",
|
||||
"DELETE FROM grp_groups"
|
||||
" USING grp_types,"
|
||||
"grp_groups"
|
||||
" WHERE grp_types.CrsCod=%ld"
|
||||
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod",
|
||||
CrsCod);
|
||||
|
||||
/* Remove all the group types in the course */
|
||||
DB_QueryDELETE ("can not remove types of group of a course",
|
||||
"DELETE FROM grp_types"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Grp_DB_RemoveCrsGrps (CrsCod);
|
||||
|
||||
/***** Remove users' requests for inscription in the course *****/
|
||||
DB_QueryDELETE ("can not remove requests for inscription to a course",
|
||||
"DELETE FROM crs_requests"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Enr_DB_RemCrsRequests (CrsCod);
|
||||
|
||||
/***** Remove possible users remaining in the course (teachers) *****/
|
||||
DB_QueryDELETE ("can not remove users from a course",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE ("can not remove users from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
Enr_DB_RemAllUsrsFromCrsSettings (CrsCod);
|
||||
Enr_DB_RemAllUsrsFromCrs (CrsCod);
|
||||
|
||||
/***** Remove directories of the course *****/
|
||||
snprintf (PathRelCrs,sizeof (PathRelCrs),"%s/%ld",
|
||||
|
@ -2163,13 +1927,13 @@ void Crs_ChangeCrsYear (void)
|
|||
if (NewYear <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid
|
||||
{
|
||||
/***** If name of course was in database in the new year... *****/
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Crs_EditingCrs->ShrtName,
|
||||
if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Crs_EditingCrs->ShrtName,
|
||||
-1L,Crs_EditingCrs->DegCod,NewYear))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_The_course_X_already_exists_in_year_Y,
|
||||
Crs_EditingCrs->ShrtName,
|
||||
Txt_YEAR_OF_DEGREE[NewYear]);
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Crs_EditingCrs->FullName,
|
||||
else if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("FullName",Crs_EditingCrs->FullName,
|
||||
-1L,Crs_EditingCrs->DegCod,NewYear))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_The_course_X_already_exists_in_year_Y,
|
||||
|
@ -2195,6 +1959,21 @@ void Crs_ChangeCrsYear (void)
|
|||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Change the institutional course code of a course **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,
|
||||
const char *NewInstitutionalCrsCod)
|
||||
{
|
||||
/***** Update institutional course code in table of courses *****/
|
||||
Crs_DB_UpdateInstitutionalCrsCod (Crs->CrsCod,NewInstitutionalCrsCod);
|
||||
|
||||
/***** Copy institutional course code *****/
|
||||
Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,
|
||||
sizeof (Crs->InstitutionalCrsCod) - 1);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Change the year/semester of a course *********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -2202,35 +1981,23 @@ void Crs_ChangeCrsYear (void)
|
|||
void Crs_UpdateCrsYear (struct Crs_Course *Crs,unsigned NewYear)
|
||||
{
|
||||
/***** Update year/semester in table of courses *****/
|
||||
DB_QueryUPDATE ("can not update the year of a course",
|
||||
"UPDATE crs_courses"
|
||||
" SET Year=%u"
|
||||
" WHERE CrsCod=%ld",
|
||||
NewYear,
|
||||
Crs->CrsCod);
|
||||
Crs_DB_UpdateCrsYear (Crs->CrsCod,NewYear);
|
||||
|
||||
/***** Copy course year/semester *****/
|
||||
Crs->Year = NewYear;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Change the institutional course code of a course **************/
|
||||
/********************** Change the status of a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstitutionalCrsCod)
|
||||
static void Crs_UpdateCrsStatus (struct Crs_Course *Crs,Crs_Status_t Status)
|
||||
{
|
||||
/***** Update institutional course code in table of courses *****/
|
||||
DB_QueryUPDATE ("can not update the institutional code"
|
||||
" of the current course",
|
||||
"UPDATE crs_courses"
|
||||
" SET InsCrsCod='%s'"
|
||||
" WHERE CrsCod=%ld",
|
||||
NewInstitutionalCrsCod,
|
||||
Crs->CrsCod);
|
||||
/***** Update status in table of courses *****/
|
||||
Crs_DB_UpdateCrsStatus (Crs->CrsCod,Status);
|
||||
|
||||
/***** Copy institutional course code *****/
|
||||
Str_Copy (Crs->InstitutionalCrsCod,NewInstitutionalCrsCod,
|
||||
sizeof (Crs->InstitutionalCrsCod) - 1);
|
||||
/***** Copy course status *****/
|
||||
Crs->Status = Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2305,7 +2072,7 @@ void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullNam
|
|||
if (strcmp (CurrentCrsName,NewCrsName)) // Different names
|
||||
{
|
||||
/***** If course was in database... *****/
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg (ParamName,NewCrsName,Crs->CrsCod,
|
||||
if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg (ParamName,NewCrsName,Crs->CrsCod,
|
||||
Crs->DegCod,Crs->Year))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_The_course_X_already_exists,
|
||||
|
@ -2313,7 +2080,7 @@ void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullNam
|
|||
else
|
||||
{
|
||||
/* Update the table changing old name by new name */
|
||||
Crs_UpdateCrsNameDB (Crs->CrsCod,FieldName,NewCrsName);
|
||||
Crs_DB_UpdateCrsName (Crs->CrsCod,FieldName,NewCrsName);
|
||||
|
||||
/* Create alert to show the change made */
|
||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||
|
@ -2336,44 +2103,6 @@ void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullNam
|
|||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Check if the name of course exists in existing courses ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
|
||||
long DegCod,unsigned Year)
|
||||
{
|
||||
/***** Get number of courses in a year of a degree and with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name"
|
||||
" of a course already existed",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND Year=%u"
|
||||
" AND %s='%s'"
|
||||
" AND CrsCod<>%ld",
|
||||
DegCod,
|
||||
Year,
|
||||
FieldName,
|
||||
Name,
|
||||
CrsCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Update course name in table of courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *NewCrsName)
|
||||
{
|
||||
/***** Update course changing old name by new name *****/
|
||||
DB_QueryUPDATE ("can not update the name of a course",
|
||||
"UPDATE crs_courses"
|
||||
" SET %s='%s'"
|
||||
" WHERE CrsCod=%ld",
|
||||
FieldName,NewCrsName,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Change the status of a course ***********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -2405,14 +2134,8 @@ void Crs_ChangeCrsStatus (void)
|
|||
/***** Get data of course *****/
|
||||
Crs_GetDataOfCourseByCod (Crs_EditingCrs);
|
||||
|
||||
/***** Update status in table of courses *****/
|
||||
DB_QueryUPDATE ("can not update the status of a course",
|
||||
"UPDATE crs_courses"
|
||||
" SET Status=%u"
|
||||
" WHERE CrsCod=%ld",
|
||||
(unsigned) Status,
|
||||
Crs_EditingCrs->CrsCod);
|
||||
Crs_EditingCrs->Status = Status;
|
||||
/***** Update status *****/
|
||||
Crs_UpdateCrsStatus (Crs_EditingCrs,Status);
|
||||
|
||||
/***** Create alert to show the change made *****/
|
||||
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
||||
|
@ -2508,9 +2231,11 @@ static void Crs_PutButtonToRegisterInCrs (void)
|
|||
// If the course being edited is different to the current one...
|
||||
if (Crs_EditingCrs->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Crs_PutParamCrsCod (Crs_EditingCrs->CrsCod);
|
||||
|
||||
Btn_PutCreateButton (Str_BuildStringStr (Txt_Register_me_in_X,
|
||||
Crs_EditingCrs->ShrtName));
|
||||
Str_FreeString ();
|
||||
|
||||
Frm_EndForm ();
|
||||
}
|
||||
|
||||
|
@ -2563,12 +2288,6 @@ void Crs_PutIconToSelectMyCoursesInBreadcrumb (void)
|
|||
/***** Put icon with link *****/
|
||||
HTM_INPUT_IMAGE (Gbl.Prefs.URLTheme,"sitemap.svg",Txt_My_courses,
|
||||
"BC_ICON ICO_HIGHLIGHT");
|
||||
/*
|
||||
HTM_BUTTON_Begin (Txt_My_courses,NULL,NULL);
|
||||
HTM_IMG (Gbl.Prefs.URLTheme,"sitemap.svg",Txt_My_courses,
|
||||
"class=\"BC_ICON ICO_HIGHLIGHT\"");
|
||||
HTM_BUTTON_End ();
|
||||
*/
|
||||
|
||||
/***** End form *****/
|
||||
Frm_EndForm ();
|
||||
|
@ -2638,48 +2357,13 @@ void Crs_GetAndWriteCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role)
|
|||
extern const char *Txt_Year_OF_A_DEGREE;
|
||||
extern const char *Txt_Course;
|
||||
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
|
||||
char *SubQuery;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumCrss;
|
||||
unsigned NumCrs;
|
||||
|
||||
/***** Get courses of a user from database *****/
|
||||
if (Role == Rol_UNK) // Role == Rol_UNK ==> any role
|
||||
{
|
||||
if (asprintf (&SubQuery,"%s","") < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&SubQuery," AND crs_users.Role=%u",(unsigned) Role) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a user",
|
||||
"SELECT deg_degrees.DegCod," // row[0]
|
||||
"crs_courses.CrsCod," // row[1]
|
||||
"deg_degrees.ShortName," // row[2]
|
||||
"deg_degrees.FullName," // row[3]
|
||||
"crs_courses.Year," // row[4]
|
||||
"crs_courses.FullName," // row[5]
|
||||
"ctr_centers.ShortName," // row[6]
|
||||
"crs_users.Accepted" // row[7]
|
||||
" FROM crs_users,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers"
|
||||
" WHERE crs_users.UsrCod=%ld%s"
|
||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" ORDER BY deg_degrees.FullName,"
|
||||
"crs_courses.Year,"
|
||||
"crs_courses.FullName",
|
||||
UsrDat->UsrCod,SubQuery);
|
||||
|
||||
/***** Free allocated memory for subquery *****/
|
||||
free (SubQuery);
|
||||
NumCrss = Crs_DB_GetCrssOfAUsr (&mysql_res,UsrDat->UsrCod,Role);
|
||||
|
||||
/***** List the courses (one row per course) *****/
|
||||
if (NumCrss)
|
||||
|
@ -2924,20 +2608,15 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Update my last click in current course ********************/
|
||||
/******************* Update last click in current course *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_UpdateCrsLast (void)
|
||||
{
|
||||
if (Gbl.Hierarchy.Level == Hie_Lvl_CRS && // Course selected
|
||||
Gbl.Usrs.Me.Role.Logged >= Rol_STD)
|
||||
/***** Update my last access to current course *****/
|
||||
DB_QueryREPLACE ("can not update last access to current course",
|
||||
"REPLACE INTO crs_last"
|
||||
" (CrsCod,LastTime)"
|
||||
" VALUES"
|
||||
" (%ld,NOW())",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
/***** Update last access to current course *****/
|
||||
Crs_DB_UpdateCrsLastClick ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3029,17 +2708,9 @@ void Crs_RemoveOldCrss (void)
|
|||
SecondsWithoutAccess = (unsigned long) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH;
|
||||
|
||||
/***** Get old courses from database *****/
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get old courses",
|
||||
"SELECT CrsCod"
|
||||
" FROM crs_last"
|
||||
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
||||
" AND CrsCod NOT IN"
|
||||
" (SELECT DISTINCT CrsCod"
|
||||
" FROM crs_users)",
|
||||
SecondsWithoutAccess);
|
||||
if (NumCrss)
|
||||
if ((NumCrss = Crs_DB_GetOldCrss (&mysql_res,SecondsWithoutAccess)))
|
||||
{
|
||||
/***** Initial warning alert *****/
|
||||
Ale_ShowAlert (Ale_INFO,Txt_Eliminating_X_courses_whithout_users_and_with_more_than_Y_months_without_access,
|
||||
NumCrss,
|
||||
MonthsWithoutAccess,
|
||||
|
@ -3059,7 +2730,7 @@ void Crs_RemoveOldCrss (void)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/***** Write end message *****/
|
||||
/***** Write final success alert *****/
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_X_courses_have_been_eliminated,
|
||||
NumCrssRemoved);
|
||||
}
|
||||
|
|
|
@ -71,12 +71,6 @@ typedef enum
|
|||
Crs_STATUS_REMOVED = 3, // 1- (Status & Crs_STATUS_BIT_REMOVED)
|
||||
} Crs_StatusTxt_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Crs_ACTIVE_COURSES = 0, // Courses with all Status bits == 0
|
||||
Crs_ALL_COURSES_EXCEPT_REMOVED = 1, // Courses with Status bit Crs_STATUS_BIT_REMOVED == 0
|
||||
} Crs_WhatCourses_t;
|
||||
|
||||
struct Crs_Course
|
||||
{
|
||||
long CrsCod;
|
||||
|
@ -137,13 +131,15 @@ bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs);
|
|||
void Crs_RemoveCourseCompletely (long CrsCod);
|
||||
void Crs_ChangeInsCrsCod (void);
|
||||
void Crs_ChangeCrsYear (void);
|
||||
|
||||
void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,
|
||||
const char *NewInstitutionalCrsCod);
|
||||
void Crs_UpdateCrsYear (struct Crs_Course *Crs,unsigned NewYear);
|
||||
void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstitutionalCrsCod);
|
||||
|
||||
void Crs_RenameCourseShort (void);
|
||||
void Crs_RenameCourseFull (void);
|
||||
void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName);
|
||||
bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
|
||||
long DegCod,unsigned Year);
|
||||
|
||||
void Crs_ChangeCrsStatus (void);
|
||||
void Crs_ContEditAfterChgCrs (void);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <stdlib.h> // For free
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_course_database.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -77,8 +78,6 @@ static void CrsCfg_Shortcut (bool PrintView);
|
|||
static void CrsCfg_QR (void);
|
||||
static void CrsCfg_Indicators (void);
|
||||
|
||||
static void CrsCfg_UpdateCrsDegDB (long CrsCod,long DegCod);
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Configuration of the current course ***********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -481,14 +480,14 @@ void CrsCfg_ChangeCrsDeg (void)
|
|||
Deg_GetDataOfDegreeByCod (&NewDeg);
|
||||
|
||||
/***** If name of course was in database in the new degree... *****/
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
|
||||
if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
|
||||
NewDeg.DegCod,Gbl.Hierarchy.Crs.Year))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z,
|
||||
Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year],
|
||||
NewDeg.FullName,
|
||||
Gbl.Hierarchy.Crs.ShrtName);
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
|
||||
else if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
|
||||
NewDeg.DegCod,Gbl.Hierarchy.Crs.Year))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z,
|
||||
|
@ -498,7 +497,7 @@ void CrsCfg_ChangeCrsDeg (void)
|
|||
else // Update degree in database
|
||||
{
|
||||
/***** Update degree in table of courses *****/
|
||||
CrsCfg_UpdateCrsDegDB (Gbl.Hierarchy.Crs.CrsCod,NewDeg.DegCod);
|
||||
Crs_DB_UpdateCrsDeg (Gbl.Hierarchy.Crs.CrsCod,NewDeg.DegCod);
|
||||
Gbl.Hierarchy.Crs.DegCod =
|
||||
Gbl.Hierarchy.Deg.DegCod = NewDeg.DegCod;
|
||||
|
||||
|
@ -514,21 +513,6 @@ void CrsCfg_ChangeCrsDeg (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Update degree in table of courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CrsCfg_UpdateCrsDegDB (long CrsCod,long DegCod)
|
||||
{
|
||||
/***** Update degree in table of courses *****/
|
||||
DB_QueryUPDATE ("can not move course to another degree",
|
||||
"UPDATE crs_courses"
|
||||
" SET DegCod=%ld"
|
||||
" WHERE CrsCod=%ld",
|
||||
DegCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Change the name of a course in configuration ****************/
|
||||
/*****************************************************************************/
|
||||
|
@ -563,13 +547,13 @@ void CrsCfg_ChangeCrsYear (void)
|
|||
if (NewYear <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid
|
||||
{
|
||||
/***** If name of course was in database in the new year... *****/
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
|
||||
if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L,
|
||||
Gbl.Hierarchy.Crs.DegCod,NewYear))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_The_course_X_already_exists_in_year_Y,
|
||||
Gbl.Hierarchy.Crs.ShrtName,
|
||||
Txt_YEAR_OF_DEGREE[NewYear]);
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
|
||||
else if (Crs_DB_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L,
|
||||
Gbl.Hierarchy.Crs.DegCod,NewYear))
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
Txt_The_course_X_already_exists_in_year_Y,
|
||||
|
|
|
@ -0,0 +1,501 @@
|
|||
// swad_course_database.c: edition 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <stdio.h> // For asprintf
|
||||
|
||||
#include "swad_course.h"
|
||||
#include "swad_course_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************************** Public constants ********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private types *********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Private variables ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Private prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Add a new requested course to pending requests ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_CreateCourse (struct Crs_Course *Crs,unsigned Status)
|
||||
{
|
||||
/***** Insert new course into pending requests *****/
|
||||
Crs->CrsCod =
|
||||
DB_QueryINSERTandReturnCode ("can not create a new course",
|
||||
"INSERT INTO crs_courses"
|
||||
" (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,"
|
||||
"ShortName,FullName)"
|
||||
" VALUES"
|
||||
" (%ld,%u,'%s',%u,%ld,"
|
||||
"'%s','%s')",
|
||||
Crs->DegCod,
|
||||
Crs->Year,
|
||||
Crs->InstitutionalCrsCod,
|
||||
Status,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Crs->ShrtName,
|
||||
Crs->FullName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get courses in current degree *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetCrssInCurrentDegBasic (MYSQL_RES **mysql_res)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"ShortName" // row[1]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" ORDER BY ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get courses in current degree *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetCrssInCurrentDegFull (MYSQL_RES **mysql_res)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"DegCod," // row[1]
|
||||
"Year," // row[2]
|
||||
"InsCrsCod," // row[3]
|
||||
"Status," // row[4]
|
||||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND (Status & %u)=0"
|
||||
" ORDER BY Year,"
|
||||
"ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
(unsigned) Crs_STATUS_BIT_REMOVED); // All courses except those removed
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get data of a course from its code ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetDataOfCourseByCod (MYSQL_RES **mysql_res,long CrsCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get data of a course",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"DegCod," // row[1]
|
||||
"Year," // row[2]
|
||||
"InsCrsCod," // row[3]
|
||||
"Status," // row[4]
|
||||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Get the short names of degree and course from a course code *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_GetShortNamesByCod (long CrsCod,
|
||||
char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
|
||||
char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1])
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
DegShortName[0] = CrsShortName[0] = '\0';
|
||||
|
||||
/***** Trivial check: course code should be > 0 *****/
|
||||
if (CrsCod <= 0)
|
||||
return;
|
||||
|
||||
/***** Get the short name of a degree from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a course",
|
||||
"SELECT crs_courses.ShortName," // row[0]
|
||||
"deg_degrees.ShortName" // row[1]
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees"
|
||||
" WHERE crs_courses.CrsCod=%ld"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod",
|
||||
CrsCod) == 1)
|
||||
{
|
||||
/***** Get the course short name and degree short name *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
Str_Copy (CrsShortName,row[0],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||
Str_Copy (DegShortName,row[1],Cns_HIERARCHY_MAX_BYTES_SHRT_NAME);
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Check if the name of course exists in existing courses ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Crs_DB_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
|
||||
long DegCod,unsigned Year)
|
||||
{
|
||||
/***** Get number of courses in a year of a degree and with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name"
|
||||
" of a course already existed",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND Year=%u"
|
||||
" AND %s='%s'"
|
||||
" AND CrsCod<>%ld",
|
||||
DegCod,
|
||||
Year,
|
||||
FieldName,
|
||||
Name,
|
||||
CrsCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Write courses of a user **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetCrssOfAUsr (MYSQL_RES **mysql_res,long UsrCod,Rol_Role_t Role)
|
||||
{
|
||||
char *SubQuery;
|
||||
unsigned NumCrss;
|
||||
|
||||
/***** Get courses of a user from database *****/
|
||||
if (Role == Rol_UNK) // Role == Rol_UNK ==> any role
|
||||
{
|
||||
if (asprintf (&SubQuery,"%s","") < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&SubQuery," AND crs_users.Role=%u",(unsigned) Role) < 0)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get courses of a user",
|
||||
"SELECT deg_degrees.DegCod," // row[0]
|
||||
"crs_courses.CrsCod," // row[1]
|
||||
"deg_degrees.ShortName," // row[2]
|
||||
"deg_degrees.FullName," // row[3]
|
||||
"crs_courses.Year," // row[4]
|
||||
"crs_courses.FullName," // row[5]
|
||||
"ctr_centers.ShortName," // row[6]
|
||||
"crs_users.Accepted" // row[7]
|
||||
" FROM crs_users,"
|
||||
"crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers"
|
||||
" WHERE crs_users.UsrCod=%ld%s"
|
||||
" AND crs_users.CrsCod=crs_courses.CrsCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" ORDER BY deg_degrees.FullName,"
|
||||
"crs_courses.Year,"
|
||||
"crs_courses.FullName",
|
||||
UsrCod,SubQuery);
|
||||
|
||||
/***** Free allocated memory for subquery *****/
|
||||
free (SubQuery);
|
||||
|
||||
return NumCrss;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Get old courses from database ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetOldCrss (MYSQL_RES **mysql_res,unsigned long SecondsWithoutAccess)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get old courses",
|
||||
"SELECT CrsCod"
|
||||
" FROM crs_last"
|
||||
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
||||
" AND CrsCod NOT IN"
|
||||
" (SELECT DISTINCT CrsCod"
|
||||
" FROM crs_users)",
|
||||
SecondsWithoutAccess);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get number of courses in a country *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetNumCrssInCty (long CtyCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a country",
|
||||
"SELECT COUNT(*)"
|
||||
" 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",
|
||||
CtyCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Get number of courses in an institution ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetNumCrssInIns (long InsCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in an institution",
|
||||
"SELECT COUNT(*)"
|
||||
" 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",
|
||||
InsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get number of courses in a center *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetNumCrssInCtr (long CtrCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a center",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
CtrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get number of courses in a degree *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetNumCrssInDeg (long DegCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a degree",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get number of courses with users ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with users",
|
||||
"SELECT COUNT(DISTINCT crs_courses.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users"
|
||||
" WHERE %s"
|
||||
"institutions.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);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Change the institutional course code of a course **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_UpdateInstitutionalCrsCod (long CrsCod,const char *NewInstitutionalCrsCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update the institutional code of a course",
|
||||
"UPDATE crs_courses"
|
||||
" SET InsCrsCod='%s'"
|
||||
" WHERE CrsCod=%ld",
|
||||
NewInstitutionalCrsCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Change the year/semester of a course *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_UpdateCrsYear (long CrsCod,unsigned NewYear)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update the year of a course",
|
||||
"UPDATE crs_courses"
|
||||
" SET Year=%u"
|
||||
" WHERE CrsCod=%ld",
|
||||
NewYear,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Change the status of a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_UpdateCrsStatus (long CrsCod,Crs_Status_t Status)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update the status of a course",
|
||||
"UPDATE crs_courses"
|
||||
" SET Status=%u"
|
||||
" WHERE CrsCod=%ld",
|
||||
(unsigned) Status,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Update course name in table of courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_UpdateCrsName (long CrsCod,const char *FieldName,const char *NewCrsName)
|
||||
{
|
||||
DB_QueryUPDATE ("can not update the name of a course",
|
||||
"UPDATE crs_courses"
|
||||
" SET %s='%s'"
|
||||
" WHERE CrsCod=%ld",
|
||||
FieldName,NewCrsName,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Update degree in table of courses ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_UpdateCrsDeg (long CrsCod,long DegCod)
|
||||
{
|
||||
DB_QueryUPDATE ("can not move course to another degree",
|
||||
"UPDATE crs_courses"
|
||||
" SET DegCod=%ld"
|
||||
" WHERE CrsCod=%ld",
|
||||
DegCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Update my last click in current course ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_UpdateCrsLastClick (void)
|
||||
{
|
||||
/***** Update last access to current course *****/
|
||||
DB_QueryREPLACE ("can not update last access to current course",
|
||||
"REPLACE INTO crs_last"
|
||||
" (CrsCod,LastTime)"
|
||||
" VALUES"
|
||||
" (%ld,NOW())",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove information about a course **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_RemoveCrsInfo (long CrsCod)
|
||||
{
|
||||
/* Remove information source of the course */
|
||||
DB_QueryDELETE ("can not remove info sources of a course",
|
||||
"DELETE FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/* Remove information text of the course */
|
||||
DB_QueryDELETE ("can not remove info of a course",
|
||||
"DELETE FROM crs_info_txt"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Remove timetable of a course *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_RemoveCrsTimetable (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove the timetable of a course",
|
||||
"DELETE FROM tmt_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***** Remove course from table of last accesses to courses in database ******/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_RemoveCrsLast (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a course",
|
||||
"DELETE FROM crs_last"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Remove course from table of courses in database ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_RemoveCrs (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a course",
|
||||
"DELETE FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
// swad_course_database.c: edition of courses operations with database
|
||||
|
||||
#ifndef _SWAD_CRS_DB
|
||||
#define _SWAD_CRS_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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "swad_constant.h"
|
||||
#include "swad_course.h"
|
||||
#include "swad_role.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public constants ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Public types ********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Crs_DB_CreateCourse (struct Crs_Course *Crs,unsigned Status);
|
||||
|
||||
unsigned Crs_DB_GetCrssInCurrentDegBasic (MYSQL_RES **mysql_res);
|
||||
unsigned Crs_DB_GetCrssInCurrentDegFull (MYSQL_RES **mysql_res);
|
||||
unsigned Crs_DB_GetDataOfCourseByCod (MYSQL_RES **mysql_res,long CrsCod);
|
||||
void Crs_DB_GetShortNamesByCod (long CrsCod,
|
||||
char CrsShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
|
||||
char DegShortName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]);
|
||||
bool Crs_DB_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
|
||||
long DegCod,unsigned Year);
|
||||
unsigned Crs_DB_GetCrssOfAUsr (MYSQL_RES **mysql_res,long UsrCod,Rol_Role_t Role);
|
||||
unsigned Crs_DB_GetOldCrss (MYSQL_RES **mysql_res,unsigned long SecondsWithoutAccess);
|
||||
|
||||
unsigned Crs_DB_GetNumCrssInCty (long CtyCod);
|
||||
unsigned Crs_DB_GetNumCrssInIns (long InsCod);
|
||||
unsigned Crs_DB_GetNumCrssInCtr (long CtrCod);
|
||||
unsigned Crs_DB_GetNumCrssInDeg (long DegCod);
|
||||
unsigned Crs_DB_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
||||
|
||||
void Crs_DB_UpdateInstitutionalCrsCod (long CrsCod,const char *NewInstitutionalCrsCod);
|
||||
void Crs_DB_UpdateCrsStatus (long CrsCod,Crs_Status_t Status);
|
||||
void Crs_DB_UpdateCrsYear (long CrsCod,unsigned NewYear);
|
||||
void Crs_DB_UpdateCrsName (long CrsCod,const char *FieldName,const char *NewCrsName);
|
||||
void Crs_DB_UpdateCrsDeg (long CrsCod,long DegCod);
|
||||
|
||||
void Crs_DB_UpdateCrsLastClick (void);
|
||||
|
||||
void Crs_DB_RemoveCrsInfo (long CrsCod);
|
||||
void Crs_DB_RemoveCrsTimetable (long CrsCod);
|
||||
void Crs_DB_RemoveCrsLast (long CrsCod);
|
||||
void Crs_DB_RemoveCrs (long CrsCod);
|
||||
|
||||
#endif
|
|
@ -1529,7 +1529,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
|||
Svy_RemoveSurveys (Hie_Lvl_DEG,DegCod);
|
||||
|
||||
/***** Remove information related to files in degree *****/
|
||||
Brw_RemoveDegFilesFromDB (DegCod);
|
||||
Brw_DB_RemoveDegFiles (DegCod);
|
||||
|
||||
/***** Remove directories of the degree *****/
|
||||
snprintf (PathDeg,sizeof (PathDeg),"%s/%02u/%u",
|
||||
|
|
|
@ -4309,7 +4309,19 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Remove a user from a course ************************/
|
||||
/*********** Remove all users' requests for inscription in a course **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemCrsRequests (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove requests for inscription to a course",
|
||||
"DELETE FROM crs_requests"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Remove user's requests for inscription from a course ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemUsrRequests (long UsrCod)
|
||||
|
@ -4320,6 +4332,30 @@ void Enr_DB_RemUsrRequests (long UsrCod)
|
|||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course settings",
|
||||
"DELETE FROM crs_user_settings"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Remove all users from settings in a course ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove users from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Remove a user from a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -145,7 +145,10 @@ void Enr_ModifyUsr2 (void);
|
|||
|
||||
void Enr_AcceptUsrInCrs (long UsrCod);
|
||||
|
||||
void Enr_DB_RemCrsRequests (long CrsCod);
|
||||
void Enr_DB_RemUsrRequests (long UsrCod);
|
||||
void Enr_DB_RemAllUsrsFromCrsSettings (long CrsCod);
|
||||
void Enr_DB_RemAllUsrsFromCrs (long CrsCod);
|
||||
void Enr_DB_RemUsrFromAllCrss (long UsrCod);
|
||||
void Enr_DB_RemUsrAsAdmin (long UsrCod);
|
||||
|
||||
|
|
|
@ -4173,7 +4173,7 @@ static void Brw_StoreSizeOfFileTreeInDB (void)
|
|||
/******** Remove files related to an institution from the database ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Brw_RemoveInsFilesFromDB (long InsCod)
|
||||
void Brw_DB_RemoveInsFiles (long InsCod)
|
||||
{
|
||||
/***** Remove from database the entries that store the file views *****/
|
||||
DB_QueryDELETE ("can not remove file views to files of an institution",
|
||||
|
@ -4241,7 +4241,7 @@ void Brw_RemoveInsFilesFromDB (long InsCod)
|
|||
/************ Remove files related to a center from the database *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Brw_RemoveCtrFilesFromDB (long CtrCod)
|
||||
void Brw_DB_RemoveCtrFiles (long CtrCod)
|
||||
{
|
||||
/***** Remove from database the entries that store the file views *****/
|
||||
DB_QueryDELETE ("can not remove file views to files of a center",
|
||||
|
@ -4305,7 +4305,7 @@ void Brw_RemoveCtrFilesFromDB (long CtrCod)
|
|||
/************ Remove files related to a degree from the database *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Brw_RemoveDegFilesFromDB (long DegCod)
|
||||
void Brw_DB_RemoveDegFiles (long DegCod)
|
||||
{
|
||||
/***** Remove from database the entries that store the file views *****/
|
||||
DB_QueryDELETE ("can not remove file views to files of a degree",
|
||||
|
@ -4373,7 +4373,7 @@ void Brw_RemoveDegFilesFromDB (long DegCod)
|
|||
so this function must be called
|
||||
before removing groups and projects */
|
||||
|
||||
void Brw_RemoveCrsFilesFromDB (long CrsCod)
|
||||
void Brw_DB_RemoveCrsFiles (long CrsCod)
|
||||
{
|
||||
char SubqueryGrp[256];
|
||||
char SubqueryPrj[128];
|
||||
|
|
|
@ -185,10 +185,10 @@ void Brw_GetSelectedUsrsAndShowWorks (void);
|
|||
void Brw_ShowFileBrowserOrWorks (void);
|
||||
void Brw_ShowAgainFileBrowserOrWorks (void);
|
||||
|
||||
void Brw_RemoveInsFilesFromDB (long InsCod);
|
||||
void Brw_RemoveCtrFilesFromDB (long CtrCod);
|
||||
void Brw_RemoveDegFilesFromDB (long DegCod);
|
||||
void Brw_RemoveCrsFilesFromDB (long CrsCod);
|
||||
void Brw_DB_RemoveInsFiles (long InsCod);
|
||||
void Brw_DB_RemoveCtrFiles (long CtrCod);
|
||||
void Brw_DB_RemoveDegFiles (long DegCod);
|
||||
void Brw_DB_RemoveCrsFiles (long CrsCod);
|
||||
void Brw_RemoveGrpFilesFromDB (long GrpCod);
|
||||
void Brw_RemovePrjFilesFromDB (long PrjCod);
|
||||
void Brw_RemoveSomeInfoAboutCrsUsrFilesFromDB (long UsrCod,long CrsCod);
|
||||
|
|
33
swad_group.c
33
swad_group.c
|
@ -5147,3 +5147,36 @@ Grp_WhichGroups_t Grp_GetParamWhichGroups (void)
|
|||
|
||||
return Gbl.Crs.Grps.WhichGrps;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Remove groups in a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Grp_DB_RemoveCrsGrps (long CrsCod)
|
||||
{
|
||||
/***** Remove all the users in groups in the course *****/
|
||||
DB_QueryDELETE ("can not remove users from groups of a course",
|
||||
"DELETE FROM grp_users"
|
||||
" USING grp_types,"
|
||||
"grp_groups,"
|
||||
"grp_users"
|
||||
" WHERE grp_types.CrsCod=%ld"
|
||||
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod"
|
||||
" AND grp_groups.GrpCod=grp_users.GrpCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove all the groups in the course *****/
|
||||
DB_QueryDELETE ("can not remove groups of a course",
|
||||
"DELETE FROM grp_groups"
|
||||
" USING grp_types,"
|
||||
"grp_groups"
|
||||
" WHERE grp_types.CrsCod=%ld"
|
||||
" AND grp_types.GrpTypCod=grp_groups.GrpTypCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove all the group types in the course *****/
|
||||
DB_QueryDELETE ("can not remove types of group of a course",
|
||||
"DELETE FROM grp_types"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
|
|
@ -242,4 +242,6 @@ void Grp_ShowFormToSelWhichGrps (Act_Action_t Action,
|
|||
void (*FuncParams) (void *Args),void *Args);
|
||||
Grp_WhichGroups_t Grp_GetParamWhichGroups (void);
|
||||
|
||||
void Grp_DB_RemoveCrsGrps (long CrsCod);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1372,7 +1372,7 @@ void Ins_RemoveInstitution (void)
|
|||
Svy_RemoveSurveys (Hie_Lvl_INS,Ins_EditingIns->InsCod);
|
||||
|
||||
/***** Remove information related to files in institution *****/
|
||||
Brw_RemoveInsFilesFromDB (Ins_EditingIns->InsCod);
|
||||
Brw_DB_RemoveInsFiles (Ins_EditingIns->InsCod);
|
||||
|
||||
/***** Remove directories of the institution *****/
|
||||
snprintf (PathIns,sizeof (PathIns),"%s/%02u/%u",
|
||||
|
|
|
@ -1087,3 +1087,30 @@ static long Not_GetParamNotCod (void)
|
|||
/***** Get notice code *****/
|
||||
return Par_GetParToLong ("NotCod");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Remove notices in a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Not_DB_RemoveCrsNotices (long CrsCod)
|
||||
{
|
||||
/***** Copy all notices from the course to table of deleted notices *****/
|
||||
DB_QueryINSERT ("can not remove notices in a course",
|
||||
"INSERT INTO not_deleted"
|
||||
" (NotCod,CrsCod,UsrCod,CreatTime,Content,NumNotif)"
|
||||
" SELECT NotCod,"
|
||||
"CrsCod,"
|
||||
"UsrCod,"
|
||||
"CreatTime,"
|
||||
"Content,"
|
||||
"NumNotif"
|
||||
" FROM not_notices"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove all notices from the course *****/
|
||||
DB_QueryDELETE ("can not remove notices in a course",
|
||||
"DELETE FROM not_notices"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
|
|
@ -77,4 +77,6 @@ unsigned Not_GetNumNoticesDeleted (Hie_Lvl_Level_t Scope,unsigned *NumNotif);
|
|||
|
||||
void Not_PutHiddenParamNotCod (long NotCod);
|
||||
|
||||
void Not_DB_RemoveCrsNotices (long CrsCod);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -4236,3 +4236,30 @@ void Rec_UpdateMyOfficePhone (void)
|
|||
/***** Show form again *****/
|
||||
Rec_ShowMySharedRecordAndMore ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove content of course record cards ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Rec_DB_RemoveCrsRecordContents (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove content of cards in a course",
|
||||
"DELETE FROM crs_records"
|
||||
" USING crs_record_fields,"
|
||||
"crs_records"
|
||||
" WHERE crs_record_fields.CrsCod=%ld"
|
||||
" AND crs_record_fields.FieldCod=crs_records.FieldCod",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Remove definition of fields in course record cards *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Rec_DB_RemoveCrsRecordFields (long CrsCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove fields of cards in a course",
|
||||
"DELETE FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
|
|
@ -180,4 +180,7 @@ void Rec_UpdateMyDepartment (void);
|
|||
void Rec_UpdateMyOffice (void);
|
||||
void Rec_UpdateMyOfficePhone (void);
|
||||
|
||||
void Rec_DB_RemoveCrsRecordContents (long CrsCod);
|
||||
void Rec_DB_RemoveCrsRecordFields (long CrsCod);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue