mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-09 02:05:24 +02:00
Version 15.19
This commit is contained in:
parent
26baa58280
commit
1221d128f8
|
@ -688,7 +688,7 @@ static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query)
|
||||||
/* Get start date (row[3] holds the start UTC time) */
|
/* Get start date (row[3] holds the start UTC time) */
|
||||||
Asg->TimeUTC[Asg_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]);
|
Asg->TimeUTC[Asg_START_TIME] = Dat_GetUNIXTimeFromStr (row[3]);
|
||||||
|
|
||||||
/* Get end date (row[4] holds the end UTC time) */
|
/* Get end date (row[4] holds the end UTC time) */
|
||||||
Asg->TimeUTC[Asg_END_TIME ] = Dat_GetUNIXTimeFromStr (row[4]);
|
Asg->TimeUTC[Asg_END_TIME ] = Dat_GetUNIXTimeFromStr (row[4]);
|
||||||
|
|
||||||
/* Get whether the assignment is open or closed (row(5)) */
|
/* Get whether the assignment is open or closed (row(5)) */
|
||||||
|
|
|
@ -673,7 +673,7 @@ bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att)
|
||||||
/* Get start date (row[4] holds the start UTC time) */
|
/* Get start date (row[4] holds the start UTC time) */
|
||||||
Att->TimeUTC[Att_START_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
Att->TimeUTC[Att_START_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
||||||
|
|
||||||
/* Get end date (row[5] holds the end UTC time) */
|
/* Get end date (row[5] holds the end UTC time) */
|
||||||
Att->TimeUTC[Att_END_TIME ] = Dat_GetUNIXTimeFromStr (row[5]);
|
Att->TimeUTC[Att_END_TIME ] = Dat_GetUNIXTimeFromStr (row[5]);
|
||||||
|
|
||||||
/* Get whether the attendance event is open or closed (row(6)) */
|
/* Get whether the attendance event is open or closed (row(6)) */
|
||||||
|
@ -1003,8 +1003,8 @@ void Att_RequestCreatOrEditAttEvent (void)
|
||||||
{
|
{
|
||||||
/* Initialize to empty attendance event */
|
/* Initialize to empty attendance event */
|
||||||
Att.AttCod = -1L;
|
Att.AttCod = -1L;
|
||||||
Att.TimeUTC[Asg_START_TIME] = Gbl.TimeStartExecution;
|
Att.TimeUTC[Att_START_TIME] = Gbl.TimeStartExecution;
|
||||||
Att.TimeUTC[Asg_END_TIME ] = Gbl.TimeStartExecution + (2 * 60 * 60); // +2 hours
|
Att.TimeUTC[Att_END_TIME ] = Gbl.TimeStartExecution + (2 * 60 * 60); // +2 hours
|
||||||
Att.Open = true;
|
Att.Open = true;
|
||||||
Att.Title[0] = '\0';
|
Att.Title[0] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -1209,8 +1209,8 @@ void Att_RecFormAttEvent (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get start/end date-times *****/
|
/***** Get start/end date-times *****/
|
||||||
NewAtt.TimeUTC[Asg_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
NewAtt.TimeUTC[Att_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
||||||
NewAtt.TimeUTC[Asg_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
|
NewAtt.TimeUTC[Att_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
|
||||||
|
|
||||||
/***** Get boolean parameter that indicates if teacher's comments are visible by students *****/
|
/***** Get boolean parameter that indicates if teacher's comments are visible by students *****/
|
||||||
Par_GetParToText ("CommentTchVisible",YN,1);
|
Par_GetParToText ("CommentTchVisible",YN,1);
|
||||||
|
@ -1223,10 +1223,10 @@ void Att_RecFormAttEvent (void)
|
||||||
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
||||||
|
|
||||||
/***** Adjust dates *****/
|
/***** Adjust dates *****/
|
||||||
if (NewAtt.TimeUTC[Asg_START_TIME] == 0)
|
if (NewAtt.TimeUTC[Att_START_TIME] == 0)
|
||||||
NewAtt.TimeUTC[Asg_START_TIME] = Gbl.TimeStartExecution;
|
NewAtt.TimeUTC[Att_START_TIME] = Gbl.TimeStartExecution;
|
||||||
if (NewAtt.TimeUTC[Asg_END_TIME] == 0)
|
if (NewAtt.TimeUTC[Att_END_TIME] == 0)
|
||||||
NewAtt.TimeUTC[Asg_END_TIME] = NewAtt.TimeUTC[Asg_START_TIME] + 2*60*60; // +2 hours
|
NewAtt.TimeUTC[Att_END_TIME] = NewAtt.TimeUTC[Att_START_TIME] + 2*60*60; // +2 hours
|
||||||
|
|
||||||
/***** Check if title is correct *****/
|
/***** Check if title is correct *****/
|
||||||
if (NewAtt.Title[0]) // If there's an attendance event title
|
if (NewAtt.Title[0]) // If there's an attendance event title
|
||||||
|
@ -1287,13 +1287,15 @@ void Att_CreateAttEvent (struct AttendanceEvent *Att,const char *Txt)
|
||||||
char Query[1024+Cns_MAX_BYTES_TEXT];
|
char Query[1024+Cns_MAX_BYTES_TEXT];
|
||||||
|
|
||||||
/***** Create a new attendance event *****/
|
/***** Create a new attendance event *****/
|
||||||
sprintf (Query,"INSERT INTO att_events (CrsCod,UsrCod,StartTime,EndTime,CommentTchVisible,Title,Txt)"
|
sprintf (Query,"INSERT INTO att_events"
|
||||||
" VALUES ('%ld','%ld',FROM_UNIXTIME('%ld'),FROM_UNIXTIME('%ld'),"
|
" (CrsCod,UsrCod,StartTime,EndTime,CommentTchVisible,Title,Txt)"
|
||||||
|
" VALUES ('%ld','%ld',"
|
||||||
|
"FROM_UNIXTIME('%ld'),FROM_UNIXTIME('%ld'),"
|
||||||
"'%c','%s','%s')",
|
"'%c','%s','%s')",
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Att->TimeUTC[Asg_START_TIME],
|
Att->TimeUTC[Att_START_TIME],
|
||||||
Att->TimeUTC[Asg_END_TIME ],
|
Att->TimeUTC[Att_END_TIME ],
|
||||||
Att->CommentTchVisible ? 'Y' :
|
Att->CommentTchVisible ? 'Y' :
|
||||||
'N',
|
'N',
|
||||||
Att->Title,
|
Att->Title,
|
||||||
|
@ -1319,8 +1321,8 @@ void Att_UpdateAttEvent (struct AttendanceEvent *Att,const char *Txt)
|
||||||
"EndTime=FROM_UNIXTIME('%ld'),"
|
"EndTime=FROM_UNIXTIME('%ld'),"
|
||||||
"CommentTchVisible='%c',Title='%s',Txt='%s'"
|
"CommentTchVisible='%c',Title='%s',Txt='%s'"
|
||||||
" WHERE AttCod='%ld' AND CrsCod='%ld'",
|
" WHERE AttCod='%ld' AND CrsCod='%ld'",
|
||||||
Att->TimeUTC[Asg_START_TIME],
|
Att->TimeUTC[Att_START_TIME],
|
||||||
Att->TimeUTC[Asg_END_TIME ],
|
Att->TimeUTC[Att_END_TIME ],
|
||||||
Att->CommentTchVisible ? 'Y' :
|
Att->CommentTchVisible ? 'Y' :
|
||||||
'N',
|
'N',
|
||||||
Att->Title,
|
Att->Title,
|
||||||
|
|
|
@ -102,17 +102,18 @@
|
||||||
// TODO: A teacher should may confirm a student ID? In what conditions? (Necessary in order to a student can view his/her marks)
|
// TODO: A teacher should may confirm a student ID? In what conditions? (Necessary in order to a student can view his/her marks)
|
||||||
// TODO: Put headers Content-type and Content-disposition when redirecting with Location:
|
// TODO: Put headers Content-type and Content-disposition when redirecting with Location:
|
||||||
// TODO: System admin should be able to remove/edit user's mail (when he/she detects a recipient does not exists, for example)
|
// TODO: System admin should be able to remove/edit user's mail (when he/she detects a recipient does not exists, for example)
|
||||||
// TODO: When a new assignment is incorrect, the second time the form is shown, it should be filled with partial data, now is always empty
|
// TODO: When a new assignment/attendance/survey is incorrect, the second time the form is shown, it should be filled with partial data, now is always empty
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.18 (2015/10/23)"
|
#define Log_PLATFORM_VERSION "SWAD 15.19 (2015/10/23)"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// 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
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.19: Oct 23, 2015 Surveys date-times are displayed in client local date-time. (186309 lines)
|
||||||
Version 15.18: Oct 23, 2015 Attendance date-times are displayed in client local date-time.
|
Version 15.18: Oct 23, 2015 Attendance date-times are displayed in client local date-time.
|
||||||
Changes in JavaScript functions related to date-time. (186403 lines)
|
Changes in JavaScript functions related to date-time. (186403 lines)
|
||||||
Version 15.17.3: Oct 23, 2015 Changes in JavaScript functions related to date-time. (186477 lines)
|
Version 15.17.3: Oct 23, 2015 Changes in JavaScript functions related to date-time. (186477 lines)
|
||||||
|
|
209
swad_survey.c
209
swad_survey.c
|
@ -330,6 +330,7 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst,bool Sh
|
||||||
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
extern const char *Txt_Answer_survey;
|
extern const char *Txt_Answer_survey;
|
||||||
extern const char *Txt_View_survey_results;
|
extern const char *Txt_View_survey_results;
|
||||||
|
static unsigned UniqueId = 0;
|
||||||
struct Survey Svy;
|
struct Survey Svy;
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
bool RolesSelected;
|
bool RolesSelected;
|
||||||
|
@ -344,8 +345,10 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst,bool Sh
|
||||||
Svy_GetDataOfSurveyByCod (&Svy);
|
Svy_GetDataOfSurveyByCod (&Svy);
|
||||||
|
|
||||||
/***** Start date/time *****/
|
/***** Start date/time *****/
|
||||||
|
UniqueId++;
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s LEFT_TOP",
|
"<td id=\"svy_date_start_%u\" class=\"%s LEFT_TOP",
|
||||||
|
UniqueId,
|
||||||
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
||||||
"DATE_RED") :
|
"DATE_RED") :
|
||||||
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
||||||
|
@ -353,17 +356,15 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst,bool Sh
|
||||||
if (!ShowOnlyThisSvyComplete)
|
if (!ShowOnlyThisSvyComplete)
|
||||||
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
|
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
|
||||||
fprintf (Gbl.F.Out,"\">"
|
fprintf (Gbl.F.Out,"\">"
|
||||||
"%02u/%02u/%02u<br />"
|
"<script type=\"text/javascript\">"
|
||||||
"%02u:%02u h"
|
"writeLocalDateTimeFromUTC('svy_date_start_%u',%ld,'<br />');"
|
||||||
|
"</script>"
|
||||||
"</td>",
|
"</td>",
|
||||||
Svy.DateTimes[Svy_START_TIME].Date.Day,
|
UniqueId,Svy.TimeUTC[Svy_START_TIME]);
|
||||||
Svy.DateTimes[Svy_START_TIME].Date.Month,
|
|
||||||
Svy.DateTimes[Svy_START_TIME].Date.Year % 100,
|
|
||||||
Svy.DateTimes[Svy_START_TIME].Time.Hour,
|
|
||||||
Svy.DateTimes[Svy_START_TIME].Time.Minute);
|
|
||||||
|
|
||||||
/***** End date/time *****/
|
/***** End date/time *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_TOP",
|
fprintf (Gbl.F.Out,"<td id=\"svy_date_end_%u\" class=\"%s LEFT_TOP",
|
||||||
|
UniqueId,
|
||||||
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
||||||
"DATE_RED") :
|
"DATE_RED") :
|
||||||
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
||||||
|
@ -371,14 +372,11 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst,bool Sh
|
||||||
if (!ShowOnlyThisSvyComplete)
|
if (!ShowOnlyThisSvyComplete)
|
||||||
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
|
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
|
||||||
fprintf (Gbl.F.Out,"\">"
|
fprintf (Gbl.F.Out,"\">"
|
||||||
"%02u/%02u/%02u<br />"
|
"<script type=\"text/javascript\">"
|
||||||
"%02u:%02u h"
|
"writeLocalDateTimeFromUTC('svy_date_end_%u',%ld,'<br />');"
|
||||||
|
"</script>"
|
||||||
"</td>",
|
"</td>",
|
||||||
Svy.DateTimes[Svy_END_TIME ].Date.Day,
|
UniqueId,Svy.TimeUTC[Svy_END_TIME]);
|
||||||
Svy.DateTimes[Svy_END_TIME ].Date.Month,
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Date.Year % 100,
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Time.Hour,
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Time.Minute);
|
|
||||||
|
|
||||||
/***** Survey title *****/
|
/***** Survey title *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP");
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP");
|
||||||
|
@ -921,8 +919,8 @@ void Svy_GetDataOfSurveyByCod (struct Survey *Svy)
|
||||||
|
|
||||||
/***** Build query *****/
|
/***** Build query *****/
|
||||||
sprintf (Query,"SELECT SvyCod,DegCod,CrsCod,Hidden,Roles,UsrCod,"
|
sprintf (Query,"SELECT SvyCod,DegCod,CrsCod,Hidden,Roles,UsrCod,"
|
||||||
"DATE_FORMAT(StartTime,'%%Y%%m%%d%%H%%i%%S'),"
|
"UNIX_TIMESTAMP(StartTime),"
|
||||||
"DATE_FORMAT(EndTime,'%%Y%%m%%d%%H%%i%%S'),"
|
"UNIX_TIMESTAMP(EndTime),"
|
||||||
"NOW() BETWEEN StartTime AND EndTime,"
|
"NOW() BETWEEN StartTime AND EndTime,"
|
||||||
"Title"
|
"Title"
|
||||||
" FROM surveys"
|
" FROM surveys"
|
||||||
|
@ -962,13 +960,11 @@ void Svy_GetDataOfSurveyByCod (struct Survey *Svy)
|
||||||
/* Get author of the survey (row[5]) */
|
/* Get author of the survey (row[5]) */
|
||||||
Svy->UsrCod = Str_ConvertStrCodToLongCod (row[5]);
|
Svy->UsrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||||
|
|
||||||
/* Get start date (row[6] holds the start date in YYYYMMDDHHMMSS format) */
|
/* Get start date (row[6] holds the start UTC time) */
|
||||||
if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&(Svy->DateTimes[Svy_START_TIME]),row[6])))
|
Svy->TimeUTC[Att_START_TIME] = Dat_GetUNIXTimeFromStr (row[6]);
|
||||||
Lay_ShowErrorAndExit ("Error when reading start date of survey.");
|
|
||||||
|
|
||||||
/* Get end date (row[7] holds the end date in YYYYMMDDHHMMSS format) */
|
/* Get end date (row[7] holds the end UTC time) */
|
||||||
if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&(Svy->DateTimes[Svy_END_TIME]),row[7])))
|
Svy->TimeUTC[Att_END_TIME ] = Dat_GetUNIXTimeFromStr (row[7]);
|
||||||
Lay_ShowErrorAndExit ("Error when reading end date of survey.");
|
|
||||||
|
|
||||||
/* Get whether the survey is open or closed (row(8)) */
|
/* Get whether the survey is open or closed (row(8)) */
|
||||||
Svy->Status.Open = (row[8][0] == '1');
|
Svy->Status.Open = (row[8][0] == '1');
|
||||||
|
@ -1045,12 +1041,8 @@ void Svy_GetDataOfSurveyByCod (struct Survey *Svy)
|
||||||
/* Initialize to empty survey */
|
/* Initialize to empty survey */
|
||||||
Svy->SvyCod = -1L;
|
Svy->SvyCod = -1L;
|
||||||
Svy->Roles = 0;
|
Svy->Roles = 0;
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Day =
|
Svy->TimeUTC[Svy_START_TIME] =
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Month =
|
Svy->TimeUTC[Svy_END_TIME ] = (time_t) 0;
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Year = 0;
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Date.Day =
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Date.Month =
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Date.Year = 0;
|
|
||||||
Svy->Title[0] = '\0';
|
Svy->Title[0] = '\0';
|
||||||
Svy->NumQsts = 0;
|
Svy->NumQsts = 0;
|
||||||
Svy->NumUsrs = 0;
|
Svy->NumUsrs = 0;
|
||||||
|
@ -1122,22 +1114,14 @@ static void Svy_GetSurveyTxtFromDB (long SvyCod,char *Txt)
|
||||||
|
|
||||||
void Svy_GetNotifSurvey (char *SummaryStr,char **ContentStr,long SvyCod,unsigned MaxChars,bool GetContent)
|
void Svy_GetNotifSurvey (char *SummaryStr,char **ContentStr,long SvyCod,unsigned MaxChars,bool GetContent)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Start_date;
|
|
||||||
extern const char *Txt_End_date;
|
|
||||||
char Query[512];
|
char Query[512];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
struct DateTime DateTimes[Asg_NUM_DATES];
|
|
||||||
|
|
||||||
SummaryStr[0] = '\0'; // Return nothing on error
|
SummaryStr[0] = '\0'; // Return nothing on error
|
||||||
|
|
||||||
/***** Build query *****/
|
/***** Build query *****/
|
||||||
sprintf (Query,"SELECT Title,"
|
sprintf (Query,"SELECT Title,Txt FROM surveys WHERE SvyCod='%ld'",
|
||||||
"DATE_FORMAT(StartTime,'%%Y%%m%%d%%H%%i%%S'),"
|
|
||||||
"DATE_FORMAT(EndTime,'%%Y%%m%%d%%H%%i%%S'),"
|
|
||||||
"Txt"
|
|
||||||
" FROM surveys"
|
|
||||||
" WHERE SvyCod='%ld'",
|
|
||||||
SvyCod);
|
SvyCod);
|
||||||
if (!mysql_query (&Gbl.mysql,Query))
|
if (!mysql_query (&Gbl.mysql,Query))
|
||||||
if ((mysql_res = mysql_store_result (&Gbl.mysql)) != NULL)
|
if ((mysql_res = mysql_store_result (&Gbl.mysql)) != NULL)
|
||||||
|
@ -1158,29 +1142,7 @@ void Svy_GetNotifSurvey (char *SummaryStr,char **ContentStr,long SvyCod,unsigned
|
||||||
{
|
{
|
||||||
if ((*ContentStr = (char *) malloc (512+Cns_MAX_BYTES_TEXT)) == NULL)
|
if ((*ContentStr = (char *) malloc (512+Cns_MAX_BYTES_TEXT)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
|
||||||
|
strcpy (*ContentStr,row[1]);
|
||||||
/* Get start date (row[1] holds the start date in YYYYMMDDHHMMSS format) */
|
|
||||||
if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&DateTimes[Asg_START_TIME],row[1])))
|
|
||||||
Lay_ShowErrorAndExit ("Error when reading start date of assignment.");
|
|
||||||
|
|
||||||
/* Get end date (row[2] holds the end date in YYYYMMDDHHMMSS format) */
|
|
||||||
if (!(Dat_GetDateTimeFromYYYYMMDDHHMMSS (&DateTimes[Asg_END_TIME ],row[2])))
|
|
||||||
Lay_ShowErrorAndExit ("Error when reading end date of assignment.");
|
|
||||||
|
|
||||||
sprintf (*ContentStr,"%s: %02u/%02u/%04u %02u:%02u<br />%s: %02u/%02u/%04u %02u:%02u<br />%s",
|
|
||||||
Txt_Start_date,
|
|
||||||
DateTimes[Asg_START_TIME].Date.Day,
|
|
||||||
DateTimes[Asg_START_TIME].Date.Month,
|
|
||||||
DateTimes[Asg_START_TIME].Date.Year,
|
|
||||||
DateTimes[Asg_START_TIME].Time.Hour,
|
|
||||||
DateTimes[Asg_START_TIME].Time.Minute,
|
|
||||||
Txt_End_date,
|
|
||||||
DateTimes[Asg_END_TIME].Date.Day,
|
|
||||||
DateTimes[Asg_END_TIME].Date.Month,
|
|
||||||
DateTimes[Asg_END_TIME].Date.Year,
|
|
||||||
DateTimes[Asg_END_TIME].Time.Hour,
|
|
||||||
DateTimes[Asg_END_TIME].Time.Minute,
|
|
||||||
row[3]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mysql_free_result (mysql_res);
|
mysql_free_result (mysql_res);
|
||||||
|
@ -1497,9 +1459,7 @@ void Svy_RequestCreatOrEditSvy (void)
|
||||||
struct SurveyQuestion SvyQst;
|
struct SurveyQuestion SvyQst;
|
||||||
bool ItsANewSurvey;
|
bool ItsANewSurvey;
|
||||||
Svy_StartOrEndTime_t StartOrEndTime;
|
Svy_StartOrEndTime_t StartOrEndTime;
|
||||||
const char *Id[Svy_NUM_DATES] = {"Start","End"};
|
const char *Id[Att_NUM_DATES] = {"Start","End"};
|
||||||
const char *NameSelectHour [Svy_NUM_DATES] = {"StartHour" ,"EndHour" };
|
|
||||||
const char *NameSelectMinute[Svy_NUM_DATES] = {"StartMinute","EndMinute"};
|
|
||||||
const char *Dates[Svy_NUM_DATES] = {Txt_Start_date,Txt_End_date};
|
const char *Dates[Svy_NUM_DATES] = {Txt_Start_date,Txt_End_date};
|
||||||
char Txt[Cns_MAX_BYTES_TEXT+1];
|
char Txt[Cns_MAX_BYTES_TEXT+1];
|
||||||
|
|
||||||
|
@ -1520,18 +1480,8 @@ void Svy_RequestCreatOrEditSvy (void)
|
||||||
|
|
||||||
/* Initialize to empty survey */
|
/* Initialize to empty survey */
|
||||||
Svy.SvyCod = -1L;
|
Svy.SvyCod = -1L;
|
||||||
Svy.DateTimes[Svy_START_TIME].Date.Year = Gbl.Now.Date.Year;
|
Svy.TimeUTC[Svy_START_TIME] = Gbl.TimeStartExecution;
|
||||||
Svy.DateTimes[Svy_START_TIME].Date.Month = Gbl.Now.Date.Month;
|
Svy.TimeUTC[Svy_END_TIME ] = Gbl.TimeStartExecution + (24 * 60 * 60); // +24 hours
|
||||||
Svy.DateTimes[Svy_START_TIME].Date.Day = Gbl.Now.Date.Day;
|
|
||||||
Svy.DateTimes[Svy_START_TIME].Time.Hour = Gbl.Now.Time.Hour;
|
|
||||||
Svy.DateTimes[Svy_START_TIME].Time.Minute = Gbl.Now.Time.Minute;
|
|
||||||
Svy.DateTimes[Svy_START_TIME].Time.Second = Gbl.Now.Time.Second;
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Date.Year = Gbl.Now.Date.Year;
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Date.Month = Gbl.Now.Date.Month;
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Date.Day = Gbl.Now.Date.Day;
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Time.Hour = 23;
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Time.Minute = 59;
|
|
||||||
Svy.DateTimes[Svy_END_TIME ].Time.Second = 59;
|
|
||||||
Svy.Title[0] = '\0';
|
Svy.Title[0] = '\0';
|
||||||
Svy.Roles = (1 << Rol_STUDENT);
|
Svy.Roles = (1 << Rol_STUDENT);
|
||||||
Svy.NumQsts = 0;
|
Svy.NumQsts = 0;
|
||||||
|
@ -1616,17 +1566,14 @@ void Svy_RequestCreatOrEditSvy (void)
|
||||||
"<td class=\"LEFT_MIDDLE\">",
|
"<td class=\"LEFT_MIDDLE\">",
|
||||||
The_ClassForm[Gbl.Prefs.Theme],
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
Dates[StartOrEndTime]);
|
Dates[StartOrEndTime]);
|
||||||
Dat_WriteFormDate (Gbl.Now.Date.Year-1,
|
|
||||||
Gbl.Now.Date.Year+1,
|
/* Date-time */
|
||||||
Id[StartOrEndTime],
|
Dat_WriteFormClientLocalDateTime (Id[StartOrEndTime],
|
||||||
&(Svy.DateTimes[StartOrEndTime].Date),
|
Svy.TimeUTC[StartOrEndTime],
|
||||||
false,false);
|
Gbl.Now.Date.Year - 1,
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
Gbl.Now.Date.Year + 1,
|
||||||
"<td class=\"LEFT_TOP\">");
|
false,false);
|
||||||
Dat_WriteFormHourMinute (NameSelectHour [StartOrEndTime],
|
|
||||||
NameSelectMinute[StartOrEndTime],
|
|
||||||
&(Svy.DateTimes[StartOrEndTime].Time),
|
|
||||||
false,false);
|
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
fprintf (Gbl.F.Out,"</td>"
|
||||||
"</tr>"
|
"</tr>"
|
||||||
"</table>"
|
"</table>"
|
||||||
|
@ -1840,23 +1787,9 @@ void Svy_RecFormSurvey (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get start date *****/
|
/***** Get start/end date-times *****/
|
||||||
Dat_GetDateFromForm ("StartDay","StartMonth","StartYear",
|
NewSvy.TimeUTC[Asg_START_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
||||||
&(NewSvy.DateTimes[Svy_START_TIME].Date.Day),
|
NewSvy.TimeUTC[Asg_END_TIME ] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
|
||||||
&(NewSvy.DateTimes[Svy_START_TIME].Date.Month),
|
|
||||||
&(NewSvy.DateTimes[Svy_START_TIME].Date.Year));
|
|
||||||
Dat_GetHourMinuteFromForm ("StartHour","StartMinute",
|
|
||||||
&(NewSvy.DateTimes[Svy_START_TIME].Time.Hour),
|
|
||||||
&(NewSvy.DateTimes[Svy_START_TIME].Time.Minute));
|
|
||||||
|
|
||||||
/***** Get end date *****/
|
|
||||||
Dat_GetDateFromForm ("EndDay","EndMonth","EndYear",
|
|
||||||
&(NewSvy.DateTimes[Svy_END_TIME].Date.Day),
|
|
||||||
&(NewSvy.DateTimes[Svy_END_TIME].Date.Month),
|
|
||||||
&(NewSvy.DateTimes[Svy_END_TIME].Date.Year));
|
|
||||||
Dat_GetHourMinuteFromForm ("EndHour","EndMinute",
|
|
||||||
&(NewSvy.DateTimes[Svy_END_TIME].Time.Hour),
|
|
||||||
&(NewSvy.DateTimes[Svy_END_TIME].Time.Minute));
|
|
||||||
|
|
||||||
/***** Get survey title *****/
|
/***** Get survey title *****/
|
||||||
Par_GetParToText ("Title",NewSvy.Title,Svy_MAX_LENGTH_SURVEY_TITLE);
|
Par_GetParToText ("Title",NewSvy.Title,Svy_MAX_LENGTH_SURVEY_TITLE);
|
||||||
|
@ -1865,28 +1798,10 @@ void Svy_RecFormSurvey (void)
|
||||||
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
||||||
|
|
||||||
/***** Adjust dates *****/
|
/***** Adjust dates *****/
|
||||||
if (NewSvy.DateTimes[Svy_START_TIME].Date.Day == 0 ||
|
if (NewSvy.TimeUTC[Svy_START_TIME] == 0)
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Date.Month == 0 ||
|
NewSvy.TimeUTC[Svy_START_TIME] = Gbl.TimeStartExecution;
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Date.Year == 0)
|
if (NewSvy.TimeUTC[Svy_END_TIME] == 0)
|
||||||
{
|
NewSvy.TimeUTC[Svy_END_TIME] = NewSvy.TimeUTC[Svy_START_TIME] + 24*60*60; // +24 hours
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Date.Year = Gbl.Now.Date.Year;
|
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Date.Month = Gbl.Now.Date.Month;
|
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Date.Day = Gbl.Now.Date.Day;
|
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Time.Hour = Gbl.Now.Time.Hour;
|
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Time.Minute = Gbl.Now.Time.Minute;
|
|
||||||
NewSvy.DateTimes[Svy_START_TIME].Time.Second = Gbl.Now.Time.Second;
|
|
||||||
}
|
|
||||||
if (NewSvy.DateTimes[Svy_END_TIME].Date.Day == 0 ||
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Date.Month == 0 ||
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Date.Year == 0)
|
|
||||||
{
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Date.Year = Gbl.Now.Date.Year;
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Date.Month = Gbl.Now.Date.Month;
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Date.Day = Gbl.Now.Date.Day;
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Time.Hour = 23;
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Time.Minute = 59;
|
|
||||||
}
|
|
||||||
NewSvy.DateTimes[Svy_END_TIME].Time.Second = 59;
|
|
||||||
|
|
||||||
/***** Get users who can answer this survey *****/
|
/***** Get users who can answer this survey *****/
|
||||||
Rol_GetSelectedRoles (&(NewSvy.Roles));
|
Rol_GetSelectedRoles (&(NewSvy.Roles));
|
||||||
|
@ -1963,24 +1878,17 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
|
||||||
char Query[1024+Cns_MAX_BYTES_TEXT];
|
char Query[1024+Cns_MAX_BYTES_TEXT];
|
||||||
|
|
||||||
/***** Create a new survey *****/
|
/***** Create a new survey *****/
|
||||||
sprintf (Query,"INSERT INTO surveys (DegCod,CrsCod,Hidden,Roles,UsrCod,StartTime,EndTime,Title,Txt)"
|
sprintf (Query,"INSERT INTO surveys"
|
||||||
" VALUES ('%ld','%ld','N','%u','%ld','%04u%02u%02u%02u%02u%02u','%04u%02u%02u%02u%02u%02u','%s','%s')",
|
" (DegCod,CrsCod,Hidden,Roles,UsrCod,StartTime,EndTime,Title,Txt)"
|
||||||
|
" VALUES ('%ld','%ld','N','%u','%ld',"
|
||||||
|
"FROM_UNIXTIME('%ld'),FROM_UNIXTIME('%ld'),"
|
||||||
|
"'%s','%s')",
|
||||||
Svy->DegCod,
|
Svy->DegCod,
|
||||||
Svy->CrsCod,
|
Svy->CrsCod,
|
||||||
Svy->Roles,
|
Svy->Roles,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Year,
|
Svy->TimeUTC[Svy_START_TIME],
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Month,
|
Svy->TimeUTC[Svy_END_TIME ],
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Day,
|
|
||||||
Svy->DateTimes[Svy_START_TIME].Time.Hour,
|
|
||||||
Svy->DateTimes[Svy_START_TIME].Time.Minute,
|
|
||||||
Svy->DateTimes[Svy_START_TIME].Time.Second,
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Date.Year,
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Date.Month,
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Date.Day,
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Time.Hour,
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Time.Minute,
|
|
||||||
Svy->DateTimes[Svy_END_TIME].Time.Second,
|
|
||||||
Svy->Title,
|
Svy->Title,
|
||||||
Txt);
|
Txt);
|
||||||
Svy->SvyCod = DB_QueryINSERTandReturnCode (Query,"can not create new survey");
|
Svy->SvyCod = DB_QueryINSERTandReturnCode (Query,"can not create new survey");
|
||||||
|
@ -2005,22 +1913,15 @@ static void Svy_UpdateSurvey (struct Survey *Svy,const char *Txt)
|
||||||
char Query[1024+Cns_MAX_BYTES_TEXT];
|
char Query[1024+Cns_MAX_BYTES_TEXT];
|
||||||
|
|
||||||
/***** Update the data of the survey *****/
|
/***** Update the data of the survey *****/
|
||||||
sprintf (Query,"UPDATE surveys SET DegCod='%ld',CrsCod='%ld',Roles='%u',StartTime='%04u%02u%02u%02u%02u%02u',EndTime='%04u%02u%02u%02u%02u%02u',Title='%s',Txt='%s'"
|
sprintf (Query,"UPDATE surveys SET DegCod='%ld',CrsCod='%ld',Roles='%u',"
|
||||||
|
"StartTime=FROM_UNIXTIME('%ld'),"
|
||||||
|
"EndTime=FROM_UNIXTIME('%ld'),"
|
||||||
|
"Title='%s',Txt='%s'"
|
||||||
" WHERE SvyCod='%ld'",
|
" WHERE SvyCod='%ld'",
|
||||||
Svy->DegCod,Svy->CrsCod,
|
Svy->DegCod,Svy->CrsCod,
|
||||||
Svy->Roles,
|
Svy->Roles,
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Year,
|
Svy->TimeUTC[Svy_START_TIME],
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Month,
|
Svy->TimeUTC[Svy_END_TIME ],
|
||||||
Svy->DateTimes[Svy_START_TIME].Date.Day,
|
|
||||||
Svy->DateTimes[Svy_START_TIME].Time.Hour,
|
|
||||||
Svy->DateTimes[Svy_START_TIME].Time.Minute,
|
|
||||||
Svy->DateTimes[Svy_START_TIME].Time.Second,
|
|
||||||
Svy->DateTimes[Svy_END_TIME ].Date.Year,
|
|
||||||
Svy->DateTimes[Svy_END_TIME ].Date.Month,
|
|
||||||
Svy->DateTimes[Svy_END_TIME ].Date.Day,
|
|
||||||
Svy->DateTimes[Svy_END_TIME ].Time.Hour,
|
|
||||||
Svy->DateTimes[Svy_END_TIME ].Time.Minute,
|
|
||||||
Svy->DateTimes[Svy_END_TIME ].Time.Second,
|
|
||||||
Svy->Title,
|
Svy->Title,
|
||||||
Txt,
|
Txt,
|
||||||
Svy->SvyCod);
|
Svy->SvyCod);
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct Survey
|
||||||
long CrsCod;
|
long CrsCod;
|
||||||
unsigned Roles; // Example: if survey can be made by students and teachers, Roles == (1 << Rol_ROLE_STUDENT) | (1 << Rol_ROLE_TEACHER)
|
unsigned Roles; // Example: if survey can be made by students and teachers, Roles == (1 << Rol_ROLE_STUDENT) | (1 << Rol_ROLE_TEACHER)
|
||||||
long UsrCod;
|
long UsrCod;
|
||||||
struct DateTime DateTimes[Svy_NUM_DATES];
|
time_t TimeUTC[Svy_NUM_DATES];
|
||||||
char Title[Svy_MAX_LENGTH_SURVEY_TITLE+1];
|
char Title[Svy_MAX_LENGTH_SURVEY_TITLE+1];
|
||||||
unsigned NumQsts; // Number of questions in the survey
|
unsigned NumQsts; // Number of questions in the survey
|
||||||
unsigned NumUsrs; // Number of distinct users who have already answered the survey
|
unsigned NumUsrs; // Number of distinct users who have already answered the survey
|
||||||
|
|
Loading…
Reference in New Issue
Block a user