From c3f51e0f988821c1f80712585c4a098e84153a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 4 Jun 2016 19:16:21 +0200 Subject: [PATCH] Version 15.219 --- sql/swad.sql | 2 +- swad_changelog.h | 8 +- swad_database.c | 2 +- swad_indicator.c | 189 +++++++++++++++++++++++++++++++++-------------- 4 files changed, 138 insertions(+), 63 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index dca198274..37a711998 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -953,7 +953,7 @@ CREATE TABLE IF NOT EXISTS social_notes ( Unavailable ENUM('N','Y') NOT NULL DEFAULT 'N', TimeNote DATETIME NOT NULL, UNIQUE INDEX(NotCod), - UNIQUE INDEX(NoteType,Cod), + INDEX(NoteType,Cod), INDEX(UsrCod), INDEX(TimeNote)); -- diff --git a/swad_changelog.h b/swad_changelog.h index 1245dd583..c86328387 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -124,21 +124,21 @@ // 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: Request confirmation to remove user's photo -// TODO: FIX BUG: In Statistics > Indicators, if we select only 5 indicators, the message "The list is too big..." is shown. -// TODO: FIX BUG: A teacher uploads a document in course documents zone, then he/she unregister from course, the he/she search for his/her documents, a document is shown in results but he/she can not view it +// TODO: FIX BUG: A teacher uploads a document in course documents zone, then he/she unregister from course, then he/she search for his/her documents, a document is shown in results but he/she can not view it /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.218.5 (2016-06-04)" +#define Log_PLATFORM_VERSION "SWAD 15.219 (2016-06-04)" #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.218.5: Jun 04, 2016 Fix bug in social notes, reported by Raymon Moreno Colina. (? lines) + Version 15.219: Jun 04, 2016 Changes in listing of indicators of courses. (202001 lines) + Version 15.218.5: Jun 04, 2016 Fix bug in social notes, reported by Raymon Moreno Colina. (201940 lines) 2 changes necessary in database: DROP INDEX NoteType ON social_notes; CREATE INDEX NoteType ON social_notes (NoteType,Cod); diff --git a/swad_database.c b/swad_database.c index e97a255e3..0aed15ac1 100644 --- a/swad_database.c +++ b/swad_database.c @@ -2019,7 +2019,7 @@ mysql> DESCRIBE social_notes; "Unavailable ENUM('N','Y') NOT NULL DEFAULT 'N'," "TimeNote DATETIME NOT NULL," "UNIQUE INDEX(NotCod)," - "UNIQUE INDEX(NoteType,Cod)," + "INDEX(NoteType,Cod)," "INDEX(UsrCod)," "INDEX(TimeNote))"); diff --git a/swad_indicator.c b/swad_indicator.c index 964bba18a..0dd01cea8 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -64,7 +64,13 @@ static long Ind_GetParamNumIndicators (void); static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res); static bool Ind_GetIfShowBigList (unsigned NumCrss); static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss); -static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t IndicatorsLayout,unsigned NumCrss,MYSQL_RES *mysql_res); + +static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS], + unsigned NumCrss,MYSQL_RES *mysql_res); +static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS], + unsigned NumCrss); +static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t IndicatorsLayout, + unsigned NumCrss,MYSQL_RES *mysql_res); static unsigned long Ind_GetNumFilesOfCrsFileZoneFromDB (Brw_FileBrowser_t FileBrowser,long CrsCod); /*****************************************************************************/ @@ -87,6 +93,8 @@ void Ind_ReqIndicatorsCourses (void) MYSQL_RES *mysql_res; unsigned Ind; unsigned NumCrss; + unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS]; + unsigned NumCrssToList; /***** Start frame *****/ Lay_StartRoundFrame (NULL,Txt_Indicators_of_courses,NULL); @@ -178,8 +186,25 @@ void Ind_ReqIndicatorsCourses (void) Act_FormEnd (); /***** 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); - if (Ind_GetIfShowBigList (NumCrss)) + + /***** 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 *****/ + Ind_ShowNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss); + + if (Gbl.Stat.NumIndicators < 0) // -1 means any number of indicators + NumCrssToList = NumCrss; + else + NumCrssToList = NumCrssWithIndicatorYes[(unsigned) Gbl.Stat.NumIndicators]; + + if (Ind_GetIfShowBigList (NumCrssToList)) { /***** Show the stats of courses *****/ /* Show table */ @@ -210,6 +235,7 @@ void Ind_ShowIndicatorsCourses (void) { MYSQL_RES *mysql_res; unsigned NumCrss; + unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS]; /***** Get users range for statistics of courses *****/ Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS | @@ -223,7 +249,7 @@ void Ind_ShowIndicatorsCourses (void) /***** Get degree type code *****/ Gbl.Stat.DegTypCod = (Gbl.Scope.Current == Sco_SCOPE_SYS) ? DT_GetParamOtherDegTypCod () : - -1L; + -1L; /***** Get department code *****/ Gbl.Stat.DptCod = Dpt_GetParamDptCod (); @@ -234,6 +260,12 @@ void Ind_ShowIndicatorsCourses (void) /***** Get courses from database *****/ 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); + + /***** Show table with numbers of courses with 0, 1, 2... indicators set to yes *****/ + Ind_ShowNumCoursesWithIndicators (NumCrssWithIndicatorYes,NumCrss); + /***** Show the stats of courses *****/ Ind_ShowTableOfCoursesWithIndicators (Ind_INDICATORS_FULL,NumCrss,mysql_res); @@ -486,11 +518,106 @@ static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss) fprintf (Gbl.F.Out,""); } +/*****************************************************************************/ +/** Get vector with numbers of courses with 0, 1, 2... indicators set to yes */ +/*****************************************************************************/ + +static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS], + unsigned NumCrss,MYSQL_RES *mysql_res) + { + MYSQL_ROW row; + unsigned NumCrs; + long CrsCod; + unsigned Ind; + struct Ind_IndicatorsCrs Indicators; + + /***** 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."); + + /* Get indicators of this course */ + Ind_GetIndicatorsCrs (CrsCod,&Indicators); + NumCrssWithIndicatorYes[Indicators.CountIndicators]++; + } + } + +/*****************************************************************************/ +/** Show table with numbers of courses with 0, 1, 2... indicators set to yes */ +/*****************************************************************************/ + +static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS], + unsigned NumCrss) + { + extern const char *Txt_No_of_indicators; + extern const char *Txt_Courses; + extern const char *Txt_Total; + unsigned Ind; + + /***** Write number of courses with each number of indicators valid *****/ + fprintf (Gbl.F.Out,"" + "" + "" + "" + "", + Txt_No_of_indicators, + Txt_Courses); + for (Ind = 0; + Ind <= Ind_NUM_INDICATORS; + Ind++) + fprintf (Gbl.F.Out,"" + "" + "" + "" + "", + Ind,NumCrssWithIndicatorYes[Ind], + NumCrss ? (float) NumCrssWithIndicatorYes[Ind] * 100.0 / (float) NumCrss : + 0.0); + fprintf (Gbl.F.Out,"" + "" + "" + "" + "" + "
" + "%s" + "" + "%s" + "
" + "%u" + "" + "%u" + "" + "(%.1f%%)" + "
" + "%s" + "" + "%u" + "" + "(%.1f%%)" + "
", + Txt_Total,NumCrss,100.0); + } + /*****************************************************************************/ /****************** Get and show total number of courses *********************/ /*****************************************************************************/ -static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t IndicatorsLayout,unsigned NumCrss,MYSQL_RES *mysql_res) +static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t IndicatorsLayout, + unsigned NumCrss,MYSQL_RES *mysql_res) { extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; extern const char *Txt_Degree; @@ -524,8 +651,6 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat MYSQL_ROW row; unsigned NumCrs; long CrsCod; - unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS]; - unsigned Ind; unsigned NumTchs; unsigned NumStds; struct Ind_IndicatorsCrs Indicators; @@ -794,13 +919,8 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat break; } - /***** Reset counters of courses with each number of indicators *****/ - for (Ind = 0; - Ind <= Ind_NUM_INDICATORS; - Ind++) - NumCrssWithIndicatorYes[Ind] = 0; - /***** List courses *****/ + mysql_data_seek (mysql_res, 0); for (Gbl.RowEvenOdd = 1, NumCrs = 0; NumCrs < NumCrss; NumCrs++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) @@ -814,7 +934,6 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat /* Get indicators of this course */ Ind_GetIndicatorsCrs (CrsCod,&Indicators); - NumCrssWithIndicatorYes[Indicators.CountIndicators]++; if (Gbl.Stat.NumIndicators < 0 || // -1 means any number of indicators Gbl.Stat.NumIndicators == (long) Indicators.CountIndicators) @@ -1169,50 +1288,6 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat /***** End table *****/ fprintf (Gbl.F.Out,""); - - /***** Write number of courses with each number of indicators valid *****/ - fprintf (Gbl.F.Out,"" - "" - "" - "" - "", - Txt_No_of_indicators, - Txt_Courses); - for (Ind = 0; - Ind <= Ind_NUM_INDICATORS; - Ind++) - fprintf (Gbl.F.Out,"" - "" - "" - "" - "", - Ind,NumCrssWithIndicatorYes[Ind], - NumCrss ? (float) NumCrssWithIndicatorYes[Ind] * 100.0 / (float) NumCrss : - 0.0); - fprintf (Gbl.F.Out,"" - "" - "" - "" - "" - "
" - "%s" - "" - "%s" - "
" - "%u" - "" - "%u" - "" - "(%.1f%%)" - "
" - "%s" - "" - "%u" - "" - "(%.1f%%)" - "
", - Txt_Total,NumCrss,100.0); } /*****************************************************************************/