Version 21.42.2: Oct 25, 2021 Code refactoring in test questions.

This commit is contained in:
acanas 2021-10-25 09:48:54 +02:00
parent 9ab6f4c2d5
commit b097b0eda9
11 changed files with 91 additions and 78 deletions

View File

@ -4303,10 +4303,10 @@ static int API_GetTstQuestions (struct soap *soap,
/* Get answer type (row[1]) */ /* Get answer type (row[1]) */
AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
getTestsOut->questionsArray.__ptr[NumRow].answerType = getTestsOut->questionsArray.__ptr[NumRow].answerType =
soap_malloc (soap,Tst_MAX_BYTES_ANSWER_TYPE + 1); soap_malloc (soap,Qst_MAX_BYTES_ANSWER_TYPE + 1);
Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].answerType, Str_Copy (getTestsOut->questionsArray.__ptr[NumRow].answerType,
Tst_StrAnswerTypesXML[AnswerType], Tst_StrAnswerTypesXML[AnswerType],
Tst_MAX_BYTES_ANSWER_TYPE); Qst_MAX_BYTES_ANSWER_TYPE);
/* Get shuffle (row[2]) */ /* Get shuffle (row[2]) */
getTestsOut->questionsArray.__ptr[NumRow].shuffle = (row[2][0] == 'Y') ? 1 : getTestsOut->questionsArray.__ptr[NumRow].shuffle = (row[2][0] == 'Y') ? 1 :
@ -4651,9 +4651,9 @@ int swad__getTrivialQuestion (struct soap *soap,
/* Get answer type (row[1]) */ /* Get answer type (row[1]) */
AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); AnswerType = Qst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
getTrivialQuestionOut->question.answerType = getTrivialQuestionOut->question.answerType =
soap_malloc (soap,Tst_MAX_BYTES_ANSWER_TYPE + 1); soap_malloc (soap,Qst_MAX_BYTES_ANSWER_TYPE + 1);
Str_Copy (getTrivialQuestionOut->question.answerType, Str_Copy (getTrivialQuestionOut->question.answerType,
Tst_StrAnswerTypesXML[AnswerType],Tst_MAX_BYTES_ANSWER_TYPE); Tst_StrAnswerTypesXML[AnswerType],Qst_MAX_BYTES_ANSWER_TYPE);
/* Get shuffle (row[2]) */ /* Get shuffle (row[2]) */
getTrivialQuestionOut->question.shuffle = (row[2][0] == 'Y') ? 1 : getTrivialQuestionOut->question.shuffle = (row[2][0] == 'Y') ? 1 :

View File

@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/ */
#define Log_PLATFORM_VERSION "SWAD 21.42.1 (2021-10-25)" #define Log_PLATFORM_VERSION "SWAD 21.42.2 (2021-10-25)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 21.42.2: Oct 25, 2021 Code refactoring in test questions. (320795 lines)
Version 21.42.1: Oct 25, 2021 Code refactoring in test questions. (320784 lines) Version 21.42.1: Oct 25, 2021 Code refactoring in test questions. (320784 lines)
Version 21.42: Oct 24, 2021 Code refactoring in test questions. (320782 lines) Version 21.42: Oct 24, 2021 Code refactoring in test questions. (320782 lines)
Version 21.41.2: Oct 24, 2021 Query moved to module swad_setting_database. (320777 lines) Version 21.41.2: Oct 24, 2021 Query moved to module swad_setting_database. (320777 lines)

View File

@ -1841,6 +1841,9 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
/***** Remove all tests in the course *****/ /***** Remove all tests in the course *****/
Tst_RemoveCrsTests (CrsCod); Tst_RemoveCrsTests (CrsCod);
/***** Remove all questions in the course *****/
Qst_RemoveCrsQsts (CrsCod);
/***** Remove groups in the course *****/ /***** Remove groups in the course *****/
Grp_DB_RemoveCrsGrps (CrsCod); Grp_DB_RemoveCrsGrps (CrsCod);

View File

@ -31,7 +31,7 @@
#include "swad_exam_print.h" #include "swad_exam_print.h"
#include "swad_exam_session.h" #include "swad_exam_session.h"
#include "swad_exam_set.h" #include "swad_exam_set.h"
#include "swad_test_type.h" #include "swad_question_type.h"
/*****************************************************************************/ /*****************************************************************************/
/************************* Public types and constants ************************/ /************************* Public types and constants ************************/

View File

@ -29,7 +29,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "swad_exam_type.h" #include "swad_exam_type.h"
#include "swad_test_type.h" #include "swad_question_type.h"
/*****************************************************************************/ /*****************************************************************************/
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/

View File

@ -1,7 +1,7 @@
// swad_test_type.h: definition of types for tests // swad_question_type.h: definition of types for questions
#ifndef _SWAD_TST_TYP #ifndef _SWAD_QST_TYP
#define _SWAD_TST_TYP #define _SWAD_QST_TYP
/* /*
SWAD (Shared Workspace At a Distance in Spanish), SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain), is a web platform developed at the University of Granada (Spain),
@ -43,8 +43,6 @@
#define Qst_MAX_CHARS_ANSWERS_ONE_QST (128 - 1) // 127 #define Qst_MAX_CHARS_ANSWERS_ONE_QST (128 - 1) // 127
#define Qst_MAX_BYTES_ANSWERS_ONE_QST ((Qst_MAX_CHARS_ANSWERS_ONE_QST + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Qst_MAX_BYTES_ANSWERS_ONE_QST ((Qst_MAX_CHARS_ANSWERS_ONE_QST + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
#define Tst_SCORE_MAX 10 // Maximum score of a test (10 in Spain). Must be unsigned! // TODO: Make this configurable by teachers
/*****************************************************************************/ /*****************************************************************************/
/******************************* Public types ********************************/ /******************************* Public types ********************************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -66,7 +66,7 @@
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
/*****************************************************************************/ /*****************************************************************************/
// strings are limited to Tst_MAX_BYTES_ANSWER_TYPE characters // strings are limited to Qst_MAX_BYTES_ANSWER_TYPE characters
const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES] = const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES] =
{ {
[Qst_ANS_INT ] = "int", [Qst_ANS_INT ] = "int",
@ -148,7 +148,7 @@ static void Tst_ShowFormConfigTst (void);
static void Tst_PutInputFieldNumQst (const char *Field,const char *Label, static void Tst_PutInputFieldNumQst (const char *Field,const char *Label,
unsigned Value); unsigned Value);
static void Tst_ShowFormAnswerTypes (const struct Tst_AnswerTypes *AnswerTypes); static void Tst_ShowFormAnswerTypes (const struct Qst_AnswerTypes *AnswerTypes);
static void Qst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res); static void Qst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res);
static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test, static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
struct TstPrn_Print *Print); struct TstPrn_Print *Print);
@ -192,7 +192,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
static unsigned Tst_GetParamNumTst (void); static unsigned Tst_GetParamNumTst (void);
static unsigned Tst_GetParamNumQsts (void); static unsigned Tst_GetParamNumQsts (void);
static unsigned Tst_CountNumTagsInList (const struct Tag_Tags *Tags); static unsigned Tst_CountNumTagsInList (const struct Tag_Tags *Tags);
static int Tst_CountNumAnswerTypesInList (const struct Tst_AnswerTypes *AnswerTypes); static int Tst_CountNumAnswerTypesInList (const struct Qst_AnswerTypes *AnswerTypes);
static void Qst_PutFormEditOneQst (struct Qst_Question *Question); static void Qst_PutFormEditOneQst (struct Qst_Question *Question);
static void Qst_PutFloatInputField (const char *Label,const char *Field, static void Qst_PutFloatInputField (const char *Label,const char *Field,
@ -266,7 +266,7 @@ static void Tst_Constructor (struct Tst_Test *Test)
Test->AnswerTypes.List[0] = '\0'; Test->AnswerTypes.List[0] = '\0';
/***** Reset selected order *****/ /***** Reset selected order *****/
Test->SelectedOrder = Tst_DEFAULT_ORDER; Test->SelectedOrder = Qst_DEFAULT_ORDER;
/***** Question constructor *****/ /***** Question constructor *****/
Qst_QstConstructor (&Test->Question); Qst_QstConstructor (&Test->Question);
@ -990,7 +990,7 @@ static void Qst_ShowFormRequestEditQsts (struct Tst_Test *Test)
if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res))) if ((Test->Tags.Num = Tag_DB_GetAllTagsFromCurrentCrs (&mysql_res)))
{ {
Frm_BeginForm (ActLstTstQst); Frm_BeginForm (ActLstTstQst);
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Tst_DEFAULT_ORDER); Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Qst_DEFAULT_ORDER);
HTM_TABLE_BeginPadding (2); HTM_TABLE_BeginPadding (2);
@ -1533,7 +1533,7 @@ static void Tst_PutInputFieldNumQst (const char *Field,const char *Label,
/***************** Show form for select the types of answers *****************/ /***************** Show form for select the types of answers *****************/
/*****************************************************************************/ /*****************************************************************************/
static void Tst_ShowFormAnswerTypes (const struct Tst_AnswerTypes *AnswerTypes) static void Tst_ShowFormAnswerTypes (const struct Qst_AnswerTypes *AnswerTypes)
{ {
extern const char *The_ClassFormInBox[The_NUM_THEMES]; extern const char *The_ClassFormInBox[The_NUM_THEMES];
extern const char *Txt_Types_of_answers; extern const char *Txt_Types_of_answers;
@ -1619,7 +1619,7 @@ void Qst_ListQuestionsToEdit (void)
Tst_Constructor (&Test); Tst_Constructor (&Test);
/***** Get parameters, query the database and list the questions *****/ /***** Get parameters, query the database and list the questions *****/
if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters from the form if (Tst_GetParamsTst (&Test,Tst_EDIT_QUESTIONS)) // Get parameters from the form
{ {
/***** Get question codes from database *****/ /***** Get question codes from database *****/
Qst_GetQuestions (&Test,&mysql_res); // Query database Qst_GetQuestions (&Test,&mysql_res); // Query database
@ -1814,27 +1814,27 @@ static void Qst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
switch (Test->SelectedOrder) switch (Test->SelectedOrder)
{ {
case Tst_ORDER_STEM: case Qst_ORDER_STEM:
Str_Concat (Query," ORDER BY tst_questions.Stem", Str_Concat (Query," ORDER BY tst_questions.Stem",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
break; break;
case Tst_ORDER_NUM_HITS: case Qst_ORDER_NUM_HITS:
Str_Concat (Query," ORDER BY tst_questions.NumHits DESC," Str_Concat (Query," ORDER BY tst_questions.NumHits DESC,"
"tst_questions.Stem", "tst_questions.Stem",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
break; break;
case Tst_ORDER_AVERAGE_SCORE: case Qst_ORDER_AVERAGE_SCORE:
Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHits DESC," Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHits DESC,"
"tst_questions.NumHits DESC," "tst_questions.NumHits DESC,"
"tst_questions.Stem", "tst_questions.Stem",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
break; break;
case Tst_ORDER_NUM_HITS_NOT_BLANK: case Qst_ORDER_NUM_HITS_NOT_BLANK:
Str_Concat (Query," ORDER BY tst_questions.NumHitsNotBlank DESC," Str_Concat (Query," ORDER BY tst_questions.NumHitsNotBlank DESC,"
"tst_questions.Stem", "tst_questions.Stem",
Tst_MAX_BYTES_QUERY_TEST); Tst_MAX_BYTES_QUERY_TEST);
break; break;
case Tst_ORDER_AVERAGE_SCORE_NOT_BLANK: case Qst_ORDER_AVERAGE_SCORE_NOT_BLANK:
Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHitsNotBlank DESC," Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHitsNotBlank DESC,"
"tst_questions.NumHitsNotBlank DESC," "tst_questions.NumHitsNotBlank DESC,"
"tst_questions.Stem", "tst_questions.Stem",
@ -2182,9 +2182,9 @@ static void Qst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test)
extern const char *Txt_Date; extern const char *Txt_Date;
extern const char *Txt_Tags; extern const char *Txt_Tags;
extern const char *Txt_Shuffle; extern const char *Txt_Shuffle;
extern const char *Txt_TST_STR_ORDER_FULL[Tst_NUM_TYPES_ORDER_QST]; extern const char *Txt_TST_STR_ORDER_FULL[Qst_NUM_TYPES_ORDER_QST];
extern const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST]; extern const char *Txt_TST_STR_ORDER_SHORT[Qst_NUM_TYPES_ORDER_QST];
Tst_QuestionsOrder_t Order; Qst_QuestionsOrder_t Order;
/***** Begin row *****/ /***** Begin row *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
@ -2201,8 +2201,8 @@ static void Qst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test)
/* Stem and answers of question */ /* Stem and answers of question */
/* Number of times that the question has been answered */ /* Number of times that the question has been answered */
/* Average score */ /* Average score */
for (Order = (Tst_QuestionsOrder_t) 0; for (Order = (Qst_QuestionsOrder_t) 0;
Order <= (Tst_QuestionsOrder_t) (Tst_NUM_TYPES_ORDER_QST - 1); Order <= (Qst_QuestionsOrder_t) (Qst_NUM_TYPES_ORDER_QST - 1);
Order++) Order++)
{ {
HTM_TH_Begin (1,1,"LT"); HTM_TH_Begin (1,1,"LT");
@ -2926,7 +2926,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
switch (ActionToDoWithQuestions) switch (ActionToDoWithQuestions)
{ {
case Tst_SHOW_TEST_TO_ANSWER: case Tst_SHOW_TEST_TO_ANSWER:
case Tst_EDIT_TEST: case Tst_EDIT_QUESTIONS:
case Tst_SELECT_QUESTIONS_FOR_EXAM: case Tst_SELECT_QUESTIONS_FOR_EXAM:
/* Get parameter that indicates if all types of answer are selected */ /* Get parameter that indicates if all types of answer are selected */
Test->AnswerTypes.All = Par_GetParToBool ("AllAnsTypes"); Test->AnswerTypes.All = Par_GetParToBool ("AllAnsTypes");
@ -2964,18 +2964,18 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
Error = true; Error = true;
} }
break; break;
case Tst_EDIT_TEST: case Tst_EDIT_QUESTIONS:
/* Get starting and ending dates */ /* Get starting and ending dates */
Dat_GetIniEndDatesFromForm (); Dat_GetIniEndDatesFromForm ();
/* Get ordering criteria */ /* Get ordering criteria */
Par_GetParMultiToText ("Order",UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT); Par_GetParMultiToText ("Order",UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT);
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1) if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
Test->SelectedOrder = (Tst_QuestionsOrder_t) Test->SelectedOrder = (Qst_QuestionsOrder_t)
((UnsignedNum < Tst_NUM_TYPES_ORDER_QST) ? UnsignedNum : ((UnsignedNum < Qst_NUM_TYPES_ORDER_QST) ? UnsignedNum :
0); 0);
else else
Test->SelectedOrder = (Tst_QuestionsOrder_t) 0; Test->SelectedOrder = (Qst_QuestionsOrder_t) 0;
break; break;
case Tst_SELECT_QUESTIONS_FOR_EXAM: case Tst_SELECT_QUESTIONS_FOR_EXAM:
case Tst_SELECT_QUESTIONS_FOR_GAME: case Tst_SELECT_QUESTIONS_FOR_GAME:
@ -2983,7 +2983,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
Dat_GetIniEndDatesFromForm (); Dat_GetIniEndDatesFromForm ();
/* Order question by stem */ /* Order question by stem */
Test->SelectedOrder = Tst_ORDER_STEM; Test->SelectedOrder = Qst_ORDER_STEM;
break; break;
default: default:
break; break;
@ -3041,7 +3041,7 @@ static unsigned Tst_CountNumTagsInList (const struct Tag_Tags *Tags)
/**** Count the number of types of answers in the list of types of answers ***/ /**** Count the number of types of answers in the list of types of answers ***/
/*****************************************************************************/ /*****************************************************************************/
static int Tst_CountNumAnswerTypesInList (const struct Tst_AnswerTypes *AnswerTypes) static int Tst_CountNumAnswerTypesInList (const struct Qst_AnswerTypes *AnswerTypes)
{ {
const char *Ptr; const char *Ptr;
int NumAnsTypes = 0; int NumAnsTypes = 0;
@ -4593,7 +4593,7 @@ void Qst_RequestRemoveSelectedQsts (void)
Tst_Constructor (&Test); Tst_Constructor (&Test);
/***** Get parameters *****/ /***** Get parameters *****/
if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters from the form if (Tst_GetParamsTst (&Test,Tst_EDIT_QUESTIONS)) // Get parameters from the form
{ {
/***** Show question and button to remove question *****/ /***** Show question and button to remove question *****/
Ale_ShowAlertAndButton (ActRemSevTstQst,NULL,NULL, Ale_ShowAlertAndButton (ActRemSevTstQst,NULL,NULL,
@ -4628,7 +4628,7 @@ void Qst_RemoveSelectedQsts (void)
Tst_Constructor (&Test); Tst_Constructor (&Test);
/***** Get parameters *****/ /***** Get parameters *****/
if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters if (Tst_GetParamsTst (&Test,Tst_EDIT_QUESTIONS)) // Get parameters
{ {
/***** Get question codes *****/ /***** Get question codes *****/
Qst_GetQuestions (&Test,&mysql_res); // Query database Qst_GetQuestions (&Test,&mysql_res); // Query database
@ -4694,7 +4694,7 @@ void Qst_RequestRemoveOneQst (void)
/* Get other parameters */ /* Get other parameters */
if (!EditingOnlyThisQst) if (!EditingOnlyThisQst)
if (!Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) if (!Tst_GetParamsTst (&Test,Tst_EDIT_QUESTIONS))
Err_ShowErrorAndExit ("Wrong test parameters."); Err_ShowErrorAndExit ("Wrong test parameters.");
/***** Show question and button to remove question *****/ /***** Show question and button to remove question *****/
@ -5036,7 +5036,7 @@ static void Qst_InsertAnswersIntoDB (struct Qst_Question *Question)
/*********************** Update the score of a question **********************/ /*********************** Update the score of a question **********************/
/*****************************************************************************/ /*****************************************************************************/
void Tst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion) void Qst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion)
{ {
/***** Update number of clicks and score of the question *****/ /***** Update number of clicks and score of the question *****/
Str_SetDecimalPointToUS (); // To print the floating point as a dot Str_SetDecimalPointToUS (); // To print the floating point as a dot
@ -5059,7 +5059,7 @@ void Tst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion)
} }
/*****************************************************************************/ /*****************************************************************************/
/**************** Remove all tests and questions in a course *****************/ /************************* Remove all tests in a course **********************/
/*****************************************************************************/ /*****************************************************************************/
void Tst_RemoveCrsTests (long CrsCod) void Tst_RemoveCrsTests (long CrsCod)
@ -5072,7 +5072,14 @@ void Tst_RemoveCrsTests (long CrsCod)
"DELETE FROM tst_config" "DELETE FROM tst_config"
" WHERE CrsCod=%ld", " WHERE CrsCod=%ld",
CrsCod); CrsCod);
}
/*****************************************************************************/
/********************* Remove all questions in a course **********************/
/*****************************************************************************/
void Qst_RemoveCrsQsts (long CrsCod)
{
/***** Remove associations between test questions /***** Remove associations between test questions
and test tags in the course *****/ and test tags in the course *****/
DB_QueryDELETE ("can not remove tags associated" DB_QueryDELETE ("can not remove tags associated"
@ -5133,13 +5140,14 @@ static void Qst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod)
unsigned NumMedia; unsigned NumMedia;
/***** Get media code associated to stem of test question from database *****/ /***** Get media code associated to stem of test question from database *****/
NumMedia = NumMedia = (unsigned)
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media", DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT MedCod" "SELECT MedCod"
" FROM tst_questions" " FROM tst_questions"
" WHERE QstCod=%ld" " WHERE QstCod=%ld"
" AND CrsCod=%ld", // Extra check " AND CrsCod=%ld", // Extra check
QstCod,CrsCod); QstCod,
CrsCod);
/***** Go over result removing media *****/ /***** Go over result removing media *****/
Med_RemoveMediaFromAllRows (NumMedia,mysql_res); Med_RemoveMediaFromAllRows (NumMedia,mysql_res);

View File

@ -30,9 +30,9 @@
#include "swad_exam.h" #include "swad_exam.h"
#include "swad_game.h" #include "swad_game.h"
#include "swad_media.h" #include "swad_media.h"
#include "swad_question_type.h"
#include "swad_test_config.h" #include "swad_test_config.h"
#include "swad_test_print.h" #include "swad_test_print.h"
#include "swad_test_type.h"
/*****************************************************************************/ /*****************************************************************************/
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
@ -41,34 +41,36 @@
#define Tst_MAX_CHARS_ANSWER_OR_FEEDBACK (1024 - 1) // 1023 #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 #define Tst_MAX_BYTES_ANSWER_OR_FEEDBACK ((Tst_MAX_CHARS_ANSWER_OR_FEEDBACK + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383
#define Tst_MAX_BYTES_ANSWER_TYPE 32 #define Qst_MAX_BYTES_ANSWER_TYPE 32
#define Tst_SCORE_MAX 10 // Maximum score of a test (10 in Spain). Must be unsigned! // TODO: Make this configurable by teachers
/*****************************************************************************/ /*****************************************************************************/
/******************************* Public types ********************************/ /******************************* Public types ********************************/
/*****************************************************************************/ /*****************************************************************************/
struct Tst_AnswerTypes struct Qst_AnswerTypes
{ {
bool All; bool All;
char List[Qst_MAX_BYTES_LIST_ANSWER_TYPES + 1]; char List[Qst_MAX_BYTES_LIST_ANSWER_TYPES + 1];
}; };
#define Tst_NUM_TYPES_ORDER_QST 5 #define Qst_NUM_TYPES_ORDER_QST 5
typedef enum typedef enum
{ {
Tst_ORDER_STEM = 0, Qst_ORDER_STEM = 0,
Tst_ORDER_NUM_HITS = 1, Qst_ORDER_NUM_HITS = 1,
Tst_ORDER_AVERAGE_SCORE = 2, Qst_ORDER_AVERAGE_SCORE = 2,
Tst_ORDER_NUM_HITS_NOT_BLANK = 3, Qst_ORDER_NUM_HITS_NOT_BLANK = 3,
Tst_ORDER_AVERAGE_SCORE_NOT_BLANK = 4, Qst_ORDER_AVERAGE_SCORE_NOT_BLANK = 4,
} Tst_QuestionsOrder_t; } Qst_QuestionsOrder_t;
#define Tst_DEFAULT_ORDER Tst_ORDER_STEM #define Qst_DEFAULT_ORDER Qst_ORDER_STEM
struct Tst_Test struct Tst_Test
{ {
struct Tag_Tags Tags; // Selected tags struct Tag_Tags Tags; // Selected tags
struct Tst_AnswerTypes AnswerTypes; // Selected answer types struct Qst_AnswerTypes AnswerTypes; // Selected answer types
Tst_QuestionsOrder_t SelectedOrder; // Order for listing questions Qst_QuestionsOrder_t SelectedOrder; // Order for listing questions
unsigned NumQsts; // Number of questions unsigned NumQsts; // Number of questions
struct Qst_Question Question; // Selected / editing question struct Qst_Question Question; // Selected / editing question
}; };
@ -77,7 +79,7 @@ typedef enum
{ {
Tst_SHOW_TEST_TO_ANSWER, // Showing a test to a student Tst_SHOW_TEST_TO_ANSWER, // Showing a test to a student
Tst_SHOW_TEST_RESULT, // Showing the assessment of a test Tst_SHOW_TEST_RESULT, // Showing the assessment of a test
Tst_EDIT_TEST, // Editing test questions Tst_EDIT_QUESTIONS, // Editing test questions
Tst_SELECT_QUESTIONS_FOR_EXAM, // Selecting test questions for a set of questions in an exam Tst_SELECT_QUESTIONS_FOR_EXAM, // Selecting test questions for a set of questions in an exam
Tst_SELECT_QUESTIONS_FOR_GAME, // Selecting test questions for a game Tst_SELECT_QUESTIONS_FOR_GAME, // Selecting test questions for a game
} Tst_ActionToDoWithQuestions_t; } Tst_ActionToDoWithQuestions_t;
@ -173,9 +175,10 @@ void Qst_PutParamQstCod (void *QstCod);
void Qst_InsertOrUpdateQstTagsAnsIntoDB (struct Qst_Question *Question); void Qst_InsertOrUpdateQstTagsAnsIntoDB (struct Qst_Question *Question);
void Tst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion); void Qst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion);
void Tst_RemoveCrsTests (long CrsCod); void Tst_RemoveCrsTests (long CrsCod);
void Qst_RemoveCrsQsts (long CrsCod);
void Tst_GetTestStats (Qst_AnswerType_t AnsType,struct Tst_Stats *Stats); void Tst_GetTestStats (Qst_AnswerType_t AnsType,struct Tst_Stats *Stats);

View File

@ -633,7 +633,7 @@ void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print)
/***** Update the number of accesses and the score of this question *****/ /***** Update the number of accesses and the score of this question *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_STD) if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[QstInd]); Qst_UpdateQstScoreInDB (&Print->PrintedQuestions[QstInd]);
/***** Destroy test question *****/ /***** Destroy test question *****/
Qst_QstDestructor (&Question); Qst_QstDestructor (&Question);
@ -795,7 +795,7 @@ void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print,
/* Update the number of hits and the score of this question in tests database */ /* Update the number of hits and the score of this question in tests database */
if (UpdateQstScore) if (UpdateQstScore)
Tst_UpdateQstScoreInDB (&Print->PrintedQuestions[QstInd]); Qst_UpdateQstScoreInDB (&Print->PrintedQuestions[QstInd]);
} }
} }

View File

@ -27,8 +27,8 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include "swad_question_type.h"
#include "swad_test_config.h" #include "swad_test_config.h"
#include "swad_test_type.h"
#include "swad_test_visibility.h" #include "swad_test_visibility.h"
#include "swad_user.h" #include "swad_user.h"

View File

@ -53951,9 +53951,9 @@ const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES] =
#endif #endif
}; };
const char *Txt_TST_STR_ORDER_FULL[Tst_NUM_TYPES_ORDER_QST] = const char *Txt_TST_STR_ORDER_FULL[Qst_NUM_TYPES_ORDER_QST] =
{ {
[Tst_ORDER_STEM] = [Qst_ORDER_STEM] =
#if L==1 // ca #if L==1 // ca
"Ordenar por enunciado de la pregunta" // Necessita traduccio "Ordenar por enunciado de la pregunta" // Necessita traduccio
#elif L==2 // de #elif L==2 // de
@ -53974,7 +53974,7 @@ const char *Txt_TST_STR_ORDER_FULL[Tst_NUM_TYPES_ORDER_QST] =
"Classificar por formula&ccedil;&atilde;o da pergunta" "Classificar por formula&ccedil;&atilde;o da pergunta"
#endif #endif
, ,
[Tst_ORDER_NUM_HITS] = [Qst_ORDER_NUM_HITS] =
#if L==1 // ca #if L==1 // ca
"Ordenar por n&ordm; de veces que se ha respondido la pregunta" // Necessita traduccio "Ordenar por n&ordm; de veces que se ha respondido la pregunta" // Necessita traduccio
#elif L==2 // de #elif L==2 // de
@ -53995,7 +53995,7 @@ const char *Txt_TST_STR_ORDER_FULL[Tst_NUM_TYPES_ORDER_QST] =
"Classificar por n&ordm; de vezes que a pergunta foi respondida" "Classificar por n&ordm; de vezes que a pergunta foi respondida"
#endif #endif
, ,
[Tst_ORDER_AVERAGE_SCORE] = [Qst_ORDER_AVERAGE_SCORE] =
#if L==1 // ca #if L==1 // ca
"Ordenar por puntuaci&oacute;n media" // Necessita traduccio "Ordenar por puntuaci&oacute;n media" // Necessita traduccio
#elif L==2 // de #elif L==2 // de
@ -54016,7 +54016,7 @@ const char *Txt_TST_STR_ORDER_FULL[Tst_NUM_TYPES_ORDER_QST] =
"Classificar por pontua&ccedil;&atilde;o m&eacute;dia" "Classificar por pontua&ccedil;&atilde;o m&eacute;dia"
#endif #endif
, ,
[Tst_ORDER_NUM_HITS_NOT_BLANK] = [Qst_ORDER_NUM_HITS_NOT_BLANK] =
#if L==1 // ca #if L==1 // ca
"Ordenar por n&ordm; de veces que se ha respondido" "Ordenar por n&ordm; de veces que se ha respondido"
" la pregunta (excluyendo respuestas en blanco)" // Necessita traduccio " la pregunta (excluyendo respuestas en blanco)" // Necessita traduccio
@ -54046,7 +54046,7 @@ const char *Txt_TST_STR_ORDER_FULL[Tst_NUM_TYPES_ORDER_QST] =
" que a pergunta foi respondida (n&atilde;o em branco)" " que a pergunta foi respondida (n&atilde;o em branco)"
#endif #endif
, ,
[Tst_ORDER_AVERAGE_SCORE_NOT_BLANK] = [Qst_ORDER_AVERAGE_SCORE_NOT_BLANK] =
#if L==1 // ca #if L==1 // ca
"Ordenar por puntuaci&oacute;n media (excluyendo respuestas en blanco)" // Necessita traduccio "Ordenar por puntuaci&oacute;n media (excluyendo respuestas en blanco)" // Necessita traduccio
#elif L==2 // de #elif L==2 // de
@ -54068,9 +54068,9 @@ const char *Txt_TST_STR_ORDER_FULL[Tst_NUM_TYPES_ORDER_QST] =
#endif #endif
}; };
const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST] = const char *Txt_TST_STR_ORDER_SHORT[Qst_NUM_TYPES_ORDER_QST] =
{ {
[Tst_ORDER_STEM] = [Qst_ORDER_STEM] =
#if L==1 // ca #if L==1 // ca
"Pregunta" "Pregunta"
#elif L==2 // de #elif L==2 // de
@ -54091,7 +54091,7 @@ const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST] =
"Pergunta" "Pergunta"
#endif #endif
, ,
[Tst_ORDER_NUM_HITS] = [Qst_ORDER_NUM_HITS] =
#if L==1 // ca #if L==1 // ca
"N.&ordm;<br />resp." // Necessita traduccio "N.&ordm;<br />resp." // Necessita traduccio
#elif L==2 // de #elif L==2 // de
@ -54112,7 +54112,7 @@ const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST] =
"N.&ordm;<br />resp." "N.&ordm;<br />resp."
#endif #endif
, ,
[Tst_ORDER_AVERAGE_SCORE] = [Qst_ORDER_AVERAGE_SCORE] =
#if L==1 // ca #if L==1 // ca
"Puntuaci&oacute;n<br />media" // Necessita traduccio "Puntuaci&oacute;n<br />media" // Necessita traduccio
#elif L==2 // de #elif L==2 // de
@ -54133,7 +54133,7 @@ const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST] =
"Pontua&ccedil;&atilde;o<br />m&eacute;dia" "Pontua&ccedil;&atilde;o<br />m&eacute;dia"
#endif #endif
, ,
[Tst_ORDER_NUM_HITS_NOT_BLANK] = [Qst_ORDER_NUM_HITS_NOT_BLANK] =
#if L==1 // ca #if L==1 // ca
"N.&ordm;<br />resp.<br />no en<br />blanco" // Necessita traduccio "N.&ordm;<br />resp.<br />no en<br />blanco" // Necessita traduccio
#elif L==2 // de #elif L==2 // de
@ -54154,7 +54154,7 @@ const char *Txt_TST_STR_ORDER_SHORT[Tst_NUM_TYPES_ORDER_QST] =
"N.&ordm;<br />resp.<br />n&atilde;o em<br />branco" "N.&ordm;<br />resp.<br />n&atilde;o em<br />branco"
#endif #endif
, ,
[Tst_ORDER_AVERAGE_SCORE_NOT_BLANK] = [Qst_ORDER_AVERAGE_SCORE_NOT_BLANK] =
#if L==1 // ca #if L==1 // ca
"Puntuaci&oacute;n<br />media<br />no en<br />blanco" // Necessita traduccio "Puntuaci&oacute;n<br />media<br />no en<br />blanco" // Necessita traduccio
#elif L==2 // de #elif L==2 // de