Version 21.56.3: Nov 10, 2021 Code refactoring in switch statements (until swad_logo.c).

This commit is contained in:
acanas 2021-11-10 21:04:34 +01:00
parent 25356528f9
commit fdb90c34d1
7 changed files with 168 additions and 258 deletions

View File

@ -391,23 +391,22 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID,
{ {
extern const char *The_ClassFormLinkOutBoxBold[The_NUM_THEMES]; extern const char *The_ClassFormLinkOutBoxBold[The_NUM_THEMES];
extern const char *Txt_Confirm_ID; extern const char *Txt_Confirm_ID;
Act_Action_t NextAction; static const Act_Action_t NextAction[Rol_NUM_ROLES] =
{
[Rol_UNK ] = ActCnfID_Oth,
[Rol_GST ] = ActCnfID_Oth,
[Rol_USR ] = ActCnfID_Oth,
[Rol_STD ] = ActCnfID_Std,
[Rol_NET ] = ActCnfID_Tch,
[Rol_TCH ] = ActCnfID_Tch,
[Rol_DEG_ADM] = ActCnfID_Oth,
[Rol_CTR_ADM] = ActCnfID_Oth,
[Rol_INS_ADM] = ActCnfID_Oth,
[Rol_SYS_ADM] = ActCnfID_Oth,
};
/***** Begin form *****/ /***** Begin form *****/
switch (UsrDat->Roles.InCurrentCrs) Frm_BeginFormAnchor (NextAction[UsrDat->Roles.InCurrentCrs],Anchor);
{
case Rol_STD:
NextAction = ActCnfID_Std;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActCnfID_Tch;
break;
default: // Guest, user or admin
NextAction = ActCnfID_Oth;
break;
}
Frm_BeginFormAnchor (NextAction,Anchor);
if (Gbl.Action.Original != ActUnk) if (Gbl.Action.Original != ActUnk)
{ {
Par_PutHiddenParamLong (NULL,"OriginalActCod", Par_PutHiddenParamLong (NULL,"OriginalActCod",
@ -510,7 +509,23 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
extern const char *Txt_Add_this_ID; extern const char *Txt_Add_this_ID;
extern const char *Txt_The_ID_is_used_in_order_to_facilitate_; extern const char *Txt_The_ID_is_used_in_order_to_facilitate_;
unsigned NumID; unsigned NumID;
Act_Action_t NextAction; static const struct
{
Act_Action_t Remove;
Act_Action_t New;
} NextAction[Rol_NUM_ROLES] =
{
[Rol_UNK ] = {ActRemID_Oth,ActNewID_Oth},
[Rol_GST ] = {ActRemID_Oth,ActNewID_Oth},
[Rol_USR ] = {ActRemID_Oth,ActNewID_Oth},
[Rol_STD ] = {ActRemID_Std,ActNewID_Std},
[Rol_NET ] = {ActRemID_Tch,ActNewID_Tch},
[Rol_TCH ] = {ActRemID_Tch,ActNewID_Tch},
[Rol_DEG_ADM] = {ActRemID_Oth,ActNewID_Oth},
[Rol_CTR_ADM] = {ActRemID_Oth,ActNewID_Oth},
[Rol_INS_ADM] = {ActRemID_Oth,ActNewID_Oth},
[Rol_SYS_ADM] = {ActRemID_Oth,ActNewID_Oth},
};
const struct UsrData *UsrDat = (ItsMe ? &Gbl.Usrs.Me.UsrDat : const struct UsrData *UsrDat = (ItsMe ? &Gbl.Usrs.Me.UsrDat :
&Gbl.Usrs.Other.UsrDat); &Gbl.Usrs.Other.UsrDat);
@ -554,23 +569,8 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
Ico_PutContextualIconToRemove (ActRemMyID,ID_ID_SECTION_ID, Ico_PutContextualIconToRemove (ActRemMyID,ID_ID_SECTION_ID,
ID_PutParamsRemoveMyID,UsrDat->IDs.List[NumID].ID); ID_PutParamsRemoveMyID,UsrDat->IDs.List[NumID].ID);
else else
{ Ico_PutContextualIconToRemove (NextAction[UsrDat->Roles.InCurrentCrs].Remove,ID_ID_SECTION_ID,
switch (UsrDat->Roles.InCurrentCrs)
{
case Rol_STD:
NextAction = ActRemID_Std;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActRemID_Tch;
break;
default: // Guest, user or admin
NextAction = ActRemID_Oth;
break;
}
Ico_PutContextualIconToRemove (NextAction,ID_ID_SECTION_ID,
ID_PutParamsRemoveOtherID,UsrDat->IDs.List[NumID].ID); ID_PutParamsRemoveOtherID,UsrDat->IDs.List[NumID].ID);
}
} }
} }
@ -619,20 +619,7 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
Frm_BeginFormAnchor (ActChgMyID,ID_ID_SECTION_ID); Frm_BeginFormAnchor (ActChgMyID,ID_ID_SECTION_ID);
else else
{ {
switch (UsrDat->Roles.InCurrentCrs) Frm_BeginFormAnchor (NextAction[UsrDat->Roles.InCurrentCrs].New,ID_ID_SECTION_ID);
{
case Rol_STD:
NextAction = ActNewID_Std;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActNewID_Tch;
break;
default: // Guest, user or admin
NextAction = ActNewID_Oth;
break;
}
Frm_BeginFormAnchor (NextAction,ID_ID_SECTION_ID);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
} }
HTM_INPUT_TEXT ("NewID",ID_MAX_BYTES_USR_ID, HTM_INPUT_TEXT ("NewID",ID_MAX_BYTES_USR_ID,

View File

@ -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. 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.2 (2021-11-10)" #define Log_PLATFORM_VERSION "SWAD 21.56.3 (2021-11-10)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 21.56.3: Nov 10, 2021 Code refactoring in switch statements (until swad_logo.c). (319403 lines)
Version 21.56.2: Nov 10, 2021 Code refactoring in pointers to text. (319501 lines) Version 21.56.2: Nov 10, 2021 Code refactoring in pointers to text. (319501 lines)
Version 21.56.1: Nov 10, 2021 Code refactoring in switch statements (until swad_enrolment.c). (319490 lines) 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.56: Nov 10, 2021 Code refactoring in hierarchy. (319618 lines)

View File

@ -318,15 +318,13 @@ static void Exa_ListAllExams (struct Exa_Exams *Exams)
bool Exa_CheckIfICanEditExams (void) bool Exa_CheckIfICanEditExams (void)
{ {
switch (Gbl.Usrs.Me.Role.Logged) static const bool ICanEditExams[Rol_NUM_ROLES] =
{ {
case Rol_TCH: [Rol_TCH ] = true,
case Rol_SYS_ADM: [Rol_SYS_ADM] = true,
return true; };
default:
return false; return ICanEditExams[Gbl.Usrs.Me.Role.Logged];
}
return false;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -335,6 +333,14 @@ bool Exa_CheckIfICanEditExams (void)
static void Exa_PutIconsListExams (void *Exams) static void Exa_PutIconsListExams (void *Exams)
{ {
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
{
[Rol_STD ] = ActSeeMyExaResCrs,
[Rol_NET ] = ActReqSeeUsrExaRes,
[Rol_TCH ] = ActReqSeeUsrExaRes,
[Rol_SYS_ADM] = ActReqSeeUsrExaRes,
};
if (Exams) if (Exams)
{ {
/***** Put icon to create a new exam *****/ /***** Put icon to create a new exam *****/
@ -342,21 +348,9 @@ static void Exa_PutIconsListExams (void *Exams)
Exa_PutIconToCreateNewExam ((struct Exa_Exams *) Exams); Exa_PutIconToCreateNewExam ((struct Exa_Exams *) Exams);
/***** Put icon to view sessions results *****/ /***** Put icon to view sessions results *****/
switch (Gbl.Usrs.Me.Role.Logged) if (NextAction[Gbl.Usrs.Me.Role.Logged])
{ Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],NULL,
case Rol_STD: NULL,NULL);
Ico_PutContextualIconToShowResults (ActSeeMyExaResCrs,NULL,
NULL,NULL);
break;
case Rol_NET:
case Rol_TCH:
case Rol_SYS_ADM:
Ico_PutContextualIconToShowResults (ActReqSeeUsrExaRes,NULL,
NULL,NULL);
break;
default:
break;
}
/***** Put icon to show a figure *****/ /***** Put icon to show a figure *****/
Fig_PutIconToShowFigure (Fig_EXAMS); Fig_PutIconToShowFigure (Fig_EXAMS);
@ -642,25 +636,19 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,
static void Exa_PutIconToShowResultsOfExam (void *Exams) static void Exa_PutIconToShowResultsOfExam (void *Exams)
{ {
if (Exams) static const Act_Action_t NextAction[Rol_NUM_ROLES] =
{ {
[Rol_STD ] = ActSeeMyExaResExa,
[Rol_NET ] = ActSeeUsrExaResExa,
[Rol_TCH ] = ActSeeUsrExaResExa,
[Rol_SYS_ADM] = ActSeeUsrExaResExa,
};
if (Exams)
/***** Put icon to view sessions results *****/ /***** Put icon to view sessions results *****/
switch (Gbl.Usrs.Me.Role.Logged) if (NextAction[Gbl.Usrs.Me.Role.Logged])
{ Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],ExaRes_RESULTS_BOX_ID,
case Rol_STD: Exa_PutParams,Exams);
Ico_PutContextualIconToShowResults (ActSeeMyExaResExa,ExaRes_RESULTS_BOX_ID,
Exa_PutParams,Exams);
break;
case Rol_NET:
case Rol_TCH:
case Rol_SYS_ADM:
Ico_PutContextualIconToShowResults (ActSeeUsrExaResExa,ExaRes_RESULTS_BOX_ID,
Exa_PutParams,Exams);
break;
default:
break;
}
}
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -240,7 +240,14 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
// 12345678901234 // 12345678901234
char SessionId[Cns_BYTES_SESSION_ID + 1]; char SessionId[Cns_BYTES_SESSION_ID + 1];
char *UserAgent; char *UserAgent;
const char *Class; const char *Class[ExaLog_NUM_ACTIONS] =
{
[ExaLog_UNKNOWN_ACTION ] = "DAT_SMALL_LIGHT",
[ExaLog_START_EXAM ] = "DAT_SMALL_N",
[ExaLog_RESUME_EXAM ] = "DAT_SMALL_N",
[ExaLog_ANSWER_QUESTION] = "DAT_SMALL",
[ExaLog_FINISH_EXAM ] = "DAT_SMALL_N",
};
/***** Get print log from database *****/ /***** Get print log from database *****/
if ((NumClicks = Exa_DB_GetExamLog (&mysql_res,Print->PrnCod))) if ((NumClicks = Exa_DB_GetExamLog (&mysql_res,Print->PrnCod)))
@ -308,25 +315,6 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
"=") < 0) "=") < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
/***** Set color of row depending on action *****/
if (UsrCouldAnswer)
switch (Action)
{
case ExaLog_START_EXAM:
case ExaLog_RESUME_EXAM:
case ExaLog_FINISH_EXAM:
Class = "DAT_SMALL_N";
break;
case ExaLog_ANSWER_QUESTION:
Class = "DAT_SMALL";
break;
default:
Class = "DAT_SMALL_LIGHT";
break;
}
else // Closed or not accesible exam print
Class = "DAT_SMALL_LIGHT";
/***** Write row *****/ /***** Write row *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
@ -340,7 +328,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
/* Write click time */ /* Write click time */
if (asprintf (&Id,"click_date_%u",NumClick) < 0) if (asprintf (&Id,"click_date_%u",NumClick) < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
HTM_TD_Begin ("id=\"%s\" class=\"LT COLOR%u %s\"",Id,Gbl.RowEvenOdd,Class); HTM_TD_Begin ("id=\"%s\" class=\"LT COLOR%u %s\"",Id,Gbl.RowEvenOdd,Class[Action]);
Dat_WriteLocalDateHMSFromUTC (Id,ClickTimeUTC, Dat_WriteLocalDateHMSFromUTC (Id,ClickTimeUTC,
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
true,true,true,0x7); true,true,true,0x7);
@ -348,12 +336,12 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
HTM_TD_End (); HTM_TD_End ();
/* Write action */ /* Write action */
HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class[Action]);
HTM_Txt (Txt_EXAM_LOG_ACTIONS[Action]); HTM_Txt (Txt_EXAM_LOG_ACTIONS[Action]);
HTM_TD_End (); HTM_TD_End ();
/* Write number of question */ /* Write number of question */
HTM_TD_Begin ("class=\"RT COLOR%u %s\"",Gbl.RowEvenOdd,Class); HTM_TD_Begin ("class=\"RT COLOR%u %s\"",Gbl.RowEvenOdd,Class[Action]);
if (QstInd >= 0) if (QstInd >= 0)
HTM_Unsigned ((unsigned) QstInd + 1); HTM_Unsigned ((unsigned) QstInd + 1);
HTM_TD_End (); HTM_TD_End ();
@ -367,7 +355,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
HTM_TD_End (); HTM_TD_End ();
/* Write IP */ /* Write IP */
HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class[Action]);
Length = strlen (IP); Length = strlen (IP);
if (Length > 6) if (Length > 6)
{ {
@ -385,7 +373,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
HTM_TD_End (); HTM_TD_End ();
/* Write session id */ /* Write session id */
HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class[Action]);
if (SessionId[0]) if (SessionId[0])
{ {
Length = strlen (SessionId); Length = strlen (SessionId);
@ -406,7 +394,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
HTM_TD_End (); HTM_TD_End ();
/* Write user agent (row[6]) */ /* Write user agent (row[6]) */
HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class[Action]);
if (UserAgent[0]) if (UserAgent[0])
HTM_Txt (UserAgent); HTM_Txt (UserAgent);
HTM_TD_End (); HTM_TD_End ();

View File

@ -70,7 +70,7 @@ static void ExaSes_ListOneOrMoreSessions (struct Exa_Exams *Exams,
MYSQL_RES *mysql_res); MYSQL_RES *mysql_res);
static void ExaSes_ListOneOrMoreSessionsHeading (bool ICanEditSessions); static void ExaSes_ListOneOrMoreSessionsHeading (bool ICanEditSessions);
static bool ExaSes_CheckIfICanEditSessions (void); static bool ExaSes_CheckIfICanEditSessions (void);
static bool ExaSes_CheckIfICanEditThisSession (const struct ExaSes_Session *Session); static bool ExaSes_CheckIfICanEditThisSession (long UsrCod);
static bool ExaSes_CheckIfVisibilityOfResultsCanBeChanged (const struct ExaSes_Session *Session); static bool ExaSes_CheckIfVisibilityOfResultsCanBeChanged (const struct ExaSes_Session *Session);
static void ExaSes_ListOneOrMoreSessionsIcons (struct Exa_Exams *Exams, static void ExaSes_ListOneOrMoreSessionsIcons (struct Exa_Exams *Exams,
const struct ExaSes_Session *Session, const struct ExaSes_Session *Session,
@ -311,7 +311,7 @@ static void ExaSes_ListOneOrMoreSessions (struct Exa_Exams *Exams,
/* Icons */ /* Icons */
if (ICanEditSessions) if (ICanEditSessions)
if (ExaSes_CheckIfICanEditThisSession (&Session)) if (ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
ExaSes_ListOneOrMoreSessionsIcons (Exams,&Session,Anchor); ExaSes_ListOneOrMoreSessionsIcons (Exams,&Session,Anchor);
/* Session participant */ /* Session participant */
@ -383,27 +383,26 @@ static void ExaSes_ListOneOrMoreSessionsHeading (bool ICanEditSessions)
static bool ExaSes_CheckIfICanEditSessions (void) static bool ExaSes_CheckIfICanEditSessions (void)
{ {
switch (Gbl.Usrs.Me.Role.Logged) static const bool ICanEditSessions[Rol_NUM_ROLES] =
{ {
case Rol_NET: [Rol_NET ] = true,
case Rol_TCH: [Rol_TCH ] = true,
case Rol_SYS_ADM: [Rol_SYS_ADM] = true,
return true; };
default:
return false; return ICanEditSessions[Gbl.Usrs.Me.Role.Logged];
}
} }
/*****************************************************************************/ /*****************************************************************************/
/************ Check if I can edit (remove/resume) an exam session ************/ /************ Check if I can edit (remove/resume) an exam session ************/
/*****************************************************************************/ /*****************************************************************************/
static bool ExaSes_CheckIfICanEditThisSession (const struct ExaSes_Session *Session) static bool ExaSes_CheckIfICanEditThisSession (long UsrCod)
{ {
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)
{ {
case Rol_NET: case Rol_NET:
return (Session->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); // Only if I am the creator return (UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod); // Only if I am the creator
case Rol_TCH: case Rol_TCH:
case Rol_SYS_ADM: case Rol_SYS_ADM:
return true; return true;
@ -420,7 +419,7 @@ static bool ExaSes_CheckIfVisibilityOfResultsCanBeChanged (const struct ExaSes_S
{ {
if (Session->ShowUsrResults || // Results are currently visible if (Session->ShowUsrResults || // Results are currently visible
Session->TimeUTC[Dat_END_TIME] < Gbl.StartExecutionTimeUTC) // End of time is in the past Session->TimeUTC[Dat_END_TIME] < Gbl.StartExecutionTimeUTC) // End of time is in the past
if (ExaSes_CheckIfICanEditThisSession (Session)) if (ExaSes_CheckIfICanEditThisSession (Session->UsrCod))
return true; return true;
return false; return false;
@ -615,22 +614,21 @@ static void ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (const struct ExaSe
static void ExaSes_ListOneOrMoreSessionsResult (struct Exa_Exams *Exams, static void ExaSes_ListOneOrMoreSessionsResult (struct Exa_Exams *Exams,
const struct ExaSes_Session *Session) const struct ExaSes_Session *Session)
{ {
static void (*Function[Rol_NUM_ROLES]) (struct Exa_Exams *Exams,
const struct ExaSes_Session *Session) =
{
[Rol_STD ] = ExaSes_ListOneOrMoreSessionsResultStd,
[Rol_NET ] = ExaSes_ListOneOrMoreSessionsResultTch,
[Rol_TCH ] = ExaSes_ListOneOrMoreSessionsResultTch,
[Rol_SYS_ADM] = ExaSes_ListOneOrMoreSessionsResultTch,
};
HTM_TD_Begin ("class=\"DAT CT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("class=\"DAT CT COLOR%u\"",Gbl.RowEvenOdd);
switch (Gbl.Usrs.Me.Role.Logged) if (Function[Gbl.Usrs.Me.Role.Logged])
{ Function[Gbl.Usrs.Me.Role.Logged] (Exams,Session);
case Rol_STD: else
ExaSes_ListOneOrMoreSessionsResultStd (Exams,Session); Err_WrongRoleExit ();
break;
case Rol_NET:
case Rol_TCH:
case Rol_SYS_ADM:
ExaSes_ListOneOrMoreSessionsResultTch (Exams,Session);
break;
default:
Err_WrongRoleExit ();
break;
}
HTM_TD_End (); HTM_TD_End ();
} }
@ -667,7 +665,7 @@ static void ExaSes_ListOneOrMoreSessionsResultTch (struct Exa_Exams *Exams,
Exams->SesCod = Session->SesCod; Exams->SesCod = Session->SesCod;
/***** Show exam session results *****/ /***** Show exam session results *****/
if (ExaSes_CheckIfICanEditThisSession (Session)) if (ExaSes_CheckIfICanEditThisSession (Session->UsrCod))
Lay_PutContextualLinkOnlyIcon (ActSeeUsrExaResSes,ExaRes_RESULTS_BOX_ID, Lay_PutContextualLinkOnlyIcon (ActSeeUsrExaResSes,ExaRes_RESULTS_BOX_ID,
ExaSes_PutParamsEdit,Exams, ExaSes_PutParamsEdit,Exams,
"trophy.svg", "trophy.svg",
@ -834,7 +832,7 @@ void ExaSes_RemoveSession (void)
ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session); ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session);
/***** Check if I can remove this exam session *****/ /***** Check if I can remove this exam session *****/
if (!ExaSes_CheckIfICanEditThisSession (&Session)) if (!ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
Err_NoPermissionExit (); Err_NoPermissionExit ();
/***** Remove questions of exams prints, and exam prints, in this session *****/ /***** Remove questions of exams prints, and exam prints, in this session *****/
@ -880,7 +878,7 @@ void ExaSes_HideSession (void)
ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session); ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session);
/***** Check if I can remove this exam session *****/ /***** Check if I can remove this exam session *****/
if (!ExaSes_CheckIfICanEditThisSession (&Session)) if (!ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
Err_NoPermissionExit (); Err_NoPermissionExit ();
/***** Hide session *****/ /***** Hide session *****/
@ -910,7 +908,7 @@ void ExaSes_UnhideSession (void)
ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session); ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session);
/***** Check if I can remove this exam session *****/ /***** Check if I can remove this exam session *****/
if (!ExaSes_CheckIfICanEditThisSession (&Session)) if (!ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
Err_NoPermissionExit (); Err_NoPermissionExit ();
/***** Unhide session *****/ /***** Unhide session *****/

View File

@ -2586,72 +2586,34 @@ static void Fig_ShowStatOfAForumType (For_ForumType_t ForumType,
extern const char *Txt_Institutions; extern const char *Txt_Institutions;
extern const char *Txt_General; extern const char *Txt_General;
extern const char *Txt_only_teachers; extern const char *Txt_only_teachers;
static const char *PlatformShortName = Cfg_PLATFORM_SHORT_NAME;
switch (ForumType) static const char *EmptyName = "";
static const struct
{ {
case For_FORUM_GLOBAL_USRS: const char *Icon;
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod, const char **ForumName1;
"comments.svg",FiguresForum, const char **ForumName2;
Txt_General,""); } Params[For_NUM_TYPES_FORUM] =
break; {
case For_FORUM_GLOBAL_TCHS: [For_FORUM_COURSE_USRS] = {"chalkboard-teacher.svg",&Txt_Courses ,&EmptyName },
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod, [For_FORUM_COURSE_TCHS] = {"chalkboard-teacher.svg",&Txt_Courses ,&Txt_only_teachers},
"comments.svg",FiguresForum, [For_FORUM_DEGREE_USRS] = {"graduation-cap.svg" ,&Txt_Degrees ,&EmptyName },
Txt_General,Txt_only_teachers); [For_FORUM_DEGREE_TCHS] = {"graduation-cap.svg" ,&Txt_Degrees ,&Txt_only_teachers},
break; [For_FORUM_CENTER_USRS] = {"building.svg" ,&Txt_Centers ,&EmptyName },
case For_FORUM__SWAD__USRS: [For_FORUM_CENTER_TCHS] = {"building.svg" ,&Txt_Centers ,&Txt_only_teachers},
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod, [For_FORUM_INSTIT_USRS] = {"university.svg" ,&Txt_Institutions ,&EmptyName },
"swad64x64.png",FiguresForum, [For_FORUM_INSTIT_TCHS] = {"university.svg" ,&Txt_Institutions ,&Txt_only_teachers},
Cfg_PLATFORM_SHORT_NAME,""); [For_FORUM_GLOBAL_USRS] = {"comments.svg" ,&Txt_General ,&EmptyName },
break; [For_FORUM_GLOBAL_TCHS] = {"comments.svg" ,&Txt_General ,&Txt_only_teachers},
case For_FORUM__SWAD__TCHS: [For_FORUM__SWAD__USRS] = {"swad64x64.png" ,&PlatformShortName,&EmptyName },
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod, [For_FORUM__SWAD__TCHS] = {"swad64x64.png" ,&PlatformShortName,&Txt_only_teachers},
"swad64x64.png",FiguresForum, };
Cfg_PLATFORM_SHORT_NAME,Txt_only_teachers);
break; if (Params[ForumType].Icon)
case For_FORUM_INSTIT_USRS: Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod, Params[ForumType].Icon,FiguresForum,
"university.svg",FiguresForum, *Params[ForumType].ForumName1,
Txt_Institutions,""); *Params[ForumType].ForumName2);
break;
case For_FORUM_INSTIT_TCHS:
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
"university.svg",FiguresForum,
Txt_Institutions,Txt_only_teachers);
break;
case For_FORUM_CENTER_USRS:
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
"building.svg",FiguresForum,
Txt_Centers,"");
break;
case For_FORUM_CENTER_TCHS:
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
"building.svg",FiguresForum,
Txt_Centers,Txt_only_teachers);
break;
case For_FORUM_DEGREE_USRS:
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
"graduation-cap.svg",FiguresForum,
Txt_Degrees,"");
break;
case For_FORUM_DEGREE_TCHS:
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
"graduation-cap.svg",FiguresForum,
Txt_Degrees,Txt_only_teachers);
break;
case For_FORUM_COURSE_USRS:
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
"chalkboard-teacher.svg",FiguresForum,
Txt_Courses,"");
break;
case For_FORUM_COURSE_TCHS:
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
"chalkboard-teacher.svg",FiguresForum,
Txt_Courses,Txt_only_teachers);
break;
default:
break;
}
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -341,15 +341,13 @@ static void Gam_ListAllGames (struct Gam_Games *Games)
static bool Gam_CheckIfICanEditGames (void) static bool Gam_CheckIfICanEditGames (void)
{ {
switch (Gbl.Usrs.Me.Role.Logged) static const bool ICanEditGames[Rol_NUM_ROLES] =
{ {
case Rol_TCH: [Rol_TCH ] = true,
case Rol_SYS_ADM: [Rol_SYS_ADM] = true,
return true; };
default:
return false; return ICanEditGames[Gbl.Usrs.Me.Role.Logged];
}
return false;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -358,16 +356,14 @@ static bool Gam_CheckIfICanEditGames (void)
static bool Gam_CheckIfICanListGameQuestions (void) static bool Gam_CheckIfICanListGameQuestions (void)
{ {
switch (Gbl.Usrs.Me.Role.Logged) static const bool ICanListGameQuestions[Rol_NUM_ROLES] =
{ {
case Rol_NET: [Rol_NET ] = true,
case Rol_TCH: [Rol_TCH ] = true,
case Rol_SYS_ADM: [Rol_SYS_ADM] = true,
return true; };
default:
return false; return ICanListGameQuestions[Gbl.Usrs.Me.Role.Logged];
}
return false;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -376,6 +372,14 @@ static bool Gam_CheckIfICanListGameQuestions (void)
static void Gam_PutIconsListGames (void *Games) static void Gam_PutIconsListGames (void *Games)
{ {
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
{
[Rol_STD ] = ActSeeMyMchResCrs,
[Rol_NET ] = ActReqSeeUsrMchRes,
[Rol_TCH ] = ActReqSeeUsrMchRes,
[Rol_SYS_ADM] = ActReqSeeUsrMchRes,
};
if (Games) if (Games)
{ {
/***** Put icon to create a new game *****/ /***** Put icon to create a new game *****/
@ -383,21 +387,9 @@ static void Gam_PutIconsListGames (void *Games)
Gam_PutIconToCreateNewGame ((struct Gam_Games *) Games); Gam_PutIconToCreateNewGame ((struct Gam_Games *) Games);
/***** Put icon to view matches results *****/ /***** Put icon to view matches results *****/
switch (Gbl.Usrs.Me.Role.Logged) if (NextAction[Gbl.Usrs.Me.Role.Logged])
{ Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],NULL,
case Rol_STD: NULL,NULL);
Ico_PutContextualIconToShowResults (ActSeeMyMchResCrs,NULL,
NULL,NULL);
break;
case Rol_NET:
case Rol_TCH:
case Rol_SYS_ADM:
Ico_PutContextualIconToShowResults (ActReqSeeUsrMchRes,NULL,
NULL,NULL);
break;
default:
break;
}
/***** Put icon to show a figure *****/ /***** Put icon to show a figure *****/
Fig_PutIconToShowFigure (Fig_GAMES); Fig_PutIconToShowFigure (Fig_GAMES);
@ -695,25 +687,19 @@ static void Gam_ShowOneGame (struct Gam_Games *Games,
static void Gam_PutIconToShowResultsOfGame (void *Games) static void Gam_PutIconToShowResultsOfGame (void *Games)
{ {
if (Games) static const Act_Action_t NextAction[Rol_NUM_ROLES] =
{ {
[Rol_STD ] = ActSeeMyMchResGam,
[Rol_NET ] = ActSeeUsrMchResGam,
[Rol_TCH ] = ActSeeUsrMchResGam,
[Rol_SYS_ADM] = ActSeeUsrMchResGam,
};
if (Games)
/***** Put icon to view matches results *****/ /***** Put icon to view matches results *****/
switch (Gbl.Usrs.Me.Role.Logged) if (NextAction[Gbl.Usrs.Me.Role.Logged])
{ Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],MchRes_RESULTS_BOX_ID,
case Rol_STD: Gam_PutParams,Games);
Ico_PutContextualIconToShowResults (ActSeeMyMchResGam,MchRes_RESULTS_BOX_ID,
Gam_PutParams,Games);
break;
case Rol_NET:
case Rol_TCH:
case Rol_SYS_ADM:
Ico_PutContextualIconToShowResults (ActSeeUsrMchResGam,MchRes_RESULTS_BOX_ID,
Gam_PutParams,Games);
break;
default:
break;
}
}
} }
/*****************************************************************************/ /*****************************************************************************/