Version19.214.1

This commit is contained in:
acanas 2020-05-07 01:14:50 +02:00
parent 8a3c93c948
commit 7d177fbf05
6 changed files with 121 additions and 91 deletions

View File

@ -753,11 +753,14 @@ void Asg_GetDataOfAssignmentByCod (struct Asg_Assignment *Asg)
{ {
/***** Build query *****/ /***** Build query *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data", NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data",
"SELECT AsgCod,Hidden,UsrCod," "SELECT AsgCod," // row[0]
"UNIX_TIMESTAMP(StartTime)," "Hidden," // row[1]
"UNIX_TIMESTAMP(EndTime)," "UsrCod," // row[2]
"NOW() BETWEEN StartTime AND EndTime," "UNIX_TIMESTAMP(StartTime)," // row[3]
"Title,Folder" "UNIX_TIMESTAMP(EndTime)," // row[4]
"NOW() BETWEEN StartTime AND EndTime," // row[5]
"Title," // row[6]
"Folder" // row[7]
" FROM assignments" " FROM assignments"
" WHERE AsgCod=%ld AND CrsCod=%ld", " WHERE AsgCod=%ld AND CrsCod=%ld",
Asg->AsgCod,Gbl.Hierarchy.Crs.CrsCod); Asg->AsgCod,Gbl.Hierarchy.Crs.CrsCod);
@ -786,11 +789,14 @@ void Asg_GetDataOfAssignmentByFolder (struct Asg_Assignment *Asg)
{ {
/***** Query database *****/ /***** Query database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data", NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment data",
"SELECT AsgCod,Hidden,UsrCod," "SELECT AsgCod," // row[0]
"UNIX_TIMESTAMP(StartTime)," "Hidden," // row[1]
"UNIX_TIMESTAMP(EndTime)," "UsrCod," // row[2]
"NOW() BETWEEN StartTime AND EndTime," "UNIX_TIMESTAMP(StartTime)," // row[3]
"Title,Folder" "UNIX_TIMESTAMP(EndTime)," // row[4]
"NOW() BETWEEN StartTime AND EndTime," // row[5]
"Title," // row[6]
"Folder" // row[7]
" FROM assignments" " FROM assignments"
" WHERE CrsCod=%ld AND Folder='%s'", " WHERE CrsCod=%ld AND Folder='%s'",
Gbl.Hierarchy.Crs.CrsCod,Asg->Folder); Gbl.Hierarchy.Crs.CrsCod,Asg->Folder);
@ -824,6 +830,16 @@ static void Asg_GetDataOfAssignment (struct Asg_Assignment *Asg,
{ {
/* Get row */ /* Get row */
row = mysql_fetch_row (*mysql_res); row = mysql_fetch_row (*mysql_res);
/*
row[0] AsgCod
row[1] Hidden
row[2] UsrCod
row[3] UNIX_TIMESTAMP(StartTime)
row[4] UNIX_TIMESTAMP(EndTime)
row[5] NOW() BETWEEN StartTime AND EndTime
row[6] Title
row[7] Folder
*/
/* Get code of the assignment (row[0]) */ /* Get code of the assignment (row[0]) */
Asg->AsgCod = Str_ConvertStrCodToLongCod (row[0]); Asg->AsgCod = Str_ConvertStrCodToLongCod (row[0]);

View File

@ -548,12 +548,12 @@ 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.214 (2020-05-06)" #define Log_PLATFORM_VERSION "SWAD 19.214.1 (2020-05-07)"
#define CSS_FILE "swad19.193.1.css" #define CSS_FILE "swad19.193.1.css"
#define JS_FILE "swad19.193.1.js" #define JS_FILE "swad19.193.1.js"
/* /*
Version 19.214.1: May 06, 2020 Change color of dates on current exam event. (? lines) Version 19.214.1: May 07, 2020 Change color of dates on current exam event. (301597 lines)
Version 19.214: May 05, 2020 New API function getLocations. (301568 lines) Version 19.214: May 06, 2020 New API function getLocations. (301568 lines)
1 change necessary in database: 1 change necessary in database:
CREATE TABLE IF NOT EXISTS room_MAC (RooCod INT NOT NULL AUTO_INCREMENT,MAC BIGINT NOT NULL,UNIQUE INDEX(RooCod,MAC),UNIQUE INDEX(MAC,RooCod)); CREATE TABLE IF NOT EXISTS room_MAC (RooCod INT NOT NULL AUTO_INCREMENT,MAC BIGINT NOT NULL,UNIQUE INDEX(RooCod,MAC),UNIQUE INDEX(MAC,RooCod));
If you want to use MyISAM: If you want to use MyISAM:

View File

@ -257,7 +257,7 @@ void Exa_ResetExam (struct Exa_Exam *Exam)
Exam->NumSets = 0; Exam->NumSets = 0;
Exam->NumQsts = 0; Exam->NumQsts = 0;
Exam->NumEvts = 0; Exam->NumEvts = 0;
Exam->NumUnfinishedEvts = 0; Exam->NumOpenEvts = 0;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -555,7 +555,7 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,
struct Exa_Exam *Exam,bool ShowOnlyThisExam) struct Exa_Exam *Exam,bool ShowOnlyThisExam)
{ {
extern const char *Txt_View_exam; extern const char *Txt_View_exam;
extern const char *Txt_Set_of_questions; extern const char *Txt_Sets_of_questions;
extern const char *Txt_Maximum_grade; extern const char *Txt_Maximum_grade;
extern const char *Txt_Result_visibility; extern const char *Txt_Result_visibility;
extern const char *Txt_Events; extern const char *Txt_Events;
@ -598,10 +598,10 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,
{ {
if (asprintf (&Id,"exa_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) if (asprintf (&Id,"exa_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
Color = Exam->NumUnfinishedEvts ? (Exam->Hidden ? "DATE_GREEN_LIGHT": Color = Exam->NumOpenEvts ? (Exam->Hidden ? "DATE_GREEN_LIGHT":
"DATE_GREEN") : "DATE_GREEN") :
(Exam->Hidden ? "DATE_RED_LIGHT": (Exam->Hidden ? "DATE_RED_LIGHT":
"DATE_RED"); "DATE_RED");
if (ShowOnlyThisExam) if (ShowOnlyThisExam)
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"", HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
Id,Color); Id,Color);
@ -639,7 +639,7 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,
/* Number of questions, maximum grade, visibility of results */ /* Number of questions, maximum grade, visibility of results */
HTM_DIV_Begin ("class=\"%s\"",Exam->Hidden ? "ASG_GRP_LIGHT" : HTM_DIV_Begin ("class=\"%s\"",Exam->Hidden ? "ASG_GRP_LIGHT" :
"ASG_GRP"); "ASG_GRP");
HTM_TxtColonNBSP (Txt_Set_of_questions); HTM_TxtColonNBSP (Txt_Sets_of_questions);
HTM_Unsigned (Exam->NumSets); HTM_Unsigned (Exam->NumSets);
HTM_BR (); HTM_BR ();
HTM_TxtColonNBSP (Txt_Maximum_grade); HTM_TxtColonNBSP (Txt_Maximum_grade);
@ -1188,8 +1188,8 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
/* Get number of events */ /* Get number of events */
Exam->NumEvts = ExaEvt_GetNumEventsInExam (Exam->ExaCod); Exam->NumEvts = ExaEvt_GetNumEventsInExam (Exam->ExaCod);
/* Get number of unfinished events */ /* Get number of open events */
Exam->NumUnfinishedEvts = ExaEvt_GetNumUnfinishedEventsInExam (Exam->ExaCod); Exam->NumOpenEvts = ExaEvt_GetNumOpenEventsInExam (Exam->ExaCod);
} }
else else
/* Initialize to empty exam */ /* Initialize to empty exam */

View File

@ -273,6 +273,7 @@ void ExaEvt_ResetEvent (struct ExaEvt_Event *Event)
Event->TimeUTC[StartEndTime] = (time_t) 0; Event->TimeUTC[StartEndTime] = (time_t) 0;
Event->Title[0] = '\0'; Event->Title[0] = '\0';
Event->Hidden = false; Event->Hidden = false;
Event->Open = false;
Event->Status.QstInd = 0; Event->Status.QstInd = 0;
Event->Status.QstCod = -1L; Event->Status.QstCod = -1L;
Event->Status.QstStartTimeUTC = (time_t) 0; Event->Status.QstStartTimeUTC = (time_t) 0;
@ -323,26 +324,28 @@ void ExaEvt_ListEvents (struct Exa_Exams *Exams,
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
/* Make query */ /* Make query */
NumEvents = (unsigned) DB_QuerySELECT (&mysql_res,"can not get events", NumEvents = (unsigned)
"SELECT EvtCod," // row[ 0] DB_QuerySELECT (&mysql_res,"can not get events",
"ExaCod," // row[ 1] "SELECT EvtCod," // row[ 0]
"Hidden," // row[ 2] "ExaCod," // row[ 1]
"UsrCod," // row[ 3] "Hidden," // row[ 2]
"UNIX_TIMESTAMP(StartTime)," // row[ 4] "UsrCod," // row[ 3]
"UNIX_TIMESTAMP(EndTime)," // row[ 5] "UNIX_TIMESTAMP(StartTime)," // row[ 4]
"Title," // row[ 6] "UNIX_TIMESTAMP(EndTime)," // row[ 5]
"QstInd," // row[ 7] "NOW() BETWEEN StartTime AND EndTime," // row[ 6]
"QstCod," // row[ 8] "Title," // row[ 7]
"Showing," // row[ 9] "QstInd," // row[ 8]
"Countdown," // row[10] "QstCod," // row[ 9]
"NumCols," // row[11] "Showing," // row[10]
"ShowQstResults," // row[12] "Countdown," // row[11]
"ShowUsrResults" // row[13] "NumCols," // row[12]
" FROM exa_events" "ShowQstResults," // row[13]
" WHERE ExaCod=%ld%s" "ShowUsrResults" // row[14]
" ORDER BY EvtCod", " FROM exa_events"
Exam->ExaCod, " WHERE ExaCod=%ld%s"
SubQuery); " ORDER BY EvtCod",
Exam->ExaCod,
SubQuery);
/* Free allocated memory for subquery */ /* Free allocated memory for subquery */
free (SubQuery); free (SubQuery);
@ -424,20 +427,21 @@ void ExaEvt_GetDataOfEventByCod (struct ExaEvt_Event *Event)
/***** Get exam data event from database *****/ /***** Get exam data event from database *****/
NumRows = (unsigned) NumRows = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get events", DB_QuerySELECT (&mysql_res,"can not get events",
"SELECT EvtCod," // row[ 0] "SELECT EvtCod," // row[ 0]
"ExaCod," // row[ 1] "ExaCod," // row[ 1]
"Hidden," // row[ 2] "Hidden," // row[ 2]
"UsrCod," // row[ 3] "UsrCod," // row[ 3]
"UNIX_TIMESTAMP(StartTime),"// row[ 4] "UNIX_TIMESTAMP(StartTime)," // row[ 4]
"UNIX_TIMESTAMP(EndTime)," // row[ 5] "UNIX_TIMESTAMP(EndTime)," // row[ 5]
"Title," // row[ 6] "NOW() BETWEEN StartTime AND EndTime," // row[ 6]
"QstInd," // row[ 7] "Title," // row[ 7]
"QstCod," // row[ 8] "QstInd," // row[ 8]
"Showing," // row[ 9] "QstCod," // row[ 9]
"Countdown," // row[10] "Showing," // row[10]
"NumCols," // row[11] "Countdown," // row[11]
"ShowQstResults," // row[12] "NumCols," // row[12]
"ShowUsrResults" // row[13] "ShowQstResults," // row[13]
"ShowUsrResults" // row[14]
" FROM exa_events" " FROM exa_events"
" WHERE EvtCod=%ld" " WHERE EvtCod=%ld"
" AND ExaCod IN" // Extra check " AND ExaCod IN" // Extra check
@ -708,12 +712,10 @@ static void ExaEvt_ListOneOrMoreEventsTimes (const struct ExaEvt_Event *Event,un
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1); StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
StartEndTime++) StartEndTime++)
{ {
Color = Event->Status.Showing == ExaEvt_END ? (Event->Hidden ? "DATE_GREEN_LIGHT": Color = Event->Open ? (Event->Hidden ? "DATE_GREEN_LIGHT":
"DATE_GREEN") : "DATE_GREEN") :
(Event->Hidden ? "DATE_RED_LIGHT": (Event->Hidden ? "DATE_RED_LIGHT":
"DATE_RED"); "DATE_RED");
if (asprintf (&Id,"exa_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) if (asprintf (&Id,"exa_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
@ -1009,7 +1011,8 @@ static void ExaEvt_GetEventDataFromRow (MYSQL_RES *mysql_res,
row[ 3] UsrCod row[ 3] UsrCod
row[ 4] UNIX_TIMESTAMP(StartTime) row[ 4] UNIX_TIMESTAMP(StartTime)
row[ 5] UNIX_TIMESTAMP(EndTime) row[ 5] UNIX_TIMESTAMP(EndTime)
row[ 6] Title row[ 6] Open = NOW() BETWEEN StartTime AND EndTime
row[ 7] Title
*/ */
/***** Get event data *****/ /***** Get event data *****/
/* Code of the event (row[0]) */ /* Code of the event (row[0]) */
@ -1032,22 +1035,25 @@ static void ExaEvt_GetEventDataFromRow (MYSQL_RES *mysql_res,
StartEndTime++) StartEndTime++)
Event->TimeUTC[StartEndTime] = Dat_GetUNIXTimeFromStr (row[4 + StartEndTime]); Event->TimeUTC[StartEndTime] = Dat_GetUNIXTimeFromStr (row[4 + StartEndTime]);
/* Get the title of the event (row[6]) */ /* Get whether the event is open or closed (row(6)) */
if (row[6]) Event->Open = (row[6][0] == '1');
Str_Copy (Event->Title,row[6],
/* Get the title of the event (row[7]) */
if (row[7])
Str_Copy (Event->Title,row[7],
ExaEvt_MAX_BYTES_TITLE); ExaEvt_MAX_BYTES_TITLE);
else else
Event->Title[0] = '\0'; Event->Title[0] = '\0';
/***** Get current event status *****/ /***** Get current event status *****/
/* /*
row[ 7] QstInd row[ 8] QstInd
row[ 8] QstCod row[ 9] QstCod
row[ 9] Showing row[10] Showing
row[10] Countdown row[11] Countdown
row[11] NumCols row[12] NumCols
row[12] ShowQstResults row[13] ShowQstResults
row[13] ShowUsrResults row[14] ShowUsrResults
*/ */
/* Current question index (row[7]) */ /* Current question index (row[7]) */
Event->Status.QstInd = Str_ConvertStrToUnsigned (row[7]); Event->Status.QstInd = Str_ConvertStrToUnsigned (row[7]);
@ -1055,23 +1061,23 @@ static void ExaEvt_GetEventDataFromRow (MYSQL_RES *mysql_res,
/* Current question code (row[8]) */ /* Current question code (row[8]) */
Event->Status.QstCod = Str_ConvertStrCodToLongCod (row[8]); Event->Status.QstCod = Str_ConvertStrCodToLongCod (row[8]);
/* Get what to show (stem, answers, results) (row(9)) */ /* Get what to show (stem, answers, results) (row(10)) */
Event->Status.Showing = ExaEvt_GetShowingFromStr (row[9]); Event->Status.Showing = ExaEvt_GetShowingFromStr (row[10]);
/* Get countdown (row[10]) */ /* Get countdown (row[11]) */
Event->Status.Countdown = Str_ConvertStrCodToLongCod (row[10]); Event->Status.Countdown = Str_ConvertStrCodToLongCod (row[11]);
/* Get number of columns (row[11]) */ /* Get number of columns (row[12]) */
LongNum = Str_ConvertStrCodToLongCod (row[11]); LongNum = Str_ConvertStrCodToLongCod (row[12]);
Event->Status.NumCols = (LongNum <= 1 ) ? 1 : Event->Status.NumCols = (LongNum <= 1 ) ? 1 :
((LongNum >= ExaEvt_MAX_COLS) ? ExaEvt_MAX_COLS : ((LongNum >= ExaEvt_MAX_COLS) ? ExaEvt_MAX_COLS :
(unsigned) LongNum); (unsigned) LongNum);
/* Get whether to show question results or not (row(12)) */ /* Get whether to show question results or not (row(13)) */
Event->Status.ShowQstResults = (row[12][0] == 'Y'); Event->Status.ShowQstResults = (row[13][0] == 'Y');
/* Get whether to show user results or not (row(13)) */ /* Get whether to show user results or not (row(14)) */
Event->Status.ShowUsrResults = (row[13][0] == 'Y'); Event->Status.ShowUsrResults = (row[14][0] == 'Y');
/***** Get whether the exam event is being played or not *****/ /***** Get whether the exam event is being played or not *****/
if (Event->Status.Showing == ExaEvt_END) // Event over if (Event->Status.Showing == ExaEvt_END) // Event over
@ -1161,6 +1167,9 @@ void ExaEvt_RemoveEvent (void)
Ale_ShowAlert (Ale_SUCCESS,Txt_Event_X_removed, Ale_ShowAlert (Ale_SUCCESS,Txt_Event_X_removed,
Event.Title); Event.Title);
/***** Get exam data again to update it after changes in event *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Show current exam *****/ /***** Show current exam *****/
Exa_ShowOnlyOneExam (&Exams,&Exam,&Event, Exa_ShowOnlyOneExam (&Exams,&Exam,&Event,
false); // Do not put form for event false); // Do not put form for event
@ -1717,6 +1726,9 @@ void ExaEvt_ReceiveFormEvent (void)
else else
Ale_ShowAlert (Ale_SUCCESS,Txt_The_event_has_been_modified); Ale_ShowAlert (Ale_SUCCESS,Txt_The_event_has_been_modified);
/***** Get exam data again to update it after changes in event *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Show current exam *****/ /***** Show current exam *****/
Exa_ShowOnlyOneExam (&Exams,&Exam,&Event, Exa_ShowOnlyOneExam (&Exams,&Exam,&Event,
false); // Do not put form for event false); // Do not put form for event
@ -2562,21 +2574,22 @@ unsigned ExaEvt_GetNumEventsInExam (long ExaCod)
} }
/*****************************************************************************/ /*****************************************************************************/
/*************** Get number of unfinished events in an exam ******************/ /****************** Get number of open events in an exam *********************/
/*****************************************************************************/ /*****************************************************************************/
unsigned ExaEvt_GetNumUnfinishedEventsInExam (long ExaCod) unsigned ExaEvt_GetNumOpenEventsInExam (long ExaCod)
{ {
/***** Trivial check *****/ /***** Trivial check *****/
if (ExaCod < 0) // A non-existing exam... if (ExaCod < 0) // A non-existing exam...
return 0; // ...has no events return 0; // ...has no events
/***** Get number of events in an exam from database *****/ /***** Get number of open events in an exam from database *****/
return return
(unsigned) DB_QueryCOUNT ("can not get number of unfinished events of an exam", (unsigned) DB_QueryCOUNT ("can not get number of open events of an exam",
"SELECT COUNT(*) FROM exa_events" "SELECT COUNT(*) FROM exa_events"
" WHERE ExaCod=%ld AND Showing<>'%s'", " WHERE ExaCod=%ld"
ExaCod,ExaEvt_ShowingStringsDB[ExaEvt_END]); " AND NOW() BETWEEN StartTime AND EndTime",
ExaCod);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -93,7 +93,7 @@ void ExaEvt_BackEvent (void);
void ExaEvt_ForwardEvent (void); void ExaEvt_ForwardEvent (void);
unsigned ExaEvt_GetNumEventsInExam (long ExaCod); unsigned ExaEvt_GetNumEventsInExam (long ExaCod);
unsigned ExaEvt_GetNumUnfinishedEventsInExam (long ExaCod); unsigned ExaEvt_GetNumOpenEventsInExam (long ExaCod);
bool ExaEvt_CheckIfICanPlayThisEventBasedOnGrps (const struct ExaEvt_Event *Event); bool ExaEvt_CheckIfICanPlayThisEventBasedOnGrps (const struct ExaEvt_Event *Event);

View File

@ -96,7 +96,7 @@ struct Exa_Exam
unsigned NumSets; // Number of sets in the exam unsigned NumSets; // Number of sets in the exam
unsigned NumQsts; // Number of questions in the exam unsigned NumQsts; // Number of questions in the exam
unsigned NumEvts; // Number of events in the exam unsigned NumEvts; // Number of events in the exam
unsigned NumUnfinishedEvts; // Number of unfinished events in the exam unsigned NumOpenEvts; // Number of open events in the exam
}; };
struct ExaSet_Set struct ExaSet_Set
@ -127,6 +127,7 @@ struct ExaEvt_Event
time_t TimeUTC[Dat_NUM_START_END_TIME]; time_t TimeUTC[Dat_NUM_START_END_TIME];
char Title[ExaEvt_MAX_BYTES_TITLE + 1]; char Title[ExaEvt_MAX_BYTES_TITLE + 1];
bool Hidden; bool Hidden;
bool Open; // If now is between start and end dates
struct struct
{ {
unsigned QstInd; // 0 means that the exam has not started. First question has index 1. unsigned QstInd; // 0 means that the exam has not started. First question has index 1.