Version19.125.1

This commit is contained in:
Antonio Cañas Vargas 2020-02-17 12:27:28 +01:00
parent 2605cfd0f5
commit fcca2648bd
8 changed files with 90 additions and 56 deletions

View File

@ -3623,6 +3623,8 @@ int swad__sendNotice (struct soap *soap,
/****************** Return test configuration in a course ********************/
/*****************************************************************************/
#define TsR_MAX_BYTES_FEEDBACK_TYPE 32
int swad__getTestConfig (struct soap *soap,
char *wsKey,int courseCode, // input
struct swad__getTestConfigOutput *getTestConfigOut) // output
@ -3687,19 +3689,19 @@ int swad__getTestConfig (struct soap *soap,
/* Convert from visibility to old feedback */
/* TODO: Remove these lines in 2021 */
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_TOTAL_SCORE )) == 0)
if (!TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility))
Str_Copy (getTestConfigOut->feedback,
"nothing",
TsR_MAX_BYTES_FEEDBACK_TYPE);
else if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_EACH_QST_SCORE)) == 0)
else if (!TsR_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
Str_Copy (getTestConfigOut->feedback,
"totalResult",
TsR_MAX_BYTES_FEEDBACK_TYPE);
else if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) == 0)
else if (!TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
Str_Copy (getTestConfigOut->feedback,
"eachResult",
TsR_MAX_BYTES_FEEDBACK_TYPE);
else if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_FEEDBACK_TEXT )) == 0)
else if (!TsR_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
Str_Copy (getTestConfigOut->feedback,
"eachGoodBad",
TsR_MAX_BYTES_FEEDBACK_TYPE);

View File

@ -497,7 +497,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.125 (2020-02-17)"
#define Log_PLATFORM_VERSION "SWAD 19.125.1 (2020-02-17)"
#define CSS_FILE "swad19.118.css"
#define JS_FILE "swad19.91.1.js"
/*
@ -509,6 +509,7 @@ ps2pdf source.ps destination.pdf
// TODO: Add visibility to API function getTestConfig
// TODO: Add visibility to games
Version 19.125.1: Feb 17, 2020 Code refactoring in test. (278851 lines)
Version 19.125: Feb 17, 2020 Removed feedback from test config form. (278823 lines)
Version 19.124.1: Feb 17, 2020 Fixed bug reported by Javier Fernández Baldomero.
Result visibility in tests is stored in database. (279010 lines)

View File

@ -1049,7 +1049,7 @@ void McR_ShowOneMchResult (void)
if (ICanViewResult)
{
Tst_GetConfigTstFromDB (); // To get feedback type
ICanViewScore = (Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_TOTAL_SCORE)) != 0;
ICanViewScore = TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
}
else
ICanViewScore = false;

View File

@ -488,7 +488,7 @@ void Tst_AssessTest (void)
HTM_TABLE_End ();
/***** Write total score and grade *****/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_TOTAL_SCORE)) != 0)
if (TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility))
{
HTM_DIV_Begin ("class=\"DAT_N_BOLD CM\"");
HTM_TxtColonNBSP (Txt_Score);
@ -992,7 +992,7 @@ void Tst_WriteQstAndAnsTest (Tst_ActionToDoWithQuestions_t ActionToDoWithQuestio
Tst_WriteAnswersTestResult (UsrDat,NumQst,QstCod,ScoreThisQst,AnswerIsNotBlank);
/* Write question feedback (row[5]) */
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_FEEDBACK_TEXT)) != 0)
if (TsR_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
Tst_WriteQstFeedback (row[5],"TEST_EXA_LIGHT");
break;
default:
@ -3499,16 +3499,16 @@ static void Tst_WriteTFAnsAssessTest (struct UsrData *UsrDat,
/***** Write the user answer *****/
HTM_TD_Begin ("class=\"%s CM\"",
(Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0 ?
(AnsTF == row[1][0] ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility) ?
(AnsTF == row[1][0] ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
Tst_WriteAnsTF (AnsTF);
HTM_TD_End ();
/***** Write the correct answer *****/
HTM_TD_Begin ("class=\"ANS_0 CM\"");
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0)
if (TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
Tst_WriteAnsTF (row[1][0]);
else
HTM_Txt ("?");
@ -3517,7 +3517,7 @@ static void Tst_WriteTFAnsAssessTest (struct UsrData *UsrDat,
HTM_TR_End ();
/***** Write the score of this question *****/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_EACH_QST_SCORE)) != 0)
if (TsR_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
{
Tst_WriteScoreStart (2);
if (AnsTF == '\0') // If user has omitted the answer
@ -3705,7 +3705,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
/* Draw icon depending on user's answer */
if (AnswersUsr[Indexes[NumOpt]] == true) // This answer has been selected by the user
{
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0)
if (TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
{
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Correct)
{
@ -3733,7 +3733,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
HTM_TD_Empty (1);
/* Draw icon that indicates whether the answer is correct */
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0)
if (TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
{
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Correct)
{
@ -3767,7 +3767,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
"TEST_MED_SHOW");
HTM_DIV_End ();
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0)
if (TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Feedback)
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Feedback[0])
{
@ -3781,8 +3781,8 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
HTM_TR_End ();
}
/***** Write the total score of this question *****/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_EACH_QST_SCORE)) != 0)
/***** Write the score of this question *****/
if (TsR_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
{
Tst_WriteScoreStart (4);
if (*ScoreThisQst == 0.0)
@ -3840,7 +3840,7 @@ void Tst_GetChoiceAns (MYSQL_RES *mysql_res)
/***** Copy answer feedback (row[2]) and convert it,
that is in HTML, to rigorous HTML ******/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_FEEDBACK_TEXT)) != 0)
if (TsR_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
if (row[2])
if (row[2][0])
{
@ -4169,7 +4169,7 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
Tst_MAX_BYTES_ANSWER_OR_FEEDBACK,false);
/***** Copy answer feedback (row[2]) and convert it, that is in HTML, to rigorous HTML ******/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_FEEDBACK_TEXT)) != 0)
if (TsR_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
if (row[2])
if (row[2][0])
{
@ -4222,10 +4222,10 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
}
}
HTM_TD_Begin ("class=\"%s CT\"",
(Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0 ?
(Correct ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility) ?
(Correct ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
HTM_Txt (Gbl.Test.StrAnswersOneQst[NumQst]);
}
else // If user has omitted the answer
@ -4233,7 +4233,7 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
HTM_TD_End ();
/***** Write the correct answers *****/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0)
if (TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
{
HTM_TD_Begin ("class=\"CT\"");
HTM_TABLE_BeginPadding (2);
@ -4256,7 +4256,7 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
HTM_Txt (Gbl.Test.Answer.Options[NumOpt].Text);
HTM_DIV_End ();
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_FEEDBACK_TEXT)) != 0)
if (TsR_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
if (Gbl.Test.Answer.Options[NumOpt].Feedback)
if (Gbl.Test.Answer.Options[NumOpt].Feedback[0])
{
@ -4296,8 +4296,8 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
*ScoreThisQst = 0.0;
}
/***** Write the mark *****/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_EACH_QST_SCORE)) != 0)
/***** Write the score of this question *****/
if (TsR_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
{
Tst_WriteScoreStart (4);
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
@ -4378,10 +4378,10 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat,
if (sscanf (Gbl.Test.StrAnswersOneQst[NumQst],"%ld",&IntAnswerUsr) == 1)
{
HTM_TD_Begin ("class=\"%s CM\"",
(Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0 ?
(IntAnswerUsr == IntAnswerCorr ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility) ?
(IntAnswerUsr == IntAnswerCorr ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
HTM_Long (IntAnswerUsr);
HTM_TD_End ();
}
@ -4398,7 +4398,7 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat,
/***** Write the correct answer *****/
HTM_TD_Begin ("class=\"ANS_0 CM\"");
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0)
if (TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
HTM_Long (IntAnswerCorr);
else
HTM_Txt ("?");
@ -4421,8 +4421,8 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat,
*ScoreThisQst = 0.0;
}
/***** Write the score *****/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_EACH_QST_SCORE)) != 0)
/***** Write the score of this question *****/
if (TsR_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
{
Tst_WriteScoreStart (2);
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
@ -4517,11 +4517,11 @@ static void Tst_WriteFloatAnsAssessTest (struct UsrData *UsrDat,
if (Gbl.Test.StrAnswersOneQst[NumQst][0]) // It's a correct floating point number
{
HTM_TD_Begin ("class=\"%s CM\"",
(Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0 ?
((FloatAnsUsr >= FloatAnsCorr[0] &&
FloatAnsUsr <= FloatAnsCorr[1]) ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility) ?
((FloatAnsUsr >= FloatAnsCorr[0] &&
FloatAnsUsr <= FloatAnsCorr[1]) ? "ANS_OK" :
"ANS_BAD") :
"ANS_0");
HTM_Double (FloatAnsUsr);
}
else // Not a floating point number
@ -4536,7 +4536,7 @@ static void Tst_WriteFloatAnsAssessTest (struct UsrData *UsrDat,
/***** Write the correct answer *****/
HTM_TD_Begin ("class=\"ANS_0 CM\"");
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0)
if (TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
{
HTM_Txt ("[");
HTM_Double (FloatAnsCorr[0]);
@ -4566,8 +4566,8 @@ static void Tst_WriteFloatAnsAssessTest (struct UsrData *UsrDat,
*ScoreThisQst = 0.0;
}
/***** Write mark *****/
if ((Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_EACH_QST_SCORE)) != 0)
/***** Write the score of this question *****/
if (TsR_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
{
Tst_WriteScoreStart (2);
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer

View File

@ -51,8 +51,6 @@
#define Tst_CONFIG_DEFAULT_DEF_QUESTIONS 20 // Number of questions to be generated by default in a self-assessment test
#define Tst_CONFIG_DEFAULT_MAX_QUESTIONS 30 // Maximum number of questions to be generated in a self-assessment test
#define TsR_MAX_BYTES_FEEDBACK_TYPE 32
#define Tst_MAX_BYTES_ANSWER_TYPE 32
/*****************************************************************************/

View File

@ -349,7 +349,7 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
case Rol_STD:
ICanViewTest = ItsMe;
ICanViewScore = ItsMe &&
(Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_TOTAL_SCORE)) != 0;
TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
break;
case Rol_NET:
case Rol_TCH:
@ -508,7 +508,7 @@ static void TsR_ShowTestResultsSummaryRow (bool ItsMe,
{
case Rol_STD:
ICanViewTotalScore = ItsMe &&
(Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_TOTAL_SCORE)) != 0;
TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
break;
case Rol_NET:
case Rol_TCH:
@ -618,7 +618,7 @@ void TsR_ShowOneTstResult (void)
if (ItsMe)
{
Tst_GetConfigTstFromDB (); // To get feedback type
ICanViewScore = (Gbl.Test.Config.Visibility & (1 << TsR_VISIBLE_TOTAL_SCORE)) != 0;
ICanViewScore = TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
}
else
ICanViewScore = false;
@ -1183,3 +1183,32 @@ void TsR_PutVisibilityCheckboxes (unsigned SelectedVisibility)
HTM_BR ();
}
}
/*****************************************************************************/
/***************************** Get visibility items **************************/
/*****************************************************************************/
bool TsR_IsVisibleQstAndAnsTxt (unsigned Visibility)
{
return (Visibility & (1 << TsR_VISIBLE_QST_ANS_TXT)) != 0;
}
bool TsR_IsVisibleFeedbackTxt (unsigned Visibility)
{
return (Visibility & (1 << TsR_VISIBLE_FEEDBACK_TXT)) != 0;
}
bool TsR_IsVisibleCorrectAns (unsigned Visibility)
{
return (Visibility & (1 << TsR_VISIBLE_CORRECT_ANSWER)) != 0;
}
bool TsR_IsVisibleEachQstScore (unsigned Visibility)
{
return (Visibility & (1 << TsR_VISIBLE_EACH_QST_SCORE)) != 0;
}
bool TsR_IsVisibleTotalScore (unsigned Visibility)
{
return (Visibility & (1 << TsR_VISIBLE_TOTAL_SCORE)) != 0;
}

View File

@ -33,9 +33,7 @@
/***************************** Public constants ******************************/
/*****************************************************************************/
#define TsR_SCORE_MAX 10 // Maximum score of a test (10 in Spain). Must be unsigned! // TODO: Make this configurable by teachers
#define TsR_MAX_BYTES_FEEDBACK_TYPE 32
#define TsR_SCORE_MAX 10 // Maximum score of a test (10 in Spain). Must be unsigned! // TODO: Make this configurable by teachers
/*****************************************************************************/
/******************************* Public types ********************************/
@ -44,8 +42,8 @@
#define TsR_NUM_ITEMS_VISIBILITY 5
typedef enum
{
TsR_VISIBLE_QST_ANS_TEXT = 0, // Questions and answers text
TsR_VISIBLE_FEEDBACK_TEXT = 1, // Feedback text
TsR_VISIBLE_QST_ANS_TXT = 0, // Questions and answers text
TsR_VISIBLE_FEEDBACK_TXT = 1, // Feedback text
TsR_VISIBLE_CORRECT_ANSWER = 2, // Correct answers
TsR_VISIBLE_EACH_QST_SCORE = 3, // Score of each question
TsR_VISIBLE_TOTAL_SCORE = 4, // Total score
@ -75,4 +73,10 @@ void TsR_RemoveCrsTestResults (long CrsCod);
unsigned TsR_GetVisibilityFromForm (void);
void TsR_PutVisibilityCheckboxes (unsigned SelectedVisibility);
bool TsR_IsVisibleQstAndAnsTxt (unsigned Visibility);
bool TsR_IsVisibleFeedbackTxt (unsigned Visibility);
bool TsR_IsVisibleCorrectAns (unsigned Visibility);
bool TsR_IsVisibleEachQstScore (unsigned Visibility);
bool TsR_IsVisibleTotalScore (unsigned Visibility);
#endif

View File

@ -51447,7 +51447,7 @@ const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST] =
const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY] =
{
[TsR_VISIBLE_QST_ANS_TEXT] =
[TsR_VISIBLE_QST_ANS_TXT] =
#if L==1 // ca
"Text de preguntes i respostes"
#elif L==2 // de
@ -51468,7 +51468,7 @@ const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY] =
"Texto de perguntas e respostas"
#endif
,
[TsR_VISIBLE_FEEDBACK_TEXT] =
[TsR_VISIBLE_FEEDBACK_TXT] =
#if L==1 // ca
"Text de realimentaci&oacute;"
#elif L==2 // de