2019-12-29 12:39:00 +01:00
|
|
|
|
// swad_course.h: edition of courses
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_CRS
|
|
|
|
|
#define _SWAD_CRS
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
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 <mysql/mysql.h> // To access MySQL databases
|
2015-10-16 02:24:29 +02:00
|
|
|
|
#include <stdbool.h> // For boolean type
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-11 22:57:09 +01:00
|
|
|
|
#include "swad_constant.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_degree.h"
|
2021-02-11 22:57:09 +01:00
|
|
|
|
#include "swad_hierarchy_level.h"
|
2016-06-16 11:28:20 +02:00
|
|
|
|
#include "swad_user.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public constants ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define Crs_MAX_COURSES_PER_USR 100 // Used in list of my courses and list of distinct courses in sent or received messages
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD (16 - 1) // 15
|
|
|
|
|
#define Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD ((Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 255
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#define Crs_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 6
|
|
|
|
|
#define Crs_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 12
|
|
|
|
|
#define Crs_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 60
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Public types ********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Crs_STATUS_BIT_PENDING = (1 << 0), // Course is requested, but not yet activated
|
|
|
|
|
Crs_STATUS_BIT_REMOVED = (1 << 1), // Course has been removed
|
|
|
|
|
} Crs_Status_Bits_t;
|
2017-01-29 12:42:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
typedef unsigned Crs_Status_t;
|
2017-01-29 21:41:08 +01:00
|
|
|
|
#define Crs_MAX_STATUS ((Crs_Status_t) 3)
|
|
|
|
|
#define Crs_WRONG_STATUS ((Crs_Status_t) (Crs_MAX_STATUS + 1))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#define Crs_NUM_STATUS_TXT 4
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Crs_STATUS_UNKNOWN = 0, // Other
|
|
|
|
|
Crs_STATUS_ACTIVE = 1, // 00 (Status == 0)
|
|
|
|
|
Crs_STATUS_PENDING = 2, // 01 (Status == Crs_STATUS_BIT_PENDING)
|
|
|
|
|
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;
|
|
|
|
|
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Crs_Course
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long CrsCod;
|
2017-03-07 11:03:05 +01:00
|
|
|
|
char InstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1]; // Institutional code of the course
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long DegCod;
|
2017-03-10 23:19:08 +01:00
|
|
|
|
unsigned Year; // Year: 0 (optatives), 1, 2, 3...
|
2019-01-15 01:34:37 +01:00
|
|
|
|
unsigned Status; // Course status
|
2017-03-10 23:19:08 +01:00
|
|
|
|
long RequesterUsrCod; // User code of the person who requested the creation of this course
|
2021-02-11 22:57:09 +01:00
|
|
|
|
char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]; // Short name of course
|
|
|
|
|
char FullName[Cns_HIERARCHY_MAX_BYTES_FULL_NAME + 1]; // Full name of course
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
2020-01-08 14:04:25 +01:00
|
|
|
|
struct ListCourses
|
|
|
|
|
{
|
|
|
|
|
unsigned Num; // Number of courses
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Crs_Course *Lst; // List of courses
|
2020-01-08 14:04:25 +01:00
|
|
|
|
};
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Crs_ShowIntroduction (void);
|
|
|
|
|
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Crs_GetCachedNumCrssInSys (void);
|
|
|
|
|
|
2020-01-07 15:11:48 +01:00
|
|
|
|
void Crs_FlushCacheNumCrssInCty (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned Crs_GetNumCrssInCty (long CtyCod);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Crs_GetCachedNumCrssInCty (long CtyCod);
|
|
|
|
|
|
2020-01-06 18:43:48 +01:00
|
|
|
|
void Crs_FlushCacheNumCrssInIns (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned Crs_GetNumCrssInIns (long InsCod);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Crs_GetCachedNumCrssInIns (long InsCod);
|
|
|
|
|
|
2020-01-05 01:46:45 +01:00
|
|
|
|
void Crs_FlushCacheNumCrssInCtr (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned Crs_GetNumCrssInCtr (long CtrCod);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Crs_GetCachedNumCrssInCtr (long CtrCod);
|
|
|
|
|
|
2020-01-05 12:52:03 +01:00
|
|
|
|
void Crs_FlushCacheNumCrssInDeg (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned Crs_GetNumCrssInDeg (long DegCod);
|
2020-05-03 20:58:03 +02:00
|
|
|
|
unsigned Crs_GetCachedNumCrssInDeg (long DegCod);
|
|
|
|
|
|
|
|
|
|
unsigned Crs_GetCachedNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
2021-02-11 22:57:09 +01:00
|
|
|
|
Hie_Lvl_Level_t Scope,long Cod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-07-25 20:20:07 +02:00
|
|
|
|
void Crs_WriteSelectorOfCourse (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Crs_ShowCrssOfCurrentDeg (void);
|
2019-04-07 12:17:10 +02:00
|
|
|
|
void Crs_FreeListCoursesInCurrentDegree (void);
|
2018-10-09 17:56:18 +02:00
|
|
|
|
void Crs_WriteSelectorMyCoursesInBreadcrumb (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-30 12:44:53 +02:00
|
|
|
|
void Crs_EditCourses (void);
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Crs_ReceiveFormReqCrs (void);
|
|
|
|
|
void Crs_ReceiveFormNewCrs (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
void Crs_RemoveCourse (void);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Crs_RemoveCourseCompletely (long CrsCod);
|
|
|
|
|
void Crs_ChangeInsCrsCod (void);
|
|
|
|
|
void Crs_ChangeCrsYear (void);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
void Crs_UpdateCrsYear (struct Crs_Course *Crs,unsigned NewYear);
|
|
|
|
|
void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstitutionalCrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Crs_RenameCourseShort (void);
|
|
|
|
|
void Crs_RenameCourseFull (void);
|
2021-02-11 00:58:53 +01:00
|
|
|
|
void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName);
|
2019-12-29 14:20:17 +01:00
|
|
|
|
bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod,
|
|
|
|
|
long DegCod,unsigned Year);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Crs_ChangeCrsStatus (void);
|
|
|
|
|
void Crs_ContEditAfterChgCrs (void);
|
|
|
|
|
|
2018-10-09 17:56:18 +02:00
|
|
|
|
void Crs_PutIconToSelectMyCoursesInBreadcrumb (void);
|
2020-04-08 13:40:21 +02:00
|
|
|
|
void Crs_PutIconToSelectMyCourses (__attribute__((unused)) void *Args);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Crs_PutParamCrsCod (long CrsCod);
|
|
|
|
|
|
|
|
|
|
void Crs_ReqSelectOneOfMyCourses (void);
|
|
|
|
|
|
2016-06-16 11:28:20 +02:00
|
|
|
|
void Crs_GetAndWriteCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2018-10-30 14:47:31 +01:00
|
|
|
|
void Crs_ListCrssFound (MYSQL_RES **mysql_res,unsigned NumCrss);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
void Crs_UpdateCrsLast (void);
|
2017-03-27 01:14:38 +02:00
|
|
|
|
|
|
|
|
|
void Crs_PutLinkToRemoveOldCrss (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Crs_AskRemoveOldCrss (void);
|
|
|
|
|
void Crs_RemoveOldCrss (void);
|
|
|
|
|
|
|
|
|
|
#endif
|