diff --git a/swad_changelog.h b/swad_changelog.h index ac0e68c4..adc62da9 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -134,14 +134,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.220.1 (2016-06-08)" +#define Log_PLATFORM_VERSION "SWAD 15.221 (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.220.2: Jun 08, 2016 Single (radio) selection of number of indicators changed to multiple (checkbox) selection. (? 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) Version 15.219.1: Jun 05, 2016 Highlighted row with number of indicators selected. (202023 lines) diff --git a/swad_global.h b/swad_global.h index 1e814f8c..6ee812f0 100644 --- a/swad_global.h +++ b/swad_global.h @@ -50,6 +50,7 @@ #include "swad_image.h" #include "swad_import.h" #include "swad_icon.h" +#include "swad_indicator.h" #include "swad_institution.h" #include "swad_layout.h" #include "swad_link.h" @@ -708,7 +709,8 @@ struct Globals unsigned long RowsPerPage; long DegTypCod; long DptCod; - long NumIndicators; + char StrIndicatorsSelected[Ind_MAX_SIZE_INDICATORS_SELECTED+1]; + bool IndicatorsSelected[1+Ind_NUM_INDICATORS]; struct { Pho_AvgPhotoTypeOfAverage_t TypeOfAverage; @@ -719,13 +721,6 @@ struct Globals float MaxPercent; } DegPhotos; } Stat; - /* - struct - { - Img_Action_t Action; - Img_FileStatus_t Status; - } Image; - */ }; /*****************************************************************************/ diff --git a/swad_indicator.c b/swad_indicator.c index 23bdbb8b..be04afd9 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -60,7 +60,7 @@ typedef enum /***************************** Internal prototypes ***************************/ /*****************************************************************************/ -static long Ind_GetParamNumIndicators (void); +static void Ind_GetParamNumIndicators (void); static unsigned Ind_GetTableOfCourses (MYSQL_RES **mysql_res); static bool Ind_GetIfShowBigList (unsigned NumCrss); static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss); @@ -93,6 +93,7 @@ void Ind_ReqIndicatorsCourses (void) unsigned NumCrss; unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS]; unsigned NumCrssToList; + unsigned Ind; /***** Get scope *****/ Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS | @@ -160,7 +161,7 @@ void Ind_ReqIndicatorsCourses (void) ""); /* Selection of the number of indicators */ - Gbl.Stat.NumIndicators = Ind_GetParamNumIndicators (); + Ind_GetParamNumIndicators (); fprintf (Gbl.F.Out,"" "" "" @@ -184,10 +185,11 @@ void Ind_ReqIndicatorsCourses (void) Act_FormEnd (); /***** Show the stats of courses *****/ - if (Gbl.Stat.NumIndicators < 0) // -1 means any number of indicators - NumCrssToList = NumCrss; - else - NumCrssToList = NumCrssWithIndicatorYes[(unsigned) Gbl.Stat.NumIndicators]; + for (Ind = 0, NumCrssToList = 0; + Ind <= Ind_NUM_INDICATORS; + Ind++) + if (Gbl.Stat.IndicatorsSelected[Ind]) + NumCrssToList += NumCrssWithIndicatorYes[Ind]; if (Ind_GetIfShowBigList (NumCrssToList)) { /* Show table */ @@ -198,7 +200,8 @@ void Ind_ReqIndicatorsCourses (void) Sco_PutParamScope (Gbl.Scope.Current); Par_PutHiddenParamLong ("OthDegTypCod",Gbl.Stat.DegTypCod); Par_PutHiddenParamLong ("DptCod",Gbl.Stat.DptCod); - Par_PutHiddenParamLong ("Indicators",Gbl.Stat.NumIndicators); + if (Gbl.Stat.StrIndicatorsSelected[0]) + Par_PutHiddenParamString ("Indicators",Gbl.Stat.StrIndicatorsSelected); Lay_PutConfirmButton (Txt_Show_more_details); Act_FormEnd (); } @@ -238,7 +241,7 @@ void Ind_ShowIndicatorsCourses (void) Gbl.Stat.DptCod = Dpt_GetParamDptCod (); /***** Get number of indicators *****/ - Gbl.Stat.NumIndicators = Ind_GetParamNumIndicators (); + Ind_GetParamNumIndicators (); /***** Get courses from database *****/ NumCrss = Ind_GetTableOfCourses (&mysql_res); @@ -260,13 +263,48 @@ void Ind_ShowIndicatorsCourses (void) /*************** Get parameter with the number of indicators *****************/ /*****************************************************************************/ -static long Ind_GetParamNumIndicators (void) +static void Ind_GetParamNumIndicators (void) { + unsigned Ind; + const char *Ptr; char LongStr[1+10+1]; + long Indicator; - /***** Get parameter with code of department *****/ - Par_GetParToText ("Indicators",LongStr,1+10); - return Str_ConvertStrCodToLongCod (LongStr); + /***** Get parameter multiple with list of indicators selected *****/ + Par_GetParMultiToText ("Indicators",Gbl.Stat.StrIndicatorsSelected,Ind_MAX_SIZE_INDICATORS_SELECTED); + + /***** 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 */ + Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1+10); + 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; } /*****************************************************************************/ @@ -492,7 +530,8 @@ static void Ind_PutButtonToConfirmIWantToSeeBigList (unsigned NumCrss) Sco_PutParamScope (Gbl.Scope.Current); Par_PutHiddenParamLong ("OthDegTypCod",Gbl.Stat.DegTypCod); Par_PutHiddenParamLong ("DptCod",Gbl.Stat.DptCod); - Par_PutHiddenParamLong ("Indicators",Gbl.Stat.NumIndicators); + if (Gbl.Stat.StrIndicatorsSelected[0]) + Par_PutHiddenParamString ("Indicators",Gbl.Stat.StrIndicatorsSelected); Par_PutHiddenParamChar ("ShowBigList",'Y'); /***** Send button *****/ @@ -545,15 +584,13 @@ static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1+ static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1+Ind_NUM_INDICATORS], unsigned NumCrss,bool PutForm) { - extern const char *Txt_No_of_indicators; + extern const char *Txt_Indicators; extern const char *Txt_Courses; - extern const char *Txt_Any_number; + extern const char *Txt_Total; unsigned Ind; const char *Class; - const char *ClassNormal = "DAT RIGHT_MIDDLE"; - const char *ClassHighlight = "DAT_N RIGHT_MIDDLE LIGHT_BLUE"; - const char *ClassTotalNormal = "DAT_N_LINE_TOP RIGHT_MIDDLE"; - const char *ClassTotalHighlight = "DAT_N_LINE_TOP RIGHT_MIDDLE LIGHT_BLUE"; + const char *ClassNormal = "DAT_LIGHT RIGHT_MIDDLE"; + const char *ClassHighlight = "DAT RIGHT_MIDDLE LIGHT_BLUE"; /***** Write number of courses with each number of indicators valid *****/ fprintf (Gbl.F.Out,"" @@ -567,21 +604,21 @@ static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 "%s" "" "", - Txt_No_of_indicators, + Txt_Indicators, Txt_Courses); for (Ind = 0; Ind <= Ind_NUM_INDICATORS; Ind++) { - Class = (Ind == Gbl.Stat.NumIndicators) ? ClassHighlight : - ClassNormal; + Class = Gbl.Stat.IndicatorsSelected[Ind] ? ClassHighlight : + ClassNormal; fprintf (Gbl.F.Out,""); if (PutForm) { fprintf (Gbl.F.Out,""); @@ -606,35 +643,23 @@ static void Ind_ShowNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1 } /***** Write total of courses *****/ - Class = (Gbl.Stat.NumIndicators < 0) ? ClassTotalHighlight : - ClassTotalNormal; fprintf (Gbl.F.Out,""); if (PutForm) - { - fprintf (Gbl.F.Out,""); - } - fprintf (Gbl.F.Out,"" - "" - "" "" "
" - "" "
" - "" + fprintf (Gbl.F.Out,"" "" + fprintf (Gbl.F.Out,"" "%s" "" + "" "%u" "" + "" "(%.1f%%)" "
", - Class, - Txt_Any_number, - Class, + Txt_Total, NumCrss, - Class, 100.0); } @@ -960,8 +985,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat /* Get indicators of this course */ Ind_GetIndicatorsCrs (CrsCod,&Indicators); - if (Gbl.Stat.NumIndicators < 0 || // -1 means any number of indicators - Gbl.Stat.NumIndicators == (long) Indicators.CountIndicators) + if (Gbl.Stat.IndicatorsSelected[Indicators.CountIndicators]) { /* Write a row for this course */ switch (IndicatorsLayout) diff --git a/swad_indicator.h b/swad_indicator.h index a116a127..6898c55f 100644 --- a/swad_indicator.h +++ b/swad_indicator.h @@ -32,6 +32,8 @@ /*****************************************************************************/ #define Ind_NUM_INDICATORS 5 +#define Ind_MAX_SIZE_INDICATORS_SELECTED ((1+Ind_NUM_INDICATORS)*(10+1)) + struct Ind_IndicatorsCrs { unsigned long NumFilesInDocumentZones; diff --git a/swad_text.c b/swad_text.c index 35552408..53f4cb56 100644 --- a/swad_text.c +++ b/swad_text.c @@ -2804,27 +2804,6 @@ const char *Txt_Any_department = "Qualquer departamento"; #endif -const char *Txt_Any_number = -#if L==1 - "Qualsevol nombre"; -#elif L==2 - "Alle Anzahl"; -#elif L==3 - "Any number"; -#elif L==4 - "Cualquier número"; -#elif L==5 - "Tout nombre"; -#elif L==6 - "Cualquier número"; // Okoteve traducción -#elif L==7 - "Qualsiasi numero"; -#elif L==8 - "Wszystkie liczba"; -#elif L==9 - "Qualquer número"; -#endif - const char *Txt_any_user = #if L==1 "qualsevol usuari";