mirror of
https://github.com/acanas/swad-core.git
synced 2024-09-20 00:02:42 +02:00
Version19.151.1
This commit is contained in:
parent
71aa5870b4
commit
dccf76d355
|
@ -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.151 (2020-03-21)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.151.1 (2020-03-21)"
|
||||
#define CSS_FILE "swad19.146.css"
|
||||
#define JS_FILE "swad19.91.1.js"
|
||||
/*
|
||||
|
@ -524,6 +524,7 @@ Param
|
|||
// TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores
|
||||
// TODO: Si el alumno ha marcado "Permitir que los profesores...", entonces pedir confirmación al pulsar el botón azul, para evitar que se envíe por error antes de tiempo
|
||||
|
||||
Version 19.151.1: Mar 21, 2020 Code refactoring in tests. (283360 lines)
|
||||
Version 19.151: Mar 21, 2020 Code refactoring in tests.
|
||||
New module swad_test_config for test configuration. (283349 lines)
|
||||
Version 19.150: Mar 19, 2020 Code refactoring in tests. (283031 lines)
|
||||
|
|
|
@ -361,7 +361,6 @@ void Gbl_InitializeGlobals (void)
|
|||
// Tst_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
||||
// Tst_SetConfigVisibility (TsV_VISIBILITY_DEFAULT);
|
||||
Gbl.Test.NumQsts = TstCfg_DEFAULT_DEF_QUESTIONS;
|
||||
Gbl.Test.AllowTeachers = true; // Test result will be visible by teachers?
|
||||
Gbl.Test.AllAnsTypes = false;
|
||||
Gbl.Test.ListAnsTypes[0] = '\0';
|
||||
|
||||
|
|
|
@ -655,7 +655,6 @@ struct Globals
|
|||
long QstCodes[TstCfg_MAX_QUESTIONS_PER_TEST]; // Codes of the sent/received questions in a test
|
||||
char StrIndexesOneQst[TstCfg_MAX_QUESTIONS_PER_TEST][Tst_MAX_BYTES_INDEXES_ONE_QST + 1]; // 0 1 2 3, 3 0 2 1, etc.
|
||||
char StrAnswersOneQst[TstCfg_MAX_QUESTIONS_PER_TEST][Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user
|
||||
bool AllowTeachers; // Can teachers of this course see the test result?
|
||||
bool AllAnsTypes;
|
||||
char ListAnsTypes[Tst_MAX_BYTES_LIST_ANSWER_TYPES + 1];
|
||||
Tst_QuestionsOrder_t SelectedOrder;
|
||||
|
|
32
swad_test.c
32
swad_test.c
|
@ -481,9 +481,8 @@ void Tst_ShowNewTest (void)
|
|||
HTM_DIV_Begin ("class=\"CM\"");
|
||||
HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
||||
HTM_INPUT_CHECKBOX ("AllowTchs",HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"value=\"Y\"%s",
|
||||
Gbl.Test.AllowTeachers ? " checked=\"checked\"" :
|
||||
"");
|
||||
"value=\"Y\""
|
||||
" checked=\"checked\""); // By default, teachers can see test result
|
||||
HTM_TxtF (" %s",Txt_Allow_teachers_to_consult_this_test);
|
||||
HTM_LABEL_End ();
|
||||
HTM_DIV_End ();
|
||||
|
@ -528,6 +527,7 @@ void Tst_AssessTest (void)
|
|||
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;
|
||||
bool AllowTeachers; // Can teachers of this course see the test result?
|
||||
long TstCod = -1L; // Initialized to avoid warning
|
||||
unsigned NumQstsNotBlank;
|
||||
double TotalScore;
|
||||
|
@ -547,13 +547,13 @@ void Tst_AssessTest (void)
|
|||
Tst_GetParamNumQst ();
|
||||
|
||||
/***** Get if test will be visible by teachers *****/
|
||||
Gbl.Test.AllowTeachers = Par_GetParToBool ("AllowTchs");
|
||||
AllowTeachers = Par_GetParToBool ("AllowTchs");
|
||||
|
||||
/***** Get questions and answers from form to assess a test *****/
|
||||
Tst_GetQuestionsAndAnswersFromForm ();
|
||||
|
||||
/***** Create new test in database to store the result *****/
|
||||
TstCod = TsR_CreateTestResultInDB ();
|
||||
TstCod = TsR_CreateTestResultInDB (AllowTeachers);
|
||||
|
||||
/***** Begin box *****/
|
||||
Box_BoxBegin (NULL,Txt_Test_result,NULL,
|
||||
|
@ -625,21 +625,21 @@ static void Tst_GetQuestionsAndAnswersFromForm (void)
|
|||
{
|
||||
/* Get question code */
|
||||
snprintf (StrQstIndOrAns,sizeof (StrQstIndOrAns),
|
||||
"Qst%06u",
|
||||
"Qst%03u",
|
||||
NumQst);
|
||||
if ((Gbl.Test.QstCodes[NumQst] = Par_GetParToLong (StrQstIndOrAns)) <= 0)
|
||||
Lay_ShowErrorAndExit ("Code of question is missing.");
|
||||
|
||||
/* Get indexes for this question */
|
||||
snprintf (StrQstIndOrAns,sizeof (StrQstIndOrAns),
|
||||
"Ind%06u",
|
||||
"Ind%03u",
|
||||
NumQst);
|
||||
Par_GetParMultiToText (StrQstIndOrAns,Gbl.Test.StrIndexesOneQst[NumQst],
|
||||
Tst_MAX_BYTES_INDEXES_ONE_QST); /* If choice ==> "0", "1", "2",... */
|
||||
|
||||
/* Get answers selected by user for this question */
|
||||
snprintf (StrQstIndOrAns,sizeof (StrQstIndOrAns),
|
||||
"Ans%06u",
|
||||
"Ans%03u",
|
||||
NumQst);
|
||||
Par_GetParMultiToText (StrQstIndOrAns,Gbl.Test.StrAnswersOneQst[NumQst],
|
||||
Tst_MAX_BYTES_ANSWERS_ONE_QST); /* If answer type == T/F ==> " ", "T", "F"; if choice ==> "0", "2",... */
|
||||
|
@ -3545,7 +3545,7 @@ static void Tst_WriteTFAnsViewTest (unsigned NumQst)
|
|||
|
||||
/***** Write selector for the answer *****/
|
||||
HTM_SELECT_Begin (false,
|
||||
"name=\"Ans%06u\"",NumQst);
|
||||
"name=\"Ans%03u\"",NumQst);
|
||||
HTM_OPTION (HTM_Type_STRING,"" ,true ,false," ");
|
||||
HTM_OPTION (HTM_Type_STRING,"T",false,false,"%s",Txt_TF_QST[0]);
|
||||
HTM_OPTION (HTM_Type_STRING,"F",false,false,"%s",Txt_TF_QST[1]);
|
||||
|
@ -3746,16 +3746,16 @@ static void Tst_WriteChoiceAnsViewTest (unsigned NumQst,long QstCod,
|
|||
/***** Write selectors and letter of this option *****/
|
||||
HTM_TD_Begin ("class=\"LT\"");
|
||||
snprintf (ParamName,sizeof (ParamName),
|
||||
"Ind%06u",
|
||||
"Ind%03u",
|
||||
NumQst);
|
||||
Par_PutHiddenParamUnsigned (NULL,ParamName,Index);
|
||||
snprintf (StrAns,sizeof (StrAns),
|
||||
"Ans%06u",
|
||||
"Ans%03u",
|
||||
NumQst);
|
||||
if (Question.Answer.Type == Tst_ANS_UNIQUE_CHOICE)
|
||||
HTM_INPUT_RADIO (StrAns,false,
|
||||
"id=\"Ans%06u_%u\" value=\"%u\""
|
||||
" onclick=\"selectUnselectRadio(this,this.form.Ans%06u,%u);\"",
|
||||
" onclick=\"selectUnselectRadio(this,this.form.Ans%03u,%u);\"",
|
||||
NumQst,NumOpt,
|
||||
Index,
|
||||
NumQst,Question.Answer.NumOptions);
|
||||
|
@ -4287,7 +4287,7 @@ static void Tst_WriteTextAnsViewTest (unsigned NumQst)
|
|||
|
||||
/***** Write input field for the answer *****/
|
||||
snprintf (StrAns,sizeof (StrAns),
|
||||
"Ans%06u",
|
||||
"Ans%03u",
|
||||
NumQst);
|
||||
HTM_INPUT_TEXT (StrAns,Tst_MAX_BYTES_ANSWERS_ONE_QST,"",false,
|
||||
"size=\"40\"");
|
||||
|
@ -4502,7 +4502,7 @@ static void Tst_WriteIntAnsViewTest (unsigned NumQst)
|
|||
|
||||
/***** Write input field for the answer *****/
|
||||
snprintf (StrAns,sizeof (StrAns),
|
||||
"Ans%06u",
|
||||
"Ans%03u",
|
||||
NumQst);
|
||||
HTM_INPUT_TEXT (StrAns,11,"",false,
|
||||
"size=\"11\"");
|
||||
|
@ -4632,7 +4632,7 @@ static void Tst_WriteFloatAnsViewTest (unsigned NumQst)
|
|||
|
||||
/***** Write input field for the answer *****/
|
||||
snprintf (StrAns,sizeof (StrAns),
|
||||
"Ans%06u",
|
||||
"Ans%03u",
|
||||
NumQst);
|
||||
HTM_INPUT_TEXT (StrAns,Tst_MAX_BYTES_FLOAT_ANSWER,"",false,
|
||||
"size=\"11\"");
|
||||
|
@ -4820,7 +4820,7 @@ static void Tst_WriteParamQstCod (unsigned NumQst,long QstCod)
|
|||
char ParamName[3 + 6 + 1];
|
||||
|
||||
snprintf (ParamName,sizeof (ParamName),
|
||||
"Qst%06u",
|
||||
"Qst%03u",
|
||||
NumQst);
|
||||
Par_PutHiddenParamLong (NULL,ParamName,QstCod);
|
||||
}
|
||||
|
|
11
swad_test.h
11
swad_test.h
|
@ -42,8 +42,8 @@
|
|||
#define Tst_MAX_BYTES_TAG ((Tst_MAX_CHARS_TAG + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
||||
|
||||
#define Tst_MAX_OPTIONS_PER_QUESTION 10
|
||||
#define Tst_MAX_BYTES_INDEXES_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (10 + 1))
|
||||
#define Tst_MAX_BYTES_ANSWERS_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (10 + 1))
|
||||
#define Tst_MAX_BYTES_INDEXES_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (3 + 1))
|
||||
#define Tst_MAX_BYTES_ANSWERS_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (3 + 1))
|
||||
|
||||
#define Tst_MAX_CHARS_ANSWER_OR_FEEDBACK (1024 - 1) // 1023
|
||||
#define Tst_MAX_BYTES_ANSWER_OR_FEEDBACK ((Tst_MAX_CHARS_ANSWER_OR_FEEDBACK + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383
|
||||
|
@ -90,9 +90,10 @@ struct Tst_Test
|
|||
struct Tst_Tags Tags;
|
||||
unsigned NumQsts;
|
||||
long QstCodes[TstCfg_MAX_QUESTIONS_PER_TEST]; // Codes of the sent/received questions in a test
|
||||
char StrIndexesOneQst[TstCfg_MAX_QUESTIONS_PER_TEST][Tst_MAX_BYTES_INDEXES_ONE_QST + 1]; // 0 1 2 3, 3 0 2 1, etc.
|
||||
char StrAnswersOneQst[TstCfg_MAX_QUESTIONS_PER_TEST][Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user
|
||||
bool AllowTeachers; // Can teachers of this course see the test result?
|
||||
char StrIndexesOneQst[TstCfg_MAX_QUESTIONS_PER_TEST]
|
||||
[Tst_MAX_BYTES_INDEXES_ONE_QST + 1]; // 0 1 2 3, 3 0 2 1, etc.
|
||||
char StrAnswersOneQst[TstCfg_MAX_QUESTIONS_PER_TEST]
|
||||
[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user
|
||||
bool AllAnsTypes;
|
||||
char ListAnsTypes[Tst_MAX_BYTES_LIST_ANSWER_TYPES + 1];
|
||||
Tst_QuestionsOrder_t SelectedOrder;
|
||||
|
|
|
@ -86,8 +86,11 @@ static void TsR_ShowTestResultsSummaryRow (bool ItsMe,
|
|||
unsigned NumTotalQstsNotBlank,
|
||||
double TotalScoreOfAllTests);
|
||||
static void TsR_ShowTstTagsPresentInATestResult (long TstCod);
|
||||
static void TsR_GetTestResultDataByTstCod (long TstCod,time_t *TstTimeUTC,
|
||||
unsigned *NumQstsNotBlank,double *Score);
|
||||
static void TsR_GetTestResultDataByTstCod (long TstCod,
|
||||
bool *AllowTeachers,
|
||||
time_t *TstTimeUTC,
|
||||
unsigned *NumQstsNotBlank,
|
||||
double *Score);
|
||||
static void TsR_GetTestResultQuestionsFromDB (long TstCod);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -169,7 +172,7 @@ void TsR_ShowMyTstResults (void)
|
|||
/********************* Store test result in database *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
long TsR_CreateTestResultInDB (void)
|
||||
long TsR_CreateTestResultInDB (bool AllowTeachers)
|
||||
{
|
||||
/***** Insert new test result into table *****/
|
||||
return
|
||||
|
@ -180,7 +183,7 @@ long TsR_CreateTestResultInDB (void)
|
|||
" (%ld,%ld,'%c',NOW(),%u)",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Test.AllowTeachers ? 'Y' :
|
||||
AllowTeachers ? 'Y' :
|
||||
'N',
|
||||
Gbl.Test.NumQsts);
|
||||
}
|
||||
|
@ -303,6 +306,7 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
|
|||
double ScoreInThisTest;
|
||||
double TotalScoreOfAllTests = 0.0;
|
||||
unsigned NumExamsVisibleByTchs = 0;
|
||||
bool AllowTeachers; // Can teachers of this course see the test result?
|
||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||
bool ICanViewTest;
|
||||
bool ICanViewScore;
|
||||
|
@ -346,8 +350,8 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
|
|||
Lay_ShowErrorAndExit ("Wrong code of test result.");
|
||||
|
||||
/* Get if teachers are allowed to see this test result (row[1]) */
|
||||
Gbl.Test.AllowTeachers = (row[1][0] == 'Y');
|
||||
ClassDat = Gbl.Test.AllowTeachers ? "DAT" :
|
||||
AllowTeachers = (row[1][0] == 'Y');
|
||||
ClassDat = AllowTeachers ? "DAT" :
|
||||
"DAT_LIGHT";
|
||||
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
|
@ -364,7 +368,7 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
|
|||
case Rol_INS_ADM:
|
||||
ICanViewTest =
|
||||
ICanViewScore = ItsMe ||
|
||||
Gbl.Test.AllowTeachers;
|
||||
AllowTeachers;
|
||||
break;
|
||||
case Rol_SYS_ADM:
|
||||
ICanViewTest =
|
||||
|
@ -395,13 +399,13 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
|
|||
/* Get number of questions (row[3]) */
|
||||
if (sscanf (row[3],"%u",&NumQstsInThisTest) != 1)
|
||||
NumQstsInThisTest = 0;
|
||||
if (Gbl.Test.AllowTeachers)
|
||||
if (AllowTeachers)
|
||||
NumTotalQsts += NumQstsInThisTest;
|
||||
|
||||
/* Get number of questions not blank (row[4]) */
|
||||
if (sscanf (row[4],"%u",&NumQstsNotBlankInThisTest) != 1)
|
||||
NumQstsNotBlankInThisTest = 0;
|
||||
if (Gbl.Test.AllowTeachers)
|
||||
if (AllowTeachers)
|
||||
NumTotalQstsNotBlank += NumQstsNotBlankInThisTest;
|
||||
|
||||
/* Get score (row[5]) */
|
||||
|
@ -409,7 +413,7 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
|
|||
if (sscanf (row[5],"%lf",&ScoreInThisTest) != 1)
|
||||
ScoreInThisTest = 0.0;
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
if (Gbl.Test.AllowTeachers)
|
||||
if (AllowTeachers)
|
||||
TotalScoreOfAllTests += ScoreInThisTest;
|
||||
|
||||
/* Write number of questions */
|
||||
|
@ -457,7 +461,7 @@ static void TsR_ShowTstResults (struct UsrData *UsrDat)
|
|||
HTM_TD_End ();
|
||||
HTM_TR_End ();
|
||||
|
||||
if (Gbl.Test.AllowTeachers)
|
||||
if (AllowTeachers)
|
||||
NumExamsVisibleByTchs++;
|
||||
}
|
||||
|
||||
|
@ -597,6 +601,7 @@ void TsR_ShowOneTstResult (void)
|
|||
extern const char *Txt_Grade;
|
||||
extern const char *Txt_Tags;
|
||||
long TstCod;
|
||||
bool AllowTeachers = false; // Initialized to avoid warning
|
||||
time_t TstTimeUTC = 0; // Test result UTC date-time, initialized to avoid warning
|
||||
unsigned NumQstsNotBlank;
|
||||
double TotalScore;
|
||||
|
@ -611,8 +616,11 @@ void TsR_ShowOneTstResult (void)
|
|||
Lay_ShowErrorAndExit ("Code of test is missing.");
|
||||
|
||||
/***** Get test result data *****/
|
||||
TsR_GetTestResultDataByTstCod (TstCod,&TstTimeUTC,
|
||||
&NumQstsNotBlank,&TotalScore);
|
||||
TsR_GetTestResultDataByTstCod (TstCod,
|
||||
&AllowTeachers,
|
||||
&TstTimeUTC,
|
||||
&NumQstsNotBlank,
|
||||
&TotalScore);
|
||||
TstCfg_SetConfigVisibility (TsV_MAX_VISIBILITY);
|
||||
|
||||
/***** Check if I can view this test result *****/
|
||||
|
@ -642,7 +650,7 @@ void TsR_ShowOneTstResult (void)
|
|||
case ActSeeOneTstResOth:
|
||||
ICanViewTest =
|
||||
ICanViewScore = ItsMe ||
|
||||
Gbl.Test.AllowTeachers;
|
||||
AllowTeachers;
|
||||
break;
|
||||
default:
|
||||
ICanViewTest =
|
||||
|
@ -932,8 +940,11 @@ void TsR_ShowTestResult (struct UsrData *UsrDat,
|
|||
/********* Get data of a test result using its test result code **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void TsR_GetTestResultDataByTstCod (long TstCod,time_t *TstTimeUTC,
|
||||
unsigned *NumQstsNotBlank,double *Score)
|
||||
static void TsR_GetTestResultDataByTstCod (long TstCod,
|
||||
bool *AllowTeachers,
|
||||
time_t *TstTimeUTC,
|
||||
unsigned *NumQstsNotBlank,
|
||||
double *Score)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
|
@ -958,7 +969,7 @@ static void TsR_GetTestResultDataByTstCod (long TstCod,time_t *TstTimeUTC,
|
|||
Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/* Get if teachers are allowed to see this test result (row[1]) */
|
||||
Gbl.Test.AllowTeachers = (row[1][0] == 'Y');
|
||||
*AllowTeachers = (row[1][0] == 'Y');
|
||||
|
||||
/* Get date-time (row[2] holds UTC date-time) */
|
||||
*TstTimeUTC = Dat_GetUNIXTimeFromStr (row[2]);
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
void TsR_SelUsrsToViewUsrsTstResults (void);
|
||||
void TsR_SelDatesToSeeMyTstResults (void);
|
||||
void TsR_ShowMyTstResults (void);
|
||||
long TsR_CreateTestResultInDB (void);
|
||||
long TsR_CreateTestResultInDB (bool AllowTeachers);
|
||||
void TsR_StoreScoreOfTestResultInDB (long TstCod,
|
||||
unsigned NumQstsNotBlank,double Score);
|
||||
void TsR_GetUsrsAndShowTstResults (void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user