Version 15.218.2

This commit is contained in:
Antonio Cañas Vargas 2016-06-04 13:25:14 +02:00
parent eac87bfc3b
commit 83288f99bc
5 changed files with 48 additions and 25 deletions

View File

@ -128,19 +128,19 @@
// TODO: FIX BUG: In Statistics > Indicators, if we select only 5 indicators, the message "The list is too big..." is shown. // TODO: FIX BUG: In Statistics > Indicators, if we select only 5 indicators, the message "The list is too big..." is shown.
// TODO: FIX BUG: A teacher uploads a document in course documents zone, then he/she unregister from course, the he/she search for his/her documents, a document is shown in results but he/she can not view it // TODO: FIX BUG: A teacher uploads a document in course documents zone, then he/she unregister from course, the he/she search for his/her documents, a document is shown in results but he/she can not view it
// TODO: FIX BUG: Txt_Save_file_properties does not have sense in briefcase, because nothing to save (license should be editable in briefcase?) // TODO: FIX BUG: Txt_Save_file_properties does not have sense in briefcase, because nothing to save (license should be editable in briefcase?)
// TODO: Check value returned by setlocale in all calls.
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.218.1 (2016-06-04)" #define Log_PLATFORM_VERSION "SWAD 15.218.2 (2016-06-04)"
#define CSS_FILE "swad15.218.css" #define CSS_FILE "swad15.218.css"
#define JS_FILE "swad15.216.js" #define JS_FILE "swad15.216.js"
// 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.218.2: Jun 04, 2016 Checked value returned by setlocale in all calls. (201957 lines)
Version 15.218.1: Jun 04, 2016 Change in listing of courses. (201934 lines) Version 15.218.1: Jun 04, 2016 Change in listing of courses. (201934 lines)
Version 15.218: Jun 03, 2016 New module swad_MFU for most frequently used actions. Version 15.218: Jun 03, 2016 New module swad_MFU for most frequently used actions.
Change in layout of most frequent actions. (201934 lines) Change in layout of most frequent actions. (201934 lines)

View File

@ -83,7 +83,8 @@ void Gbl_InitializeGlobals (void)
extern const unsigned Txt_Current_CGI_SWAD_Language; extern const unsigned Txt_Current_CGI_SWAD_Language;
Txt_Language_t Lan; Txt_Language_t Lan;
setlocale (LC_ALL,"es_ES.utf8"); if (!setlocale (LC_NUMERIC,"es_ES.utf8"))
exit (1);
gettimeofday (&Gbl.tvStart, &Gbl.tz); gettimeofday (&Gbl.tvStart, &Gbl.tz);
Dat_GetStartExecutionTimeUTC (); Dat_GetStartExecutionTimeUTC ();

View File

@ -867,10 +867,12 @@ float Str_GetFloatNumFromStr (const char *Str)
if (Str) if (Str)
{ {
setlocale (LC_NUMERIC,"en_US.utf8"); // To get the decimal point if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To get the decimal point
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
if (sscanf (Str,"%f",&Num) != 1) if (sscanf (Str,"%f",&Num) != 1)
Lay_ShowErrorAndExit ("Bad floating point format."); Lay_ShowErrorAndExit ("Bad floating point format.");
setlocale (LC_NUMERIC,"es_ES.utf8"); if (!setlocale (LC_NUMERIC,"es_ES.utf8"))
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
} }
else // Str == NULL else // Str == NULL
Num = 0.0; Num = 0.0;

View File

@ -1172,7 +1172,8 @@ static void Tst_UpdateScoreQst (long QstCod,float ScoreThisQst,bool AnswerIsNotB
char Query[512]; char Query[512];
/***** Update number of clicks and score of the question *****/ /***** Update number of clicks and score of the question *****/
setlocale (LC_NUMERIC,"en_US.utf8"); // To print the floating point as a dot if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To print the floating point as a dot
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
if (AnswerIsNotBlank) if (AnswerIsNotBlank)
sprintf (Query,"UPDATE tst_questions" sprintf (Query,"UPDATE tst_questions"
" SET NumHits=NumHits+1,NumHitsNotBlank=NumHitsNotBlank+1,Score=Score+(%lf)" " SET NumHits=NumHits+1,NumHitsNotBlank=NumHitsNotBlank+1,Score=Score+(%lf)"
@ -1183,7 +1184,8 @@ static void Tst_UpdateScoreQst (long QstCod,float ScoreThisQst,bool AnswerIsNotB
" SET NumHits=NumHits+1" " SET NumHits=NumHits+1"
" WHERE QstCod='%ld'", " WHERE QstCod='%ld'",
QstCod); QstCod);
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
DB_QueryUPDATE (Query,"can not update the score of a question"); DB_QueryUPDATE (Query,"can not update the score of a question");
} }
@ -2842,10 +2844,12 @@ static void Tst_ListOneOrMoreQuestionsToEdit (unsigned long NumRows,MYSQL_RES *m
Lay_ShowErrorAndExit ("Wrong number of hits not blank to a question."); Lay_ShowErrorAndExit ("Wrong number of hits not blank to a question.");
/* Get the acumulated score of the question (row[11]) */ /* Get the acumulated score of the question (row[11]) */
setlocale (LC_NUMERIC,"en_US.utf8"); // To get decimal point if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To get the decimal point
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
if (sscanf (row[11],"%lf",&TotalScoreThisQst) != 1) if (sscanf (row[11],"%lf",&TotalScoreThisQst) != 1)
Lay_ShowErrorAndExit ("Wrong score of a question."); Lay_ShowErrorAndExit ("Wrong score of a question.");
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
/* Write number of times this question has been answered */ /* Write number of times this question has been answered */
fprintf (Gbl.F.Out,"<td class=\"DAT_SMALL CENTER_TOP COLOR%u\">" fprintf (Gbl.F.Out,"<td class=\"DAT_SMALL CENTER_TOP COLOR%u\">"
@ -5622,13 +5626,15 @@ double Tst_GetFloatAnsFromStr (char *Str)
Str_ConvertStrFloatCommaToStrFloatPoint (Str); Str_ConvertStrFloatCommaToStrFloatPoint (Str);
/***** The string is "scanned" in floating point (it must have a point, not a colon as decimal separator) *****/ /***** The string is "scanned" in floating point (it must have a point, not a colon as decimal separator) *****/
setlocale (LC_NUMERIC,"en_US.utf8"); // To get decimal point if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To get the decimal point
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
if (sscanf (Str,"%lg",&DoubleNum) != 1) // If the string does not hold a valid floating point number... if (sscanf (Str,"%lg",&DoubleNum) != 1) // If the string does not hold a valid floating point number...
{ {
DoubleNum = 0.0; // ...the number is reset to 0 DoubleNum = 0.0; // ...the number is reset to 0
Str[0] = '\0'; // ...and the string is reset to "" Str[0] = '\0'; // ...and the string is reset to ""
} }
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
return DoubleNum; return DoubleNum;
} }
@ -6046,7 +6052,8 @@ static void Tst_InsertAnswersIntoDB (void)
DB_QueryINSERT (Query,"can not create answer"); DB_QueryINSERT (Query,"can not create answer");
break; break;
case Tst_ANS_FLOAT: case Tst_ANS_FLOAT:
setlocale (LC_NUMERIC,"en_US.utf8"); // To print the floating point as a dot if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To print the floating point as a dot
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
for (i = 0; for (i = 0;
i < 2; i < 2;
i++) i++)
@ -6059,7 +6066,8 @@ static void Tst_InsertAnswersIntoDB (void)
Gbl.Test.Answer.FloatingPoint[i]); Gbl.Test.Answer.FloatingPoint[i]);
DB_QueryINSERT (Query,"can not create answer"); DB_QueryINSERT (Query,"can not create answer");
} }
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
break; break;
case Tst_ANS_TRUE_FALSE: case Tst_ANS_TRUE_FALSE:
sprintf (Query,"INSERT INTO tst_answers" sprintf (Query,"INSERT INTO tst_answers"
@ -6482,10 +6490,12 @@ static unsigned Tst_GetNumTstQuestions (Sco_Scope_t Scope,Tst_AnswerType_t AnsTy
if (sscanf (row[1],"%lu",&(Stats->NumHits)) != 1) if (sscanf (row[1],"%lu",&(Stats->NumHits)) != 1)
Lay_ShowErrorAndExit ("Error when getting total number of hits in test questions."); Lay_ShowErrorAndExit ("Error when getting total number of hits in test questions.");
setlocale (LC_NUMERIC,"en_US.utf8"); // To get decimal point if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To get the decimal point
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
if (sscanf (row[2],"%lf",&(Stats->TotalScore)) != 1) if (sscanf (row[2],"%lf",&(Stats->TotalScore)) != 1)
Lay_ShowErrorAndExit ("Error when getting total score in test questions."); Lay_ShowErrorAndExit ("Error when getting total score in test questions.");
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
} }
else else
{ {
@ -6938,13 +6948,15 @@ static void Tst_StoreScoreOfTestExamInDB (long TstCod,
char Query[256]; char Query[256];
/***** Update score in test exam *****/ /***** Update score in test exam *****/
setlocale (LC_NUMERIC,"en_US.utf8"); // To print the floating point as a dot if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To print the floating point as a dot
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
sprintf (Query,"UPDATE tst_exams" sprintf (Query,"UPDATE tst_exams"
" SET NumQstsNotBlank='%u',Score='%lf'" " SET NumQstsNotBlank='%u',Score='%lf'"
" WHERE TstCod='%ld'", " WHERE TstCod='%ld'",
NumQstsNotBlank,Score, NumQstsNotBlank,Score,
TstCod); TstCod);
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
DB_QueryUPDATE (Query,"can not update result of test exam"); DB_QueryUPDATE (Query,"can not update result of test exam");
} }
@ -7174,7 +7186,8 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat)
NumQstsNotBlankInThisExam = 0; NumQstsNotBlankInThisExam = 0;
/* Get score (row[5]) */ /* Get score (row[5]) */
setlocale (LC_NUMERIC,"en_US.utf8"); // To get decimal point if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To get the decimal point
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
if (sscanf (row[5],"%lf",&ScoreInThisExam) == 1) if (sscanf (row[5],"%lf",&ScoreInThisExam) == 1)
{ {
if (Gbl.Test.AllowTeachers) if (Gbl.Test.AllowTeachers)
@ -7182,7 +7195,8 @@ static void Tst_ShowResultsOfTestExams (struct UsrData *UsrDat)
} }
else else
ScoreInThisExam = 0.0; ScoreInThisExam = 0.0;
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
/* Write number of questions */ /* Write number of questions */
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_TOP COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_TOP COLOR%u\">",
@ -7687,10 +7701,12 @@ static void Tst_GetExamDataByTstCod (long TstCod,time_t *TstTimeUTC,
*NumQstsNotBlank = 0; *NumQstsNotBlank = 0;
/* Get score (row[5]) */ /* Get score (row[5]) */
setlocale (LC_NUMERIC,"en_US.utf8"); // To get decimal point if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To get the decimal point
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
if (sscanf (row[5],"%lf",Score) != 1) if (sscanf (row[5],"%lf",Score) != 1)
*Score = 0.0; *Score = 0.0;
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -7713,7 +7729,8 @@ static void Tst_StoreOneExamQstInDB (long TstCod,long QstCod,unsigned NumQst,dou
Par_ReplaceSeparatorMultipleByComma (Gbl.Test.StrAnswersOneQst[NumQst],Answers); Par_ReplaceSeparatorMultipleByComma (Gbl.Test.StrAnswersOneQst[NumQst],Answers);
/***** Insert question and user's answers into database *****/ /***** Insert question and user's answers into database *****/
setlocale (LC_NUMERIC,"en_US.utf8"); // To print the floating point as a dot if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To print the floating point as a dot
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
sprintf (Query,"INSERT INTO tst_exam_questions" sprintf (Query,"INSERT INTO tst_exam_questions"
" (TstCod,QstCod,QstInd,Score,Indexes,Answers)" " (TstCod,QstCod,QstInd,Score,Indexes,Answers)"
" VALUES ('%ld','%ld','%u','%lf','%s','%s')", " VALUES ('%ld','%ld','%u','%lf','%s','%s')",
@ -7722,7 +7739,8 @@ static void Tst_StoreOneExamQstInDB (long TstCod,long QstCod,unsigned NumQst,dou
Score, Score,
Indexes, Indexes,
Answers); Answers);
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
DB_QueryINSERT (Query,"can not insert a question of an exam"); DB_QueryINSERT (Query,"can not insert a question of an exam");
} }

View File

@ -3736,7 +3736,8 @@ int swad__getTrivialQuestion (struct soap *soap,
"lowerScore or upperScore values not valid"); "lowerScore or upperScore values not valid");
/***** Start query *****/ /***** Start query *****/
setlocale (LC_NUMERIC,"en_US.utf8"); // To print the floating point as a dot if (!setlocale (LC_NUMERIC,"en_US.utf8")) // To print the floating point as a dot
Lay_ShowAlert (Lay_ERROR,"Can not set locale to en_US.");
sprintf (Query,"SELECT DISTINCTROW tst_questions.QstCod," sprintf (Query,"SELECT DISTINCTROW tst_questions.QstCod,"
"tst_questions.AnsType,tst_questions.Shuffle," "tst_questions.AnsType,tst_questions.Shuffle,"
"tst_questions.Stem,tst_questions.Feedback," "tst_questions.Stem,tst_questions.Feedback,"
@ -3757,7 +3758,8 @@ int swad__getTrivialQuestion (struct soap *soap,
" ORDER BY RAND(NOW()) LIMIT 1", " ORDER BY RAND(NOW()) LIMIT 1",
DegreesStr,DegreesStr, DegreesStr,DegreesStr,
lowerScore,upperScore); lowerScore,upperScore);
setlocale (LC_NUMERIC,"es_ES.utf8"); // Return to spanish system (TODO: this should be internationalized!!!!!!!) if (!setlocale (LC_NUMERIC,"es_ES.utf8")) // Return to spanish system (TODO: this should be internationalized!!!!!!!)
Lay_ShowAlert (Lay_ERROR,"Can not set locale to es_ES.");
NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get test questions"); NumRows = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get test questions");