mirror of https://github.com/acanas/swad-core.git
Version 18.27.1
This commit is contained in:
parent
300c651135
commit
68198c046e
|
@ -273,6 +273,7 @@ Centre:
|
|||
NEW. ActRenClaSho Change short name of a classroom
|
||||
NEW. ActRenClaFul Change full name of a classroom
|
||||
NEW. ActChgClaMaxStd Change number of students in a classroom
|
||||
NEW. ActRenClaLoc Change location of a classroom
|
||||
|
||||
148. ActPrnCtrCrs Show print view of the academic calendar
|
||||
149. ActChgCtrCrs1stDay Change first day of week and show academic calendar
|
||||
|
@ -1808,7 +1809,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActRemCla */{1747,-1,TabUnk,ActSeeCla , 0, 0, 0,0x3C6, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_RemoveClassroom ,NULL},
|
||||
/* ActRenClaSho */{1748,-1,TabUnk,ActSeeCla , 0, 0, 0,0x3C6, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_RenameClassroomShort ,NULL},
|
||||
/* ActRenClaFul */{1749,-1,TabUnk,ActSeeCla , 0, 0, 0,0x3C6, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_RenameClassroomFull ,NULL},
|
||||
/* ActChgClaMaxStd */{1750,-1,TabUnk,ActSeeCla , 0, 0, 0,0x3C6, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_ChangeMaxStudents ,NULL},
|
||||
/* ActChgClaMaxStd */{1750,-1,TabUnk,ActSeeCla , 0, 0, 0,0x3C6, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_ChangeCapacity ,NULL},
|
||||
/* ActRenClaLoc */{1751,-1,TabUnk,ActSeeCla , 0, 0, 0,0x3C6, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_ChangeClassroomLocation ,NULL},
|
||||
|
||||
/* ActPrnCalCtr */{1632,-1,TabUnk,ActSeeCalCtr , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Cal_PrintCalendar ,NULL},
|
||||
/* ActChgCalCtr1stDay*/{1633,-1,TabUnk,ActSeeCalCtr , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Cal_ChangeFirstDayOfWeek ,Cal_DrawCalendarCtr ,NULL},
|
||||
|
@ -4955,6 +4957,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
|
|||
ActRenClaSho, // #1748
|
||||
ActRenClaFul, // #1749
|
||||
ActChgClaMaxStd, // #1750
|
||||
ActRenClaLoc, // #1751
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -61,9 +61,9 @@ typedef enum
|
|||
|
||||
typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
|
||||
|
||||
#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 40 + 24 + 115 + 157 + 437 + 165 + 172 + 42 + 14 + 76)
|
||||
#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 41 + 24 + 115 + 157 + 437 + 165 + 172 + 42 + 14 + 76)
|
||||
|
||||
#define Act_MAX_ACTION_COD 1750
|
||||
#define Act_MAX_ACTION_COD 1751
|
||||
|
||||
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
|
||||
|
||||
|
@ -272,9 +272,10 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
|
|||
#define ActRenClaSho (ActChgCalIns1stDay + 36)
|
||||
#define ActRenClaFul (ActChgCalIns1stDay + 37)
|
||||
#define ActChgClaMaxStd (ActChgCalIns1stDay + 38)
|
||||
#define ActRenClaLoc (ActChgCalIns1stDay + 39)
|
||||
|
||||
#define ActPrnCalCtr (ActChgCalIns1stDay + 39)
|
||||
#define ActChgCalCtr1stDay (ActChgCalIns1stDay + 40)
|
||||
#define ActPrnCalCtr (ActChgCalIns1stDay + 40)
|
||||
#define ActChgCalCtr1stDay (ActChgCalIns1stDay + 41)
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************************* Degree tab ********************************/
|
||||
|
|
|
@ -987,7 +987,11 @@ static void Agd_GetListEvents (Agd_AgendaType_t AgendaType)
|
|||
char Past__FutureEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
||||
char PrivatPublicEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
||||
char HiddenVisiblEventsSubQuery[Agd_MAX_BYTES_SUBQUERY];
|
||||
char *OrderBySubQuery;
|
||||
static const char *OrderBySubQuery[Agd_NUM_ORDERS] =
|
||||
{
|
||||
"StartTime,EndTime,Event,Location", // Agd_ORDER_BY_START_DATE
|
||||
"EndTime,StartTime,Event,Location", // Agd_ORDER_BY_END_DATE
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -1086,26 +1090,7 @@ static void Agd_GetListEvents (Agd_AgendaType_t AgendaType)
|
|||
|
||||
if (DoQuery)
|
||||
{
|
||||
/* Build order subquery */
|
||||
switch (Gbl.Agenda.SelectedOrder)
|
||||
{
|
||||
case Agd_ORDER_BY_START_DATE:
|
||||
if (asprintf (&OrderBySubQuery,"StartTime,"
|
||||
"EndTime,"
|
||||
"Event,"
|
||||
"Location") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Agd_ORDER_BY_END_DATE:
|
||||
if (asprintf (&OrderBySubQuery,"EndTime,"
|
||||
"StartTime,"
|
||||
"Event,"
|
||||
"Location") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Build full query */
|
||||
/* Make query */
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get agenda events",
|
||||
"SELECT AgdCod FROM agendas"
|
||||
" WHERE %s%s%s%s"
|
||||
|
@ -1114,10 +1099,9 @@ static void Agd_GetListEvents (Agd_AgendaType_t AgendaType)
|
|||
Past__FutureEventsSubQuery,
|
||||
PrivatPublicEventsSubQuery,
|
||||
HiddenVisiblEventsSubQuery,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Agenda.SelectedOrder]);
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
free ((void *) OrderBySubQuery);
|
||||
/* Free allocated memory for subquery */
|
||||
free ((void *) UsrSubQuery);
|
||||
|
||||
if (NumRows) // Events found...
|
||||
|
|
|
@ -25,10 +25,8 @@
|
|||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <linux/limits.h> // For PATH_MAX
|
||||
#include <linux/stddef.h> // For NULL
|
||||
#include <stdio.h> // For asprintf
|
||||
#include <stdlib.h> // For calloc
|
||||
#include <string.h> // For string functions
|
||||
|
||||
|
@ -624,8 +622,24 @@ static void Asg_PutParams (void)
|
|||
|
||||
void Asg_GetListAssignments (void)
|
||||
{
|
||||
char *HiddenSubQuery;
|
||||
char *OrderBySubQuery;
|
||||
static const char *HiddenSubQuery[Rol_NUM_ROLES] =
|
||||
{
|
||||
" AND Hidden='N'", // Rol_UNK
|
||||
" AND Hidden='N'", // Rol_GST
|
||||
" AND Hidden='N'", // Rol_USR
|
||||
" AND Hidden='N'", // Rol_STD
|
||||
" AND Hidden='N'", // Rol_NET
|
||||
"", // Rol_TCH
|
||||
" AND Hidden='N'", // Rol_DEG_ADM
|
||||
" AND Hidden='N'", // Rol_CTR_ADM
|
||||
" AND Hidden='N'", // Rol_INS_ADM
|
||||
"", // Rol_SYS_ADM
|
||||
};
|
||||
static const char *OrderBySubQuery[Dat_NUM_START_END_TIME] =
|
||||
{
|
||||
"StartTime DESC,EndTime DESC,Title DESC", // Dat_START_TIME
|
||||
"EndTime DESC,StartTime DESC,Title DESC", // Dat_END_TIME
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -635,31 +649,6 @@ void Asg_GetListAssignments (void)
|
|||
Asg_FreeListAssignments ();
|
||||
|
||||
/***** Get list of assignments from database *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
if (asprintf (&HiddenSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
if (asprintf (&HiddenSubQuery," AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
switch (Gbl.Asgs.SelectedOrder)
|
||||
{
|
||||
case Dat_START_TIME:
|
||||
if (asprintf (&OrderBySubQuery,
|
||||
"StartTime DESC,EndTime DESC,Title DESC") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Dat_END_TIME:
|
||||
if (asprintf (&OrderBySubQuery,
|
||||
"EndTime DESC,StartTime DESC,Title DESC") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
if (Gbl.CurrentCrs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS)
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||
"SELECT AsgCod"
|
||||
|
@ -669,21 +658,17 @@ void Asg_GetListAssignments (void)
|
|||
" AsgCod IN (SELECT asg_grp.AsgCod FROM asg_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld AND asg_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Asgs.SelectedOrder]);
|
||||
else // Gbl.CurrentCrs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||
"SELECT AsgCod"
|
||||
" FROM assignments"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,
|
||||
OrderBySubQuery);
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
free ((void *) OrderBySubQuery);
|
||||
free ((void *) HiddenSubQuery);
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||
OrderBySubQuery[Gbl.Asgs.SelectedOrder]);
|
||||
|
||||
if (NumRows) // Assignments found...
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ static void Att_PutFormToListStdsParams (void);
|
|||
|
||||
static void Att_PutFormsToRemEditOneAttEvent (long AttCod,bool Hidden);
|
||||
static void Att_PutParams (void);
|
||||
static void Att_GetListAttEvents (Att_OrderTime_t Order);
|
||||
static void Att_GetListAttEvents (Att_OrderNewestOldest_t OrderNewestOldest);
|
||||
static void Att_GetDataOfAttEventByCodAndCheckCrs (struct AttendanceEvent *Att);
|
||||
static void Att_ResetAttendanceEvent (struct AttendanceEvent *Att);
|
||||
static void Att_GetAttEventTxtFromDB (long AttCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
||||
|
@ -600,10 +600,32 @@ static void Att_PutParams (void)
|
|||
/********************* List all the attendance events ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Att_GetListAttEvents (Att_OrderTime_t Order)
|
||||
static void Att_GetListAttEvents (Att_OrderNewestOldest_t OrderNewestOldest)
|
||||
{
|
||||
char *HiddenSubQuery;
|
||||
char *OrderBySubQuery;
|
||||
static const char *HiddenSubQuery[Rol_NUM_ROLES] =
|
||||
{
|
||||
" AND Hidden='N'", // Rol_UNK
|
||||
" AND Hidden='N'", // Rol_GST
|
||||
" AND Hidden='N'", // Rol_USR
|
||||
" AND Hidden='N'", // Rol_STD
|
||||
" AND Hidden='N'", // Rol_NET
|
||||
"", // Rol_TCH
|
||||
" AND Hidden='N'", // Rol_DEG_ADM
|
||||
" AND Hidden='N'", // Rol_CTR_ADM
|
||||
" AND Hidden='N'", // Rol_INS_ADM
|
||||
"", // Rol_SYS_ADM
|
||||
};
|
||||
static const char *OrderBySubQuery[Dat_NUM_START_END_TIME][Att_NUM_ORDERS_NEWEST_OLDEST] =
|
||||
{
|
||||
{ // Dat_START_TIME
|
||||
"StartTime DESC,EndTime DESC,Title DESC", // Att_NEWEST_FIRST
|
||||
"StartTime,EndTime,Title", // Att_OLDEST_FIRST
|
||||
},
|
||||
{ // Dat_END_TIME
|
||||
"EndTime DESC,StartTime DESC,Title DESC", // Att_NEWEST_FIRST
|
||||
"EndTime,StartTime,Title", // Att_OLDEST_FIRST
|
||||
}
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -613,33 +635,6 @@ static void Att_GetListAttEvents (Att_OrderTime_t Order)
|
|||
Att_FreeListAttEvents ();
|
||||
|
||||
/***** Get list of attendance events from database *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
if (asprintf (&HiddenSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
if (asprintf (&HiddenSubQuery," AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
switch (Gbl.AttEvents.SelectedOrder)
|
||||
{
|
||||
case Dat_START_TIME:
|
||||
if (asprintf (&OrderBySubQuery,
|
||||
(Order == Att_NEWEST_FIRST) ? "StartTime DESC,EndTime DESC,Title DESC" :
|
||||
"StartTime,EndTime,Title") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Dat_END_TIME:
|
||||
if (asprintf (&OrderBySubQuery,
|
||||
(Order == Att_NEWEST_FIRST) ? "EndTime DESC,StartTime DESC,Title DESC" :
|
||||
"EndTime,StartTime,Title") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
if (Gbl.CurrentCrs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS)
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
||||
"SELECT AttCod"
|
||||
|
@ -650,19 +645,19 @@ static void Att_GetListAttEvents (Att_OrderTime_t Order)
|
|||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND att_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,OrderBySubQuery);
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
OrderBySubQuery[Gbl.AttEvents.SelectedOrder][OrderNewestOldest]);
|
||||
else // Gbl.CurrentCrs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
||||
"SELECT AttCod"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,HiddenSubQuery,OrderBySubQuery);
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
free ((void *) OrderBySubQuery);
|
||||
free ((void *) HiddenSubQuery);
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged],
|
||||
OrderBySubQuery[Gbl.AttEvents.SelectedOrder][OrderNewestOldest]);
|
||||
|
||||
if (NumRows) // Attendance events found...
|
||||
{
|
||||
|
|
|
@ -62,11 +62,12 @@ struct AttendanceEvent
|
|||
bool Selected; // I have selected this attendance event
|
||||
};
|
||||
|
||||
#define Att_NUM_ORDERS_NEWEST_OLDEST 2
|
||||
typedef enum
|
||||
{
|
||||
Att_NEWEST_FIRST,
|
||||
Att_OLDEST_FIRST,
|
||||
} Att_OrderTime_t;
|
||||
} Att_OrderNewestOldest_t;
|
||||
|
||||
#define Att_ORDER_DEFAULT Dat_START_TIME
|
||||
|
||||
|
|
|
@ -1048,7 +1048,11 @@ void Ctr_PutIconToViewCentres (void)
|
|||
|
||||
void Ctr_GetListCentres (long InsCod)
|
||||
{
|
||||
char *OrderBySubQuery;
|
||||
static const char *OrderBySubQuery[Ctr_NUM_ORDERS] =
|
||||
{
|
||||
"FullName", // Ctr_ORDER_BY_CENTRE
|
||||
"NumUsrs DESC,FullName", // Ctr_ORDER_BY_NUM_TCHS
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -1056,17 +1060,6 @@ void Ctr_GetListCentres (long InsCod)
|
|||
struct Centre *Ctr;
|
||||
|
||||
/***** Get centres from database *****/
|
||||
switch (Gbl.Ctrs.SelectedOrder)
|
||||
{
|
||||
case Ctr_ORDER_BY_CENTRE:
|
||||
if (asprintf (&OrderBySubQuery,"FullName") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Ctr_ORDER_BY_NUM_TCHS:
|
||||
if (asprintf (&OrderBySubQuery,"NumUsrs DESC,FullName") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get centres",
|
||||
"(SELECT centres.CtrCod,centres.InsCod,centres.PlcCod,"
|
||||
"centres.Status,centres.RequesterUsrCod,"
|
||||
|
@ -1086,8 +1079,7 @@ void Ctr_GetListCentres (long InsCod)
|
|||
" ORDER BY %s",
|
||||
InsCod,
|
||||
InsCod,
|
||||
OrderBySubQuery);
|
||||
free ((void *) OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Ctrs.SelectedOrder]);
|
||||
|
||||
if (NumRows) // Centres found...
|
||||
{
|
||||
|
|
|
@ -345,8 +345,6 @@ Buenos d
|
|||
|
||||
// TODO: Que un grupo tenga asociado un lugar, como un aula, así al hacer un evento de asistencia, podría tener por defecto el lugar asignado al grupo elegido.
|
||||
|
||||
// TODO: Refactorize OrderBySubQuery
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -366,10 +364,15 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.26.3 (2019-01-03)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.27.1 (2019-01-03)"
|
||||
#define CSS_FILE "swad18.22.css"
|
||||
#define JS_FILE "swad17.17.1.js"
|
||||
/*
|
||||
Version 18.27.1: Jan 03, 2019 New field in forms of classrooms for location. (238800 lines)
|
||||
1 change necessary in database:
|
||||
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1751','es','N','Cambiar ubicación aula');
|
||||
|
||||
Version 18.27: Jan 03, 2019 Subqueries refactorized. (238667 lines)
|
||||
Version 18.26.3: Jan 03, 2019 New column location in classrooms listing. (238725 lines)
|
||||
Version 18.26.2: Jan 02, 2019 New column location in classrooms table. (238711 lines)
|
||||
1 change necessary in database:
|
||||
|
@ -385,11 +388,11 @@ UPDATE actions SET Txt='Cambiar aforo de aula' WHERE ActCod='1750' AND Language=
|
|||
DROP INDEX NumStds ON classrooms;
|
||||
ALTER TABLE classrooms CHANGE COLUMN NumStds MaxStudents INT NOT NULL;
|
||||
UPDATE actions SET Txt='Cambiar máx. estudiantes en grupo' WHERE ActCod='106' AND Language='es';
|
||||
UPDATE actions SET Txt='Cambiar máx. estudiantes en aula' WHERE ActCod='1750' AND Language='es';
|
||||
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1750','es','N','Cambiar máx. estudiantes en aula');
|
||||
|
||||
Version 18.25.3: Dec 30, 2018 Fixed bugs in classrooms. (238514 lines)
|
||||
Version 18.25.2: Dec 30, 2018 New database table for classrooms. (238525 lines)
|
||||
8 changes necessary in database:
|
||||
7 changes necessary in database:
|
||||
CREATE TABLE IF NOT EXISTS classrooms (ClaCod INT NOT NULL AUTO_INCREMENT,CtrCod INT NOT NULL,ShortName VARCHAR(511) NOT NULL,FullName VARCHAR(2047) NOT NULL,NumStds INT NOT NULL,UNIQUE INDEX(ClaCod),INDEX(CtrCod),INDEX(NumStds));
|
||||
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1744','es','N','Ver aulas');
|
||||
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1745','es','N','Editar aulas');
|
||||
|
|
137
swad_classroom.c
137
swad_classroom.c
|
@ -25,9 +25,7 @@
|
|||
/********************************** Headers **********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <linux/stddef.h> // For NULL
|
||||
#include <stdio.h> // For asprintf
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_box.h"
|
||||
|
@ -267,7 +265,12 @@ void Cla_PutIconToViewClassrooms (void)
|
|||
|
||||
void Cla_GetListClassrooms (void)
|
||||
{
|
||||
char *OrderBySubQuery;
|
||||
static const char *OrderBySubQuery[Cla_NUM_ORDERS] =
|
||||
{
|
||||
"FullName", // Cla_ORDER_BY_CLASSROOM
|
||||
"Capacity DESC,FullName", // Cla_ORDER_BY_CAPACITY
|
||||
"Location,FullName", // Cla_ORDER_BY_LOCATION
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -275,26 +278,6 @@ void Cla_GetListClassrooms (void)
|
|||
struct Classroom *Cla;
|
||||
|
||||
/***** Get classrooms from database *****/
|
||||
/* Build order subquery */
|
||||
switch (Gbl.Classrooms.SelectedOrder)
|
||||
{
|
||||
case Cla_ORDER_BY_CLASSROOM:
|
||||
if (asprintf (&OrderBySubQuery,"FullName") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Cla_ORDER_BY_CAPACITY:
|
||||
if (asprintf (&OrderBySubQuery,"Capacity DESC,"
|
||||
"FullName") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Cla_ORDER_BY_LOCATION:
|
||||
if (asprintf (&OrderBySubQuery,"Location DESC,"
|
||||
"FullName") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/* Build query */
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get classrooms",
|
||||
"SELECT ClaCod,"
|
||||
"ShortName,"
|
||||
|
@ -305,10 +288,7 @@ void Cla_GetListClassrooms (void)
|
|||
" WHERE CtrCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
OrderBySubQuery);
|
||||
|
||||
/* Free allocated memory for subquery */
|
||||
free ((void *) OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Classrooms.SelectedOrder]);
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows) // Classrooms found...
|
||||
|
@ -469,7 +449,7 @@ static void Cla_ListClassroomsForEdition (void)
|
|||
Frm_StartForm (ActRenClaSho);
|
||||
Cla_PutParamClaCod (Cla->ClaCod);
|
||||
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"ShortName\""
|
||||
" maxlength=\"%u\" value=\"%s\""
|
||||
" size=\"10\" maxlength=\"%u\" value=\"%s\""
|
||||
" class=\"INPUT_SHORT_NAME\""
|
||||
" onchange=\"document.getElementById('%s').submit();\" />",
|
||||
Cla_MAX_CHARS_SHRT_NAME,Cla->ShrtName,Gbl.Form.Id);
|
||||
|
@ -481,7 +461,7 @@ static void Cla_ListClassroomsForEdition (void)
|
|||
Frm_StartForm (ActRenClaFul);
|
||||
Cla_PutParamClaCod (Cla->ClaCod);
|
||||
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FullName\""
|
||||
" maxlength=\"%u\" value=\"%s\""
|
||||
" size=\"20\" maxlength=\"%u\" value=\"%s\""
|
||||
" class=\"INPUT_FULL_NAME\""
|
||||
" onchange=\"document.getElementById('%s').submit();\" />",
|
||||
Cla_MAX_CHARS_FULL_NAME,Cla->FullName,Gbl.Form.Id);
|
||||
|
@ -498,6 +478,18 @@ static void Cla_ListClassroomsForEdition (void)
|
|||
fprintf (Gbl.F.Out,"\" onchange=\"document.getElementById('%s').submit();\" />",
|
||||
Gbl.Form.Id);
|
||||
Frm_EndForm ();
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
/* Classroom location */
|
||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">");
|
||||
Frm_StartForm (ActRenClaLoc);
|
||||
Cla_PutParamClaCod (Cla->ClaCod);
|
||||
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"Location\""
|
||||
" size=\"15\" maxlength=\"%u\" value=\"%s\""
|
||||
" class=\"INPUT_FULL_NAME\""
|
||||
" onchange=\"document.getElementById('%s').submit();\" />",
|
||||
Cla_MAX_CHARS_LOCATION,Cla->Location,Gbl.Form.Id);
|
||||
Frm_EndForm ();
|
||||
fprintf (Gbl.F.Out,"</td>"
|
||||
"</tr>");
|
||||
}
|
||||
|
@ -697,10 +689,10 @@ static void Cla_UpdateClaNameDB (long ClaCod,const char *FieldName,const char *N
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Change maximum number of students in a classroom *************/
|
||||
/****************** Change sitting capacity of a classroom *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Cla_ChangeMaxStudents (void)
|
||||
void Cla_ChangeCapacity (void)
|
||||
{
|
||||
extern const char *Txt_The_capacity_of_classroom_X_has_not_changed;
|
||||
extern const char *Txt_The_classroom_X_does_not_have_a_limited_capacity_now;
|
||||
|
@ -771,6 +763,60 @@ static void Cla_WriteCapacity (unsigned Capacity)
|
|||
fprintf (Gbl.F.Out,"%u",Capacity);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Change the location of a classroom *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Cla_ChangeClassroomLocation (void)
|
||||
{
|
||||
extern const char *Txt_The_location_of_the_classroom_X_has_changed_to_Y;
|
||||
extern const char *Txt_The_location_of_the_classroom_X_has_not_changed;
|
||||
struct Classroom *Cla;
|
||||
char NewLocation[Cla_MAX_BYTES_FULL_NAME + 1];
|
||||
|
||||
Cla = &Gbl.Classrooms.EditingCla;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get the code of the classroom */
|
||||
if ((Cla->ClaCod = Cla_GetParamClaCod ()) == -1L)
|
||||
Lay_ShowErrorAndExit ("Code of classroom is missing.");
|
||||
|
||||
/* Get the new location for the classroom */
|
||||
Par_GetParToText ("Location",NewLocation,Cla_MAX_BYTES_LOCATION);
|
||||
|
||||
/***** Get from the database the old location of the classroom *****/
|
||||
Cla_GetDataOfClassroomByCod (Cla);
|
||||
|
||||
/***** Check if old and new locations are the same
|
||||
(this happens when return is pressed without changes) *****/
|
||||
if (strcmp (Cla->Location,NewLocation)) // Different locations
|
||||
{
|
||||
/* Update the table changing old name by new name */
|
||||
Cla_UpdateClaNameDB (Cla->ClaCod,"Location",NewLocation);
|
||||
Str_Copy (Cla->Location,NewLocation,
|
||||
Cla_MAX_BYTES_LOCATION);
|
||||
|
||||
/* Write message to show the change made */
|
||||
Gbl.Alert.Type = Ale_SUCCESS;
|
||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||
Txt_The_location_of_the_classroom_X_has_changed_to_Y,
|
||||
Cla->FullName,NewLocation);
|
||||
}
|
||||
else // The same location
|
||||
{
|
||||
Gbl.Alert.Type = Ale_INFO;
|
||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||
Txt_The_location_of_the_classroom_X_has_not_changed,
|
||||
Cla->FullName);
|
||||
}
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
Ale_ShowAlert (Gbl.Alert.Type,Gbl.Alert.Txt);
|
||||
|
||||
/***** Show the form again *****/
|
||||
Cla_EditClassrooms ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Put a form to create a new classroom ********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -802,31 +848,39 @@ static void Cla_PutFormToCreateClassroom (void)
|
|||
fprintf (Gbl.F.Out,"<td class=\"CODE\"></td>");
|
||||
|
||||
/***** Classroom short name *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
|
||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
||||
"<input type=\"text\" name=\"ShortName\""
|
||||
" maxlength=\"%u\" value=\"%s\""
|
||||
" size=\"10\" maxlength=\"%u\" value=\"%s\""
|
||||
" class=\"INPUT_SHORT_NAME\""
|
||||
" required=\"required\" />"
|
||||
"</td>",
|
||||
Cla_MAX_CHARS_SHRT_NAME,Cla->ShrtName);
|
||||
|
||||
/***** Classroom full name *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
|
||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
||||
"<input type=\"text\" name=\"FullName\""
|
||||
" maxlength=\"%u\" value=\"%s\""
|
||||
" size=\"20\" maxlength=\"%u\" value=\"%s\""
|
||||
" class=\"INPUT_FULL_NAME\""
|
||||
" required=\"required\" />"
|
||||
"</td>",
|
||||
Cla_MAX_CHARS_FULL_NAME,Cla->FullName);
|
||||
|
||||
/***** Seating capacity *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
|
||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
||||
"<input type=\"text\" name=\"Capacity\""
|
||||
" size=\"3\" maxlength=\"10\" value=\"");
|
||||
Cla_WriteCapacity (Cla->Capacity);
|
||||
fprintf (Gbl.F.Out,"\" />"
|
||||
"</td>");
|
||||
|
||||
/***** Classroom location *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
||||
"<input type=\"text\" name=\"Location\""
|
||||
" size=\"15\" maxlength=\"%u\" value=\"%s\""
|
||||
" class=\"INPUT_FULL_NAME\" />"
|
||||
"</td>"
|
||||
"</tr>");
|
||||
"</tr>",
|
||||
Cla_MAX_CHARS_LOCATION,Cla->Location);
|
||||
|
||||
/***** End table, send button and end box *****/
|
||||
Box_EndBoxTableWithButton (Btn_CREATE_BUTTON,Txt_Create_classroom);
|
||||
|
@ -845,6 +899,7 @@ static void Cla_PutHeadClassrooms (void)
|
|||
extern const char *Txt_Short_name;
|
||||
extern const char *Txt_Full_name;
|
||||
extern const char *Txt_Capacity_OF_A_CLASSROOM;
|
||||
extern const char *Txt_Location;
|
||||
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<th class=\"BM\"></th>"
|
||||
|
@ -860,11 +915,15 @@ static void Cla_PutHeadClassrooms (void)
|
|||
"<th class=\"LEFT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"</tr>",
|
||||
"<th class=\"LEFT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"</tr>",
|
||||
Txt_Code,
|
||||
Txt_Short_name,
|
||||
Txt_Full_name,
|
||||
Txt_Capacity_OF_A_CLASSROOM);
|
||||
Txt_Capacity_OF_A_CLASSROOM,
|
||||
Txt_Location);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -63,7 +63,7 @@ typedef enum
|
|||
Cla_ORDER_BY_CAPACITY = 1,
|
||||
Cla_ORDER_BY_LOCATION = 2,
|
||||
} Cla_Order_t;
|
||||
#define Cla_ORDER_DEFAULT Cla_ORDER_BY_CLASSROOM
|
||||
#define Cla_ORDER_DEFAULT Cla_ORDER_BY_LOCATION
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
|
@ -76,10 +76,13 @@ void Cla_GetListClassrooms (void);
|
|||
void Cla_FreeListClassrooms (void);
|
||||
void Cla_GetDataOfClassroomByCod (struct Classroom *Cla);
|
||||
long Cla_GetParamClaCod (void);
|
||||
|
||||
void Cla_RemoveClassroom (void);
|
||||
void Cla_RenameClassroomShort (void);
|
||||
void Cla_RenameClassroomFull (void);
|
||||
void Cla_ChangeMaxStudents (void);
|
||||
void Cla_ChangeCapacity (void);
|
||||
void Cla_ChangeClassroomLocation (void);
|
||||
|
||||
void Cla_RecFormNewClassroom (void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -261,7 +261,11 @@ void Dpt_EditDepartments (void)
|
|||
|
||||
void Dpt_GetListDepartments (long InsCod)
|
||||
{
|
||||
char OrderBySubQuery[256];
|
||||
static const char *OrderBySubQuery[Dpt_NUM_ORDERS] =
|
||||
{
|
||||
"FullName", // Dpt_ORDER_BY_DEPARTMENT
|
||||
"NumTchs DESC,FullName", // Dpt_ORDER_BY_NUM_TCHS
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumDpt;
|
||||
|
@ -273,15 +277,6 @@ void Dpt_GetListDepartments (long InsCod)
|
|||
if (InsCod > 0) // Institution specified
|
||||
{
|
||||
/***** Get departments from database *****/
|
||||
switch (Gbl.Dpts.SelectedOrder)
|
||||
{
|
||||
case Dpt_ORDER_BY_DEPARTMENT:
|
||||
sprintf (OrderBySubQuery,"FullName");
|
||||
break;
|
||||
case Dpt_ORDER_BY_NUM_TCHS:
|
||||
sprintf (OrderBySubQuery,"NumTchs DESC,FullName");
|
||||
break;
|
||||
}
|
||||
Gbl.Dpts.Num = (unsigned) DB_QuerySELECT (&mysql_res,"can not get departments",
|
||||
"(SELECT departments.DptCod,departments.InsCod,"
|
||||
"departments.ShortName,departments.FullName,departments.WWW,"
|
||||
|
@ -301,7 +296,7 @@ void Dpt_GetListDepartments (long InsCod)
|
|||
" ORDER BY %s",
|
||||
InsCod,(unsigned) Rol_NET,(unsigned) Rol_TCH,
|
||||
InsCod,(unsigned) Rol_NET,(unsigned) Rol_TCH,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Dpts.SelectedOrder]);
|
||||
if (Gbl.Dpts.Num) // Departments found...
|
||||
{
|
||||
/***** Create list with courses in degree *****/
|
||||
|
|
109
swad_game.c
109
swad_game.c
|
@ -885,8 +885,12 @@ static void Gam_PutParams (void)
|
|||
void Gam_GetListGames (void)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char SubQuery[Sco_NUM_SCOPES][256];
|
||||
char OrderBySubQuery[256];
|
||||
char *SubQuery[Sco_NUM_SCOPES];
|
||||
static const char *OrderBySubQuery[Gam_NUM_ORDERS] =
|
||||
{
|
||||
"StartTime DESC,EndTime DESC,Title DESC", // Gam_ORDER_BY_START_DATE
|
||||
"EndTime DESC,StartTime DESC,Title DESC", // Gam_ORDER_BY_END_DATE
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
||||
|
@ -895,7 +899,7 @@ void Gam_GetListGames (void)
|
|||
unsigned HiddenAllowed = 0;
|
||||
long Cods[Sco_NUM_SCOPES];
|
||||
Sco_Scope_t Scope;
|
||||
bool SubQueryFilled;
|
||||
bool SubQueryFilled = false;
|
||||
|
||||
/***** Free list of games *****/
|
||||
if (Gbl.Games.LstIsRead)
|
||||
|
@ -913,69 +917,72 @@ void Gam_GetListGames (void)
|
|||
Cods[Sco_SCOPE_CRS] = Gbl.CurrentCrs.Crs.CrsCod; // Course
|
||||
|
||||
/* Fill subqueries for system, country, institution, centre and degree */
|
||||
for (Scope = Sco_SCOPE_SYS, SubQueryFilled = false;
|
||||
for (Scope = Sco_SCOPE_SYS;
|
||||
Scope <= Sco_SCOPE_DEG;
|
||||
Scope++)
|
||||
if (ScopesAllowed & 1 << Scope)
|
||||
{
|
||||
sprintf (SubQuery[Scope],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Scope],Cods[Scope],
|
||||
(HiddenAllowed & 1 << Scope) ? "" :
|
||||
" AND Hidden='N'");
|
||||
if (asprintf (&SubQuery[Scope],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Scope],Cods[Scope],
|
||||
(HiddenAllowed & 1 << Scope) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
SubQueryFilled = true;
|
||||
}
|
||||
else
|
||||
SubQuery[Scope][0] = '\0';
|
||||
{
|
||||
if (asprintf (&SubQuery[Scope],"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Fill subquery for course */
|
||||
if (ScopesAllowed & 1 << Sco_SCOPE_CRS)
|
||||
{
|
||||
if (Gbl.CurrentCrs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS)
|
||||
sprintf (SubQuery[Sco_SCOPE_CRS],"%s("
|
||||
"Scope='%s' AND Cod=%ld%s"
|
||||
" AND "
|
||||
"(GamCod NOT IN"
|
||||
" (SELECT GamCod FROM gam_grp)"
|
||||
" OR"
|
||||
" GamCod IN"
|
||||
" (SELECT gam_grp.GamCod"
|
||||
" FROM gam_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND gam_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
")",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
{
|
||||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s("
|
||||
"Scope='%s' AND Cod=%ld%s"
|
||||
" AND "
|
||||
"(GamCod NOT IN"
|
||||
" (SELECT GamCod FROM gam_grp)"
|
||||
" OR"
|
||||
" GamCod IN"
|
||||
" (SELECT gam_grp.GamCod"
|
||||
" FROM gam_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND gam_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
")",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Gbl.CurrentCrs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
sprintf (SubQuery[Sco_SCOPE_CRS],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'");
|
||||
{
|
||||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
SubQueryFilled = true;
|
||||
}
|
||||
else
|
||||
SubQuery[Sco_SCOPE_CRS][0] = '\0';
|
||||
{
|
||||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Build query */
|
||||
/* Make query */
|
||||
if (SubQueryFilled)
|
||||
{
|
||||
switch (Gbl.Games.SelectedOrder)
|
||||
{
|
||||
case Gam_ORDER_BY_START_DATE:
|
||||
sprintf (OrderBySubQuery,"StartTime DESC,EndTime DESC,Title DESC");
|
||||
break;
|
||||
case Gam_ORDER_BY_END_DATE:
|
||||
sprintf (OrderBySubQuery,"EndTime DESC,StartTime DESC,Title DESC");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Make query */
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get games",
|
||||
"SELECT GamCod FROM games"
|
||||
|
@ -987,11 +994,17 @@ void Gam_GetListGames (void)
|
|||
SubQuery[Sco_SCOPE_CTR],
|
||||
SubQuery[Sco_SCOPE_DEG],
|
||||
SubQuery[Sco_SCOPE_CRS],
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Games.SelectedOrder]);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Can not get list of games.");
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
for (Scope = Sco_SCOPE_SYS;
|
||||
Scope <= Sco_SCOPE_CRS;
|
||||
Scope++)
|
||||
free ((void *) SubQuery[Scope]);
|
||||
|
||||
if (NumRows) // Games found...
|
||||
{
|
||||
Gbl.Games.Num = (unsigned) NumRows;
|
||||
|
|
|
@ -249,7 +249,11 @@ void Hld_EditHolidays (void)
|
|||
|
||||
void Hld_GetListHolidays (void)
|
||||
{
|
||||
char OrderBySubQuery[256];
|
||||
static const char *OrderBySubQuery[Hld_NUM_ORDERS] =
|
||||
{
|
||||
"Place,StartDate", // Hld_ORDER_BY_PLACE
|
||||
"StartDate,Place", // Hld_ORDER_BY_START_DATE
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumHld;
|
||||
|
@ -261,15 +265,6 @@ void Hld_GetListHolidays (void)
|
|||
Hld_FreeListHolidays ();
|
||||
|
||||
/***** Get holidays from database *****/
|
||||
switch (Gbl.Hlds.SelectedOrder)
|
||||
{
|
||||
case Hld_ORDER_BY_PLACE:
|
||||
sprintf (OrderBySubQuery,"Place,StartDate");
|
||||
break;
|
||||
case Hld_ORDER_BY_START_DATE:
|
||||
sprintf (OrderBySubQuery,"StartDate,Place");
|
||||
break;
|
||||
}
|
||||
Gbl.Hlds.Num =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get holidays",
|
||||
"(SELECT holidays.HldCod,"
|
||||
|
@ -301,7 +296,7 @@ void Hld_GetListHolidays (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Hlds.SelectedOrder]);
|
||||
if (Gbl.Hlds.Num) // Holidays found...
|
||||
{
|
||||
/***** Create list of holidays *****/
|
||||
|
|
|
@ -995,7 +995,11 @@ static void Ins_PutIconToViewInstitutions (void)
|
|||
|
||||
void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
||||
{
|
||||
char OrderBySubQuery[256];
|
||||
static const char *OrderBySubQuery[Ins_NUM_ORDERS] =
|
||||
{
|
||||
"FullName", // Ins_ORDER_BY_INSTITUTION
|
||||
"NumUsrs DESC,FullName", // Ins_ORDER_BY_NUM_USRS
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
||||
|
@ -1014,15 +1018,6 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
|||
CtyCod);
|
||||
break;
|
||||
case Ins_GET_EXTRA_DATA:
|
||||
switch (Gbl.Inss.SelectedOrder)
|
||||
{
|
||||
case Ins_ORDER_BY_INSTITUTION:
|
||||
sprintf (OrderBySubQuery,"FullName");
|
||||
break;
|
||||
case Ins_ORDER_BY_NUM_USRS:
|
||||
sprintf (OrderBySubQuery,"NumUsrs DESC,FullName");
|
||||
break;
|
||||
}
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"(SELECT institutions.InsCod,institutions.CtyCod,"
|
||||
"institutions.Status,institutions.RequesterUsrCod,"
|
||||
|
@ -1040,7 +1035,7 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
|||
" (SELECT DISTINCT InsCod FROM usr_data))"
|
||||
" ORDER BY %s",
|
||||
CtyCod,CtyCod,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Inss.SelectedOrder]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
21
swad_mail.c
21
swad_mail.c
|
@ -218,7 +218,12 @@ void Mai_EditMailDomains (void)
|
|||
|
||||
static void Mai_GetListMailDomainsAllowedForNotif (void)
|
||||
{
|
||||
char OrderBySubQuery[256];
|
||||
static const char *OrderBySubQuery[Mai_NUM_ORDERS] =
|
||||
{
|
||||
"Domain,Info,N DESC", // Mai_ORDER_BY_DOMAIN
|
||||
"Info,Domain,N DESC", // Mai_ORDER_BY_INFO
|
||||
"N DESC,Info,Domain", // Mai_ORDER_BY_USERS
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -242,18 +247,6 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
|||
"CREATE TEMPORARY TABLE T2 ENGINE=MEMORY SELECT * FROM T1");
|
||||
|
||||
/***** Get mail domains from database *****/
|
||||
switch (Gbl.Mails.SelectedOrder)
|
||||
{
|
||||
case Mai_ORDER_BY_DOMAIN:
|
||||
sprintf (OrderBySubQuery,"Domain,Info,N DESC");
|
||||
break;
|
||||
case Mai_ORDER_BY_INFO:
|
||||
sprintf (OrderBySubQuery,"Info,Domain,N DESC");
|
||||
break;
|
||||
case Mai_ORDER_BY_USERS:
|
||||
sprintf (OrderBySubQuery,"N DESC,Info,Domain");
|
||||
break;
|
||||
}
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get mail domains",
|
||||
"(SELECT mail_domains.MaiCod,"
|
||||
"mail_domains.Domain AS Domain,"
|
||||
|
@ -270,7 +263,7 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
|||
" WHERE Domain NOT IN"
|
||||
" (SELECT Domain COLLATE 'latin1_bin' FROM T2))"
|
||||
" ORDER BY %s", // COLLATE necessary to avoid error in comparisons
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Mails.SelectedOrder]);
|
||||
|
||||
if (NumRows) // Mail domains found...
|
||||
{
|
||||
|
|
17
swad_place.c
17
swad_place.c
|
@ -311,7 +311,11 @@ void Plc_PutIconToViewPlaces (void)
|
|||
|
||||
void Plc_GetListPlaces (void)
|
||||
{
|
||||
char OrderBySubQuery[256];
|
||||
static const char *OrderBySubQuery[Plc_NUM_ORDERS] =
|
||||
{
|
||||
"FullName", // Plc_ORDER_BY_PLACE
|
||||
"NumCtrs DESC,FullName", // Plc_ORDER_BY_NUM_CTRS
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -319,15 +323,6 @@ void Plc_GetListPlaces (void)
|
|||
struct Place *Plc;
|
||||
|
||||
/***** Get places from database *****/
|
||||
switch (Gbl.Plcs.SelectedOrder)
|
||||
{
|
||||
case Plc_ORDER_BY_PLACE:
|
||||
sprintf (OrderBySubQuery,"FullName");
|
||||
break;
|
||||
case Plc_ORDER_BY_NUM_CTRS:
|
||||
sprintf (OrderBySubQuery,"NumCtrs DESC,FullName");
|
||||
break;
|
||||
}
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get places",
|
||||
"(SELECT places.PlcCod,"
|
||||
"places.ShortName,"
|
||||
|
@ -353,7 +348,7 @@ void Plc_GetListPlaces (void)
|
|||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Plcs.SelectedOrder]);
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows) // Places found...
|
||||
|
|
113
swad_project.c
113
swad_project.c
|
@ -2278,14 +2278,30 @@ static bool Prj_CheckIfICanEditProject (long PrjCod)
|
|||
/************************** List all the projects ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Prj_MAX_BYTES_SUBQUERY 128
|
||||
|
||||
void Prj_GetListProjects (void)
|
||||
{
|
||||
char PreNonSubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||
char HidVisSubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||
char DptCodSubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||
char OrderBySubQuery[Prj_MAX_BYTES_SUBQUERY];
|
||||
char *PreNonSubQuery;
|
||||
char *HidVisSubQuery;
|
||||
char *DptCodSubQuery;
|
||||
static const char *OrderBySubQuery[Prj_NUM_ORDERS] =
|
||||
{
|
||||
"projects.CreatTime DESC," // Prj_ORDER_START_TIME
|
||||
"projects.ModifTime DESC,"
|
||||
"projects.Title",
|
||||
|
||||
"projects.ModifTime DESC," // Prj_ORDER_END_TIME
|
||||
"projects.CreatTime DESC,"
|
||||
"projects.Title",
|
||||
|
||||
"projects.Title," // Prj_ORDER_TITLE
|
||||
"projects.CreatTime DESC,"
|
||||
"projects.ModifTime DESC",
|
||||
|
||||
"departments.FullName," // Prj_ORDER_DEPARTMENT
|
||||
"projects.CreatTime DESC,"
|
||||
"projects.ModifTime DESC,"
|
||||
"projects.Title",
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows = 0; // Initialized to avoid warning
|
||||
|
@ -2303,16 +2319,17 @@ void Prj_GetListProjects (void)
|
|||
/* Preassigned subquery */
|
||||
switch (Gbl.Prjs.Filter.PreNon)
|
||||
{
|
||||
case (1 << Prj_PREASSIGNED):
|
||||
Str_Copy (PreNonSubQuery," AND projects.Preassigned='Y'",
|
||||
Prj_MAX_BYTES_SUBQUERY); // Preassigned projects
|
||||
case (1 << Prj_PREASSIGNED): // Preassigned projects
|
||||
if (asprintf (&PreNonSubQuery," AND projects.Preassigned='Y'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case (1 << Prj_NONPREASSIG):
|
||||
Str_Copy (PreNonSubQuery," AND projects.Preassigned='N'",
|
||||
Prj_MAX_BYTES_SUBQUERY); // Non-preassigned projects
|
||||
case (1 << Prj_NONPREASSIG): // Non-preassigned projects
|
||||
if (asprintf (&PreNonSubQuery," AND projects.Preassigned='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
PreNonSubQuery[0] = '\0'; // All projects
|
||||
default: // All projects
|
||||
if (asprintf (&PreNonSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2320,24 +2337,25 @@ void Prj_GetListProjects (void)
|
|||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD: // Students can view only visible projects
|
||||
Str_Copy (HidVisSubQuery," AND projects.Hidden='N'",
|
||||
Prj_MAX_BYTES_SUBQUERY); // Visible projects
|
||||
if (asprintf (&HidVisSubQuery," AND projects.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
switch (Gbl.Prjs.Filter.HidVis)
|
||||
{
|
||||
case (1 << Prj_HIDDEN):
|
||||
Str_Copy (HidVisSubQuery," AND projects.Hidden='Y'",
|
||||
Prj_MAX_BYTES_SUBQUERY); // Hidden projects
|
||||
case (1 << Prj_HIDDEN): // Hidden projects
|
||||
if (asprintf (&HidVisSubQuery," AND projects.Hidden='Y'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case (1 << Prj_VISIBL):
|
||||
Str_Copy (HidVisSubQuery," AND projects.Hidden='N'",
|
||||
Prj_MAX_BYTES_SUBQUERY); // Visible projects
|
||||
case (1 << Prj_VISIBL): // Visible projects
|
||||
if (asprintf (&HidVisSubQuery," AND projects.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
HidVisSubQuery[0] = '\0'; // All projects
|
||||
default: // All projects
|
||||
if (asprintf (&HidVisSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2348,35 +2366,15 @@ void Prj_GetListProjects (void)
|
|||
|
||||
/* Department subquery */
|
||||
if (Gbl.Prjs.Filter.DptCod >= 0)
|
||||
sprintf (DptCodSubQuery," AND projects.DptCod=%ld",
|
||||
Gbl.Prjs.Filter.DptCod);
|
||||
{
|
||||
if (asprintf (&DptCodSubQuery," AND projects.DptCod=%ld",
|
||||
Gbl.Prjs.Filter.DptCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Any department
|
||||
DptCodSubQuery[0] = '\0';
|
||||
|
||||
/* Order subquery */
|
||||
switch (Gbl.Prjs.SelectedOrder)
|
||||
{
|
||||
case Prj_ORDER_START_TIME:
|
||||
sprintf (OrderBySubQuery,"projects.CreatTime DESC,"
|
||||
"projects.ModifTime DESC,"
|
||||
"projects.Title");
|
||||
break;
|
||||
case Prj_ORDER_END_TIME:
|
||||
sprintf (OrderBySubQuery,"projects.ModifTime DESC,"
|
||||
"projects.CreatTime DESC,"
|
||||
"projects.Title");
|
||||
break;
|
||||
case Prj_ORDER_TITLE:
|
||||
sprintf (OrderBySubQuery,"projects.Title,"
|
||||
"projects.CreatTime DESC,"
|
||||
"projects.ModifTime DESC");
|
||||
break;
|
||||
case Prj_ORDER_DEPARTMENT:
|
||||
sprintf (OrderBySubQuery,"departments.FullName,"
|
||||
"projects.CreatTime DESC,"
|
||||
"projects.ModifTime DESC,"
|
||||
"projects.Title");
|
||||
break;
|
||||
if (asprintf (&DptCodSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Query */
|
||||
|
@ -2397,7 +2395,7 @@ void Prj_GetListProjects (void)
|
|||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
||||
break;
|
||||
case Prj_ORDER_DEPARTMENT:
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
||||
|
@ -2412,7 +2410,7 @@ void Prj_GetListProjects (void)
|
|||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
||||
break;
|
||||
}
|
||||
else // Gbl.Prjs.My_All == Prj_ALL_PROJECTS
|
||||
|
@ -2429,7 +2427,7 @@ void Prj_GetListProjects (void)
|
|||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
||||
break;
|
||||
case Prj_ORDER_DEPARTMENT:
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get projects",
|
||||
|
@ -2441,10 +2439,15 @@ void Prj_GetListProjects (void)
|
|||
" ORDER BY %s",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||
OrderBySubQuery);
|
||||
OrderBySubQuery[Gbl.Prjs.SelectedOrder]);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
free ((void *) PreNonSubQuery);
|
||||
free ((void *) HidVisSubQuery);
|
||||
free ((void *) DptCodSubQuery);
|
||||
|
||||
if (NumRows) // Projects found...
|
||||
{
|
||||
Gbl.Prjs.Num = (unsigned) NumRows;
|
||||
|
|
111
swad_survey.c
111
swad_survey.c
|
@ -25,8 +25,10 @@
|
|||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <linux/limits.h> // For PATH_MAX
|
||||
#include <linux/stddef.h> // For NULL
|
||||
#include <stdio.h> // For asprintf
|
||||
#include <stdlib.h> // For calloc
|
||||
#include <string.h> // For string functions
|
||||
|
||||
|
@ -846,8 +848,12 @@ static void Svy_PutParams (void)
|
|||
void Svy_GetListSurveys (void)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char SubQuery[Sco_NUM_SCOPES][256];
|
||||
char OrderBySubQuery[256];
|
||||
char *SubQuery[Sco_NUM_SCOPES];
|
||||
static const char *OrderBySubQuery[Svy_NUM_ORDERS] =
|
||||
{
|
||||
"StartTime DESC,EndTime DESC,Title DESC", // Svy_ORDER_BY_START_DATE
|
||||
"EndTime DESC,StartTime DESC,Title DESC", // Svy_ORDER_BY_END_DATE
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
@ -856,7 +862,7 @@ void Svy_GetListSurveys (void)
|
|||
unsigned HiddenAllowed = 0;
|
||||
long Cods[Sco_NUM_SCOPES];
|
||||
Sco_Scope_t Scope;
|
||||
bool SubQueryFilled;
|
||||
bool SubQueryFilled = false;
|
||||
|
||||
/***** Free list of surveys *****/
|
||||
if (Gbl.Svys.LstIsRead)
|
||||
|
@ -874,69 +880,71 @@ void Svy_GetListSurveys (void)
|
|||
Cods[Sco_SCOPE_CRS] = Gbl.CurrentCrs.Crs.CrsCod; // Course
|
||||
|
||||
/* Fill subqueries for system, country, institution, centre and degree */
|
||||
for (Scope = Sco_SCOPE_SYS, SubQueryFilled = false;
|
||||
for (Scope = Sco_SCOPE_SYS;
|
||||
Scope <= Sco_SCOPE_DEG;
|
||||
Scope++)
|
||||
if (ScopesAllowed & 1 << Scope)
|
||||
{
|
||||
sprintf (SubQuery[Scope],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Scope],Cods[Scope],
|
||||
(HiddenAllowed & 1 << Scope) ? "" :
|
||||
" AND Hidden='N'");
|
||||
if (asprintf (&SubQuery[Scope],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Scope],Cods[Scope],
|
||||
(HiddenAllowed & 1 << Scope) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
SubQueryFilled = true;
|
||||
}
|
||||
else
|
||||
SubQuery[Scope][0] = '\0';
|
||||
{
|
||||
if (asprintf (&SubQuery[Scope],"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Fill subquery for course */
|
||||
if (ScopesAllowed & 1 << Sco_SCOPE_CRS)
|
||||
{
|
||||
if (Gbl.CurrentCrs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS)
|
||||
sprintf (SubQuery[Sco_SCOPE_CRS],"%s("
|
||||
"Scope='%s' AND Cod=%ld%s"
|
||||
" AND "
|
||||
"(SvyCod NOT IN"
|
||||
" (SELECT SvyCod FROM svy_grp)"
|
||||
" OR"
|
||||
" SvyCod IN"
|
||||
" (SELECT svy_grp.SvyCod"
|
||||
" FROM svy_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND svy_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
")",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
{
|
||||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s("
|
||||
"Scope='%s' AND Cod=%ld%s"
|
||||
" AND "
|
||||
"(SvyCod NOT IN"
|
||||
" (SELECT SvyCod FROM svy_grp)"
|
||||
" OR"
|
||||
" SvyCod IN"
|
||||
" (SELECT svy_grp.SvyCod"
|
||||
" FROM svy_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND svy_grp.GrpCod=crs_grp_usr.GrpCod))"
|
||||
")",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Gbl.CurrentCrs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
sprintf (SubQuery[Sco_SCOPE_CRS],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'");
|
||||
{
|
||||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s(Scope='%s' AND Cod=%ld%s)",
|
||||
SubQueryFilled ? " OR " :
|
||||
"",
|
||||
Sco_ScopeDB[Sco_SCOPE_CRS],Cods[Sco_SCOPE_CRS],
|
||||
(HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
SubQueryFilled = true;
|
||||
}
|
||||
else
|
||||
SubQuery[Sco_SCOPE_CRS][0] = '\0';
|
||||
{
|
||||
if (asprintf (&SubQuery[Sco_SCOPE_CRS],"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Make query */
|
||||
if (SubQueryFilled)
|
||||
{
|
||||
switch (Gbl.Svys.SelectedOrder)
|
||||
{
|
||||
case Svy_ORDER_BY_START_DATE:
|
||||
sprintf (OrderBySubQuery,"StartTime DESC,EndTime DESC,Title DESC");
|
||||
break;
|
||||
case Svy_ORDER_BY_END_DATE:
|
||||
sprintf (OrderBySubQuery,"EndTime DESC,StartTime DESC,Title DESC");
|
||||
break;
|
||||
}
|
||||
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get surveys",
|
||||
"SELECT SvyCod FROM surveys"
|
||||
" WHERE %s%s%s%s%s%s"
|
||||
|
@ -947,14 +955,19 @@ void Svy_GetListSurveys (void)
|
|||
SubQuery[Sco_SCOPE_CTR],
|
||||
SubQuery[Sco_SCOPE_DEG],
|
||||
SubQuery[Sco_SCOPE_CRS],
|
||||
OrderBySubQuery);
|
||||
}
|
||||
OrderBySubQuery[Gbl.Svys.SelectedOrder]);
|
||||
else
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Can not get list of surveys.");
|
||||
NumRows = 0; // Not reached. Initialized to avoid warning
|
||||
}
|
||||
|
||||
/* Free allocated memory for subqueries */
|
||||
for (Scope = Sco_SCOPE_SYS;
|
||||
Scope <= Sco_SCOPE_CRS;
|
||||
Scope++)
|
||||
free ((void *) SubQuery[Scope]);
|
||||
|
||||
if (NumRows) // Surveys found...
|
||||
{
|
||||
Gbl.Svys.Num = (unsigned) NumRows;
|
||||
|
|
62
swad_text.c
62
swad_text.c
|
@ -45575,6 +45575,66 @@ const char *Txt_The_list_of_X_users_is_too_large_to_be_displayed = // Warning: i
|
|||
"A lista de %u usuários é muito grande para ser exibida.";
|
||||
#endif
|
||||
|
||||
const char *Txt_The_location_of_the_classroom_X_has_changed_to_Y = // Warning: it is very important to include two %s in the following sentences
|
||||
#if L==1 // ca
|
||||
"La ubicació de l'aula <strong>%s</strong>"
|
||||
" ha canviat a <strong>%s</strong>.";
|
||||
#elif L==2 // de
|
||||
"Der Standort des Klassenzimmer <strong>%s</strong>"
|
||||
" wurde in <strong>%s</strong> geändert.";
|
||||
#elif L==3 // en
|
||||
"The location of the classroom <strong>%s</strong>"
|
||||
" has changed to <strong>%s</strong>.";
|
||||
#elif L==4 // es
|
||||
"La ubicación del aula <strong>%s</strong>"
|
||||
" ha cambiado a <strong>%s</strong>.";
|
||||
#elif L==5 // fr
|
||||
"L'emplacement de la salle de classe <strong>%s</strong>"
|
||||
" a été remplacé par <strong>%s</strong>.";
|
||||
#elif L==6 // gn
|
||||
"La ubicación del aula <strong>%s</strong>"
|
||||
" ha cambiado a <strong>%s</strong>."; // Okoteve traducción
|
||||
#elif L==7 // it
|
||||
"La posizione della aula <strong>%s</strong>"
|
||||
" è cambiata in <strong>%s</strong>.";
|
||||
#elif L==8 // pl
|
||||
"Lokalizacja klasy <strong>%s</strong>"
|
||||
" zmieniła się na <strong>%s</strong>.";
|
||||
#elif L==9 // pt
|
||||
"A localização da sala de clase <strong>%s</strong>"
|
||||
" mudou para <strong>%s</strong>.";
|
||||
#endif
|
||||
|
||||
const char *Txt_The_location_of_the_classroom_X_has_not_changed = // Warning: it is very important to include %s in the following sentences
|
||||
#if L==1 // ca
|
||||
"La ubicació de l'aula <strong>%s</strong>"
|
||||
" no ha canviat.";
|
||||
#elif L==2 // de
|
||||
"Der Standort des Klassenzimmer <strong>%s</strong>"
|
||||
" hat sich nicht geändert.";
|
||||
#elif L==3 // en
|
||||
"The location of the classroom <strong>%s</strong>"
|
||||
" has not changed.";
|
||||
#elif L==4 // es
|
||||
"La ubicación del aula <strong>%s</strong>"
|
||||
" no ha cambiado.";
|
||||
#elif L==5 // fr
|
||||
"L'emplacement de la salle de classe <strong>%s</strong>"
|
||||
" n'a pas changé.";
|
||||
#elif L==6 // gn
|
||||
"La ubicación del aula <strong>%s</strong>"
|
||||
" no ha cambiado."; // Okoteve traducción
|
||||
#elif L==7 // it
|
||||
"La posizione della aula <strong>%s</strong>"
|
||||
" non è cambiata.";
|
||||
#elif L==8 // pl
|
||||
"Lokalizacja klasy <strong>%s</strong>"
|
||||
" nie uległa zmianie.";
|
||||
#elif L==9 // pt
|
||||
"A localização da sala de clase <strong>%s</strong>"
|
||||
" não foi alterada.";
|
||||
#endif
|
||||
|
||||
const char *Txt_The_lower_limit_of_correct_answers_must_be_less_than_or_equal_to_the_upper_limit =
|
||||
#if L==1 // ca
|
||||
"El límite inferior del intervalo de respuestas correctas"
|
||||
|
@ -45804,7 +45864,7 @@ const char *Txt_The_name_of_the_classroom_X_has_not_changed = // Warning: it is
|
|||
#if L==1 // ca
|
||||
"El nom de l'aula <strong>%s</strong> no ha canviat.";
|
||||
#elif L==2 // de
|
||||
"Der Name von Klassenzimmer <strong>%s</strong> hat sich nicht geändert.";
|
||||
"Der Name des Klassenzimmer <strong>%s</strong> hat sich nicht geändert.";
|
||||
#elif L==3 // en
|
||||
"The name of the classroom <strong>%s</strong> has not changed.";
|
||||
#elif L==4 // es
|
||||
|
|
Loading…
Reference in New Issue