diff --git a/swad_attendance.c b/swad_attendance.c index 817e7a073..03f565f74 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -2266,7 +2266,6 @@ void Att_RegisterStudentsInAttEvent (void) { extern const char *Txt_Presents; extern const char *Txt_Absents; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; struct AttendanceEvent Att; char Format[256]; unsigned NumStd; @@ -2371,7 +2370,8 @@ void Att_RegisterStudentsInAttEvent (void) Lay_ShowAlert (Lay_INFO,Gbl.Message); } else // Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs == 0 - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_STUDENT]); + /***** Show warning indicating no students found *****/ + Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Show the attendance event again *****/ Gbl.AttEvents.AttCod = Att.AttCod; diff --git a/swad_changelog.h b/swad_changelog.h index 435722668..2ffafc925 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -176,8 +176,6 @@ // TODO: When activating folders in groups, go to section for that type of group // TODO: I can not remove a folder inside assignments (see swad.ugr.es -> EC -> assignment acanas) -// TODO: When teacher sees "No hay estudiantes", put a button to add students -// TODO: When admin sees "No hay profesores", put a button to add teachers // TODO: Fix bug in notification content about files sent to plugins like SWADroid: do not write internal name (for example "comun"). Call instead Brw_GetFileNameToShow or similar. @@ -196,13 +194,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.135.2 (2017-02-09)" +#define Log_PLATFORM_VERSION "SWAD 16.135.3 (2017-02-09)" #define CSS_FILE "swad16.135.css" #define JS_FILE "swad16.123.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.135.3: Feb 09, 2017 Code refactoring related to enrolling teachers and students. (212499 lines) Version 16.135.2: Feb 09, 2017 Changes in layout of stats on degrees. (212456 lines) Version 16.135.1: Feb 09, 2017 Link from current date to calendar depending on scope. (212461 lines) Version 16.135: Feb 09, 2017 Changes in layout of tabs. (212452 lines) diff --git a/swad_duplicate.c b/swad_duplicate.c index efbc9c46f..7b57a9a63 100644 --- a/swad_duplicate.c +++ b/swad_duplicate.c @@ -128,7 +128,6 @@ void Dup_ListDuplicateUsrs (void) extern const char *Hlp_USERS_Duplicates_possibly_duplicate_users; extern const char *Txt_Possibly_duplicate_users; extern const char *Txt_Informants; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; char Query[1024]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -223,7 +222,8 @@ void Dup_ListDuplicateUsrs (void) Usr_UsrDataDestructor (&UsrDat); } else // There are no users - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_UNKNOWN]); + /***** Show warning indicating no users found *****/ + Usr_ShowWarningNoUsersFound (Rol_UNKNOWN); /***** End frame *****/ Lay_EndRoundFrame (); @@ -248,7 +248,6 @@ static void Dup_ListSimilarUsrs (void) { extern const char *Hlp_USERS_Duplicates_possibly_similar_users; extern const char *Txt_Similar_users; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; struct UsrData UsrDat; char Query[512]; MYSQL_RES *mysql_res; @@ -363,7 +362,8 @@ static void Dup_ListSimilarUsrs (void) Usr_UsrDataDestructor (&UsrDat); } else // There are no users - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_UNKNOWN]); + /***** Show warning indicating no users found *****/ + Usr_ShowWarningNoUsersFound (Rol_UNKNOWN); /***** End frame *****/ Lay_EndRoundFrame (); diff --git a/swad_enrollment.c b/swad_enrollment.c index 272462e6b..dd09549e3 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -143,9 +143,32 @@ void Enr_PutButtonToEnrollStudents (void) { extern const char *Txt_Register_students; - Act_FormStart (ActReqEnrSevStd); - Lay_PutConfirmButton (Txt_Register_students); - Act_FormEnd (); + /***** Form to enroll several students *****/ + if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected + Gbl.Usrs.Me.LoggedRole == Rol_TEACHER) // I am logged as teacher + { + Act_FormStart (ActReqEnrSevStd); + Lay_PutConfirmButton (Txt_Register_students); + Act_FormEnd (); + } + } + +/*****************************************************************************/ +/**************** Show form with button to enroll teachers *******************/ +/*****************************************************************************/ + +void Enr_PutButtonToEnrollTeachers (void) + { + extern const char *Txt_Register_teachers; + + /***** Form to enroll several students *****/ + if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected + Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM) // I am an administrator + { + Act_FormStart (ActReqEnrSevTch); + Lay_PutConfirmButton (Txt_Register_teachers); + Act_FormEnd (); + } } /*****************************************************************************/ @@ -1723,7 +1746,6 @@ void Enr_AskRemAllStdsThisCrs (void) extern const char *Hlp_USERS_Administration_remove_all_students; extern const char *Txt_Remove_all_students; extern const char *Txt_Do_you_really_want_to_remove_the_X_students_from_the_course_Y_; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; unsigned NumStds; /***** Start frame *****/ @@ -1745,11 +1767,8 @@ void Enr_AskRemAllStdsThisCrs (void) Act_FormEnd (); } else - { - sprintf (Gbl.Message,Txt_No_users_found[Rol_STUDENT], - Gbl.CurrentCrs.Crs.FullName); - Lay_ShowAlert (Lay_INFO,Gbl.Message); - } + /***** Show warning indicating no students found *****/ + Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** End frame *****/ Lay_EndRoundFrame (); @@ -1762,7 +1781,6 @@ void Enr_AskRemAllStdsThisCrs (void) void Enr_RemAllStdsThisCrs (void) { extern const char *Txt_The_X_students_who_belonged_to_the_course_Y_have_been_removed_from_it; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; unsigned NumStdsInCrs; if (Pwd_GetConfirmationOnDangerousAction ()) @@ -1774,11 +1792,8 @@ void Enr_RemAllStdsThisCrs (void) Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); } else - { - sprintf (Gbl.Message,Txt_No_users_found[Rol_STUDENT], - Gbl.CurrentCrs.Crs.FullName); - Lay_ShowAlert (Lay_INFO,Gbl.Message); - } + /***** Show warning indicating no students found *****/ + Usr_ShowWarningNoUsersFound (Rol_STUDENT); } } diff --git a/swad_enrollment.h b/swad_enrollment.h index 8b4594d6e..b162b80eb 100644 --- a/swad_enrollment.h +++ b/swad_enrollment.h @@ -70,6 +70,7 @@ typedef enum /*****************************************************************************/ void Enr_PutButtonToEnrollStudents (void); +void Enr_PutButtonToEnrollTeachers (void); void Enr_PutLinkToRequestSignUp (void); diff --git a/swad_photo.c b/swad_photo.c index 92a9ca09c..f56e6779f 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -2004,7 +2004,6 @@ static void Pho_GetMaxStdsPerDegree (void) static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint) { - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; char Query[512]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2071,7 +2070,8 @@ static void Pho_ShowOrPrintClassPhotoDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrin fprintf (Gbl.F.Out,""); } else // No degrees with students found - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_STUDENT]); + /***** Show warning indicating no students found *****/ + Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -2086,7 +2086,6 @@ static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint) extern const char *Txt_No_INDEX; extern const char *Txt_Degree; extern const char *Txt_SEX_PLURAL_Abc[Usr_NUM_SEXS]; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; char Query[512]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2186,7 +2185,8 @@ static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint) fprintf (Gbl.F.Out,""); } else // No degrees with students found! - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_STUDENT]); + /***** Show warning indicating no students found *****/ + Usr_ShowWarningNoUsersFound (Rol_STUDENT); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); diff --git a/swad_text.c b/swad_text.c index 92ae28f2d..fce97f1a5 100644 --- a/swad_text.c +++ b/swad_text.c @@ -30695,6 +30695,27 @@ const char *Txt_Register_the_users_indicated_in_step_1_and_remove_the_users_not_ " e registrar os utilizadores que estão na lista"; #endif +const char *Txt_Register_teachers = +#if L==1 + "Inscriure professors"; +#elif L==2 + "Anmeldung Lehrkräfte"; +#elif L==3 + "Register teachers"; +#elif L==4 + "Inscribir profesores"; +#elif L==5 + "Inscrire enseignants"; +#elif L==6 + "Inscribir profesores"; // Okoteve traducción +#elif L==7 + "Registrare professori"; +#elif L==8 + "Rejestracja nauczycieli"; +#elif L==9 + "Registrar professores"; +#endif + const char *Txt_Register_user_IN_A_COURSE_OR_DEGREE = #if L==1 "Inscriure usuari"; diff --git a/swad_user.c b/swad_user.c index 63a776212..0a9e0d3fa 100644 --- a/swad_user.c +++ b/swad_user.c @@ -5941,8 +5941,14 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) free ((void *) GroupNames); } else // Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs == 0 + { + /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STUDENT); + /***** Button to enroll students *****/ + Enr_PutButtonToEnrollStudents (); + } + /***** Free memory for students list *****/ Usr_FreeUsrsList (Rol_STUDENT); } @@ -5953,7 +5959,6 @@ static void Usr_ListMainDataStds (bool PutCheckBoxToSelectUsr) static void Usr_ListMainDataTchs (bool PutCheckBoxToSelectUsr) { - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; unsigned NumColumns; unsigned NumCol; unsigned NumUsr; @@ -6012,7 +6017,13 @@ static void Usr_ListMainDataTchs (bool PutCheckBoxToSelectUsr) Usr_UsrDataDestructor (&UsrDat); } else // Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs == 0 - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_TEACHER]); + { + /***** Show warning indicating no teachers found *****/ + Usr_ShowWarningNoUsersFound (Rol_TEACHER); + + /***** Button to enroll teachers *****/ + Enr_PutButtonToEnrollTeachers (); + } /***** Free memory for teachers list *****/ Usr_FreeUsrsList (Rol_TEACHER); @@ -6394,7 +6405,6 @@ void Usr_ListAllDataTchs (void) extern const char *Txt_Department; extern const char *Txt_Office; extern const char *Txt_Phone; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; unsigned NumColumns; unsigned NumCol; unsigned NumUsr; @@ -6478,7 +6488,8 @@ void Usr_ListAllDataTchs (void) fprintf (Gbl.F.Out,""); } else // Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs == 0 - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_TEACHER]); + /***** Show warning indicating no teachers found *****/ + Usr_ShowWarningNoUsersFound (Rol_TEACHER); /***** Free memory for teachers list *****/ Usr_FreeUsrsList (Rol_TEACHER); @@ -6604,7 +6615,6 @@ void Usr_ListDataAdms (void) extern const char *Txt_First_name; extern const char *Txt_Email; extern const char *Txt_Institution; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; unsigned NumCol; unsigned NumUsr; struct UsrData UsrDat; @@ -6723,7 +6733,8 @@ void Usr_ListDataAdms (void) fprintf (Gbl.F.Out,""); } else // Gbl.Usrs.LstUsrs[Rol_DEG_ADM].NumUsrs == 0 - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_DEG_ADM]); + /***** Show warning indicating no admins found *****/ + Usr_ShowWarningNoUsersFound (Rol_DEG_ADM); /***** End frame *****/ Lay_EndRoundFrame (); @@ -7394,10 +7405,8 @@ void Usr_SeeStudents (void) /***** Show warning indicating no students found *****/ Usr_ShowWarningNoUsersFound (Rol_STUDENT); - /***** Form to enroll several students *****/ - if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected - Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_TEACHER) // I am a teacher in current course - Enr_PutButtonToEnrollStudents (); + /***** Button to enroll students *****/ + Enr_PutButtonToEnrollStudents (); } } @@ -7422,7 +7431,6 @@ void Usr_SeeTeachers (void) extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_Scope; extern const char *Txt_Show_records; - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; bool ICanViewRecords; /***** Put contextual links *****/ @@ -7545,7 +7553,13 @@ void Usr_SeeTeachers (void) } } else - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_TEACHER]); + { + /***** Show warning indicating no teachers found *****/ + Usr_ShowWarningNoUsersFound (Rol_TEACHER); + + /***** Button to enroll teachers *****/ + Enr_PutButtonToEnrollTeachers (); + } /***** End frame *****/ Lay_EndRoundFrame (); @@ -7853,8 +7867,6 @@ void Usr_SeeStdClassPhotoPrn (void) void Usr_SeeTchClassPhotoPrn (void) { - extern const char *Txt_No_users_found[Rol_NUM_ROLES]; - /***** Get and update type of list, number of columns in class photo and preference about view photos *****/ @@ -7894,7 +7906,8 @@ void Usr_SeeTchClassPhotoPrn (void) Lay_EndRoundFrame (); } else - Lay_ShowAlert (Lay_INFO,Txt_No_users_found[Rol_TEACHER]); + /***** Show warning indicating no teachers found *****/ + Usr_ShowWarningNoUsersFound (Rol_TEACHER); /***** Free memory for teachers list *****/ Usr_FreeUsrsList (Rol_TEACHER);