Version 16.155.5

This commit is contained in:
Antonio Cañas Vargas 2017-03-11 00:47:23 +01:00
parent 0056a531e2
commit 58cfa4c66c
5 changed files with 122 additions and 84 deletions

View File

@ -266,7 +266,7 @@ CREATE TABLE IF NOT EXISTS courses (
CREATE TABLE IF NOT EXISTS crs_grp ( CREATE TABLE IF NOT EXISTS crs_grp (
GrpCod INT NOT NULL AUTO_INCREMENT, GrpCod INT NOT NULL AUTO_INCREMENT,
GrpTypCod INT NOT NULL, GrpTypCod INT NOT NULL,
GrpName VARCHAR(255) NOT NULL, GrpName VARCHAR(2047) NOT NULL,
MaxStudents INT NOT NULL, MaxStudents INT NOT NULL,
Open ENUM('N','Y') NOT NULL DEFAULT 'N', Open ENUM('N','Y') NOT NULL DEFAULT 'N',
FileZones ENUM('N','Y') NOT NULL DEFAULT 'N', FileZones ENUM('N','Y') NOT NULL DEFAULT 'N',
@ -278,7 +278,7 @@ CREATE TABLE IF NOT EXISTS crs_grp (
CREATE TABLE IF NOT EXISTS crs_grp_types ( CREATE TABLE IF NOT EXISTS crs_grp_types (
GrpTypCod INT NOT NULL AUTO_INCREMENT, GrpTypCod INT NOT NULL AUTO_INCREMENT,
CrsCod INT NOT NULL DEFAULT -1, CrsCod INT NOT NULL DEFAULT -1,
GrpTypName VARCHAR(255) NOT NULL, GrpTypName VARCHAR(2047) NOT NULL,
Mandatory ENUM('N','Y') NOT NULL, Mandatory ENUM('N','Y') NOT NULL,
Multiple ENUM('N','Y') NOT NULL, Multiple ENUM('N','Y') NOT NULL,
MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N', MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N',

View File

@ -207,13 +207,18 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.155.4 (2017-03-10)" #define Log_PLATFORM_VERSION "SWAD 16.155.5 (2017-03-11)"
#define CSS_FILE "swad16.147.css" #define CSS_FILE "swad16.147.css"
#define JS_FILE "swad16.144.js" #define JS_FILE "swad16.144.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.155.5: Mar 11, 2017 Adjusting size of database fields. (216663 lines)
2 changes necessary in database:
ALTER TABLE crs_grp CHANGE COLUMN GrpName GrpName VARCHAR(2047) NOT NULL;
ALTER TABLE crs_grp_types CHANGE COLUMN GrpTypName GrpTypName VARCHAR(2047) NOT NULL;
Version 16.155.4: Mar 10, 2017 Adjusting size of database fields. (216626 lines) Version 16.155.4: Mar 10, 2017 Adjusting size of database fields. (216626 lines)
2 changes necessary in database: 2 changes necessary in database:
ALTER TABLE courses CHANGE COLUMN ShortName ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL; ALTER TABLE courses CHANGE COLUMN ShortName ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL;

View File

@ -588,20 +588,20 @@ mysql> DESCRIBE countries;
/***** Table courses *****/ /***** Table courses *****/
/* /*
mysql> DESCRIBE courses; mysql> DESCRIBE courses;
+-----------------+--------------+------+-----+---------+----------------+ +-----------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+ +-----------------+---------------+------+-----+---------+----------------+
| CrsCod | int(11) | NO | PRI | NULL | auto_increment | | CrsCod | int(11) | NO | PRI | NULL | auto_increment |
| DegCod | int(11) | NO | MUL | -1 | | | DegCod | int(11) | NO | MUL | -1 | |
| Year | tinyint(4) | NO | | 0 | | | Year | tinyint(4) | NO | | 0 | |
| InsCrsCod | char(7) | NO | | NULL | | | InsCrsCod | char(7) | NO | | NULL | |
| Status | tinyint(4) | NO | MUL | 0 | | | Status | tinyint(4) | NO | MUL | 0 | |
| RequesterUsrCod | int(11) | NO | | -1 | | | RequesterUsrCod | int(11) | NO | | -1 | |
| ShortName | varchar(32) | NO | | NULL | | | ShortName | varchar(511) | NO | | NULL | |
| FullName | varchar(127) | NO | | NULL | | | FullName | varchar(2047) | NO | | NULL | |
| NumIndicators | int(11) | NO | | -1 | | | NumIndicators | int(11) | NO | | -1 | |
+-----------------+--------------+------+-----+---------+----------------+ +-----------------+---------------+------+-----+---------+----------------+
9 rows in set (0.00 sec) 9 rows in set (0,00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS courses (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS courses ("
"CrsCod INT NOT NULL AUTO_INCREMENT," "CrsCod INT NOT NULL AUTO_INCREMENT,"
@ -625,22 +625,22 @@ mysql> DESCRIBE crs_grp;
+-------------+---------------+------+-----+---------+----------------+ +-------------+---------------+------+-----+---------+----------------+
| GrpCod | int(11) | NO | PRI | NULL | auto_increment | | GrpCod | int(11) | NO | PRI | NULL | auto_increment |
| GrpTypCod | int(11) | NO | MUL | NULL | | | GrpTypCod | int(11) | NO | MUL | NULL | |
| GrpName | varchar(255) | NO | | NULL | | | GrpName | varchar(2047) | NO | | NULL | |
| MaxStudents | int(11) | NO | | NULL | | | MaxStudents | int(11) | NO | | NULL | |
| Open | enum('N','Y') | NO | | N | | | Open | enum('N','Y') | NO | | N | |
| FileZones | enum('N','Y') | NO | | N | | | FileZones | enum('N','Y') | NO | | N | |
+-------------+---------------+------+-----+---------+----------------+ +-------------+---------------+------+-----+---------+----------------+
6 rows in set (0.01 sec) 6 rows in set (0,00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_grp (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_grp ("
"GrpCod INT NOT NULL AUTO_INCREMENT," "GrpCod INT NOT NULL AUTO_INCREMENT,"
"GrpTypCod INT NOT NULL," "GrpTypCod INT NOT NULL,"
"GrpName VARCHAR(255) NOT NULL," "GrpName VARCHAR(2047) NOT NULL," // Grp_MAX_BYTES_GROUP_NAME
"MaxStudents INT NOT NULL," "MaxStudents INT NOT NULL,"
"Open ENUM('N','Y') NOT NULL DEFAULT 'N'," "Open ENUM('N','Y') NOT NULL DEFAULT 'N',"
"FileZones ENUM('N','Y') NOT NULL DEFAULT 'N'," "FileZones ENUM('N','Y') NOT NULL DEFAULT 'N',"
"UNIQUE INDEX(GrpCod)," "UNIQUE INDEX(GrpCod),"
"INDEX(GrpTypCod))"); "INDEX(GrpTypCod))");
/***** Table crs_grp_types *****/ /***** Table crs_grp_types *****/
/* /*
@ -650,24 +650,24 @@ mysql> DESCRIBE crs_grp_types;
+--------------+---------------+------+-----+---------+----------------+ +--------------+---------------+------+-----+---------+----------------+
| GrpTypCod | int(11) | NO | PRI | NULL | auto_increment | | GrpTypCod | int(11) | NO | PRI | NULL | auto_increment |
| CrsCod | int(11) | NO | MUL | -1 | | | CrsCod | int(11) | NO | MUL | -1 | |
| GrpTypName | varchar(255) | NO | | NULL | | | GrpTypName | varchar(2047) | NO | | NULL | |
| Mandatory | enum('N','Y') | NO | | NULL | | | Mandatory | enum('N','Y') | NO | | NULL | |
| Multiple | enum('N','Y') | NO | | NULL | | | Multiple | enum('N','Y') | NO | | NULL | |
| MustBeOpened | enum('N','Y') | NO | | N | | | MustBeOpened | enum('N','Y') | NO | | N | |
| OpenTime | datetime | NO | | NULL | | | OpenTime | datetime | NO | | NULL | |
+--------------+---------------+------+-----+---------+----------------+ +--------------+---------------+------+-----+---------+----------------+
7 rows in set (0.01 sec) 7 rows in set (0,00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_grp_types (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_grp_types ("
"GrpTypCod INT NOT NULL AUTO_INCREMENT," "GrpTypCod INT NOT NULL AUTO_INCREMENT,"
"CrsCod INT NOT NULL DEFAULT -1," "CrsCod INT NOT NULL DEFAULT -1,"
"GrpTypName VARCHAR(255) NOT NULL," "GrpTypName VARCHAR(2047) NOT NULL," // Grp_MAX_BYTES_GROUP_TYPE_NAME
"Mandatory ENUM('N','Y') NOT NULL," "Mandatory ENUM('N','Y') NOT NULL,"
"Multiple ENUM('N','Y') NOT NULL," "Multiple ENUM('N','Y') NOT NULL,"
"MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N'," "MustBeOpened ENUM('N','Y') NOT NULL DEFAULT 'N',"
"OpenTime DATETIME NOT NULL," "OpenTime DATETIME NOT NULL,"
"UNIQUE INDEX(GrpTypCod)," "UNIQUE INDEX(GrpTypCod),"
"INDEX(CrsCod))"); "INDEX(CrsCod))");
/***** Table crs_grp_usr *****/ /***** Table crs_grp_usr *****/
/* /*

View File

@ -999,13 +999,14 @@ unsigned Grp_RemoveUsrFromGroups (struct UsrData *UsrDat,struct ListCodGrps *Lst
void Grp_RemUsrFromAllGrpsInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose) void Grp_RemUsrFromAllGrpsInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose)
{ {
extern const char *Txt_THE_USER_X_has_been_removed_from_all_groups_of_the_course_Y; extern const char *Txt_THE_USER_X_has_been_removed_from_all_groups_of_the_course_Y;
char Query[1024]; char Query[512];
/***** Remove user from all the groups of the course *****/ /***** Remove user from all the groups of the course *****/
sprintf (Query,"DELETE FROM crs_grp_usr" sprintf (Query,"DELETE FROM crs_grp_usr"
" WHERE UsrCod='%ld' AND GrpCod IN" " WHERE UsrCod='%ld' AND GrpCod IN"
" (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp" " (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod='%ld' AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)", " WHERE crs_grp_types.CrsCod='%ld'"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)",
UsrDat->UsrCod,Crs->CrsCod); UsrDat->UsrCod,Crs->CrsCod);
DB_QueryDELETE (Query,"can not remove a user from all groups of a course"); DB_QueryDELETE (Query,"can not remove a user from all groups of a course");
@ -1025,7 +1026,7 @@ void Grp_RemUsrFromAllGrpsInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_Q
void Grp_RemUsrFromAllGrps (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrVerbose) void Grp_RemUsrFromAllGrps (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrVerbose)
{ {
extern const char *Txt_THE_USER_X_has_been_removed_from_all_groups_in_all_courses; extern const char *Txt_THE_USER_X_has_been_removed_from_all_groups_in_all_courses;
char Query[512]; char Query[128];
/***** Remove user from all groups *****/ /***** Remove user from all groups *****/
sprintf (Query,"DELETE FROM crs_grp_usr WHERE UsrCod='%ld'", sprintf (Query,"DELETE FROM crs_grp_usr WHERE UsrCod='%ld'",
@ -1047,11 +1048,11 @@ void Grp_RemUsrFromAllGrps (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrV
static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod) static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
{ {
char Query[512]; char Query[256];
/***** Remove user from group *****/ /***** Remove user from group *****/
sprintf (Query,"DELETE FROM crs_grp_usr" sprintf (Query,"DELETE FROM crs_grp_usr"
" WHERE GrpCod='%ld' AND UsrCod='%ld'", " WHERE GrpCod='%ld' AND UsrCod='%ld'",
GrpCod,UsrCod); GrpCod,UsrCod);
DB_QueryDELETE (Query,"can not remove a user from a group"); DB_QueryDELETE (Query,"can not remove a user from a group");
} }
@ -1062,7 +1063,7 @@ static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod)
static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod) static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod)
{ {
char Query[512]; char Query[256];
/***** Register in group *****/ /***** Register in group *****/
sprintf (Query,"INSERT INTO crs_grp_usr (GrpCod,UsrCod)" sprintf (Query,"INSERT INTO crs_grp_usr (GrpCod,UsrCod)"
@ -1335,7 +1336,7 @@ static void Grp_ListGroupsForEdition (void)
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"); fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
Act_FormStart (ActChgGrpTyp); Act_FormStart (ActChgGrpTyp);
Grp_PutParamGrpCod (Grp->GrpCod); Grp_PutParamGrpCod (Grp->GrpCod);
fprintf (Gbl.F.Out,"<select name=\"GrpTypCod\"" fprintf (Gbl.F.Out,"<select name=\"GrpTypCod\" style=\"width:150px;\""
" onchange=\"document.getElementById('%s').submit();\">", " onchange=\"document.getElementById('%s').submit();\">",
Gbl.Form.Id); Gbl.Form.Id);
for (NumTipGrpAux = 0; for (NumTipGrpAux = 0;
@ -2207,7 +2208,7 @@ static void Grp_PutFormToCreateGroup (void)
/***** Group type *****/ /***** Group type *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
"<select name=\"GrpTypCod\">"); "<select name=\"GrpTypCod\" style=\"width:150px;\">");
for (NumGrpTyp = 0; for (NumGrpTyp = 0;
NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num; NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num;
NumGrpTyp++) NumGrpTyp++)
@ -2541,7 +2542,7 @@ unsigned Grp_CountNumGrpsInCurrentCrs (void)
static unsigned Grp_CountNumGrpsInThisCrsOfType (long GrpTypCod) static unsigned Grp_CountNumGrpsInThisCrsOfType (long GrpTypCod)
{ {
char Query[512]; char Query[128];
/***** Get number of groups of a type from database *****/ /***** Get number of groups of a type from database *****/
sprintf (Query,"SELECT COUNT(*) FROM crs_grp WHERE GrpTypCod='%ld'", sprintf (Query,"SELECT COUNT(*) FROM crs_grp WHERE GrpTypCod='%ld'",
@ -2608,7 +2609,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
static bool Grp_GetMultipleEnrollmentOfAGroupType (long GrpTypCod) static bool Grp_GetMultipleEnrollmentOfAGroupType (long GrpTypCod)
{ {
char Query[512]; char Query[128];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
bool MultipleEnrollment; bool MultipleEnrollment;
@ -2709,7 +2710,7 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
static long Grp_GetTypeOfGroupOfAGroup (long GrpCod) static long Grp_GetTypeOfGroupOfAGroup (long GrpCod)
{ {
char Query[256]; char Query[128];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
long GrpTypCod; long GrpTypCod;
@ -2797,9 +2798,12 @@ static unsigned Grp_CountNumStdsInNoGrpsOfType (long GrpTypCod)
/***** Get number of students not belonging to groups of a type from database ******/ /***** Get number of students not belonging to groups of a type from database ******/
sprintf (Query,"SELECT COUNT(UsrCod) FROM crs_usr" sprintf (Query,"SELECT COUNT(UsrCod) FROM crs_usr"
" WHERE CrsCod='%ld' AND Role='%u' AND UsrCod NOT IN" " WHERE CrsCod='%ld' AND Role='%u'"
" (SELECT DISTINCT crs_grp_usr.UsrCod FROM crs_grp,crs_grp_usr" " AND UsrCod NOT IN"
" WHERE crs_grp.GrpTypCod='%ld' AND crs_grp.GrpCod=crs_grp_usr.GrpCod)", " (SELECT DISTINCT crs_grp_usr.UsrCod"
" FROM crs_grp,crs_grp_usr"
" WHERE crs_grp.GrpTypCod='%ld'"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod)",
Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Rol_STUDENT,GrpTypCod); Gbl.CurrentCrs.Crs.CrsCod,(unsigned) Rol_STUDENT,GrpTypCod);
DB_QuerySELECT (Query,&mysql_res,"can not get the number of students not belonging to groups of a type"); DB_QuerySELECT (Query,&mysql_res,"can not get the number of students not belonging to groups of a type");
@ -2821,15 +2825,17 @@ static unsigned Grp_CountNumStdsInNoGrpsOfType (long GrpTypCod)
static long Grp_GetFirstCodGrpStdBelongsTo (long GrpTypCod,long UsrCod) static long Grp_GetFirstCodGrpStdBelongsTo (long GrpTypCod,long UsrCod)
{ {
char Query[1024]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
long CodGrpIBelong; long CodGrpIBelong;
/***** Get a group which a user belong to from database *****/ /***** Get a group which a user belong to from database *****/
sprintf (Query,"SELECT crs_grp.GrpCod FROM crs_grp,crs_grp_usr WHERE crs_grp.GrpTypCod='%ld'" sprintf (Query,"SELECT crs_grp.GrpCod FROM crs_grp,crs_grp_usr"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod AND crs_grp_usr.UsrCod='%ld'", " WHERE crs_grp.GrpTypCod='%ld'"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod='%ld'",
GrpTypCod,UsrCod); GrpTypCod,UsrCod);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get the group which a user belongs to"); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get the group which a user belongs to");
@ -2880,17 +2886,28 @@ unsigned Grp_NumGrpTypesMandatIDontBelong (void)
/***** Get the number of types of groups with mandatory enrollment which I don't belong to, from database *****/ /***** Get the number of types of groups with mandatory enrollment which I don't belong to, from database *****/
sprintf (Query,"SELECT COUNT(DISTINCT GrpTypCod) FROM" sprintf (Query,"SELECT COUNT(DISTINCT GrpTypCod) FROM"
" (SELECT crs_grp_types.GrpTypCod AS GrpTypCod,COUNT(*) AS NumStudents,crs_grp.MaxStudents as MaxStudents" " (SELECT crs_grp_types.GrpTypCod AS GrpTypCod,"
"COUNT(*) AS NumStudents,"
"crs_grp.MaxStudents as MaxStudents"
" FROM crs_grp_types,crs_grp,crs_grp_usr,crs_usr" " FROM crs_grp_types,crs_grp,crs_grp_usr,crs_usr"
" WHERE crs_grp_types.CrsCod='%ld' AND crs_grp_types.Mandatory='Y'" " WHERE crs_grp_types.CrsCod='%ld'"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod AND crs_grp.Open='Y'" " AND crs_grp_types.Mandatory='Y'"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.Open='Y'"
" AND crs_grp_types.CrsCod=crs_usr.CrsCod" " AND crs_grp_types.CrsCod=crs_usr.CrsCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod AND crs_grp_usr.UsrCod=crs_usr.UsrCod AND crs_usr.Role='%u'" " AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" GROUP BY crs_grp.GrpCod HAVING NumStudents<MaxStudents) AS grp_types_open_not_full" " AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
" AND crs_usr.Role='%u'"
" GROUP BY crs_grp.GrpCod"
" HAVING NumStudents<MaxStudents) AS grp_types_open_not_full"
" WHERE GrpTypCod NOT IN" " WHERE GrpTypCod NOT IN"
" (SELECT DISTINCT crs_grp_types.GrpTypCod FROM crs_grp_types,crs_grp,crs_grp_usr" " (SELECT DISTINCT crs_grp_types.GrpTypCod"
" WHERE crs_grp_types.CrsCod='%ld' AND crs_grp_types.Mandatory='Y' AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod" " FROM crs_grp_types,crs_grp,crs_grp_usr"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod AND crs_grp_usr.UsrCod='%ld')", " WHERE crs_grp_types.CrsCod='%ld'"
" AND crs_grp_types.Mandatory='Y'"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod='%ld')",
Gbl.CurrentCrs.Crs.CrsCod, Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) Rol_STUDENT, (unsigned) Rol_STUDENT,
Gbl.CurrentCrs.Crs.CrsCod, Gbl.CurrentCrs.Crs.CrsCod,
@ -2912,12 +2929,19 @@ static bool Grp_GetIfGrpIsAvailable (long GrpTypCod)
/***** Get the number of types of group (0 or 1) of a type /***** Get the number of types of group (0 or 1) of a type
with one or more open groups with vacants, from database *****/ with one or more open groups with vacants, from database *****/
sprintf (Query,"SELECT COUNT(DISTINCT GrpTypCod) FROM" sprintf (Query,"SELECT COUNT(DISTINCT GrpTypCod) FROM"
" (SELECT crs_grp_types.GrpTypCod AS GrpTypCod,COUNT(*) AS NumStudents,crs_grp.MaxStudents as MaxStudents" " (SELECT crs_grp_types.GrpTypCod AS GrpTypCod,"
"COUNT(*) AS NumStudents,"
"crs_grp.MaxStudents as MaxStudents"
" FROM crs_grp_types,crs_grp,crs_grp_usr,crs_usr" " FROM crs_grp_types,crs_grp,crs_grp_usr,crs_usr"
" WHERE crs_grp_types.GrpTypCod='%ld' AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod" " WHERE crs_grp_types.GrpTypCod='%ld'"
" AND crs_grp.Open='Y' AND crs_grp_types.CrsCod=crs_usr.CrsCod" " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod AND crs_grp_usr.UsrCod=crs_usr.UsrCod AND crs_usr.Role='%u'" " AND crs_grp.Open='Y'"
" GROUP BY crs_grp.GrpCod HAVING NumStudents<MaxStudents) AS available_grp_types", " AND crs_grp_types.CrsCod=crs_usr.CrsCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod=crs_usr.UsrCod"
" AND crs_usr.Role='%u'"
" GROUP BY crs_grp.GrpCod"
" HAVING NumStudents<MaxStudents) AS available_grp_types",
GrpTypCod,(unsigned) Rol_STUDENT); GrpTypCod,(unsigned) Rol_STUDENT);
NumGrpTypes = DB_QueryCOUNT (Query,"can not check if a type of group has available groups"); NumGrpTypes = DB_QueryCOUNT (Query,"can not check if a type of group has available groups");
@ -2940,19 +2964,27 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
/***** Get groups which a user belong to from database *****/ /***** Get groups which a user belong to from database *****/
if (CrsCod < 0) // Query the groups from all the user's courses if (CrsCod < 0) // Query the groups from all the user's courses
sprintf (Query,"SELECT GrpCod FROM crs_grp_usr" sprintf (Query,"SELECT GrpCod"
" FROM crs_grp_usr"
" WHERE UsrCod='%ld'", // Groups will be unordered " WHERE UsrCod='%ld'", // Groups will be unordered
UsrCod); UsrCod);
else if (GrpTypCod < 0) // Query the groups of any type in the course else if (GrpTypCod < 0) // Query the groups of any type in the course
sprintf (Query,"SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp,crs_grp_usr" sprintf (Query,"SELECT crs_grp.GrpCod"
" WHERE crs_grp_types.CrsCod='%ld' AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod" " FROM crs_grp_types,crs_grp,crs_grp_usr"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod AND crs_grp_usr.UsrCod='%ld'" " WHERE crs_grp_types.CrsCod='%ld'"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod='%ld'"
" ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName", " ORDER BY crs_grp_types.GrpTypName,crs_grp.GrpName",
Gbl.CurrentCrs.Crs.CrsCod,UsrCod); Gbl.CurrentCrs.Crs.CrsCod,UsrCod);
else // Query only the groups of specified type in the course else // Query only the groups of specified type in the course
sprintf (Query,"SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp,crs_grp_usr" sprintf (Query,"SELECT crs_grp.GrpCod"
" WHERE crs_grp_types.CrsCod='%ld' AND crs_grp_types.GrpTypCod='%ld' AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod" " FROM crs_grp_types,crs_grp,crs_grp_usr"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod AND crs_grp_usr.UsrCod='%ld'" " WHERE crs_grp_types.CrsCod='%ld'"
" AND crs_grp_types.GrpTypCod='%ld'"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.GrpCod=crs_grp_usr.GrpCod"
" AND crs_grp_usr.UsrCod='%ld'"
" ORDER BY crs_grp.GrpName", " ORDER BY crs_grp.GrpName",
Gbl.CurrentCrs.Crs.CrsCod,GrpTypCod,UsrCod); Gbl.CurrentCrs.Crs.CrsCod,GrpTypCod,UsrCod);
LstGrps->NumGrps = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get the groups which a user belongs to"); LstGrps->NumGrps = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get the groups which a user belongs to");
@ -2991,7 +3023,8 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
unsigned NumGrp; unsigned NumGrp;
/***** Get groups which I belong to from database *****/ /***** Get groups which I belong to from database *****/
sprintf (Query,"SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp,crs_grp_usr" sprintf (Query,"SELECT crs_grp.GrpCod"
" FROM crs_grp_types,crs_grp,crs_grp_usr"
" WHERE crs_grp_types.CrsCod='%ld'" " WHERE crs_grp_types.CrsCod='%ld'"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod" " AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND crs_grp.FileZones='Y'" " AND crs_grp.FileZones='Y'"
@ -3196,11 +3229,12 @@ void Grp_RecFormNewGrp (void)
static bool Grp_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCod) static bool Grp_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCod)
{ {
char Query[512]; char Query[256 + Grp_MAX_BYTES_GROUP_TYPE_NAME];
/***** Get number of group types with a name from database *****/ /***** Get number of group types with a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM crs_grp_types" sprintf (Query,"SELECT COUNT(*) FROM crs_grp_types"
" WHERE CrsCod='%ld' AND GrpTypName='%s' AND GrpTypCod<>'%ld'", " WHERE CrsCod='%ld' AND GrpTypName='%s'"
" AND GrpTypCod<>'%ld'",
Gbl.CurrentCrs.Crs.CrsCod,GrpTypName,GrpTypCod); Gbl.CurrentCrs.Crs.CrsCod,GrpTypName,GrpTypCod);
return (DB_QueryCOUNT (Query,"can not check if the name of type of group already existed") != 0); return (DB_QueryCOUNT (Query,"can not check if the name of type of group already existed") != 0);
} }
@ -3211,7 +3245,7 @@ static bool Grp_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCo
static bool Grp_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long GrpCod) static bool Grp_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long GrpCod)
{ {
char Query[512]; char Query[256 + Grp_MAX_BYTES_GROUP_NAME];
/***** Get number of groups with a type and a name from database *****/ /***** Get number of groups with a type and a name from database *****/
sprintf (Query,"SELECT COUNT(*) FROM crs_grp" sprintf (Query,"SELECT COUNT(*) FROM crs_grp"
@ -3930,7 +3964,7 @@ void Grp_RenameGroupType (void)
extern const char *Txt_The_type_of_group_X_already_exists; extern const char *Txt_The_type_of_group_X_already_exists;
extern const char *Txt_The_type_of_group_X_has_been_renamed_as_Y; extern const char *Txt_The_type_of_group_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_type_of_group_X_has_not_changed; extern const char *Txt_The_name_of_the_type_of_group_X_has_not_changed;
char Query[1024]; char Query[128 + Grp_MAX_BYTES_GROUP_TYPE_NAME];
char NewNameGrpTyp[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1]; char NewNameGrpTyp[Grp_MAX_BYTES_GROUP_TYPE_NAME + 1];
/***** Get parameters from form *****/ /***** Get parameters from form *****/
@ -3966,8 +4000,7 @@ void Grp_RenameGroupType (void)
else else
{ {
/* Update the table changing old name by new name */ /* Update the table changing old name by new name */
sprintf (Query,"UPDATE crs_grp_types" sprintf (Query,"UPDATE crs_grp_types SET GrpTypName='%s'"
" SET GrpTypName='%s'"
" WHERE GrpTypCod='%ld'", " WHERE GrpTypCod='%ld'",
NewNameGrpTyp, NewNameGrpTyp,
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod); Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod);
@ -4004,7 +4037,7 @@ void Grp_RenameGroup (void)
extern const char *Txt_The_group_X_has_been_renamed_as_Y; extern const char *Txt_The_group_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_group_X_has_not_changed; extern const char *Txt_The_name_of_the_group_X_has_not_changed;
struct GroupData GrpDat; struct GroupData GrpDat;
char Query[512]; char Query[128 + Grp_MAX_BYTES_GROUP_NAME];
char NewNameGrp[Grp_MAX_BYTES_GROUP_NAME + 1]; char NewNameGrp[Grp_MAX_BYTES_GROUP_NAME + 1];
/***** Get parameters from form *****/ /***** Get parameters from form *****/

View File

@ -36,7 +36,7 @@
#define Lay_MAX_BYTES_ALERT (16 * 1024 - 1) // Max. size for alert message #define Lay_MAX_BYTES_ALERT (16 * 1024 - 1) // Max. size for alert message
// Important: the size of alert message must be enough large to store the longest message. // Important: the size of alert message must be enough large to store the longest message.
#define Lay_MAX_BYTES_TITLE (1024 - 1) #define Lay_MAX_BYTES_TITLE (4096 - 1)
#define Lay_HIDE_BOTH_COLUMNS 0 // 00 #define Lay_HIDE_BOTH_COLUMNS 0 // 00
#define Lay_SHOW_RIGHT_COLUMN 1 // 01 #define Lay_SHOW_RIGHT_COLUMN 1 // 01