Version 15.21.3

This commit is contained in:
Antonio Cañas Vargas 2015-10-26 14:11:30 +01:00
parent 15f6ce0266
commit 98f14fd94d
2 changed files with 50 additions and 41 deletions

View File

@ -113,7 +113,7 @@
// 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.21.3: Oct 26, 2015 Changes in date-times of test exams. (? lines) Version 15.21.3: Oct 26, 2015 Changes in date-times of test exams. (186325 lines)
Version 15.21.2: Oct 26, 2015 Date-times in tests are displayed in client local date-time. (186315 lines) Version 15.21.2: Oct 26, 2015 Date-times in tests are displayed in client local date-time. (186315 lines)
Version 15.21.1: Oct 26, 2015 New forms to enter range of date-times in statistic and test. (186313 lines) Version 15.21.1: Oct 26, 2015 New forms to enter range of date-times in statistic and test. (186313 lines)
Version 15.21: Oct 25, 2015 New forms to enter range of date-times in statistic and test. Not finished. (186549 lines) Version 15.21: Oct 25, 2015 New forms to enter range of date-times in statistic and test. Not finished. (186549 lines)

View File

@ -230,8 +230,9 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat);
static void Tst_ShowDataUsr (struct UsrData *UsrDat,unsigned NumExams); static void Tst_ShowDataUsr (struct UsrData *UsrDat,unsigned NumExams);
static void Tst_PutParamTstCod (long TstCod); static void Tst_PutParamTstCod (long TstCod);
static long Tst_GetParamTstCod (void); static long Tst_GetParamTstCod (void);
static void Tst_ShowExamTstResult (const char *TstTime); static void Tst_ShowExamTstResult (time_t TstTimeUTC);
static void Tst_GetExamDataByTstCod (long TstCod,char *TstTime,unsigned *NumQsts,unsigned *NumQstsNotBlank,double *Score); static void Tst_GetExamDataByTstCod (long TstCod,time_t *TstTimeUTC,
unsigned *NumQsts,unsigned *NumQstsNotBlank,double *Score);
static void Tst_StoreOneExamQstInDB (long TstCod,long QstCod,unsigned NumQst,double Score); static void Tst_StoreOneExamQstInDB (long TstCod,long QstCod,unsigned NumQst,double Score);
static void Tst_GetExamQuestionsFromDB (long TstCod); static void Tst_GetExamQuestionsFromDB (long TstCod);
@ -857,7 +858,7 @@ static void Tst_ShowTstResultAfterAssess (long TstCod,unsigned *NumQstsNotBlank,
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* /*
row[0] QstCod row[0] QstCod
row[1] DATE_FORMAT(EditTime,'%%Y%%m%%d%%H%%i%%S') row[1] UNIX_TIMESTAMP(EditTime)
row[2] AnsType row[2] AnsType
row[3] Shuffle row[3] Shuffle
row[4] Stem row[4] Stem
@ -920,7 +921,7 @@ static void Tst_WriteQstAndAnsExam (unsigned NumQst,long QstCod,MYSQL_ROW row,
extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES];
/* /*
row[0] QstCod row[0] QstCod
row[1] DATE_FORMAT(EditTime,'%%Y%%m%%d%%H%%i%%S') row[1] UNIX_TIMESTAMP(EditTime)
row[2] AnsType row[2] AnsType
row[3] Shuffle row[3] Shuffle
row[4] Stem row[4] Stem
@ -2240,7 +2241,7 @@ static unsigned long Tst_GetQuestionsForExam (MYSQL_RES **mysql_res)
/***** Select questions without hidden tags *****/ /***** Select questions without hidden tags *****/
/* /*
row[0] QstCod row[0] QstCod
row[1] DATE_FORMAT(EditTime,'%%Y%%m%%d%%H%%i%%S') row[1] UNIX_TIMESTAMP(EditTime)
row[2] AnsType row[2] AnsType
row[3] Shuffle row[3] Shuffle
row[4] Stem row[4] Stem
@ -2254,7 +2255,7 @@ static unsigned long Tst_GetQuestionsForExam (MYSQL_RES **mysql_res)
// Select only questions with tags // Select only questions with tags
// DISTINCTROW is necessary to not repeat questions // DISTINCTROW is necessary to not repeat questions
sprintf (Query,"SELECT DISTINCTROW tst_questions.QstCod," sprintf (Query,"SELECT DISTINCTROW tst_questions.QstCod,"
"DATE_FORMAT(tst_questions.EditTime,'%%Y%%m%%d%%H%%i%%S')," "UNIX_TIMESTAMP(tst_questions.EditTime),"
"tst_questions.AnsType,tst_questions.Shuffle," "tst_questions.AnsType,tst_questions.Shuffle,"
"tst_questions.Stem,tst_questions.Feedback," "tst_questions.Stem,tst_questions.Feedback,"
"tst_questions.NumHits,tst_questions.NumHitsNotBlank," "tst_questions.NumHits,tst_questions.NumHitsNotBlank,"
@ -2368,7 +2369,7 @@ static bool Tst_GetOneQuestionByCod (long QstCod,MYSQL_RES **mysql_res)
/***** Get data of a question from database *****/ /***** Get data of a question from database *****/
/* /*
row[0] QstCod row[0] QstCod
row[1] DATE_FORMAT(EditTime,'%%Y%%m%%d%%H%%i%%S') row[1] UNIX_TIMESTAMP(EditTime)
row[2] AnsType row[2] AnsType
row[3] Shuffle row[3] Shuffle
row[4] Stem row[4] Stem
@ -2377,7 +2378,7 @@ static bool Tst_GetOneQuestionByCod (long QstCod,MYSQL_RES **mysql_res)
row[7] NumHitsNotBlank row[7] NumHitsNotBlank
row[8] Score row[8] Score
*/ */
sprintf (Query,"SELECT QstCod,DATE_FORMAT(EditTime,'%%Y%%m%%d%%H%%i%%S')," sprintf (Query,"SELECT QstCod,UNIX_TIMESTAMP(EditTime),"
"AnsType,Shuffle,Stem,Feedback," "AnsType,Shuffle,Stem,Feedback,"
"NumHits,NumHitsNotBlank,Score" "NumHits,NumHitsNotBlank,Score"
" FROM tst_questions" " FROM tst_questions"
@ -2534,10 +2535,10 @@ static void Tst_ListOneOrMoreQuestionsToEdit (unsigned long NumRows,MYSQL_RES *m
" class=\"DAT_SMALL CENTER_TOP COLOR%u\">" " class=\"DAT_SMALL CENTER_TOP COLOR%u\">"
"<script type=\"text/javascript\">" "<script type=\"text/javascript\">"
"writeLocalDateTimeFromUTC('tst_date_%u',%ld,'<br />');" "writeLocalDateTimeFromUTC('tst_date_%u',%ld,'<br />');"
"</script>", "</script>"
"</td>",
UniqueId,Gbl.RowEvenOdd, UniqueId,Gbl.RowEvenOdd,
UniqueId,TimeUTC); UniqueId,(long) TimeUTC);
fprintf (Gbl.F.Out,"</td>");
/* Write the question tags */ /* Write the question tags */
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP COLOR%u\">",
@ -6184,7 +6185,9 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat)
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumExams,NumExam; unsigned NumExams;
unsigned NumExam;
unsigned UniqueId;
long TstCod; long TstCod;
unsigned NumQstsInThisExam; unsigned NumQstsInThisExam;
unsigned NumQstsNotBlankInThisExam; unsigned NumQstsNotBlankInThisExam;
@ -6197,11 +6200,12 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat)
bool IAmATeacher = (Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER); bool IAmATeacher = (Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER);
bool ICanViewExam; bool ICanViewExam;
bool ICanViewScore; bool ICanViewScore;
time_t TimeUTC;
char *ClassDat; char *ClassDat;
/***** Make database query *****/ /***** Make database query *****/
sprintf (Query,"SELECT TstCod,AllowTeachers," sprintf (Query,"SELECT TstCod,AllowTeachers,"
"DATE_FORMAT(TstTime,'%%Y%%m%%d%%H%%i%%S')," "UNIX_TIMESTAMP(TstTime),"
"NumQsts,NumQstsNotBlank,Score" "NumQsts,NumQstsNotBlank,Score"
" FROM tst_exams" " FROM tst_exams"
" WHERE CrsCod='%ld' AND UsrCod='%ld'" " WHERE CrsCod='%ld' AND UsrCod='%ld'"
@ -6225,9 +6229,9 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat)
/***** Get and print exams results *****/ /***** Get and print exams results *****/
if (NumExams) if (NumExams)
{ {
for (NumExam = 0; for (NumExam = 0, UniqueId = 1;
NumExam < NumExams; NumExam < NumExams;
NumExam++) NumExam++, UniqueId++)
{ {
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -6246,13 +6250,15 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat)
if (NumExam) if (NumExam)
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
/* Write date and time (row[2] holds date and time in YYYYMMDDHHMMSS format) */ /* Write date and time (row[2] holds UTC date-time) */
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_TOP COLOR%u\">", TimeUTC = Dat_GetUNIXTimeFromStr (row[2]);
ClassDat,Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"<td id =\"tst_date_%u\" class=\"%s RIGHT_TOP COLOR%u\">"
Dat_WriteDate (row[2]); "<script type=\"text/javascript\">"
fprintf (Gbl.F.Out,"&nbsp;"); "writeLocalDateTimeFromUTC('tst_date_%u',%ld,'&nbsp;');"
Dat_WriteHourMinute (&row[2][8]); "</script>"
fprintf (Gbl.F.Out,"</td>"); "</td>",
UniqueId,ClassDat,Gbl.RowEvenOdd,
UniqueId,(long) TimeUTC);
/* Get number of questions (row[3]) */ /* Get number of questions (row[3]) */
if (sscanf (row[3],"%u",&NumQstsInThisExam) == 1) if (sscanf (row[3],"%u",&NumQstsInThisExam) == 1)
@ -6508,7 +6514,7 @@ void Tst_ShowOneTestExam (void)
extern const char *Txt_out_of_PART_OF_A_SCORE; extern const char *Txt_out_of_PART_OF_A_SCORE;
extern const char *Txt_Tags; extern const char *Txt_Tags;
long TstCod; long TstCod;
char TstTime[4+2+2+2+2+2+1]; // Test exam time in YYYYMMDDHHMMSS format time_t TstTimeUTC = 0; // Test exam UTC date-time, initialized to avoid warning
unsigned NumQstsNotBlank; unsigned NumQstsNotBlank;
double TotalScore; double TotalScore;
bool ShowPhoto; bool ShowPhoto;
@ -6520,7 +6526,7 @@ void Tst_ShowOneTestExam (void)
Lay_ShowErrorAndExit ("Code of test exam is missing."); Lay_ShowErrorAndExit ("Code of test exam is missing.");
/***** Get exam data and check if I can view this test exam) *****/ /***** Get exam data and check if I can view this test exam) *****/
Tst_GetExamDataByTstCod (TstCod,TstTime,&Gbl.Test.NumQsts,&NumQstsNotBlank,&TotalScore); Tst_GetExamDataByTstCod (TstCod,&TstTimeUTC,&Gbl.Test.NumQsts,&NumQstsNotBlank,&TotalScore);
Gbl.Test.Config.FeedbackType = Tst_FEEDBACK_FULL_FEEDBACK; // Initialize feedback to maximum Gbl.Test.Config.FeedbackType = Tst_FEEDBACK_FULL_FEEDBACK; // Initialize feedback to maximum
ICanViewScore = true; ICanViewScore = true;
switch (Gbl.CurrentAct) switch (Gbl.CurrentAct)
@ -6586,13 +6592,13 @@ void Tst_ShowOneTestExam (void)
"<td class=\"DAT_N RIGHT_TOP\">" "<td class=\"DAT_N RIGHT_TOP\">"
"%s:" "%s:"
"</td>" "</td>"
"<td class=\"DAT LEFT_TOP\">", "<td id=\"exam\" class=\"DAT LEFT_TOP\">"
Txt_Date); "<script type=\"text/javascript\">"
Dat_WriteDate (TstTime); "writeLocalDateTimeFromUTC('exam',%ld,'&nbsp;');"
fprintf (Gbl.F.Out,"&nbsp;"); "</script>"
Dat_WriteHourMinute (&TstTime[8]); "</td>"
fprintf (Gbl.F.Out,"</td>" "</tr>",
"</tr>"); Txt_Date,TstTimeUTC);
/* Number of questions */ /* Number of questions */
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
@ -6639,7 +6645,7 @@ void Tst_ShowOneTestExam (void)
"</tr>"); "</tr>");
/***** Write answers and solutions *****/ /***** Write answers and solutions *****/
Tst_ShowExamTstResult (TstTime); Tst_ShowExamTstResult (TstTimeUTC);
/***** Write total mark of test *****/ /***** Write total mark of test *****/
if (ICanViewScore) if (ICanViewScore)
@ -6653,7 +6659,7 @@ void Tst_ShowOneTestExam (void)
/********************* Show the result of a test exam ************************/ /********************* Show the result of a test exam ************************/
/*****************************************************************************/ /*****************************************************************************/
static void Tst_ShowExamTstResult (const char *TstTime) static void Tst_ShowExamTstResult (time_t TstTimeUTC)
{ {
extern const char *Txt_Question_modified; extern const char *Txt_Question_modified;
extern const char *Txt_Question_removed; extern const char *Txt_Question_removed;
@ -6664,6 +6670,7 @@ static void Tst_ShowExamTstResult (const char *TstTime)
double ScoreThisQst; double ScoreThisQst;
bool AnswerIsNotBlank; bool AnswerIsNotBlank;
bool ThisQuestionHasBeenEdited; bool ThisQuestionHasBeenEdited;
time_t EditTimeUTC;
for (NumQst = 0; for (NumQst = 0;
NumQst < Gbl.Test.NumQsts; NumQst < Gbl.Test.NumQsts;
@ -6678,7 +6685,7 @@ static void Tst_ShowExamTstResult (const char *TstTime)
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/* /*
row[0] QstCod row[0] QstCod
row[1] DATE_FORMAT(EditTime,'%%Y%%m%%d%%H%%i%%S') row[1] UNIX_TIMESTAMP(EditTime)
row[2] AnsType row[2] AnsType
row[3] Shuffle row[3] Shuffle
row[4] Stem row[4] Stem
@ -6688,9 +6695,10 @@ static void Tst_ShowExamTstResult (const char *TstTime)
row[8] Score row[8] Score
*/ */
/***** If this question has been edited later than test exam time ==> don't show question ****/ /***** If this question has been edited later than test exam time ==> don't show question ****/
EditTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
ThisQuestionHasBeenEdited = false; ThisQuestionHasBeenEdited = false;
if (TstTime) // if (TstTimeUTC)
if (strcmp (row[1],TstTime) > 0) // EditTime > TstTime if (EditTimeUTC > TstTimeUTC)
ThisQuestionHasBeenEdited = true; ThisQuestionHasBeenEdited = true;
if (ThisQuestionHasBeenEdited) if (ThisQuestionHasBeenEdited)
@ -6743,7 +6751,8 @@ static void Tst_ShowExamTstResult (const char *TstTime)
/************ Get data of a test exam using its test exam code ***************/ /************ Get data of a test exam using its test exam code ***************/
/*****************************************************************************/ /*****************************************************************************/
static void Tst_GetExamDataByTstCod (long TstCod,char *TstTime,unsigned *NumQsts,unsigned *NumQstsNotBlank,double *Score) static void Tst_GetExamDataByTstCod (long TstCod,time_t *TstTimeUTC,
unsigned *NumQsts,unsigned *NumQstsNotBlank,double *Score)
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -6751,7 +6760,7 @@ static void Tst_GetExamDataByTstCod (long TstCod,char *TstTime,unsigned *NumQsts
/***** Make database query *****/ /***** Make database query *****/
sprintf (Query,"SELECT UsrCod,AllowTeachers," sprintf (Query,"SELECT UsrCod,AllowTeachers,"
"DATE_FORMAT(TstTime,'%%Y%%m%%d%%H%%i%%S')," "UNIX_TIMESTAMP(TstTime),"
"NumQsts,NumQstsNotBlank,Score" "NumQsts,NumQstsNotBlank,Score"
" FROM tst_exams" " FROM tst_exams"
" WHERE TstCod='%ld' AND CrsCod='%ld'", " WHERE TstCod='%ld' AND CrsCod='%ld'",
@ -6767,8 +6776,8 @@ static void Tst_GetExamDataByTstCod (long TstCod,char *TstTime,unsigned *NumQsts
/* Get if teachers are allowed to see this test exam (row[1]) */ /* Get if teachers are allowed to see this test exam (row[1]) */
Gbl.Test.AllowTeachers = (Str_ConvertToUpperLetter (row[1][0]) == 'Y'); Gbl.Test.AllowTeachers = (Str_ConvertToUpperLetter (row[1][0]) == 'Y');
/* Get date and time (row[2] holds date and time in YYYYMMDDHHMMSS format) */ /* Get date-time (row[2] holds UTC date-time) */
strcpy (TstTime,row[2]); *TstTimeUTC = Dat_GetUNIXTimeFromStr (row[2]);
/* Get number of questions (row[3]) */ /* Get number of questions (row[3]) */
if (sscanf (row[3],"%u",NumQsts) != 1) if (sscanf (row[3],"%u",NumQsts) != 1)