Version 17.23.1

This commit is contained in:
Antonio Cañas Vargas 2017-10-10 10:46:35 +02:00
parent 0c96d661ab
commit a9fd5d23ac
6 changed files with 129 additions and 135 deletions

View File

@ -254,13 +254,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 17.23 (2017-10-10)"
#define Log_PLATFORM_VERSION "SWAD 17.23.1 (2017-10-10)"
#define CSS_FILE "swad17.0.css"
#define JS_FILE "swad17.17.1.js"
// 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
/*
Version 17.23.1: Oct 10, 2017 Changes in selectors of departments. (234133 lines)
Version 17.23: Oct 10, 2017 New filter to select preassigned/non-preassigned projects.
New filter to select hidden/visible projects.
Code refactoring in parameters of projects. (234140 lines)

View File

@ -253,8 +253,8 @@ void Dpt_EditDepartments (void)
/*****************************************************************************/
/************************** Get list of departments **************************/
/*****************************************************************************/
// If InsCod <= 0 ==> get all the departments
// If InsCod > 0 ==> get departments of an institution
// If InsCod <= 0 ==> an empty list is returned
void Dpt_GetListDepartments (long InsCod)
{
@ -262,21 +262,24 @@ void Dpt_GetListDepartments (long InsCod)
char Query[1024];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
unsigned NumDpt;
struct Department *Dpt;
/***** Get departments from database *****/
switch (Gbl.Dpts.SelectedOrder)
/***** Free list of departments *****/
Dpt_FreeListDepartments (); // List is initialized to empty
if (InsCod > 0) // Institution specified
{
case Dpt_ORDER_BY_DEPARTMENT:
sprintf (OrderBySubQuery,"FullName");
break;
case Dpt_ORDER_BY_NUM_TCHS:
sprintf (OrderBySubQuery,"NumTchs DESC,FullName");
break;
}
if (InsCod > 0) // Only the departments of an institution
/***** 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;
}
sprintf (Query,"(SELECT departments.DptCod,departments.InsCod,"
"departments.ShortName,departments.FullName,departments.WWW,"
"COUNT(DISTINCT usr_data.UsrCod) AS NumTchs"
@ -296,76 +299,54 @@ void Dpt_GetListDepartments (long InsCod)
InsCod,(unsigned) Rol_NET,(unsigned) Rol_TCH,
InsCod,(unsigned) Rol_NET,(unsigned) Rol_TCH,
OrderBySubQuery);
else // All the departments
sprintf (Query,"(SELECT departments.DptCod,departments.InsCod,"
"departments.ShortName,departments.FullName,departments.WWW,"
"COUNT(DISTINCT usr_data.UsrCod) AS NumTchs"
" FROM departments,usr_data,crs_usr"
" WHERE departments.DptCod=usr_data.DptCod"
" AND usr_data.UsrCod=crs_usr.UsrCod"
" AND crs_usr.Role IN (%u,%u)"
" GROUP BY departments.DptCod)"
" UNION "
"(SELECT DptCod,InsCod,ShortName,FullName,WWW,0 AS NumTchs"
" FROM departments"
" WHERE DptCod NOT IN"
" (SELECT DISTINCT usr_data.DptCod FROM usr_data,crs_usr"
" WHERE crs_usr.Role IN (%u,%u) AND crs_usr.UsrCod=usr_data.UsrCod))"
" ORDER BY %s",
(unsigned) Rol_NET,(unsigned) Rol_TCH,
(unsigned) Rol_NET,(unsigned) Rol_TCH,
OrderBySubQuery);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get departments");
Gbl.Dpts.Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get departments");
if (NumRows) // Departments found...
{
// NumRows should be equal to Deg->NumCourses
Gbl.Dpts.Num = (unsigned) NumRows;
if (Gbl.Dpts.Num) // Departments found...
{
/***** Create list with courses in degree *****/
if ((Gbl.Dpts.Lst = (struct Department *) calloc ((size_t) Gbl.Dpts.Num,
sizeof (struct Department))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store departments.");
/***** Create list with courses in degree *****/
if ((Gbl.Dpts.Lst = (struct Department *) calloc (NumRows,sizeof (struct Department))) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store departments.");
/***** Get the departments *****/
for (NumDpt = 0;
NumDpt < Gbl.Dpts.Num;
NumDpt++)
{
Dpt = &(Gbl.Dpts.Lst[NumDpt]);
/***** Get the departments *****/
for (NumDpt = 0;
NumDpt < Gbl.Dpts.Num;
NumDpt++)
{
Dpt = &(Gbl.Dpts.Lst[NumDpt]);
/* Get next department */
row = mysql_fetch_row (mysql_res);
/* Get next department */
row = mysql_fetch_row (mysql_res);
/* Get department code (row[0]) */
if ((Dpt->DptCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of department.");
/* Get department code (row[0]) */
if ((Dpt->DptCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
Lay_ShowErrorAndExit ("Wrong code of department.");
/* Get institution code (row[1]) */
if ((Dpt->InsCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
Lay_ShowErrorAndExit ("Wrong code of institution.");
/* Get institution code (row[1]) */
if ((Dpt->InsCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
Lay_ShowErrorAndExit ("Wrong code of institution.");
/* Get the short name of the department (row[2]) */
Str_Copy (Dpt->ShrtName,row[2],
Hie_MAX_BYTES_SHRT_NAME);
/* Get the short name of the department (row[2]) */
Str_Copy (Dpt->ShrtName,row[2],
Hie_MAX_BYTES_SHRT_NAME);
/* Get the full name of the department (row[3]) */
Str_Copy (Dpt->FullName,row[3],
Hie_MAX_BYTES_FULL_NAME);
/* Get the full name of the department (row[3]) */
Str_Copy (Dpt->FullName,row[3],
Hie_MAX_BYTES_FULL_NAME);
/* Get the URL of the department (row[4]) */
Str_Copy (Dpt->WWW,row[4],
Cns_MAX_BYTES_WWW);
/* Get the URL of the department (row[4]) */
Str_Copy (Dpt->WWW,row[4],
Cns_MAX_BYTES_WWW);
/* Get number of non-editing teachers and teachers in this department (row[5]) */
if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1)
Dpt->NumTchs = 0;
}
}
/* Get number of non-editing teachers and teachers in this department (row[5]) */
if (sscanf (row[5],"%u",&Dpt->NumTchs) != 1)
Dpt->NumTchs = 0;
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
else
Gbl.Dpts.Num = 0;
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
@ -451,12 +432,11 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt)
void Dpt_FreeListDepartments (void)
{
if (Gbl.Dpts.Lst)
{
/***** Free memory used by the list of courses in degree *****/
/***** Free memory used by the list of departments *****/
free ((void *) Gbl.Dpts.Lst);
Gbl.Dpts.Lst = NULL;
Gbl.Dpts.Num = 0;
}
Gbl.Dpts.Lst = NULL;
Gbl.Dpts.Num = 0;
}
/*****************************************************************************/
@ -1130,28 +1110,56 @@ unsigned Dpt_GetNumDptsInIns (long InsCod)
/*********************** Put selector for department *************************/
/*****************************************************************************/
void Dpt_WriteSelectorDepartment (long InsCod,long DptCod,bool SubmitFormOnChange)
void Dpt_WriteSelectorDepartment (long InsCod,long DptCod,
unsigned SelectorWidth, // In pixels
long FirstOption,
const char *TextWhenNoDptSelected,
bool SubmitFormOnChange)
{
extern const char *Txt_Any_department;
extern const char *Txt_Another_department;
unsigned NumDpt;
bool NoDptSelectable;
/***** Form to select department *****/
/* Get list of departments */
/***** Get list of departments *****/
Dpt_GetListDepartments (InsCod);
/* List departments */
/***** Selector to select department *****/
/* Start selector */
fprintf (Gbl.F.Out,"<select id=\"DptCod\" name=\"DptCod\""
" style=\"width:375px;\"");
" style=\"width:%upx;\"",
SelectorWidth);
if (SubmitFormOnChange)
fprintf (Gbl.F.Out," onchange=\"document.getElementById('%s').submit();\"",
Gbl.Form.Id);
fprintf (Gbl.F.Out,"\">");
fprintf (Gbl.F.Out,"<option value=\"-1\"");
if (DptCod == -1L)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",Txt_Any_department);
if (FirstOption <= 0)
{
/* Option when no department selected */
if (FirstOption < 0)
{
NoDptSelectable = false;
if (TextWhenNoDptSelected)
if (TextWhenNoDptSelected[0])
NoDptSelectable = true;
fprintf (Gbl.F.Out,"<option value=\"-1\"");
if (DptCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
if (!NoDptSelectable)
fprintf (Gbl.F.Out," disabled=\"disabled\"");
fprintf (Gbl.F.Out,">%s</option>",TextWhenNoDptSelected);
}
/* Another department selected (different to all departments listed) */
fprintf (Gbl.F.Out,"<option value=\"0\"");
if (DptCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_department);
}
/* List all departments */
for (NumDpt = 0;
NumDpt < Gbl.Dpts.Num;
NumDpt++)
@ -1162,8 +1170,9 @@ void Dpt_WriteSelectorDepartment (long InsCod,long DptCod,bool SubmitFormOnChang
fprintf (Gbl.F.Out,">%s</option>",Gbl.Dpts.Lst[NumDpt].FullName);
}
/* End selector */
fprintf (Gbl.F.Out,"</select>");
/* Free list of departments */
/***** Free list of departments *****/
Dpt_FreeListDepartments ();
}

View File

@ -71,6 +71,10 @@ void Dpt_RecFormNewDpt (void);
unsigned Dpt_GetTotalNumberOfDepartments (void);
unsigned Dpt_GetNumDptsInIns (long InsCod);
void Dpt_WriteSelectorDepartment (long InsCod,long DptCod,bool SubmitFormOnChange);
void Dpt_WriteSelectorDepartment (long InsCod,long DptCod,
unsigned SelectorWidth, // In pixels
long FirstOptionSelectable,
const char *TextWhenNoDptSelected,
bool SubmitFormOnChange);
#endif

View File

@ -94,6 +94,7 @@ void Ind_ReqIndicatorsCourses (void)
extern const char *Txt_Types_of_degree;
extern const char *Txt_only_if_the_scope_is_X;
extern const char *Txt_Department;
extern const char *Txt_Any_department;
extern const char *Txt_No_of_indicators;
extern const char *Txt_Indicators_of_courses;
extern const char *Txt_Show_more_details;
@ -147,9 +148,12 @@ void Ind_ReqIndicatorsCourses (void)
"</td>"
"<td class=\"LEFT_MIDDLE\">",
The_ClassForm[Gbl.Prefs.Theme],Txt_Department);
Dpt_WriteSelectorDepartment (-1L, // All institutions
Gbl.Stat.DptCod, // Selected department
true); // Submit on change
Dpt_WriteSelectorDepartment (Gbl.CurrentIns.Ins.InsCod, // Departments in current insitution
Gbl.Stat.DptCod, // Selected department
375, // Width in pixels
-1L, // First option
Txt_Any_department, // Text when no department selected
true); // Submit on change
fprintf (Gbl.F.Out,"</td>"
"</tr>");
@ -326,7 +330,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
switch (Gbl.Scope.Current)
{
case Sco_SCOPE_SYS:
if (Gbl.Stat.DptCod > 0)
if (Gbl.Stat.DptCod >= 0) // 0 means another department
{
if (Gbl.Stat.DegTypCod > 0)
sprintf (Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
@ -370,7 +374,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
}
break;
case Sco_SCOPE_CTY:
if (Gbl.Stat.DptCod > 0)
if (Gbl.Stat.DptCod >= 0) // 0 means another department
sprintf (Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
" WHERE institutions.CtyCod=%ld"
@ -396,7 +400,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
Gbl.CurrentCty.Cty.CtyCod);
break;
case Sco_SCOPE_INS:
if (Gbl.Stat.DptCod > 0)
if (Gbl.Stat.DptCod >= 0) // 0 means another department
sprintf (Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM centres,degrees,courses,crs_usr,usr_data"
" WHERE centres.InsCod=%ld"
@ -420,7 +424,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
Gbl.CurrentIns.Ins.InsCod);
break;
case Sco_SCOPE_CTR:
if (Gbl.Stat.DptCod > 0)
if (Gbl.Stat.DptCod >= 0) // 0 means another department
sprintf (Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE degrees.CtrCod=%ld"
@ -442,7 +446,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
Gbl.CurrentCtr.Ctr.CtrCod);
break;
case Sco_SCOPE_DEG:
if (Gbl.Stat.DptCod > 0)
if (Gbl.Stat.DptCod >= 0) // 0 means another department
sprintf (Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE degrees.DegCod=%ld"
@ -464,7 +468,7 @@ static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
Gbl.CurrentDeg.Deg.DegCod);
break;
case Sco_SCOPE_CRS:
if (Gbl.Stat.DptCod > 0)
if (Gbl.Stat.DptCod >= 0) // 0 means another department
sprintf (Query,"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE courses.CrsCod=%ld"

View File

@ -2754,6 +2754,7 @@ static void Prj_PutFormProject (struct Project *Prj,bool ItsANewProject)
extern const char *Txt_Data;
extern const char *Txt_Title;
extern const char *Txt_Department;
extern const char *Txt_Another_department;
extern const char *Txt_Preassigned_QUESTION;
extern const char *Txt_Number_of_students;
extern const char *Txt_Proposal;
@ -2831,9 +2832,12 @@ static void Prj_PutFormProject (struct Project *Prj,bool ItsANewProject)
"</td>"
"<td class=\"LEFT_MIDDLE\">",
The_ClassForm[Gbl.Prefs.Theme],Txt_Department);
Dpt_WriteSelectorDepartment (Gbl.CurrentIns.Ins.InsCod,
Prj->DptCod, // Selected department
false); // Don't submit on change
Dpt_WriteSelectorDepartment (Gbl.CurrentIns.Ins.InsCod, // Departments in current institution
Prj->DptCod, // Selected department
375, // Width in pixels
0, // First option
Txt_Another_department, // Text when no department selected
false); // Don't submit on change
fprintf (Gbl.F.Out,"</td>"
"</tr>");

View File

@ -3964,14 +3964,12 @@ void Rec_ShowFormMyInsCtrDpt (void)
extern const char *Txt_Centre;
extern const char *Txt_Another_centre;
extern const char *Txt_Department;
extern const char *Txt_Another_department;
extern const char *Txt_Office;
extern const char *Txt_Phone;
const char *ClassForm = The_ClassForm[Gbl.Prefs.Theme];
unsigned NumCty;
unsigned NumIns;
unsigned NumCtr;
unsigned NumDpt;
bool IAmATeacher;
/***** Get my roles if not yet got *****/
@ -4142,39 +4140,13 @@ void Rec_ShowFormMyInsCtrDpt (void)
"<td class=\"LEFT_MIDDLE\" style=\"width:%upx;\">",
ClassForm,Txt_Department,
COL2_WIDTH);
/* Get list of departments in this institution */
Dpt_FreeListDepartments ();
if (Gbl.Usrs.Me.UsrDat.InsCod > 0)
Dpt_GetListDepartments (Gbl.Usrs.Me.UsrDat.InsCod);
/* Start form to select department */
Act_FormGoToStart (ActChgMyDpt);
fprintf (Gbl.F.Out,"<select id=\"DptCod\" name=\"DptCod\""
" style=\"width:500px;\""
" onchange=\"document.getElementById('%s').submit();\">"
"<option value=\"-1\"",
Gbl.Form.Id);
if (Gbl.Usrs.Me.UsrDat.Tch.DptCod < 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out," disabled=\"disabled\"></option>"
"<option value=\"0\"");
if (Gbl.Usrs.Me.UsrDat.Tch.DptCod == 0)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_Another_department);
for (NumDpt = 0;
NumDpt < Gbl.Dpts.Num;
NumDpt++)
{
fprintf (Gbl.F.Out,"<option value=\"%ld\"",
Gbl.Dpts.Lst[NumDpt].DptCod);
if (Gbl.Dpts.Lst[NumDpt].DptCod == Gbl.Usrs.Me.UsrDat.Tch.DptCod)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Gbl.Dpts.Lst[NumDpt].FullName);
}
fprintf (Gbl.F.Out,"</select>");
Dpt_WriteSelectorDepartment (Gbl.Usrs.Me.UsrDat.InsCod, // Departments in my institution
Gbl.Usrs.Me.UsrDat.Tch.DptCod, // Selected department
500, // Width in pixels
-1L, // First option
"", // Text when no department selected
true); // Submit on change
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"
"</tr>");