diff --git a/swad_changelog.h b/swad_changelog.h
index adc62da99..6fd8adb3d 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -134,13 +134,15 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 15.221 (2016-06-08)"
+#define Log_PLATFORM_VERSION "SWAD 15.221.1 (2016-06-08)"
#define CSS_FILE "swad15.218.css"
#define JS_FILE "swad15.216.js"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
+ Version 15.221.1: Jun 08, 2016 Fix bug in form of indicators.
+ Speed up database queries to get course info when getting indicators. (? lines)
Version 15.221: Jun 08, 2016 Single (radio) selection of number of indicators changed to multiple (checkbox) selection. (202028 lines)
Version 15.220.1: Jun 08, 2016 Code refactoring in form to view indicators of courses. (202031 lines)
Version 15.220: Jun 08, 2016 Number of indicators now appears inside form. (202029 lines)
diff --git a/swad_indicator.c b/swad_indicator.c
index be04afd9a..6f922171a 100644
--- a/swad_indicator.c
+++ b/swad_indicator.c
@@ -95,7 +95,21 @@ void Ind_ReqIndicatorsCourses (void)
unsigned NumCrssToList;
unsigned Ind;
- /***** Get scope *****/
+ /***** Start frame *****/
+ Lay_StartRoundFrame (NULL,Txt_Indicators_of_courses,NULL);
+
+ /***** Form to update indicators *****/
+ /* Start form */
+ Act_FormStart (ActReqStaCrs);
+ fprintf (Gbl.F.Out,"
");
+
+ /* Scope */
+ fprintf (Gbl.F.Out,"
"
+ "
"
+ ""
+ "
"
+ "
",
+ The_ClassForm[Gbl.Prefs.Theme],Txt_Scope);
Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS |
1 << Sco_SCOPE_CTY |
1 << Sco_SCOPE_INS |
@@ -104,33 +118,6 @@ void Ind_ReqIndicatorsCourses (void)
1 << Sco_SCOPE_CRS;
Gbl.Scope.Default = Sco_SCOPE_CRS;
Sco_GetScope ();
-
- /***** 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);
-
- /***** Start frame *****/
- Lay_StartRoundFrame (NULL,Txt_Indicators_of_courses,NULL);
-
- /***** Form to update indicators *****/
- /* Start form */
- Act_FormStart (ActReqStaCrs);
-
- fprintf (Gbl.F.Out,"
");
@@ -160,6 +147,17 @@ void Ind_ReqIndicatorsCourses (void)
fprintf (Gbl.F.Out,""
"");
+ /***** 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);
+
/* Selection of the number of indicators */
Ind_GetParamNumIndicators ();
fprintf (Gbl.F.Out,"
"
@@ -1345,7 +1343,6 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat
void Ind_GetIndicatorsCrs (long CrsCod,struct Ind_IndicatorsCrs *Indicators)
{
- bool MustBeRead; // Not used
Indicators->CountIndicators = 0;
/* Get whether download zones are empty or not */
@@ -1359,9 +1356,9 @@ void Ind_GetIndicatorsCrs (long CrsCod,struct Ind_IndicatorsCrs *Indicators)
Indicators->NumFilesInSharedZonesGrp;
/* Indicator #1: information about syllabus */
- Inf_GetInfoSrcFromDB (CrsCod,Inf_LECTURES ,&(Indicators->SyllabusLecSrc ),&MustBeRead);
- Inf_GetInfoSrcFromDB (CrsCod,Inf_PRACTICALS ,&(Indicators->SyllabusPraSrc ),&MustBeRead);
- Inf_GetInfoSrcFromDB (CrsCod,Inf_TEACHING_GUIDE,&(Indicators->TeachingGuideSrc),&MustBeRead);
+ Indicators->SyllabusLecSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_LECTURES);
+ Indicators->SyllabusPraSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_PRACTICALS);
+ Indicators->TeachingGuideSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_TEACHING_GUIDE);
Indicators->ThereIsSyllabus = (Indicators->SyllabusLecSrc != Inf_INFO_SRC_NONE) ||
(Indicators->SyllabusPraSrc != Inf_INFO_SRC_NONE) ||
(Indicators->TeachingGuideSrc != Inf_INFO_SRC_NONE);
@@ -1371,7 +1368,7 @@ void Ind_GetIndicatorsCrs (long CrsCod,struct Ind_IndicatorsCrs *Indicators)
/* Indicator #2: information about assignments */
Indicators->NumAssignments = Asg_GetNumAssignmentsInCrs (CrsCod);
Indicators->NumFilesAssignments = Ind_GetNumFilesOfCrsFileZoneFromDB (Brw_ADMI_ASSIG_USR,CrsCod);
- Indicators->NumFilesWorks = Ind_GetNumFilesOfCrsFileZoneFromDB (Brw_ADMI_WORKS_USR ,CrsCod);
+ Indicators->NumFilesWorks = Ind_GetNumFilesOfCrsFileZoneFromDB (Brw_ADMI_WORKS_USR,CrsCod);
Indicators->ThereAreAssignments = (Indicators->NumAssignments != 0) ||
(Indicators->NumFilesAssignments != 0) ||
(Indicators->NumFilesWorks != 0);
@@ -1395,7 +1392,7 @@ void Ind_GetIndicatorsCrs (long CrsCod,struct Ind_IndicatorsCrs *Indicators)
Indicators->CountIndicators++;
/* Indicator #5: information about assessment */
- Inf_GetInfoSrcFromDB (CrsCod,Inf_ASSESSMENT,&(Indicators->AssessmentSrc),&MustBeRead);
+ Indicators->AssessmentSrc = Inf_GetInfoSrcFromDB (CrsCod,Inf_ASSESSMENT);
Indicators->ThereIsAssessment = (Indicators->AssessmentSrc != Inf_INFO_SRC_NONE) ||
(Indicators->TeachingGuideSrc != Inf_INFO_SRC_NONE);
if (Indicators->ThereIsAssessment)
diff --git a/swad_info.c b/swad_info.c
index 50687cf5d..48dd77197 100644
--- a/swad_info.c
+++ b/swad_info.c
@@ -330,7 +330,7 @@ void Inf_ShowInfo (void)
Gbl.CurrentCrs.Info.Type = Inf_AsignInfoType ();
/***** Get info source from database *****/
- Inf_GetInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrc,&MustBeRead);
+ Inf_GetAndCheckInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrc,&MustBeRead);
switch (Gbl.CurrentCrs.Info.Type)
{
@@ -1044,7 +1044,7 @@ void Inf_FormsToSelSendInfo (void)
Gbl.CurrentCrs.Info.Type = Inf_AsignInfoType ();
/***** Get current info source from database *****/
- Inf_GetInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrcSelected,&MustBeRead);
+ Inf_GetAndCheckInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrcSelected,&MustBeRead);
/***** Check if info available *****/
for (InfoSrc = (Inf_InfoSrc_t) 0;
@@ -1455,12 +1455,45 @@ void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc)
}
}
+
/*****************************************************************************/
-/********* Get info source for a type of course info from database ***********/
+/***** Get and check info source for a type of course info from database *****/
/*****************************************************************************/
-void Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType,
- Inf_InfoSrc_t *InfoSrc,bool *MustBeRead)
+Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType)
+ {
+ char Query[512];
+ MYSQL_RES *mysql_res;
+ MYSQL_ROW row;
+ Inf_InfoSrc_t InfoSrc;
+
+ /***** Get info source for a specific type of info from database *****/
+ sprintf (Query,"SELECT InfoSrc FROM crs_info_src"
+ " WHERE CrsCod='%ld' AND InfoType='%s'",
+ CrsCod,Inf_NamesInDBForInfoType[InfoType]);
+ if (DB_QuerySELECT (Query,&mysql_res,"can not get info source"))
+ {
+ /* Get row */
+ row = mysql_fetch_row (mysql_res);
+
+ /* Get info source (row[0]) */
+ InfoSrc = Inf_ConvertFromStrDBToInfoSrc (row[0]);
+ }
+ else
+ InfoSrc = Inf_INFO_SRC_NONE;
+
+ /***** Free structure that stores the query result *****/
+ DB_FreeMySQLResult (&mysql_res);
+
+ return InfoSrc;
+ }
+
+/*****************************************************************************/
+/***** Get and check info source for a type of course info from database *****/
+/*****************************************************************************/
+
+void Inf_GetAndCheckInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType,
+ Inf_InfoSrc_t *InfoSrc,bool *MustBeRead)
{
char Query[512];
MYSQL_RES *mysql_res;
@@ -1471,8 +1504,7 @@ void Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType,
*InfoSrc = Inf_INFO_SRC_NONE;
*MustBeRead = false;
- /***** Get info source for a specific type of course information
- (bibliography, FAQ, links or evaluation) from database *****/
+ /***** Get info source for a specific type of info from database *****/
sprintf (Query,"SELECT InfoSrc,MustBeRead FROM crs_info_src"
" WHERE CrsCod='%ld' AND InfoType='%s'",
CrsCod,Inf_NamesInDBForInfoType[InfoType]);
@@ -1587,7 +1619,7 @@ Inf_InfoSrc_t Inf_ConvertFromStrDBToInfoSrc (const char *StrInfoSrcDB)
if (!strcmp (StrInfoSrcDB,Inf_NamesInDBForInfoSrc[InfoSrc]))
return InfoSrc;
- return (Inf_InfoSrc_t) 0;
+ return Inf_INFO_SRC_NONE;
}
/*****************************************************************************/
diff --git a/swad_info.h b/swad_info.h
index 9e5675a6c..5605ef609 100644
--- a/swad_info.h
+++ b/swad_info.h
@@ -85,8 +85,9 @@ void Inf_FormToSendPage (Inf_InfoSrc_t InfoSrc);
void Inf_FormToSendURL (Inf_InfoSrc_t InfoSrc);
Inf_InfoSrc_t Inf_GetInfoSrcFromForm (void);
void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc);
-void Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType,
- Inf_InfoSrc_t *InfoSrc,bool *MustBeRead);
+Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType);
+void Inf_GetAndCheckInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType,
+ Inf_InfoSrc_t *InfoSrc,bool *MustBeRead);
Inf_InfoType_t Inf_ConvertFromStrDBToInfoType (const char *StrInfoTypeDB);
Inf_InfoSrc_t Inf_ConvertFromStrDBToInfoSrc (const char *StrInfoSrcDB);
int Inf_WritePlainTextIntoHTMLBuffer (char **HTMLBuffer);
diff --git a/swad_web_service.c b/swad_web_service.c
index cab856bc1..f78e3bc8c 100644
--- a/swad_web_service.c
+++ b/swad_web_service.c
@@ -1292,7 +1292,7 @@ int swad__getCourseInfo (struct soap *soap,
"Bad info type",
"Unknown requested info type");
Gbl.CurrentCrs.Info.Type = InfoType;
- Inf_GetInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrc,&MustBeRead);
+ Inf_GetAndCheckInfoSrcFromDB (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type,&InfoSrc,&MustBeRead);
getCourseInfo->infoSrc = (char *) soap_malloc (Gbl.soap,strlen (NamesInWSForInfoSrc[InfoSrc]) + 1);
strcpy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc]);