diff --git a/Makefile b/Makefile
index 27920dec..75e83c45 100644
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \
swad_place.o swad_place_database.o swad_plugin.o swad_plugin_database.o \
swad_privacy.o swad_profile.o swad_profile_database.o swad_program.o \
swad_program_database.o swad_project.o swad_project_database.o \
- swad_QR.o \
+ swad_question_import.o swad_QR.o \
swad_record.o swad_record_database.o swad_report.o \
swad_report_database.o swad_role.o swad_role_database.o swad_room.o \
swad_room_database.o swad_RSS.o \
@@ -83,14 +83,12 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \
swad_statistic_database.o swad_string.o swad_survey.o \
swad_survey_database.o swad_syllabus.o swad_system_config.o \
swad_tab.o swad_tag.o swad_tag_database.o swad_test.o \
- swad_test_config.o swad_test_import.o swad_test_print.o \
- swad_test_visibility.o swad_theme.o swad_timeline.o \
- swad_timeline_comment.o swad_timeline_database.o \
- swad_timeline_favourite.o swad_timeline_form.o swad_timeline_note.o \
- swad_timeline_notification.o swad_timeline_post.o \
- swad_timeline_publication.o swad_timeline_share.o \
- swad_timeline_user.o swad_timeline_who.o \
- swad_timetable.o \
+ swad_test_config.o swad_test_print.o swad_test_visibility.o \
+ swad_theme.o swad_timeline.o swad_timeline_comment.o \
+ swad_timeline_database.o swad_timeline_favourite.o swad_timeline_form.o \
+ swad_timeline_note.o swad_timeline_notification.o swad_timeline_post.o \
+ swad_timeline_publication.o swad_timeline_share.o swad_timeline_user.o \
+ swad_timeline_who.o swad_timetable.o \
swad_user.o \
swad_xml.o \
swad_zip.o
diff --git a/swad_action.c b/swad_action.c
index 3723b28c..dbfefa2d 100644
--- a/swad_action.c
+++ b/swad_action.c
@@ -87,6 +87,7 @@
#include "swad_profile.h"
#include "swad_program.h"
#include "swad_project.h"
+#include "swad_question_import.h"
#include "swad_QR.h"
#include "swad_report.h"
#include "swad_role.h"
@@ -96,7 +97,6 @@
#include "swad_system_config.h"
#include "swad_tab.h"
#include "swad_tag.h"
-#include "swad_test_import.h"
#include "swad_timeline.h"
#include "swad_timeline_comment.h"
#include "swad_timeline_favourite.h"
@@ -669,8 +669,8 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
[ActUnhCfe ] = {1621,-1,TabUnk,ActSeeAllExaAnn ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Cfe_UnhideCallForExam ,Cfe_ListCallsForExamsEdit ,NULL},
[ActEdiOneTstQst ] = { 105,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_ShowFormEditOneQst ,NULL},
- [ActReqImpTstQst ] = {1007,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TsI_ShowFormImportQstsFromXML ,NULL},
- [ActImpTstQst ] = {1008,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,TsI_ImportQstsFromXML ,NULL},
+ [ActReqImpTstQst ] = {1007,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,QstImp_ShowFormImportQstsFromXML ,NULL},
+ [ActImpTstQst ] = {1008,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,QstImp_ImportQstsFromXML ,NULL},
[ActLstTstQst ] = { 132,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_ListQuestionsToEdit ,NULL},
[ActRcvTstQst ] = { 126,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,Qst_ReceiveQst ,NULL},
[ActReqRemSevTstQst ] = {1835,-1,TabUnk,ActEdiTstQst ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Qst_RequestRemoveSelectedQsts ,NULL},
diff --git a/swad_changelog.h b/swad_changelog.h
index 8ea86bbf..719e7cdd 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -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.
*/
-#define Log_PLATFORM_VERSION "SWAD 21.42 (2021-10-24)"
+#define Log_PLATFORM_VERSION "SWAD 21.42.1 (2021-10-25)"
#define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
+ 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.41.2: Oct 24, 2021 Query moved to module swad_setting_database. (320777 lines)
Version 21.41.1: Oct 24, 2021 Queries moved to module swad_tag_database. (320767 lines)
diff --git a/swad_exam_set.c b/swad_exam_set.c
index 7f03930f..9e344586 100644
--- a/swad_exam_set.c
+++ b/swad_exam_set.c
@@ -607,7 +607,7 @@ void ExaSet_ListQstsToAddToSet (void)
Exams.SetCod = Set.SetCod;
/***** List several test questions for selection *****/
- Tst_ListQuestionsToSelectForSet (&Exams);
+ Qst_ListQuestionsToSelectForExamSet (&Exams);
/***** Show current exam and its sets *****/
Exa_PutFormsOneExam (&Exams,&Exam,&Set,
diff --git a/swad_game.c b/swad_game.c
index 19872d9f..0b4bbf9e 100644
--- a/swad_game.c
+++ b/swad_game.c
@@ -1616,7 +1616,7 @@ void Gam_ListQstsToAddToGame (void)
/***** List several test questions for selection *****/
Games.GamCod = Game.GamCod;
- Tst_ListQuestionsToSelectForGame (&Games);
+ Qst_ListQuestionsToSelectForGame (&Games);
}
/*****************************************************************************/
diff --git a/swad_test_import.c b/swad_question_import.c
similarity index 62%
rename from swad_test_import.c
rename to swad_question_import.c
index 80df89cb..154a32ee 100644
--- a/swad_test_import.c
+++ b/swad_question_import.c
@@ -67,36 +67,36 @@ extern struct Globals Gbl;
/***************************** Private prototypes ****************************/
/*****************************************************************************/
-static void TsI_PutParamsExportQsts (void *Test);
-static void TsI_PutCreateXMLParam (void);
+static void QstImp_PutParamsExportQsts (void *Test);
+static void QstImp_PutCreateXMLParam (void);
-static void TsI_ExportQuestion (struct Qst_Question *Question,FILE *FileXML);
+static void QstImp_ExportQuestion (struct Qst_Question *Question,FILE *FileXML);
-static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML);
-static void TsI_WriteAnswersOfAQstXML (const struct Qst_Question *Question,
- FILE *FileXML);
-static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML);
-static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer);
-static Qst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML);
-static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem,
- struct Qst_Question *Question);
-static void TsI_WriteHeadingListImportedQst (void);
-static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
- struct XMLElement *FeedbackElem,
- const struct Qst_Question *Question,
- bool QuestionExists);
+static void QstImp_GetAndWriteTagsXML (long QstCod,FILE *FileXML);
+static void QstImp_WriteAnswersOfAQstXML (const struct Qst_Question *Question,
+ FILE *FileXML);
+static void QstImp_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML);
+static void QstImp_ImportQuestionsFromXMLBuffer (const char *XMLBuffer);
+static Qst_AnswerType_t QstImp_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML);
+static void QstImp_GetAnswerFromXML (struct XMLElement *AnswerElem,
+ struct Qst_Question *Question);
+static void QstImp_WriteHeadingListImportedQst (void);
+static void QstImp_WriteRowImportedQst (struct XMLElement *StemElem,
+ struct XMLElement *FeedbackElem,
+ const struct Qst_Question *Question,
+ bool QuestionExists);
/*****************************************************************************/
/**************** Put a link (form) to export test questions *****************/
/*****************************************************************************/
-void TsI_PutIconToExportQuestions (struct Tst_Test *Test)
+void QstImp_PutIconToExportQuestions (struct Tst_Test *Test)
{
extern const char *Txt_Export_questions;
/***** Put a link to create a file with questions *****/
Lay_PutContextualLinkOnlyIcon (ActLstTstQst,NULL,
- TsI_PutParamsExportQsts,Test,
+ QstImp_PutParamsExportQsts,Test,
"file-import.svg",
Txt_Export_questions);
}
@@ -105,14 +105,14 @@ void TsI_PutIconToExportQuestions (struct Tst_Test *Test)
/****************** Put params to export test questions **********************/
/*****************************************************************************/
-static void TsI_PutParamsExportQsts (void *Test)
+static void QstImp_PutParamsExportQsts (void *Test)
{
if (Test)
{
Qst_PutParamsEditQst (Test);
Par_PutHiddenParamChar ("OnlyThisQst",'N');
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) (((struct Tst_Test *) Test)->SelectedOrder));
- TsI_PutCreateXMLParam ();
+ QstImp_PutCreateXMLParam ();
}
}
@@ -120,12 +120,12 @@ static void TsI_PutParamsExportQsts (void *Test)
/************************ Parameter to create XML file ***********************/
/*****************************************************************************/
-static void TsI_PutCreateXMLParam (void)
+static void QstImp_PutCreateXMLParam (void)
{
Par_PutHiddenParamChar ("CreateXML",'Y');
}
-bool TsI_GetCreateXMLParamFromForm (void)
+bool QstImp_GetCreateXMLParamFromForm (void)
{
return Par_GetParToBool ("CreateXML");
}
@@ -134,7 +134,7 @@ bool TsI_GetCreateXMLParamFromForm (void)
/*************** Put a link (form) to import test questions ******************/
/*****************************************************************************/
-void TsI_PutIconToImportQuestions (void)
+void QstImp_PutIconToImportQuestions (void)
{
extern const char *Txt_Import_questions;
@@ -149,7 +149,7 @@ void TsI_PutIconToImportQuestions (void)
/*********** Show form to import test questions from an XML file *************/
/*****************************************************************************/
-void TsI_ShowFormImportQstsFromXML (void)
+void QstImp_ShowFormImportQstsFromXML (void)
{
extern const char *Hlp_ASSESSMENT_Tests;
extern const char *The_ClassFormInBox[The_NUM_THEMES];
@@ -162,18 +162,18 @@ void TsI_ShowFormImportQstsFromXML (void)
NULL,NULL,
Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE);
- /***** Write help message *****/
- Ale_ShowAlert (Ale_INFO,Txt_You_need_an_XML_file_containing_a_list_of_questions);
+ /***** Write help message *****/
+ Ale_ShowAlert (Ale_INFO,Txt_You_need_an_XML_file_containing_a_list_of_questions);
- /***** Write a form to import questions *****/
- Frm_BeginForm (ActImpTstQst);
- HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
- HTM_TxtColonNBSP (Txt_XML_file);
- HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,".xml",
- HTM_SUBMIT_ON_CHANGE,
- NULL);
- HTM_LABEL_End ();
- Frm_EndForm ();
+ /***** Write a form to import questions *****/
+ Frm_BeginForm (ActImpTstQst);
+ HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
+ HTM_TxtColonNBSP (Txt_XML_file);
+ HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,".xml",
+ HTM_SUBMIT_ON_CHANGE,
+ NULL);
+ HTM_LABEL_End ();
+ Frm_EndForm ();
/***** End box *****/
Box_BoxEnd ();
@@ -183,7 +183,7 @@ void TsI_ShowFormImportQstsFromXML (void)
/*** Create the XML file with test questions and put a link to download it ***/
/*****************************************************************************/
-void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
+void QstImp_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
{
extern const char *The_ClassFormOutBoxBold[The_NUM_THEMES];
extern const char *Txt_NEW_LINE;
@@ -223,7 +223,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongQuestionExit ();
- TsI_ExportQuestion (&Question,FileXML);
+ QstImp_ExportQuestion (&Question,FileXML);
/* Destroy test question */
Qst_QstDestructor (&Question);
@@ -244,8 +244,8 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
Gbl.FileBrowser.TmpPubDir.L,
Gbl.FileBrowser.TmpPubDir.R,
The_ClassFormOutBoxBold[Gbl.Prefs.Theme]);
- Ico_PutIconTextLink ("file.svg",
- Txt_XML_file);
+ Ico_PutIconTextLink ("file.svg",
+ Txt_XML_file);
HTM_A_End ();
}
@@ -253,7 +253,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
/****************** Write one question into the XML file *********************/
/*****************************************************************************/
-static void TsI_ExportQuestion (struct Qst_Question *Question,FILE *FileXML)
+static void QstImp_ExportQuestion (struct Qst_Question *Question,FILE *FileXML)
{
extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES];
extern const char *Txt_NEW_LINE;
@@ -266,7 +266,7 @@ static void TsI_ExportQuestion (struct Qst_Question *Question,FILE *FileXML)
/***** Write the question tags *****/
fprintf (FileXML,"%s",Txt_NEW_LINE);
- TsI_GetAndWriteTagsXML (Question->QstCod,FileXML);
+ QstImp_GetAndWriteTagsXML (Question->QstCod,FileXML);
fprintf (FileXML,"%s",Txt_NEW_LINE);
/***** Write the stem, that is in HTML format *****/
@@ -287,7 +287,7 @@ static void TsI_ExportQuestion (struct Qst_Question *Question,FILE *FileXML)
Question->Answer.Shuffle ? "yes" :
"no");
fprintf (FileXML,">");
- TsI_WriteAnswersOfAQstXML (Question,FileXML);
+ QstImp_WriteAnswersOfAQstXML (Question,FileXML);
fprintf (FileXML,"%s",Txt_NEW_LINE);
/***** End question *****/
@@ -300,7 +300,7 @@ static void TsI_ExportQuestion (struct Qst_Question *Question,FILE *FileXML)
/************* Get and write tags of a question into the XML file ************/
/*****************************************************************************/
-static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML)
+static void QstImp_GetAndWriteTagsXML (long QstCod,FILE *FileXML)
{
extern const char *Txt_NEW_LINE;
unsigned NumTags;
@@ -310,7 +310,7 @@ static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML)
if ((NumTags = Tag_DB_GetTagsQst (&mysql_res,QstCod))) // Result: TagTxt
/***** Write the tags *****/
- for (NumTag = 1;
+ for (NumTag = 1;
NumTag <= NumTags;
NumTag++)
{
@@ -327,8 +327,8 @@ static void TsI_GetAndWriteTagsXML (long QstCod,FILE *FileXML)
/**************** Get and write the answers of a test question ***************/
/*****************************************************************************/
-static void TsI_WriteAnswersOfAQstXML (const struct Qst_Question *Question,
- FILE *FileXML)
+static void QstImp_WriteAnswersOfAQstXML (const struct Qst_Question *Question,
+ FILE *FileXML)
{
extern const char *Txt_NEW_LINE;
unsigned NumOpt;
@@ -395,7 +395,7 @@ static void TsI_WriteAnswersOfAQstXML (const struct Qst_Question *Question,
/************ Get questions from XML and store them in database **************/
/*****************************************************************************/
-void TsI_ImportQstsFromXML (void)
+void QstImp_ImportQstsFromXML (void)
{
extern const char *Txt_The_file_is_not_X;
struct Param *Param;
@@ -429,7 +429,7 @@ void TsI_ImportQstsFromXML (void)
Cfg_PATH_TEST_PRIVATE,Gbl.UniqueNameEncrypted);
if (Fil_EndReceptionOfFile (FileNameXMLTmp,Param))
/***** Get questions from XML file and store them in database *****/
- TsI_ReadQuestionsFromXMLFileAndStoreInDB (FileNameXMLTmp);
+ QstImp_ReadQuestionsFromXMLFileAndStoreInDB (FileNameXMLTmp);
else
Ale_ShowAlert (Ale_WARNING,"Error copying file.");
}
@@ -439,7 +439,7 @@ void TsI_ImportQstsFromXML (void)
/********** Get questions from XML file and store them in database ***********/
/*****************************************************************************/
-static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
+static void QstImp_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
{
FILE *FileXML;
char *XMLBuffer;
@@ -466,7 +466,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
XMLBuffer[0] = '\0';
/***** Import questions from XML buffer *****/
- TsI_ImportQuestionsFromXMLBuffer (XMLBuffer);
+ QstImp_ImportQuestionsFromXMLBuffer (XMLBuffer);
free (XMLBuffer);
}
@@ -479,7 +479,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
/******************** Import questions from XML buffer ***********************/
/*****************************************************************************/
-static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
+static void QstImp_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
{
extern const char *Hlp_ASSESSMENT_Tests;
extern const char *Txt_XML_file_content;
@@ -505,165 +505,167 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
NULL,NULL,
Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE);
- /***** Print XML tree *****/
- HTM_DIV_Begin ("class=\"TEST_FILE_CONTENT\"");
- HTM_TEXTAREA_Begin ("title=\"%s\" cols=\"60\" rows=\"5\""
- " spellcheck=\"false\" readonly",
- Txt_XML_file_content);
- XML_PrintTree (RootElem);
- HTM_TEXTAREA_End ();
- HTM_DIV_End ();
+ /***** Print XML tree *****/
+ HTM_DIV_Begin ("class=\"TEST_FILE_CONTENT\"");
+ HTM_TEXTAREA_Begin ("title=\"%s\" cols=\"60\" rows=\"5\""
+ " spellcheck=\"false\" readonly",
+ Txt_XML_file_content);
+ XML_PrintTree (RootElem);
+ HTM_TEXTAREA_End ();
+ HTM_DIV_End ();
- /***** Get questions from XML tree and print them *****/
- /* Go to element */
- if (RootElem->FirstChild)
- {
- TestElem = RootElem->FirstChild;
- if (strcmp (TestElem->TagName,"test")) // must be at level 1
- TestElem = NULL;
- }
- if (TestElem)
- {
- /* Current element is */
-
- /***** Write heading of list of imported questions *****/
- HTM_TABLE_BeginWideMarginPadding (5);
- TsI_WriteHeadingListImportedQst ();
-
- /***** For each question... *****/
- for (QuestionElem = TestElem->FirstChild;
- QuestionElem != NULL;
- QuestionElem = QuestionElem->NextBrother)
+ /***** Get questions from XML tree and print them *****/
+ /* Go to element */
+ if (RootElem->FirstChild)
{
- if (!strcmp (QuestionElem->TagName,"question"))
- {
- /***** Create test question *****/
- Qst_QstConstructor (&Question);
+ TestElem = RootElem->FirstChild;
+ if (strcmp (TestElem->TagName,"test")) // must be at level 1
+ TestElem = NULL;
+ }
+ if (TestElem)
+ {
+ /* Current element is */
- /* Get answer type (in mandatory attribute "type") */
- AnswerTypeFound = false;
- for (Attribute = QuestionElem->FirstAttribute;
- Attribute != NULL;
- Attribute = Attribute->Next)
- if (!strcmp (Attribute->AttributeName,"type"))
- {
- Question.Answer.Type = TsI_ConvertFromStrAnsTypXMLToAnsTyp (Attribute->Content);
- AnswerTypeFound = true;
- break; // Only first attribute "type"
- }
+ /***** Begin table *****/
+ HTM_TABLE_BeginWideMarginPadding (5);
- if (AnswerTypeFound)
+ /***** Write heading of list of imported questions *****/
+ QstImp_WriteHeadingListImportedQst ();
+
+ /***** For each question... *****/
+ for (QuestionElem = TestElem->FirstChild;
+ QuestionElem != NULL;
+ QuestionElem = QuestionElem->NextBrother)
{
- /* Get tags */
- for (TagsElem = QuestionElem->FirstChild, Question.Tags.Num = 0;
- TagsElem != NULL;
- TagsElem = TagsElem->NextBrother)
- if (!strcmp (TagsElem->TagName,"tags"))
- {
- for (TagElem = TagsElem->FirstChild;
- TagElem != NULL && Question.Tags.Num < Tag_MAX_TAGS_PER_QUESTION;
- TagElem = TagElem->NextBrother)
- if (!strcmp (TagElem->TagName,"tag"))
- {
- if (TagElem->Content)
- {
- Str_Copy (Question.Tags.Txt[Question.Tags.Num],
- TagElem->Content,
- sizeof (Question.Tags.Txt[Question.Tags.Num]) - 1);
- Question.Tags.Num++;
- }
- }
- break; // Only first element "tags"
- }
-
- /* Get stem (mandatory) */
- for (StemElem = QuestionElem->FirstChild;
- StemElem != NULL;
- StemElem = StemElem->NextBrother)
- if (!strcmp (StemElem->TagName,"stem"))
- {
- if (StemElem->Content)
- {
- /* Convert stem from text to HTML (in database stem is stored in HTML) */
- Str_Copy (Question.Stem,StemElem->Content,Cns_MAX_BYTES_TEXT);
- Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
- Question.Stem,Cns_MAX_BYTES_TEXT,true);
- }
- break; // Only first element "stem"
- }
-
- /* Get feedback (optional) */
- for (FeedbackElem = QuestionElem->FirstChild;
- FeedbackElem != NULL;
- FeedbackElem = FeedbackElem->NextBrother)
- if (!strcmp (FeedbackElem->TagName,"feedback"))
- {
- if (FeedbackElem->Content)
- {
- /* Convert feedback from text to HTML (in database feedback is stored in HTML) */
- Str_Copy (Question.Feedback,FeedbackElem->Content,Cns_MAX_BYTES_TEXT);
- Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
- Question.Feedback,Cns_MAX_BYTES_TEXT,true);
- }
- break; // Only first element "feedback"
- }
-
- /* Get shuffle. By default, shuffle is false. */
- Question.Answer.Shuffle = false;
- for (AnswerElem = QuestionElem->FirstChild;
- AnswerElem != NULL;
- AnswerElem = AnswerElem->NextBrother)
- if (!strcmp (AnswerElem->TagName,"answer"))
- {
- if (Question.Answer.Type == Qst_ANS_UNIQUE_CHOICE ||
- Question.Answer.Type == Qst_ANS_MULTIPLE_CHOICE)
- /* Get whether shuffle answers (in attribute "shuffle") */
- for (Attribute = AnswerElem->FirstAttribute;
- Attribute != NULL;
- Attribute = Attribute->Next)
- if (!strcmp (Attribute->AttributeName,"shuffle"))
- {
- Question.Answer.Shuffle = XML_GetAttributteYesNoFromXMLTree (Attribute);
- break; // Only first attribute "shuffle"
- }
- break; // Only first element "answer"
- }
-
- /* Get answer (mandatory) */
- TsI_GetAnswerFromXML (AnswerElem,&Question);
-
- /* Make sure that tags, text and answer are not empty */
- if (Qst_CheckIfQstFormatIsCorrectAndCountNumOptions (&Question))
+ if (!strcmp (QuestionElem->TagName,"question"))
{
- /* Check if question already exists in database */
- QuestionExists = Qst_CheckIfQuestionExistsInDB (&Question);
+ /***** Create test question *****/
+ Qst_QstConstructor (&Question);
- /* Write row with this imported question */
- TsI_WriteRowImportedQst (StemElem,FeedbackElem,
- &Question,QuestionExists);
+ /* Get answer type (in mandatory attribute "type") */
+ AnswerTypeFound = false;
+ for (Attribute = QuestionElem->FirstAttribute;
+ Attribute != NULL;
+ Attribute = Attribute->Next)
+ if (!strcmp (Attribute->AttributeName,"type"))
+ {
+ Question.Answer.Type = QstImp_ConvertFromStrAnsTypXMLToAnsTyp (Attribute->Content);
+ AnswerTypeFound = true;
+ break; // Only first attribute "type"
+ }
- /***** If a new question ==> insert question, tags and answer in the database *****/
- if (!QuestionExists)
+ if (AnswerTypeFound)
{
- Question.QstCod = -1L;
- Qst_InsertOrUpdateQstTagsAnsIntoDB (&Question);
- if (Question.QstCod <= 0)
- Err_ShowErrorAndExit ("Can not create question.");
+ /* Get tags */
+ for (TagsElem = QuestionElem->FirstChild, Question.Tags.Num = 0;
+ TagsElem != NULL;
+ TagsElem = TagsElem->NextBrother)
+ if (!strcmp (TagsElem->TagName,"tags"))
+ {
+ for (TagElem = TagsElem->FirstChild;
+ TagElem != NULL && Question.Tags.Num < Tag_MAX_TAGS_PER_QUESTION;
+ TagElem = TagElem->NextBrother)
+ if (!strcmp (TagElem->TagName,"tag"))
+ {
+ if (TagElem->Content)
+ {
+ Str_Copy (Question.Tags.Txt[Question.Tags.Num],
+ TagElem->Content,
+ sizeof (Question.Tags.Txt[Question.Tags.Num]) - 1);
+ Question.Tags.Num++;
+ }
+ }
+ break; // Only first element "tags"
+ }
+
+ /* Get stem (mandatory) */
+ for (StemElem = QuestionElem->FirstChild;
+ StemElem != NULL;
+ StemElem = StemElem->NextBrother)
+ if (!strcmp (StemElem->TagName,"stem"))
+ {
+ if (StemElem->Content)
+ {
+ /* Convert stem from text to HTML (in database stem is stored in HTML) */
+ Str_Copy (Question.Stem,StemElem->Content,Cns_MAX_BYTES_TEXT);
+ Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
+ Question.Stem,Cns_MAX_BYTES_TEXT,true);
+ }
+ break; // Only first element "stem"
+ }
+
+ /* Get feedback (optional) */
+ for (FeedbackElem = QuestionElem->FirstChild;
+ FeedbackElem != NULL;
+ FeedbackElem = FeedbackElem->NextBrother)
+ if (!strcmp (FeedbackElem->TagName,"feedback"))
+ {
+ if (FeedbackElem->Content)
+ {
+ /* Convert feedback from text to HTML (in database feedback is stored in HTML) */
+ Str_Copy (Question.Feedback,FeedbackElem->Content,Cns_MAX_BYTES_TEXT);
+ Str_ChangeFormat (Str_FROM_TEXT,Str_TO_HTML,
+ Question.Feedback,Cns_MAX_BYTES_TEXT,true);
+ }
+ break; // Only first element "feedback"
+ }
+
+ /* Get shuffle. By default, shuffle is false. */
+ Question.Answer.Shuffle = false;
+ for (AnswerElem = QuestionElem->FirstChild;
+ AnswerElem != NULL;
+ AnswerElem = AnswerElem->NextBrother)
+ if (!strcmp (AnswerElem->TagName,"answer"))
+ {
+ if (Question.Answer.Type == Qst_ANS_UNIQUE_CHOICE ||
+ Question.Answer.Type == Qst_ANS_MULTIPLE_CHOICE)
+ /* Get whether shuffle answers (in attribute "shuffle") */
+ for (Attribute = AnswerElem->FirstAttribute;
+ Attribute != NULL;
+ Attribute = Attribute->Next)
+ if (!strcmp (Attribute->AttributeName,"shuffle"))
+ {
+ Question.Answer.Shuffle = XML_GetAttributteYesNoFromXMLTree (Attribute);
+ break; // Only first attribute "shuffle"
+ }
+ break; // Only first element "answer"
+ }
+
+ /* Get answer (mandatory) */
+ QstImp_GetAnswerFromXML (AnswerElem,&Question);
+
+ /* Make sure that tags, text and answer are not empty */
+ if (Qst_CheckIfQstFormatIsCorrectAndCountNumOptions (&Question))
+ {
+ /* Check if question already exists in database */
+ QuestionExists = Qst_CheckIfQuestionExistsInDB (&Question);
+
+ /* Write row with this imported question */
+ QstImp_WriteRowImportedQst (StemElem,FeedbackElem,
+ &Question,QuestionExists);
+
+ /***** If a new question ==> insert question, tags and answer in the database *****/
+ if (!QuestionExists)
+ {
+ Question.QstCod = -1L;
+ Qst_InsertOrUpdateQstTagsAnsIntoDB (&Question);
+ if (Question.QstCod <= 0)
+ Err_ShowErrorAndExit ("Can not create question.");
+ }
+ }
}
+ else // Answer type not found
+ Err_WrongAnswerExit ();
+
+ /***** Destroy test question *****/
+ Qst_QstDestructor (&Question);
}
}
- else // Answer type not found
- Err_WrongAnswerExit ();
- /***** Destroy test question *****/
- Qst_QstDestructor (&Question);
- }
+ HTM_TABLE_End ();
}
-
- HTM_TABLE_End ();
- }
- else // TestElem not found
- Ale_ShowAlert (Ale_ERROR,"Root element <test> not found.");
+ else // TestElem not found
+ Ale_ShowAlert (Ale_ERROR,"Root element <test> not found.");
/***** End table *****/
Box_BoxEnd ();
@@ -676,7 +678,7 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
/***** Convert a string with the type of answer in XML to type of answer *****/
/*****************************************************************************/
-static Qst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML)
+static Qst_AnswerType_t QstImp_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsTypeXML)
{
extern const char *Tst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES];
Qst_AnswerType_t AnsType;
@@ -698,8 +700,8 @@ static Qst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsT
/*****************************************************************************/
// Answer is mandatory
-static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem,
- struct Qst_Question *Question)
+static void QstImp_GetAnswerFromXML (struct XMLElement *AnswerElem,
+ struct Qst_Question *Question)
{
struct XMLElement *OptionElem;
struct XMLElement *TextElem;
@@ -822,9 +824,9 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem,
Question->Answer.Options[NumOpt].Correct = true;
else
/* Check if option is correct or wrong */
- for (Attribute = OptionElem->FirstAttribute;
+ for (Attribute = OptionElem->FirstAttribute;
Attribute != NULL;
- Attribute = Attribute->Next)
+ Attribute = Attribute->Next)
if (!strcmp (Attribute->AttributeName,"correct"))
{
Question->Answer.Options[NumOpt].Correct = XML_GetAttributteYesNoFromXMLTree (Attribute);
@@ -841,7 +843,7 @@ static void TsI_GetAnswerFromXML (struct XMLElement *AnswerElem,
/************* Write heading of list of imported test questions **************/
/*****************************************************************************/
-static void TsI_WriteHeadingListImportedQst (void)
+static void QstImp_WriteHeadingListImportedQst (void)
{
extern const char *Txt_No_INDEX;
extern const char *Txt_Tags;
@@ -852,13 +854,13 @@ static void TsI_WriteHeadingListImportedQst (void)
/***** Write the heading *****/
HTM_TR_Begin (NULL);
- HTM_TH_Empty (1);
+ HTM_TH_Empty (1);
- HTM_TH (1,1,"CT",Txt_No_INDEX);
- HTM_TH (1,1,"CT",Txt_Tags);
- HTM_TH (1,1,"CT",Txt_Type);
- HTM_TH (1,1,"CT",Txt_Shuffle);
- HTM_TH (1,1,"LT",Txt_Question);
+ HTM_TH (1,1,"CT",Txt_No_INDEX);
+ HTM_TH (1,1,"CT",Txt_Tags);
+ HTM_TH (1,1,"CT",Txt_Type);
+ HTM_TH (1,1,"CT",Txt_Shuffle);
+ HTM_TH (1,1,"LT",Txt_Question);
HTM_TR_End ();
}
@@ -867,10 +869,10 @@ static void TsI_WriteHeadingListImportedQst (void)
/**************** Write a row with one imported test question ****************/
/*****************************************************************************/
-static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
- struct XMLElement *FeedbackElem,
- const struct Qst_Question *Question,
- bool QuestionExists)
+static void QstImp_WriteRowImportedQst (struct XMLElement *StemElem,
+ struct XMLElement *FeedbackElem,
+ const struct Qst_Question *Question,
+ bool QuestionExists)
{
extern const char *Txt_Existing_question;
extern const char *Txt_New_question;
@@ -899,176 +901,178 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
HTM_TR_Begin (NULL);
- /***** Put icon to indicate that a question does not exist in database *****/
- HTM_TD_Begin ("class=\"BT%u CT\"",Gbl.RowEvenOdd);
- Ico_PutIcon (QuestionExists ? "tr16x16.gif" :
- "check-circle.svg",
- QuestionExists ? Txt_Existing_question :
- Txt_New_question,
- "CONTEXT_ICO_16x16");
- HTM_TD_End ();
+ /***** Put icon to indicate that a question does not exist in database *****/
+ HTM_TD_Begin ("class=\"BT%u CT\"",Gbl.RowEvenOdd);
+ Ico_PutIcon (QuestionExists ? "tr16x16.gif" :
+ "check-circle.svg",
+ QuestionExists ? Txt_Existing_question :
+ Txt_New_question,
+ "CONTEXT_ICO_16x16");
+ HTM_TD_End ();
- /***** Write number of question *****/
- HTM_TD_Begin ("class=\"%s CT COLOR%u\"",ClassData,Gbl.RowEvenOdd);
- if (!QuestionExists)
- HTM_TxtF ("%u ",++NumNonExistingQst);
- HTM_TD_End ();
+ /***** Write number of question *****/
+ HTM_TD_Begin ("class=\"%s CT COLOR%u\"",ClassData,Gbl.RowEvenOdd);
+ if (!QuestionExists)
+ HTM_TxtF ("%u ",++NumNonExistingQst);
+ HTM_TD_End ();
- /***** Write the question tags *****/
- HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
- if (Question->Tags.Num)
- {
- /***** Write the tags *****/
- HTM_TABLE_Begin (NULL);
- for (NumTag = 0;
- NumTag < Question->Tags.Num;
- NumTag++)
- {
- HTM_TR_Begin (NULL);
+ /***** Write the question tags *****/
+ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
- HTM_TD_Begin ("class=\"%s LT\"",ClassData);
- HTM_TxtF (" %s ","•");
- HTM_TD_End ();
-
- HTM_TD_Begin ("class=\"%s LT\"",ClassData);
- HTM_Txt (Question->Tags.Txt[NumTag]);
- HTM_TD_End ();
-
- HTM_TR_End ();
- }
- HTM_TABLE_End ();
- }
- else // no tags for this question
- {
- HTM_SPAN_Begin ("class=\"%s\"",ClassData);
- HTM_TxtF (" (%s) ",Txt_no_tags);
- HTM_SPAN_End ();
- }
-
- HTM_TD_End ();
-
- /***** Write the question type *****/
- HTM_TD_Begin ("class=\"%s CT COLOR%u\"",ClassData,Gbl.RowEvenOdd);
- HTM_TxtF ("%s ",Txt_TST_STR_ANSWER_TYPES[Question->Answer.Type]);
- HTM_TD_End ();
-
- /***** Write if shuffle is enabled *****/
- HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd);
- if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE ||
- Question->Answer.Type == Qst_ANS_MULTIPLE_CHOICE)
- /* Put an icon that indicates whether shuffle is enabled or not */
- if (Question->Answer.Shuffle)
- Ico_PutIcon ("check.svg",Txt_TST_Answer_given_by_the_teachers,
- QuestionExists ? "ICO_HIDDEN ICO16x16" :
- "ICO16x16");
- HTM_TD_End ();
-
- /***** Write the stem and the answers *****/
- HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
- Qst_WriteQstStem (Stem,ClassStem,
- true); // Visible
- Qst_WriteQstFeedback (Feedback,"TEST_TXT_LIGHT");
- switch (Question->Answer.Type)
- {
- case Qst_ANS_INT:
- HTM_SPAN_Begin ("class=\"%s\"",ClassStem);
- HTM_TxtF ("(%ld)",Question->Answer.Integer);
- HTM_SPAN_End ();
- break;
- case Qst_ANS_FLOAT:
- HTM_SPAN_Begin ("class=\"%s\"",ClassStem);
- HTM_Txt ("([");
- HTM_Double (Question->Answer.FloatingPoint[0]);
- HTM_Txt ("; ");
- HTM_Double (Question->Answer.FloatingPoint[1]);
- HTM_Txt ("])");
- HTM_SPAN_End ();
- break;
- case Qst_ANS_TRUE_FALSE:
- HTM_SPAN_Begin ("class=\"%s\"",ClassStem);
- HTM_Txt ("(");
- Qst_WriteAnsTF (Question->Answer.TF);
- HTM_Txt (")");
- HTM_SPAN_End ();
- break;
- case Qst_ANS_UNIQUE_CHOICE:
- case Qst_ANS_MULTIPLE_CHOICE:
- case Qst_ANS_TEXT:
- HTM_TABLE_Begin (NULL);
- for (NumOpt = 0;
- NumOpt < Question->Answer.NumOptions;
- NumOpt++)
- {
- /* Convert the answer, that is in HTML, to rigorous HTML */
- AnswerTextLength = strlen (Question->Answer.Options[NumOpt].Text) *
- Str_MAX_BYTES_PER_CHAR;
- if ((AnswerText = malloc (AnswerTextLength + 1)) == NULL)
- Err_NotEnoughMemoryExit ();
- Str_Copy (AnswerText,Question->Answer.Options[NumOpt].Text,
- AnswerTextLength);
- Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
- AnswerText,AnswerTextLength,false);
-
- /* Convert the feedback, that is in HTML, to rigorous HTML */
- AnswerFeedbackLength = 0;
- AnswerFeedback = NULL;
- if (Question->Answer.Options[NumOpt].Feedback)
- if (Question->Answer.Options[NumOpt].Feedback[0])
+ if (Question->Tags.Num)
+ {
+ /***** Write the tags *****/
+ HTM_TABLE_Begin (NULL);
+ for (NumTag = 0;
+ NumTag < Question->Tags.Num;
+ NumTag++)
{
- AnswerFeedbackLength = strlen (Question->Answer.Options[NumOpt].Feedback) *
- Str_MAX_BYTES_PER_CHAR;
- if ((AnswerFeedback = malloc (AnswerFeedbackLength + 1)) == NULL)
- Err_NotEnoughMemoryExit ();
- Str_Copy (AnswerFeedback,
- Question->Answer.Options[NumOpt].Feedback,
- AnswerFeedbackLength);
- Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
- AnswerFeedback,AnswerFeedbackLength,false);
+ HTM_TR_Begin (NULL);
+
+ HTM_TD_Begin ("class=\"%s LT\"",ClassData);
+ HTM_TxtF (" %s ","•");
+ HTM_TD_End ();
+
+ HTM_TD_Begin ("class=\"%s LT\"",ClassData);
+ HTM_Txt (Question->Tags.Txt[NumTag]);
+ HTM_TD_End ();
+
+ HTM_TR_End ();
}
+ HTM_TABLE_End ();
+ }
+ else // no tags for this question
+ {
+ HTM_SPAN_Begin ("class=\"%s\"",ClassData);
+ HTM_TxtF (" (%s) ",Txt_no_tags);
+ HTM_SPAN_End ();
+ }
- HTM_TR_Begin (NULL);
+ HTM_TD_End ();
- /* Put an icon that indicates whether the answer is correct or wrong */
- HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
- if (Question->Answer.Options[NumOpt].Correct)
- Ico_PutIcon ("check.svg",Txt_TST_Answer_given_by_the_teachers,
- QuestionExists ? "ICO_HIDDEN CONTEXT_ICO_16x16" :
- "CONTEXT_ICO_16x16");
- HTM_TD_End ();
+ /***** Write the question type *****/
+ HTM_TD_Begin ("class=\"%s CT COLOR%u\"",ClassData,Gbl.RowEvenOdd);
+ HTM_TxtF ("%s ",Txt_TST_STR_ANSWER_TYPES[Question->Answer.Type]);
+ HTM_TD_End ();
- /* Write the number of option */
- HTM_TD_Begin ("class=\"%s LT\"",ClassData);
- HTM_TxtF ("%c) ",'a' + (char) NumOpt);
- HTM_TD_End ();
+ /***** Write if shuffle is enabled *****/
+ HTM_TD_Begin ("class=\"CT COLOR%u\"",Gbl.RowEvenOdd);
+ if (Question->Answer.Type == Qst_ANS_UNIQUE_CHOICE ||
+ Question->Answer.Type == Qst_ANS_MULTIPLE_CHOICE)
+ /* Put an icon that indicates whether shuffle is enabled or not */
+ if (Question->Answer.Shuffle)
+ Ico_PutIcon ("check.svg",Txt_TST_Answer_given_by_the_teachers,
+ QuestionExists ? "ICO_HIDDEN ICO16x16" :
+ "ICO16x16");
+ HTM_TD_End ();
- /* Write the text and the feedback of the answer */
- HTM_TD_Begin ("class=\"LT\"");
+ /***** Write the stem and the answers *****/
+ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
+ Qst_WriteQstStem (Stem,ClassStem,
+ true); // Visible
+ Qst_WriteQstFeedback (Feedback,"TEST_TXT_LIGHT");
+ switch (Question->Answer.Type)
+ {
+ case Qst_ANS_INT:
+ HTM_SPAN_Begin ("class=\"%s\"",ClassStem);
+ HTM_TxtF ("(%ld)",Question->Answer.Integer);
+ HTM_SPAN_End ();
+ break;
+ case Qst_ANS_FLOAT:
+ HTM_SPAN_Begin ("class=\"%s\"",ClassStem);
+ HTM_Txt ("([");
+ HTM_Double (Question->Answer.FloatingPoint[0]);
+ HTM_Txt ("; ");
+ HTM_Double (Question->Answer.FloatingPoint[1]);
+ HTM_Txt ("])");
+ HTM_SPAN_End ();
+ break;
+ case Qst_ANS_TRUE_FALSE:
+ HTM_SPAN_Begin ("class=\"%s\"",ClassStem);
+ HTM_Txt ("(");
+ Qst_WriteAnsTF (Question->Answer.TF);
+ HTM_Txt (")");
+ HTM_SPAN_End ();
+ break;
+ case Qst_ANS_UNIQUE_CHOICE:
+ case Qst_ANS_MULTIPLE_CHOICE:
+ case Qst_ANS_TEXT:
+ HTM_TABLE_Begin (NULL);
+ for (NumOpt = 0;
+ NumOpt < Question->Answer.NumOptions;
+ NumOpt++)
+ {
+ /* Convert the answer, that is in HTML, to rigorous HTML */
+ AnswerTextLength = strlen (Question->Answer.Options[NumOpt].Text) *
+ Str_MAX_BYTES_PER_CHAR;
+ if ((AnswerText = malloc (AnswerTextLength + 1)) == NULL)
+ Err_NotEnoughMemoryExit ();
+ Str_Copy (AnswerText,Question->Answer.Options[NumOpt].Text,
+ AnswerTextLength);
+ Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
+ AnswerText,AnswerTextLength,false);
- HTM_DIV_Begin ("class=\"%s\"",ClassStem);
- HTM_Txt (AnswerText);
- HTM_DIV_End ();
+ /* Convert the feedback, that is in HTML, to rigorous HTML */
+ AnswerFeedbackLength = 0;
+ AnswerFeedback = NULL;
+ if (Question->Answer.Options[NumOpt].Feedback)
+ if (Question->Answer.Options[NumOpt].Feedback[0])
+ {
+ AnswerFeedbackLength = strlen (Question->Answer.Options[NumOpt].Feedback) *
+ Str_MAX_BYTES_PER_CHAR;
+ if ((AnswerFeedback = malloc (AnswerFeedbackLength + 1)) == NULL)
+ Err_NotEnoughMemoryExit ();
+ Str_Copy (AnswerFeedback,
+ Question->Answer.Options[NumOpt].Feedback,
+ AnswerFeedbackLength);
+ Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
+ AnswerFeedback,AnswerFeedbackLength,false);
+ }
- if (AnswerFeedbackLength)
- {
- HTM_DIV_Begin ("class=\"TEST_TXT_LIGHT\"");
- HTM_Txt (AnswerFeedback);
- HTM_DIV_End ();
- }
+ HTM_TR_Begin (NULL);
- HTM_TD_End ();
+ /* Put an icon that indicates whether the answer is correct or wrong */
+ HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
+ if (Question->Answer.Options[NumOpt].Correct)
+ Ico_PutIcon ("check.svg",Txt_TST_Answer_given_by_the_teachers,
+ QuestionExists ? "ICO_HIDDEN CONTEXT_ICO_16x16" :
+ "CONTEXT_ICO_16x16");
+ HTM_TD_End ();
- HTM_TR_End ();
+ /* Write the number of option */
+ HTM_TD_Begin ("class=\"%s LT\"",ClassData);
+ HTM_TxtF ("%c) ",'a' + (char) NumOpt);
+ HTM_TD_End ();
+
+ /* Write the text and the feedback of the answer */
+ HTM_TD_Begin ("class=\"LT\"");
+
+ HTM_DIV_Begin ("class=\"%s\"",ClassStem);
+ HTM_Txt (AnswerText);
+ HTM_DIV_End ();
+
+ if (AnswerFeedbackLength)
+ {
+ HTM_DIV_Begin ("class=\"TEST_TXT_LIGHT\"");
+ HTM_Txt (AnswerFeedback);
+ HTM_DIV_End ();
+ }
+
+ HTM_TD_End ();
+
+ HTM_TR_End ();
+
+ /* Free memory allocated for the answer and the feedback */
+ free (AnswerText);
+ if (AnswerFeedbackLength)
+ free (AnswerFeedback);
+ }
+ HTM_TABLE_End ();
+ break;
+ default:
+ break;
+ }
+ HTM_TD_End ();
- /* Free memory allocated for the answer and the feedback */
- free (AnswerText);
- if (AnswerFeedbackLength)
- free (AnswerFeedback);
- }
- HTM_TABLE_End ();
- break;
- default:
- break;
- }
- HTM_TD_End ();
HTM_TR_End ();
}
diff --git a/swad_test_import.h b/swad_question_import.h
similarity index 81%
rename from swad_test_import.h
rename to swad_question_import.h
index fc0e9530..ba37585a 100644
--- a/swad_test_import.h
+++ b/swad_question_import.h
@@ -1,7 +1,7 @@
-// swad_test_import.h: import and export self-assessment tests using XML files
+// swad_question_import.h: import and export questions using XML files
-#ifndef _SWAD_TSI
-#define _SWAD_TSI
+#ifndef _SWAD_QST_IMP
+#define _SWAD_QST_IMP
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
@@ -39,11 +39,11 @@
/***************************** Public prototypes *****************************/
/*****************************************************************************/
-void TsI_PutIconToExportQuestions (struct Tst_Test *Test);
-bool TsI_GetCreateXMLParamFromForm (void);
-void TsI_PutIconToImportQuestions (void);
-void TsI_CreateXML (unsigned long NumRows,MYSQL_RES *mysql_res);
-void TsI_ShowFormImportQstsFromXML (void);
-void TsI_ImportQstsFromXML (void);
+void QstImp_PutIconToExportQuestions (struct Tst_Test *Test);
+bool QstImp_GetCreateXMLParamFromForm (void);
+void QstImp_PutIconToImportQuestions (void);
+void QstImp_CreateXML (unsigned long NumRows,MYSQL_RES *mysql_res);
+void QstImp_ShowFormImportQstsFromXML (void);
+void QstImp_ImportQstsFromXML (void);
#endif
diff --git a/swad_test.c b/swad_test.c
index dc67d64a..9e19cdd3 100644
--- a/swad_test.c
+++ b/swad_test.c
@@ -52,10 +52,10 @@
#include "swad_match.h"
#include "swad_media.h"
#include "swad_parameter.h"
+#include "swad_question_import.h"
#include "swad_tag_database.h"
#include "swad_test.h"
#include "swad_test_config.h"
-#include "swad_test_import.h"
#include "swad_test_print.h"
#include "swad_test_visibility.h"
#include "swad_theme.h"
@@ -117,19 +117,19 @@ extern struct Globals Gbl;
/***************************** Private prototypes ****************************/
/*****************************************************************************/
-static void Tst_TstConstructor (struct Tst_Test *Test);
-static void Tst_TstDestructor (struct Tst_Test *Test);
+static void Tst_Constructor (struct Tst_Test *Test);
+static void Tst_Destructor (struct Tst_Test *Test);
static void Tst_ShowFormRequestTest (struct Tst_Test *Test);
static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print);
static bool Tst_CheckIfNextTstAllowed (void);
-static unsigned Tst_GetNumExamsGeneratedByMe (void);
+static unsigned Tst_GetNumTstExamsGeneratedByMe (void);
-static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
+static void Qst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
bool OptionsDisabled);
-static void Tst_IncreaseMyNumAccessTst (void);
+static void Tst_IncreaseMyNumTstExams (void);
static void Tst_UpdateLastAccTst (unsigned NumQsts);
static void Qst_ShowFormRequestEditQsts (struct Tst_Test *Test);
@@ -152,34 +152,36 @@ static void Tst_ShowFormAnswerTypes (const struct Tst_AnswerTypes *AnswerTypes);
static void Qst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res);
static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
struct TstPrn_Print *Print);
+static void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
+ bool Shuffle);
-static void Tst_ListOneQstToEdit (struct Tst_Test *Test);
-static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
+static void Qst_ListOneQstToEdit (struct Tst_Test *Test);
+static void Qst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
MYSQL_RES *mysql_res);
-static void Tst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test);
-static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd);
-static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exams,
- unsigned NumQsts,
- MYSQL_RES *mysql_res);
-static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Games,
+static void Qst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test);
+static void Qst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd);
+static void Qst_ListOneOrMoreQuestionsForSelectionForExamSet (struct Exa_Exams *Exams,
+ unsigned NumQsts,
+ MYSQL_RES *mysql_res);
+static void Qst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Games,
unsigned NumQsts,
MYSQL_RES *mysql_res);
-static void Tst_PutCheckboxToSelectAllQuestions (void);
-static void Tst_WriteQuestionRowForSelection (unsigned QstInd,
+static void Qst_PutCheckboxToSelectAllQuestions (void);
+static void Qst_WriteQuestionRowForSelection (unsigned QstInd,
struct Qst_Question *Question);
//-----------------------------------------------------------------------------
-static void Tst_WriteIntAnsBank (struct Qst_Question *Question,
+static void Qst_WriteIntAnsBank (struct Qst_Question *Question,
const char *ClassTxt,
__attribute__((unused)) const char *ClassFeedback);
-static void Tst_WriteFltAnsBank (struct Qst_Question *Question,
+static void Qst_WriteFltAnsBank (struct Qst_Question *Question,
const char *ClassTxt,
__attribute__((unused)) const char *ClassFeedback);
-static void Tst_WriteTF_AnsBank (struct Qst_Question *Question,
+static void Qst_WriteTF_AnsBank (struct Qst_Question *Question,
const char *ClassTxt,
__attribute__((unused)) const char *ClassFeedback);
-static void Tst_WriteChoAnsBank (struct Qst_Question *Question,
+static void Qst_WriteChoAnsBank (struct Qst_Question *Question,
const char *ClassTxt,
const char *ClassFeedback);
@@ -206,7 +208,7 @@ static void Qst_ResetMediaOfQuestion (struct Qst_Question *Question);
static void Qst_FreeMediaOfQuestion (struct Qst_Question *Question);
static long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt);
-static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
+static void Qst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
struct Med_Media *Media);
static Qst_AnswerType_t Qst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr);
@@ -241,20 +243,20 @@ void Tst_RequestTest (void)
struct Tst_Test Test;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Show form to generate a self-assessment test *****/
Tst_ShowFormRequestTest (&Test);
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
/***************************** Test constructor ******************************/
/*****************************************************************************/
-static void Tst_TstConstructor (struct Tst_Test *Test)
+static void Tst_Constructor (struct Tst_Test *Test)
{
/***** Reset tags *****/
Tag_ResetTags (&Test->Tags);
@@ -274,7 +276,7 @@ static void Tst_TstConstructor (struct Tst_Test *Test)
/****************************** Test destructor ******************************/
/*****************************************************************************/
-static void Tst_TstDestructor (struct Tst_Test *Test)
+static void Tst_Destructor (struct Tst_Test *Test)
{
/***** Question destructor *****/
Qst_QstDestructor (&Test->Question);
@@ -372,10 +374,10 @@ void Tst_ShowNewTest (void)
extern const char *Txt_No_questions_found_matching_your_search_criteria;
struct Tst_Test Test;
struct TstPrn_Print Print;
- unsigned NumExamsGeneratedByMe;
+ unsigned NumTstExamsGeneratedByMe;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Read test configuration from database *****/
TstCfg_GetConfigFromDB ();
@@ -391,8 +393,8 @@ void Tst_ShowNewTest (void)
if (Print.NumQsts.All)
{
/***** Increase number of exams generated (answered or not) by me *****/
- Tst_IncreaseMyNumAccessTst ();
- NumExamsGeneratedByMe = Tst_GetNumExamsGeneratedByMe ();
+ Tst_IncreaseMyNumTstExams ();
+ NumTstExamsGeneratedByMe = Tst_GetNumTstExamsGeneratedByMe ();
/***** Create new test exam in database *****/
TstPrn_CreatePrintInDB (&Print);
@@ -400,7 +402,7 @@ void Tst_ShowNewTest (void)
false); // Don't update question score
/***** Show test exam to be answered *****/
- TstPrn_ShowTestPrintToFillIt (&Print,NumExamsGeneratedByMe,TstPrn_REQUEST);
+ TstPrn_ShowTestPrintToFillIt (&Print,NumTstExamsGeneratedByMe,TstPrn_REQUEST);
/***** Update date-time of my next allowed access to test *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_STD)
@@ -417,7 +419,7 @@ void Tst_ShowNewTest (void)
}
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -650,12 +652,12 @@ static bool Tst_CheckIfNextTstAllowed (void)
/***************** Get number of test exams generated by me ******************/
/*****************************************************************************/
-static unsigned Tst_GetNumExamsGeneratedByMe (void)
+static unsigned Tst_GetNumTstExamsGeneratedByMe (void)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
- unsigned NumExamsGeneratedByMe = 0;
+ unsigned NumTstExamsGeneratedByMe = 0;
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
{
@@ -669,15 +671,15 @@ static unsigned Tst_GetNumExamsGeneratedByMe (void)
Gbl.Hierarchy.Crs.CrsCod);
if (NumRows == 0)
- NumExamsGeneratedByMe = 0;
+ NumTstExamsGeneratedByMe = 0;
else if (NumRows == 1)
{
/* Get number of hits */
row = mysql_fetch_row (mysql_res);
if (row[0] == NULL)
- NumExamsGeneratedByMe = 0;
- else if (sscanf (row[0],"%u",&NumExamsGeneratedByMe) != 1)
- NumExamsGeneratedByMe = 0;
+ NumTstExamsGeneratedByMe = 0;
+ else if (sscanf (row[0],"%u",&NumTstExamsGeneratedByMe) != 1)
+ NumTstExamsGeneratedByMe = 0;
}
else
Err_ShowErrorAndExit ("Error when getting number of hits to test.");
@@ -686,7 +688,7 @@ static unsigned Tst_GetNumExamsGeneratedByMe (void)
DB_FreeMySQLResult (&mysql_res);
}
- return NumExamsGeneratedByMe;
+ return NumTstExamsGeneratedByMe;
}
/*****************************************************************************/
@@ -816,7 +818,7 @@ void Qst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible)
/************* Put form to upload a new image for a test question ************/
/*****************************************************************************/
-static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
+static void Qst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMedia,
bool OptionsDisabled)
{
extern const char *The_ClassFormInBox[The_NUM_THEMES];
@@ -910,7 +912,7 @@ void Qst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback)
/*********** Update my number of accesses to test in this course *************/
/*****************************************************************************/
-static void Tst_IncreaseMyNumAccessTst (void)
+static void Tst_IncreaseMyNumTstExams (void)
{
/***** Trivial check *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs)
@@ -953,13 +955,13 @@ void Qst_RequestEditQsts (void)
struct Tst_Test Test;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Show form to generate a self-assessment test *****/
Qst_ShowFormRequestEditQsts (&Test);
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -1033,13 +1035,13 @@ void Qst_RequestSelectQstsForExamSet (struct Exa_Exams *Exams)
struct Tst_Test Test;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Show form to select test for exam *****/
Tst_ShowFormRequestSelectTestsForSet (Exams,&Test); // No tags selected
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -1051,13 +1053,13 @@ void Qst_RequestSelectQstsForGame (struct Gam_Games *Games)
struct Tst_Test Test;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Show form to select test for game *****/
Tst_ShowFormRequestSelectTestsForGame (Games,&Test); // No tags selected
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -1210,7 +1212,7 @@ static void Qst_PutIconsRequestBankQsts (__attribute__((unused)) void *Args)
Tag_PutIconToEditTags ();
/***** Put icon to import questions *****/
- TsI_PutIconToImportQuestions ();
+ QstImp_PutIconToImportQuestions ();
/***** Put icon to show a figure *****/
Fig_PutIconToShowFigure (Fig_TESTS);
@@ -1249,7 +1251,7 @@ static void Qst_PutIconsEditBankQsts (void *Test)
Tag_PutIconToEditTags ();
/***** Put icon to export questions *****/
- TsI_PutIconToExportQuestions (Test);
+ QstImp_PutIconToExportQuestions (Test);
/***** Put icon to show a figure *****/
Fig_PutIconToShowFigure (Fig_TESTS);
@@ -1394,7 +1396,7 @@ static void Tst_ShowFormConfigTst (void)
char StrMinTimeNxtTstPerQst[Cns_MAX_DECIMAL_DIGITS_ULONG + 1];
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Read test configuration from database *****/
TstCfg_GetConfigFromDB ();
@@ -1497,7 +1499,7 @@ static void Tst_ShowFormConfigTst (void)
Box_BoxEnd ();
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -1614,7 +1616,7 @@ void Qst_ListQuestionsToEdit (void)
MYSQL_RES *mysql_res;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get parameters, query the database and list the questions *****/
if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters from the form
@@ -1624,16 +1626,16 @@ void Qst_ListQuestionsToEdit (void)
if (Test.NumQsts)
{
/* Contextual menu */
- if (TsI_GetCreateXMLParamFromForm ())
+ if (QstImp_GetCreateXMLParamFromForm ())
{
Mnu_ContextMenuBegin ();
- TsI_CreateXML (Test.NumQsts,mysql_res); // Create XML file with exported questions...
+ QstImp_CreateXML (Test.NumQsts,mysql_res); // Create XML file with exported questions...
// ...and put a link to download it
Mnu_ContextMenuEnd ();
}
/* Show the table with the questions */
- Tst_ListOneOrMoreQuestionsForEdition (&Test,mysql_res);
+ Qst_ListOneOrMoreQuestionsForEdition (&Test,mysql_res);
}
/***** Free structure that stores the query result *****/
@@ -1644,20 +1646,20 @@ void Qst_ListQuestionsToEdit (void)
Qst_ShowFormRequestEditQsts (&Test);
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
/************ List several test questions for selection for exam *************/
/*****************************************************************************/
-void Tst_ListQuestionsToSelectForSet (struct Exa_Exams *Exams)
+void Qst_ListQuestionsToSelectForExamSet (struct Exa_Exams *Exams)
{
struct Tst_Test Test;
MYSQL_RES *mysql_res;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get parameters, query the database and list the questions *****/
if (Tst_GetParamsTst (&Test,Tst_SELECT_QUESTIONS_FOR_EXAM)) // Get parameters from the form
@@ -1665,7 +1667,7 @@ void Tst_ListQuestionsToSelectForSet (struct Exa_Exams *Exams)
Qst_GetQuestions (&Test,&mysql_res); // Query database
if (Test.NumQsts)
/* Show the table with the questions */
- Tst_ListOneOrMoreQuestionsForSelectionForSet (Exams,Test.NumQsts,mysql_res);
+ Qst_ListOneOrMoreQuestionsForSelectionForExamSet (Exams,Test.NumQsts,mysql_res);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
@@ -1675,20 +1677,20 @@ void Tst_ListQuestionsToSelectForSet (struct Exa_Exams *Exams)
Tst_ShowFormRequestSelectTestsForSet (Exams,&Test);
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
/************ List several test questions for selection for game *************/
/*****************************************************************************/
-void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games)
+void Qst_ListQuestionsToSelectForGame (struct Gam_Games *Games)
{
struct Tst_Test Test;
MYSQL_RES *mysql_res;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get parameters, query the database and list the questions *****/
if (Tst_GetParamsTst (&Test,Tst_SELECT_QUESTIONS_FOR_GAME)) // Get parameters from the form
@@ -1696,7 +1698,7 @@ void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games)
Qst_GetQuestions (&Test,&mysql_res); // Query database
if (Test.NumQsts)
/* Show the table with the questions */
- Tst_ListOneOrMoreQuestionsForSelectionForGame (Games,Test.NumQsts,mysql_res);
+ Qst_ListOneOrMoreQuestionsForSelectionForGame (Games,Test.NumQsts,mysql_res);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
@@ -1706,7 +1708,7 @@ void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games)
Tst_ShowFormRequestSelectTestsForGame (Games,&Test);
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -2019,8 +2021,8 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
/*************** Generate choice indexes depending on shuffle ****************/
/*****************************************************************************/
-void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
- bool Shuffle)
+static void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
+ bool Shuffle)
{
struct Qst_Question Question;
unsigned NumOpt;
@@ -2082,7 +2084,7 @@ void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
/*********************** List a test question for edition ********************/
/*****************************************************************************/
-static void Tst_ListOneQstToEdit (struct Tst_Test *Test)
+static void Qst_ListOneQstToEdit (struct Tst_Test *Test)
{
extern const char *Hlp_ASSESSMENT_Tests;
extern const char *Txt_Questions;
@@ -2099,10 +2101,10 @@ static void Tst_ListOneQstToEdit (struct Tst_Test *Test)
HTM_TABLE_BeginWideMarginPadding (5);
/***** Write the heading *****/
- Tst_WriteHeadingRowQuestionsForEdition (Test);
+ Qst_WriteHeadingRowQuestionsForEdition (Test);
/***** Write question row *****/
- Tst_WriteQuestionListing (Test,0);
+ Qst_WriteQuestionListing (Test,0);
/***** End table *****/
HTM_TABLE_End ();
@@ -2118,7 +2120,7 @@ static void Tst_ListOneQstToEdit (struct Tst_Test *Test)
/****************** List for edition one or more test questions **************/
/*****************************************************************************/
-static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
+static void Qst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
MYSQL_RES *mysql_res)
{
extern const char *Hlp_ASSESSMENT_Tests;
@@ -2135,7 +2137,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
HTM_TABLE_BeginWideMarginPadding (5);
/***** Write the heading *****/
- Tst_WriteHeadingRowQuestionsForEdition (Test);
+ Qst_WriteHeadingRowQuestionsForEdition (Test);
/***** Write rows *****/
for (QstInd = 0;
@@ -2153,7 +2155,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
Err_WrongQuestionExit ();
/***** Write question row *****/
- Tst_WriteQuestionListing (Test,QstInd);
+ Qst_WriteQuestionListing (Test,QstInd);
/***** Destroy test question *****/
Qst_QstDestructor (&Test->Question);
@@ -2173,7 +2175,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
/*********** Write heading row in listing of questions for edition ***********/
/*****************************************************************************/
-static void Tst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test)
+static void Qst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test)
{
extern const char *Txt_No_INDEX;
extern const char *Txt_Code;
@@ -2234,7 +2236,7 @@ static void Tst_WriteHeadingRowQuestionsForEdition (struct Tst_Test *Test)
/********** Write question row in listing of questions for edition ***********/
/*****************************************************************************/
-static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd)
+static void Qst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd)
{
static unsigned UniqueId = 0;
char *Id;
@@ -2354,9 +2356,9 @@ static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned QstInd)
/*************** List for selection one or more test questions ***************/
/*****************************************************************************/
-static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exams,
- unsigned NumQsts,
- MYSQL_RES *mysql_res)
+static void Qst_ListOneOrMoreQuestionsForSelectionForExamSet (struct Exa_Exams *Exams,
+ unsigned NumQsts,
+ MYSQL_RES *mysql_res)
{
extern const char *Hlp_ASSESSMENT_Exams_questions;
extern const char *Txt_Questions;
@@ -2382,7 +2384,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam
ExaSet_PutParamsOneSet (Exams);
/***** Select all questions *****/
- Tst_PutCheckboxToSelectAllQuestions ();
+ Qst_PutCheckboxToSelectAllQuestions ();
/***** Begin table *****/
HTM_TABLE_BeginWideMarginPadding (5);
@@ -2418,7 +2420,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam
Err_WrongQuestionExit ();
/* Write question row */
- Tst_WriteQuestionRowForSelection (QstInd,&Question);
+ Qst_WriteQuestionRowForSelection (QstInd,&Question);
/* Destroy test question */
Qst_QstDestructor (&Question);
@@ -2441,7 +2443,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam
/*************** List for selection one or more test questions ***************/
/*****************************************************************************/
-static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Games,
+static void Qst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Games,
unsigned NumQsts,
MYSQL_RES *mysql_res)
{
@@ -2469,7 +2471,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
Gam_PutParams (Games);
/***** Select all questions *****/
- Tst_PutCheckboxToSelectAllQuestions ();
+ Qst_PutCheckboxToSelectAllQuestions ();
/***** Begin table *****/
HTM_TABLE_BeginWideMarginPadding (5);
@@ -2504,7 +2506,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
Err_WrongQuestionExit ();
/* Write question row */
- Tst_WriteQuestionRowForSelection (QstInd,&Question);
+ Qst_WriteQuestionRowForSelection (QstInd,&Question);
/* Destroy test question */
Qst_QstDestructor (&Question);
@@ -2527,7 +2529,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
/************** Select all questions to add them to set/game *****************/
/*****************************************************************************/
-static void Tst_PutCheckboxToSelectAllQuestions (void)
+static void Qst_PutCheckboxToSelectAllQuestions (void)
{
extern const char *The_ClassFormInBox[The_NUM_THEMES];
extern const char *Txt_All_questions;
@@ -2544,7 +2546,7 @@ static void Tst_PutCheckboxToSelectAllQuestions (void)
/********************** Write question row for selection *********************/
/*****************************************************************************/
-static void Tst_WriteQuestionRowForSelection (unsigned QstInd,
+static void Qst_WriteQuestionRowForSelection (unsigned QstInd,
struct Qst_Question *Question)
{
extern const char *Txt_TST_STR_ANSWER_TYPES[Qst_NUM_ANS_TYPES];
@@ -2730,12 +2732,12 @@ void Qst_WriteAnswersBank (struct Qst_Question *Question,
const char *ClassTxt,
const char *ClassFeedback) =
{
- [Qst_ANS_INT ] = Tst_WriteIntAnsBank,
- [Qst_ANS_FLOAT ] = Tst_WriteFltAnsBank,
- [Qst_ANS_TRUE_FALSE ] = Tst_WriteTF_AnsBank,
- [Qst_ANS_UNIQUE_CHOICE ] = Tst_WriteChoAnsBank,
- [Qst_ANS_MULTIPLE_CHOICE] = Tst_WriteChoAnsBank,
- [Qst_ANS_TEXT ] = Tst_WriteChoAnsBank,
+ [Qst_ANS_INT ] = Qst_WriteIntAnsBank,
+ [Qst_ANS_FLOAT ] = Qst_WriteFltAnsBank,
+ [Qst_ANS_TRUE_FALSE ] = Qst_WriteTF_AnsBank,
+ [Qst_ANS_UNIQUE_CHOICE ] = Qst_WriteChoAnsBank,
+ [Qst_ANS_MULTIPLE_CHOICE] = Qst_WriteChoAnsBank,
+ [Qst_ANS_TEXT ] = Qst_WriteChoAnsBank,
};
/***** Write answers *****/
@@ -2746,7 +2748,7 @@ void Qst_WriteAnswersBank (struct Qst_Question *Question,
/****************** Write integer answer when editing a test *****************/
/*****************************************************************************/
-static void Tst_WriteIntAnsBank (struct Qst_Question *Question,
+static void Qst_WriteIntAnsBank (struct Qst_Question *Question,
const char *ClassTxt,
__attribute__((unused)) const char *ClassFeedback)
{
@@ -2759,7 +2761,7 @@ static void Tst_WriteIntAnsBank (struct Qst_Question *Question,
/****************** Write float answer when editing a test *******************/
/*****************************************************************************/
-static void Tst_WriteFltAnsBank (struct Qst_Question *Question,
+static void Qst_WriteFltAnsBank (struct Qst_Question *Question,
const char *ClassTxt,
__attribute__((unused)) const char *ClassFeedback)
{
@@ -2776,7 +2778,7 @@ static void Tst_WriteFltAnsBank (struct Qst_Question *Question,
/*********** Write false / true answer when listing test questions ***********/
/*****************************************************************************/
-static void Tst_WriteTF_AnsBank (struct Qst_Question *Question,
+static void Qst_WriteTF_AnsBank (struct Qst_Question *Question,
const char *ClassTxt,
__attribute__((unused)) const char *ClassFeedback)
{
@@ -2792,7 +2794,7 @@ static void Tst_WriteTF_AnsBank (struct Qst_Question *Question,
/**** Write single or multiple choice answer when listing test questions *****/
/*****************************************************************************/
-static void Tst_WriteChoAnsBank (struct Qst_Question *Question,
+static void Qst_WriteChoAnsBank (struct Qst_Question *Question,
const char *ClassTxt,
const char *ClassFeedback)
{
@@ -3277,7 +3279,7 @@ static void Qst_PutFormEditOneQst (struct Qst_Question *Question)
HTM_Txt (Question->Stem);
HTM_TEXTAREA_End ();
HTM_BR ();
- Tst_PutFormToEditQstMedia (&Question->Media,-1,
+ Qst_PutFormToEditQstMedia (&Question->Media,-1,
false);
/***** Feedback *****/
@@ -3480,7 +3482,7 @@ static void Qst_PutFormEditOneQst (struct Qst_Question *Question)
HTM_TEXTAREA_End ();
/* Media */
- Tst_PutFormToEditQstMedia (&Question->Answer.Options[NumOpt].Media,
+ Qst_PutFormToEditQstMedia (&Question->Answer.Options[NumOpt].Media,
(int) NumOpt,
OptionsDisabled);
@@ -3956,7 +3958,7 @@ static long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt)
// NumOpt < 0 ==> media associated to stem
// NumOpt >= 0 ==> media associated to an answer option
-static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
+static void Qst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
struct Med_Media *Media)
{
/***** Get media *****/
@@ -4007,7 +4009,7 @@ void Qst_ReceiveQst (void)
struct Tst_Test Test;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get parameters of the question from form *****/
Qst_GetQstFromForm (&Test.Question);
@@ -4024,7 +4026,7 @@ void Qst_ReceiveQst (void)
/***** Show the question just inserted in the database *****/
snprintf (Test.AnswerTypes.List,sizeof (Test.AnswerTypes.List),"%u",
(unsigned) Test.Question.Answer.Type);
- Tst_ListOneQstToEdit (&Test);
+ Qst_ListOneQstToEdit (&Test);
}
else // Question is wrong
{
@@ -4036,7 +4038,7 @@ void Qst_ReceiveQst (void)
}
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -4106,7 +4108,7 @@ static void Qst_GetQstFromForm (struct Qst_Question *Question)
Med_GetMediaFromForm (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod,
-1, // < 0 ==> the image associated to the stem
&Question->Media,
- Tst_GetMediaFromDB,
+ Qst_GetMediaFromDB,
NULL);
Ale_ShowAlerts (NULL);
@@ -4181,7 +4183,7 @@ static void Qst_GetQstFromForm (struct Qst_Question *Question)
Med_GetMediaFromForm (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod,
(int) NumOpt, // >= 0 ==> the image associated to an answer
&Question->Answer.Options[NumOpt].Media,
- Tst_GetMediaFromDB,
+ Qst_GetMediaFromDB,
NULL);
Ale_ShowAlerts (NULL);
}
@@ -4588,7 +4590,7 @@ void Qst_RequestRemoveSelectedQsts (void)
struct Tst_Test Test;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get parameters *****/
if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters from the form
@@ -4606,7 +4608,7 @@ void Qst_RequestRemoveSelectedQsts (void)
Qst_ListQuestionsToEdit ();
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -4623,7 +4625,7 @@ void Qst_RemoveSelectedQsts (void)
long QstCod;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get parameters *****/
if (Tst_GetParamsTst (&Test,Tst_EDIT_TEST)) // Get parameters
@@ -4653,7 +4655,7 @@ void Qst_RemoveSelectedQsts (void)
}
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -4678,7 +4680,7 @@ void Qst_RequestRemoveOneQst (void)
struct Tst_Test Test;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get main parameters from form *****/
/* Get the question code */
@@ -4711,12 +4713,12 @@ void Qst_RequestRemoveOneQst (void)
/***** Continue editing questions *****/
if (EditingOnlyThisQst)
- Tst_ListOneQstToEdit (&Test);
+ Qst_ListOneQstToEdit (&Test);
else
Qst_ListQuestionsToEdit ();
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
@@ -4800,7 +4802,7 @@ void Qst_ChangeShuffleQst (void)
bool Shuffle;
/***** Create test *****/
- Tst_TstConstructor (&Test);
+ Tst_Constructor (&Test);
/***** Get the question code *****/
Test.Question.QstCod = Qst_GetParamQstCod ();
@@ -4832,12 +4834,12 @@ void Qst_ChangeShuffleQst (void)
/***** Continue editing questions *****/
if (EditingOnlyThisQst)
- Tst_ListOneQstToEdit (&Test);
+ Qst_ListOneQstToEdit (&Test);
else
Qst_ListQuestionsToEdit ();
/***** Destroy test *****/
- Tst_TstDestructor (&Test);
+ Tst_Destructor (&Test);
}
/*****************************************************************************/
diff --git a/swad_test.h b/swad_test.h
index ef8d9656..7b2f4108 100644
--- a/swad_test.h
+++ b/swad_test.h
@@ -117,11 +117,8 @@ void Qst_RequestSelectQstsForExamSet (struct Exa_Exams *Exams);
void Qst_RequestSelectQstsForGame (struct Gam_Games *Games);
void Qst_ListQuestionsToEdit (void);
-void Tst_ListQuestionsToSelectForSet (struct Exa_Exams *Exams);
-void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games);
-
-void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
- bool Shuffle);
+void Qst_ListQuestionsToSelectForExamSet (struct Exa_Exams *Exams);
+void Qst_ListQuestionsToSelectForGame (struct Gam_Games *Games);
void Qst_PutParamsEditQst (void *Test);
diff --git a/swad_test_print.c b/swad_test_print.c
index b35ab870..3ce2bcf2 100644
--- a/swad_test_print.c
+++ b/swad_test_print.c
@@ -263,7 +263,7 @@ void TstPrn_UpdatePrintInDB (const struct TstPrn_Print *Print)
/*****************************************************************************/
void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
- unsigned NumExamsGeneratedByMe,
+ unsigned NumTstExamsGeneratedByMe,
TstPrn_RequestOrConfirm_t RequestOrConfirm)
{
extern const char *Hlp_ASSESSMENT_Tests;
@@ -292,7 +292,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
/***** Begin form *****/
Frm_BeginForm (Action[RequestOrConfirm]);
TstPrn_PutParamPrnCod (Print->PrnCod);
- Par_PutHiddenParamUnsigned (NULL,"NumTst",NumExamsGeneratedByMe);
+ Par_PutHiddenParamUnsigned (NULL,"NumTst",NumTstExamsGeneratedByMe);
/***** Begin table *****/
HTM_TABLE_BeginWideMarginPadding (10);
diff --git a/swad_test_print.h b/swad_test_print.h
index 2c5af2dc..d9fc0cd4 100644
--- a/swad_test_print.h
+++ b/swad_test_print.h
@@ -93,7 +93,7 @@ void TstPrn_CreatePrintInDB (struct TstPrn_Print *Print);
void TstPrn_UpdatePrintInDB (const struct TstPrn_Print *Print);
void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
- unsigned NumExamsGeneratedByMe,
+ unsigned NumTstExamsGeneratedByMe,
TstPrn_RequestOrConfirm_t RequestOrConfirm);
void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print);
@@ -115,6 +115,7 @@ void TstPrn_ComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
const struct Qst_Question *Question);
void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
const struct Qst_Question *Question);
+
//-----------------------------------------------------------------------------
void Qst_ChangeFormatAnswersText (struct Qst_Question *Question);