mirror of https://github.com/acanas/swad-core.git
Version 21.56.1: Nov 10, 2021 Code refactoring in switch statements (until swad_enrolment.c).
This commit is contained in:
parent
a257bf39c3
commit
5e737fb2b7
|
@ -3225,16 +3225,9 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat)
|
|||
extern const char *Txt_View_record_for_this_course;
|
||||
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_UNK ] = ActUnk,
|
||||
[Rol_GST ] = ActUnk,
|
||||
[Rol_USR ] = ActUnk,
|
||||
[Rol_STD ] = ActSeeRecOneStd,
|
||||
[Rol_NET ] = ActSeeRecOneTch,
|
||||
[Rol_TCH ] = ActSeeRecOneTch,
|
||||
[Rol_DEG_ADM] = ActUnk,
|
||||
[Rol_CTR_ADM] = ActUnk,
|
||||
[Rol_INS_ADM] = ActUnk,
|
||||
[Rol_SYS_ADM] = ActUnk,
|
||||
[Rol_STD] = ActSeeRecOneStd,
|
||||
[Rol_NET] = ActSeeRecOneTch,
|
||||
[Rol_TCH] = ActSeeRecOneTch,
|
||||
};
|
||||
|
||||
/***** Show user's photo *****/
|
||||
|
@ -3247,9 +3240,8 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat)
|
|||
|
||||
HTM_DIV_Begin ("class=\"OWNER_WORKS_DATA AUTHOR_TXT\"");
|
||||
|
||||
if (NextAction[UsrDat->Roles.InCurrentCrs] == ActUnk)
|
||||
if (!NextAction[UsrDat->Roles.InCurrentCrs])
|
||||
Err_WrongRoleExit ();
|
||||
|
||||
Frm_BeginForm (NextAction[UsrDat->Roles.InCurrentCrs]);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
|
||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
|||
|
||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.56 (2021-11-10)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.56.1 (2021-11-10)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.69.1.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 21.56.1: Nov 10, 2021 Code refactoring in switch statements (until swad_enrolment.c). (319490 lines)
|
||||
Version 21.56: Nov 10, 2021 Code refactoring in hierarchy. (319618 lines)
|
||||
Version 21.55.2: Nov 10, 2021 Code refactoring in switch statements (until swad_button.c). (319875 lines)
|
||||
Version 21.55.1: Nov 09, 2021 Removed unused comments. (319893 lines)
|
||||
|
|
|
@ -552,16 +552,9 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role)
|
|||
extern const char *Txt_View_record_for_this_course;
|
||||
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_UNK ] = ActUnk,
|
||||
[Rol_GST ] = ActUnk,
|
||||
[Rol_USR ] = ActUnk,
|
||||
[Rol_STD ] = ActSeeRecOneStd,
|
||||
[Rol_NET ] = ActSeeRecOneTch,
|
||||
[Rol_TCH ] = ActSeeRecOneTch,
|
||||
[Rol_DEG_ADM] = ActUnk,
|
||||
[Rol_CTR_ADM] = ActUnk,
|
||||
[Rol_INS_ADM] = ActUnk,
|
||||
[Rol_SYS_ADM] = ActUnk,
|
||||
[Rol_STD] = ActSeeRecOneStd,
|
||||
[Rol_NET] = ActSeeRecOneTch,
|
||||
[Rol_TCH] = ActSeeRecOneTch,
|
||||
};
|
||||
const char *ClassTxt;
|
||||
const char *ClassLink;
|
||||
|
@ -612,7 +605,7 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role)
|
|||
// The form must be unique because
|
||||
// the list of connected users
|
||||
// is dynamically updated via AJAX
|
||||
if (NextAction[Role] == ActUnk)
|
||||
if (!NextAction[Role])
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginFormUnique (NextAction[Role]);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
|
@ -652,16 +645,9 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R
|
|||
{
|
||||
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_UNK ] = ActUnk,
|
||||
[Rol_GST ] = ActUnk,
|
||||
[Rol_USR ] = ActUnk,
|
||||
[Rol_STD ] = ActSeeRecOneStd,
|
||||
[Rol_NET ] = ActSeeRecOneTch,
|
||||
[Rol_TCH ] = ActSeeRecOneTch,
|
||||
[Rol_DEG_ADM] = ActUnk,
|
||||
[Rol_CTR_ADM] = ActUnk,
|
||||
[Rol_INS_ADM] = ActUnk,
|
||||
[Rol_SYS_ADM] = ActUnk,
|
||||
[Rol_STD] = ActSeeRecOneStd,
|
||||
[Rol_NET] = ActSeeRecOneTch,
|
||||
[Rol_TCH] = ActSeeRecOneTch,
|
||||
};
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -727,7 +713,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R
|
|||
|
||||
if (PutLinkToRecord)
|
||||
{
|
||||
if (NextAction[Role] == ActUnk)
|
||||
if (!NextAction[Role])
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginForm (NextAction[Role]);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
|
||||
|
|
23
swad_date.c
23
swad_date.c
|
@ -556,6 +556,12 @@ void Dat_WriteFormClientLocalDateTimeFromTimeUTC (const char *Id,
|
|||
[Dat_FORM_SECONDS_OFF] = 5,
|
||||
[Dat_FORM_SECONDS_ON ] = 1,
|
||||
};
|
||||
static const char *Format[Dat_NUM_SET_HMS] =
|
||||
{
|
||||
[Dat_HMS_DO_NOT_SET] = NULL,
|
||||
[Dat_HMS_TO_000000 ] = "setHMSTo000000('%s');", // Set HH:MM:SS form selectors to 00:00:00
|
||||
[Dat_HMS_TO_235959 ] = "setHMSTo235959('%s');", // Set HH:MM:SS form selectors to 23:59:59
|
||||
};
|
||||
char *IdTimeUTC;
|
||||
char *ParamNameTimeUTC;
|
||||
|
||||
|
@ -723,23 +729,12 @@ void Dat_WriteFormClientLocalDateTimeFromTimeUTC (const char *Id,
|
|||
HTM_SCRIPT_Begin (NULL,NULL);
|
||||
HTM_TxtF ("setLocalDateTimeFormFromUTC('%s',%ld);\n" // Set date-time form from UTC time
|
||||
"adjustDateForm('%s');\n" // Adjust date-time form
|
||||
"setUTCFromLocalDateTimeForm('%s');\n", // Adjust UTC time from date-time form
|
||||
"setUTCFromLocalDateTimeForm('%s');\n", // Adjust UTC time from date-time form
|
||||
Id,(long) TimeUTC,
|
||||
Id,
|
||||
Id);
|
||||
switch (SetHMS)
|
||||
{
|
||||
case Dat_HMS_TO_000000:
|
||||
// Set HH:MM:SS form selectors to 00:00:00
|
||||
HTM_TxtF ("setHMSTo000000('%s');",Id); // Hidden TimeUTC is also adjusted
|
||||
break;
|
||||
case Dat_HMS_TO_235959:
|
||||
// Set HH:MM:SS form selectors to 23:59:59
|
||||
HTM_TxtF ("setHMSTo235959('%s');",Id); // Hidden TimeUTC is also adjusted
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (Format[SetHMS])
|
||||
HTM_TxtF (Format[SetHMS],Id); // Hidden TimeUTC is also adjusted
|
||||
HTM_SCRIPT_End ();
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ typedef enum
|
|||
Dat_FORM_SECONDS_ON,
|
||||
} Dat_FormSeconds;
|
||||
|
||||
#define Dat_NUM_SET_HMS 3
|
||||
typedef enum
|
||||
{
|
||||
Dat_HMS_DO_NOT_SET = 0,
|
||||
|
|
323
swad_enrolment.c
323
swad_enrolment.c
|
@ -289,27 +289,19 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
|||
static void Enr_NotifyAfterEnrolment (const struct UsrData *UsrDat,
|
||||
Rol_Role_t NewRole)
|
||||
{
|
||||
static const Ntf_NotifyEvent_t NotifyEvent[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_STD] = Ntf_EVENT_ENROLMENT_STD,
|
||||
[Rol_NET] = Ntf_EVENT_ENROLMENT_NET,
|
||||
[Rol_TCH] = Ntf_EVENT_ENROLMENT_TCH,
|
||||
};
|
||||
bool CreateNotif;
|
||||
bool NotifyByEmail;
|
||||
Ntf_NotifyEvent_t NotifyEvent;
|
||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||
|
||||
/***** Check if user's role is allowed *****/
|
||||
switch (NewRole)
|
||||
{
|
||||
case Rol_STD:
|
||||
NotifyEvent = Ntf_EVENT_ENROLMENT_STD;
|
||||
break;
|
||||
case Rol_NET:
|
||||
NotifyEvent = Ntf_EVENT_ENROLMENT_NET;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
NotifyEvent = Ntf_EVENT_ENROLMENT_TCH;
|
||||
break;
|
||||
default:
|
||||
NotifyEvent = Ntf_EVENT_UNKNOWN;
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
if (!NotifyEvent[NewRole])
|
||||
Err_WrongRoleExit ();
|
||||
|
||||
/***** Remove possible enrolment request ******/
|
||||
Enr_RemUsrEnrolmentRequestInCrs (UsrDat->UsrCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
@ -320,11 +312,11 @@ static void Enr_NotifyAfterEnrolment (const struct UsrData *UsrDat,
|
|||
Ntf_DB_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLMENT_TCH,-1,UsrDat->UsrCod);
|
||||
|
||||
/***** Create new notification ******/
|
||||
CreateNotif = (UsrDat->NtfEvents.CreateNotif & (1 << NotifyEvent));
|
||||
CreateNotif = (UsrDat->NtfEvents.CreateNotif & (1 << NotifyEvent[NewRole]));
|
||||
NotifyByEmail = CreateNotif && !ItsMe &&
|
||||
(UsrDat->NtfEvents.SendEmail & (1 << NotifyEvent));
|
||||
(UsrDat->NtfEvents.SendEmail & (1 << NotifyEvent[NewRole]));
|
||||
if (CreateNotif)
|
||||
Ntf_DB_StoreNotifyEventToUsr (NotifyEvent,UsrDat->UsrCod,-1L,
|
||||
Ntf_DB_StoreNotifyEventToUsr (NotifyEvent[NewRole],UsrDat->UsrCod,-1L,
|
||||
(Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
|
||||
0),
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
|
@ -377,7 +369,20 @@ void Enr_ReqAcceptRegisterInCrs (void)
|
|||
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
extern const char *Txt_Confirm_my_enrolment;
|
||||
extern const char *Txt_Remove_me_from_this_course;
|
||||
Ntf_NotifyEvent_t NotifyEvent;
|
||||
static const struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
Act_Action_t Accept;
|
||||
Act_Action_t Refuse;
|
||||
} NextAction;
|
||||
Ntf_NotifyEvent_t NotifyEvent;
|
||||
} WhatToDo[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_STD] = {{ActAccEnrStd,ActRemMe_Std},Ntf_EVENT_ENROLMENT_STD},
|
||||
[Rol_NET] = {{ActAccEnrNET,ActRemMe_NET},Ntf_EVENT_ENROLMENT_NET},
|
||||
[Rol_TCH] = {{ActAccEnrTch,ActRemMe_Tch},Ntf_EVENT_ENROLMENT_TCH},
|
||||
};
|
||||
|
||||
/***** Begin box *****/
|
||||
Box_BoxBegin (NULL,Txt_Enrolment,
|
||||
|
@ -390,62 +395,26 @@ void Enr_ReqAcceptRegisterInCrs (void)
|
|||
Gbl.Hierarchy.Crs.FullName);
|
||||
|
||||
/***** Send button to accept register in the current course *****/
|
||||
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs)
|
||||
{
|
||||
case Rol_STD:
|
||||
Frm_BeginForm (ActAccEnrStd);
|
||||
break;
|
||||
case Rol_NET:
|
||||
Frm_BeginForm (ActAccEnrNET);
|
||||
break;
|
||||
case Rol_TCH:
|
||||
Frm_BeginForm (ActAccEnrTch);
|
||||
break;
|
||||
default:
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
Btn_PutCreateButtonInline (Txt_Confirm_my_enrolment);
|
||||
if (!WhatToDo[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs].NextAction.Accept)
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginForm (WhatToDo[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs].NextAction.Accept);
|
||||
Btn_PutCreateButtonInline (Txt_Confirm_my_enrolment);
|
||||
Frm_EndForm ();
|
||||
|
||||
/***** Send button to refuse register in the current course *****/
|
||||
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs)
|
||||
{
|
||||
case Rol_STD:
|
||||
Frm_BeginForm (ActRemMe_Std);
|
||||
break;
|
||||
case Rol_NET:
|
||||
Frm_BeginForm (ActRemMe_NET);
|
||||
break;
|
||||
case Rol_TCH:
|
||||
Frm_BeginForm (ActRemMe_Tch);
|
||||
break;
|
||||
default:
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
Btn_PutRemoveButtonInline (Txt_Remove_me_from_this_course);
|
||||
if (!WhatToDo[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs].NextAction.Refuse)
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginForm (WhatToDo[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs].NextAction.Refuse);
|
||||
Btn_PutRemoveButtonInline (Txt_Remove_me_from_this_course);
|
||||
Frm_EndForm ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
|
||||
/***** Mark possible notification as seen *****/
|
||||
switch (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs)
|
||||
{
|
||||
case Rol_STD:
|
||||
NotifyEvent = Ntf_EVENT_ENROLMENT_STD;
|
||||
break;
|
||||
case Rol_NET:
|
||||
NotifyEvent = Ntf_EVENT_ENROLMENT_NET;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
NotifyEvent = Ntf_EVENT_ENROLMENT_TCH;
|
||||
break;
|
||||
default:
|
||||
NotifyEvent = Ntf_EVENT_UNKNOWN;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Ntf_DB_MarkNotifsInCrsAsSeen (NotifyEvent);
|
||||
if (!WhatToDo[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs].NotifyEvent)
|
||||
Err_WrongRoleExit ();
|
||||
Ntf_DB_MarkNotifsInCrsAsSeen (WhatToDo[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs].NotifyEvent);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -566,8 +535,16 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role)
|
|||
extern const char *Txt_No_groups_have_been_created_in_the_course_X_Therefore_;
|
||||
extern const char *Txt_Step_4_Confirm_the_enrolment_removing;
|
||||
extern const char *Txt_Confirm;
|
||||
Act_Action_t NextAction;
|
||||
const char *Title;
|
||||
static const struct
|
||||
{
|
||||
Act_Action_t NextAction;
|
||||
const char **Title;
|
||||
} WhatToDo[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_STD] = {ActRcvFrmEnrSevStd,&Txt_Administer_multiple_students },
|
||||
[Rol_NET] = {ActRcvFrmEnrSevNET,&Txt_Administer_multiple_non_editing_teachers},
|
||||
[Rol_TCH] = {ActRcvFrmEnrSevTch,&Txt_Administer_multiple_teachers },
|
||||
};
|
||||
|
||||
/***** Contextual menu *****/
|
||||
if (Gbl.Hierarchy.Level == HieLvl_CRS) // Course selected
|
||||
|
@ -594,8 +571,6 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role)
|
|||
Enr_PutLinkToAdminOneUsr (ActReqMdfOneTch);
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Title = NULL;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
@ -604,30 +579,12 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role)
|
|||
}
|
||||
|
||||
/***** Form to send students to be enroled / removed *****/
|
||||
switch (Role)
|
||||
{
|
||||
case Rol_STD:
|
||||
NextAction = ActRcvFrmEnrSevStd;
|
||||
Title = Txt_Administer_multiple_students;
|
||||
break;
|
||||
case Rol_NET:
|
||||
NextAction = ActRcvFrmEnrSevNET;
|
||||
Title = Txt_Administer_multiple_non_editing_teachers;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
NextAction = ActRcvFrmEnrSevTch;
|
||||
Title = Txt_Administer_multiple_teachers;
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Title = NULL;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Frm_BeginForm (NextAction);
|
||||
if (!WhatToDo[Role].NextAction)
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginForm (WhatToDo[Role].NextAction);
|
||||
|
||||
/***** Begin box *****/
|
||||
Box_BoxBegin (NULL,Title,
|
||||
Box_BoxBegin (NULL,*WhatToDo[Role].Title,
|
||||
NULL,NULL,
|
||||
Hlp_USERS_Administration_administer_multiple_users,Box_NOT_CLOSABLE);
|
||||
|
||||
|
@ -992,7 +949,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
|||
case Enr_REGISTER_SPECIFIED_USRS_IN_CRS:
|
||||
WhatToDo.RemoveUsrs = false;
|
||||
WhatToDo.RemoveSpecifiedUsrs = false; // Ignored
|
||||
WhatToDo.EliminateUsrs = false; // Ignored
|
||||
WhatToDo.EliminateUsrs = false; // Ignored
|
||||
WhatToDo.RegisterUsrs = true;
|
||||
break;
|
||||
case Enr_REMOVE_SPECIFIED_USRS_FROM_CRS:
|
||||
|
@ -2129,7 +2086,12 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
bool UsrExists;
|
||||
bool UsrBelongsToCrs;
|
||||
Rol_Role_t DesiredRole;
|
||||
Act_Action_t NextAction;
|
||||
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_STD] = ActReqMdfStd,
|
||||
[Rol_NET] = ActReqMdfNET,
|
||||
[Rol_TCH] = ActReqMdfTch,
|
||||
};
|
||||
|
||||
/***** Remove expired enrolment requests *****/
|
||||
Enr_DB_RemoveExpiredEnrolmentRequests ();
|
||||
|
@ -2294,23 +2256,9 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
|
||||
/***** Button to confirm the request *****/
|
||||
HTM_TD_Begin ("class=\"DAT LT\"");
|
||||
switch (DesiredRole)
|
||||
{
|
||||
case Rol_STD:
|
||||
NextAction = ActReqMdfStd;
|
||||
break;
|
||||
case Rol_NET:
|
||||
NextAction = ActReqMdfNET;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
NextAction = ActReqMdfTch;
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Frm_BeginForm (NextAction);
|
||||
if (!NextAction[DesiredRole])
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginForm (NextAction[DesiredRole]);
|
||||
Crs_PutParamCrsCod (Crs.CrsCod);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
|
||||
Btn_PutCreateButtonInline (Txt_Register);
|
||||
|
@ -2398,32 +2346,23 @@ void Enr_PutLinkToAdminSeveralUsrs (Rol_Role_t Role)
|
|||
extern const char *Txt_Administer_multiple_students;
|
||||
extern const char *Txt_Administer_multiple_non_editing_teachers;
|
||||
extern const char *Txt_Administer_multiple_teachers;
|
||||
Act_Action_t NextAction;
|
||||
const char *TitleText;
|
||||
|
||||
switch (Role)
|
||||
static const struct
|
||||
{
|
||||
case Rol_STD:
|
||||
NextAction = ActReqEnrSevStd;
|
||||
TitleText = Txt_Administer_multiple_students;
|
||||
break;
|
||||
case Rol_NET:
|
||||
NextAction = ActReqEnrSevNET;
|
||||
TitleText = Txt_Administer_multiple_non_editing_teachers;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
NextAction = ActReqEnrSevTch;
|
||||
TitleText = Txt_Administer_multiple_teachers;
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
TitleText = NULL;
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
Lay_PutContextualLinkIconText (NextAction,NULL,
|
||||
Act_Action_t NextAction;
|
||||
const char **Title;
|
||||
} WhatToDo[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_STD] = {ActReqEnrSevStd,&Txt_Administer_multiple_students },
|
||||
[Rol_NET] = {ActReqEnrSevNET,&Txt_Administer_multiple_non_editing_teachers},
|
||||
[Rol_TCH] = {ActReqEnrSevTch,&Txt_Administer_multiple_teachers },
|
||||
};
|
||||
|
||||
if (!WhatToDo[Role].NextAction)
|
||||
Err_WrongRoleExit ();
|
||||
Lay_PutContextualLinkIconText (WhatToDo[Role].NextAction,NULL,
|
||||
NULL,NULL,
|
||||
"users-cog.svg",
|
||||
TitleText);
|
||||
*WhatToDo[Role].Title);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2478,7 +2417,13 @@ static void Enr_ReqAnotherUsrIDToRegisterRemove (Rol_Role_t Role)
|
|||
{
|
||||
extern const char *Hlp_USERS_Administration_administer_one_user;
|
||||
extern const char *Txt_Administer_one_user;
|
||||
Act_Action_t NextAction;
|
||||
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_GST] = ActReqMdfOth,
|
||||
[Rol_STD] = ActReqMdfStd,
|
||||
[Rol_NET] = ActReqMdfNET,
|
||||
[Rol_TCH] = ActReqMdfTch,
|
||||
};
|
||||
|
||||
/***** Begin box *****/
|
||||
Box_BoxBegin (NULL,Txt_Administer_one_user,
|
||||
|
@ -2486,26 +2431,9 @@ static void Enr_ReqAnotherUsrIDToRegisterRemove (Rol_Role_t Role)
|
|||
Hlp_USERS_Administration_administer_one_user,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Write form to request another user's ID *****/
|
||||
switch (Role)
|
||||
{
|
||||
case Rol_GST:
|
||||
NextAction = ActReqMdfOth;
|
||||
break;
|
||||
case Rol_STD:
|
||||
NextAction = ActReqMdfStd;
|
||||
break;
|
||||
case Rol_NET:
|
||||
NextAction = ActReqMdfNET;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
NextAction = ActReqMdfTch;
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Enr_WriteFormToReqAnotherUsrID (NextAction,NULL);
|
||||
if (!NextAction[Role])
|
||||
Err_WrongRoleExit ();
|
||||
Enr_WriteFormToReqAnotherUsrID (NextAction[Role],NULL);
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
|
@ -2804,6 +2732,13 @@ void Enr_CreateNewUsr1 (void)
|
|||
extern const char *Txt_The_ID_X_is_not_valid;
|
||||
Rol_Role_t OldRole;
|
||||
Rol_Role_t NewRole;
|
||||
static const Act_Action_t Action[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_GST] = ActCreOth,
|
||||
[Rol_STD] = ActCreStd,
|
||||
[Rol_NET] = ActCreNET,
|
||||
[Rol_TCH] = ActCreTch,
|
||||
};
|
||||
|
||||
/***** Get user's ID from form *****/
|
||||
ID_GetParamOtherUsrIDPlain (); // User's ID was already modified and passed as a hidden parameter
|
||||
|
@ -2862,24 +2797,9 @@ void Enr_CreateNewUsr1 (void)
|
|||
}
|
||||
|
||||
/***** Change current action *****/
|
||||
switch (NewRole)
|
||||
{
|
||||
case Rol_GST:
|
||||
Gbl.Action.Act = ActCreOth;
|
||||
break;
|
||||
case Rol_STD:
|
||||
Gbl.Action.Act = ActCreStd;
|
||||
break;
|
||||
case Rol_NET:
|
||||
Gbl.Action.Act = ActCreNET;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
Gbl.Action.Act = ActCreTch;
|
||||
break;
|
||||
default:
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
if (!Action[NewRole])
|
||||
Err_WrongRoleExit ();
|
||||
Gbl.Action.Act = Action[NewRole];
|
||||
Tab_SetCurrentTab ();
|
||||
}
|
||||
else // User's ID not valid
|
||||
|
@ -2915,6 +2835,13 @@ void Enr_ModifyUsr1 (void)
|
|||
bool ItsMe;
|
||||
Rol_Role_t OldRole;
|
||||
Rol_Role_t NewRole;
|
||||
static const Act_Action_t Action[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_GST] = ActUpdOth,
|
||||
[Rol_STD] = ActUpdStd,
|
||||
[Rol_NET] = ActUpdNET,
|
||||
[Rol_TCH] = ActUpdTch,
|
||||
};
|
||||
|
||||
/***** Get user from form *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||
|
@ -2993,24 +2920,9 @@ void Enr_ModifyUsr1 (void)
|
|||
}
|
||||
|
||||
/***** Change current action *****/
|
||||
switch (NewRole)
|
||||
{
|
||||
case Rol_GST:
|
||||
Gbl.Action.Act = ActUpdOth;
|
||||
break;
|
||||
case Rol_STD:
|
||||
Gbl.Action.Act = ActUpdStd;
|
||||
break;
|
||||
case Rol_NET:
|
||||
Gbl.Action.Act = ActUpdNET;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
Gbl.Action.Act = ActUpdTch;
|
||||
break;
|
||||
default:
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
if (!Action[NewRole])
|
||||
Err_WrongRoleExit ();
|
||||
Gbl.Action.Act = Action[NewRole];
|
||||
Tab_SetCurrentTab ();
|
||||
}
|
||||
}
|
||||
|
@ -3125,7 +3037,12 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
|
|||
extern const char *Txt_Remove_me_from_this_course;
|
||||
extern const char *Txt_Remove_user_from_this_course;
|
||||
bool ItsMe;
|
||||
Act_Action_t NextAction;
|
||||
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_STD] = ActRemStdCrs,
|
||||
[Rol_NET] = ActRemNETCrs,
|
||||
[Rol_TCH] = ActRemTchCrs,
|
||||
};
|
||||
|
||||
if (Enr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
|
||||
{
|
||||
|
@ -3141,23 +3058,9 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
|
|||
Rec_ShowSharedRecordUnmodifiable (UsrDat);
|
||||
|
||||
/* Show form to request confirmation */
|
||||
switch (UsrDat->Roles.InCurrentCrs)
|
||||
{
|
||||
case Rol_STD:
|
||||
NextAction = ActRemStdCrs;
|
||||
break;
|
||||
case Rol_NET:
|
||||
NextAction = ActRemNETCrs;
|
||||
break;
|
||||
case Rol_TCH:
|
||||
NextAction = ActRemTchCrs;
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Frm_BeginForm (NextAction);
|
||||
if (!NextAction[UsrDat->Roles.InCurrentCrs])
|
||||
Err_WrongRoleExit ();
|
||||
Frm_BeginForm (NextAction[UsrDat->Roles.InCurrentCrs]);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
Pwd_AskForConfirmationOnDangerousAction ();
|
||||
Btn_PutRemoveButton (ItsMe ? Txt_Remove_me_from_this_course :
|
||||
|
|
15
swad_user.c
15
swad_user.c
|
@ -6365,16 +6365,9 @@ void Usr_ShowTableCellWithUsrData (struct UsrData *UsrDat,unsigned NumRows)
|
|||
{
|
||||
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
||||
{
|
||||
[Rol_UNK ] = ActUnk,
|
||||
[Rol_GST ] = ActUnk,
|
||||
[Rol_USR ] = ActUnk,
|
||||
[Rol_STD ] = ActSeeRecOneStd,
|
||||
[Rol_NET ] = ActSeeRecOneTch,
|
||||
[Rol_TCH ] = ActSeeRecOneTch,
|
||||
[Rol_DEG_ADM] = ActUnk,
|
||||
[Rol_CTR_ADM] = ActUnk,
|
||||
[Rol_INS_ADM] = ActUnk,
|
||||
[Rol_SYS_ADM] = ActUnk,
|
||||
[Rol_STD] = ActSeeRecOneStd,
|
||||
[Rol_NET] = ActSeeRecOneTch,
|
||||
[Rol_TCH] = ActSeeRecOneTch,
|
||||
};
|
||||
|
||||
/***** Show user's photo *****/
|
||||
|
@ -6395,7 +6388,7 @@ void Usr_ShowTableCellWithUsrData (struct UsrData *UsrDat,unsigned NumRows)
|
|||
HTM_TD_Begin ("class=\"LT LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd);
|
||||
|
||||
/* Action to go to user's record depending on role in course */
|
||||
if (NextAction[UsrDat->Roles.InCurrentCrs] == ActUnk)
|
||||
if (!NextAction[UsrDat->Roles.InCurrentCrs])
|
||||
/* Begin div */
|
||||
HTM_DIV_Begin ("class=\"LT AUTHOR_TXT\"");
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue