mirror of https://github.com/acanas/swad-core.git
Version 21.56.3: Nov 10, 2021 Code refactoring in switch statements (until swad_logo.c).
This commit is contained in:
parent
25356528f9
commit
fdb90c34d1
79
swad_ID.c
79
swad_ID.c
|
@ -391,23 +391,22 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID,
|
|||
{
|
||||
extern const char *The_ClassFormLinkOutBoxBold[The_NUM_THEMES];
|
||||
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 *****/
|
||||
switch (UsrDat->Roles.InCurrentCrs)
|
||||
{
|
||||
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);
|
||||
Frm_BeginFormAnchor (NextAction[UsrDat->Roles.InCurrentCrs],Anchor);
|
||||
if (Gbl.Action.Original != ActUnk)
|
||||
{
|
||||
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_The_ID_is_used_in_order_to_facilitate_;
|
||||
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 :
|
||||
&Gbl.Usrs.Other.UsrDat);
|
||||
|
||||
|
@ -554,23 +569,8 @@ static void ID_ShowFormChangeUsrID (bool ItsMe,bool IShouldFillInID)
|
|||
Ico_PutContextualIconToRemove (ActRemMyID,ID_ID_SECTION_ID,
|
||||
ID_PutParamsRemoveMyID,UsrDat->IDs.List[NumID].ID);
|
||||
else
|
||||
{
|
||||
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,
|
||||
Ico_PutContextualIconToRemove (NextAction[UsrDat->Roles.InCurrentCrs].Remove,ID_ID_SECTION_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);
|
||||
else
|
||||
{
|
||||
switch (UsrDat->Roles.InCurrentCrs)
|
||||
{
|
||||
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);
|
||||
Frm_BeginFormAnchor (NextAction[UsrDat->Roles.InCurrentCrs].New,ID_ID_SECTION_ID);
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
}
|
||||
HTM_INPUT_TEXT ("NewID",ID_MAX_BYTES_USR_ID,
|
||||
|
|
|
@ -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.2 (2021-11-10)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.56.3 (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.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.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)
|
||||
|
|
68
swad_exam.c
68
swad_exam.c
|
@ -318,15 +318,13 @@ static void Exa_ListAllExams (struct Exa_Exams *Exams)
|
|||
|
||||
bool Exa_CheckIfICanEditExams (void)
|
||||
{
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
static const bool ICanEditExams[Rol_NUM_ROLES] =
|
||||
{
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
[Rol_TCH ] = true,
|
||||
[Rol_SYS_ADM] = true,
|
||||
};
|
||||
|
||||
return ICanEditExams[Gbl.Usrs.Me.Role.Logged];
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -335,6 +333,14 @@ bool Exa_CheckIfICanEditExams (void)
|
|||
|
||||
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)
|
||||
{
|
||||
/***** Put icon to create a new exam *****/
|
||||
|
@ -342,21 +348,9 @@ static void Exa_PutIconsListExams (void *Exams)
|
|||
Exa_PutIconToCreateNewExam ((struct Exa_Exams *) Exams);
|
||||
|
||||
/***** Put icon to view sessions results *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
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;
|
||||
}
|
||||
if (NextAction[Gbl.Usrs.Me.Role.Logged])
|
||||
Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],NULL,
|
||||
NULL,NULL);
|
||||
|
||||
/***** Put icon to show a figure *****/
|
||||
Fig_PutIconToShowFigure (Fig_EXAMS);
|
||||
|
@ -642,25 +636,19 @@ static void Exa_ShowOneExam (struct Exa_Exams *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 *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (NextAction[Gbl.Usrs.Me.Role.Logged])
|
||||
Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],ExaRes_RESULTS_BOX_ID,
|
||||
Exa_PutParams,Exams);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -240,7 +240,14 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
// 12345678901234
|
||||
char SessionId[Cns_BYTES_SESSION_ID + 1];
|
||||
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 *****/
|
||||
if ((NumClicks = Exa_DB_GetExamLog (&mysql_res,Print->PrnCod)))
|
||||
|
@ -308,25 +315,6 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
"=") < 0)
|
||||
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 *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
@ -340,7 +328,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
/* Write click time */
|
||||
if (asprintf (&Id,"click_date_%u",NumClick) < 0)
|
||||
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,
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
true,true,true,0x7);
|
||||
|
@ -348,12 +336,12 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
HTM_TD_End ();
|
||||
|
||||
/* 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_TD_End ();
|
||||
|
||||
/* 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)
|
||||
HTM_Unsigned ((unsigned) QstInd + 1);
|
||||
HTM_TD_End ();
|
||||
|
@ -367,7 +355,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
HTM_TD_End ();
|
||||
|
||||
/* 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);
|
||||
if (Length > 6)
|
||||
{
|
||||
|
@ -385,7 +373,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
HTM_TD_End ();
|
||||
|
||||
/* 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])
|
||||
{
|
||||
Length = strlen (SessionId);
|
||||
|
@ -406,7 +394,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
HTM_TD_End ();
|
||||
|
||||
/* 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])
|
||||
HTM_Txt (UserAgent);
|
||||
HTM_TD_End ();
|
||||
|
|
|
@ -70,7 +70,7 @@ static void ExaSes_ListOneOrMoreSessions (struct Exa_Exams *Exams,
|
|||
MYSQL_RES *mysql_res);
|
||||
static void ExaSes_ListOneOrMoreSessionsHeading (bool ICanEditSessions);
|
||||
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 void ExaSes_ListOneOrMoreSessionsIcons (struct Exa_Exams *Exams,
|
||||
const struct ExaSes_Session *Session,
|
||||
|
@ -311,7 +311,7 @@ static void ExaSes_ListOneOrMoreSessions (struct Exa_Exams *Exams,
|
|||
|
||||
/* Icons */
|
||||
if (ICanEditSessions)
|
||||
if (ExaSes_CheckIfICanEditThisSession (&Session))
|
||||
if (ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
|
||||
ExaSes_ListOneOrMoreSessionsIcons (Exams,&Session,Anchor);
|
||||
|
||||
/* Session participant */
|
||||
|
@ -383,27 +383,26 @@ static void ExaSes_ListOneOrMoreSessionsHeading (bool ICanEditSessions)
|
|||
|
||||
static bool ExaSes_CheckIfICanEditSessions (void)
|
||||
{
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
static const bool ICanEditSessions[Rol_NUM_ROLES] =
|
||||
{
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
[Rol_NET ] = true,
|
||||
[Rol_TCH ] = true,
|
||||
[Rol_SYS_ADM] = true,
|
||||
};
|
||||
|
||||
return ICanEditSessions[Gbl.Usrs.Me.Role.Logged];
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ 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)
|
||||
{
|
||||
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_SYS_ADM:
|
||||
return true;
|
||||
|
@ -420,7 +419,7 @@ static bool ExaSes_CheckIfVisibilityOfResultsCanBeChanged (const struct ExaSes_S
|
|||
{
|
||||
if (Session->ShowUsrResults || // Results are currently visible
|
||||
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 false;
|
||||
|
@ -615,22 +614,21 @@ static void ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (const struct ExaSe
|
|||
static void ExaSes_ListOneOrMoreSessionsResult (struct Exa_Exams *Exams,
|
||||
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);
|
||||
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
ExaSes_ListOneOrMoreSessionsResultStd (Exams,Session);
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
ExaSes_ListOneOrMoreSessionsResultTch (Exams,Session);
|
||||
break;
|
||||
default:
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
if (Function[Gbl.Usrs.Me.Role.Logged])
|
||||
Function[Gbl.Usrs.Me.Role.Logged] (Exams,Session);
|
||||
else
|
||||
Err_WrongRoleExit ();
|
||||
|
||||
HTM_TD_End ();
|
||||
}
|
||||
|
@ -667,7 +665,7 @@ static void ExaSes_ListOneOrMoreSessionsResultTch (struct Exa_Exams *Exams,
|
|||
Exams->SesCod = Session->SesCod;
|
||||
|
||||
/***** Show exam session results *****/
|
||||
if (ExaSes_CheckIfICanEditThisSession (Session))
|
||||
if (ExaSes_CheckIfICanEditThisSession (Session->UsrCod))
|
||||
Lay_PutContextualLinkOnlyIcon (ActSeeUsrExaResSes,ExaRes_RESULTS_BOX_ID,
|
||||
ExaSes_PutParamsEdit,Exams,
|
||||
"trophy.svg",
|
||||
|
@ -834,7 +832,7 @@ void ExaSes_RemoveSession (void)
|
|||
ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session);
|
||||
|
||||
/***** Check if I can remove this exam session *****/
|
||||
if (!ExaSes_CheckIfICanEditThisSession (&Session))
|
||||
if (!ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove questions of exams prints, and exam prints, in this session *****/
|
||||
|
@ -880,7 +878,7 @@ void ExaSes_HideSession (void)
|
|||
ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session);
|
||||
|
||||
/***** Check if I can remove this exam session *****/
|
||||
if (!ExaSes_CheckIfICanEditThisSession (&Session))
|
||||
if (!ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Hide session *****/
|
||||
|
@ -910,7 +908,7 @@ void ExaSes_UnhideSession (void)
|
|||
ExaSes_GetAndCheckParameters (&Exams,&Exam,&Session);
|
||||
|
||||
/***** Check if I can remove this exam session *****/
|
||||
if (!ExaSes_CheckIfICanEditThisSession (&Session))
|
||||
if (!ExaSes_CheckIfICanEditThisSession (Session.UsrCod))
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Unhide session *****/
|
||||
|
|
|
@ -2586,72 +2586,34 @@ static void Fig_ShowStatOfAForumType (For_ForumType_t ForumType,
|
|||
extern const char *Txt_Institutions;
|
||||
extern const char *Txt_General;
|
||||
extern const char *Txt_only_teachers;
|
||||
|
||||
switch (ForumType)
|
||||
static const char *PlatformShortName = Cfg_PLATFORM_SHORT_NAME;
|
||||
static const char *EmptyName = "";
|
||||
static const struct
|
||||
{
|
||||
case For_FORUM_GLOBAL_USRS:
|
||||
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
|
||||
"comments.svg",FiguresForum,
|
||||
Txt_General,"");
|
||||
break;
|
||||
case For_FORUM_GLOBAL_TCHS:
|
||||
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
|
||||
"comments.svg",FiguresForum,
|
||||
Txt_General,Txt_only_teachers);
|
||||
break;
|
||||
case For_FORUM__SWAD__USRS:
|
||||
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
|
||||
"swad64x64.png",FiguresForum,
|
||||
Cfg_PLATFORM_SHORT_NAME,"");
|
||||
break;
|
||||
case For_FORUM__SWAD__TCHS:
|
||||
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
|
||||
"swad64x64.png",FiguresForum,
|
||||
Cfg_PLATFORM_SHORT_NAME,Txt_only_teachers);
|
||||
break;
|
||||
case For_FORUM_INSTIT_USRS:
|
||||
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
|
||||
"university.svg",FiguresForum,
|
||||
Txt_Institutions,"");
|
||||
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;
|
||||
}
|
||||
const char *Icon;
|
||||
const char **ForumName1;
|
||||
const char **ForumName2;
|
||||
} Params[For_NUM_TYPES_FORUM] =
|
||||
{
|
||||
[For_FORUM_COURSE_USRS] = {"chalkboard-teacher.svg",&Txt_Courses ,&EmptyName },
|
||||
[For_FORUM_COURSE_TCHS] = {"chalkboard-teacher.svg",&Txt_Courses ,&Txt_only_teachers},
|
||||
[For_FORUM_DEGREE_USRS] = {"graduation-cap.svg" ,&Txt_Degrees ,&EmptyName },
|
||||
[For_FORUM_DEGREE_TCHS] = {"graduation-cap.svg" ,&Txt_Degrees ,&Txt_only_teachers},
|
||||
[For_FORUM_CENTER_USRS] = {"building.svg" ,&Txt_Centers ,&EmptyName },
|
||||
[For_FORUM_CENTER_TCHS] = {"building.svg" ,&Txt_Centers ,&Txt_only_teachers},
|
||||
[For_FORUM_INSTIT_USRS] = {"university.svg" ,&Txt_Institutions ,&EmptyName },
|
||||
[For_FORUM_INSTIT_TCHS] = {"university.svg" ,&Txt_Institutions ,&Txt_only_teachers},
|
||||
[For_FORUM_GLOBAL_USRS] = {"comments.svg" ,&Txt_General ,&EmptyName },
|
||||
[For_FORUM_GLOBAL_TCHS] = {"comments.svg" ,&Txt_General ,&Txt_only_teachers},
|
||||
[For_FORUM__SWAD__USRS] = {"swad64x64.png" ,&PlatformShortName,&EmptyName },
|
||||
[For_FORUM__SWAD__TCHS] = {"swad64x64.png" ,&PlatformShortName,&Txt_only_teachers},
|
||||
};
|
||||
|
||||
if (Params[ForumType].Icon)
|
||||
Fig_WriteForumTitleAndStats (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,
|
||||
Params[ForumType].Icon,FiguresForum,
|
||||
*Params[ForumType].ForumName1,
|
||||
*Params[ForumType].ForumName2);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
84
swad_game.c
84
swad_game.c
|
@ -341,15 +341,13 @@ static void Gam_ListAllGames (struct Gam_Games *Games)
|
|||
|
||||
static bool Gam_CheckIfICanEditGames (void)
|
||||
{
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
static const bool ICanEditGames[Rol_NUM_ROLES] =
|
||||
{
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
[Rol_TCH ] = true,
|
||||
[Rol_SYS_ADM] = true,
|
||||
};
|
||||
|
||||
return ICanEditGames[Gbl.Usrs.Me.Role.Logged];
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -358,16 +356,14 @@ static bool Gam_CheckIfICanEditGames (void)
|
|||
|
||||
static bool Gam_CheckIfICanListGameQuestions (void)
|
||||
{
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
static const bool ICanListGameQuestions[Rol_NUM_ROLES] =
|
||||
{
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
[Rol_NET ] = true,
|
||||
[Rol_TCH ] = true,
|
||||
[Rol_SYS_ADM] = true,
|
||||
};
|
||||
|
||||
return ICanListGameQuestions[Gbl.Usrs.Me.Role.Logged];
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -376,6 +372,14 @@ static bool Gam_CheckIfICanListGameQuestions (void)
|
|||
|
||||
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)
|
||||
{
|
||||
/***** Put icon to create a new game *****/
|
||||
|
@ -383,21 +387,9 @@ static void Gam_PutIconsListGames (void *Games)
|
|||
Gam_PutIconToCreateNewGame ((struct Gam_Games *) Games);
|
||||
|
||||
/***** Put icon to view matches results *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
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;
|
||||
}
|
||||
if (NextAction[Gbl.Usrs.Me.Role.Logged])
|
||||
Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],NULL,
|
||||
NULL,NULL);
|
||||
|
||||
/***** Put icon to show a figure *****/
|
||||
Fig_PutIconToShowFigure (Fig_GAMES);
|
||||
|
@ -695,25 +687,19 @@ static void Gam_ShowOneGame (struct Gam_Games *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 *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (NextAction[Gbl.Usrs.Me.Role.Logged])
|
||||
Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],MchRes_RESULTS_BOX_ID,
|
||||
Gam_PutParams,Games);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue