From 3ac8d2b49ed48dc17be78a08fe1db74014ecc0ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 29 May 2017 21:34:43 +0200 Subject: [PATCH] Version 16.226 --- css/{swad16.222.css => swad16.226.css} | 20 ++++++----- swad_assignment.c | 3 ++ swad_attendance.c | 6 ++-- swad_changelog.h | 5 +-- swad_connected.c | 4 +-- swad_course.c | 19 +--------- swad_duplicate.c | 6 ++-- swad_enrolment.c | 50 +++++++++++--------------- swad_enrolment.h | 4 +-- swad_exam.c | 5 ++- swad_file_browser.c | 6 +++- swad_forum.c | 5 +++ swad_help.c | 33 ++++++++--------- swad_layout.c | 20 +++++++++++ swad_layout.h | 1 + swad_mail.c | 3 +- swad_mark.c | 9 ++--- swad_message.c | 3 ++ swad_notice.c | 3 ++ swad_statistic.c | 3 ++ swad_test.c | 3 +- swad_user.c | 44 +++++++++++++---------- 22 files changed, 141 insertions(+), 114 deletions(-) rename css/{swad16.222.css => swad16.226.css} (99%) diff --git a/css/swad16.222.css b/css/swad16.226.css similarity index 99% rename from css/swad16.222.css rename to css/swad16.226.css index 630d69e5c..62009bd3d 100644 --- a/css/swad16.222.css +++ b/css/swad16.226.css @@ -1309,27 +1309,30 @@ a:hover /* Default ==> underlined */ } .BT_SUBMIT { - color:white; - font-size:20px; - font-weight:bold; - line-height:normal; margin:8px auto; padding:10px 20px; border-radius:4px; box-shadow:0 1px 0 rgba(255,255,255,0.15) inset; + color:white; + font-size:20px; + font-weight:bold; + line-height:normal; + white-space:nowrap; } .BT_SUBMIT_INLINE { box-sizing:border-box; min-width:170px; + margin:0 10px; + padding:2px 4px; + border-radius:4px; + box-shadow:0 1px 0 rgba(255,255,255,0.15) inset; color:white; font-size:15px; font-weight:bold; line-height:normal; - margin:0 10px; - padding:4px; - border-radius:4px; - box-shadow:0 1px 0 rgba(255,255,255,0.15) inset; + white-space:nowrap; + vertical-align:middle; } .BT_SUBMIT:hover { @@ -1490,7 +1493,6 @@ a:hover /* Default ==> underlined */ { display:inline-block; box-sizing:border-box; - max-width:90%; margin:8px auto; padding:12px; background-color:#FFF9EA; diff --git a/swad_assignment.c b/swad_assignment.c index ff7580d51..f2d7f61e9 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -165,6 +165,9 @@ static void Asg_ShowAllAssignments (void) if (Asg_CheckIfICanCreateAssignments ()) Asg_PutButtonToCreateNewAsg (); + /***** Put link to register students *****/ + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); + /***** End frame *****/ Lay_EndRoundFrame (); diff --git a/swad_attendance.c b/swad_attendance.c index d11e44db7..34e6f3925 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1994,7 +1994,8 @@ static void Att_ListAttStudents (struct AttendanceEvent *Att) /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); } - else + else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 + /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); /***** End section with user list *****/ @@ -2699,7 +2700,8 @@ void Usr_ReqListStdsAttendanceCrs (void) Usr_FreeListsSelectedUsrsCods (); } } - else + else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 + /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); /***** End section with user list *****/ diff --git a/swad_changelog.h b/swad_changelog.h index a8658eb4b..f1c0d3d73 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -235,13 +235,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.225.12 (2017-05-29)" -#define CSS_FILE "swad16.222.css" +#define Log_PLATFORM_VERSION "SWAD 16.226 (2017-05-29)" +#define CSS_FILE "swad16.226.css" #define JS_FILE "swad16.206.3.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 16.226: May 29, 2017 Code refactoring in buttons. (220607 lines) Version 16.225.12:May 29, 2017 Button to register students in connected and requests. (220587 lines) Version 16.225.11:May 29, 2017 Button to register students everytime an alert with no students in course is displayed. (220581 lines) Version 16.225.10:May 29, 2017 Buttons to register students in listing of teacher's courses. (220561 lines) diff --git a/swad_connected.c b/swad_connected.c index 8af2a38e8..29b2d74d4 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -492,9 +492,7 @@ static void Con_ShowConnectedUsrsBelongingToLocation (void) fprintf (Gbl.F.Out,""); /***** Put link to register students *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_TCH) // Course selected and I am logged as teacher - if (!Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD]) // No students in course - Usr_ShowWarningNoUsersFound (Rol_STD); + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); /***** End container *****/ fprintf (Gbl.F.Out,""); diff --git a/swad_course.c b/swad_course.c index bea90d3d6..66b2ed111 100644 --- a/swad_course.c +++ b/swad_course.c @@ -514,7 +514,6 @@ static void Crs_WriteListMyCoursesToSelectOne (void) extern const char *Txt_My_courses; extern const char *Txt_System; extern const char *Txt_Go_to_X; - extern const char *Txt_Register_students; struct Country Cty; struct Instit Ins; struct Centre Ctr; @@ -541,7 +540,6 @@ static void Crs_WriteListMyCoursesToSelectOne (void) char ActTxt[Act_MAX_BYTES_ACTION_TXT + 1]; const char *ClassNormal; char ClassHighlight[64]; - Rol_Role_t MyRoleInCrsDB; ClassNormal = The_ClassForm[Gbl.Prefs.Theme]; sprintf (ClassHighlight,"%s LIGHT_BLUE",The_ClassFormDark[Gbl.Prefs.Theme]); @@ -749,22 +747,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Act_FormEnd (); /***** Put link to register students *****/ - MyRoleInCrsDB = Rol_GetRoleInCrs (Crs.CrsCod, - Gbl.Usrs.Me.UsrDat.UsrCod); - if (MyRoleInCrsDB == Rol_TCH) // I am a teacher in this course - { - Crs.NumUsrs[Rol_STD] = Usr_GetNumUsrsInCrs (Rol_STD,Crs.CrsCod); - if (!Crs.NumUsrs[Rol_STD]) // No students in this course - { - Act_FormStart (ActReqEnrSevStd); - Crs_PutParamCrsCod (Crs.CrsCod); - fprintf (Gbl.F.Out,"", - Txt_Register_students); - Act_FormEnd (); - } - } + Enr_PutButtonInlineToRegisterStds (Crs.CrsCod); fprintf (Gbl.F.Out,""); } diff --git a/swad_duplicate.c b/swad_duplicate.c index e5d95f181..4d45cd503 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -223,7 +223,7 @@ void Dup_ListDuplicateUsrs (void) /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); } - else // There are no users + else // There are no duplicated users /***** Show warning indicating no users found *****/ Usr_ShowWarningNoUsersFound (Rol_UNK); @@ -281,7 +281,7 @@ static void Dup_ListSimilarUsrs (void) Gbl.Usrs.Other.UsrDat.UsrCod); NumUsrs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get similar users"); - /***** List possible duplicated users *****/ + /***** List possible similar users *****/ if (NumUsrs) { /***** Initialize field names *****/ @@ -364,7 +364,7 @@ static void Dup_ListSimilarUsrs (void) /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); } - else // There are no users + else // There are no similar users /***** Show warning indicating no users found *****/ Usr_ShowWarningNoUsersFound (Rol_UNK); diff --git a/swad_enrolment.c b/swad_enrolment.c index 37c3d86c8..af8db626f 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -152,39 +152,33 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Sco_Scope_t Scope, long Cod,const char *InsCtrDegName); /*****************************************************************************/ -/***************** Show form with button to enrol students *******************/ +/************ Put button to register students *************/ /*****************************************************************************/ -void Enr_PutButtonToEnrolStudents (void) +void Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (void) { - extern const char *Txt_Register_students; - - /***** Form to enrol several students *****/ - if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected - Gbl.Usrs.Me.LoggedRole == Rol_TCH) // I am logged as teacher - { - Act_FormStart (ActReqEnrSevStd); - Lay_PutCreateButton (Txt_Register_students); - Act_FormEnd (); - } + /***** Put link to register students *****/ + if (Gbl.Usrs.Me.LoggedRole == Rol_TCH) // Course selected and I am logged as teacher + if (!Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD]) // No students in course + Usr_ShowWarningNoUsersFound (Rol_STD); } /*****************************************************************************/ -/**************** Show form with button to enrol teachers ********************/ +/************ Put button to register students *************/ /*****************************************************************************/ -void Enr_PutButtonToEnrolOneTeacher (void) +void Enr_PutButtonInlineToRegisterStds (long CrsCod) { - extern const char *Txt_Register_teacher; + extern const char *Txt_Register_students; - /***** Form to enrol several students *****/ - if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected - Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) // I am an administrator - { - Act_FormStart (ActReqMdfOneTch); - Lay_PutConfirmButton (Txt_Register_teacher); - Act_FormEnd (); - } + if (Rol_GetRoleInCrs (CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod) == Rol_TCH) // I am a teacher in course + if (!Usr_GetNumUsrsInCrs (Rol_STD,CrsCod)) // No students in course + { + Act_FormStart (ActReqEnrSevStd); + Crs_PutParamCrsCod (CrsCod); + Lay_PutCreateButtonInline (Txt_Register_students); + Act_FormEnd (); + } } /*****************************************************************************/ @@ -1838,7 +1832,7 @@ void Enr_AskRemAllStdsThisCrs (void) Lay_StartRoundFrame (NULL,Txt_Remove_all_students,NULL, Hlp_USERS_Administration_remove_all_students); - if ((NumStds = Usr_GetNumUsrsInCrs (Rol_STD,Gbl.CurrentCrs.Crs.CrsCod))) + if (Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD]) { /***** Show question and button to remove students *****/ /* Start alert */ @@ -1856,7 +1850,7 @@ void Enr_AskRemAllStdsThisCrs (void) /* End alert */ Ale_ShowAlertAndButton2 (ActUnk,NULL,NULL,NULL,Lay_NO_BUTTON,NULL); } - else + else // Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD] == 0 /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); @@ -1881,7 +1875,7 @@ void Enr_RemAllStdsThisCrs (void) NumStdsInCrs,Gbl.CurrentCrs.Crs.FullName); Ale_ShowAlert (Ale_SUCCESS,Gbl.Alert.Txt); } - else + else // NumStdsInCrs == 0 /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); } @@ -2933,9 +2927,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) Ale_ShowAlert (Ale_INFO,Txt_No_enrolment_requests); /***** Put link to register students *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_TCH) // Course selected and I am logged as teacher - if (!Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD]) // No students in course - Usr_ShowWarningNoUsersFound (Rol_STD); + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); /***** End frame *****/ Lay_EndRoundFrame (); diff --git a/swad_enrolment.h b/swad_enrolment.h index 5bcd9f8e0..be6bdfc58 100644 --- a/swad_enrolment.h +++ b/swad_enrolment.h @@ -70,8 +70,8 @@ typedef enum /****************************** Public prototypes ****************************/ /*****************************************************************************/ -void Enr_PutButtonToEnrolStudents (void); -void Enr_PutButtonToEnrolOneTeacher (void); +void Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (void); +void Enr_PutButtonInlineToRegisterStds (long CrsCod); void Enr_PutLinkToRequestSignUp (void); diff --git a/swad_exam.c b/swad_exam.c index 00b8282f5..8030dce07 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -689,10 +689,13 @@ static void Exa_ListExamAnnouncements (Exa_TypeViewExamAnnouncement_t TypeViewEx /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); - /***** Button to create a new assignment *****/ + /***** Button to create a new exam announcement *****/ if (ICanEdit) Exa_PutButtonToCreateNewExamAnnouncement (); + /***** Put link to register students *****/ + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); + /***** End frame *****/ Lay_EndRoundFrame (); } diff --git a/swad_file_browser.c b/swad_file_browser.c index 7329aa8c4..319d0810e 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3132,6 +3132,9 @@ void Brw_AskEditWorksCrs (void) /* Form to select type of list used for select several users */ Usr_ShowFormsToSelectUsrListType (ActReqAsgWrkCrs); + /***** Put link to register students *****/ + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); + /* Start form */ Act_FormStart (ActAdmAsgWrkCrs); Grp_PutParamsCodGrps (); @@ -3152,7 +3155,8 @@ void Brw_AskEditWorksCrs (void) Act_FormEnd (); } } - else + else // NumTotalUsrs == 0 + /***** Show warning indicating no users found *****/ Usr_ShowWarningNoUsersFound (Rol_UNK); /***** End section with user list *****/ diff --git a/swad_forum.c b/swad_forum.c index 39410b570..c497a8e51 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2181,6 +2181,11 @@ static void For_WriteLinkToForum (struct Forum *Forum, /***** End row *****/ fprintf (Gbl.F.Out,""); Act_FormEnd (); + + /***** Put link to register students *****/ + if (Forum->Type == For_FORUM_COURSE_USRS) + Enr_PutButtonInlineToRegisterStds (Forum->Location); + fprintf (Gbl.F.Out,""); } diff --git a/swad_help.c b/swad_help.c index 22cf4d72d..3c2bfd023 100644 --- a/swad_help.c +++ b/swad_help.c @@ -61,7 +61,7 @@ extern struct Globals Gbl; static void Hlp_ShowRowHelpWhatWouldYouLikeToDo (const char *Description, Act_Action_t Action, - const char *ClassButton, + Lay_Button_t Button, const char *TxtButton); /*****************************************************************************/ @@ -147,7 +147,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) Gbl.CurrentCrs.Crs.ShrtName); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB], - "BT_REMOVE",Txt_Remove_me); + Lay_REMOVE_BUTTON,Txt_Remove_me); } } else // I do not belong to this course @@ -157,7 +157,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) Gbl.CurrentCrs.Crs.ShrtName); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActReqSignUp, - "BT_CREATE",Txt_Sign_up); + Lay_CREATE_BUTTON,Txt_Sign_up); } } @@ -172,14 +172,14 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) Gbl.CurrentCrs.Crs.ShrtName); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActReqEnrSevStd, - "BT_CREATE",Txt_Register_students); + Lay_CREATE_BUTTON,Txt_Register_students); } if (Gbl.Action.Act != ActMyCrs) // I am not seeing the action to list my courses /* Request list my courses */ Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Go_to_one_of_my_courses, ActMyCrs, - "BT_CONFIRM",Txt_My_courses); + Lay_CONFIRM_BUTTON,Txt_My_courses); } if (Gbl.CurrentDeg.Deg.DegCod > 0) // Degree selected @@ -190,7 +190,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) Gbl.CurrentDeg.Deg.ShrtName); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActSeeCrs, - "BT_CONFIRM",Txt_Courses); + Lay_CONFIRM_BUTTON,Txt_Courses); } else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) // Centre selected { @@ -200,7 +200,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) Gbl.CurrentCtr.Ctr.ShrtName); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActSeeDeg, - "BT_CONFIRM",Txt_Degrees); + Lay_CONFIRM_BUTTON,Txt_Degrees); } else if (Gbl.CurrentIns.Ins.InsCod > 0) // Institution selected { @@ -210,7 +210,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) Gbl.CurrentIns.Ins.ShrtName); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActSeeCtr, - "BT_CONFIRM",Txt_Centres); + Lay_CONFIRM_BUTTON,Txt_Centres); } else if (Gbl.CurrentCty.Cty.CtyCod > 0) // Country selected { @@ -220,33 +220,33 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActSeeIns, - "BT_CONFIRM",Txt_Institutions); + Lay_CONFIRM_BUTTON,Txt_Institutions); } else /* Select a country */ Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.CurrentCty.Cty.CtyCod > 0 ? Txt_Select_another_country : Txt_Select_one_country, ActSeeCty, - "BT_CONFIRM",Txt_Countries); + Lay_CONFIRM_BUTTON,Txt_Countries); if (!Gbl.Usrs.Me.MyPhotoExists) // I have no photo Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Upload_my_picture, ActReqMyPho, - "BT_CREATE",Txt_Upload_photo); + Lay_CREATE_BUTTON,Txt_Upload_photo); } else // I am not logged { /* Log in */ Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Log_in, ActFrmLogIn, - "BT_CONFIRM",Txt_Log_in); + Lay_CONFIRM_BUTTON,Txt_Log_in); /* Sign up */ sprintf (Gbl.Title,Txt_New_on_PLATFORM_Sign_up, Cfg_PLATFORM_SHORT_NAME); Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title, ActFrmMyAcc, - "BT_CREATE",Txt_Create_account); + Lay_CREATE_BUTTON,Txt_Create_account); } /* End table */ @@ -259,7 +259,7 @@ void Hlp_ShowHelpWhatWouldYouLikeToDo (void) static void Hlp_ShowRowHelpWhatWouldYouLikeToDo (const char *Description, Act_Action_t Action, - const char *ClassButton, + Lay_Button_t Button, const char *TxtButton) { /***** Description *****/ @@ -272,10 +272,7 @@ static void Hlp_ShowRowHelpWhatWouldYouLikeToDo (const char *Description, /***** Button *****/ fprintf (Gbl.F.Out,""); Act_FormStart (Action); - fprintf (Gbl.F.Out,"", - ClassButton,TxtButton); + Lay_PutButtonInline (Button,TxtButton); Act_FormEnd (); fprintf (Gbl.F.Out,"" ""); diff --git a/swad_layout.c b/swad_layout.c index df77f48b8..cd6790a65 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1363,6 +1363,26 @@ void Lay_PutButton (Lay_Button_t Button,const char *TxtButton) } } +void Lay_PutButtonInline (Lay_Button_t Button,const char *TxtButton) + { + if (TxtButton) + if (TxtButton[0]) + switch (Button) + { + case Lay_NO_BUTTON: + break; + case Lay_CREATE_BUTTON: + Lay_PutCreateButtonInline (TxtButton); + break; + case Lay_CONFIRM_BUTTON: + Lay_PutConfirmButtonInline (TxtButton); + break; + case Lay_REMOVE_BUTTON: + Lay_PutRemoveButtonInline (TxtButton); + break; + } + } + void Lay_PutCreateButton (const char *TxtButton) { fprintf (Gbl.F.Out,"
" diff --git a/swad_layout.h b/swad_layout.h index 20a9d07e9..51a056368 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -85,6 +85,7 @@ void Lay_PutIconBRemovalNotAllowed (void); void Lay_PutIconRemove (void); void Lay_PutButton (Lay_Button_t Button,const char *TxtButton); +void Lay_PutButtonInline (Lay_Button_t Button,const char *TxtButton); void Lay_PutCreateButton (const char *TxtButton); void Lay_PutCreateButtonInline (const char *TxtButton); void Lay_PutConfirmButton (const char *TxtButton); diff --git a/swad_mail.c b/swad_mail.c index f748a8418..24b773cc4 100644 --- a/swad_mail.c +++ b/swad_mail.c @@ -978,7 +978,8 @@ void Mai_ListEmails (void) "
"); } } - else + else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 + /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); /***** End section with user list *****/ diff --git a/swad_mark.c b/swad_mark.c index 19245157f..c4b71ed9e 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -635,10 +635,7 @@ void Mrk_ShowMyMarks (void) UsrDat = &Gbl.Usrs.Other.UsrDat; } else - { UsrIsOK = false; - Usr_ShowWarningNoUsersFound (Rol_STD); - } } else // Course zone { @@ -648,10 +645,7 @@ void Mrk_ShowMyMarks (void) UsrDat = &Gbl.Usrs.Other.UsrDat; } else - { UsrIsOK = false; - Usr_ShowWarningNoUsersFound (Rol_STD); - } } } @@ -706,6 +700,9 @@ void Mrk_ShowMyMarks (void) unlink (FileNameUsrMarks); // File with marks is no longer necessary } + else + /***** Show warning indicating no students found *****/ + Usr_ShowWarningNoUsersFound (Rol_STD); } /*****************************************************************************/ diff --git a/swad_message.c b/swad_message.c index cfa1879ea..d30423cc1 100644 --- a/swad_message.c +++ b/swad_message.c @@ -247,6 +247,9 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]) /***** Form to select type of list used for select several users *****/ Usr_ShowFormsToSelectUsrListType (ActReqMsgUsr); + /***** Put link to register students *****/ + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); + /***** Check if it's a big list *****/ ShowUsrsInCrs = Usr_GetIfShowBigList (NumUsrsInCrs,"CopyMessageToHiddenFields()"); diff --git a/swad_notice.c b/swad_notice.c index f415f558f..73a952c15 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -460,6 +460,9 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing) if (Not_CheckIfICanEditNotices ()) Not_PutButtonToAddNewNotice (); + /***** Put link to register students *****/ + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); + /***** End frame *****/ Lay_EndRoundFrame (); break; diff --git a/swad_statistic.c b/swad_statistic.c index e7b1025c5..fce5842df 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -489,6 +489,9 @@ void Sta_AskShowCrsHits (void) /***** Form to select type of list used for select several users *****/ Usr_ShowFormsToSelectUsrListType (ActReqAccCrs); + /***** Put link to register students *****/ + Enr_CheckStdsAndPutButtonToRegisterStdsInCurrentCrs (); + /***** Start form *****/ Act_FormStartAnchor (ActSeeAccCrs,Sta_STAT_RESULTS_SECTION_ID); diff --git a/swad_test.c b/swad_test.c index 723cb6e9d..c15584b75 100644 --- a/swad_test.c +++ b/swad_test.c @@ -7025,7 +7025,8 @@ void Tst_SelUsrsToSeeUsrsTestResults (void) Act_FormEnd (); } } - else + else // NumTotalUsrs == 0 + /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_UNK); /***** End section with user list *****/ diff --git a/swad_user.c b/swad_user.c index 6e13e1e32..3703614bf 100644 --- a/swad_user.c +++ b/swad_user.c @@ -5941,6 +5941,7 @@ static void Usr_ListMainDataGsts (bool PutCheckBoxToSelectUsr) Usr_UsrDataDestructor (&UsrDat); } else // Gbl.Usrs.LstUsrs[Rol_GST].NumUsrs == 0 + /***** Show warning indicating no guests found *****/ Usr_ShowWarningNoUsersFound (Rol_GST); /***** Free memory for guests list *****/ @@ -6193,6 +6194,7 @@ void Usr_ListAllDataGsts (void) Lay_EndTable (); } else // Gbl.Usrs.LstUsrs[Rol_GST].NumUsrs == 0 + /***** Show warning indicating no guests found *****/ Usr_ShowWarningNoUsersFound (Rol_GST); /***** Free memory for guests list *****/ @@ -6396,6 +6398,7 @@ void Usr_ListAllDataStds (void) free ((void *) GroupNames); } else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 + /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); /***** Free memory for list of selected groups *****/ @@ -6522,7 +6525,7 @@ void Usr_ListAllDataTchs (void) /***** End of table *****/ Lay_EndTable (); } - else // Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs == 0 + else // NumUsrs == 0 /***** Show warning indicating no teachers found *****/ Usr_ShowWarningNoUsersFound (Rol_TCH); @@ -7308,7 +7311,8 @@ void Usr_SeeGuests (void) Act_FormEnd (); } } - else + else // Gbl.Usrs.LstUsrs[Rol_GST].NumUsrs == 0 + /***** Show warning indicating no guests found *****/ Usr_ShowWarningNoUsersFound (Rol_GST); /***** End section with user list *****/ @@ -7482,7 +7486,7 @@ void Usr_SeeStudents (void) } } } - else + else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); @@ -7644,15 +7648,10 @@ void Usr_SeeTeachers (void) } } } - else - { + else // NumUsrs == 0 /***** Show warning indicating no teachers found *****/ Usr_ShowWarningNoUsersFound (Rol_TCH); - /***** Button to enrol a teacher *****/ - Enr_PutButtonToEnrolOneTeacher (); - } - /***** End section with user list *****/ Lay_EndSection (); @@ -7846,7 +7845,8 @@ void Usr_SeeGstClassPhotoPrn (void) Rol_GST,false); Lay_EndTable (); } - else + else // Gbl.Usrs.LstUsrs[Rol_GST].NumUsrs + /***** Show warning indicating no guests found *****/ Usr_ShowWarningNoUsersFound (Rol_GST); /***** Free memory for guests list *****/ @@ -7893,7 +7893,8 @@ void Usr_SeeStdClassPhotoPrn (void) Rol_STD,false); Lay_EndTable (); } - else + else // Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs == 0 + /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STD); /***** Free memory for students list *****/ @@ -7957,7 +7958,7 @@ void Usr_SeeTchClassPhotoPrn (void) Lay_EndTable (); } - else + else // NumUsrs == 0 /***** Show warning indicating no teachers found *****/ Usr_ShowWarningNoUsersFound (Rol_TCH); @@ -8160,16 +8161,23 @@ bool Usr_ChkIfUsrCodExists (long UsrCod) void Usr_ShowWarningNoUsersFound (Rol_Role_t Role) { extern const char *Txt_No_users_found[Rol_NUM_ROLES]; + extern const char *Txt_Register_students; + extern const char *Txt_Register_teacher; if (Role == Rol_STD && // No students found Gbl.Usrs.Me.LoggedRole == Rol_TCH) // Course selected and I am logged as teacher - { - /***** Show alert *****/ - Ale_ShowAlert (Ale_WARNING,Txt_No_users_found[Role]); + /***** Show alert and button to enrol students *****/ + Ale_ShowAlertAndButton (Ale_WARNING,Txt_No_users_found[Rol_STD], + ActReqEnrSevStd,NULL,NULL,NULL, + Lay_CREATE_BUTTON,Txt_Register_students); - /***** Button to enrol students *****/ - Enr_PutButtonToEnrolStudents (); - } + else if (Role == Rol_TCH && // No teachers found + Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected + Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) // I am an administrator + /***** Show alert and button to enrol students *****/ + Ale_ShowAlertAndButton (Ale_WARNING,Txt_No_users_found[Rol_TCH], + ActReqMdfOneTch,NULL,NULL,NULL, + Lay_CREATE_BUTTON,Txt_Register_teacher); else /***** Show alert *****/ Ale_ShowAlert (Ale_INFO,Txt_No_users_found[Role]);