diff --git a/swad_HTML.c b/swad_HTML.c
index e3c53d39..3e83f001 100644
--- a/swad_HTML.c
+++ b/swad_HTML.c
@@ -1770,6 +1770,21 @@ void HTM_Long (long Num)
}
void HTM_Double (double Num)
+ {
+ char *Str;
+
+ /***** Write from floating point number to string
+ with the correct accuracy *****/
+ Str_DoubleNumToStr (&Str,Num);
+
+ /***** Write number from string to file *****/
+ HTM_Txt (Str);
+
+ /***** Free memory allocated for string *****/
+ free (Str);
+ }
+
+void HTM_Double2Decimals (double Num)
{
HTM_TxtF ("%.2lf",Num);
}
diff --git a/swad_HTML.h b/swad_HTML.h
index e82dc8c4..b701187f 100644
--- a/swad_HTML.h
+++ b/swad_HTML.h
@@ -179,6 +179,7 @@ void HTM_Int (int Num);
void HTM_UnsignedLong (unsigned long Num);
void HTM_Long (long Num);
void HTM_Double (double Num);
+void HTM_Double2Decimals (double Num);
void HTM_Percentage (double Percentage);
#endif
diff --git a/swad_changelog.h b/swad_changelog.h
index f72d92f8..24d22e96 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -490,13 +490,14 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
-#define Log_PLATFORM_VERSION "SWAD 19.91.1 (2019-12-14)"
+#define Log_PLATFORM_VERSION "SWAD 19.91.2 (2019-12-14)"
#define CSS_FILE "swad19.90.1.css"
#define JS_FILE "swad19.91.1.js"
/*
// TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.)
// TODO: Impedir la creación y edición de proyectos si no son editables.
+ Version 19.91.2: Dec 14, 2019 Code refactoring related to doubles. (248538 lines)
Version 19.91.1: Dec 14, 2019 Changes in match layout. (248533 lines)
Version 19.91: Dec 13, 2019 Changes in match countdown.
Code refactoring in HTML. (248513 lines)
diff --git a/swad_figure.c b/swad_figure.c
index 80cc936e..b6f20d1d 100644
--- a/swad_figure.c
+++ b/swad_figure.c
@@ -436,11 +436,11 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role)
HTM_TD_End ();
HTM_TD_Begin ("class=\"%s\"",Class);
- HTM_Double (NumCrssPerUsr);
+ HTM_Double2Decimals (NumCrssPerUsr);
HTM_TD_End ();
HTM_TD_Begin ("class=\"%s\"",Class);
- HTM_Double (NumUsrsPerCrs);
+ HTM_Double2Decimals (NumUsrsPerCrs);
HTM_TD_End ();
HTM_TR_End ();
@@ -467,11 +467,11 @@ static void Fig_GetAndShowNumUsrsNotBelongingToAnyCrs (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"%s\"",Class);
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
HTM_TD_End ();
HTM_TD_Begin ("class=\"%s\"",Class);
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
HTM_TD_End ();
HTM_TR_End ();
@@ -2979,7 +2979,7 @@ static void Fig_GetAndShowAssignmentsStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (NumAssignmentsPerCourse);
+ HTM_Double2Decimals (NumAssignmentsPerCourse);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
@@ -3038,7 +3038,7 @@ static void Fig_GetAndShowProjectsStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (NumProjectsPerCourse);
+ HTM_Double2Decimals (NumProjectsPerCourse);
HTM_TD_End ();
HTM_TR_End ();
@@ -3119,7 +3119,7 @@ static void Fig_GetAndShowTestsStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (Stats.AvgQstsPerCourse);
+ HTM_Double2Decimals (Stats.AvgQstsPerCourse);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
@@ -3127,15 +3127,15 @@ static void Fig_GetAndShowTestsStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (Stats.AvgHitsPerCourse);
+ HTM_Double2Decimals (Stats.AvgHitsPerCourse);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (Stats.AvgHitsPerQuestion);
+ HTM_Double2Decimals (Stats.AvgHitsPerQuestion);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (Stats.AvgScorePerQuestion);
+ HTM_Double2Decimals (Stats.AvgScorePerQuestion);
HTM_TD_End ();
HTM_TR_End ();
@@ -3168,7 +3168,7 @@ static void Fig_GetAndShowTestsStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (Stats.AvgQstsPerCourse);
+ HTM_Double2Decimals (Stats.AvgQstsPerCourse);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
@@ -3176,15 +3176,15 @@ static void Fig_GetAndShowTestsStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (Stats.AvgHitsPerCourse);
+ HTM_Double2Decimals (Stats.AvgHitsPerCourse);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (Stats.AvgHitsPerQuestion);
+ HTM_Double2Decimals (Stats.AvgHitsPerQuestion);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (Stats.AvgScorePerQuestion);
+ HTM_Double2Decimals (Stats.AvgScorePerQuestion);
HTM_TD_End ();
HTM_TR_End ();
@@ -3238,7 +3238,7 @@ static void Fig_GetAndShowGamesStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (NumGamesPerCourse);
+ HTM_Double2Decimals (NumGamesPerCourse);
HTM_TD_End ();
HTM_TR_End ();
@@ -3420,7 +3420,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (NumUsrs ? (double) NumNotes / (double) NumUsrs :
+ HTM_Double2Decimals (NumUsrs ? (double) NumNotes / (double) NumUsrs :
0.0);
HTM_TD_End ();
@@ -3540,7 +3540,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (NumUsrs ? (double) NumNotes / (double) NumUsrs :
+ HTM_Double2Decimals (NumUsrs ? (double) NumNotes / (double) NumUsrs :
0.0);
HTM_TD_End ();
@@ -3824,7 +3824,7 @@ static void Fig_GetAndShowFollowStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (Average);
+ HTM_Double2Decimals (Average);
HTM_TD_End ();
HTM_TD_Empty (1);
@@ -4100,15 +4100,15 @@ static void Fig_WriteForumTitleAndStats (For_ForumType_t ForumType,
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RT\"");
- HTM_Double (NumThrsPerForum);
+ HTM_Double2Decimals (NumThrsPerForum);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RT\"");
- HTM_Double (NumPostsPerThread);
+ HTM_Double2Decimals (NumPostsPerThread);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RT\"");
- HTM_Double (NumPostsPerForum);
+ HTM_Double2Decimals (NumPostsPerForum);
HTM_TD_End ();
HTM_TR_End ();
@@ -4163,15 +4163,15 @@ static void Fig_WriteForumTotalStats (struct Fig_FiguresForum *FiguresForum)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (NumThrsPerForum);
+ HTM_Double2Decimals (NumThrsPerForum);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (NumPostsPerThread);
+ HTM_Double2Decimals (NumPostsPerThread);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM\"");
- HTM_Double (NumPostsPerForum);
+ HTM_Double2Decimals (NumPostsPerForum);
HTM_TD_End ();
HTM_TR_End ();
@@ -4628,11 +4628,11 @@ static void Fig_GetAndShowSurveysStats (void)
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (NumSurveysPerCourse);
+ HTM_Double2Decimals (NumSurveysPerCourse);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
- HTM_Double (NumQstsPerSurvey);
+ HTM_Double2Decimals (NumQstsPerSurvey);
HTM_TD_End ();
HTM_TD_Begin ("class=\"DAT RM\"");
diff --git a/swad_match.c b/swad_match.c
index 36ae2b3f..c57f193e 100644
--- a/swad_match.c
+++ b/swad_match.c
@@ -3140,12 +3140,12 @@ static void Mch_DrawEmptyScoreRow (unsigned NumRow,double MinScore,double MaxSco
HTM_TD_Begin ("class=\"MCH_SCO_SCO\"");
if (NumRow == 0)
{
- Str_WriteDoubleNumToFile (Gbl.F.Out,MaxScore);
+ HTM_Double (MaxScore);
HTM_NBSP ();
}
else if (NumRow == Mch_NUM_ROWS_SCORE - 1)
{
- Str_WriteDoubleNumToFile (Gbl.F.Out,MinScore);
+ HTM_Double (MinScore);
HTM_NBSP ();
}
HTM_TD_End ();
@@ -3214,7 +3214,7 @@ static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
/* Write score */
HTM_TD_Begin ("class=\"MCH_SCO_SCO\"");
- Str_WriteDoubleNumToFile (Gbl.F.Out,Score);
+ HTM_Double (Score);
HTM_NBSP ();
HTM_TD_End ();
diff --git a/swad_match_result.c b/swad_match_result.c
index f48ce00d..6dbc17c2 100644
--- a/swad_match_result.c
+++ b/swad_match_result.c
@@ -850,7 +850,7 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther,
/* Write score */
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
if (ShowResultThisMatch)
- HTM_Double (ScoreInThisResult);
+ HTM_Double2Decimals (ScoreInThisResult);
else
Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_results);
HTM_TD_End ();
@@ -858,7 +858,7 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther,
/* Write average score per question */
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
if (ShowResultThisMatch)
- HTM_Double (NumQstsInThisResult ? ScoreInThisResult /
+ HTM_Double2Decimals (NumQstsInThisResult ? ScoreInThisResult /
(double) NumQstsInThisResult :
0.0);
else
@@ -958,18 +958,18 @@ static void McR_ShowMchResultsSummaryRow (unsigned NumResults,
/***** Write total score *****/
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
- HTM_Double (TotalScoreOfAllResults);
+ HTM_Double2Decimals (TotalScoreOfAllResults);
HTM_TD_End ();
/***** Write average score per question *****/
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
- HTM_Double (NumTotalQsts ? TotalScoreOfAllResults / (double) NumTotalQsts :
+ HTM_Double2Decimals (NumTotalQsts ? TotalScoreOfAllResults / (double) NumTotalQsts :
0.0);
HTM_TD_End ();
/***** Write total grade *****/
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
- HTM_Double (TotalGrade);
+ HTM_Double2Decimals (TotalGrade);
HTM_TD_End ();
/***** Last cell *****/
@@ -1187,7 +1187,7 @@ void McR_ShowOneMchResult (void)
HTM_TD_Begin ("class=\"DAT LT\"");
if (ICanViewScore)
- HTM_Double (TotalScore);
+ HTM_Double2Decimals (TotalScore);
else
HTM_Txt ("?"); // No feedback
HTM_TD_End ();
@@ -1234,7 +1234,7 @@ void McR_ShowOneMchResult (void)
{
HTM_DIV_Begin ("class=\"DAT_N_BOLD CM\"");
HTM_TxtF ("%s: ",Txt_Score);
- HTM_Double (TotalScore);
+ HTM_Double2Decimals (TotalScore);
HTM_BR ();
HTM_TxtF ("%s: ",Txt_Grade);
Tst_ComputeAndShowGrade (NumQsts,TotalScore,Game.MaxGrade);
diff --git a/swad_profile.c b/swad_profile.c
index 033370b2..3dc1e3af 100644
--- a/swad_profile.c
+++ b/swad_profile.c
@@ -601,9 +601,8 @@ static void Prf_ShowNumClicks (const struct UsrData *UsrDat,
if (UsrFigures->NumDays > 0)
{
HTM_TxtF (" %s","(");
- Str_WriteDoubleNumToFile (Gbl.F.Out,
- (double) UsrFigures->NumClicks /
- (double) UsrFigures->NumDays);
+ HTM_Double ((double) UsrFigures->NumClicks /
+ (double) UsrFigures->NumDays);
HTM_TxtF ("/%s ",Txt_day);
Prf_ShowRanking (Prf_GetRankingNumClicksPerDay (UsrDat->UsrCod),
Prf_GetNumUsrsWithNumClicksPerDay ());
@@ -642,9 +641,8 @@ static void Prf_ShowNumFileViews (const struct UsrData *UsrDat,
if (UsrFigures->NumDays > 0)
{
HTM_TxtF (" %s","(");
- Str_WriteDoubleNumToFile (Gbl.F.Out,
- (double) UsrFigures->NumFileViews /
- (double) UsrFigures->NumDays);
+ HTM_Double ((double) UsrFigures->NumFileViews /
+ (double) UsrFigures->NumDays);
HTM_TxtF ("/%s)",Txt_day);
}
}
@@ -680,9 +678,8 @@ static void Prf_ShowNumSocialPublications (const struct UsrData *UsrDat,
if (UsrFigures->NumDays > 0)
{
HTM_TxtF (" %s","(");
- Str_WriteDoubleNumToFile (Gbl.F.Out,
- (double) UsrFigures->NumSocPub /
- (double) UsrFigures->NumDays);
+ HTM_Double ((double) UsrFigures->NumSocPub /
+ (double) UsrFigures->NumDays);
HTM_TxtF ("/%s)",Txt_day);
}
}
@@ -718,9 +715,8 @@ static void Prf_ShowNumForumPosts (const struct UsrData *UsrDat,
if (UsrFigures->NumDays > 0)
{
HTM_TxtF (" %s","(");
- Str_WriteDoubleNumToFile (Gbl.F.Out,
- (double) UsrFigures->NumForPst /
- (double) UsrFigures->NumDays);
+ HTM_Double ((double) UsrFigures->NumForPst /
+ (double) UsrFigures->NumDays);
HTM_TxtF ("/%s)",Txt_day);
}
}
@@ -756,9 +752,8 @@ static void Prf_ShowNumMessagesSent (const struct UsrData *UsrDat,
if (UsrFigures->NumDays > 0)
{
HTM_TxtF (" %s","(");
- Str_WriteDoubleNumToFile (Gbl.F.Out,
- (double) UsrFigures->NumMsgSnt /
- (double) UsrFigures->NumDays);
+ HTM_Double ((double) UsrFigures->NumMsgSnt /
+ (double) UsrFigures->NumDays);
HTM_TxtF ("/%s)",Txt_day);
}
}
@@ -1730,7 +1725,7 @@ void Prf_GetAndShowRankingClicksPerDay (void)
ItsMe ? "DAT_SMALL_N" :
"DAT_SMALL",
Gbl.RowEvenOdd);
- Str_WriteDoubleNumToFile (Gbl.F.Out,NumClicksPerDay);
+ HTM_Double (NumClicksPerDay);
HTM_TD_End ();
HTM_TR_End ();
}
diff --git a/swad_report.c b/swad_report.c
index 773e5494..dcf22517 100644
--- a/swad_report.c
+++ b/swad_report.c
@@ -140,6 +140,8 @@ static void Rep_ComputeMaxAndTotalHits (struct Rep_Hits *Hits,
static void Rep_DrawBarNumHits (unsigned long HitsNum,unsigned long HitsMax,
unsigned MaxBarWidth);
+static void Rep_WriteDouble (double Num);
+
static void Rep_RemoveUsrReportsFiles (long UsrCod);
static void Rep_RemoveUsrReportsFromDB (long UsrCod);
@@ -651,9 +653,8 @@ static void Rep_WriteSectionUsrFigures (const struct Rep_Report *Report)
if (Report->UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Rep," (");
- Str_WriteDoubleNumToFile (Gbl.F.Rep,
- (double) Report->UsrFigures.NumClicks /
- (double) Report->UsrFigures.NumDays);
+ Rep_WriteDouble ((double) Report->UsrFigures.NumClicks /
+ (double) Report->UsrFigures.NumDays);
fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
@@ -686,9 +687,8 @@ static void Rep_WriteSectionUsrFigures (const struct Rep_Report *Report)
if (Report->UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Rep," (");
- Str_WriteDoubleNumToFile (Gbl.F.Rep,
- (double) Report->UsrFigures.NumFileViews /
- (double) Report->UsrFigures.NumDays);
+ Rep_WriteDouble ((double) Report->UsrFigures.NumFileViews /
+ (double) Report->UsrFigures.NumDays);
fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
@@ -707,9 +707,8 @@ static void Rep_WriteSectionUsrFigures (const struct Rep_Report *Report)
if (Report->UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Rep," (");
- Str_WriteDoubleNumToFile (Gbl.F.Rep,
- (double) Report->UsrFigures.NumForPst /
- (double) Report->UsrFigures.NumDays);
+ Rep_WriteDouble ((double) Report->UsrFigures.NumForPst /
+ (double) Report->UsrFigures.NumDays);
fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
@@ -728,9 +727,8 @@ static void Rep_WriteSectionUsrFigures (const struct Rep_Report *Report)
if (Report->UsrFigures.NumDays > 0)
{
fprintf (Gbl.F.Rep," (");
- Str_WriteDoubleNumToFile (Gbl.F.Rep,
- (double) Report->UsrFigures.NumMsgSnt /
- (double) Report->UsrFigures.NumDays);
+ Rep_WriteDouble ((double) Report->UsrFigures.NumMsgSnt /
+ (double) Report->UsrFigures.NumDays);
fprintf (Gbl.F.Rep," / %s)",Txt_day);
}
}
@@ -1378,7 +1376,7 @@ static void Rep_DrawBarNumHits (unsigned long HitsNum,unsigned long HitsMax,
/***** Write the number of hits *****/
fprintf (Gbl.F.Rep," ");
- Str_WriteDoubleNumToFile (Gbl.F.Rep,HitsNum);
+ Rep_WriteDouble (HitsNum);
}
}
@@ -1386,6 +1384,25 @@ static void Rep_DrawBarNumHits (unsigned long HitsNum,unsigned long HitsMax,
/********** Remove all user's usage report of a user from database ***********/
/*****************************************************************************/
+static void Rep_WriteDouble (double Num)
+ {
+ char *Str;
+
+ /***** Write from floating point number to string
+ with the correct accuracy *****/
+ Str_DoubleNumToStr (&Str,Num);
+
+ /***** Write number from string to file *****/
+ fputs (Str,Gbl.F.Rep);
+
+ /***** Free memory allocated for string *****/
+ free (Str);
+ }
+
+/*****************************************************************************/
+/********** Remove all user's usage report of a user from database ***********/
+/*****************************************************************************/
+
void Rep_RemoveUsrUsageReports (long UsrCod)
{
/***** Remove all user's usage report files of a user *****/
diff --git a/swad_statistic.c b/swad_statistic.c
index 718ad285..12cf4b32 100644
--- a/swad_statistic.c
+++ b/swad_statistic.c
@@ -1888,7 +1888,7 @@ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,MYSQL_RES *mysql_res)
BarWidth);
HTM_NBSP ();
}
- Str_WriteDoubleNumToFile (Gbl.F.Out,Hits.Num);
+ HTM_Double (Hits.Num);
HTM_TD_End ();
HTM_TR_End ();
@@ -2338,14 +2338,14 @@ static void Sta_DrawBarColors (Sta_ColorType_t ColorType,double HitsMax)
HTM_TD_Begin ("colspan=\"%u\" class=\"LOG CB\" style=\"width:%upx;\"",
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5,
GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5);
- Str_WriteDoubleNumToFile (Gbl.F.Out,(double) Interval * HitsMax / 5.0);
+ HTM_Double ((double) Interval * HitsMax / 5.0);
HTM_TD_End ();
}
HTM_TD_Begin ("colspan=\"%u\" class=\"LOG RB\" style=\"width:%upx;\"",
(GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5)/2,
(GRAPH_DISTRIBUTION_PER_HOUR_TOTAL_WIDTH/5)/2);
- Str_WriteDoubleNumToFile (Gbl.F.Out,HitsMax);
+ HTM_Double (HitsMax);
HTM_TD_End ();
HTM_TR_End ();
@@ -2857,7 +2857,7 @@ static void Sta_WriteAccessHour (unsigned Hour,struct Sta_Hits *Hits,unsigned Co
HTM_TxtF ("%u%%",(unsigned) (((Hits->Num * 100.0) /
Hits->Total) + 0.5));
HTM_BR ();
- Str_WriteDoubleNumToFile (Gbl.F.Out,Hits->Num);
+ HTM_Double (Hits->Num);
HTM_BR ();
BarHeight = (unsigned) (((Hits->Num * 500.0) / Hits->Max) + 0.5);
if (BarHeight == 0)
@@ -3860,7 +3860,7 @@ static void Sta_DrawBarNumHits (char Color,
/***** Write the number of hits *****/
HTM_NBSP ();
- Str_WriteDoubleNumToFile (Gbl.F.Out,HitsNum);
+ HTM_Double (HitsNum);
HTM_TxtF (" (%u",(unsigned) (((HitsNum * 100.0) /
HitsTotal) + 0.5));
}
diff --git a/swad_string.c b/swad_string.c
index 9eb0f9d5..78fb9373 100644
--- a/swad_string.c
+++ b/swad_string.c
@@ -857,24 +857,6 @@ char Str_ConvertToLowerLetter (char Ch)
}
}
-/*****************************************************************************/
-/*** Write a number in floating point with the correct accuracy to a file ****/
-/*****************************************************************************/
-
-void Str_WriteDoubleNumToFile (FILE *FileDst,double Number)
- {
- char *Str;
-
- /***** Write from floating point number to string *****/
- Str_DoubleNumToStr (&Str,Number);
-
- /***** Write number from string to file *****/
- fprintf (FileDst,"%s",Str);
-
- /***** Free memory allocated for string *****/
- free (Str);
- }
-
/*****************************************************************************/
/** Write a number in floating point with the correct accuracy to a string ***/
/*****************************************************************************/
diff --git a/swad_string.h b/swad_string.h
index 9e5f91d8..f782fe36 100644
--- a/swad_string.h
+++ b/swad_string.h
@@ -91,7 +91,6 @@ char *Str_ConvertToLowerText (char *Str);
char Str_ConvertToUpperLetter (char Ch);
char Str_ConvertToLowerLetter (char Ch);
-void Str_WriteDoubleNumToFile (FILE *FileDst,double Number);
void Str_DoubleNumToStr (char **Str,double Number);
void Str_ConvertStrFloatCommaToStrFloatPoint (char *Str);
double Str_GetDoubleFromStr (char *Str);
diff --git a/swad_test.c b/swad_test.c
index 857d8f27..5893bc07 100644
--- a/swad_test.c
+++ b/swad_test.c
@@ -537,7 +537,7 @@ void Tst_AssessTest (void)
{
HTM_DIV_Begin ("class=\"DAT_N_BOLD CM\"");
HTM_TxtF ("%s: ",Txt_Score);
- HTM_Double (TotalScore);
+ HTM_Double2Decimals (TotalScore);
HTM_BR ();
HTM_TxtF ("%s: ",Txt_Grade);
Tst_ComputeAndShowGrade (Gbl.Test.NumQsts,TotalScore,Tst_SCORE_MAX);
@@ -639,9 +639,9 @@ double Tst_ComputeGrade (unsigned NumQsts,double Score,double MaxGrade)
void Tst_ShowGrade (double Grade,double MaxGrade)
{
/***** Write grade over maximum grade *****/
- HTM_Double (Grade);
+ HTM_Double2Decimals (Grade);
HTM_Txt ("/");
- HTM_Double (MaxGrade);
+ HTM_Double2Decimals (MaxGrade);
}
/*****************************************************************************/
@@ -2999,7 +2999,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (unsigned long NumRows,
/* Write average score */
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
if (NumHitsThisQst)
- HTM_Double (TotalScoreThisQst / (double) NumHitsThisQst);
+ HTM_Double2Decimals (TotalScoreThisQst / (double) NumHitsThisQst);
else
HTM_Txt ("N.A.");
HTM_TD_End ();
@@ -3012,7 +3012,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (unsigned long NumRows,
/* Write average score (not blank) */
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
if (NumHitsNotBlankThisQst)
- HTM_Double (TotalScoreThisQst / (double) NumHitsNotBlankThisQst);
+ HTM_Double2Decimals (TotalScoreThisQst / (double) NumHitsNotBlankThisQst);
else
HTM_Txt ("N.A.");
HTM_TD_End ();
@@ -3633,17 +3633,17 @@ static void Tst_WriteTFAnsAssessTest (struct UsrData *UsrDat,
if (AnsTF == '\0') // If user has omitted the answer
{
HTM_SPAN_Begin ("class=\"ANS_0\"");
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
}
else if (AnsTF == row[1][0]) // If correct
{
HTM_SPAN_Begin ("class=\"ANS_OK\"");
- HTM_Double (1.0);
+ HTM_Double2Decimals (1.0);
}
else // If wrong
{
HTM_SPAN_Begin ("class=\"ANS_BAD\"");
- HTM_Double (-1.0);
+ HTM_Double2Decimals (-1.0);
}
HTM_SPAN_End ();
Tst_WriteScoreEnd ();
@@ -3905,7 +3905,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
HTM_SPAN_Begin ("class=\"ANS_OK\"");
else
HTM_SPAN_Begin ("class=\"ANS_BAD\"");
- HTM_Double (*ScoreThisQst);
+ HTM_Double2Decimals (*ScoreThisQst);
HTM_SPAN_End ();
Tst_WriteScoreEnd ();
}
@@ -4421,17 +4421,17 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
{
HTM_SPAN_Begin ("class=\"ANS_0\"");
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
}
else if (Correct) // If correct
{
HTM_SPAN_Begin ("class=\"ANS_OK\"");
- HTM_Double (1.0);
+ HTM_Double2Decimals (1.0);
}
else // If wrong
{
HTM_SPAN_Begin ("class=\"ANS_BAD\"");
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
}
HTM_SPAN_End ();
Tst_WriteScoreEnd ();
@@ -4550,17 +4550,17 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat,
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
{
HTM_SPAN_Begin ("class=\"ANS_0\"");
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
}
else if (IntAnswerUsr == IntAnswerCorr) // If correct
{
HTM_SPAN_Begin ("class=\"ANS_OK\"");
- HTM_Double (1.0);
+ HTM_Double2Decimals (1.0);
}
else // If wrong
{
HTM_SPAN_Begin ("class=\"ANS_BAD\"");
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
}
HTM_SPAN_End ();
Tst_WriteScoreEnd ();
@@ -4693,18 +4693,18 @@ static void Tst_WriteFloatAnsAssessTest (struct UsrData *UsrDat,
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
{
HTM_SPAN_Begin ("class=\"ANS_0\"");
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
}
else if (FloatAnsUsr >= FloatAnsCorr[0] &&
FloatAnsUsr <= FloatAnsCorr[1]) // If correct (inside the interval)
{
HTM_SPAN_Begin ("class=\"ANS_OK\"");
- HTM_Double (1.0);
+ HTM_Double2Decimals (1.0);
}
else // If wrong (outside the interval)
{
HTM_SPAN_Begin ("class=\"ANS_BAD\"");
- HTM_Double (0.0);
+ HTM_Double2Decimals (0.0);
}
HTM_SPAN_End ();
Tst_WriteScoreEnd ();
@@ -7744,13 +7744,13 @@ static void Tst_ShowTstResults (struct UsrData *UsrDat)
/* Write score */
HTM_TD_Begin ("class=\"%s RT COLOR%u\"",ClassDat,Gbl.RowEvenOdd);
if (ICanViewScore)
- HTM_Double (ScoreInThisTest);
+ HTM_Double2Decimals (ScoreInThisTest);
HTM_TD_End ();
/* Write average score per question */
HTM_TD_Begin ("class=\"%s RT COLOR%u\"",ClassDat,Gbl.RowEvenOdd);
if (ICanViewScore)
- HTM_Double (NumQstsInThisTest ? ScoreInThisTest /
+ HTM_Double2Decimals (NumQstsInThisTest ? ScoreInThisTest /
(double) NumQstsInThisTest :
0.0);
HTM_TD_End ();
@@ -7873,13 +7873,13 @@ static void Tst_ShowTestResultsSummaryRow (bool ItsMe,
/***** Write total score *****/
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
if (ICanViewTotalScore)
- HTM_Double (TotalScoreOfAllTests);
+ HTM_Double2Decimals (TotalScoreOfAllTests);
HTM_TD_End ();
/***** Write average score per question *****/
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
if (ICanViewTotalScore)
- HTM_Double (NumTotalQsts ? TotalScoreOfAllTests / (double) NumTotalQsts :
+ HTM_Double2Decimals (NumTotalQsts ? TotalScoreOfAllTests / (double) NumTotalQsts :
0.0);
HTM_TD_End ();
@@ -8061,7 +8061,7 @@ void Tst_ShowOneTstResult (void)
HTM_TD_Begin ("class=\"DAT LT\"");
if (ICanViewScore)
- HTM_Double (TotalScore);
+ HTM_Double2Decimals (TotalScore);
else
HTM_Txt ("?"); // No feedback
HTM_TD_End ();
@@ -8107,7 +8107,7 @@ void Tst_ShowOneTstResult (void)
{
HTM_DIV_Begin ("class=\"DAT_N_BOLD CM\"");
HTM_TxtF ("%s: ",Txt_Score);
- HTM_Double (TotalScore);
+ HTM_Double2Decimals (TotalScore);
HTM_BR ();
HTM_TxtF ("%s: ",Txt_Grade);
Tst_ComputeAndShowGrade (Gbl.Test.NumQsts,TotalScore,Tst_SCORE_MAX);