Version 15.248.1

This commit is contained in:
Antonio Cañas Vargas 2016-09-07 18:02:25 +02:00
parent aff03a995e
commit ffec62f2b1
4 changed files with 60 additions and 45 deletions

View File

@ -711,7 +711,7 @@ static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query)
/* Get code of the assignment (row[0]) */
Asg->AsgCod = Str_ConvertStrCodToLongCod (row[0]);
/* Get wether the assignment is hidden or not (row[1]) */
/* Get whether the assignment is hidden or not (row[1]) */
Asg->Hidden = (Str_ConvertToUpperLetter (row[1][0]) == 'Y');
/* Get author of the assignment (row[2]) */

View File

@ -746,7 +746,7 @@ bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att)
/* Get code of the course (row[1]) */
Att->CrsCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get wether the attendance event is hidden or not (row[2]) */
/* Get whether the attendance event is hidden or not (row[2]) */
Att->Hidden = (Str_ConvertToUpperLetter (row[2][0]) == 'Y');
/* Get author of the attendance event (row[3]) */
@ -1248,77 +1248,78 @@ void Att_RecFormAttEvent (void)
extern const char *Txt_Created_new_event_X;
extern const char *Txt_The_event_has_been_modified;
struct AttendanceEvent OldAtt;
struct AttendanceEvent NewAtt;
struct AttendanceEvent ReceivedAtt;
char YN[1+1];
bool ItsANewAttEvent;
bool NewAttEventIsCorrect = true;
bool ReceivedAttEventIsCorrect = true;
char Txt[Cns_MAX_BYTES_TEXT+1];
/***** Get the code of the attendance event *****/
ItsANewAttEvent = ((NewAtt.AttCod = Att_GetParamAttCod ()) == -1L);
ItsANewAttEvent = ((ReceivedAtt.AttCod = Att_GetParamAttCod ()) == -1L);
if (!ItsANewAttEvent)
{
/* Get data of the old (current) attendance event from database */
OldAtt.AttCod = NewAtt.AttCod;
OldAtt.AttCod = ReceivedAtt.AttCod;
Att_GetDataOfAttEventByCodAndCheckCrs (&OldAtt);
}
/***** Get start/end date-times *****/
NewAtt.TimeUTC[Att_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
NewAtt.TimeUTC[Att_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
ReceivedAtt.TimeUTC[Att_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
ReceivedAtt.TimeUTC[Att_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
/***** Get boolean parameter that indicates if teacher's comments are visible by students *****/
Par_GetParToText ("CommentTchVisible",YN,1);
NewAtt.CommentTchVisible = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
ReceivedAtt.CommentTchVisible = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
/***** Get attendance event title *****/
Par_GetParToText ("Title",NewAtt.Title,Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
Par_GetParToText ("Title",ReceivedAtt.Title,Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
/***** Get attendance event text *****/
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
/***** Adjust dates *****/
if (NewAtt.TimeUTC[Att_START_TIME] == 0)
NewAtt.TimeUTC[Att_START_TIME] = Gbl.StartExecutionTimeUTC;
if (NewAtt.TimeUTC[Att_END_TIME] == 0)
NewAtt.TimeUTC[Att_END_TIME] = NewAtt.TimeUTC[Att_START_TIME] + 2*60*60; // +2 hours
if (ReceivedAtt.TimeUTC[Att_START_TIME] == 0)
ReceivedAtt.TimeUTC[Att_START_TIME] = Gbl.StartExecutionTimeUTC;
if (ReceivedAtt.TimeUTC[Att_END_TIME] == 0)
ReceivedAtt.TimeUTC[Att_END_TIME] = ReceivedAtt.TimeUTC[Att_START_TIME] + 2*60*60; // +2 hours // TODO: 2*60*60 should be in a #define in swad_config.h
/***** Check if title is correct *****/
if (NewAtt.Title[0]) // If there's an attendance event title
if (ReceivedAtt.Title[0]) // If there's an attendance event title
{
/* If title of attendance event was in database... */
if (Att_CheckIfSimilarAttEventExists ("Title",NewAtt.Title,NewAtt.AttCod))
if (Att_CheckIfSimilarAttEventExists ("Title",ReceivedAtt.Title,ReceivedAtt.AttCod))
{
NewAttEventIsCorrect = false;
ReceivedAttEventIsCorrect = false;
sprintf (Gbl.Message,Txt_Already_existed_an_event_with_the_title_X,
NewAtt.Title);
ReceivedAtt.Title);
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
}
}
else // If there is not an attendance event title
{
NewAttEventIsCorrect = false;
ReceivedAttEventIsCorrect = false;
Lay_ShowAlert (Lay_WARNING,Txt_You_must_specify_the_title_of_the_event);
}
/***** Create a new attendance event or update an existing one *****/
if (NewAttEventIsCorrect)
if (ReceivedAttEventIsCorrect)
{
/* Get groups for this attendance events */
Grp_GetParCodsSeveralGrpsToEditAsgAttOrSvy ();
if (ItsANewAttEvent)
{
Att_CreateAttEvent (&NewAtt,Txt); // Add new attendance event to database
ReceivedAtt.Hidden = false; // New attendance events are visible by default
Att_CreateAttEvent (&ReceivedAtt,Txt); // Add new attendance event to database
/***** Write success message *****/
sprintf (Gbl.Message,Txt_Created_new_event_X,NewAtt.Title);
sprintf (Gbl.Message,Txt_Created_new_event_X,ReceivedAtt.Title);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
}
else
{
Att_UpdateAttEvent (&NewAtt,Txt);
Att_UpdateAttEvent (&ReceivedAtt,Txt);
/***** Write success message *****/
Lay_ShowAlert (Lay_SUCCESS,Txt_The_event_has_been_modified);
@ -1344,11 +1345,14 @@ void Att_CreateAttEvent (struct AttendanceEvent *Att,const char *Txt)
/***** Create a new attendance event *****/
sprintf (Query,"INSERT INTO att_events"
" (CrsCod,UsrCod,StartTime,EndTime,CommentTchVisible,Title,Txt)"
" VALUES ('%ld','%ld',"
" (CrsCod,Hidden,UsrCod,"
"StartTime,EndTime,CommentTchVisible,Title,Txt)"
" VALUES ('%ld','%c','%ld',"
"FROM_UNIXTIME('%ld'),FROM_UNIXTIME('%ld'),"
"'%c','%s','%s')",
Gbl.CurrentCrs.Crs.CrsCod,
Att->Hidden ? 'Y' :
'N',
Gbl.Usrs.Me.UsrDat.UsrCod,
Att->TimeUTC[Att_START_TIME],
Att->TimeUTC[Att_END_TIME ],
@ -1418,7 +1422,8 @@ bool Att_CheckIfAttEventIsAssociatedToGrp (long AttCod,long GrpCod)
char Query[512];
/***** Get if an attendance event is associated to a group from database *****/
sprintf (Query,"SELECT COUNT(*) FROM att_grp WHERE AttCod='%ld' AND GrpCod='%ld'",
sprintf (Query,"SELECT COUNT(*) FROM att_grp"
" WHERE AttCod='%ld' AND GrpCod='%ld'",
AttCod,GrpCod);
return (DB_QueryCOUNT (Query,"can not check if an attendance event is associated to a group") != 0);
}

View File

@ -135,13 +135,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.248 (2016-09-06)"
#define Log_PLATFORM_VERSION "SWAD 15.248.1 (2016-09-07)"
#define CSS_FILE "swad15.229.css"
#define JS_FILE "swad15.238.1.js"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
Version 15.248.1: Sep 07, 2016 Fix bugs related to hidden attendance events, reported by Rubén Martín Hidalgo. (204200 lines)
Version 15.248: Sep 06, 2016 New web service function removeAttendanceEvent. (204186 lines)
Version 15.247.2: Jul 30, 2016 Fixed bug in listings of users, reported by José Abraham Mora Sánchez. (204104 lines)
Version 15.247.1: Jul 27, 2016 In listings of users ready for printing, show institution name instead of logo. (204102 lines)

View File

@ -2117,10 +2117,11 @@ int swad__getAttendanceEvents (struct soap *soap,
/***** Query list of attendance events *****/
sprintf (Query,"SELECT AttCod,UsrCod,"
"UNIX_TIMESTAMP(StartTime) AS ST,UNIX_TIMESTAMP(EndTime) AS ET,"
"UNIX_TIMESTAMP(StartTime) AS ST,"
"UNIX_TIMESTAMP(EndTime) AS ET,"
"CommentTchVisible,Title,Txt"
" FROM att_events"
" WHERE CrsCod='%d' AND Hidden='N'"
" WHERE CrsCod='%d'"
" ORDER BY ST DESC,ET DESC,Title DESC",
courseCode);
getAttendanceEventsOut->eventsArray.__size =
@ -2143,8 +2144,12 @@ int swad__getAttendanceEvents (struct soap *soap,
AttCod = Str_ConvertStrCodToLongCod (row[0]);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].attendanceEventCode = (int) AttCod;
/* Get user's code of the user who created the event (row[1]) */
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[1]);
/* Get whether the attendance event is hidden or not (row[1]) */
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].hidden = (row[1][0] == 'Y') ? 1 :
0;
/* Get user's code of the user who created the event (row[2]) */
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[2]);
if (Svc_GetSomeUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Gbl.CurrentCrs.Crs.CrsCod)) // Get some user's data from database
{
Length = strlen (Gbl.Usrs.Other.UsrDat.Surname1);
@ -2176,33 +2181,33 @@ int swad__getAttendanceEvents (struct soap *soap,
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].userPhoto = NULL;
}
/* Get event start time (row[2]) */
/* Get event start time (row[3]) */
StartTime = 0L;
if (row[2])
sscanf (row[2],"%ld",&StartTime);
if (row[3])
sscanf (row[3],"%ld",&StartTime);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].startTime = StartTime;
/* Get event end time (row[3]) */
/* Get event end time (row[4]) */
EndTime = 0L;
if (row[3])
sscanf (row[3],"%ld",&EndTime);
if (row[4])
sscanf (row[4],"%ld",&EndTime);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].endTime = EndTime;
/* Get whether teachers comments are visible ('Y') or hidden ('N') (row[4]) */
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].commentsTeachersVisible = (row[4][0] == 'Y') ? 1 :
/* Get whether teachers comments are visible ('Y') or hidden ('N') (row[5]) */
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].commentsTeachersVisible = (row[5][0] == 'Y') ? 1 :
0;
/* Get title of the event (row[5]) */
Length = strlen (row[5]);
/* Get title of the event (row[6]) */
Length = strlen (row[6]);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title = (char *) soap_malloc (Gbl.soap,Length + 1);
strcpy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].title,
row[5]);
row[6]);
/* Get Txt (row[6]) */
Length = strlen (row[6]);
/* Get Txt (row[7]) */
Length = strlen (row[7]);
getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text = (char *) soap_malloc (Gbl.soap,Length + 1);
strcpy (getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].text,
row[6]);
row[7]);
/* Get list of groups for this attendance event */
Svc_GetListGrpsInAttendanceEventFromDB (AttCod,&(getAttendanceEventsOut->eventsArray.__ptr[NumAttEvent].groups));
@ -2344,6 +2349,10 @@ int swad__sendAttendanceEvent (struct soap *soap,
false);
/* Title */
if (!title[0])
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
"Title of attendance event is empty");
strncpy (Att.Title,title,Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
Att.Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE] = '\0';