diff --git a/swad_action.c b/swad_action.c index bccb258d4..b688cea28 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2158,7 +2158,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActSeeMyTstRes */{1084,-1,TabUnk,ActReqTst ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_ShowMyTstResults ,NULL}, /* ActSeeOneTstResMe */{1085,-1,TabUnk,ActReqTst ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_ShowOneTstResult ,NULL}, /* ActReqSeeUsrTstRes*/{1080,-1,TabUnk,ActReqTst ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,Tst_SelUsrsToViewUsrsTstResults,NULL}, - /* ActSeeUsrTstRes */{1081,-1,TabUnk,ActReqTst ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_ShowUsrsTstResults ,NULL}, + /* ActSeeUsrTstRes */{1081,-1,TabUnk,ActReqTst ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_GetUsrsAndShowTstResults ,NULL}, /* ActSeeOneTstResOth*/{1082,-1,TabUnk,ActReqTst ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Tst_ShowOneTstResult ,NULL}, /* ActSeeGam */{1650,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_SeeOneGame ,NULL}, @@ -2184,7 +2184,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActSeeOneMchResMe */{1797,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowOneMchResult ,NULL}, /* ActReqSeeUsrMchRes*/{1798,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,McR_SelUsrsToViewUsrsMchResults,NULL}, - /* ActSeeUsrMchRes */{1799,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowUsrsMchResults ,NULL}, + /* ActSeeUsrMchRes */{1799,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_GetUsrsAndShowMchResults ,NULL}, /* ActSeeOneMchResOth*/{1800,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,McR_ShowOneMchResult ,NULL}, /* ActChgVisResMchUsr*/{1801,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_ToggleVisibilResultsMchUsr ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index 07036fffb..b6d97a120 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -487,7 +487,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.68 (2019-11-14)" +#define Log_PLATFORM_VERSION "SWAD 19.68.1 (2019-11-14)" #define CSS_FILE "swad19.47.css" #define JS_FILE "swad19.65.js" /* @@ -495,6 +495,8 @@ ps2pdf source.ps destination.pdf // TODO: Impedir la creación y edición de proyectos si no son editables. // TODO: Code refactoring in HTML h1, title, meta, video, p, iframe, input hidden, area + Version 19.68.1: Nov 14, 2019 Code refactoring in match results. + Code refactoring in test results. (246623 lines) Version 19.68: Nov 14, 2019 Code refactoring in projects. (246642 lines) 1 change necessary in database: INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1805','es','N','Seleccionar usuarios para ver sus proyectos'); diff --git a/swad_match_result.c b/swad_match_result.c index ee8d555fc..e0dd8f3ec 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -69,6 +69,7 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ +static void McR_ShowUsrsMchResults (void); static void McR_ShowHeaderMchResults (Usr_MeOrOther_t MeOrOther); static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther); static void McR_ShowMchResultsSummaryRow (bool ShowSummaryResults, @@ -256,59 +257,51 @@ void McR_SelUsrsToViewUsrsMchResults (void) Grp_FreeListCodSelectedGrps (); } +/*****************************************************************************/ +/****************** Get users and show their matches results *****************/ +/*****************************************************************************/ + +void McR_GetUsrsAndShowMchResults (void) + { + Usr_GetSelectedUsrsAndGoToAct (McR_ShowUsrsMchResults, + McR_SelUsrsToViewUsrsMchResults); + } + /*****************************************************************************/ /****************** Show matches results for several users *******************/ /*****************************************************************************/ -void McR_ShowUsrsMchResults (void) +static void McR_ShowUsrsMchResults (void) { extern const char *Hlp_ASSESSMENT_Games_results; extern const char *Txt_Results; - extern const char *Txt_You_must_select_one_ore_more_users; const char *Ptr; - /***** Get list of the selected users's IDs *****/ - Usr_GetListsSelectedUsrsCods (); - /***** Get starting and ending dates *****/ Dat_GetIniEndDatesFromForm (); - /***** Check the number of users whose matches results will be shown *****/ - if (Usr_CheckIfThereAreUsrsInListOfSelectedEncryptedUsrCods ()) // If some users are selected... + /***** Begin box and table *****/ + Box_StartBoxTable (NULL,Txt_Results,NULL, + Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE,2); + + /***** Header of the table with the list of users *****/ + McR_ShowHeaderMchResults (Usr_OTHER); + + /***** List the matches results of the selected users *****/ + Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; + while (*Ptr) { - /***** Begin box and table *****/ - Box_StartBoxTable (NULL,Txt_Results,NULL, - Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE,2); - - /***** Header of the table with the list of users *****/ - McR_ShowHeaderMchResults (Usr_OTHER); - - /***** List the matches results of the selected users *****/ - Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; - while (*Ptr) - { - Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod, - Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); - Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); - if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get of the database the data of the user - if (Usr_CheckIfICanViewMch (&Gbl.Usrs.Other.UsrDat)) - /***** Show matches results *****/ - McR_ShowMchResults (Usr_OTHER); - } - - /***** End table and box *****/ - Box_EndBoxTable (); - } - else // If no users are selected... - { - // ...write warning alert - Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_users); - // ...and show again the form - McR_SelUsrsToViewUsrsMchResults (); + Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod, + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); + Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get of the database the data of the user + if (Usr_CheckIfICanViewMch (&Gbl.Usrs.Other.UsrDat)) + /***** Show matches results *****/ + McR_ShowMchResults (Usr_OTHER); } - /***** Free memory used by list of selected users' codes *****/ - Usr_FreeListsSelectedEncryptedUsrsCods (); + /***** End table and box *****/ + Box_EndBoxTable (); } /*****************************************************************************/ diff --git a/swad_match_result.h b/swad_match_result.h index fdc2e3200..c8bc9dd0c 100644 --- a/swad_match_result.h +++ b/swad_match_result.h @@ -39,7 +39,7 @@ void McR_PutFormToViewMchResults (Act_Action_t Action); void McR_SelDatesToSeeMyMchResults (void); void McR_ShowMyMchResults (void); void McR_SelUsrsToViewUsrsMchResults (void); -void McR_ShowUsrsMchResults (void); +void McR_GetUsrsAndShowMchResults (void); void McR_ShowOneMchResult (void); void McR_GetMatchResultQuestionsFromDB (long MchCod,long UsrCod, unsigned *NumQsts,unsigned *NumQstsNotBlank); diff --git a/swad_project.c b/swad_project.c index 597b3219f..91d8d12a1 100644 --- a/swad_project.c +++ b/swad_project.c @@ -275,12 +275,8 @@ void Prj_SeeProjects (void) Prj_ShowProjectsInCurrentPage (); break; case Usr_WHO_SELECTED: - // if (Gbl.Prjs.Filter.ReqUsrs) // Request the selection of users - /* List users to select some of them */ - // Prj_ReqListUsrsToSelect (); - //else - /* Show projects of selected users */ - Prj_GetSelectedUsrsAndShowPrjs (); + /* Get selected users and show their projects */ + Prj_GetSelectedUsrsAndShowPrjs (); break; default: break; @@ -294,7 +290,7 @@ void Prj_SeeProjects (void) static void Prj_GetSelectedUsrsAndShowPrjs (void) { Usr_GetSelectedUsrsAndGoToAct (Prj_ShowProjectsInCurrentPage,// when user(s) selected - Prj_ReqUsrsToSelect); // when no user selected + Prj_ReqUsrsToSelect); // when no user selected } /*****************************************************************************/ @@ -816,10 +812,6 @@ static void Prj_GetParamWho (void) /***** Get which users I want to see *****/ Gbl.Prjs.Filter.Who = Usr_GetHiddenParamWho (); - /***** If parameter Who is not present, get it from database *****/ - // if (Gbl.Prjs.Filter.Who == Usr_WHO_UNKNOWN) - // Gbl.Prjs.Filter.Who = Prj_GetWhoFromDB (); - /***** If parameter Who is unknown, set it to default *****/ if (Gbl.Prjs.Filter.Who == Usr_WHO_UNKNOWN) Gbl.Prjs.Filter.Who = Prj_FILTER_WHO_DEFAULT; diff --git a/swad_test.c b/swad_test.c index 6df0780fe..a5b007fc5 100644 --- a/swad_test.c +++ b/swad_test.c @@ -283,6 +283,7 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Level_t Scope,Ts static long Tst_CreateTestResultInDB (void); static void Tst_StoreScoreOfTestResultInDB (long TstCod, unsigned NumQstsNotBlank,double Score); +static void Tst_ShowUsrsTstResults (void); static void Tst_ShowHeaderTestResults (void); static void Tst_ShowTstResults (struct UsrData *UsrDat); static void Tst_PutParamTstCod (long TstCod); @@ -7628,59 +7629,51 @@ static void Tst_StoreScoreOfTestResultInDB (long TstCod, Str_SetDecimalPointToLocal (); // Return to local system } +/*****************************************************************************/ +/******************* Get users and show their test results *******************/ +/*****************************************************************************/ + +void Tst_GetUsrsAndShowTstResults (void) + { + Usr_GetSelectedUsrsAndGoToAct (Tst_ShowUsrsTstResults, + Tst_SelUsrsToViewUsrsTstResults); + } + /*****************************************************************************/ /******************** Show test results for several users ********************/ /*****************************************************************************/ -void Tst_ShowUsrsTstResults (void) +static void Tst_ShowUsrsTstResults (void) { extern const char *Hlp_ASSESSMENT_Tests_results; extern const char *Txt_Results; - extern const char *Txt_You_must_select_one_ore_more_users; const char *Ptr; - /***** Get list of the selected users's IDs *****/ - Usr_GetListsSelectedUsrsCods (); - /***** Get starting and ending dates *****/ Dat_GetIniEndDatesFromForm (); - /***** Check the number of users whose tests results will be shown *****/ - if (Usr_CheckIfThereAreUsrsInListOfSelectedEncryptedUsrCods ()) // If some users are selected... + /***** Begin box and table *****/ + Box_StartBoxTable (NULL,Txt_Results,NULL, + Hlp_ASSESSMENT_Tests_results,Box_NOT_CLOSABLE,2); + + /***** Header of the table with the list of users *****/ + Tst_ShowHeaderTestResults (); + + /***** List the test exams of the selected users *****/ + Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; + while (*Ptr) { - /***** Begin box and table *****/ - Box_StartBoxTable (NULL,Txt_Results,NULL, - Hlp_ASSESSMENT_Tests_results,Box_NOT_CLOSABLE,2); - - /***** Header of the table with the list of users *****/ - Tst_ShowHeaderTestResults (); - - /***** List the test exams of the selected users *****/ - Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; - while (*Ptr) - { - Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod, - Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); - Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); - if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get of the database the data of the user - if (Usr_CheckIfICanViewTst (&Gbl.Usrs.Other.UsrDat)) - /***** Show test results *****/ - Tst_ShowTstResults (&Gbl.Usrs.Other.UsrDat); - } - - /***** End table and box *****/ - Box_EndBoxTable (); - } - else // If no users are selected... - { - // ...write warning alert - Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_users); - // ...and show again the form - Tst_SelUsrsToViewUsrsTstResults (); + Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod, + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); + Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get of the database the data of the user + if (Usr_CheckIfICanViewTst (&Gbl.Usrs.Other.UsrDat)) + /***** Show test results *****/ + Tst_ShowTstResults (&Gbl.Usrs.Other.UsrDat); } - /***** Free memory used by list of selected users' codes *****/ - Usr_FreeListsSelectedEncryptedUsrsCods (); + /***** End table and box *****/ + Box_EndBoxTable (); } /*****************************************************************************/ diff --git a/swad_test.h b/swad_test.h index e82c1baa4..9462358e1 100644 --- a/swad_test.h +++ b/swad_test.h @@ -211,7 +211,7 @@ void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats); void Tst_SelUsrsToViewUsrsTstResults (void); void Tst_SelDatesToSeeMyTstResults (void); void Tst_ShowMyTstResults (void); -void Tst_ShowUsrsTstResults (void); +void Tst_GetUsrsAndShowTstResults (void); void Tst_ShowOneTstResult (void); void Tst_ShowTestResult (struct UsrData *UsrDat, unsigned NumQsts,time_t TstTimeUTC);