mirror of
https://github.com/acanas/swad-core.git
synced 2024-05-29 04:53:26 +02:00
Version 15.199
This commit is contained in:
parent
b0581608be
commit
b5c01ab334
|
@ -11516,3 +11516,8 @@ OPTIMIZE TABLE msg_snt_deleted;
|
||||||
|
|
||||||
|
|
||||||
SELECT COUNT(*) FROM social_notes WHERE NoteType='10';
|
SELECT COUNT(*) FROM social_notes WHERE NoteType='10';
|
||||||
|
|
||||||
|
|
||||||
|
----- SWAD 15.199 (2016/04/16) -----
|
||||||
|
|
||||||
|
SELECT degrees.DegCod,degrees.CtrCod,degrees.DegTypCod,degrees.Status,degrees.RequesterUsrCod,degrees.ShortName,degrees.FullName,degrees.WWW FROM degrees,courses,crs_usr WHERE degrees.DegCod=courses.CrsCod AND courses.CrsCod=crs_usr.CrsCod AND crs_usr.Role='3' ORDER BY degrees.ShortName;
|
||||||
|
|
|
@ -125,7 +125,6 @@
|
||||||
// TODO: Important!!!! E-mail should not be visible for not logged users
|
// TODO: Important!!!! E-mail should not be visible for not logged users
|
||||||
// TODO: Do not show e-mails of administrators and teachers in lists openly
|
// TODO: Do not show e-mails of administrators and teachers in lists openly
|
||||||
// TODO: Fix bug in marks reported by Francisco Ocaña
|
// TODO: Fix bug in marks reported by Francisco Ocaña
|
||||||
// TODO: In Statistics > Degrees, show only degrees with students
|
|
||||||
// TODO: Change PhotoAttribution in table centres from TEXT to VARCHAR(255) (check maximum length first)
|
// TODO: Change PhotoAttribution in table centres from TEXT to VARCHAR(255) (check maximum length first)
|
||||||
// TODO: In social refreshing via AJAX, an error occurs when session expirates
|
// TODO: In social refreshing via AJAX, an error occurs when session expirates
|
||||||
// TODO: Messages in msg_content_deleted older than a certain time should be deleted to ensure the protection of personal data
|
// TODO: Messages in msg_content_deleted older than a certain time should be deleted to ensure the protection of personal data
|
||||||
|
@ -136,13 +135,15 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.198 (2016-04-15)"
|
#define Log_PLATFORM_VERSION "SWAD 15.199 (2016-04-16)"
|
||||||
#define CSS_FILE "swad15.198.css"
|
#define CSS_FILE "swad15.198.css"
|
||||||
#define JS_FILE "swad15.197.js"
|
#define JS_FILE "swad15.197.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 15.199: Apr 16, 2016 In Statistics > Degrees, show only degrees with students.
|
||||||
|
Code optimization in number of courses in a degree. (199665 lines)
|
||||||
Version 15.198: Apr 15, 2016 Changes in layout related to image URL. (199646 lines)
|
Version 15.198: Apr 15, 2016 Changes in layout related to image URL. (199646 lines)
|
||||||
Version 15.197: Apr 15, 2016 Input field to enter image URL. (199518 lines)
|
Version 15.197: Apr 15, 2016 Input field to enter image URL. (199518 lines)
|
||||||
Version 15.196: Apr 15, 2016 Changes related to image URL. (199467 lines)
|
Version 15.196: Apr 15, 2016 Changes related to image URL. (199467 lines)
|
||||||
|
|
|
@ -465,11 +465,16 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
||||||
MYSQL_RES *mysql_resDeg;
|
MYSQL_RES *mysql_resDeg;
|
||||||
MYSQL_RES *mysql_resCrs;
|
MYSQL_RES *mysql_resCrs;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumCty,NumCtys;
|
unsigned NumCty;
|
||||||
unsigned NumIns,NumInss;
|
unsigned NumCtys;
|
||||||
unsigned NumCtr,NumCtrs;
|
unsigned NumIns;
|
||||||
unsigned NumDeg,NumDegs;
|
unsigned NumInss;
|
||||||
unsigned NumCrs,NumCrss;
|
unsigned NumCtr;
|
||||||
|
unsigned NumCtrs;
|
||||||
|
unsigned NumDeg;
|
||||||
|
unsigned NumDegs;
|
||||||
|
unsigned NumCrs;
|
||||||
|
unsigned NumCrss;
|
||||||
char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1];
|
char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1];
|
||||||
char PathRelRSSFile[PATH_MAX+1];
|
char PathRelRSSFile[PATH_MAX+1];
|
||||||
char ClassNormal[64];
|
char ClassNormal[64];
|
||||||
|
@ -943,7 +948,7 @@ void Crs_ReqEditCourses (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************** Create a list with courses in this degree ******************/
|
/*************** Create a list with courses in current degree ****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses)
|
static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses)
|
||||||
|
@ -951,7 +956,7 @@ static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses)
|
||||||
char Query[512];
|
char Query[512];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
unsigned NumCrss;
|
||||||
unsigned NumCrs;
|
unsigned NumCrs;
|
||||||
struct Course *Crs;
|
struct Course *Crs;
|
||||||
|
|
||||||
|
@ -974,20 +979,17 @@ static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get the courses of a degree");
|
NumCrss = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get the courses of a degree");
|
||||||
|
|
||||||
if (NumRows) // Courses found...
|
if (NumCrss) // Courses found...
|
||||||
{
|
{
|
||||||
// NumRows should be equal to Deg->NumCrss
|
|
||||||
Gbl.CurrentDeg.Deg.NumCrss = (unsigned) NumRows;
|
|
||||||
|
|
||||||
/***** Create list with courses in degree *****/
|
/***** Create list with courses in degree *****/
|
||||||
if ((Gbl.CurrentDeg.Deg.LstCrss = (struct Course *) calloc (NumRows,sizeof (struct Course))) == NULL)
|
if ((Gbl.CurrentDeg.Deg.LstCrss = (struct Course *) calloc ((size_t) NumCrss,sizeof (struct Course))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Not enough memory to store the courses of a degree.");
|
Lay_ShowErrorAndExit ("Not enough memory to store the courses of a degree.");
|
||||||
|
|
||||||
/***** Get the courses in degree *****/
|
/***** Get the courses in degree *****/
|
||||||
for (NumCrs = 0;
|
for (NumCrs = 0;
|
||||||
NumCrs < Gbl.CurrentDeg.Deg.NumCrss;
|
NumCrs < NumCrss;
|
||||||
NumCrs++)
|
NumCrs++)
|
||||||
{
|
{
|
||||||
Crs = &(Gbl.CurrentDeg.Deg.LstCrss[NumCrs]);
|
Crs = &(Gbl.CurrentDeg.Deg.LstCrss[NumCrs]);
|
||||||
|
@ -997,8 +999,8 @@ static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses)
|
||||||
Crs_GetDataOfCourseFromRow (Crs,row);
|
Crs_GetDataOfCourseFromRow (Crs,row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Gbl.CurrentDeg.Deg.NumCrss = 0;
|
Gbl.CurrentDeg.NumCrss = NumCrss;
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1015,7 +1017,6 @@ void Crs_FreeListCoursesInDegree (struct Degree *Deg)
|
||||||
/***** Free memory used by the list of courses in degree *****/
|
/***** Free memory used by the list of courses in degree *****/
|
||||||
free ((void *) Deg->LstCrss);
|
free ((void *) Deg->LstCrss);
|
||||||
Deg->LstCrss = NULL;
|
Deg->LstCrss = NULL;
|
||||||
Deg->NumCrss = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1129,7 +1130,7 @@ static void Crs_ListCourses (void)
|
||||||
Lay_StartRoundFrame (NULL,Gbl.Title,ICanEdit ? Crs_PutIconToEditCourses :
|
Lay_StartRoundFrame (NULL,Gbl.Title,ICanEdit ? Crs_PutIconToEditCourses :
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (Gbl.CurrentDeg.Deg.NumCrss) // There are courses in the current degree
|
if (Gbl.CurrentDeg.NumCrss) // There are courses in the current degree
|
||||||
{
|
{
|
||||||
/***** Start table *****/
|
/***** Start table *****/
|
||||||
fprintf (Gbl.F.Out,"<table class=\"FRAME_TABLE_MARGIN CELLS_PAD_2\">");
|
fprintf (Gbl.F.Out,"<table class=\"FRAME_TABLE_MARGIN CELLS_PAD_2\">");
|
||||||
|
@ -1153,8 +1154,8 @@ static void Crs_ListCourses (void)
|
||||||
if (ICanEdit)
|
if (ICanEdit)
|
||||||
{
|
{
|
||||||
Act_FormStart (ActEdiCrs);
|
Act_FormStart (ActEdiCrs);
|
||||||
Lay_PutConfirmButton (Gbl.CurrentDeg.Deg.NumCrss ? Txt_Create_another_course :
|
Lay_PutConfirmButton (Gbl.CurrentDeg.NumCrss ? Txt_Create_another_course :
|
||||||
Txt_Create_course);
|
Txt_Create_course);
|
||||||
Act_FormEnd ();
|
Act_FormEnd ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1195,7 +1196,7 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year)
|
||||||
|
|
||||||
/***** Write all the courses of this year *****/
|
/***** Write all the courses of this year *****/
|
||||||
for (NumCrs = 0;
|
for (NumCrs = 0;
|
||||||
NumCrs < Gbl.CurrentDeg.Deg.NumCrss;
|
NumCrs < Gbl.CurrentDeg.NumCrss;
|
||||||
NumCrs++)
|
NumCrs++)
|
||||||
{
|
{
|
||||||
Crs = &(Gbl.CurrentDeg.Deg.LstCrss[NumCrs]);
|
Crs = &(Gbl.CurrentDeg.Deg.LstCrss[NumCrs]);
|
||||||
|
@ -1292,7 +1293,7 @@ static void Crs_EditCourses (void)
|
||||||
Crs_PutFormToCreateCourse ();
|
Crs_PutFormToCreateCourse ();
|
||||||
|
|
||||||
/***** Forms to edit current courses *****/
|
/***** Forms to edit current courses *****/
|
||||||
if (Gbl.CurrentDeg.Deg.NumCrss)
|
if (Gbl.CurrentDeg.NumCrss)
|
||||||
Crs_ListCoursesForEdition ();
|
Crs_ListCoursesForEdition ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1328,7 +1329,7 @@ static void Crs_ListCoursesForEdition (void)
|
||||||
Year <= Deg_MAX_YEARS_PER_DEGREE;
|
Year <= Deg_MAX_YEARS_PER_DEGREE;
|
||||||
Year++)
|
Year++)
|
||||||
for (NumCrs = 0;
|
for (NumCrs = 0;
|
||||||
NumCrs < Gbl.CurrentDeg.Deg.NumCrss;
|
NumCrs < Gbl.CurrentDeg.NumCrss;
|
||||||
NumCrs++)
|
NumCrs++)
|
||||||
{
|
{
|
||||||
Crs = &(Gbl.CurrentDeg.Deg.LstCrss[NumCrs]);
|
Crs = &(Gbl.CurrentDeg.Deg.LstCrss[NumCrs]);
|
||||||
|
|
|
@ -433,7 +433,7 @@ static void Deg_Configuration (bool PrintView)
|
||||||
"</td>"
|
"</td>"
|
||||||
"</tr>",
|
"</tr>",
|
||||||
The_ClassForm[Gbl.Prefs.Theme],
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
Txt_Courses,Gbl.CurrentDeg.Deg.NumCrss);
|
Txt_Courses,Gbl.CurrentDeg.NumCrss);
|
||||||
|
|
||||||
/***** Number of teachers *****/
|
/***** Number of teachers *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
|
@ -890,7 +890,7 @@ void Deg_InitCurrentCourse (void)
|
||||||
/***** If numerical degree code is available, get degree data *****/
|
/***** If numerical degree code is available, get degree data *****/
|
||||||
if (Gbl.CurrentDeg.Deg.DegCod > 0)
|
if (Gbl.CurrentDeg.Deg.DegCod > 0)
|
||||||
{
|
{
|
||||||
if (Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg)) // Degree found
|
if (Deg_GetDataOfDegreeByCod (&Gbl.CurrentDeg.Deg)) // Degree found
|
||||||
{
|
{
|
||||||
Gbl.CurrentCtr.Ctr.CtrCod = Gbl.CurrentDeg.Deg.CtrCod;
|
Gbl.CurrentCtr.Ctr.CtrCod = Gbl.CurrentDeg.Deg.CtrCod;
|
||||||
Gbl.CurrentDegTyp.DegTyp.DegTypCod = Gbl.CurrentDeg.Deg.DegTypCod;
|
Gbl.CurrentDegTyp.DegTyp.DegTypCod = Gbl.CurrentDeg.Deg.DegTypCod;
|
||||||
|
@ -1050,6 +1050,7 @@ static void Deg_ListDegreesForEdition (void)
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
bool ICanEdit;
|
bool ICanEdit;
|
||||||
Deg_StatusTxt_t StatusTxt;
|
Deg_StatusTxt_t StatusTxt;
|
||||||
|
unsigned NumCrss;
|
||||||
|
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
Usr_UsrDataConstructor (&UsrDat);
|
Usr_UsrDataConstructor (&UsrDat);
|
||||||
|
@ -1067,12 +1068,14 @@ static void Deg_ListDegreesForEdition (void)
|
||||||
{
|
{
|
||||||
Deg = &(Gbl.CurrentCtr.LstDegs[NumDeg]);
|
Deg = &(Gbl.CurrentCtr.LstDegs[NumDeg]);
|
||||||
|
|
||||||
|
NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod);
|
||||||
|
|
||||||
ICanEdit = Deg_CheckIfICanEdit (Deg);
|
ICanEdit = Deg_CheckIfICanEdit (Deg);
|
||||||
|
|
||||||
/* Put icon to remove degree */
|
/* Put icon to remove degree */
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"BM\">");
|
"<td class=\"BM\">");
|
||||||
if (Deg->NumCrss || // Degree has courses ==> deletion forbidden
|
if (NumCrss || // Degree has courses ==> deletion forbidden
|
||||||
!ICanEdit)
|
!ICanEdit)
|
||||||
Lay_PutIconRemovalNotAllowed ();
|
Lay_PutIconRemovalNotAllowed ();
|
||||||
else
|
else
|
||||||
|
@ -1216,7 +1219,7 @@ static void Deg_ListDegreesForEdition (void)
|
||||||
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">"
|
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||||
"%u"
|
"%u"
|
||||||
"</td>",
|
"</td>",
|
||||||
Deg->NumCrss);
|
NumCrss);
|
||||||
|
|
||||||
/* Degree status */
|
/* Degree status */
|
||||||
StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status);
|
StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status);
|
||||||
|
@ -1651,6 +1654,10 @@ static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg)
|
||||||
const char *TxtClassStrong;
|
const char *TxtClassStrong;
|
||||||
const char *BgColor;
|
const char *BgColor;
|
||||||
Crs_StatusTxt_t StatusTxt;
|
Crs_StatusTxt_t StatusTxt;
|
||||||
|
unsigned NumCrss;
|
||||||
|
|
||||||
|
/***** Get number of courses in this degree *****/
|
||||||
|
NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod);
|
||||||
|
|
||||||
/***** Get data of type of degree of this degree *****/
|
/***** Get data of type of degree of this degree *****/
|
||||||
DegTyp.DegTypCod = Deg->DegTypCod;
|
DegTyp.DegTypCod = Deg->DegTypCod;
|
||||||
|
@ -1679,12 +1686,12 @@ static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg)
|
||||||
"</td>",
|
"</td>",
|
||||||
BgColor,
|
BgColor,
|
||||||
Gbl.Prefs.IconsURL,
|
Gbl.Prefs.IconsURL,
|
||||||
Deg->NumCrss ? "ok_green" :
|
NumCrss ? "ok_green" :
|
||||||
"tr",
|
"tr",
|
||||||
Deg->NumCrss ? Txt_DEGREE_With_courses :
|
NumCrss ? Txt_DEGREE_With_courses :
|
||||||
Txt_DEGREE_Without_courses,
|
Txt_DEGREE_Without_courses,
|
||||||
Deg->NumCrss ? Txt_DEGREE_With_courses :
|
NumCrss ? Txt_DEGREE_With_courses :
|
||||||
Txt_DEGREE_Without_courses);
|
Txt_DEGREE_Without_courses);
|
||||||
|
|
||||||
/***** Number of degree in this list *****/
|
/***** Number of degree in this list *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
|
@ -1709,7 +1716,7 @@ static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg)
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
"%u"
|
"%u"
|
||||||
"</td>",
|
"</td>",
|
||||||
TxtClassNormal,BgColor,Deg->NumCrss);
|
TxtClassNormal,BgColor,NumCrss);
|
||||||
|
|
||||||
/***** Degree status *****/
|
/***** Degree status *****/
|
||||||
StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status);
|
StatusTxt = Deg_GetStatusTxtFromStatusBits (Deg->Status);
|
||||||
|
@ -1781,10 +1788,10 @@ void Deg_EditDegrees (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************* Create a list with all the degrees ********************/
|
/********** Create a list with all the degrees that have students ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Deg_GetListAllDegs (void)
|
void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs)
|
||||||
{
|
{
|
||||||
char Query[1024];
|
char Query[1024];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
@ -1792,29 +1799,35 @@ void Deg_GetListAllDegs (void)
|
||||||
unsigned NumDeg;
|
unsigned NumDeg;
|
||||||
|
|
||||||
/***** Get degrees admin by me from database *****/
|
/***** Get degrees admin by me from database *****/
|
||||||
sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod,"
|
sprintf (Query,"SELECT DISTINCTROW degrees.DegCod,degrees.CtrCod,"
|
||||||
"ShortName,FullName,WWW"
|
"degrees.DegTypCod,degrees.Status,degrees.RequesterUsrCod,"
|
||||||
" FROM degrees ORDER BY FullName");
|
"degrees.ShortName,degrees.FullName,degrees.WWW"
|
||||||
Gbl.Degs.AllDegs.Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees admin by you");
|
" FROM degrees,courses,crs_usr"
|
||||||
|
" WHERE degrees.DegCod=courses.CrsCod"
|
||||||
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
|
" AND crs_usr.Role='%u'"
|
||||||
|
" ORDER BY degrees.ShortName",
|
||||||
|
(unsigned) Rol_STUDENT);
|
||||||
|
Degs->Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees admin by you");
|
||||||
|
|
||||||
if (Gbl.Degs.AllDegs.Num) // Degrees found...
|
if (Degs->Num) // Degrees found...
|
||||||
{
|
{
|
||||||
/***** Create list with degrees *****/
|
/***** Create list with degrees *****/
|
||||||
if ((Gbl.Degs.AllDegs.Lst = (struct Degree *) calloc (Gbl.Degs.AllDegs.Num,sizeof (struct Degree))) == NULL)
|
if ((Degs->Lst = (struct Degree *) calloc (Degs->Num,sizeof (struct Degree))) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Not enough memory to store degrees admin by you.");
|
Lay_ShowErrorAndExit ("Not enough memory to store degrees admin by you.");
|
||||||
|
|
||||||
/***** Get the degrees *****/
|
/***** Get the degrees *****/
|
||||||
for (NumDeg = 0;
|
for (NumDeg = 0;
|
||||||
NumDeg < Gbl.Degs.AllDegs.Num;
|
NumDeg < Degs->Num;
|
||||||
NumDeg++)
|
NumDeg++)
|
||||||
{
|
{
|
||||||
/* Get next degree */
|
/* Get next degree */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
Deg_GetDataOfDegreeFromRow (&(Gbl.Degs.AllDegs.Lst[NumDeg]),row);
|
Deg_GetDataOfDegreeFromRow (&(Degs->Lst[NumDeg]),row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Gbl.Degs.AllDegs.Lst = NULL;
|
Degs->Lst = NULL;
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -1824,13 +1837,13 @@ void Deg_GetListAllDegs (void)
|
||||||
/*********************** Free list of all the degrees ************************/
|
/*********************** Free list of all the degrees ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Deg_FreeListAllDegs (void)
|
void Deg_FreeListDegs (struct ListDegrees *Degs)
|
||||||
{
|
{
|
||||||
if (Gbl.Degs.AllDegs.Lst)
|
if (Degs->Lst)
|
||||||
{
|
{
|
||||||
free ((void *) Gbl.Degs.AllDegs.Lst);
|
free ((void *) Degs->Lst);
|
||||||
Gbl.Degs.AllDegs.Lst = NULL;
|
Degs->Lst = NULL;
|
||||||
Gbl.Degs.AllDegs.Num = 0;
|
Degs->Num = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2063,7 +2076,7 @@ void Deg_RemoveDegree (void)
|
||||||
Deg_GetDataOfDegreeByCod (&Deg);
|
Deg_GetDataOfDegreeByCod (&Deg);
|
||||||
|
|
||||||
/***** Check if this degree has courses *****/
|
/***** Check if this degree has courses *****/
|
||||||
if (Deg.NumCrss) // Degree has courses ==> don't remove
|
if (Crs_GetNumCrssInDeg (Deg.DegCod)) // Degree has courses ==> don't remove
|
||||||
Lay_ShowAlert (Lay_WARNING,Txt_To_remove_a_degree_you_must_first_remove_all_courses_in_the_degree);
|
Lay_ShowAlert (Lay_WARNING,Txt_To_remove_a_degree_you_must_first_remove_all_courses_in_the_degree);
|
||||||
else // Degree has no courses ==> remove it
|
else // Degree has no courses ==> remove it
|
||||||
{
|
{
|
||||||
|
@ -2134,7 +2147,6 @@ bool Deg_GetDataOfDegreeByCod (struct Degree *Deg)
|
||||||
Deg->ShortName[0] = '\0';
|
Deg->ShortName[0] = '\0';
|
||||||
Deg->FullName[0] = '\0';
|
Deg->FullName[0] = '\0';
|
||||||
Deg->WWW[0] = '\0';
|
Deg->WWW[0] = '\0';
|
||||||
Deg->NumCrss = 0;
|
|
||||||
Deg->LstCrss = NULL;
|
Deg->LstCrss = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2164,7 +2176,6 @@ bool Deg_GetDataOfDegreeByCod (struct Degree *Deg)
|
||||||
Deg->ShortName[0] = '\0';
|
Deg->ShortName[0] = '\0';
|
||||||
Deg->FullName[0] = '\0';
|
Deg->FullName[0] = '\0';
|
||||||
Deg->WWW[0] = '\0';
|
Deg->WWW[0] = '\0';
|
||||||
Deg->NumCrss = 0;
|
|
||||||
Deg->LstCrss = NULL;
|
Deg->LstCrss = NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2208,9 +2219,6 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row)
|
||||||
|
|
||||||
/***** Get WWW (row[7]) *****/
|
/***** Get WWW (row[7]) *****/
|
||||||
strcpy (Deg->WWW,row[7]);
|
strcpy (Deg->WWW,row[7]);
|
||||||
|
|
||||||
/***** Get number of courses *****/
|
|
||||||
Deg->NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -76,10 +76,15 @@ struct Degree
|
||||||
char ShortName[Deg_MAX_LENGTH_DEGREE_SHORT_NAME+1]; // Short name of degree
|
char ShortName[Deg_MAX_LENGTH_DEGREE_SHORT_NAME+1]; // Short name of degree
|
||||||
char FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; // Full name of degree
|
char FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; // Full name of degree
|
||||||
char WWW[Cns_MAX_LENGTH_WWW+1];
|
char WWW[Cns_MAX_LENGTH_WWW+1];
|
||||||
unsigned NumCrss; // Number of courses in the degree
|
|
||||||
struct Course *LstCrss; // List of courses in this degree
|
struct Course *LstCrss; // List of courses in this degree
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ListDegrees
|
||||||
|
{
|
||||||
|
unsigned Num; // Number of degrees
|
||||||
|
struct Degree *Lst; // List of degrees
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -104,8 +109,8 @@ unsigned Deg_ConvStrToYear (const char *StrYear);
|
||||||
|
|
||||||
void Deg_EditDegrees (void);
|
void Deg_EditDegrees (void);
|
||||||
|
|
||||||
void Deg_GetListAllDegs (void);
|
void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs);
|
||||||
void Deg_FreeListAllDegs (void);
|
void Deg_FreeListDegs (struct ListDegrees *Degs);
|
||||||
void Deg_GetListDegsAdminByMe (void);
|
void Deg_GetListDegsAdminByMe (void);
|
||||||
void Deg_FreeListMyAdminDegs (void);
|
void Deg_FreeListMyAdminDegs (void);
|
||||||
|
|
||||||
|
|
|
@ -297,9 +297,6 @@ void Gbl_InitializeGlobals (void)
|
||||||
Gbl.Degs.DegTypes.Num = 0;
|
Gbl.Degs.DegTypes.Num = 0;
|
||||||
Gbl.Degs.DegTypes.Lst = NULL;
|
Gbl.Degs.DegTypes.Lst = NULL;
|
||||||
|
|
||||||
Gbl.Degs.AllDegs.Num = 0;
|
|
||||||
Gbl.Degs.AllDegs.Lst = NULL;
|
|
||||||
|
|
||||||
Gbl.Degs.EditingDegTyp.DegTypCod = -1L;
|
Gbl.Degs.EditingDegTyp.DegTypCod = -1L;
|
||||||
Gbl.Degs.EditingDegTyp.DegTypName[0] = '\0';
|
Gbl.Degs.EditingDegTyp.DegTypName[0] = '\0';
|
||||||
|
|
||||||
|
@ -307,7 +304,6 @@ void Gbl_InitializeGlobals (void)
|
||||||
Gbl.Degs.EditingDeg.ShortName[0] = '\0';
|
Gbl.Degs.EditingDeg.ShortName[0] = '\0';
|
||||||
Gbl.Degs.EditingDeg.FullName[0] = '\0';
|
Gbl.Degs.EditingDeg.FullName[0] = '\0';
|
||||||
Gbl.Degs.EditingDeg.WWW[0] = '\0';
|
Gbl.Degs.EditingDeg.WWW[0] = '\0';
|
||||||
Gbl.Degs.EditingDeg.NumCrss = 0;
|
|
||||||
Gbl.Degs.EditingDeg.LstCrss = NULL;
|
Gbl.Degs.EditingDeg.LstCrss = NULL;
|
||||||
|
|
||||||
Gbl.Degs.EditingCrs.CrsCod = -1L;
|
Gbl.Degs.EditingCrs.CrsCod = -1L;
|
||||||
|
@ -455,7 +451,6 @@ void Gbl_Cleanup (void)
|
||||||
Grp_FreeListCodSelectedGrps ();
|
Grp_FreeListCodSelectedGrps ();
|
||||||
Crs_FreeListCoursesInDegree (&Gbl.Degs.EditingDeg);
|
Crs_FreeListCoursesInDegree (&Gbl.Degs.EditingDeg);
|
||||||
Deg_FreeListMyAdminDegs ();
|
Deg_FreeListMyAdminDegs ();
|
||||||
Deg_FreeListAllDegs ();
|
|
||||||
DT_FreeListDegreeTypes ();
|
DT_FreeListDegreeTypes ();
|
||||||
Ins_FreeListInstitutions ();
|
Ins_FreeListInstitutions ();
|
||||||
Ctr_FreeListCentres ();
|
Ctr_FreeListCentres ();
|
||||||
|
|
|
@ -261,11 +261,6 @@ struct Globals
|
||||||
unsigned Num; // Number of degree types
|
unsigned Num; // Number of degree types
|
||||||
struct DegreeType *Lst; // List of degree types
|
struct DegreeType *Lst; // List of degree types
|
||||||
} DegTypes;
|
} DegTypes;
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned Num; // Number of degrees
|
|
||||||
struct Degree *Lst; // List of degrees
|
|
||||||
} AllDegs;
|
|
||||||
struct DegreeType EditingDegTyp;
|
struct DegreeType EditingDegTyp;
|
||||||
struct Degree EditingDeg;
|
struct Degree EditingDeg;
|
||||||
struct Course EditingCrs;
|
struct Course EditingCrs;
|
||||||
|
@ -432,6 +427,7 @@ struct Globals
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
struct Degree Deg;
|
struct Degree Deg;
|
||||||
|
unsigned NumCrss;
|
||||||
} CurrentDeg;
|
} CurrentDeg;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|
60
swad_photo.c
60
swad_photo.c
|
@ -1232,11 +1232,18 @@ static long Pho_GetDegWithAvgPhotoLeastRecentlyUpdated (void)
|
||||||
/***** Delete all the degrees in sta_degrees table not present in degrees table *****/
|
/***** Delete all the degrees in sta_degrees table not present in degrees table *****/
|
||||||
Pho_RemoveObsoleteStatDegrees ();
|
Pho_RemoveObsoleteStatDegrees ();
|
||||||
|
|
||||||
/***** 1. If any degree is not in table, choose it as least recently updated *****/
|
/***** 1. If a degree is not in table of computed degrees,
|
||||||
/* Get degrees from database */
|
choose it as least recently updated *****/
|
||||||
sprintf (Query,"SELECT DegCod FROM degrees"
|
/* Get one degree with students not yet computed */
|
||||||
" WHERE DegCod NOT IN (SELECT DISTINCT DegCod FROM sta_degrees)"
|
sprintf (Query,"SELECT DISTINCT degrees.DegCod"
|
||||||
" LIMIT 1");
|
" FROM degrees,courses,crs_usr"
|
||||||
|
" WHERE degrees.DegCod=courses.CrsCod"
|
||||||
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
|
" AND crs_usr.Role='%u'"
|
||||||
|
" AND degrees.DegCod NOT IN"
|
||||||
|
" (SELECT DISTINCT DegCod FROM sta_degrees)"
|
||||||
|
" LIMIT 1",
|
||||||
|
(unsigned) Rol_STUDENT);
|
||||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees");
|
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees");
|
||||||
|
|
||||||
/* If number of rows is 1, then get the degree code */
|
/* If number of rows is 1, then get the degree code */
|
||||||
|
@ -1254,19 +1261,25 @@ static long Pho_GetDegWithAvgPhotoLeastRecentlyUpdated (void)
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** 2. If all the degrees are in table, choose the least recently updated *****/
|
/***** 2. If all the degrees are in table,
|
||||||
|
choose the least recently updated that has students *****/
|
||||||
/* Get degrees from database */
|
/* Get degrees from database */
|
||||||
sprintf (Query,"SELECT DegCod FROM sta_degrees"
|
sprintf (Query,"SELECT sta_degrees.DegCod"
|
||||||
" WHERE TimeAvgPhoto<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')"
|
" FROM sta_degrees,courses,crs_usr"
|
||||||
" ORDER BY TimeAvgPhoto LIMIT 1",
|
" WHERE sta_degrees.TimeAvgPhoto<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')"
|
||||||
Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO);
|
" AND sta_degrees.DegCod=courses.CrsCod"
|
||||||
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
|
" AND crs_usr.Role='%u'"
|
||||||
|
" ORDER BY sta_degrees.TimeAvgPhoto LIMIT 1",
|
||||||
|
Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO,
|
||||||
|
(unsigned) Rol_STUDENT);
|
||||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees");
|
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees");
|
||||||
|
|
||||||
/* If number of rows is 1, then get the degree code */
|
/* If number of rows is 1, then get the degree code */
|
||||||
if (NumRows == 1)
|
if (NumRows == 1)
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get degree code (row[0]) */
|
/* Get degree code (row[0]) */
|
||||||
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||||
|
@ -1787,6 +1800,7 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
|
||||||
extern const char *Txt_Calculate_average_photo_of_THE_DEGREE_X;
|
extern const char *Txt_Calculate_average_photo_of_THE_DEGREE_X;
|
||||||
extern const char *Txt_unknown_TIME;
|
extern const char *Txt_unknown_TIME;
|
||||||
extern const char *Txt_time;
|
extern const char *Txt_time;
|
||||||
|
struct ListDegrees Degs;
|
||||||
unsigned NumDeg;
|
unsigned NumDeg;
|
||||||
struct Degree Deg;
|
struct Degree Deg;
|
||||||
long EstimatedTimeToComputeAvgPhotoInMicroseconds;
|
long EstimatedTimeToComputeAvgPhotoInMicroseconds;
|
||||||
|
@ -1795,7 +1809,7 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
|
||||||
if ((Deg.DegCod = Pho_GetDegWithAvgPhotoLeastRecentlyUpdated ()) > 0)
|
if ((Deg.DegCod = Pho_GetDegWithAvgPhotoLeastRecentlyUpdated ()) > 0)
|
||||||
{
|
{
|
||||||
/***** Get list of all the degrees *****/
|
/***** Get list of all the degrees *****/
|
||||||
Deg_GetListAllDegs ();
|
Deg_GetListAllDegsWithStds (&Degs);
|
||||||
|
|
||||||
/***** Get data of the degree from database *****/
|
/***** Get data of the degree from database *****/
|
||||||
Deg_GetDataOfDegreeByCod (&Deg);
|
Deg_GetDataOfDegreeByCod (&Deg);
|
||||||
|
@ -1814,26 +1828,26 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
|
||||||
Act_LinkFormSubmitAnimated (Txt_Calculate_average_photo_of_a_degree,The_ClassFormBold[Gbl.Prefs.Theme]);
|
Act_LinkFormSubmitAnimated (Txt_Calculate_average_photo_of_a_degree,The_ClassFormBold[Gbl.Prefs.Theme]);
|
||||||
Lay_PutCalculateIconWithText (Txt_Calculate_average_photo_of_a_degree,Txt_Calculate_average_photo_of_THE_DEGREE_X);
|
Lay_PutCalculateIconWithText (Txt_Calculate_average_photo_of_a_degree,Txt_Calculate_average_photo_of_THE_DEGREE_X);
|
||||||
|
|
||||||
/***** Put selector with all the degrees *****/
|
/***** Put selector with all the degrees with students *****/
|
||||||
fprintf (Gbl.F.Out,"<select name=\"OthDegCod\">");
|
fprintf (Gbl.F.Out,"<select name=\"OthDegCod\">");
|
||||||
for (NumDeg = 0;
|
for (NumDeg = 0;
|
||||||
NumDeg < Gbl.Degs.AllDegs.Num;
|
NumDeg < Degs.Num;
|
||||||
NumDeg++)
|
NumDeg++)
|
||||||
{
|
{
|
||||||
/* Get time to compute average photo of this degree */
|
/* Get time to compute average photo of this degree */
|
||||||
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Gbl.Degs.AllDegs.Lst[NumDeg].DegCod);
|
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod);
|
||||||
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
|
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
|
||||||
strcpy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME);
|
strcpy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME);
|
||||||
else
|
else
|
||||||
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,EstimatedTimeToComputeAvgPhotoInMicroseconds);
|
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,EstimatedTimeToComputeAvgPhotoInMicroseconds);
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s (%s: %s)</option>",
|
fprintf (Gbl.F.Out,"<option value=\"%ld\"%s>%s (%s: %s)</option>",
|
||||||
Gbl.Degs.AllDegs.Lst[NumDeg].DegCod,
|
Degs.Lst[NumDeg].DegCod,
|
||||||
Gbl.Degs.AllDegs.Lst[NumDeg].DegCod == Deg.DegCod ? " selected=\"selected\"" :
|
Degs.Lst[NumDeg].DegCod == Deg.DegCod ? " selected=\"selected\"" :
|
||||||
((Pho_GetTimeAvgPhotoWasComputed (Gbl.Degs.AllDegs.Lst[NumDeg].DegCod) >=
|
((Pho_GetTimeAvgPhotoWasComputed (Degs.Lst[NumDeg].DegCod) >=
|
||||||
Gbl.StartExecutionTimeUTC - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO) ? " disabled=\"disabled\"" :
|
Gbl.StartExecutionTimeUTC - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO) ? " disabled=\"disabled\"" :
|
||||||
""),
|
""),
|
||||||
Gbl.Degs.AllDegs.Lst[NumDeg].ShortName,
|
Degs.Lst[NumDeg].ShortName,
|
||||||
Txt_time,
|
Txt_time,
|
||||||
StrEstimatedTimeToComputeAvgPhoto);
|
StrEstimatedTimeToComputeAvgPhoto);
|
||||||
}
|
}
|
||||||
|
@ -1843,8 +1857,8 @@ static void Pho_PutLinkToCalculateDegreeStats (void)
|
||||||
Act_FormEnd ();
|
Act_FormEnd ();
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
|
|
||||||
/***** Free list of all the degrees *****/
|
/***** Free list of all the degrees with students *****/
|
||||||
Deg_FreeListAllDegs ();
|
Deg_FreeListDegs (&Degs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user