diff --git a/swad_changelog.h b/swad_changelog.h index 5163adcd..ddf3a09e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -490,7 +490,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.80 (2019-11-28)" +#define Log_PLATFORM_VERSION "SWAD 19.80.1 (2019-11-28)" #define CSS_FILE "swad19.78.1.css" #define JS_FILE "swad19.70.js" /* @@ -498,6 +498,7 @@ ps2pdf source.ps destination.pdf // TODO: Impedir la creación y edición de proyectos si no son editables. // TODO: En cada juego, poder listar los resultados en una tabla como la de resultados globales + Version 19.80.1: Nov 28, 2019 Changes in test results and match results. (247252 lines) Version 19.80: Nov 28, 2019 Changes in test results and match results. (247265 lines) Version 19.79.2: Nov 27, 2019 Column for grade in matches results. (247232 lines) Version 19.79.1: Nov 27, 2019 Maximum grade shown in listing of games. (247201 lines) diff --git a/swad_match_result.c b/swad_match_result.c index 8251aa07..482cb7fd 100644 --- a/swad_match_result.c +++ b/swad_match_result.c @@ -471,7 +471,6 @@ static void McR_ShowHeaderMchResults (Usr_MeOrOther_t MeOrOther) static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, unsigned NumGamesSelected) { - extern const char *Txt_out_of_PART_OF_A_SCORE; extern const char *Txt_Match_result; extern const char *Txt_Hidden_result; MYSQL_RES *mysql_res; @@ -651,20 +650,9 @@ static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther, HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); if (ShowResultThisMatch) { - if (NumQstsInThisResult) - { - MaxScore = (double) NumQstsInThisResult; - Grade = ScoreInThisResult * MaxGrade / MaxScore; - } - else - Grade = 0.0; + Grade = Tst_ComputeGrade (NumQstsInThisResult,ScoreInThisResult,MaxGrade); + Tst_ShowGrade (Grade,MaxGrade); TotalGrade += Grade; - - HTM_Double (Grade); - HTM_NBSP (); - HTM_Txt (Txt_out_of_PART_OF_A_SCORE); - HTM_NBSP (); - HTM_Double (MaxGrade); } HTM_TD_End (); @@ -790,7 +778,6 @@ void McR_ShowOneMchResult (void) extern const char *Txt_Questions; extern const char *Txt_non_blank_QUESTIONS; extern const char *Txt_Score; - extern const char *Txt_out_of_PART_OF_A_SCORE; extern const char *Txt_Tags; struct Game Game; struct Match Match; @@ -803,7 +790,6 @@ void McR_ShowOneMchResult (void) unsigned NumQstsNotBlank; double MaxScore; double TotalScore; - double Grade; bool ShowPhoto; char PhotoURL[PATH_MAX + 1]; bool ItsMe; @@ -986,25 +972,9 @@ void McR_ShowOneMchResult (void) HTM_TD_Begin ("class=\"DAT LT\""); if (ICanViewScore) - { - if (NumQsts) - { - MaxScore = (double) NumQsts; - Grade = TotalScore * Game.MaxGrade / MaxScore; - } - else - Grade = 0.0; - HTM_Double (TotalScore); - HTM_Txt (" ("); - HTM_Double (Grade); - } + Tst_ShowScoreAndGrade (NumQsts,TotalScore,Game.MaxGrade); else - HTM_Txt ("? (?"); // No feedback - HTM_NBSP (); - HTM_Txt (Txt_out_of_PART_OF_A_SCORE); - HTM_NBSP (); - HTM_Double (Game.MaxGrade); - HTM_Txt (")"); + HTM_Txt ("?"); // No feedback HTM_TD_End (); HTM_TR_End (); @@ -1030,7 +1000,12 @@ void McR_ShowOneMchResult (void) /***** Write total mark of match result *****/ if (ICanViewScore) - Tst_ShowTstTotalMark (NumQsts,TotalScore,Game.MaxGrade); + { + HTM_DIV_Begin ("class=\"DAT CM\""); + HTM_TxtF ("%s: ",Txt_Score); + Tst_ShowScoreAndGrade (NumQsts,TotalScore,Game.MaxGrade); + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); diff --git a/swad_test.c b/swad_test.c index da49072d..08aec8b1 100644 --- a/swad_test.c +++ b/swad_test.c @@ -512,6 +512,7 @@ void Tst_AssessTest (void) extern const char *Hlp_ASSESSMENT_Tests; extern const char *Txt_Test_result; extern const char *Txt_Test_No_X_that_you_make_in_this_course; + extern const char *Txt_Score; extern const char *Txt_The_test_X_has_already_been_assessed_previously; extern const char *Txt_There_was_an_error_in_assessing_the_test_X; unsigned NumTst; @@ -565,7 +566,12 @@ void Tst_AssessTest (void) /***** Write total mark of test *****/ if (Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING) - Tst_ShowTstTotalMark (Gbl.Test.NumQsts,TotalScore,Tst_SCORE_MAX); + { + HTM_DIV_Begin ("class=\"DAT CM\""); + HTM_TxtF ("%s: ",Txt_Score); + Tst_ShowScoreAndGrade (Gbl.Test.NumQsts,TotalScore,Tst_SCORE_MAX); + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); @@ -626,16 +632,29 @@ static void Tst_GetQuestionsAndAnswersFromForm (void) } /*****************************************************************************/ -/************************** Show total mark of a test ************************/ +/********* Show total score (and total grade out of maximum grade) ***********/ /*****************************************************************************/ -void Tst_ShowTstTotalMark (unsigned NumQsts,double Score,double MaxGrade) +void Tst_ShowScoreAndGrade (unsigned NumQsts,double Score,double MaxGrade) + { + /***** Write total score ****/ + HTM_Double (Score); + + /***** Separator *****/ + HTM_NBSP (); + + /***** Compute and write grade over maximum grade *****/ + HTM_Txt ("("); + Tst_ShowGrade (Tst_ComputeGrade (NumQsts,Score,MaxGrade),MaxGrade); + HTM_Txt (")"); + } + +double Tst_ComputeGrade (unsigned NumQsts,double Score,double MaxGrade) { - extern const char *Txt_Score; - extern const char *Txt_out_of_PART_OF_A_SCORE; double MaxScore; double Grade; + /***** Compute grade *****/ if (NumQsts) { MaxScore = (double) NumQsts; @@ -644,22 +663,19 @@ void Tst_ShowTstTotalMark (unsigned NumQsts,double Score,double MaxGrade) else Grade = 0.0; - /***** Write total score ****/ - HTM_DIV_Begin ("class=\"DAT CM\""); - HTM_TxtF ("%s: ",Txt_Score); - HTM_SPAN_Begin ("class=\"%s\"", - (Grade >= MaxGrade / 2.0) ? "ANS_OK" : - "ANS_BAD"); - HTM_Double (Score); - HTM_Txt (" ("); + return Grade; + } + +void Tst_ShowGrade (double Grade,double MaxGrade) + { + extern const char *Txt_out_of_PART_OF_A_SCORE; + + /***** Write grade over maximum grade *****/ HTM_Double (Grade); HTM_NBSP (); HTM_Txt (Txt_out_of_PART_OF_A_SCORE); HTM_NBSP (); HTM_Double (MaxGrade); - HTM_Txt (")"); - HTM_SPAN_End (); - HTM_DIV_End (); } /*****************************************************************************/ @@ -8014,7 +8030,6 @@ void Tst_ShowOneTstResult (void) extern const char *Txt_Questions; extern const char *Txt_non_blank_QUESTIONS; extern const char *Txt_Score; - extern const char *Txt_out_of_PART_OF_A_SCORE; extern const char *Txt_Tags; long TstCod; time_t TstTimeUTC = 0; // Test result UTC date-time, initialized to avoid warning @@ -8164,16 +8179,9 @@ void Tst_ShowOneTstResult (void) HTM_TD_Begin ("class=\"DAT LT\""); if (ICanViewScore) - { - HTM_Double (TotalScore); - HTM_Txt (" ("); - HTM_Double (Gbl.Test.NumQsts ? TotalScore * Tst_SCORE_MAX / - (double) Gbl.Test.NumQsts : - 0.0); - } + Tst_ShowScoreAndGrade (Gbl.Test.NumQsts,TotalScore,Tst_SCORE_MAX); else - HTM_Txt ("? (?"); // No feedback - HTM_TxtF (" %s %u)",Txt_out_of_PART_OF_A_SCORE,Tst_SCORE_MAX); + HTM_Txt ("?"); // No feedback HTM_TD_End (); HTM_TR_End (); @@ -8200,7 +8208,12 @@ void Tst_ShowOneTstResult (void) /***** Write total mark of test *****/ if (ICanViewScore) - Tst_ShowTstTotalMark (Gbl.Test.NumQsts,TotalScore,Tst_SCORE_MAX); + { + HTM_DIV_Begin ("class=\"DAT CM\""); + HTM_TxtF ("%s: ",Txt_Score); + Tst_ShowScoreAndGrade (Gbl.Test.NumQsts,TotalScore,Tst_SCORE_MAX); + HTM_DIV_End (); + } /***** End box *****/ Box_BoxEnd (); diff --git a/swad_test.h b/swad_test.h index 4aa8fae5..f9be6de6 100644 --- a/swad_test.h +++ b/swad_test.h @@ -140,7 +140,10 @@ struct Tst_Stats void Tst_ShowFormAskTst (void); void Tst_ShowNewTest (void); void Tst_AssessTest (void); -void Tst_ShowTstTotalMark (unsigned NumQsts,double Score,double MaxGrade); + +void Tst_ShowScoreAndGrade (unsigned NumQsts,double Score,double MaxGrade); +double Tst_ComputeGrade (unsigned NumQsts,double Score,double MaxGrade); +void Tst_ShowGrade (double Grade,double MaxGrade); void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res);