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,"