mirror of https://github.com/acanas/swad-core.git
Version19.126
This commit is contained in:
parent
0a3077d32b
commit
1b1316360e
2
Makefile
2
Makefile
|
@ -57,7 +57,7 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \
|
|||
swad_statistic.o swad_string.o swad_survey.o swad_syllabus.o \
|
||||
swad_system_config.o \
|
||||
swad_tab.o swad_test.o swad_test_import.o swad_test_result.o \
|
||||
swad_theme.o swad_timeline.o swad_timetable.o \
|
||||
swad_test_visibility.o swad_theme.o swad_timeline.o swad_timetable.o \
|
||||
swad_user.o \
|
||||
swad_xml.o \
|
||||
swad_zip.o
|
||||
|
|
11
swad_API.c
11
swad_API.c
|
@ -113,6 +113,7 @@ cp -f /home/acanas/swad/swad/swad /var/www/cgi-bin/
|
|||
#include "swad_notification.h"
|
||||
#include "swad_password.h"
|
||||
#include "swad_search.h"
|
||||
#include "swad_test_visibility.h"
|
||||
#include "swad_user.h"
|
||||
#include "swad_xml.h"
|
||||
|
||||
|
@ -3689,19 +3690,19 @@ int swad__getTestConfig (struct soap *soap,
|
|||
|
||||
/* Convert from visibility to old feedback */
|
||||
/* TODO: Remove these lines in 2021 */
|
||||
if (!TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility))
|
||||
if (!TsV_IsVisibleTotalScore (Gbl.Test.Config.Visibility))
|
||||
Str_Copy (getTestConfigOut->feedback,
|
||||
"nothing",
|
||||
TsR_MAX_BYTES_FEEDBACK_TYPE);
|
||||
else if (!TsR_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
|
||||
else if (!TsV_IsVisibleEachQstScore (Gbl.Test.Config.Visibility))
|
||||
Str_Copy (getTestConfigOut->feedback,
|
||||
"totalResult",
|
||||
TsR_MAX_BYTES_FEEDBACK_TYPE);
|
||||
else if (!TsR_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
|
||||
else if (!TsV_IsVisibleCorrectAns (Gbl.Test.Config.Visibility))
|
||||
Str_Copy (getTestConfigOut->feedback,
|
||||
"eachResult",
|
||||
TsR_MAX_BYTES_FEEDBACK_TYPE);
|
||||
else if (!TsR_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
|
||||
else if (!TsV_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
|
||||
Str_Copy (getTestConfigOut->feedback,
|
||||
"eachGoodBad",
|
||||
TsR_MAX_BYTES_FEEDBACK_TYPE);
|
||||
|
@ -3741,7 +3742,7 @@ static int API_GetTstConfig (long CrsCod)
|
|||
{
|
||||
Gbl.Test.Config.Pluggable = Tst_PLUGGABLE_UNKNOWN;
|
||||
Gbl.Test.Config.Min = Gbl.Test.Config.Def = Gbl.Test.Config.Max = 0;
|
||||
Gbl.Test.Config.Visibility = TsR_VISIBILITY_DEFAULT;
|
||||
Gbl.Test.Config.Visibility = TsV_VISIBILITY_DEFAULT;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
|
|
@ -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.4 (2020-02-17)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.126 (2020-02-18)"
|
||||
#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 games
|
||||
// TODO: Sugerencia de Jesús González Peñalver: añadir un poco más de espacio entre pregunta y pregunta en las opciones de un juego
|
||||
|
||||
Version 19.126: Feb 18, 2020 New module swad_test_visibility for visibility of test results. (279013 lines)
|
||||
Version 19.125.4: Feb 17, 2020 Changes in visibility of answers. (278930 lines)
|
||||
Version 19.125.3: Feb 17, 2020 Changes in visibility of question stem. (278898 lines)
|
||||
Version 19.125.2: Feb 17, 2020 Removed Feedback field from tst_config database table. (278850 lines)
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "swad_project.h"
|
||||
#include "swad_role.h"
|
||||
#include "swad_setting.h"
|
||||
#include "swad_test_visibility.h"
|
||||
#include "swad_theme.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -356,7 +357,7 @@ void Gbl_InitializeGlobals (void)
|
|||
|
||||
/* Tests */
|
||||
Gbl.Test.Config.Pluggable = Tst_PLUGGABLE_UNKNOWN;
|
||||
Gbl.Test.Config.Visibility = TsR_VISIBILITY_DEFAULT;
|
||||
Gbl.Test.Config.Visibility = TsV_VISIBILITY_DEFAULT;
|
||||
Gbl.Test.NumQsts = Tst_CONFIG_DEFAULT_DEF_QUESTIONS;
|
||||
Gbl.Test.AllowTeachers = false; // Must the test result be saved?
|
||||
Gbl.Test.AllAnsTypes = false;
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "swad_ID.h"
|
||||
#include "swad_match.h"
|
||||
#include "swad_match_result.h"
|
||||
#include "swad_test_visibility.h"
|
||||
#include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1032,7 +1033,7 @@ void McR_ShowOneMchResult (void)
|
|||
&NumQsts,
|
||||
&NumQstsNotBlank,
|
||||
&TotalScore);
|
||||
Gbl.Test.Config.Visibility = TsR_MAX_VISIBILITY; // Initialize visibility to maximum
|
||||
Gbl.Test.Config.Visibility = TsV_MAX_VISIBILITY; // Initialize visibility to maximum
|
||||
|
||||
/***** Check if I can view this match result *****/
|
||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||
|
@ -1049,7 +1050,7 @@ void McR_ShowOneMchResult (void)
|
|||
if (ICanViewResult)
|
||||
{
|
||||
Tst_GetConfigTstFromDB (); // To get feedback type
|
||||
ICanViewScore = TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
|
||||
ICanViewScore = TsV_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
|
||||
}
|
||||
else
|
||||
ICanViewScore = false;
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include <stdbool.h> // For boolean type
|
||||
#include <stddef.h> // For size_t
|
||||
|
||||
#include "swad_string.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Public types and constants ***********************/
|
||||
/*****************************************************************************/
|
||||
|
|
66
swad_test.c
66
swad_test.c
|
@ -51,7 +51,7 @@
|
|||
#include "swad_theme.h"
|
||||
#include "swad_test.h"
|
||||
#include "swad_test_import.h"
|
||||
#include "swad_test_result.h"
|
||||
#include "swad_test_visibility.h"
|
||||
#include "swad_user.h"
|
||||
#include "swad_xml.h"
|
||||
|
||||
|
@ -494,7 +494,7 @@ void Tst_AssessTest (void)
|
|||
HTM_TABLE_End ();
|
||||
|
||||
/***** Write total score and grade *****/
|
||||
if (TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility))
|
||||
if (TsV_IsVisibleTotalScore (Gbl.Test.Config.Visibility))
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"DAT_N_BOLD CM\"");
|
||||
HTM_TxtColonNBSP (Txt_Score);
|
||||
|
@ -812,7 +812,7 @@ static void Tst_ShowTestQuestionsWhenSeeing (MYSQL_RES *mysql_res)
|
|||
Tst_WriteQstAndAnsTest (Tst_SHOW_TEST_TO_ANSWER,
|
||||
&Gbl.Usrs.Me.UsrDat,
|
||||
NumQst,QstCod,row,
|
||||
TsR_MAX_VISIBILITY, // All visible here
|
||||
TsV_MAX_VISIBILITY, // All visible here
|
||||
&ScoreThisQst, // Not used here
|
||||
&AnswerIsNotBlank); // Not used here
|
||||
}
|
||||
|
@ -946,7 +946,7 @@ void Tst_WriteQstAndAnsTest (Tst_ActionToDoWithQuestions_t ActionToDoWithQuestio
|
|||
double *ScoreThisQst,bool *AnswerIsNotBlank)
|
||||
{
|
||||
extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES];
|
||||
bool IsVisibleQstAndAnsTxt = TsR_IsVisibleQstAndAnsTxt (Visibility);
|
||||
bool IsVisibleQstAndAnsTxt = TsV_IsVisibleQstAndAnsTxt (Visibility);
|
||||
/*
|
||||
row[0] QstCod
|
||||
row[1] UNIX_TIMESTAMP(EditTime)
|
||||
|
@ -1006,7 +1006,7 @@ void Tst_WriteQstAndAnsTest (Tst_ActionToDoWithQuestions_t ActionToDoWithQuestio
|
|||
ScoreThisQst,AnswerIsNotBlank);
|
||||
|
||||
/* Write question feedback (row[5]) */
|
||||
if (TsR_IsVisibleFeedbackTxt (Visibility))
|
||||
if (TsV_IsVisibleFeedbackTxt (Visibility))
|
||||
Tst_WriteQstFeedback (row[5],"TEST_EXA_LIGHT");
|
||||
break;
|
||||
default:
|
||||
|
@ -1923,7 +1923,7 @@ static void Tst_ShowFormConfigTst (void)
|
|||
HTM_TD_End ();
|
||||
|
||||
HTM_TD_Begin ("class=\"LB\"");
|
||||
TsR_PutVisibilityCheckboxes (Gbl.Test.Config.Visibility);
|
||||
TsV_PutVisibilityCheckboxes (Gbl.Test.Config.Visibility);
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
|
@ -1991,7 +1991,7 @@ void Tst_GetConfigTstFromDB (void)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
Gbl.Test.Config.MinTimeNxtTstPerQst = 0UL;
|
||||
Gbl.Test.Config.Visibility = TsR_VISIBILITY_DEFAULT;
|
||||
Gbl.Test.Config.Visibility = TsV_VISIBILITY_DEFAULT;
|
||||
if (NumRows == 0)
|
||||
{
|
||||
Gbl.Test.Config.Pluggable = Tst_PLUGGABLE_UNKNOWN;
|
||||
|
@ -2061,7 +2061,7 @@ void Tst_GetConfigFromRow (MYSQL_ROW row)
|
|||
|
||||
/***** Get visibility (row[5]) *****/
|
||||
if (sscanf (row[5],"%u",&UnsignedNum) == 1)
|
||||
Gbl.Test.Config.Visibility = UnsignedNum & TsR_MAX_VISIBILITY;
|
||||
Gbl.Test.Config.Visibility = UnsignedNum & TsV_MAX_VISIBILITY;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2155,7 +2155,7 @@ void Tst_ReceiveConfigTst (void)
|
|||
0);
|
||||
|
||||
/***** Get type of feedback from form *****/
|
||||
Gbl.Test.Config.Visibility = TsR_GetVisibilityFromForm ();
|
||||
Gbl.Test.Config.Visibility = TsV_GetVisibilityFromForm ();
|
||||
|
||||
/***** Update database *****/
|
||||
DB_QueryREPLACE ("can not save configuration of tests",
|
||||
|
@ -3537,7 +3537,7 @@ static void Tst_WriteTFAnsAssessTest (struct UsrData *UsrDat,
|
|||
|
||||
/***** Write the user answer *****/
|
||||
HTM_TD_Begin ("class=\"%s CM\"",
|
||||
TsR_IsVisibleCorrectAns (Visibility) ?
|
||||
TsV_IsVisibleCorrectAns (Visibility) ?
|
||||
(AnsTF == row[1][0] ? "ANS_OK" :
|
||||
"ANS_BAD") :
|
||||
"ANS_0");
|
||||
|
@ -3546,8 +3546,8 @@ static void Tst_WriteTFAnsAssessTest (struct UsrData *UsrDat,
|
|||
|
||||
/***** Write the correct answer *****/
|
||||
HTM_TD_Begin ("class=\"ANS_0 CM\"");
|
||||
if (TsR_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsR_IsVisibleCorrectAns (Visibility))
|
||||
if (TsV_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsV_IsVisibleCorrectAns (Visibility))
|
||||
Tst_WriteAnsTF (row[1][0]);
|
||||
else
|
||||
HTM_Txt ("?");
|
||||
|
@ -3556,7 +3556,7 @@ static void Tst_WriteTFAnsAssessTest (struct UsrData *UsrDat,
|
|||
HTM_TR_End ();
|
||||
|
||||
/***** Write the score of this question *****/
|
||||
if (TsR_IsVisibleEachQstScore (Visibility))
|
||||
if (TsV_IsVisibleEachQstScore (Visibility))
|
||||
{
|
||||
Tst_WriteScoreStart (2);
|
||||
if (AnsTF == '\0') // If user has omitted the answer
|
||||
|
@ -3746,7 +3746,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 (TsR_IsVisibleCorrectAns (Visibility))
|
||||
if (TsV_IsVisibleCorrectAns (Visibility))
|
||||
{
|
||||
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Correct)
|
||||
{
|
||||
|
@ -3774,7 +3774,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
|
|||
HTM_TD_Empty (1);
|
||||
|
||||
/* Draw icon that indicates whether the answer is correct */
|
||||
if (TsR_IsVisibleCorrectAns (Visibility))
|
||||
if (TsV_IsVisibleCorrectAns (Visibility))
|
||||
{
|
||||
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Correct)
|
||||
{
|
||||
|
@ -3802,7 +3802,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
|
|||
HTM_TD_Begin ("class=\"LT\"");
|
||||
|
||||
HTM_DIV_Begin ("class=\"ANS_TXT\"");
|
||||
if (TsR_IsVisibleQstAndAnsTxt (Visibility))
|
||||
if (TsV_IsVisibleQstAndAnsTxt (Visibility))
|
||||
{
|
||||
HTM_Txt (Gbl.Test.Answer.Options[Indexes[NumOpt]].Text);
|
||||
Med_ShowMedia (&Gbl.Test.Answer.Options[Indexes[NumOpt]].Media,
|
||||
|
@ -3813,7 +3813,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
|
|||
HTM_Txt (Txt_Question_not_visible);
|
||||
HTM_DIV_End ();
|
||||
|
||||
if (TsR_IsVisibleCorrectAns (Visibility))
|
||||
if (TsV_IsVisibleCorrectAns (Visibility))
|
||||
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Feedback)
|
||||
if (Gbl.Test.Answer.Options[Indexes[NumOpt]].Feedback[0])
|
||||
{
|
||||
|
@ -3828,7 +3828,7 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
|
|||
}
|
||||
|
||||
/***** Write the score of this question *****/
|
||||
if (TsR_IsVisibleEachQstScore (Visibility))
|
||||
if (TsV_IsVisibleEachQstScore (Visibility))
|
||||
{
|
||||
Tst_WriteScoreStart (4);
|
||||
if (*ScoreThisQst == 0.0)
|
||||
|
@ -3886,7 +3886,7 @@ void Tst_GetChoiceAns (MYSQL_RES *mysql_res)
|
|||
|
||||
/***** Copy answer feedback (row[2]) and convert it,
|
||||
that is in HTML, to rigorous HTML ******/
|
||||
if (TsR_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
|
||||
if (TsV_IsVisibleFeedbackTxt (Gbl.Test.Config.Visibility))
|
||||
if (row[2])
|
||||
if (row[2][0])
|
||||
{
|
||||
|
@ -4216,7 +4216,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 (TsR_IsVisibleFeedbackTxt (Visibility))
|
||||
if (TsV_IsVisibleFeedbackTxt (Visibility))
|
||||
if (row[2])
|
||||
if (row[2][0])
|
||||
{
|
||||
|
@ -4269,7 +4269,7 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
|
|||
}
|
||||
}
|
||||
HTM_TD_Begin ("class=\"%s CT\"",
|
||||
TsR_IsVisibleCorrectAns (Visibility) ?
|
||||
TsV_IsVisibleCorrectAns (Visibility) ?
|
||||
(Correct ? "ANS_OK" :
|
||||
"ANS_BAD") :
|
||||
"ANS_0");
|
||||
|
@ -4280,8 +4280,8 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
|
|||
HTM_TD_End ();
|
||||
|
||||
/***** Write the correct answers *****/
|
||||
if (TsR_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsR_IsVisibleCorrectAns (Visibility))
|
||||
if (TsV_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsV_IsVisibleCorrectAns (Visibility))
|
||||
{
|
||||
HTM_TD_Begin ("class=\"CT\"");
|
||||
HTM_TABLE_BeginPadding (2);
|
||||
|
@ -4304,7 +4304,7 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
|
|||
HTM_Txt (Gbl.Test.Answer.Options[NumOpt].Text);
|
||||
HTM_DIV_End ();
|
||||
|
||||
if (TsR_IsVisibleFeedbackTxt (Visibility))
|
||||
if (TsV_IsVisibleFeedbackTxt (Visibility))
|
||||
if (Gbl.Test.Answer.Options[NumOpt].Feedback)
|
||||
if (Gbl.Test.Answer.Options[NumOpt].Feedback[0])
|
||||
{
|
||||
|
@ -4345,7 +4345,7 @@ static void Tst_WriteTextAnsAssessTest (struct UsrData *UsrDat,
|
|||
}
|
||||
|
||||
/***** Write the score of this question *****/
|
||||
if (TsR_IsVisibleEachQstScore (Visibility))
|
||||
if (TsV_IsVisibleEachQstScore (Visibility))
|
||||
{
|
||||
Tst_WriteScoreStart (4);
|
||||
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
|
||||
|
@ -4427,7 +4427,7 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat,
|
|||
if (sscanf (Gbl.Test.StrAnswersOneQst[NumQst],"%ld",&IntAnswerUsr) == 1)
|
||||
{
|
||||
HTM_TD_Begin ("class=\"%s CM\"",
|
||||
TsR_IsVisibleCorrectAns (Visibility) ?
|
||||
TsV_IsVisibleCorrectAns (Visibility) ?
|
||||
(IntAnswerUsr == IntAnswerCorr ? "ANS_OK" :
|
||||
"ANS_BAD") :
|
||||
"ANS_0");
|
||||
|
@ -4447,8 +4447,8 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat,
|
|||
|
||||
/***** Write the correct answer *****/
|
||||
HTM_TD_Begin ("class=\"ANS_0 CM\"");
|
||||
if (TsR_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsR_IsVisibleCorrectAns (Visibility))
|
||||
if (TsV_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsV_IsVisibleCorrectAns (Visibility))
|
||||
HTM_Long (IntAnswerCorr);
|
||||
else
|
||||
HTM_Txt ("?");
|
||||
|
@ -4472,7 +4472,7 @@ static void Tst_WriteIntAnsAssessTest (struct UsrData *UsrDat,
|
|||
}
|
||||
|
||||
/***** Write the score of this question *****/
|
||||
if (TsR_IsVisibleEachQstScore (Visibility))
|
||||
if (TsV_IsVisibleEachQstScore (Visibility))
|
||||
{
|
||||
Tst_WriteScoreStart (2);
|
||||
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
|
||||
|
@ -4568,7 +4568,7 @@ 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\"",
|
||||
TsR_IsVisibleCorrectAns (Visibility) ?
|
||||
TsV_IsVisibleCorrectAns (Visibility) ?
|
||||
((FloatAnsUsr >= FloatAnsCorr[0] &&
|
||||
FloatAnsUsr <= FloatAnsCorr[1]) ? "ANS_OK" :
|
||||
"ANS_BAD") :
|
||||
|
@ -4587,8 +4587,8 @@ static void Tst_WriteFloatAnsAssessTest (struct UsrData *UsrDat,
|
|||
|
||||
/***** Write the correct answer *****/
|
||||
HTM_TD_Begin ("class=\"ANS_0 CM\"");
|
||||
if (TsR_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsR_IsVisibleCorrectAns (Visibility))
|
||||
if (TsV_IsVisibleQstAndAnsTxt (Visibility) &&
|
||||
TsV_IsVisibleCorrectAns (Visibility))
|
||||
{
|
||||
HTM_Txt ("[");
|
||||
HTM_Double (FloatAnsCorr[0]);
|
||||
|
@ -4619,7 +4619,7 @@ static void Tst_WriteFloatAnsAssessTest (struct UsrData *UsrDat,
|
|||
}
|
||||
|
||||
/***** Write the score of this question *****/
|
||||
if (TsR_IsVisibleEachQstScore (Visibility))
|
||||
if (TsV_IsVisibleEachQstScore (Visibility))
|
||||
{
|
||||
Tst_WriteScoreStart (2);
|
||||
if (!Gbl.Test.StrAnswersOneQst[NumQst][0]) // If user has omitted the answer
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "swad_HTML.h"
|
||||
#include "swad_ID.h"
|
||||
#include "swad_test.h"
|
||||
#include "swad_test_result.h"
|
||||
#include "swad_test_visibility.h"
|
||||
#include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -349,7 +349,7 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
|
|||
case Rol_STD:
|
||||
ICanViewTest = ItsMe;
|
||||
ICanViewScore = ItsMe &&
|
||||
TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
|
||||
TsV_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 &&
|
||||
TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
|
||||
TsV_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
|
@ -607,7 +607,7 @@ void TsR_ShowOneTstResult (void)
|
|||
/***** Get test result data *****/
|
||||
TsR_GetTestResultDataByTstCod (TstCod,&TstTimeUTC,
|
||||
&NumQstsNotBlank,&TotalScore);
|
||||
Gbl.Test.Config.Visibility = TsR_MAX_VISIBILITY;
|
||||
Gbl.Test.Config.Visibility = TsV_MAX_VISIBILITY;
|
||||
|
||||
/***** Check if I can view this test result *****/
|
||||
ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
|
@ -618,7 +618,7 @@ void TsR_ShowOneTstResult (void)
|
|||
if (ItsMe)
|
||||
{
|
||||
Tst_GetConfigTstFromDB (); // To get feedback type
|
||||
ICanViewScore = TsR_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
|
||||
ICanViewScore = TsV_IsVisibleTotalScore (Gbl.Test.Config.Visibility);
|
||||
}
|
||||
else
|
||||
ICanViewScore = false;
|
||||
|
@ -1118,98 +1118,3 @@ void TsR_RemoveCrsTestResults (long CrsCod)
|
|||
"DELETE FROM tst_exams WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get type of feedback from form **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned TsR_GetVisibilityFromForm (void)
|
||||
{
|
||||
size_t MaxSizeListVisibilitySelected;
|
||||
char *StrVisibilitySelected;
|
||||
const char *Ptr;
|
||||
char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||
unsigned UnsignedNum;
|
||||
TsR_ResultVisibility_t VisibilityItem;
|
||||
unsigned Visibility = 0; // Nothing selected
|
||||
|
||||
/***** Allocate memory for list of attendance events selected *****/
|
||||
MaxSizeListVisibilitySelected = TsR_NUM_ITEMS_VISIBILITY * (Cns_MAX_DECIMAL_DIGITS_UINT + 1);
|
||||
if ((StrVisibilitySelected = (char *) malloc (MaxSizeListVisibilitySelected + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get parameter multiple with list of visibility items selected *****/
|
||||
Par_GetParMultiToText ("Visibility",StrVisibilitySelected,MaxSizeListVisibilitySelected);
|
||||
|
||||
/***** Set which attendance events will be shown as selected (checkboxes on) *****/
|
||||
if (StrVisibilitySelected[0]) // There are events selected
|
||||
for (Ptr = StrVisibilitySelected;
|
||||
*Ptr;
|
||||
)
|
||||
{
|
||||
/* Get next visibility item selected */
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT);
|
||||
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
|
||||
if (UnsignedNum < TsR_NUM_ITEMS_VISIBILITY)
|
||||
{
|
||||
VisibilityItem = (TsR_ResultVisibility_t) UnsignedNum;
|
||||
Visibility |= (1 << VisibilityItem);
|
||||
}
|
||||
}
|
||||
|
||||
return Visibility;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Put checkboxes in form to select result visibility *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TsR_PutVisibilityCheckboxes (unsigned SelectedVisibility)
|
||||
{
|
||||
extern const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY];
|
||||
TsR_ResultVisibility_t Visibility;
|
||||
|
||||
for (Visibility = (TsR_ResultVisibility_t) 0;
|
||||
Visibility <= (TsR_ResultVisibility_t) (TsR_NUM_ITEMS_VISIBILITY - 1);
|
||||
Visibility++)
|
||||
{
|
||||
HTM_LABEL_Begin ("class=\"DAT\"");
|
||||
HTM_INPUT_CHECKBOX ("Visibility",false,
|
||||
"value=\"%u\"%s",
|
||||
(unsigned) Visibility,
|
||||
(SelectedVisibility & (1 << Visibility)) != 0 ? " checked=\"checked\"" :
|
||||
"");
|
||||
HTM_Txt (Txt_TST_STR_VISIBILITY[Visibility]);
|
||||
HTM_LABEL_End ();
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -39,18 +39,6 @@
|
|||
/******************************* Public types ********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define TsR_NUM_ITEMS_VISIBILITY 5
|
||||
typedef enum
|
||||
{
|
||||
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
|
||||
} TsR_ResultVisibility_t;
|
||||
#define TsR_MAX_VISIBILITY ((1 << TsR_NUM_ITEMS_VISIBILITY) - 1) // All visible
|
||||
#define TsR_VISIBILITY_DEFAULT TsR_MAX_VISIBILITY
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -70,13 +58,4 @@ void TsR_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod);
|
|||
void TsR_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod);
|
||||
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
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
// swad_test_visibility.c: visibility of test results
|
||||
|
||||
/*
|
||||
SWAD (Shared Workspace At a Distance),
|
||||
is a web platform developed at the University of Granada (Spain),
|
||||
and used to support university teaching.
|
||||
|
||||
This file is part of SWAD core.
|
||||
Copyright (C) 1999-2020 Antonio Cañas Vargas
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/*********************************** Headers *********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_test_visibility.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public constants ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Private constants ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Private global variables **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get type of feedback from form **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned TsV_GetVisibilityFromForm (void)
|
||||
{
|
||||
size_t MaxSizeListVisibilitySelected;
|
||||
char *StrVisibilitySelected;
|
||||
const char *Ptr;
|
||||
char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||
unsigned UnsignedNum;
|
||||
TsV_ResultVisibility_t VisibilityItem;
|
||||
unsigned Visibility = 0; // Nothing selected
|
||||
|
||||
/***** Allocate memory for list of attendance events selected *****/
|
||||
MaxSizeListVisibilitySelected = TsV_NUM_ITEMS_VISIBILITY * (Cns_MAX_DECIMAL_DIGITS_UINT + 1);
|
||||
if ((StrVisibilitySelected = (char *) malloc (MaxSizeListVisibilitySelected + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get parameter multiple with list of visibility items selected *****/
|
||||
Par_GetParMultiToText ("Visibility",StrVisibilitySelected,MaxSizeListVisibilitySelected);
|
||||
|
||||
/***** Set which attendance events will be shown as selected (checkboxes on) *****/
|
||||
if (StrVisibilitySelected[0]) // There are events selected
|
||||
for (Ptr = StrVisibilitySelected;
|
||||
*Ptr;
|
||||
)
|
||||
{
|
||||
/* Get next visibility item selected */
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT);
|
||||
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
|
||||
if (UnsignedNum < TsV_NUM_ITEMS_VISIBILITY)
|
||||
{
|
||||
VisibilityItem = (TsV_ResultVisibility_t) UnsignedNum;
|
||||
Visibility |= (1 << VisibilityItem);
|
||||
}
|
||||
}
|
||||
|
||||
return Visibility;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Put checkboxes in form to select result visibility *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void TsV_PutVisibilityCheckboxes (unsigned SelectedVisibility)
|
||||
{
|
||||
extern const char *Txt_TST_STR_VISIBILITY[TsV_NUM_ITEMS_VISIBILITY];
|
||||
TsV_ResultVisibility_t Visibility;
|
||||
|
||||
for (Visibility = (TsV_ResultVisibility_t) 0;
|
||||
Visibility <= (TsV_ResultVisibility_t) (TsV_NUM_ITEMS_VISIBILITY - 1);
|
||||
Visibility++)
|
||||
{
|
||||
HTM_LABEL_Begin ("class=\"DAT\"");
|
||||
HTM_INPUT_CHECKBOX ("Visibility",false,
|
||||
"value=\"%u\"%s",
|
||||
(unsigned) Visibility,
|
||||
(SelectedVisibility & (1 << Visibility)) != 0 ? " checked=\"checked\"" :
|
||||
"");
|
||||
HTM_Txt (Txt_TST_STR_VISIBILITY[Visibility]);
|
||||
HTM_LABEL_End ();
|
||||
HTM_BR ();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Get visibility items **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool TsV_IsVisibleQstAndAnsTxt (unsigned Visibility)
|
||||
{
|
||||
return (Visibility & (1 << TsV_VISIBLE_QST_ANS_TXT)) != 0;
|
||||
}
|
||||
|
||||
bool TsV_IsVisibleFeedbackTxt (unsigned Visibility)
|
||||
{
|
||||
return (Visibility & (1 << TsV_VISIBLE_FEEDBACK_TXT)) != 0;
|
||||
}
|
||||
|
||||
bool TsV_IsVisibleCorrectAns (unsigned Visibility)
|
||||
{
|
||||
return (Visibility & (1 << TsV_VISIBLE_CORRECT_ANSWER)) != 0;
|
||||
}
|
||||
|
||||
bool TsV_IsVisibleEachQstScore (unsigned Visibility)
|
||||
{
|
||||
return (Visibility & (1 << TsV_VISIBLE_EACH_QST_SCORE)) != 0;
|
||||
}
|
||||
|
||||
bool TsV_IsVisibleTotalScore (unsigned Visibility)
|
||||
{
|
||||
return (Visibility & (1 << TsV_VISIBLE_TOTAL_SCORE)) != 0;
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
// swad_test_visibility.h: visibility of test results
|
||||
|
||||
#ifndef _SWAD_TSV
|
||||
#define _SWAD_TSV
|
||||
/*
|
||||
SWAD (Shared Workspace At a Distance in Spanish),
|
||||
is a web platform developed at the University of Granada (Spain),
|
||||
and used to support university teaching.
|
||||
|
||||
This file is part of SWAD core.
|
||||
Copyright (C) 1999-2020 Antonio Cañas Vargas
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "swad_user.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public constants ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Public types ********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define TsV_NUM_ITEMS_VISIBILITY 5
|
||||
typedef enum
|
||||
{
|
||||
TsV_VISIBLE_QST_ANS_TXT = 0, // Questions and answers text
|
||||
TsV_VISIBLE_FEEDBACK_TXT = 1, // Feedback text
|
||||
TsV_VISIBLE_CORRECT_ANSWER = 2, // Correct answers
|
||||
TsV_VISIBLE_EACH_QST_SCORE = 3, // Score of each question
|
||||
TsV_VISIBLE_TOTAL_SCORE = 4, // Total score
|
||||
} TsV_ResultVisibility_t;
|
||||
#define TsV_MAX_VISIBILITY ((1 << TsV_NUM_ITEMS_VISIBILITY) - 1) // All visible
|
||||
#define TsV_VISIBILITY_DEFAULT TsV_MAX_VISIBILITY
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned TsV_GetVisibilityFromForm (void);
|
||||
void TsV_PutVisibilityCheckboxes (unsigned SelectedVisibility);
|
||||
|
||||
bool TsV_IsVisibleQstAndAnsTxt (unsigned Visibility);
|
||||
bool TsV_IsVisibleFeedbackTxt (unsigned Visibility);
|
||||
bool TsV_IsVisibleCorrectAns (unsigned Visibility);
|
||||
bool TsV_IsVisibleEachQstScore (unsigned Visibility);
|
||||
bool TsV_IsVisibleTotalScore (unsigned Visibility);
|
||||
|
||||
#endif
|
13
swad_text.c
13
swad_text.c
|
@ -88,6 +88,7 @@
|
|||
#include "swad_syllabus.h"
|
||||
#include "swad_tab.h"
|
||||
#include "swad_test.h"
|
||||
#include "swad_test_visibility.h"
|
||||
#include "swad_timeline.h"
|
||||
#include "swad_timetable.h"
|
||||
#include "swad_user.h"
|
||||
|
@ -51466,9 +51467,9 @@ const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST] =
|
|||
#endif
|
||||
};
|
||||
|
||||
const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY] =
|
||||
const char *Txt_TST_STR_VISIBILITY[TsV_NUM_ITEMS_VISIBILITY] =
|
||||
{
|
||||
[TsR_VISIBLE_QST_ANS_TXT] =
|
||||
[TsV_VISIBLE_QST_ANS_TXT] =
|
||||
#if L==1 // ca
|
||||
"Text de preguntes i respostes"
|
||||
#elif L==2 // de
|
||||
|
@ -51489,7 +51490,7 @@ const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY] =
|
|||
"Texto de perguntas e respostas"
|
||||
#endif
|
||||
,
|
||||
[TsR_VISIBLE_FEEDBACK_TXT] =
|
||||
[TsV_VISIBLE_FEEDBACK_TXT] =
|
||||
#if L==1 // ca
|
||||
"Text de realimentació"
|
||||
#elif L==2 // de
|
||||
|
@ -51510,7 +51511,7 @@ const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY] =
|
|||
"Texto de feedback"
|
||||
#endif
|
||||
,
|
||||
[TsR_VISIBLE_CORRECT_ANSWER] =
|
||||
[TsV_VISIBLE_CORRECT_ANSWER] =
|
||||
#if L==1 // ca
|
||||
"Respostes correctes"
|
||||
#elif L==2 // de
|
||||
|
@ -51531,7 +51532,7 @@ const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY] =
|
|||
"Respostas corretas"
|
||||
#endif
|
||||
,
|
||||
[TsR_VISIBLE_EACH_QST_SCORE] =
|
||||
[TsV_VISIBLE_EACH_QST_SCORE] =
|
||||
#if L==1 // ca
|
||||
"Puntuació de cada pregunta"
|
||||
#elif L==2 // de
|
||||
|
@ -51552,7 +51553,7 @@ const char *Txt_TST_STR_VISIBILITY[TsR_NUM_ITEMS_VISIBILITY] =
|
|||
"Pontuação de cada pergunta"
|
||||
#endif
|
||||
,
|
||||
[TsR_VISIBLE_TOTAL_SCORE] =
|
||||
[TsV_VISIBLE_TOTAL_SCORE] =
|
||||
#if L==1 // ca
|
||||
"Puntuació total"
|
||||
#elif L==2 // de
|
||||
|
|
Loading…
Reference in New Issue