From f26618284235da53d206018aa3cf01b9949a844d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 22 May 2017 12:23:08 +0200 Subject: [PATCH] Version 16.220.10 --- swad_ID.c | 79 ++++++++++++++++++++++++++++++++++++--------- swad_changelog.h | 3 +- swad_file_browser.c | 3 +- swad_group.c | 6 ++-- swad_group.h | 2 +- swad_indicator.c | 5 +-- swad_info.c | 15 ++++++--- swad_institution.c | 68 +++++++++++++++++--------------------- swad_layout.c | 11 +++++-- swad_layout.h | 3 +- swad_notification.c | 3 +- swad_record.c | 8 +++-- 12 files changed, 131 insertions(+), 75 deletions(-) diff --git a/swad_ID.c b/swad_ID.c index 569108d11..68e3f4b0d 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -406,6 +406,7 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat) /***** Check if I have permission to see another user's IDs *****/ switch (Gbl.Usrs.Me.LoggedRole) { + case Rol_NET: case Rol_TCH: /* Check 1: I can see the IDs of users who do not exist in database */ if (UsrDat->UsrCod <= 0) // User does not exist (when creating a new user) @@ -413,7 +414,7 @@ bool ID_ICanSeeOtherUsrIDs (const struct UsrData *UsrDat) /* Check 2: I can see the IDs of confirmed students */ if (UsrDat->RoleInCurrentCrsDB == Rol_STD && // A student - UsrDat->Accepted) // who accepted registration + UsrDat->Accepted) // who accepted registration return true; /* Check 3: I can see the IDs of users with user's data empty */ @@ -448,12 +449,23 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID, extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; extern const char *The_ClassFormBold[The_NUM_THEMES]; extern const char *Txt_Confirm_ID; + Act_Action_t NextAction; /***** Start form *****/ - Act_FormStartAnchor ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActCnfID_Std : - (UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActCnfID_Tch : - ActCnfID_Oth), - Anchor); + switch (UsrDat->RoleInCurrentCrsDB) + { + case Rol_STD: + NextAction = ActCnfID_Std; + break; + case Rol_NET: + case Rol_TCH: + NextAction = ActCnfID_Tch; + break; + default: // Guest, visitor or admin + NextAction = ActCnfID_Oth; + break; + } + Act_FormStartAnchor (NextAction,Anchor); if (Gbl.Action.Original != ActUnk) { Par_PutHiddenParamLong ("OriginalActCod", @@ -490,6 +502,7 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID, void ID_PutLinkToChangeUsrIDs (void) { extern const char *Txt_Change_IDs; + Act_Action_t NextAction; /***** Link for changing the password *****/ if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me @@ -498,13 +511,26 @@ void ID_PutLinkToChangeUsrIDs (void) Txt_Change_IDs,Txt_Change_IDs, NULL); else // Not me - Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActFrmIDsStd : - (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActFrmIDsTch : - ActFrmIDsOth), // Guest, visitor or admin - NULL,Usr_PutParamOtherUsrCodEncrypted, + { + switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB) + { + case Rol_STD: + NextAction = ActFrmIDsStd; + break; + case Rol_NET: + case Rol_TCH: + NextAction = ActFrmIDsTch; + break; + default: // Guest, visitor or admin + NextAction = ActFrmIDsOth; + break; + } + Lay_PutContextualLink (NextAction,NULL, + Usr_PutParamOtherUsrCodEncrypted, "arroba64x64.gif", Txt_Change_IDs,Txt_Change_IDs, NULL); + } } /*****************************************************************************/ @@ -559,6 +585,7 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe) extern const char *Txt_If_there_are_multiple_versions_of_the_ID_; extern const char *Txt_The_ID_is_used_in_order_to_facilitate_; unsigned NumID; + Act_Action_t NextAction; /***** List existing user's IDs *****/ for (NumID = 0; @@ -587,9 +614,20 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe) Act_FormStart (ActRemID_Me); else { - Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActRemID_Std : - (UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActRemID_Tch : - ActRemID_Oth)); // Guest, visitor or admin + switch (UsrDat->RoleInCurrentCrsDB) + { + case Rol_STD: + NextAction = ActRemID_Std; + break; + case Rol_NET: + case Rol_TCH: + NextAction = ActRemID_Tch; + break; + default: // Guest, visitor or admin + NextAction = ActRemID_Oth; + break; + } + Act_FormStart (NextAction); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); } fprintf (Gbl.F.Out,"", @@ -641,9 +679,20 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe) Act_FormStart (ActNewIDMe); else { - Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActNewID_Std : - (UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActNewID_Tch : - ActNewID_Oth)); // Guest, visitor or admin + switch (UsrDat->RoleInCurrentCrsDB) + { + case Rol_STD: + NextAction = ActNewID_Std; + break; + case Rol_NET: + case Rol_TCH: + NextAction = ActNewID_Tch; + break; + default: // Guest, visitor or admin + NextAction = ActNewID_Oth; + break; + } + Act_FormStart (NextAction); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); } fprintf (Gbl.F.Out,"
" diff --git a/swad_changelog.h b/swad_changelog.h index 1fb31dba9..a713b50a0 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -233,13 +233,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.220.9 (2017-05-22)" +#define Log_PLATFORM_VERSION "SWAD 16.220.10 (2017-05-22)" #define CSS_FILE "swad16.209.3.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.220.10:May 22, 2017 Changes related with new role. Not finished. (219775 lines) Version 16.220.9: May 22, 2017 Changes related with new role. Not finished. (219720 lines) Version 16.220.8: May 22, 2017 Changes related with new role. Not finished. (219663 lines) 4 changes necessary in database: diff --git a/swad_file_browser.c b/swad_file_browser.c index d3047f9ab..42a691ffd 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -4709,7 +4709,8 @@ static void Brw_PutCheckboxFullTree (void) Lay_PutContextualCheckbox (Brw_ActSeeAdm[Gbl.FileBrowser.Type], Brw_PutParamsFullTree, - "FullTree",Gbl.FileBrowser.FullTree, + "FullTree", + Gbl.FileBrowser.FullTree,false, Txt_Show_all_files,Txt_Show_all_files); } diff --git a/swad_group.c b/swad_group.c index 3ab2f0f96..f3d4ab586 100644 --- a/swad_group.c +++ b/swad_group.c @@ -1635,14 +1635,14 @@ void Grp_ListGrpsToEditAsgAttOrSvy (struct GroupType *GrpTyp,long Cod,Grp_AsgOrS void Grp_ReqRegisterInGrps (void) { /***** Show list of groups to register/remove me *****/ - Grp_ShowLstGrpsToChgMyGrps ((Gbl.Usrs.Me.LoggedRole == Rol_STD)); + Grp_ShowLstGrpsToChgMyGrps (); } /*****************************************************************************/ /***************** Show list of groups to register/remove me *****************/ /*****************************************************************************/ -void Grp_ShowLstGrpsToChgMyGrps (bool ShowWarningsToStudents) +void Grp_ShowLstGrpsToChgMyGrps (void) { extern const char *Hlp_USERS_Groups; extern const char *Txt_My_groups; @@ -1664,7 +1664,7 @@ void Grp_ShowLstGrpsToChgMyGrps (bool ShowWarningsToStudents) /***** Show warnings to students *****/ // Students are required to join groups with mandatory enrolment; teachers don't - if (ShowWarningsToStudents) + if (Gbl.Usrs.Me.LoggedRole == Rol_STD) Grp_ShowWarningToStdsToChangeGrps (); } diff --git a/swad_group.h b/swad_group.h index 53eb2e5f1..e2910ffbb 100644 --- a/swad_group.h +++ b/swad_group.h @@ -153,7 +153,7 @@ void Grp_RemUsrFromAllGrps (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrV void Grp_ListGrpsToEditAsgAttOrSvy (struct GroupType *GrpTyp,long Cod,Grp_AsgOrSvy_t Grp_AsgOrSvy); void Grp_ReqRegisterInGrps (void); -void Grp_ShowLstGrpsToChgMyGrps (bool ShowWarningsToStudents); +void Grp_ShowLstGrpsToChgMyGrps (void); void Grp_ShowLstGrpsToChgOtherUsrsGrps (long UsrCod); void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes); diff --git a/swad_indicator.c b/swad_indicator.c index 7410ba5ae..2036844b2 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -1116,8 +1116,9 @@ static void Ind_ShowTableOfCoursesWithIndicators (Ind_IndicatorsLayout_t Indicat break; case Ind_INDICATORS_FULL: /* Get number of users */ - NumStds = Usr_GetNumUsrsInCrs (Rol_STD,CrsCod); - NumTchs = Usr_GetNumUsrsInCrs (Rol_TCH,CrsCod); + NumStds = Usr_GetNumUsrsInCrs (Rol_STD,CrsCod); // Students + NumTchs = Usr_GetNumUsrsInCrs (Rol_NET,CrsCod) + // Non-editing teachers + Usr_GetNumUsrsInCrs (Rol_TCH,CrsCod); // Teachers fprintf (Gbl.F.Out,"" "" diff --git a/swad_info.c b/swad_info.c index 2f9b587e2..13173a539 100644 --- a/swad_info.c +++ b/swad_info.c @@ -299,7 +299,7 @@ extern const char *Hlp_ASSESSMENT_System_edit; static void Inf_PutButtonToEditInfo (void); static void Inf_PutIconToViewInfo (void); -static void Inf_PutCheckboxForceStdsToReadInfo (bool MustBeRead); +static void Inf_PutCheckboxForceStdsToReadInfo (bool MustBeRead,bool Disabled); static void Inf_PutCheckboxConfirmIHaveReadInfo (void); static bool Inf_CheckIfIHaveReadInfo (void); static bool Inf_GetMustBeReadFromForm (void); @@ -340,6 +340,7 @@ void Inf_ShowInfo (void) extern const char *Txt_No_information; Inf_InfoSrc_t InfoSrc; bool MustBeRead; + bool Disabled; bool ICanEdit = (Gbl.Usrs.Me.LoggedRole == Rol_TCH || Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); bool ShowWarningNoInfo = false; @@ -384,13 +385,15 @@ void Inf_ShowInfo (void) fprintf (Gbl.F.Out,"
"); } break; + case Rol_NET: case Rol_TCH: case Rol_SYS_ADM: /* Put checkbox to force students to read this couse info */ if (InfoSrc != Inf_INFO_SRC_NONE) { fprintf (Gbl.F.Out,"
"); - Inf_PutCheckboxForceStdsToReadInfo (MustBeRead); + Disabled = (Gbl.Usrs.Me.LoggedRole == Rol_NET); // Non-editing teachers can not change the status of checkbox + Inf_PutCheckboxForceStdsToReadInfo (MustBeRead,Disabled); fprintf (Gbl.F.Out,"
"); } break; @@ -480,13 +483,14 @@ void Inf_PutIconToEditInfo (void) /********** Put a form (checkbox) to force students to read info *************/ /*****************************************************************************/ -static void Inf_PutCheckboxForceStdsToReadInfo (bool MustBeRead) +static void Inf_PutCheckboxForceStdsToReadInfo (bool MustBeRead,bool Disabled) { extern const char *Txt_Force_students_to_read_this_information; Lay_PutContextualCheckbox (Inf_ActionsChangeForceReadInfo[Gbl.CurrentCrs.Info.Type], NULL, - "MustBeRead",MustBeRead, + "MustBeRead", + MustBeRead,Disabled, Txt_Force_students_to_read_this_information, Txt_Force_students_to_read_this_information); } @@ -502,7 +506,8 @@ static void Inf_PutCheckboxConfirmIHaveReadInfo (void) Lay_PutContextualCheckbox (Inf_ActionsIHaveReadInfo[Gbl.CurrentCrs.Info.Type], NULL, - "IHaveRead",IHaveRead, + "IHaveRead", + IHaveRead,false, Txt_I_have_read_this_information, Txt_I_have_read_this_information); } diff --git a/swad_institution.c b/swad_institution.c index 0abaf9c8a..dae930e35 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -66,6 +66,7 @@ extern struct Globals Gbl; static void Ins_Configuration (bool PrintView); static void Ins_PutIconsToPrintAndUpload (void); +static void Ins_ShowNumUsrsInCrssOfIns (Rol_Role_t Role); static void Ins_ListInstitutions (void); static bool Ins_CheckIfICanCreateInstitutions (void); @@ -298,7 +299,6 @@ static void Ins_Configuration (bool PrintView) extern const char *Txt_Courses; extern const char *Txt_Departments; extern const char *Txt_Users_of_the_institution; - extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; unsigned NumCty; bool PutLink = !PrintView && Gbl.CurrentIns.Ins.WWW[0]; @@ -573,45 +573,11 @@ static void Ins_Configuration (bool PrintView) Txt_Departments, Dpt_GetNumDepartmentsInInstitution (Gbl.CurrentIns.Ins.InsCod)); - /***** Number of teachers in courses of this institution *****/ - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "" - "%u" - "" - "", - The_ClassForm[Gbl.Prefs.Theme], - Txt_ROLES_PLURAL_Abc[Rol_TCH][Usr_SEX_UNKNOWN], - Usr_GetNumUsrsInCrssOfIns (Rol_TCH,Gbl.CurrentIns.Ins.InsCod)); - - /***** Number of students in courses of this institution *****/ - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "" - "%u" - "" - "", - The_ClassForm[Gbl.Prefs.Theme], - Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN], - Usr_GetNumUsrsInCrssOfIns (Rol_STD,Gbl.CurrentIns.Ins.InsCod)); - /***** Number of users in courses of this institution *****/ - fprintf (Gbl.F.Out,"" - "" - "%s + %s:" - "" - "" - "%u" - "" - "", - The_ClassForm[Gbl.Prefs.Theme], - Txt_ROLES_PLURAL_Abc[Rol_TCH][Usr_SEX_UNKNOWN], - Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN], - Usr_GetNumUsrsInCrssOfIns (Rol_UNK,Gbl.CurrentIns.Ins.InsCod)); + Ins_ShowNumUsrsInCrssOfIns (Rol_TCH); + Ins_ShowNumUsrsInCrssOfIns (Rol_NET); + Ins_ShowNumUsrsInCrssOfIns (Rol_STD); + Ins_ShowNumUsrsInCrssOfIns (Rol_UNK); } /***** End table *****/ @@ -636,6 +602,30 @@ static void Ins_PutIconsToPrintAndUpload (void) Log_PutIconToChangeLogo (Sco_SCOPE_INS); } +/*****************************************************************************/ +/************** Number of users in courses of this institution ***************/ +/*****************************************************************************/ + +static void Ins_ShowNumUsrsInCrssOfIns (Rol_Role_t Role) + { + extern const char *The_ClassForm[The_NUM_THEMES]; + extern const char *Txt_Users_in_courses; + extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; + + fprintf (Gbl.F.Out,"" + "" + "%s:" + "" + "" + "%u" + "" + "", + The_ClassForm[Gbl.Prefs.Theme], + (Role == Rol_UNK) ? Txt_Users_in_courses : + Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN], + Usr_GetNumUsrsInCrssOfIns (Role,Gbl.CurrentIns.Ins.InsCod)); + } + /*****************************************************************************/ /**************** List the institutions of the current country ***************/ /*****************************************************************************/ diff --git a/swad_layout.c b/swad_layout.c index 3212229e2..643df831a 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1169,7 +1169,8 @@ void Lay_PutContextualLink (Act_Action_t NextAction,const char *Anchor, void Lay_PutContextualCheckbox (Act_Action_t NextAction, void (*FuncParams) (), - const char *CheckboxName,bool Checked, + const char *CheckboxName, + bool Checked,bool Disabled, const char *Title,const char *Text) { extern const char *The_ClassFormBold[The_NUM_THEMES]; @@ -1197,8 +1198,12 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction, CheckboxName); if (Checked) fprintf (Gbl.F.Out," checked=\"checked\""); - fprintf (Gbl.F.Out," onclick=\"document.getElementById('%s').submit();\" />", - Gbl.Form.Id); + if (Disabled) + fprintf (Gbl.F.Out," disabled=\"disabled\""); + else + fprintf (Gbl.F.Out," onclick=\"document.getElementById('%s').submit();\"", + Gbl.Form.Id); + fprintf (Gbl.F.Out," />"); if (Text) if (Text[0]) fprintf (Gbl.F.Out," %s", diff --git a/swad_layout.h b/swad_layout.h index 02e539f8e..768e4dc6e 100644 --- a/swad_layout.h +++ b/swad_layout.h @@ -71,7 +71,8 @@ void Lay_PutContextualLink (Act_Action_t NextAction,const char *Anchor, const char *OnSubmit); void Lay_PutContextualCheckbox (Act_Action_t NextAction, void (*FuncParams) (), - const char *CheckboxName,bool Checked, + const char *CheckboxName, + bool Checked,bool Disabled, const char *Title,const char *Text); void Lay_PutIconLink (const char *Icon,const char *Title,const char *Text, const char *LinkStyle,const char *OnSubmit); diff --git a/swad_notification.c b/swad_notification.c index 19084a21b..33c9eac33 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -669,7 +669,8 @@ static void Ntf_WriteFormAllNotifications (bool AllNotifications) extern const char *Txt_Show_all_NOTIFICATIONS; Lay_PutContextualCheckbox (ActSeeNtf,NULL, - "All",AllNotifications, + "All", + AllNotifications,false, Txt_Show_all_notifications, Txt_Show_all_NOTIFICATIONS); } diff --git a/swad_record.c b/swad_record.c index 3082f5b53..9ddd0b54d 100644 --- a/swad_record.c +++ b/swad_record.c @@ -1562,7 +1562,8 @@ static void Rec_WriteFormShowOfficeHoursOneTch (bool ShowOfficeHours) extern const char *Txt_Show_office_hours; Lay_PutContextualCheckbox (ActSeeRecOneTch,Rec_PutParamsShowOfficeHoursOneTch, - "ShowOfficeHours",ShowOfficeHours, + "ShowOfficeHours", + ShowOfficeHours,false, Txt_Show_office_hours, Txt_Show_office_hours); } @@ -1572,7 +1573,8 @@ static void Rec_WriteFormShowOfficeHoursSeveralTchs (bool ShowOfficeHours) extern const char *Txt_Show_office_hours; Lay_PutContextualCheckbox (ActSeeRecSevTch,Rec_PutParamsShowOfficeHoursSeveralTchs, - "ShowOfficeHours",ShowOfficeHours, + "ShowOfficeHours", + ShowOfficeHours,false, Txt_Show_office_hours, Txt_Show_office_hours); } @@ -2453,7 +2455,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, { // Don't show groups if I don't belong to course if (Gbl.Usrs.Me.IBelongToCurrentCrs) - Grp_ShowLstGrpsToChgMyGrps ((Gbl.Usrs.Me.LoggedRole == Rol_STD)); + Grp_ShowLstGrpsToChgMyGrps (); } else Grp_ShowLstGrpsToChgOtherUsrsGrps (UsrDat->UsrCod);