mirror of https://github.com/acanas/swad-core.git
Version19.230
This commit is contained in:
parent
51dfff146b
commit
7bcc8dadc4
|
@ -548,10 +548,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 19.229.2 (2020-05-14)"
|
#define Log_PLATFORM_VERSION "SWAD 19.230 (2020-05-15)"
|
||||||
#define CSS_FILE "swad19.217.css"
|
#define CSS_FILE "swad19.217.css"
|
||||||
#define JS_FILE "swad19.223.js"
|
#define JS_FILE "swad19.223.js"
|
||||||
/*
|
/*
|
||||||
|
Version 19.230: May 15, 2020 Code refactoring and bug fixing in exams. (300984 lines)
|
||||||
Version 19.229.2: May 14, 2020 Some messages translated in exam results. (301070 lines)
|
Version 19.229.2: May 14, 2020 Some messages translated in exam results. (301070 lines)
|
||||||
Version 19.229.1: May 14, 2020 Removed unused database tables in exams.
|
Version 19.229.1: May 14, 2020 Removed unused database tables in exams.
|
||||||
Fixed bugs in exam prints. (301009 lines)
|
Fixed bugs in exam prints. (301009 lines)
|
||||||
|
|
|
@ -535,7 +535,7 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,
|
||||||
if (Exam->TimeUTC[Dat_START_TIME])
|
if (Exam->TimeUTC[Dat_START_TIME])
|
||||||
Dat_WriteLocalDateHMSFromUTC (Id,Exam->TimeUTC[StartEndTime],
|
Dat_WriteLocalDateHMSFromUTC (Id,Exam->TimeUTC[StartEndTime],
|
||||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||||
true,true,true,0x7);
|
true,true,true,0x6);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
free (Id);
|
free (Id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,17 +224,26 @@ void ExaEvt_ListEvents (struct Exa_Exams *Exams,
|
||||||
Hlp_ASSESSMENT_Exams_events,Box_NOT_CLOSABLE);
|
Hlp_ASSESSMENT_Exams_events,Box_NOT_CLOSABLE);
|
||||||
|
|
||||||
/***** Select whether show only my groups or all groups *****/
|
/***** Select whether show only my groups or all groups *****/
|
||||||
if (Gbl.Crs.Grps.NumGrps)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
Set_StartSettingsHead ();
|
case Rol_NET:
|
||||||
Grp_ShowFormToSelWhichGrps (ActSeeExa,
|
case Rol_TCH:
|
||||||
Exa_PutParams,Exams);
|
case Rol_SYS_ADM:
|
||||||
Set_EndSettingsHead ();
|
if (Gbl.Crs.Grps.NumGrps)
|
||||||
|
{
|
||||||
|
Set_StartSettingsHead ();
|
||||||
|
Grp_ShowFormToSelWhichGrps (ActSeeExa,
|
||||||
|
Exa_PutParams,Exams);
|
||||||
|
Set_EndSettingsHead ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Show the table with the events *****/
|
||||||
if (NumEvents)
|
if (NumEvents)
|
||||||
{
|
{
|
||||||
/***** Show the table with the events *****/
|
|
||||||
EvtCodToBeEdited = PutFormEvent && Event->EvtCod > 0 ? Event->EvtCod :
|
EvtCodToBeEdited = PutFormEvent && Event->EvtCod > 0 ? Event->EvtCod :
|
||||||
-1L;
|
-1L;
|
||||||
ExaEvt_ListOneOrMoreEvents (Exams,Exam,EvtCodToBeEdited,NumEvents,mysql_res);
|
ExaEvt_ListOneOrMoreEvents (Exams,Exam,EvtCodToBeEdited,NumEvents,mysql_res);
|
||||||
|
@ -321,6 +330,25 @@ void ExaEvt_GetDataOfEventByCod (struct ExaEvt_Event *Event)
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************** Check if exam event is visible and open *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool ExaEvt_CheckIfEventIsVisibleAndOpen (long EvtCod)
|
||||||
|
{
|
||||||
|
/***** Trivial check *****/
|
||||||
|
if (EvtCod < 0) // A non-existing event...
|
||||||
|
return false; // ...is not visible or open
|
||||||
|
|
||||||
|
/***** Check if exam event is visible and open from database *****/
|
||||||
|
return (DB_QueryCOUNT ("can not check if event is visible and open",
|
||||||
|
"SELECT COUNT(*) FROM exa_events"
|
||||||
|
" WHERE EvtCod=%ld"
|
||||||
|
" AND Hidden='N'" // Visible
|
||||||
|
" AND NOW() BETWEEN StartTime AND EndTime", // Open
|
||||||
|
EvtCod) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Put icons in list of events of an exam *******************/
|
/****************** Put icons in list of events of an exam *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -389,7 +417,7 @@ static void ExaEvt_ListOneOrMoreEvents (struct Exa_Exams *Exams,
|
||||||
/***** Get exam event data from row *****/
|
/***** Get exam event data from row *****/
|
||||||
ExaEvt_GetEventDataFromRow (mysql_res,&Event);
|
ExaEvt_GetEventDataFromRow (mysql_res,&Event);
|
||||||
|
|
||||||
if (ExaEvt_CheckIfICanPlayThisEventBasedOnGrps (&Event))
|
if (ExaEvt_CheckIfICanListThisEventBasedOnGrps (&Event))
|
||||||
{
|
{
|
||||||
/***** Build anchor string *****/
|
/***** Build anchor string *****/
|
||||||
if (asprintf (&Anchor,"evt_%ld_%ld",Exam->ExaCod,Event.EvtCod) < 0)
|
if (asprintf (&Anchor,"evt_%ld_%ld",Exam->ExaCod,Event.EvtCod) < 0)
|
||||||
|
@ -574,7 +602,7 @@ static void ExaEvt_ListOneOrMoreEventsTimes (const struct ExaEvt_Event *Event,un
|
||||||
Id,Color,Gbl.RowEvenOdd);
|
Id,Color,Gbl.RowEvenOdd);
|
||||||
Dat_WriteLocalDateHMSFromUTC (Id,Event->TimeUTC[StartEndTime],
|
Dat_WriteLocalDateHMSFromUTC (Id,Event->TimeUTC[StartEndTime],
|
||||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||||
true,true,true,0x7);
|
true,true,true,0x6);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
free (Id);
|
free (Id);
|
||||||
}
|
}
|
||||||
|
@ -595,17 +623,27 @@ static void ExaEvt_ListOneOrMoreEventsTitleGrps (struct Exa_Exams *Exams,
|
||||||
|
|
||||||
/***** Event title *****/
|
/***** Event title *****/
|
||||||
HTM_ARTICLE_Begin (Anchor);
|
HTM_ARTICLE_Begin (Anchor);
|
||||||
Frm_StartForm (ActSeeExaPrn);
|
if (ExaEvt_CheckIfICanAnswerThisEvent (Event))
|
||||||
Exa_PutParams (Exams);
|
{
|
||||||
ExaEvt_PutParamEvtCod (Event->EvtCod);
|
Frm_StartForm (ActSeeExaPrn);
|
||||||
HTM_BUTTON_SUBMIT_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play :
|
Exa_PutParams (Exams);
|
||||||
Txt_Resume,
|
ExaEvt_PutParamEvtCod (Event->EvtCod);
|
||||||
Event->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT":
|
HTM_BUTTON_SUBMIT_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play :
|
||||||
"BT_LINK LT ASG_TITLE",
|
Txt_Resume,
|
||||||
NULL);
|
Event->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT":
|
||||||
HTM_Txt (Event->Title);
|
"BT_LINK LT ASG_TITLE",
|
||||||
HTM_BUTTON_End ();
|
NULL);
|
||||||
Frm_EndForm ();
|
HTM_Txt (Event->Title);
|
||||||
|
HTM_BUTTON_End ();
|
||||||
|
Frm_EndForm ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HTM_SPAN_Begin ("class=\"%s\"",Event->Hidden ? "LT ASG_TITLE_LIGHT":
|
||||||
|
"LT ASG_TITLE");
|
||||||
|
HTM_Txt (Event->Title);
|
||||||
|
HTM_SPAN_End ();
|
||||||
|
}
|
||||||
HTM_ARTICLE_End ();
|
HTM_ARTICLE_End ();
|
||||||
|
|
||||||
/***** Groups whose students can answer this exam event *****/
|
/***** Groups whose students can answer this exam event *****/
|
||||||
|
@ -1152,17 +1190,17 @@ void ExaEvt_GetAndCheckParameters (struct Exa_Exams *Exams,
|
||||||
if ((Event->EvtCod = ExaEvt_GetParamEvtCod ()) <= 0)
|
if ((Event->EvtCod = ExaEvt_GetParamEvtCod ()) <= 0)
|
||||||
Lay_WrongEventExit ();
|
Lay_WrongEventExit ();
|
||||||
|
|
||||||
/***** Get exam data and event from database *****/
|
/***** Get exam data from database *****/
|
||||||
Exa_GetDataOfExamByCod (Exam);
|
Exa_GetDataOfExamByCod (Exam);
|
||||||
if (Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
if (Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||||
Lay_WrongExamExit ();
|
Lay_WrongExamExit ();
|
||||||
Exams->ExaCod = Exam->ExaCod;
|
Exams->ExaCod = Exam->ExaCod;
|
||||||
ExaEvt_GetDataOfEventByCod (Event);
|
|
||||||
|
|
||||||
/***** Ensure parameters are correct *****/
|
/***** Get set data from database *****/
|
||||||
if (Exam->ExaCod != Event->ExaCod ||
|
ExaEvt_GetDataOfEventByCod (Event);
|
||||||
Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
if (Event->ExaCod != Exam->ExaCod)
|
||||||
Lay_WrongExamExit ();
|
Lay_WrongSetExit ();
|
||||||
|
Exams->EvtCod = Event->EvtCod;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1203,8 +1241,6 @@ static void ExaEvt_PutFormEvent (const struct ExaEvt_Event *Event)
|
||||||
if (!ItsANewEvent) // Existing event
|
if (!ItsANewEvent) // Existing event
|
||||||
ExaEvt_PutParamEvtCod (Event->EvtCod);
|
ExaEvt_PutParamEvtCod (Event->EvtCod);
|
||||||
|
|
||||||
// Exa_PutParamQstInd (0); // Start by first question in exam
|
|
||||||
|
|
||||||
/***** Begin box and table *****/
|
/***** Begin box and table *****/
|
||||||
Box_BoxTableBegin (NULL,ItsANewEvent ? Txt_New_event :
|
Box_BoxTableBegin (NULL,ItsANewEvent ? Txt_New_event :
|
||||||
Event->Title,
|
Event->Title,
|
||||||
|
@ -1228,7 +1264,7 @@ static void ExaEvt_PutFormEvent (const struct ExaEvt_Event *Event)
|
||||||
|
|
||||||
/***** Start and end dates *****/
|
/***** Start and end dates *****/
|
||||||
Dat_PutFormStartEndClientLocalDateTimes (Event->TimeUTC,
|
Dat_PutFormStartEndClientLocalDateTimes (Event->TimeUTC,
|
||||||
Dat_FORM_SECONDS_ON,
|
Dat_FORM_SECONDS_OFF,
|
||||||
SetHMS);
|
SetHMS);
|
||||||
|
|
||||||
/***** Groups *****/
|
/***** Groups *****/
|
||||||
|
@ -1625,7 +1661,16 @@ unsigned ExaEvt_GetNumOpenEventsInExam (long ExaCod)
|
||||||
/********* Check if I belong to any of the groups of an exam event ***********/
|
/********* Check if I belong to any of the groups of an exam event ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool ExaEvt_CheckIfICanPlayThisEventBasedOnGrps (const struct ExaEvt_Event *Event)
|
bool ExaEvt_CheckIfICanAnswerThisEvent (const struct ExaEvt_Event *Event)
|
||||||
|
{
|
||||||
|
/***** Hidden or closed events are not accesible *****/
|
||||||
|
if (Event->Hidden || !Event->Open)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ExaEvt_CheckIfICanListThisEventBasedOnGrps (Event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ExaEvt_CheckIfICanListThisEventBasedOnGrps (const struct ExaEvt_Event *Event)
|
||||||
{
|
{
|
||||||
switch (Gbl.Usrs.Me.Role.Logged)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
|
@ -1647,8 +1692,6 @@ bool ExaEvt_CheckIfICanPlayThisEventBasedOnGrps (const struct ExaEvt_Event *Even
|
||||||
Event->EvtCod,Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
|
Event->EvtCod,Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
|
||||||
break;
|
break;
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
/***** Only if I am the creator *****/
|
|
||||||
return (Event->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -55,6 +55,7 @@ void ExaEvt_ListEvents (struct Exa_Exams *Exams,
|
||||||
struct ExaEvt_Event *Event,
|
struct ExaEvt_Event *Event,
|
||||||
bool PutFormEvent);
|
bool PutFormEvent);
|
||||||
void ExaEvt_GetDataOfEventByCod (struct ExaEvt_Event *Event);
|
void ExaEvt_GetDataOfEventByCod (struct ExaEvt_Event *Event);
|
||||||
|
bool ExaEvt_CheckIfEventIsVisibleAndOpen (long EvtCod);
|
||||||
|
|
||||||
void ExaEvt_ToggleVisibilResultsEvtUsr (void);
|
void ExaEvt_ToggleVisibilResultsEvtUsr (void);
|
||||||
|
|
||||||
|
@ -84,7 +85,8 @@ void ExaEvt_RemoveGroupsOfType (long GrpTypCod);
|
||||||
unsigned ExaEvt_GetNumEventsInExam (long ExaCod);
|
unsigned ExaEvt_GetNumEventsInExam (long ExaCod);
|
||||||
unsigned ExaEvt_GetNumOpenEventsInExam (long ExaCod);
|
unsigned ExaEvt_GetNumOpenEventsInExam (long ExaCod);
|
||||||
|
|
||||||
bool ExaEvt_CheckIfICanPlayThisEventBasedOnGrps (const struct ExaEvt_Event *Event);
|
bool ExaEvt_CheckIfICanAnswerThisEvent (const struct ExaEvt_Event *Event);
|
||||||
|
bool ExaEvt_CheckIfICanListThisEventBasedOnGrps (const struct ExaEvt_Event *Event);
|
||||||
|
|
||||||
void ExaEvt_GetQstAnsFromDB (long EvtCod,long UsrCod,unsigned QstInd,
|
void ExaEvt_GetQstAnsFromDB (long EvtCod,long UsrCod,unsigned QstInd,
|
||||||
struct ExaEvt_UsrAnswer *UsrAnswer);
|
struct ExaEvt_UsrAnswer *UsrAnswer);
|
||||||
|
|
|
@ -62,7 +62,7 @@ extern struct Globals Gbl;
|
||||||
struct ExaPrn_Print
|
struct ExaPrn_Print
|
||||||
{
|
{
|
||||||
long PrnCod; // Exam print code
|
long PrnCod; // Exam print code
|
||||||
long ExaCod; // Exam code
|
// long ExaCod; // Exam code
|
||||||
long EvtCod; // Event code associated to this print
|
long EvtCod; // Event code associated to this print
|
||||||
long UsrCod; // User who answered the exam print
|
long UsrCod; // User who answered the exam print
|
||||||
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
||||||
|
@ -90,7 +90,7 @@ static void ExaPrn_ResetPrint (struct ExaPrn_Print *Print);
|
||||||
static void ExaPrn_ResetPrintExceptEvtCodAndUsrCod (struct ExaPrn_Print *Print);
|
static void ExaPrn_ResetPrintExceptEvtCodAndUsrCod (struct ExaPrn_Print *Print);
|
||||||
|
|
||||||
static void ExaPrn_GetPrintDataByEvtCodAndUsrCod (struct ExaPrn_Print *Print);
|
static void ExaPrn_GetPrintDataByEvtCodAndUsrCod (struct ExaPrn_Print *Print);
|
||||||
static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print);
|
static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,long ExaCod);
|
||||||
static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print,
|
static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print,
|
||||||
struct ExaSet_Set *Set,
|
struct ExaSet_Set *Set,
|
||||||
unsigned *NumQstInPrint);
|
unsigned *NumQstInPrint);
|
||||||
|
@ -174,7 +174,7 @@ static void ExaPrn_ResetPrint (struct ExaPrn_Print *Print)
|
||||||
static void ExaPrn_ResetPrintExceptEvtCodAndUsrCod (struct ExaPrn_Print *Print)
|
static void ExaPrn_ResetPrintExceptEvtCodAndUsrCod (struct ExaPrn_Print *Print)
|
||||||
{
|
{
|
||||||
Print->PrnCod = -1L;
|
Print->PrnCod = -1L;
|
||||||
Print->ExaCod = -1L;
|
// Print->ExaCod = -1L;
|
||||||
Print->TimeUTC[Dat_START_TIME] =
|
Print->TimeUTC[Dat_START_TIME] =
|
||||||
Print->TimeUTC[Dat_END_TIME ] = (time_t) 0;
|
Print->TimeUTC[Dat_END_TIME ] = (time_t) 0;
|
||||||
Print->NumQsts =
|
Print->NumQsts =
|
||||||
|
@ -203,37 +203,35 @@ void ExaPrn_ShowExamPrint (void)
|
||||||
/***** Get and check parameters *****/
|
/***** Get and check parameters *****/
|
||||||
ExaEvt_GetAndCheckParameters (&Exams,&Exam,&Event);
|
ExaEvt_GetAndCheckParameters (&Exams,&Exam,&Event);
|
||||||
|
|
||||||
/***** Get print data from database *****/
|
/***** Check if I can access to this event *****/
|
||||||
Print.EvtCod = Event.EvtCod;
|
if (ExaEvt_CheckIfICanAnswerThisEvent (&Event))
|
||||||
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
|
||||||
ExaPrn_GetPrintDataByEvtCodAndUsrCod (&Print);
|
|
||||||
|
|
||||||
if (Print.PrnCod > 0) // Print exists
|
|
||||||
{
|
{
|
||||||
Ale_ShowAlert (Ale_INFO,"Examen existente.");
|
/***** Get print data from database *****/
|
||||||
|
Print.EvtCod = Event.EvtCod;
|
||||||
|
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||||
|
ExaPrn_GetPrintDataByEvtCodAndUsrCod (&Print);
|
||||||
|
|
||||||
/***** Get questions and answers from database *****/
|
if (Print.PrnCod > 0) // Print exists and I can access to it
|
||||||
ExaPrn_GetPrintQuestionsFromDB (&Print);
|
/***** Get questions and answers from database *****/
|
||||||
|
ExaPrn_GetPrintQuestionsFromDB (&Print);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/***** Get questions from database *****/
|
||||||
|
ExaPrn_GetQuestionsForNewPrintFromDB (&Print,Exam.ExaCod);
|
||||||
|
|
||||||
|
if (Print.NumQsts)
|
||||||
|
{
|
||||||
|
/***** Create/update new exam print in database *****/
|
||||||
|
ExaPrn_CreatePrintInDB (&Print);
|
||||||
|
ExaPrn_ComputeScoresAndStoreQuestionsOfPrint (&Print);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Show test exam to be answered *****/
|
||||||
|
ExaPrn_ShowExamPrintToFillIt (Exam.Title,&Print);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
Ale_ShowAlert (Ale_INFO,"Usted no tiene acceso al examen."); // TODO: Need translation!!!!
|
||||||
Ale_ShowAlert (Ale_INFO,"Examen nuevo.");
|
|
||||||
|
|
||||||
/***** Get questions from database *****/
|
|
||||||
// Print doesn't exists ==> exam code is -1 ==> so initialize it
|
|
||||||
Print.ExaCod = Exam.ExaCod;
|
|
||||||
ExaPrn_GetQuestionsForNewPrintFromDB (&Print);
|
|
||||||
|
|
||||||
if (Print.NumQsts)
|
|
||||||
{
|
|
||||||
/***** Create/update new exam print in database *****/
|
|
||||||
ExaPrn_CreatePrintInDB (&Print);
|
|
||||||
ExaPrn_ComputeScoresAndStoreQuestionsOfPrint (&Print);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Show test exam to be answered *****/
|
|
||||||
ExaPrn_ShowExamPrintToFillIt (Exam.Title,&Print);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -247,51 +245,42 @@ static void ExaPrn_GetPrintDataByEvtCodAndUsrCod (struct ExaPrn_Print *Print)
|
||||||
|
|
||||||
/***** Make database query *****/
|
/***** Make database query *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get data of an exam print",
|
if (DB_QuerySELECT (&mysql_res,"can not get data of an exam print",
|
||||||
"SELECT exa_prints.PrnCod," // row[0]
|
"SELECT PrnCod," // row[0]
|
||||||
"exa_exams.ExaCod," // row[1]
|
"UNIX_TIMESTAMP(StartTime)," // row[1]
|
||||||
"UNIX_TIMESTAMP(exa_prints.StartTime)," // row[2]
|
"UNIX_TIMESTAMP(EndTime)," // row[2]
|
||||||
"UNIX_TIMESTAMP(exa_prints.EndTime)," // row[3]
|
"NumQsts," // row[3]
|
||||||
"exa_prints.NumQsts," // row[4]
|
"NumQstsNotBlank," // row[4]
|
||||||
"exa_prints.NumQstsNotBlank," // row[5]
|
"Sent," // row[5]
|
||||||
"exa_prints.Sent," // row[6]
|
"Score" // row[6]
|
||||||
"exa_prints.Score" // row[7]
|
" FROM exa_prints"
|
||||||
" FROM exa_prints,exa_events,exa_exams"
|
" WHERE EvtCod=%ld"
|
||||||
" WHERE exa_prints.EvtCod=%ld"
|
" AND UsrCod=%ld",
|
||||||
" AND exa_prints.UsrCod=%ld" // Extra check: it belong to user
|
|
||||||
" AND exa_prints.EvtCod=exa_events.EvtCod"
|
|
||||||
" AND (NOW() BETWEEN exa_events.StartTime AND exa_events.EndTime)" // Extra check: event is open
|
|
||||||
" AND exa_events.ExaCod=exa_exams.ExaCod"
|
|
||||||
" AND exa_exams.CrsCod=%ld", // Extra check: it belong to current course
|
|
||||||
Print->EvtCod,
|
Print->EvtCod,
|
||||||
Print->UsrCod,
|
Print->UsrCod) == 1)
|
||||||
Gbl.Hierarchy.Crs.CrsCod) == 1)
|
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get print code (row[0]) */
|
/* Get print code (row[0]) */
|
||||||
Print->PrnCod = Str_ConvertStrCodToLongCod (row[0]);
|
Print->PrnCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get exam code (row[1]) */
|
/* Get date-time (row[1] and row[2] hold UTC date-time) */
|
||||||
Print->ExaCod = Str_ConvertStrCodToLongCod (row[1]);
|
Print->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[1]);
|
||||||
|
Print->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[2]);
|
||||||
|
|
||||||
/* Get date-time (row[2] and row[3] hold UTC date-time) */
|
/* Get number of questions (row[3]) */
|
||||||
Print->TimeUTC[Dat_START_TIME] = Dat_GetUNIXTimeFromStr (row[2]);
|
if (sscanf (row[3],"%u",&Print->NumQsts) != 1)
|
||||||
Print->TimeUTC[Dat_END_TIME ] = Dat_GetUNIXTimeFromStr (row[3]);
|
|
||||||
|
|
||||||
/* Get number of questions (row[4]) */
|
|
||||||
if (sscanf (row[4],"%u",&Print->NumQsts) != 1)
|
|
||||||
Print->NumQsts = 0;
|
Print->NumQsts = 0;
|
||||||
|
|
||||||
/* Get number of questions not blank (row[5]) */
|
/* Get number of questions not blank (row[4]) */
|
||||||
if (sscanf (row[5],"%u",&Print->NumQstsNotBlank) != 1)
|
if (sscanf (row[4],"%u",&Print->NumQstsNotBlank) != 1)
|
||||||
Print->NumQstsNotBlank = 0;
|
Print->NumQstsNotBlank = 0;
|
||||||
|
|
||||||
/* Get if exam has been sent (row[6]) */
|
/* Get if exam has been sent (row[5]) */
|
||||||
Print->Sent = (row[6][0] == 'Y');
|
Print->Sent = (row[5][0] == 'Y');
|
||||||
|
|
||||||
/* Get score (row[7]) */
|
/* Get score (row[6]) */
|
||||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||||
if (sscanf (row[7],"%lf",&Print->Score) != 1)
|
if (sscanf (row[6],"%lf",&Print->Score) != 1)
|
||||||
Print->Score = 0.0;
|
Print->Score = 0.0;
|
||||||
Str_SetDecimalPointToLocal (); // Return to local system
|
Str_SetDecimalPointToLocal (); // Return to local system
|
||||||
}
|
}
|
||||||
|
@ -306,7 +295,7 @@ static void ExaPrn_GetPrintDataByEvtCodAndUsrCod (struct ExaPrn_Print *Print)
|
||||||
/*********** Get questions for a new exam print from the database ************/
|
/*********** Get questions for a new exam print from the database ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print)
|
static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,long ExaCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -325,7 +314,7 @@ static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print)
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE ExaCod=%ld"
|
" WHERE ExaCod=%ld"
|
||||||
" ORDER BY SetInd",
|
" ORDER BY SetInd",
|
||||||
Print->ExaCod);
|
ExaCod);
|
||||||
|
|
||||||
/***** Get questions from all sets *****/
|
/***** Get questions from all sets *****/
|
||||||
Print->NumQsts = 0;
|
Print->NumQsts = 0;
|
||||||
|
@ -658,7 +647,7 @@ static void ExaPrn_ShowTableWithQstsToFill (struct ExaPrn_Print *Print)
|
||||||
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
Question.QstCod = Print->PrintedQuestions[NumQst].QstCod;
|
||||||
|
|
||||||
/* Show question */
|
/* Show question */
|
||||||
ExaSet_GetQstDataFromDB (&Question,Print->ExaCod);
|
ExaSet_GetQstDataFromDB (&Question);
|
||||||
|
|
||||||
/* Write question and answers */
|
/* Write question and answers */
|
||||||
ExaPrn_WriteQstAndAnsToFill (Print,NumQst,&Question);
|
ExaPrn_WriteQstAndAnsToFill (Print,NumQst,&Question);
|
||||||
|
@ -691,9 +680,7 @@ static void ExaPrn_WriteQstAndAnsToFill (struct ExaPrn_Print *Print,
|
||||||
if (Print->PrintedQuestions[NumQst].SetCod != CurrentSet.SetCod)
|
if (Print->PrintedQuestions[NumQst].SetCod != CurrentSet.SetCod)
|
||||||
{
|
{
|
||||||
/***** Get data of this set *****/
|
/***** Get data of this set *****/
|
||||||
CurrentSet.ExaCod = Print->ExaCod;
|
|
||||||
CurrentSet.SetCod = Print->PrintedQuestions[NumQst].SetCod;
|
CurrentSet.SetCod = Print->PrintedQuestions[NumQst].SetCod;
|
||||||
|
|
||||||
ExaSet_GetDataOfSetByCod (&CurrentSet);
|
ExaSet_GetDataOfSetByCod (&CurrentSet);
|
||||||
|
|
||||||
/***** Title for this set *****/
|
/***** Title for this set *****/
|
||||||
|
@ -956,30 +943,38 @@ void ExaPrn_ReceivePrintAnswer (void)
|
||||||
/***** Reset print *****/
|
/***** Reset print *****/
|
||||||
ExaPrn_ResetPrint (&Print);
|
ExaPrn_ResetPrint (&Print);
|
||||||
|
|
||||||
/***** Get and check parameters *****/
|
/***** Get event code *****/
|
||||||
Print.EvtCod = ExaEvt_GetParamEvtCod ();
|
Print.EvtCod = ExaEvt_GetParamEvtCod ();
|
||||||
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
|
||||||
ExaPrn_GetPrintDataByEvtCodAndUsrCod (&Print);
|
|
||||||
if (Print.PrnCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
|
|
||||||
/***** Get questions and answers from database *****/
|
/***** Check if event if visible and open *****/
|
||||||
ExaPrn_GetPrintQuestionsFromDB (&Print);
|
if (ExaEvt_CheckIfEventIsVisibleAndOpen (Print.EvtCod))
|
||||||
|
{
|
||||||
|
/***** Get print data *****/
|
||||||
|
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||||
|
ExaPrn_GetPrintDataByEvtCodAndUsrCod (&Print);
|
||||||
|
if (Print.PrnCod <= 0)
|
||||||
|
Lay_WrongExamExit ();
|
||||||
|
|
||||||
/***** Get answers from form to assess a test *****/
|
/***** Get questions and answers from database *****/
|
||||||
NumQst = ExaPrn_GetAnswerFromForm (&Print);
|
ExaPrn_GetPrintQuestionsFromDB (&Print);
|
||||||
|
|
||||||
/***** Update answer in database *****/
|
/***** Get answers from form to assess a test *****/
|
||||||
/* Compute question score and store in database */
|
NumQst = ExaPrn_GetAnswerFromForm (&Print);
|
||||||
ExaPrn_ComputeScoreAndStoreQuestionOfPrint (&Print,NumQst);
|
|
||||||
|
|
||||||
/* Update exam print in database */
|
/***** Update answer in database *****/
|
||||||
ExaPrn_GetNumQstsNotBlank (&Print);
|
/* Compute question score and store in database */
|
||||||
ExaPrn_ComputeTotalScoreOfPrint (&Print);
|
ExaPrn_ComputeScoreAndStoreQuestionOfPrint (&Print,NumQst);
|
||||||
ExaPrn_UpdatePrintInDB (&Print);
|
|
||||||
|
|
||||||
/***** Show table with questions to answer *****/
|
/* Update exam print in database */
|
||||||
ExaPrn_ShowTableWithQstsToFill (&Print);
|
ExaPrn_GetNumQstsNotBlank (&Print);
|
||||||
|
ExaPrn_ComputeTotalScoreOfPrint (&Print);
|
||||||
|
ExaPrn_UpdatePrintInDB (&Print);
|
||||||
|
|
||||||
|
/***** Show table with questions to answer *****/
|
||||||
|
ExaPrn_ShowTableWithQstsToFill (&Print);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Ale_ShowAlert (Ale_INFO,"Usted no tiene acceso al examen."); // TODO: Need translation!!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1444,7 +1444,7 @@ static bool ExaRes_CheckIfICanSeeEventResult (struct ExaEvt_Event *Event,long Us
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
ItsMe = Usr_ItsMe (UsrCod);
|
ItsMe = Usr_ItsMe (UsrCod);
|
||||||
if (ItsMe && Event->ShowUsrResults)
|
if (ItsMe && Event->ShowUsrResults)
|
||||||
return ExaEvt_CheckIfICanPlayThisEventBasedOnGrps (Event);
|
return ExaEvt_CheckIfICanListThisEventBasedOnGrps (Event);
|
||||||
return false;
|
return false;
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
|
|
309
swad_exam_set.c
309
swad_exam_set.c
|
@ -131,6 +131,10 @@ static void ExaSet_FreeListsSelectedQuestions (struct Exa_Exams *Exams);
|
||||||
|
|
||||||
static void ExaSet_CopyQstFromBankToExamSet (struct ExaSet_Set *Set,long QstCod);
|
static void ExaSet_CopyQstFromBankToExamSet (struct ExaSet_Set *Set,long QstCod);
|
||||||
|
|
||||||
|
static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams,
|
||||||
|
struct Exa_Exam *Exam,
|
||||||
|
struct ExaSet_Set *Set);
|
||||||
|
|
||||||
static long ExaSet_GetParamQstCod (void);
|
static long ExaSet_GetParamQstCod (void);
|
||||||
static void ExaSet_PutParamQstCod (void *QstCod); // Should be a pointer to long
|
static void ExaSet_PutParamQstCod (void *QstCod); // Should be a pointer to long
|
||||||
|
|
||||||
|
@ -208,36 +212,40 @@ void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set)
|
||||||
/***** Get data of set of questions from database *****/
|
/***** Get data of set of questions from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get set data",
|
if (DB_QuerySELECT (&mysql_res,"can not get set data",
|
||||||
"SELECT SetCod," // row[0]
|
"SELECT SetCod," // row[0]
|
||||||
"SetInd," // row[1]
|
"ExaCod," // row[1]
|
||||||
"NumQstsToPrint," // row[2]
|
"SetInd," // row[2]
|
||||||
"Title" // row[3]
|
"NumQstsToPrint," // row[3]
|
||||||
|
"Title" // row[4]
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE SetCod=%ld"
|
" WHERE SetCod=%ld",
|
||||||
" AND ExaCod=%ld", // Extra check
|
Set->SetCod)) // Set found...
|
||||||
Set->SetCod,Set->ExaCod)) // Set found...
|
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
/*
|
/*
|
||||||
row[0] SetCod
|
row[0] SetCod
|
||||||
row[1] SetInd
|
row[1] ExaCod
|
||||||
row[2] NumQstsToPrint
|
row[2] SetInd
|
||||||
row[3] Title
|
row[3] NumQstsToPrint
|
||||||
|
row[4] Title
|
||||||
*/
|
*/
|
||||||
/* Get set code (row[0]) */
|
/* Get set code (row[0]) */
|
||||||
Set->SetCod = Str_ConvertStrCodToLongCod (row[0]);
|
Set->SetCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get set index (row[1]) */
|
/* Get exam code (row[0]) */
|
||||||
Set->SetInd = Str_ConvertStrToUnsigned (row[1]);
|
Set->ExaCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
|
||||||
|
/* Get set index (row[2]) */
|
||||||
|
Set->SetInd = Str_ConvertStrToUnsigned (row[2]);
|
||||||
snprintf (StrSetInd,sizeof (Set->SetInd),
|
snprintf (StrSetInd,sizeof (Set->SetInd),
|
||||||
"%u",
|
"%u",
|
||||||
Set->SetInd);
|
Set->SetInd);
|
||||||
|
|
||||||
/* Get set index (row[2]) */
|
/* Get set index (row[3]) */
|
||||||
Set->NumQstsToPrint = Str_ConvertStrToUnsigned (row[2]);
|
Set->NumQstsToPrint = Str_ConvertStrToUnsigned (row[3]);
|
||||||
|
|
||||||
/* Get the title of the set (row[3]) */
|
/* Get the title of the set (row[4]) */
|
||||||
Str_Copy (Set->Title,row[3],
|
Str_Copy (Set->Title,row[4],
|
||||||
ExaSet_MAX_BYTES_TITLE);
|
ExaSet_MAX_BYTES_TITLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -447,21 +455,8 @@ void ExaSet_ChangeSetTitle (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Get exam and set data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Receive new title from form *****/
|
/***** Receive new title from form *****/
|
||||||
Par_GetParToText ("Title",NewTitle,ExaSet_MAX_BYTES_TITLE);
|
Par_GetParToText ("Title",NewTitle,ExaSet_MAX_BYTES_TITLE);
|
||||||
|
@ -501,21 +496,8 @@ void ExaSet_ChangeNumQstsToExam (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Get exam and set data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Get number of questions in set to appear in exam print *****/
|
/***** Get number of questions in set to appear in exam print *****/
|
||||||
NumQstsToPrint = (unsigned) Par_GetParToUnsignedLong ("NumQstsToPrint",
|
NumQstsToPrint = (unsigned) Par_GetParToUnsignedLong ("NumQstsToPrint",
|
||||||
|
@ -726,38 +708,14 @@ void ExaSet_ReqSelectQstsToAddToSet (void)
|
||||||
struct Exa_Exams Exams;
|
struct Exa_Exams Exams;
|
||||||
struct Exa_Exam Exam;
|
struct Exa_Exam Exam;
|
||||||
struct ExaSet_Set Set;
|
struct ExaSet_Set Set;
|
||||||
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
|
||||||
|
|
||||||
/***** Reset exams context *****/
|
/***** Reset exams context *****/
|
||||||
Exa_ResetExams (&Exams);
|
Exa_ResetExams (&Exams);
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Exam.ExaCod = Exams.ExaCod;
|
|
||||||
|
|
||||||
/***** Get parameters *****/
|
|
||||||
Exa_GetParams (&Exams);
|
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
Exa_GetExamTxtFromDB (Exam.ExaCod,Txt);
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Show form to select questions for set *****/
|
/***** Show form to select questions for set *****/
|
||||||
Tst_RequestSelectTestsForSet (&Exams);
|
Tst_RequestSelectTestsForSet (&Exams);
|
||||||
|
@ -776,34 +734,14 @@ void ExaSet_ListQstsToAddToSet (void)
|
||||||
struct Exa_Exams Exams;
|
struct Exa_Exams Exams;
|
||||||
struct Exa_Exam Exam;
|
struct Exa_Exam Exam;
|
||||||
struct ExaSet_Set Set;
|
struct ExaSet_Set Set;
|
||||||
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
|
||||||
|
|
||||||
/***** Reset exams context *****/
|
/***** Reset exams context *****/
|
||||||
Exa_ResetExams (&Exams);
|
Exa_ResetExams (&Exams);
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Exam.ExaCod = Exams.ExaCod;
|
|
||||||
|
|
||||||
/***** Get parameters *****/
|
|
||||||
Exa_GetParams (&Exams);
|
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
Exa_GetExamTxtFromDB (Exam.ExaCod,Txt);
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
/***** Get set data from database *****/
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
ExaSet_GetDataOfSetByCod (&Set);
|
||||||
|
@ -1368,7 +1306,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Question *****/
|
/***** Question *****/
|
||||||
ExaSet_GetQstDataFromDB (&Question,Exams->ExaCod);
|
ExaSet_GetQstDataFromDB (&Question);
|
||||||
ExaSet_ListQuestionForEdition (&Question,NumQst + 1,Anchor);
|
ExaSet_ListQuestionForEdition (&Question,NumQst + 1,Anchor);
|
||||||
|
|
||||||
/***** End row *****/
|
/***** End row *****/
|
||||||
|
@ -1417,7 +1355,7 @@ Tst_AnswerType_t ExaSet_GetQstAnswerTypeFromDB (long QstCod)
|
||||||
/*************** Get data of a question in a set from database ***************/
|
/*************** Get data of a question in a set from database ***************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void ExaSet_GetQstDataFromDB (struct Tst_Question *Question,long ExaCod)
|
void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -1432,11 +1370,8 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question,long ExaCod)
|
||||||
"Feedback," // row[3]
|
"Feedback," // row[3]
|
||||||
"MedCod" // row[4]
|
"MedCod" // row[4]
|
||||||
" FROM exa_set_questions"
|
" FROM exa_set_questions"
|
||||||
" WHERE QstCod=%ld"
|
" WHERE QstCod=%ld",
|
||||||
" AND SetCod IN"
|
Question->QstCod) != 0);
|
||||||
" (SELECT SetCod FROM exa_sets WHERE ExaCod=%ld)", // Extra check
|
|
||||||
Question->QstCod,
|
|
||||||
ExaCod) != 0);
|
|
||||||
|
|
||||||
if (QuestionExists)
|
if (QuestionExists)
|
||||||
{
|
{
|
||||||
|
@ -1622,7 +1557,6 @@ void ExaSet_AddQstsToSet (void)
|
||||||
struct Exa_Exams Exams;
|
struct Exa_Exams Exams;
|
||||||
struct Exa_Exam Exam;
|
struct Exa_Exam Exam;
|
||||||
struct ExaSet_Set Set;
|
struct ExaSet_Set Set;
|
||||||
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
|
||||||
const char *Ptr;
|
const char *Ptr;
|
||||||
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
||||||
long QstCod;
|
long QstCod;
|
||||||
|
@ -1632,27 +1566,8 @@ void ExaSet_AddQstsToSet (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Exam.ExaCod = Exams.ExaCod;
|
|
||||||
|
|
||||||
/***** Get parameters *****/
|
|
||||||
Exa_GetParams (&Exams);
|
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
Exa_GetExamTxtFromDB (Exam.ExaCod,Txt);
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
/***** Get set data from database *****/
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
ExaSet_GetDataOfSetByCod (&Set);
|
||||||
|
@ -1822,24 +1737,8 @@ void ExaSet_RequestRemoveSet (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Show question and button to remove question *****/
|
/***** Show question and button to remove question *****/
|
||||||
Ale_ShowAlertAndButton (ActRemExaSet,NULL,NULL,
|
Ale_ShowAlertAndButton (ActRemExaSet,NULL,NULL,
|
||||||
|
@ -1869,24 +1768,8 @@ void ExaSet_RemoveSet (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Remove the set from all the tables *****/
|
/***** Remove the set from all the tables *****/
|
||||||
/* Remove questions associated to set */
|
/* Remove questions associated to set */
|
||||||
|
@ -1939,24 +1822,8 @@ void ExaSet_MoveUpSet (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Get set index *****/
|
/***** Get set index *****/
|
||||||
SetIndBottom = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod);
|
SetIndBottom = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod);
|
||||||
|
@ -1999,24 +1866,8 @@ void ExaSet_MoveDownSet (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Get set index *****/
|
/***** Get set index *****/
|
||||||
SetIndTop = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod);
|
SetIndTop = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod);
|
||||||
|
@ -2061,24 +1912,8 @@ void ExaSet_RequestRemoveQstFromSet (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Get question index *****/
|
/***** Get question index *****/
|
||||||
Exams.QstCod = ExaSet_GetParamQstCod ();
|
Exams.QstCod = ExaSet_GetParamQstCod ();
|
||||||
|
@ -2118,24 +1953,8 @@ void ExaSet_RemoveQstFromSet (void)
|
||||||
Exa_ResetExam (&Exam);
|
Exa_ResetExam (&Exam);
|
||||||
ExaSet_ResetSet (&Set);
|
ExaSet_ResetSet (&Set);
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get and check parameters *****/
|
||||||
Exa_GetParams (&Exams);
|
ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set);
|
||||||
if (Exams.ExaCod <= 0)
|
|
||||||
Lay_WrongExamExit ();
|
|
||||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
|
||||||
Set.SetCod = ExaSet_GetParamSetCod ();
|
|
||||||
if (Set.SetCod <= 0)
|
|
||||||
Lay_WrongSetExit ();
|
|
||||||
|
|
||||||
/***** Get exam data from database *****/
|
|
||||||
Exa_GetDataOfExamByCod (&Exam);
|
|
||||||
Exams.ExaCod = Exam.ExaCod;
|
|
||||||
if (!Exa_CheckIfEditable (&Exam))
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
|
|
||||||
/***** Get set data from database *****/
|
|
||||||
ExaSet_GetDataOfSetByCod (&Set);
|
|
||||||
Exams.SetCod = Set.SetCod;
|
|
||||||
|
|
||||||
/***** Get question index *****/
|
/***** Get question index *****/
|
||||||
QstCod = ExaSet_GetParamQstCod ();
|
QstCod = ExaSet_GetParamQstCod ();
|
||||||
|
@ -2158,6 +1977,36 @@ void ExaSet_RemoveQstFromSet (void)
|
||||||
false); // It's not a new exam
|
false); // It's not a new exam
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************** Get and check parameters *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams,
|
||||||
|
struct Exa_Exam *Exam,
|
||||||
|
struct ExaSet_Set *Set)
|
||||||
|
{
|
||||||
|
/***** Get parameters *****/
|
||||||
|
Exa_GetParams (Exams);
|
||||||
|
if (Exams->ExaCod <= 0)
|
||||||
|
Lay_WrongExamExit ();
|
||||||
|
Exam->ExaCod = Exams->ExaCod;
|
||||||
|
Grp_GetParamWhichGroups ();
|
||||||
|
if ((Set->SetCod = ExaSet_GetParamSetCod ()) <= 0)
|
||||||
|
Lay_WrongSetExit ();
|
||||||
|
|
||||||
|
/***** Get exam data from database *****/
|
||||||
|
Exa_GetDataOfExamByCod (Exam);
|
||||||
|
if (Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||||
|
Lay_WrongExamExit ();
|
||||||
|
Exams->ExaCod = Exam->ExaCod;
|
||||||
|
|
||||||
|
/***** Get set data from database *****/
|
||||||
|
ExaSet_GetDataOfSetByCod (Set);
|
||||||
|
if (Set->ExaCod != Exam->ExaCod)
|
||||||
|
Lay_WrongSetExit ();
|
||||||
|
Exams->SetCod = Set->SetCod;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************ Get the parameter with the code of a test question *************/
|
/************ Get the parameter with the code of a test question *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -62,7 +62,7 @@ void ExaSet_ListExamSets (struct Exa_Exams *Exams,
|
||||||
void ExaSet_ResetSet (struct ExaSet_Set *Set);
|
void ExaSet_ResetSet (struct ExaSet_Set *Set);
|
||||||
|
|
||||||
Tst_AnswerType_t ExaSet_GetQstAnswerTypeFromDB (long QstCod);
|
Tst_AnswerType_t ExaSet_GetQstAnswerTypeFromDB (long QstCod);
|
||||||
void ExaSet_GetQstDataFromDB (struct Tst_Question *Question,long ExaCod);
|
void ExaSet_GetQstDataFromDB (struct Tst_Question *Question);
|
||||||
void ExaSet_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
|
void ExaSet_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
|
||||||
bool Shuffle);
|
bool Shuffle);
|
||||||
|
|
||||||
|
|
|
@ -5070,6 +5070,7 @@ Grp_WhichGroups_t Grp_GetParamWhichGroups (void)
|
||||||
case ActPrnCrsTT: // Print course timetable
|
case ActPrnCrsTT: // Print course timetable
|
||||||
case ActChgCrsTT1stDay:// Change first day of week in course timetable
|
case ActChgCrsTT1stDay:// Change first day of week in course timetable
|
||||||
case ActSeeAsg: // List assignments
|
case ActSeeAsg: // List assignments
|
||||||
|
case ActSeeAllExa: // List exams
|
||||||
case ActSeeAllGam: // List games
|
case ActSeeAllGam: // List games
|
||||||
case ActSeeAllSvy: // List surveys
|
case ActSeeAllSvy: // List surveys
|
||||||
case ActSeeAtt: // List attendance
|
case ActSeeAtt: // List attendance
|
||||||
|
|
21
swad_match.c
21
swad_match.c
|
@ -341,16 +341,25 @@ void Mch_ListMatches (struct Gam_Games *Games,
|
||||||
Hlp_ASSESSMENT_Games_matches,Box_NOT_CLOSABLE);
|
Hlp_ASSESSMENT_Games_matches,Box_NOT_CLOSABLE);
|
||||||
|
|
||||||
/***** Select whether show only my groups or all groups *****/
|
/***** Select whether show only my groups or all groups *****/
|
||||||
if (Gbl.Crs.Grps.NumGrps)
|
switch (Gbl.Usrs.Me.Role.Logged)
|
||||||
{
|
{
|
||||||
Set_StartSettingsHead ();
|
case Rol_NET:
|
||||||
Grp_ShowFormToSelWhichGrps (ActSeeGam,
|
case Rol_TCH:
|
||||||
Gam_PutParams,Games);
|
case Rol_SYS_ADM:
|
||||||
Set_EndSettingsHead ();
|
if (Gbl.Crs.Grps.NumGrps)
|
||||||
|
{
|
||||||
|
Set_StartSettingsHead ();
|
||||||
|
Grp_ShowFormToSelWhichGrps (ActSeeGam,
|
||||||
|
Gam_PutParams,Games);
|
||||||
|
Set_EndSettingsHead ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Show the table with the matches *****/
|
||||||
if (NumMatches)
|
if (NumMatches)
|
||||||
/***** Show the table with the matches *****/
|
|
||||||
Mch_ListOneOrMoreMatches (Games,Game,NumMatches,mysql_res);
|
Mch_ListOneOrMoreMatches (Games,Game,NumMatches,mysql_res);
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
|
Loading…
Reference in New Issue