swad-core/swad_indicator.c

1675 lines
63 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_indicators.c: indicators of courses
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
2018-10-22 12:36:35 +02:00
#define _GNU_SOURCE // For asprintf
2014-12-01 23:55:08 +01:00
#include <linux/stddef.h> // For NULL
2018-10-22 12:36:35 +02:00
#include <stdio.h> // For aprintf
2014-12-01 23:55:08 +01:00
#include <mysql/mysql.h> // To access MySQL databases
#include "swad_action.h"
2017-06-10 21:38:10 +02:00
#include "swad_box.h"
2014-12-01 23:55:08 +01:00
#include "swad_database.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
#include "swad_forum.h"
2014-12-01 23:55:08 +01:00
#include "swad_global.h"
#include "swad_indicator.h"
#include "swad_parameter.h"
2017-06-11 20:09:59 +02:00
#include "swad_table.h"
2014-12-01 23:55:08 +01:00
#include "swad_theme.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/*************************** Internal constants ******************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Internal types ******************************/
/*****************************************************************************/
typedef enum
{
Ind_INDICATORS_BRIEF,
Ind_INDICATORS_FULL,
} Ind_IndicatorsLayout_t;
/*****************************************************************************/
/***************************** Internal prototypes ***************************/
/*****************************************************************************/
2016-06-09 18:04:18 +02:00
static void Ind_GetParamsIndicators (void);
2016-06-08 14:14:31 +02:00
static void Ind_GetParamNumIndicators (void);
2014-12-01 23:55:08 +01:00
static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res);
static bool Ind_GetIfShowBigList (unsigned NumCrss);
static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss);
2017-05-25 14:25:22 +02:00
static void Ind_PutParamsConfirmIWantToSeeBigList (void);
2016-06-04 19:16:21 +02:00
2017-01-28 15:58:46 +01:00
static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS],
2016-06-04 19:16:21 +02:00
unsigned NumCrss,MYSQL_RES *mysql_res);
2017-01-28 15:58:46 +01:00
static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS],
2016-06-08 13:19:17 +02:00
unsigned NumCrss,bool PutForm);
2016-06-04 19:16:21 +02:00
static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t IndicatorsLayout,
unsigned NumCrss,MYSQL_RES *mysql_res);
2016-06-10 10:22:22 +02:00
static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod);
2016-06-09 14:00:10 +02:00
static void Ind_StoreIndicatorsCrsIntoDB (long CrsCod,unsigned NumIndicators);
2016-06-08 18:41:32 +02:00
static unsigned long Ind_GetNumFilesInDocumZonesOfCrsFromDB (long CrsCod);
static unsigned long Ind_GetNumFilesInShareZonesOfCrsFromDB (long CrsCod);
static unsigned long Ind_GetNumFilesInAssigZonesOfCrsFromDB (long CrsCod);
static unsigned long Ind_GetNumFilesInWorksZonesOfCrsFromDB (long CrsCod);
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************* Request showing statistics of courses *******************/
/*****************************************************************************/
void Ind_ReqIndicatorsCourses (void)
{
2017-12-19 18:41:19 +01:00
extern const char *Hlp_ANALYTICS_Indicators;
2019-02-22 21:47:50 +01:00
extern const char *The_ClassFormInBox[The_NUM_THEMES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Scope;
extern const char *Txt_Types_of_degree;
extern const char *Txt_only_if_the_scope_is_X;
extern const char *Txt_Department;
2017-10-10 10:46:35 +02:00
extern const char *Txt_Any_department;
2014-12-01 23:55:08 +01:00
extern const char *Txt_No_of_indicators;
extern const char *Txt_Indicators_of_courses;
extern const char *Txt_Show_more_details;
MYSQL_RES *mysql_res;
unsigned NumCrss;
2017-01-28 15:58:46 +01:00
unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS];
2016-06-04 19:16:21 +02:00
unsigned NumCrssToList;
2016-06-08 14:14:31 +02:00
unsigned Ind;
2014-12-01 23:55:08 +01:00
2016-06-09 17:19:10 +02:00
/***** Get parameters *****/
2016-06-09 18:04:18 +02:00
Ind_GetParamsIndicators ();
2016-06-09 17:56:57 +02:00
2017-06-12 14:16:33 +02:00
/***** Start box *****/
2017-06-10 21:38:10 +02:00
Box_StartBox (NULL,Txt_Indicators_of_courses,NULL,
2017-12-19 18:41:19 +01:00
Hlp_ANALYTICS_Indicators,Box_NOT_CLOSABLE);
2015-03-24 19:41:54 +01:00
2014-12-01 23:55:08 +01:00
/***** Form to update indicators *****/
2017-05-01 10:22:16 +02:00
/* Start form and table */
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActReqStaCrs);
2017-06-11 20:09:59 +02:00
Tbl_StartTableWide (2);
2014-12-01 23:55:08 +01:00
2016-06-08 15:03:06 +02:00
/* Scope */
fprintf (Gbl.F.Out,"<tr>"
2016-03-27 21:36:52 +02:00
"<td class=\"RIGHT_MIDDLE\">"
2016-12-20 02:18:50 +01:00
"<label for=\"ScopeInd\" class=\"%s\">%s:</label>"
2014-12-23 01:36:58 +01:00
"</td>"
2015-08-03 20:22:41 +02:00
"<td class=\"LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Scope);
2016-06-24 20:34:58 +02:00
Sco_PutSelectorScope ("ScopeInd",true);
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
/* Compute stats for a type of degree */
fprintf (Gbl.F.Out,"<tr>"
2016-03-27 21:36:52 +02:00
"<td class=\"RIGHT_MIDDLE\">"
2016-12-20 02:18:50 +01:00
"<label for=\"OthDegTypCod\" class=\"%s\">%s:</label>"
2014-12-23 01:36:58 +01:00
"</td>"
2015-08-03 20:22:41 +02:00
"<td class=\"DAT LEFT_MIDDLE\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Types_of_degree);
2016-03-20 22:31:57 +01:00
DT_WriteSelectorDegreeTypes ();
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out," (");
fprintf (Gbl.F.Out,Txt_only_if_the_scope_is_X,
Cfg_PLATFORM_SHORT_NAME);
fprintf (Gbl.F.Out,")</td>"
"</tr>");
/* Compute stats for courses with teachers belonging to any department or to a particular departament? */
fprintf (Gbl.F.Out,"<tr>"
2016-03-27 21:36:52 +02:00
"<td class=\"RIGHT_MIDDLE\">"
2017-10-10 12:37:09 +02:00
"<label for=\"%s\" class=\"%s\">%s:</label>"
2014-12-23 01:36:58 +01:00
"</td>"
2015-08-03 20:22:41 +02:00
"<td class=\"LEFT_MIDDLE\">",
2017-10-10 12:37:09 +02:00
Dpt_PARAM_DPT_COD_NAME,
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],Txt_Department);
2019-04-03 20:57:04 +02:00
Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current insitution
2017-10-10 10:46:35 +02:00
Gbl.Stat.DptCod, // Selected department
2018-10-08 14:11:21 +02:00
"INDICATORS_INPUT", // Selector class
2017-10-10 10:46:35 +02:00
-1L, // First option
Txt_Any_department, // Text when no department selected
true); // Submit on change
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"</td>"
"</tr>");
2016-06-08 15:03:06 +02:00
/***** Get courses from database *****/
/* The result will contain courses with any number of indicators
If Gbl.Stat.NumIndicators < 0 ==> all courses in result will be listed
If Gbl.Stat.NumIndicators >= 0 ==> only those courses in result
with Gbl.Stat.NumIndicators set to yes
will be listed */
NumCrss = Ind_GetTableOfCourses (&mysql_res);
/***** Get vector with numbers of courses with 0, 1, 2... indicators set to yes *****/
Ind_GetNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,mysql_res);
2016-06-08 13:26:19 +02:00
/* Selection of the number of indicators */
2014-12-01 23:55:08 +01:00
fprintf (Gbl.F.Out,"<tr>"
2016-12-20 02:18:50 +01:00
"<td class=\"RIGHT_TOP %s\">"
"%s:"
2014-12-23 01:36:58 +01:00
"</td>"
2016-06-08 13:19:17 +02:00
"<td class=\"LEFT_TOP\">",
2019-02-22 21:47:50 +01:00
The_ClassFormInBox[Gbl.Prefs.Theme],
2016-12-20 02:18:50 +01:00
Txt_No_of_indicators);
2016-06-08 13:19:17 +02:00
Ind_ShowNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,true);
fprintf (Gbl.F.Out,"</td>"
2015-03-24 19:41:54 +01:00
"</tr>");
2014-12-01 23:55:08 +01:00
2017-05-13 00:08:22 +02:00
/* End table and form */
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
2016-06-08 13:19:17 +02:00
/***** Show the stats of courses *****/
2016-06-08 14:14:31 +02:00
for (Ind = 0, NumCrssToList = 0;
Ind <= Ind_NUM_INDICATORS;
Ind++)
if (Gbl.Stat.IndicatorsSelected[Ind])
NumCrssToList += NumCrssWithIndicatorYes[Ind];
2016-06-04 19:16:21 +02:00
if (Ind_GetIfShowBigList (NumCrssToList))
2014-12-01 23:55:08 +01:00
{
/* Show table */
Ind_ShowTableOfCoursesWithIndicators (Ind_INDICATORS_BRIEF,NumCrss,mysql_res);
/* Button to show more details */
2018-11-09 20:47:39 +01:00
Frm_StartForm (ActSeeAllStaCrs);
2016-06-24 20:34:58 +02:00
Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current);
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamLong ("OthDegTypCod",Gbl.Stat.DegTypCod);
2017-10-10 12:37:09 +02:00
Par_PutHiddenParamLong (Dpt_PARAM_DPT_COD_NAME,Gbl.Stat.DptCod);
2016-06-08 14:14:31 +02:00
if (Gbl.Stat.StrIndicatorsSelected[0])
Par_PutHiddenParamString ("Indicators",Gbl.Stat.StrIndicatorsSelected);
2017-06-11 19:02:40 +02:00
Btn_PutConfirmButton (Txt_Show_more_details);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2014-12-01 23:55:08 +01:00
}
2017-06-12 14:16:33 +02:00
/***** End box *****/
2017-06-10 21:38:10 +02:00
Box_EndBox ();
2015-03-24 19:41:54 +01:00
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
2016-06-09 18:04:18 +02:00
/************* Get parameters related to indicators of courses ***************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-06-09 18:04:18 +02:00
static void Ind_GetParamsIndicators (void)
2014-12-01 23:55:08 +01:00
{
2016-06-09 18:04:18 +02:00
/***** Get scope *****/
2019-04-03 20:57:04 +02:00
Gbl.Scope.Allowed = 1 << Hie_SYS |
1 << Hie_CTY |
1 << Hie_INS |
1 << Hie_CTR |
1 << Hie_DEG |
1 << Hie_CRS;
Gbl.Scope.Default = Hie_CRS;
2016-06-24 20:34:58 +02:00
Sco_GetScope ("ScopeInd");
2014-12-01 23:55:08 +01:00
/***** Get degree type code *****/
2019-04-03 20:57:04 +02:00
Gbl.Stat.DegTypCod = (Gbl.Scope.Current == Hie_SYS) ?
2017-05-31 21:05:59 +02:00
DT_GetAndCheckParamOtherDegTypCod (-1L) : // -1L (any degree type) is allowed here
-1L;
2014-12-01 23:55:08 +01:00
/***** Get department code *****/
2017-05-31 21:05:59 +02:00
Gbl.Stat.DptCod = Dpt_GetAndCheckParamDptCod (-1L); // -1L (any department) is allowed here
2014-12-01 23:55:08 +01:00
/***** Get number of indicators *****/
2016-06-08 14:14:31 +02:00
Ind_GetParamNumIndicators ();
2016-06-09 18:04:18 +02:00
}
/*****************************************************************************/
/*********************** Show statistics of courses **************************/
/*****************************************************************************/
void Ind_ShowIndicatorsCourses (void)
{
MYSQL_RES *mysql_res;
unsigned NumCrss;
2017-01-28 15:58:46 +01:00
unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS];
2016-06-09 18:04:18 +02:00
/***** Get parameters *****/
Ind_GetParamsIndicators ();
2014-12-01 23:55:08 +01:00
/***** Get courses from database *****/
NumCrss = Ind_GetTableOfCourses (&mysql_res);
2016-06-04 19:16:21 +02:00
/***** Get vector with numbers of courses with 0, 1, 2... indicators set to yes *****/
Ind_GetNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,mysql_res);
/***** Show table with numbers of courses with 0, 1, 2... indicators set to yes *****/
2016-06-08 13:19:17 +02:00
Ind_ShowNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss,false);
2016-06-04 19:16:21 +02:00
2014-12-01 23:55:08 +01:00
/***** Show the stats of courses *****/
Ind_ShowTableOfCoursesWithIndicators (Ind_INDICATORS_FULL,NumCrss,mysql_res);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/*************** Get parameter with the number of indicators *****************/
/*****************************************************************************/
2016-06-08 14:14:31 +02:00
static void Ind_GetParamNumIndicators (void)
2014-12-01 23:55:08 +01:00
{
2016-06-08 14:14:31 +02:00
unsigned Ind;
const char *Ptr;
2017-01-28 15:58:46 +01:00
char LongStr[1 + 10 + 1];
2016-06-08 14:14:31 +02:00
long Indicator;
/***** Get parameter multiple with list of indicators selected *****/
Par_GetParMultiToText ("Indicators",Gbl.Stat.StrIndicatorsSelected,Ind_MAX_SIZE_INDICATORS_SELECTED);
2014-12-01 23:55:08 +01:00
2016-06-08 14:14:31 +02:00
/***** Set which indicators have been selected (checkboxes on) *****/
if (Gbl.Stat.StrIndicatorsSelected[0])
{
/* Reset all indicators */
for (Ind = 0;
Ind <= Ind_NUM_INDICATORS;
Ind++)
Gbl.Stat.IndicatorsSelected[Ind] = false;
/* Set indicators selected */
for (Ptr = Gbl.Stat.StrIndicatorsSelected;
*Ptr;
)
{
/* Get next indicator selected */
2017-01-28 15:58:46 +01:00
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1 + 10);
2016-06-08 14:14:31 +02:00
Indicator = Str_ConvertStrCodToLongCod (LongStr);
/* Set each indicator in list StrIndicatorsSelected as selected */
for (Ind = 0;
Ind <= Ind_NUM_INDICATORS;
Ind++)
if ((long) Ind == Indicator)
Gbl.Stat.IndicatorsSelected[Ind] = true;
}
}
else
/* Set all indicators */
for (Ind = 0;
Ind <= Ind_NUM_INDICATORS;
Ind++)
Gbl.Stat.IndicatorsSelected[Ind] = true;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******************* Build query to get table of courses *********************/
/*****************************************************************************/
// Return the number of courses found
static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res)
{
2018-10-31 13:00:40 +01:00
unsigned NumCrss = 0; // Initialized to avoid warning
2014-12-01 23:55:08 +01:00
switch (Gbl.Scope.Current)
{
2019-04-03 20:57:04 +02:00
case Hie_SYS:
2017-10-10 10:46:35 +02:00
if (Gbl.Stat.DptCod >= 0) // 0 means another department
2014-12-01 23:55:08 +01:00
{
if (Gbl.Stat.DegTypCod > 0)
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE degrees.DegTypCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=usr_data.UsrCod"
" AND usr_data.DptCod=%ld"
" ORDER BY degrees.FullName,courses.FullName",
Gbl.Stat.DegTypCod,
(unsigned) Rol_TCH,
Gbl.Stat.DptCod);
2014-12-01 23:55:08 +01:00
else
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=usr_data.UsrCod"
" AND usr_data.DptCod=%ld"
" ORDER BY degrees.FullName,courses.FullName",
(unsigned) Rol_TCH,
Gbl.Stat.DptCod);
2014-12-01 23:55:08 +01:00
}
else
{
if (Gbl.Stat.DegTypCod > 0)
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses"
" WHERE degrees.DegTypCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" ORDER BY degrees.FullName,courses.FullName",
Gbl.Stat.DegTypCod);
2014-12-01 23:55:08 +01:00
else
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses"
" WHERE degrees.DegCod=courses.DegCod"
" ORDER BY degrees.FullName,courses.FullName");
2014-12-01 23:55:08 +01:00
}
break;
2019-04-03 20:57:04 +02:00
case Hie_CTY:
2017-10-10 10:46:35 +02:00
if (Gbl.Stat.DptCod >= 0) // 0 means another department
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM institutions,centres,degrees,courses,crs_usr,usr_data"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=usr_data.UsrCod"
" AND usr_data.DptCod=%ld"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cty.CtyCod,
2018-10-31 13:00:40 +01:00
(unsigned) Rol_TCH,
Gbl.Stat.DptCod);
2015-03-24 19:41:54 +01:00
else
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM institutions,centres,degrees,courses"
" WHERE institutions.CtyCod=%ld"
" AND institutions.InsCod=centres.InsCod"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cty.CtyCod);
2015-03-24 19:41:54 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_INS:
2017-10-10 10:46:35 +02:00
if (Gbl.Stat.DptCod >= 0) // 0 means another department
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM centres,degrees,courses,crs_usr,usr_data"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=usr_data.UsrCod"
" AND usr_data.DptCod=%ld"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod,
2018-10-31 13:00:40 +01:00
(unsigned) Rol_TCH,
Gbl.Stat.DptCod);
2014-12-01 23:55:08 +01:00
else
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM centres,degrees,courses"
" WHERE centres.InsCod=%ld"
" AND centres.CtrCod=degrees.CtrCod"
" AND degrees.DegCod=courses.DegCod"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod);
2014-12-01 23:55:08 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_CTR:
2017-10-10 10:46:35 +02:00
if (Gbl.Stat.DptCod >= 0) // 0 means another department
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE degrees.CtrCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=usr_data.UsrCod"
" AND usr_data.DptCod=%ld"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod,
2018-10-31 13:00:40 +01:00
(unsigned) Rol_TCH,
Gbl.Stat.DptCod);
2014-12-01 23:55:08 +01:00
else
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses"
" WHERE degrees.CtrCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod);
2014-12-01 23:55:08 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_DEG:
2017-10-10 10:46:35 +02:00
if (Gbl.Stat.DptCod >= 0) // 0 means another department
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE degrees.DegCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=usr_data.UsrCod"
" AND usr_data.DptCod=%ld"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.DegCod,
2018-10-31 13:00:40 +01:00
(unsigned) Rol_TCH,
Gbl.Stat.DptCod);
2014-12-01 23:55:08 +01:00
else
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses"
" WHERE degrees.DegCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.DegCod);
2014-12-01 23:55:08 +01:00
break;
2019-04-03 20:57:04 +02:00
case Hie_CRS:
2017-10-10 10:46:35 +02:00
if (Gbl.Stat.DptCod >= 0) // 0 means another department
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT DISTINCTROW degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses,crs_usr,usr_data"
" WHERE courses.CrsCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" AND courses.CrsCod=crs_usr.CrsCod"
" AND crs_usr.CrsCod=%ld"
" AND crs_usr.Role=%u"
" AND crs_usr.UsrCod=usr_data.UsrCod"
" AND usr_data.DptCod=%ld"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Hierarchy.Crs.CrsCod,
2018-10-31 13:00:40 +01:00
(unsigned) Rol_TCH,
Gbl.Stat.DptCod);
2014-12-01 23:55:08 +01:00
else
2018-10-31 13:00:40 +01:00
NumCrss =
(unsigned) DB_QuerySELECT (mysql_res,"can not get courses",
"SELECT degrees.FullName,courses.FullName,courses.CrsCod,courses.InsCrsCod"
" FROM degrees,courses"
" WHERE courses.CrsCod=%ld"
" AND degrees.DegCod=courses.DegCod"
" ORDER BY degrees.FullName,courses.FullName",
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.CrsCod);
2014-12-01 23:55:08 +01:00
break;
default:
2018-10-24 23:03:11 +02:00
Lay_WrongScopeExit ();
2014-12-01 23:55:08 +01:00
break;
}
2018-10-31 13:00:40 +01:00
return NumCrss;
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
/******* Show form to confirm that I want to see a big list of courses *******/
/*****************************************************************************/
static bool Ind_GetIfShowBigList (unsigned NumCrss)
{
bool ShowBigList;
/***** If list of courses is too big... *****/
if (NumCrss <= Cfg_MIN_NUM_COURSES_TO_CONFIRM_SHOW_BIG_LIST)
return true; // List is not too big ==> show it
/***** Get parameter with user's confirmation to see a big list of courses *****/
2017-01-28 20:32:50 +01:00
if (!(ShowBigList = Par_GetParToBool ("ShowBigList")))
2014-12-01 23:55:08 +01:00
Ind_PutButtonToConfirmIWantToSeeBigList (NumCrss);
return ShowBigList;
}
/*****************************************************************************/
/****** Show form to confirm that I want to see a big list of courses ********/
/*****************************************************************************/
static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss)
{
extern const char *Txt_The_list_of_X_courses_is_too_large_to_be_displayed;
extern const char *Txt_Show_anyway;
2017-05-25 14:25:22 +02:00
/***** Show alert and button to confirm that I want to see the big list *****/
2019-02-17 01:14:55 +01:00
Ale_ShowAlertAndButton (Gbl.Action.Act,NULL,NULL,
2017-05-25 14:25:22 +02:00
Ind_PutParamsConfirmIWantToSeeBigList,
2019-02-17 01:14:55 +01:00
Btn_CONFIRM_BUTTON,Txt_Show_anyway,
Ale_WARNING,Txt_The_list_of_X_courses_is_too_large_to_be_displayed,
NumCrss);
2017-05-25 14:25:22 +02:00
}
2014-12-01 23:55:08 +01:00
2017-05-25 14:25:22 +02:00
static void Ind_PutParamsConfirmIWantToSeeBigList (void)
{
2016-06-24 20:34:58 +02:00
Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current);
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamLong ("OthDegTypCod",Gbl.Stat.DegTypCod);
2017-10-10 12:37:09 +02:00
Par_PutHiddenParamLong (Dpt_PARAM_DPT_COD_NAME,Gbl.Stat.DptCod);
2016-06-08 14:14:31 +02:00
if (Gbl.Stat.StrIndicatorsSelected[0])
Par_PutHiddenParamString ("Indicators",Gbl.Stat.StrIndicatorsSelected);
2014-12-01 23:55:08 +01:00
Par_PutHiddenParamChar ("ShowBigList",'Y');
}
2016-06-04 19:16:21 +02:00
/*****************************************************************************/
/** Get vector with numbers of courses with 0, 1, 2... indicators set to yes */
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS],
2016-06-04 19:16:21 +02:00
unsigned NumCrss,MYSQL_RES *mysql_res)
{
MYSQL_ROW row;
unsigned NumCrs;
long CrsCod;
unsigned Ind;
2016-06-09 11:50:24 +02:00
unsigned NumIndicators;
2016-06-04 19:16:21 +02:00
/***** Reset counters of courses with each number of indicators *****/
for (Ind = 0;
Ind <= Ind_NUM_INDICATORS;
Ind++)
NumCrssWithIndicatorYes[Ind] = 0;
/***** List courses *****/
for (Gbl.RowEvenOdd = 1, NumCrs = 0;
NumCrs < NumCrss;
NumCrs++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
{
/* Get next course */
row = mysql_fetch_row (mysql_res);
/* Get course code (row[2]) */
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0)
Lay_ShowErrorAndExit ("Wrong code of course.");
2016-06-10 10:22:22 +02:00
/* Get stored number of indicators of this course */
2016-06-09 11:50:24 +02:00
NumIndicators = Ind_GetAndUpdateNumIndicatorsCrs (CrsCod);
NumCrssWithIndicatorYes[NumIndicators]++;
2016-06-04 19:16:21 +02:00
}
}
/*****************************************************************************/
/** Show table with numbers of courses with 0, 1, 2... indicators set to yes */
/*****************************************************************************/
2017-01-28 15:58:46 +01:00
static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 + Ind_NUM_INDICATORS],
2016-06-08 13:19:17 +02:00
unsigned NumCrss,bool PutForm)
2016-06-04 19:16:21 +02:00
{
2016-06-08 14:14:31 +02:00
extern const char *Txt_Indicators;
2016-06-04 19:16:21 +02:00
extern const char *Txt_Courses;
2016-06-08 14:14:31 +02:00
extern const char *Txt_Total;
2016-06-04 19:16:21 +02:00
unsigned Ind;
2016-06-05 01:01:18 +02:00
const char *Class;
2016-06-08 14:14:31 +02:00
const char *ClassNormal = "DAT_LIGHT RIGHT_MIDDLE";
const char *ClassHighlight = "DAT RIGHT_MIDDLE LIGHT_BLUE";
2016-06-04 19:16:21 +02:00
/***** Write number of courses with each number of indicators valid *****/
2017-06-11 20:09:59 +02:00
Tbl_StartTable (2);
2017-05-01 12:36:24 +02:00
fprintf (Gbl.F.Out,"<tr>");
2016-06-08 13:19:17 +02:00
if (PutForm)
fprintf (Gbl.F.Out,"<th></th>");
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
2016-06-04 19:16:21 +02:00
"%s"
"</th>"
"<th colspan=\"2\" class=\"RIGHT_MIDDLE\">"
"%s"
"</th>"
"</tr>",
2016-06-08 14:14:31 +02:00
Txt_Indicators,
2016-06-04 19:16:21 +02:00
Txt_Courses);
for (Ind = 0;
Ind <= Ind_NUM_INDICATORS;
Ind++)
2016-06-05 01:01:18 +02:00
{
2016-06-08 14:14:31 +02:00
Class = Gbl.Stat.IndicatorsSelected[Ind] ? ClassHighlight :
ClassNormal;
2016-06-08 13:19:17 +02:00
fprintf (Gbl.F.Out,"<tr>");
if (PutForm)
{
fprintf (Gbl.F.Out,"<td class=\"%s\">"
2016-12-20 02:18:50 +01:00
"<input type=\"checkbox\""
" id=\"Indicators%u\" name=\"Indicators\""
" value=\"%u\"",
Class,Ind,Ind);
2016-06-08 14:14:31 +02:00
if (Gbl.Stat.IndicatorsSelected[Ind])
2016-06-08 13:19:17 +02:00
fprintf (Gbl.F.Out," checked=\"checked\"");
2016-06-09 17:56:57 +02:00
fprintf (Gbl.F.Out," onchange=\"document.getElementById('%s').submit();\" />"
"</td>",
Gbl.Form.Id);
2016-06-08 13:19:17 +02:00
}
fprintf (Gbl.F.Out,"<td class=\"%s\">"
2016-12-20 02:18:50 +01:00
"<label for=\"Indicators%u\">%u</label>"
2016-06-04 19:16:21 +02:00
"</td>"
2016-06-05 01:01:18 +02:00
"<td class=\"%s\">"
2016-06-04 19:16:21 +02:00
"%u"
"</td>"
2016-06-05 01:01:18 +02:00
"<td class=\"%s\">"
2016-06-04 19:16:21 +02:00
"(%.1f%%)"
"</td>"
"</tr>",
2016-06-05 01:01:18 +02:00
Class,
2016-12-20 02:18:50 +01:00
Ind,Ind,
2016-06-05 01:01:18 +02:00
Class,
NumCrssWithIndicatorYes[Ind],
Class,
2016-06-04 19:16:21 +02:00
NumCrss ? (float) NumCrssWithIndicatorYes[Ind] * 100.0 / (float) NumCrss :
0.0);
2016-06-05 01:01:18 +02:00
}
/***** Write total of courses *****/
2016-06-08 13:19:17 +02:00
fprintf (Gbl.F.Out,"<tr>");
if (PutForm)
2016-06-08 14:14:31 +02:00
fprintf (Gbl.F.Out,"<td>"
2016-06-08 13:19:17 +02:00
"</td>");
2016-06-08 14:14:31 +02:00
fprintf (Gbl.F.Out,"<td class=\"DAT_N_LINE_TOP RIGHT_MIDDLE\">"
2016-06-04 19:16:21 +02:00
"%s"
"</td>"
2016-06-08 14:14:31 +02:00
"<td class=\"DAT_N_LINE_TOP RIGHT_MIDDLE\">"
2016-06-04 19:16:21 +02:00
"%u"
"</td>"
2016-06-08 14:14:31 +02:00
"<td class=\"DAT_N_LINE_TOP RIGHT_MIDDLE\">"
2016-06-04 19:16:21 +02:00
"(%.1f%%)"
"</td>"
2017-05-01 12:36:24 +02:00
"</tr>",
2016-06-08 14:14:31 +02:00
Txt_Total,
2016-06-05 01:01:18 +02:00
NumCrss,
100.0);
2017-05-01 12:36:24 +02:00
2017-06-11 20:09:59 +02:00
Tbl_EndTable ();
2016-06-04 19:16:21 +02:00
}
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/****************** Get and show total number of courses *********************/
/*****************************************************************************/
2016-06-04 19:16:21 +02:00
static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t IndicatorsLayout,
unsigned NumCrss,MYSQL_RES *mysql_res)
2014-12-01 23:55:08 +01:00
{
extern const char *Txt_Degree;
extern const char *Txt_Course;
extern const char *Txt_Institutional_BR_code;
extern const char *Txt_Web_page_of_the_course;
2017-05-30 21:43:05 +02:00
extern const char *Txt_ROLES_PLURAL_BRIEF_Abc[Rol_NUM_ROLES];
2014-12-01 23:55:08 +01:00
extern const char *Txt_Indicators;
extern const char *Txt_No_INDEX;
extern const char *Txt_Syllabus_of_the_course;
extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES];
2015-01-26 12:39:48 +01:00
extern const char *Txt_No_of_files_in_SHARE_zones;
extern const char *Txt_No_of_files_in_DOCUM_zones;
2014-12-01 23:55:08 +01:00
extern const char *Txt_Guided_academic_assignments;
extern const char *Txt_Assignments;
extern const char *Txt_Files_assignments;
extern const char *Txt_Files_works;
extern const char *Txt_Online_tutoring;
extern const char *Txt_Forum_threads;
extern const char *Txt_Forum_posts;
extern const char *Txt_Messages_sent_by_teachers;
extern const char *Txt_Materials;
extern const char *Txt_Assessment_criteria;
extern const char *Txt_YES;
extern const char *Txt_NO;
extern const char *Txt_INFO_SRC_SHORT_TEXT[Inf_NUM_INFO_SOURCES];
extern const char *Txt_Courses;
MYSQL_ROW row;
unsigned NumCrs;
long CrsCod;
unsigned NumTchs;
unsigned NumStds;
2016-06-09 14:00:10 +02:00
unsigned NumIndicators;
2014-12-01 23:55:08 +01:00
struct Ind_IndicatorsCrs Indicators;
2018-04-24 13:21:53 +02:00
long ActCod;
2014-12-01 23:55:08 +01:00
2017-06-12 14:16:33 +02:00
/***** Start table *****/
2015-09-05 19:19:39 +02:00
fprintf (Gbl.F.Out,"<table class=\"INDICATORS\">");
2014-12-01 23:55:08 +01:00
/***** Write table heading *****/
switch (IndicatorsLayout)
{
case Ind_INDICATORS_BRIEF:
fprintf (Gbl.F.Out,"<tr>"
2015-09-05 19:19:39 +02:00
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"11\" class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>"
"<tr>"
2015-09-05 19:19:39 +02:00
"<th rowspan=\"2\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"2\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(A) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"2\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(B) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"2\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(C) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"2\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(D) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"2\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(E) %s"
2015-09-05 19:19:39 +02:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>"
"<tr>"
2015-09-05 19:19:39 +02:00
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
2015-09-04 17:43:18 +02:00
Txt_Degree,
Txt_Course,
Txt_Institutional_BR_code,
Txt_Web_page_of_the_course,
Txt_Indicators,
2014-12-01 23:55:08 +01:00
2015-09-04 17:43:18 +02:00
Txt_No_INDEX,
Txt_Syllabus_of_the_course,
Txt_Guided_academic_assignments,
Txt_Online_tutoring,
Txt_Materials,
Txt_Assessment_criteria,
2014-12-01 23:55:08 +01:00
2015-09-04 17:43:18 +02:00
Txt_YES,
Txt_NO,
2014-12-01 23:55:08 +01:00
2015-09-04 17:43:18 +02:00
Txt_YES,
Txt_NO,
2014-12-01 23:55:08 +01:00
2015-09-04 17:43:18 +02:00
Txt_YES,
Txt_NO,
2014-12-01 23:55:08 +01:00
2015-09-04 17:43:18 +02:00
Txt_YES,
Txt_NO,
2014-12-01 23:55:08 +01:00
2015-09-04 17:43:18 +02:00
Txt_YES,
Txt_NO);
2014-12-01 23:55:08 +01:00
break;
case Ind_INDICATORS_FULL:
fprintf (Gbl.F.Out,"<tr>"
2015-09-05 19:19:39 +02:00
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th rowspan=\"3\" class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"24\" class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>"
"<tr>"
2015-09-05 19:19:39 +02:00
"<th rowspan=\"2\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"5\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(A) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"5\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(B) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"5\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(C) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"4\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(D) %s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th colspan=\"4\" class=\"CENTER_TOP COLOR0\">"
2014-12-23 01:36:58 +01:00
"(E) %s"
2015-09-05 19:19:39 +02:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>"
"<tr>"
2015-09-05 19:19:39 +02:00
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"RIGHT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"CENTER_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
"<th class=\"LEFT_MIDDLE COLOR0\">"
2014-12-23 01:36:58 +01:00
"%s"
2015-09-05 19:19:39 +02:00
"</th>"
2014-12-01 23:55:08 +01:00
"</tr>",
2015-09-04 17:43:18 +02:00
Txt_Degree,
Txt_Course,
Txt_Institutional_BR_code,
Txt_Web_page_of_the_course,
2017-05-30 21:43:05 +02:00
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_TCH],
Txt_ROLES_PLURAL_BRIEF_Abc[Rol_STD],
2015-09-04 17:43:18 +02:00
Txt_Indicators,
Txt_No_INDEX,
Txt_Syllabus_of_the_course,
Txt_Guided_academic_assignments,
Txt_Online_tutoring,
Txt_Materials,
Txt_Assessment_criteria,
Txt_YES,
Txt_NO,
Txt_INFO_TITLE[Inf_LECTURES],
Txt_INFO_TITLE[Inf_PRACTICALS],
Txt_INFO_TITLE[Inf_TEACHING_GUIDE],
Txt_YES,
Txt_NO,
Txt_Assignments,
Txt_Files_assignments,
Txt_Files_works,
Txt_YES,
Txt_NO,
Txt_Forum_threads,
Txt_Forum_posts,
Txt_Messages_sent_by_teachers,
Txt_YES,
Txt_NO,
Txt_No_of_files_in_DOCUM_zones,
Txt_No_of_files_in_SHARE_zones,
Txt_YES,
Txt_NO,
Txt_INFO_TITLE[Inf_ASSESSMENT],
Txt_INFO_TITLE[Inf_TEACHING_GUIDE]);
2014-12-01 23:55:08 +01:00
break;
}
/***** List courses *****/
2017-04-25 14:48:47 +02:00
mysql_data_seek (mysql_res,0);
2014-12-01 23:55:08 +01:00
for (Gbl.RowEvenOdd = 1, NumCrs = 0;
NumCrs < NumCrss;
NumCrs++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
{
/* Get next course */
row = mysql_fetch_row (mysql_res);
/* Get course code (row[2]) */
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0)
Lay_ShowErrorAndExit ("Wrong code of course.");
2016-06-09 14:00:10 +02:00
/* Get stored number of indicators of this course */
NumIndicators = Ind_GetAndUpdateNumIndicatorsCrs (CrsCod);
if (Gbl.Stat.IndicatorsSelected[NumIndicators])
{
/* Compute and store indicators */
Ind_ComputeAndStoreIndicatorsCrs (CrsCod,(int) NumIndicators,&Indicators);
/* The number of indicators may have changed */
2016-06-10 10:22:22 +02:00
if (Gbl.Stat.IndicatorsSelected[Indicators.NumIndicators])
2016-06-09 14:00:10 +02:00
{
2018-04-24 13:21:53 +02:00
ActCod = Act_GetActCod (ActReqStaCrs);
2016-06-09 14:00:10 +02:00
/* Write a row for this course */
switch (IndicatorsLayout)
{
case Ind_INDICATORS_BRIEF:
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"DAT_SMALL LEFT_MIDDLE COLOR%u\">"
"<a href=\"%s/?crs=%ld&amp;act=%ld\" target=\"_blank\">"
"%s/?crs=%ld&amp;act=%ld"
"</a>"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"</tr>",
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
row[0],
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
row[1],
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
row[3],
2018-04-24 13:21:53 +02:00
Gbl.RowEvenOdd,Cfg_URL_SWAD_CGI,CrsCod,ActCod,
Cfg_URL_SWAD_CGI,CrsCod,ActCod,
2016-06-09 14:00:10 +02:00
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
2016-06-10 10:22:22 +02:00
Indicators.NumIndicators,
2016-06-09 14:00:10 +02:00
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereIsSyllabus ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereIsSyllabus ? "" :
Txt_NO,
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereAreAssignments ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereAreAssignments ? "" :
Txt_NO,
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereIsOnlineTutoring ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereIsOnlineTutoring ? "" :
Txt_NO,
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereAreMaterials ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereAreMaterials ? "" :
Txt_NO,
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereIsAssessment ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereIsAssessment ? "" :
Txt_NO);
break;
case Ind_INDICATORS_FULL:
/* Get number of users */
2017-05-22 12:23:08 +02:00
NumStds = Usr_GetNumUsrsInCrs (Rol_STD,CrsCod); // Students
NumTchs = Usr_GetNumUsrsInCrs (Rol_NET,CrsCod) + // Non-editing teachers
Usr_GetNumUsrsInCrs (Rol_TCH,CrsCod); // Teachers
2016-06-09 14:00:10 +02:00
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"DAT_SMALL LEFT_MIDDLE COLOR%u\">"
"<a href=\"%s/?crs=%ld&amp;act=%ld\" target=\"_blank\">"
"%s/?crs=%ld&amp;act=%ld"
"</a>"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%lu"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%lu"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%u"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%lu"
"</td>"
"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
"%lu"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s CENTER_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"<td class=\"%s LEFT_MIDDLE COLOR%u\">"
"%s"
"</td>"
"</tr>",
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
row[0],
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
row[1],
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
row[3],
2018-04-24 13:21:53 +02:00
Gbl.RowEvenOdd,Cfg_URL_SWAD_CGI,CrsCod,ActCod,
Cfg_URL_SWAD_CGI,CrsCod,ActCod,
2016-06-09 14:00:10 +02:00
NumTchs != 0 ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
NumTchs,
NumStds != 0 ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
NumStds,
Indicators.CourseAllOK ? "DAT_SMALL_GREEN" :
(Indicators.CoursePartiallyOK ? "DAT_SMALL" :
"DAT_SMALL_RED"),
Gbl.RowEvenOdd,
2016-06-10 10:22:22 +02:00
Indicators.NumIndicators,
2016-06-09 14:00:10 +02:00
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereIsSyllabus ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereIsSyllabus ? "" :
Txt_NO,
(Indicators.SyllabusLecSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Txt_INFO_SRC_SHORT_TEXT[Indicators.SyllabusLecSrc],
(Indicators.SyllabusPraSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Txt_INFO_SRC_SHORT_TEXT[Indicators.SyllabusPraSrc],
(Indicators.TeachingGuideSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Txt_INFO_SRC_SHORT_TEXT[Indicators.TeachingGuideSrc],
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereAreAssignments ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereAreAssignments ? "" :
Txt_NO,
(Indicators.NumAssignments != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumAssignments,
(Indicators.NumFilesAssignments != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumFilesAssignments,
(Indicators.NumFilesWorks != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumFilesWorks,
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereIsOnlineTutoring ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereIsOnlineTutoring ? "" :
Txt_NO,
(Indicators.NumThreads != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumThreads,
(Indicators.NumPosts != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumPosts,
(Indicators.NumMsgsSentByTchs != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumMsgsSentByTchs,
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereAreMaterials ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereAreMaterials ? "" :
Txt_NO,
(Indicators.NumFilesInDocumentZones != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumFilesInDocumentZones,
(Indicators.NumFilesInSharedZones != 0) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Indicators.NumFilesInSharedZones,
"DAT_SMALL_GREEN",Gbl.RowEvenOdd,
Indicators.ThereIsAssessment ? Txt_YES :
"",
"DAT_SMALL_RED",Gbl.RowEvenOdd,
Indicators.ThereIsAssessment ? "" :
Txt_NO,
(Indicators.AssessmentSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Txt_INFO_SRC_SHORT_TEXT[Indicators.AssessmentSrc],
(Indicators.TeachingGuideSrc != Inf_INFO_SRC_NONE) ? "DAT_SMALL_GREEN" :
"DAT_SMALL_RED",
Gbl.RowEvenOdd,
Txt_INFO_SRC_SHORT_TEXT[Indicators.TeachingGuideSrc]);
break;
}
}
}
2014-12-01 23:55:08 +01:00
}
/***** End table *****/
fprintf (Gbl.F.Out,"</table>");
}
/*****************************************************************************/
2016-06-09 11:50:24 +02:00
/************ Get number of indicators of a course from database *************/
/************ If not stored ==> compute and store it *************/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-06-10 10:22:22 +02:00
static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod)
2014-12-01 23:55:08 +01:00
{
2016-06-09 11:50:24 +02:00
unsigned NumIndicators;
struct Ind_IndicatorsCrs Indicators;
int NumIndicatorsFromDB = Ind_GetNumIndicatorsCrsFromDB (CrsCod);
/***** If number of indicators is not already computed ==> compute it! *****/
if (NumIndicatorsFromDB >= 0)
NumIndicators = (unsigned) NumIndicatorsFromDB;
else // Number of indicators is not already computed
{
/***** Compute and store number of indicators *****/
Ind_ComputeAndStoreIndicatorsCrs (CrsCod,NumIndicatorsFromDB,&Indicators);
2016-06-10 10:22:22 +02:00
NumIndicators = Indicators.NumIndicators;
2016-06-09 11:50:24 +02:00
}
return NumIndicators;
}
/*****************************************************************************/
/************ Get number of indicators of a course from database *************/
/*****************************************************************************/
2016-12-15 02:22:47 +01:00
// This function returns -1 if number of indicators is not yet calculated
2016-06-09 11:50:24 +02:00
2016-06-10 10:22:22 +02:00
int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
2016-06-09 11:50:24 +02:00
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-12-15 02:22:47 +01:00
int NumIndicatorsFromDB = -1; // -1 means not yet calculated
2016-06-09 11:50:24 +02:00
2016-12-15 02:22:47 +01:00
/***** Get number of indicators of a course from database *****/
2018-10-31 16:16:57 +01:00
if (DB_QuerySELECT (&mysql_res,"can not get number of indicators",
"SELECT NumIndicators FROM courses"
" WHERE CrsCod=%ld",
CrsCod))
2016-06-09 11:50:24 +02:00
{
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get number of indicators (row[0]) *****/
if (sscanf (row[0],"%d",&NumIndicatorsFromDB) != 1)
Lay_ShowErrorAndExit ("Error when getting number of indicators.");
}
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumIndicatorsFromDB;
}
/*****************************************************************************/
/************ Store number of indicators of a course in database *************/
/*****************************************************************************/
2016-06-09 14:00:10 +02:00
static void Ind_StoreIndicatorsCrsIntoDB (long CrsCod,unsigned NumIndicators)
2016-06-09 11:50:24 +02:00
{
/***** Store number of indicators of a course in database *****/
2018-11-03 12:16:40 +01:00
DB_QueryUPDATE ("can not store number of indicators of a course",
"UPDATE courses SET NumIndicators=%u WHERE CrsCod=%ld",
NumIndicators,CrsCod);
2016-06-09 11:50:24 +02:00
}
/*****************************************************************************/
/********************* Compute indicators of a course ************************/
/*****************************************************************************/
2016-06-10 10:22:22 +02:00
/* NumIndicatorsFromDB (number of indicators stored in database)
must be retrieved before calling this function.
If NumIndicatorsFromDB is different from number of indicators just computed
==> update it into database */
2016-06-09 11:50:24 +02:00
2016-06-10 10:22:22 +02:00
void Ind_ComputeAndStoreIndicatorsCrs (long CrsCod,int NumIndicatorsFromDB,
struct Ind_IndicatorsCrs *Indicators)
2016-06-09 11:50:24 +02:00
{
/***** Initialize number of indicators *****/
2016-06-10 10:22:22 +02:00
Indicators->NumIndicators = 0;
2014-12-01 23:55:08 +01:00
2016-06-09 11:50:24 +02:00
/***** Get whether download zones are empty or not *****/
2016-06-08 18:41:32 +02:00
Indicators->NumFilesInDocumentZones = Ind_GetNumFilesInDocumZonesOfCrsFromDB (CrsCod);
Indicators->NumFilesInSharedZones = Ind_GetNumFilesInShareZonesOfCrsFromDB (CrsCod);
2014-12-01 23:55:08 +01:00
2016-06-09 11:50:24 +02:00
/***** Indicator #1: information about syllabus *****/
2016-06-08 15:03:06 +02:00
Indicators->SyllabusLecSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_LECTURES);
Indicators->SyllabusPraSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_PRACTICALS);
Indicators->TeachingGuideSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_TEACHING_GUIDE);
2014-12-01 23:55:08 +01:00
Indicators->ThereIsSyllabus = (Indicators->SyllabusLecSrc != Inf_INFO_SRC_NONE) ||
(Indicators->SyllabusPraSrc != Inf_INFO_SRC_NONE) ||
(Indicators->TeachingGuideSrc != Inf_INFO_SRC_NONE);
if (Indicators->ThereIsSyllabus)
2016-06-10 10:22:22 +02:00
Indicators->NumIndicators++;
2014-12-01 23:55:08 +01:00
2016-06-09 11:50:24 +02:00
/***** Indicator #2: information about assignments *****/
2014-12-01 23:55:08 +01:00
Indicators->NumAssignments = Asg_GetNumAssignmentsInCrs (CrsCod);
2016-06-08 18:41:32 +02:00
Indicators->NumFilesAssignments = Ind_GetNumFilesInAssigZonesOfCrsFromDB (CrsCod);
Indicators->NumFilesWorks = Ind_GetNumFilesInWorksZonesOfCrsFromDB (CrsCod);
2014-12-01 23:55:08 +01:00
Indicators->ThereAreAssignments = (Indicators->NumAssignments != 0) ||
(Indicators->NumFilesAssignments != 0) ||
(Indicators->NumFilesWorks != 0);
if (Indicators->ThereAreAssignments)
2016-06-10 10:22:22 +02:00
Indicators->NumIndicators++;
2014-12-01 23:55:08 +01:00
2016-06-09 11:50:24 +02:00
/***** Indicator #3: information about online tutoring *****/
2015-03-09 01:41:37 +01:00
Indicators->NumThreads = For_GetNumTotalThrsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod);
Indicators->NumPosts = For_GetNumTotalPstsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod,&(Indicators->NumUsrsToBeNotifiedByEMail));
2014-12-01 23:55:08 +01:00
Indicators->NumMsgsSentByTchs = Msg_GetNumMsgsSentByTchsCrs (CrsCod);
Indicators->ThereIsOnlineTutoring = (Indicators->NumThreads != 0) ||
(Indicators->NumPosts != 0) ||
(Indicators->NumMsgsSentByTchs != 0);
if (Indicators->ThereIsOnlineTutoring)
2016-06-10 10:22:22 +02:00
Indicators->NumIndicators++;
2014-12-01 23:55:08 +01:00
2016-06-09 11:50:24 +02:00
/***** Indicator #4: information about materials *****/
2016-04-22 09:47:25 +02:00
Indicators->ThereAreMaterials = (Indicators->NumFilesInDocumentZones != 0) ||
(Indicators->NumFilesInSharedZones != 0);
2014-12-01 23:55:08 +01:00
if (Indicators->ThereAreMaterials)
2016-06-10 10:22:22 +02:00
Indicators->NumIndicators++;
2014-12-01 23:55:08 +01:00
2016-06-09 11:50:24 +02:00
/***** Indicator #5: information about assessment *****/
2016-06-08 15:03:06 +02:00
Indicators->AssessmentSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_ASSESSMENT);
2014-12-01 23:55:08 +01:00
Indicators->ThereIsAssessment = (Indicators->AssessmentSrc != Inf_INFO_SRC_NONE) ||
(Indicators->TeachingGuideSrc != Inf_INFO_SRC_NONE);
if (Indicators->ThereIsAssessment)
2016-06-10 10:22:22 +02:00
Indicators->NumIndicators++;
2014-12-01 23:55:08 +01:00
2016-06-09 11:50:24 +02:00
/***** All the indicators are OK? *****/
2016-06-10 10:22:22 +02:00
Indicators->CoursePartiallyOK = Indicators->NumIndicators >= 1 &&
Indicators->NumIndicators < Ind_NUM_INDICATORS;
Indicators->CourseAllOK = Indicators->NumIndicators == Ind_NUM_INDICATORS;
2016-06-09 11:50:24 +02:00
/***** Update number of indicators into database
if different to the stored one *****/
2016-06-10 10:22:22 +02:00
if (NumIndicatorsFromDB != (int) Indicators->NumIndicators)
Ind_StoreIndicatorsCrsIntoDB (CrsCod,Indicators->NumIndicators);
2014-12-01 23:55:08 +01:00
}
/*****************************************************************************/
2016-06-08 18:41:32 +02:00
/*********** Get the number of files in document zones of a course ***********/
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
2016-06-08 18:41:32 +02:00
static unsigned long Ind_GetNumFilesInDocumZonesOfCrsFromDB (long CrsCod)
2014-12-01 23:55:08 +01:00
{
2015-01-25 23:40:07 +01:00
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
2016-06-08 18:41:32 +02:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-08 19:05:49 +02:00
unsigned long NumFiles;
2016-06-08 18:41:32 +02:00
/***** Get number of files in document zones of a course from database *****/
2018-10-31 16:16:57 +01:00
DB_QuerySELECT (&mysql_res,"can not get the number of files",
"SELECT"
" (SELECT COALESCE(SUM(NumFiles),0)"
" FROM file_browser_size"
" WHERE FileBrowser=%u AND Cod=%ld) +"
" (SELECT COALESCE(SUM(file_browser_size.NumFiles),0)"
" FROM crs_grp_types,crs_grp,file_browser_size"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND file_browser_size.FileBrowser=%u"
" AND file_browser_size.Cod=crs_grp.GrpCod)",
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_DOC_CRS],
CrsCod,
CrsCod,
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_DOC_GRP]);
2016-06-08 18:41:32 +02:00
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get number of files (row[0]) *****/
2016-06-08 19:05:49 +02:00
if (sscanf (row[0],"%lu",&NumFiles) != 1)
Lay_ShowErrorAndExit ("Error when getting the number of files.");
2016-06-08 18:41:32 +02:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumFiles;
}
/*****************************************************************************/
/*********** Get the number of files in shared zones of a course ***********/
/*****************************************************************************/
static unsigned long Ind_GetNumFilesInShareZonesOfCrsFromDB (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-08 19:05:49 +02:00
unsigned long NumFiles;
2016-06-08 18:41:32 +02:00
/***** Get number of files in document zones of a course from database *****/
2018-10-31 16:16:57 +01:00
DB_QuerySELECT (&mysql_res,"can not get the number of files",
"SELECT"
" (SELECT COALESCE(SUM(NumFiles),0)"
" FROM file_browser_size"
" WHERE FileBrowser=%u AND Cod=%ld) +"
" (SELECT COALESCE(SUM(file_browser_size.NumFiles),0)"
" FROM crs_grp_types,crs_grp,file_browser_size"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod"
" AND file_browser_size.FileBrowser=%u"
" AND file_browser_size.Cod=crs_grp.GrpCod)",
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_SHR_CRS],
CrsCod,
CrsCod,
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_SHR_GRP]);
2016-06-08 18:41:32 +02:00
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get number of files (row[0]) *****/
2016-06-08 19:05:49 +02:00
if (sscanf (row[0],"%lu",&NumFiles) != 1)
Lay_ShowErrorAndExit ("Error when getting the number of files.");
2016-06-08 18:41:32 +02:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumFiles;
}
/*****************************************************************************/
/********* Get the number of files in assignment zones of a course ***********/
/*****************************************************************************/
static unsigned long Ind_GetNumFilesInAssigZonesOfCrsFromDB (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-08 19:05:49 +02:00
unsigned long NumFiles;
2016-06-08 18:41:32 +02:00
/***** Get number of files in document zones of a course from database *****/
2018-10-31 16:16:57 +01:00
DB_QuerySELECT (&mysql_res,"can not get the number of files",
"SELECT COALESCE(SUM(NumFiles),0)"
" FROM file_browser_size"
" WHERE FileBrowser=%u AND Cod=%ld",
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_ASG_USR],
CrsCod);
2016-06-08 18:41:32 +02:00
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get number of files (row[0]) *****/
2016-06-08 19:05:49 +02:00
if (sscanf (row[0],"%lu",&NumFiles) != 1)
Lay_ShowErrorAndExit ("Error when getting the number of files.");
2016-06-08 18:41:32 +02:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumFiles;
}
/*****************************************************************************/
/************* Get the number of files in works zones of a course ************/
/*****************************************************************************/
static unsigned long Ind_GetNumFilesInWorksZonesOfCrsFromDB (long CrsCod)
{
extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER];
2014-12-01 23:55:08 +01:00
MYSQL_RES *mysql_res;
MYSQL_ROW row;
2016-06-08 19:05:49 +02:00
unsigned long NumFiles;
2014-12-01 23:55:08 +01:00
2016-06-08 18:41:32 +02:00
/***** Get number of files in document zones of a course from database *****/
2018-10-31 16:16:57 +01:00
DB_QuerySELECT (&mysql_res,"can not get the number of files",
"SELECT COALESCE(SUM(NumFiles),0)"
" FROM file_browser_size"
" WHERE FileBrowser=%u AND Cod=%ld",
(unsigned) Brw_FileBrowserForDB_files[Brw_ADMI_WRK_USR],
CrsCod);
2014-12-01 23:55:08 +01:00
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get number of files (row[0]) *****/
2016-06-08 19:05:49 +02:00
if (sscanf (row[0],"%lu",&NumFiles) != 1)
Lay_ShowErrorAndExit ("Error when getting the number of files.");
2014-12-01 23:55:08 +01:00
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return NumFiles;
}