mirror of https://github.com/acanas/swad-core.git
Version 15.184.1
This commit is contained in:
parent
58ccf23b80
commit
27d20b8c63
|
@ -132,13 +132,15 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.184 (2016-04-06)"
|
#define Log_PLATFORM_VERSION "SWAD 15.184.1 (2016-04-06)"
|
||||||
#define CSS_FILE "swad15.178.2.css"
|
#define CSS_FILE "swad15.178.2.css"
|
||||||
#define JS_FILE "swad15.178.2.js"
|
#define JS_FILE "swad15.178.2.js"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.184.1: Apr 06, 2016 Fixed bug when removing a test question.
|
||||||
|
Code refactoring in tests. (198680 lines)
|
||||||
Version 15.184: Apr 06, 2016 Code refactoring in tests and images.
|
Version 15.184: Apr 06, 2016 Code refactoring in tests and images.
|
||||||
Fixed bugs in test questions. (198682 lines)
|
Fixed bugs in test questions. (198682 lines)
|
||||||
Version 15.183.1: Apr 06, 2016 Fix bug in feedback of test question. (198706 lines)
|
Version 15.183.1: Apr 06, 2016 Fix bug in feedback of test question. (198706 lines)
|
||||||
|
|
|
@ -386,6 +386,7 @@ void Gbl_InitializeGlobals (void)
|
||||||
|
|
||||||
Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF;
|
Gbl.Usrs.ClassPhoto.Cols = Usr_CLASS_PHOTO_COLS_DEF;
|
||||||
|
|
||||||
|
/* Statistics */
|
||||||
Gbl.Stat.ClicksGroupedBy = Sta_CLICKS_CRS_PER_USR;
|
Gbl.Stat.ClicksGroupedBy = Sta_CLICKS_CRS_PER_USR;
|
||||||
Gbl.Stat.CountType = Sta_TOTAL_CLICKS;
|
Gbl.Stat.CountType = Sta_TOTAL_CLICKS;
|
||||||
Gbl.Stat.Role = Sta_IDENTIFIED_USRS;
|
Gbl.Stat.Role = Sta_IDENTIFIED_USRS;
|
||||||
|
@ -397,19 +398,24 @@ void Gbl_InitializeGlobals (void)
|
||||||
|
|
||||||
Gbl.Usrs.Connected.TimeToRefreshInMs = Con_MAX_TIME_TO_REFRESH_CONNECTED_IN_MS;
|
Gbl.Usrs.Connected.TimeToRefreshInMs = Con_MAX_TIME_TO_REFRESH_CONNECTED_IN_MS;
|
||||||
|
|
||||||
|
/* Tests */
|
||||||
Gbl.Test.Config.Pluggable = Tst_PLUGGABLE_UNKNOWN;
|
Gbl.Test.Config.Pluggable = Tst_PLUGGABLE_UNKNOWN;
|
||||||
Gbl.Test.NumQsts = Tst_CONFIG_DEFAULT_DEF_QUESTIONS;
|
Gbl.Test.NumQsts = Tst_CONFIG_DEFAULT_DEF_QUESTIONS;
|
||||||
Gbl.Test.AllowTeachers = false; // Must the exam be saved?
|
Gbl.Test.AllowTeachers = false; // Must the exam be saved?
|
||||||
Gbl.Test.AllTags = Gbl.Test.AllAnsTypes = false;
|
Gbl.Test.AllAnsTypes = false;
|
||||||
Gbl.Test.TagsList = NULL;
|
|
||||||
Gbl.Test.ListAnsTypes[0] = '\0';
|
Gbl.Test.ListAnsTypes[0] = '\0';
|
||||||
|
|
||||||
|
Gbl.Test.Tags.Num = 0;
|
||||||
|
Gbl.Test.Tags.All = false;
|
||||||
|
Gbl.Test.Tags.List = NULL;
|
||||||
|
|
||||||
|
/* Forums */
|
||||||
Gbl.Forum.ForumType = (For_ForumType_t) 0;
|
Gbl.Forum.ForumType = (For_ForumType_t) 0;
|
||||||
Gbl.Forum.WhichForums = For_DEFAULT_WHICH_FORUMS;
|
Gbl.Forum.WhichForums = For_DEFAULT_WHICH_FORUMS;
|
||||||
Gbl.Forum.SelectedOrderType = For_DEFAULT_ORDER;
|
Gbl.Forum.SelectedOrderType = For_DEFAULT_ORDER;
|
||||||
Gbl.Forum.ThreadToMove = -1L;
|
Gbl.Forum.ThreadToMove = -1L;
|
||||||
|
|
||||||
/* Related to user nickname */
|
/* User nickname */
|
||||||
Gbl.Usrs.Me.UsrDat.Nickname[0] = '\0';
|
Gbl.Usrs.Me.UsrDat.Nickname[0] = '\0';
|
||||||
|
|
||||||
/* File browser */
|
/* File browser */
|
||||||
|
@ -423,7 +429,7 @@ void Gbl_InitializeGlobals (void)
|
||||||
Gbl.ColorRows[0] = "COLOR0"; // Darker
|
Gbl.ColorRows[0] = "COLOR0"; // Darker
|
||||||
Gbl.ColorRows[1] = "COLOR1"; // Lighter
|
Gbl.ColorRows[1] = "COLOR1"; // Lighter
|
||||||
|
|
||||||
/* Related to imported data from external site */
|
/* Imported data from external site */
|
||||||
Gbl.Imported.ExternalUsrId[0] = '\0';
|
Gbl.Imported.ExternalUsrId[0] = '\0';
|
||||||
Gbl.Imported.ExternalSesId[0] = '\0';
|
Gbl.Imported.ExternalSesId[0] = '\0';
|
||||||
Gbl.Imported.ExternalRole = Rol_UNKNOWN;
|
Gbl.Imported.ExternalRole = Rol_UNKNOWN;
|
||||||
|
|
|
@ -643,17 +643,20 @@ struct Globals
|
||||||
{
|
{
|
||||||
struct Tst_Config Config;
|
struct Tst_Config Config;
|
||||||
long QstCod;
|
long QstCod;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned Num;
|
||||||
|
bool All;
|
||||||
|
char *List;
|
||||||
|
char Txt[Tst_MAX_TAGS_PER_QUESTION][Tst_MAX_BYTES_TAG+1];
|
||||||
|
} Tags;
|
||||||
Tst_AnswerType_t AnswerType;
|
Tst_AnswerType_t AnswerType;
|
||||||
char TagText[Tst_MAX_TAGS_PER_QUESTION][Tst_MAX_BYTES_TAG+1];
|
|
||||||
unsigned NumQsts;
|
unsigned NumQsts;
|
||||||
long QstCodes[Tst_MAX_QUESTIONS_PER_EXAM]; // Codes of the sent/received questions in a test
|
long QstCodes[Tst_MAX_QUESTIONS_PER_EXAM]; // Codes of the sent/received questions in a test
|
||||||
char StrIndexesOneQst[Tst_MAX_QUESTIONS_PER_EXAM][Tst_MAX_SIZE_INDEXES_ONE_QST+1]; // 0 1 2 3, 3 0 2 1, etc.
|
char StrIndexesOneQst[Tst_MAX_QUESTIONS_PER_EXAM][Tst_MAX_SIZE_INDEXES_ONE_QST+1]; // 0 1 2 3, 3 0 2 1, etc.
|
||||||
char StrAnswersOneQst[Tst_MAX_QUESTIONS_PER_EXAM][Tst_MAX_SIZE_ANSWERS_ONE_QST+1]; // Answers selected by user
|
char StrAnswersOneQst[Tst_MAX_QUESTIONS_PER_EXAM][Tst_MAX_SIZE_ANSWERS_ONE_QST+1]; // Answers selected by user
|
||||||
bool AllowTeachers; // Can teachers of this course see the exam?
|
bool AllowTeachers; // Can teachers of this course see the exam?
|
||||||
bool AllTags;
|
|
||||||
bool AllAnsTypes;
|
bool AllAnsTypes;
|
||||||
unsigned NumTags;
|
|
||||||
char *TagsList;
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char *Text;
|
char *Text;
|
||||||
|
|
91
swad_test.c
91
swad_test.c
|
@ -1601,7 +1601,7 @@ static void Tst_ShowFormSelTags (unsigned long NumRows,MYSQL_RES *mysql_res,
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE\">"
|
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE\">"
|
||||||
"<input type=\"checkbox\" name=\"AllTags\" value=\"Y\"",
|
"<input type=\"checkbox\" name=\"AllTags\" value=\"Y\"",
|
||||||
The_ClassForm[Gbl.Prefs.Theme]);
|
The_ClassForm[Gbl.Prefs.Theme]);
|
||||||
if (Gbl.Test.AllTags)
|
if (Gbl.Test.Tags.All)
|
||||||
fprintf (Gbl.F.Out," checked=\"checked\"");
|
fprintf (Gbl.F.Out," checked=\"checked\"");
|
||||||
fprintf (Gbl.F.Out," onclick=\"togglecheckChildren(this,'ChkTag')\" />"
|
fprintf (Gbl.F.Out," onclick=\"togglecheckChildren(this,'ChkTag')\" />"
|
||||||
" %s"
|
" %s"
|
||||||
|
@ -1636,9 +1636,9 @@ static void Tst_ShowFormSelTags (unsigned long NumRows,MYSQL_RES *mysql_res,
|
||||||
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">"
|
fprintf (Gbl.F.Out,"<td class=\"DAT LEFT_MIDDLE\">"
|
||||||
"<input type=\"checkbox\" name=\"ChkTag\" value=\"%s\"",
|
"<input type=\"checkbox\" name=\"ChkTag\" value=\"%s\"",
|
||||||
row[1]);
|
row[1]);
|
||||||
if (Gbl.Test.TagsList)
|
if (Gbl.Test.Tags.List)
|
||||||
{
|
{
|
||||||
Ptr = Gbl.Test.TagsList;
|
Ptr = Gbl.Test.Tags.List;
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
||||||
|
@ -2332,7 +2332,7 @@ static unsigned long Tst_GetQuestionsForEdit (MYSQL_RES **mysql_res)
|
||||||
"tst_questions.NumHits,tst_questions.NumHitsNotBlank,"
|
"tst_questions.NumHits,tst_questions.NumHitsNotBlank,"
|
||||||
"tst_questions.Score"
|
"tst_questions.Score"
|
||||||
" FROM tst_questions");
|
" FROM tst_questions");
|
||||||
if (!Gbl.Test.AllTags)
|
if (!Gbl.Test.Tags.All)
|
||||||
strcat (Query,",tst_question_tags,tst_tags");
|
strcat (Query,",tst_question_tags,tst_tags");
|
||||||
|
|
||||||
strcat (Query," WHERE tst_questions.CrsCod='");
|
strcat (Query," WHERE tst_questions.CrsCod='");
|
||||||
|
@ -2347,7 +2347,7 @@ static unsigned long Tst_GetQuestionsForEdit (MYSQL_RES **mysql_res)
|
||||||
strcat (Query,"')");
|
strcat (Query,"')");
|
||||||
|
|
||||||
/* Add the tags selected */
|
/* Add the tags selected */
|
||||||
if (!Gbl.Test.AllTags)
|
if (!Gbl.Test.Tags.All)
|
||||||
{
|
{
|
||||||
strcat (Query," AND tst_questions.QstCod=tst_question_tags.QstCod"
|
strcat (Query," AND tst_questions.QstCod=tst_question_tags.QstCod"
|
||||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||||
|
@ -2356,7 +2356,7 @@ static unsigned long Tst_GetQuestionsForEdit (MYSQL_RES **mysql_res)
|
||||||
strcat (Query,"'");
|
strcat (Query,"'");
|
||||||
LengthQuery = strlen (Query);
|
LengthQuery = strlen (Query);
|
||||||
NumItemInList = 0;
|
NumItemInList = 0;
|
||||||
Ptr = Gbl.Test.TagsList;
|
Ptr = Gbl.Test.Tags.List;
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
||||||
|
@ -2487,12 +2487,12 @@ static unsigned long Tst_GetQuestionsForExam (MYSQL_RES **mysql_res)
|
||||||
Gbl.CurrentCrs.Crs.CrsCod,
|
Gbl.CurrentCrs.Crs.CrsCod,
|
||||||
Gbl.CurrentCrs.Crs.CrsCod);
|
Gbl.CurrentCrs.Crs.CrsCod);
|
||||||
|
|
||||||
if (!Gbl.Test.AllTags) // User has not selected all the tags
|
if (!Gbl.Test.Tags.All) // User has not selected all the tags
|
||||||
{
|
{
|
||||||
/* Add selected tags */
|
/* Add selected tags */
|
||||||
LengthQuery = strlen (Query);
|
LengthQuery = strlen (Query);
|
||||||
NumItemInList = 0;
|
NumItemInList = 0;
|
||||||
Ptr = Gbl.Test.TagsList;
|
Ptr = Gbl.Test.Tags.List;
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
||||||
|
@ -2882,10 +2882,10 @@ static void Tst_ListOneOrMoreQuestionsToEdit (unsigned long NumRows,MYSQL_RES *m
|
||||||
void Tst_WriteParamEditQst (void)
|
void Tst_WriteParamEditQst (void)
|
||||||
{
|
{
|
||||||
Par_PutHiddenParamChar ("AllTags",
|
Par_PutHiddenParamChar ("AllTags",
|
||||||
Gbl.Test.AllTags ? 'Y' :
|
Gbl.Test.Tags.All ? 'Y' :
|
||||||
'N');
|
'N');
|
||||||
Par_PutHiddenParamString ("ChkTag",
|
Par_PutHiddenParamString ("ChkTag",
|
||||||
Gbl.Test.TagsList ? Gbl.Test.TagsList :
|
Gbl.Test.Tags.List ? Gbl.Test.Tags.List :
|
||||||
"");
|
"");
|
||||||
Par_PutHiddenParamChar ("AllAnsTypes",
|
Par_PutHiddenParamChar ("AllAnsTypes",
|
||||||
Gbl.Test.AllAnsTypes ? 'Y' :
|
Gbl.Test.AllAnsTypes ? 'Y' :
|
||||||
|
@ -3099,10 +3099,6 @@ static void Tst_WriteAnswersOfAQstAssessExam (unsigned NumQst,long QstCod,
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
|
||||||
/***** Create test question *****/
|
|
||||||
Tst_QstConstructor ();
|
|
||||||
Gbl.Test.QstCod = QstCod;
|
|
||||||
|
|
||||||
/***** Get answers of a question from database *****/
|
/***** Get answers of a question from database *****/
|
||||||
Gbl.Test.Answer.NumOptions = Tst_GetAnswersQst (QstCod,&mysql_res,false); // Result: AnsInd,Answer,Correct
|
Gbl.Test.Answer.NumOptions = Tst_GetAnswersQst (QstCod,&mysql_res,false); // Result: AnsInd,Answer,Correct
|
||||||
/*
|
/*
|
||||||
|
@ -3138,9 +3134,6 @@ static void Tst_WriteAnswersOfAQstAssessExam (unsigned NumQst,long QstCod,
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Destroy test question *****/
|
|
||||||
Tst_QstDestructor ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -4154,12 +4147,12 @@ static bool Tst_GetParamsTst (void)
|
||||||
/***** Tags *****/
|
/***** Tags *****/
|
||||||
/* Get parameter that indicates whether all tags are selected */
|
/* Get parameter that indicates whether all tags are selected */
|
||||||
Par_GetParToText ("AllTags",YN,1);
|
Par_GetParToText ("AllTags",YN,1);
|
||||||
Gbl.Test.AllTags = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
|
Gbl.Test.Tags.All = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
|
||||||
|
|
||||||
/* Get the tags */
|
/* Get the tags */
|
||||||
if ((Gbl.Test.TagsList = malloc (Tst_MAX_BYTES_TAGS_LIST+1)) == NULL)
|
if ((Gbl.Test.Tags.List = malloc (Tst_MAX_BYTES_TAGS_LIST+1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Not enough memory to store tags.");
|
Lay_ShowErrorAndExit ("Not enough memory to store tags.");
|
||||||
Par_GetParMultiToText ("ChkTag",Gbl.Test.TagsList,Tst_MAX_BYTES_TAGS_LIST);
|
Par_GetParMultiToText ("ChkTag",Gbl.Test.Tags.List,Tst_MAX_BYTES_TAGS_LIST);
|
||||||
|
|
||||||
/* Check number of tags selected */
|
/* Check number of tags selected */
|
||||||
if (Tst_CountNumTagsInList () == 0) // If no tags selected...
|
if (Tst_CountNumTagsInList () == 0) // If no tags selected...
|
||||||
|
@ -4282,10 +4275,10 @@ static int Tst_CountNumTagsInList (void)
|
||||||
int NumTags = 0;
|
int NumTags = 0;
|
||||||
char TagText[Tst_MAX_BYTES_TAG+1];
|
char TagText[Tst_MAX_BYTES_TAG+1];
|
||||||
|
|
||||||
/***** Go over the list Gbl.Test.TagsList counting the number of tags *****/
|
/***** Go over the list Gbl.Test.Tags.List counting the number of tags *****/
|
||||||
if (Gbl.Test.TagsList)
|
if (Gbl.Test.Tags.List)
|
||||||
{
|
{
|
||||||
Ptr = Gbl.Test.TagsList;
|
Ptr = Gbl.Test.Tags.List;
|
||||||
while (*Ptr)
|
while (*Ptr)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tst_MAX_BYTES_TAG);
|
||||||
|
@ -4322,10 +4315,11 @@ static int Tst_CountNumAnswerTypesInList (void)
|
||||||
|
|
||||||
void Tst_FreeTagsList (void)
|
void Tst_FreeTagsList (void)
|
||||||
{
|
{
|
||||||
if (Gbl.Test.TagsList)
|
if (Gbl.Test.Tags.List)
|
||||||
{
|
{
|
||||||
free ((void *) Gbl.Test.TagsList);
|
free ((void *) Gbl.Test.Tags.List);
|
||||||
Gbl.Test.TagsList = NULL;
|
Gbl.Test.Tags.List = NULL;
|
||||||
|
Gbl.Test.Tags.Num = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4453,7 +4447,7 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<option value=\"%s\"",row[1]);
|
fprintf (Gbl.F.Out,"<option value=\"%s\"",row[1]);
|
||||||
if (!strcasecmp (Gbl.Test.TagText[NumTag],row[1]))
|
if (!strcasecmp (Gbl.Test.Tags.Txt[NumTag],row[1]))
|
||||||
{
|
{
|
||||||
fprintf (Gbl.F.Out," selected=\"selected\"");
|
fprintf (Gbl.F.Out," selected=\"selected\"");
|
||||||
TagNotFound = false;
|
TagNotFound = false;
|
||||||
|
@ -4461,9 +4455,9 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
|
||||||
fprintf (Gbl.F.Out,">%s</option>",row[1]);
|
fprintf (Gbl.F.Out,">%s</option>",row[1]);
|
||||||
}
|
}
|
||||||
/* If it's a new tag received from the form */
|
/* If it's a new tag received from the form */
|
||||||
if (TagNotFound && Gbl.Test.TagText[NumTag][0])
|
if (TagNotFound && Gbl.Test.Tags.Txt[NumTag][0])
|
||||||
fprintf (Gbl.F.Out,"<option value=\"%s\" selected=\"selected\">%s</option>",
|
fprintf (Gbl.F.Out,"<option value=\"%s\" selected=\"selected\">%s</option>",
|
||||||
Gbl.Test.TagText[NumTag],Gbl.Test.TagText[NumTag]);
|
Gbl.Test.Tags.Txt[NumTag],Gbl.Test.Tags.Txt[NumTag]);
|
||||||
fprintf (Gbl.F.Out,"<option value=\"\">[%s]</option>"
|
fprintf (Gbl.F.Out,"<option value=\"\">[%s]</option>"
|
||||||
"</select>"
|
"</select>"
|
||||||
"</td>",
|
"</td>",
|
||||||
|
@ -4475,7 +4469,7 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
|
||||||
" class=\"TAG_TXT\" maxlength=\"%u\" value=\"%s\""
|
" class=\"TAG_TXT\" maxlength=\"%u\" value=\"%s\""
|
||||||
" onchange=\"changeSelTag('%u')\" />"
|
" onchange=\"changeSelTag('%u')\" />"
|
||||||
"</td>",
|
"</td>",
|
||||||
NumTag,NumTag,Tst_MAX_TAG_LENGTH,Gbl.Test.TagText[NumTag],NumTag);
|
NumTag,NumTag,Tst_MAX_TAG_LENGTH,Gbl.Test.Tags.Txt[NumTag],NumTag);
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</tr>");
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
}
|
}
|
||||||
|
@ -4733,15 +4727,8 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
|
||||||
void Tst_QstConstructor (void)
|
void Tst_QstConstructor (void)
|
||||||
{
|
{
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
unsigned NumTag;
|
|
||||||
|
|
||||||
Gbl.Test.QstCod = -1L;
|
Gbl.Test.QstCod = -1L;
|
||||||
for (NumTag = 0;
|
|
||||||
NumTag < Tst_MAX_TAGS_PER_QUESTION;
|
|
||||||
NumTag++)
|
|
||||||
Gbl.Test.TagText[NumTag][0] = '\0';
|
|
||||||
Gbl.Test.NumTags = 0;
|
|
||||||
Gbl.Test.TagsList = NULL;
|
|
||||||
Gbl.Test.Stem.Text = NULL;
|
Gbl.Test.Stem.Text = NULL;
|
||||||
Gbl.Test.Stem.Length = 0;
|
Gbl.Test.Stem.Length = 0;
|
||||||
Gbl.Test.Feedback.Text = NULL;
|
Gbl.Test.Feedback.Text = NULL;
|
||||||
|
@ -4933,8 +4920,8 @@ static void Tst_GetQstDataFromDB (char *Stem,char *Feedback)
|
||||||
NumRow++)
|
NumRow++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
strncpy (Gbl.Test.TagText[NumRow],row[0],Tst_MAX_BYTES_TAG);
|
strncpy (Gbl.Test.Tags.Txt[NumRow],row[0],Tst_MAX_BYTES_TAG);
|
||||||
Gbl.Test.TagText[NumRow][Tst_MAX_BYTES_TAG] = '\0';
|
Gbl.Test.Tags.Txt[NumRow][Tst_MAX_BYTES_TAG] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free structure that stores the query result */
|
/* Free structure that stores the query result */
|
||||||
|
@ -5148,19 +5135,19 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
|
||||||
NumTag++)
|
NumTag++)
|
||||||
{
|
{
|
||||||
sprintf (TagStr,"TagTxt%u",NumTag);
|
sprintf (TagStr,"TagTxt%u",NumTag);
|
||||||
Par_GetParToText (TagStr,Gbl.Test.TagText[NumTag],Tst_MAX_BYTES_TAG);
|
Par_GetParToText (TagStr,Gbl.Test.Tags.Txt[NumTag],Tst_MAX_BYTES_TAG);
|
||||||
|
|
||||||
if (Gbl.Test.TagText[NumTag][0])
|
if (Gbl.Test.Tags.Txt[NumTag][0])
|
||||||
{
|
{
|
||||||
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,
|
Str_ChangeFormat (Str_FROM_FORM,Str_TO_TEXT,
|
||||||
Gbl.Test.TagText[NumTag],Tst_MAX_BYTES_TAG,true);
|
Gbl.Test.Tags.Txt[NumTag],Tst_MAX_BYTES_TAG,true);
|
||||||
/* Check if not repeated */
|
/* Check if not repeated */
|
||||||
for (NumTagRead = 0;
|
for (NumTagRead = 0;
|
||||||
NumTagRead < NumTag;
|
NumTagRead < NumTag;
|
||||||
NumTagRead++)
|
NumTagRead++)
|
||||||
if (!strcmp (Gbl.Test.TagText[NumTagRead],Gbl.Test.TagText[NumTag]))
|
if (!strcmp (Gbl.Test.Tags.Txt[NumTagRead],Gbl.Test.Tags.Txt[NumTag]))
|
||||||
{
|
{
|
||||||
Gbl.Test.TagText[NumTag][0] = '\0';
|
Gbl.Test.Tags.Txt[NumTag][0] = '\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5282,11 +5269,11 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Adjust global variables related to this test question *****/
|
/***** Adjust global variables related to this test question *****/
|
||||||
for (NumTag = 0, Gbl.Test.NumTags = 0;
|
for (NumTag = 0, Gbl.Test.Tags.Num = 0;
|
||||||
NumTag < Tst_MAX_TAGS_PER_QUESTION;
|
NumTag < Tst_MAX_TAGS_PER_QUESTION;
|
||||||
NumTag++)
|
NumTag++)
|
||||||
if (Gbl.Test.TagText[NumTag][0])
|
if (Gbl.Test.Tags.Txt[NumTag][0])
|
||||||
Gbl.Test.NumTags++;
|
Gbl.Test.Tags.Num++;
|
||||||
Gbl.Test.Stem.Text = Stem;
|
Gbl.Test.Stem.Text = Stem;
|
||||||
Gbl.Test.Stem.Length = strlen (Gbl.Test.Stem.Text);
|
Gbl.Test.Stem.Length = strlen (Gbl.Test.Stem.Text);
|
||||||
Gbl.Test.Feedback.Text = Feedback;
|
Gbl.Test.Feedback.Text = Feedback;
|
||||||
|
@ -5330,7 +5317,7 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (void)
|
||||||
Gbl.Test.Answer.NumOptions = 0;
|
Gbl.Test.Answer.NumOptions = 0;
|
||||||
|
|
||||||
/***** A question must have at least one tag *****/
|
/***** A question must have at least one tag *****/
|
||||||
if (!Gbl.Test.NumTags) // There are no tags with text
|
if (!Gbl.Test.Tags.Num) // There are no tags with text
|
||||||
{
|
{
|
||||||
Lay_ShowAlert (Lay_WARNING,Txt_You_must_type_at_least_one_tag_for_the_question);
|
Lay_ShowAlert (Lay_WARNING,Txt_You_must_type_at_least_one_tag_for_the_question);
|
||||||
return false;
|
return false;
|
||||||
|
@ -5942,14 +5929,14 @@ static void Tst_InsertTagsIntoDB (void)
|
||||||
|
|
||||||
/***** For each tag... *****/
|
/***** For each tag... *****/
|
||||||
for (NumTag = 0, TagIdx = 0;
|
for (NumTag = 0, TagIdx = 0;
|
||||||
TagIdx < Gbl.Test.NumTags;
|
TagIdx < Gbl.Test.Tags.Num;
|
||||||
NumTag++)
|
NumTag++)
|
||||||
if (Gbl.Test.TagText[NumTag][0])
|
if (Gbl.Test.Tags.Txt[NumTag][0])
|
||||||
{
|
{
|
||||||
/***** Check if this tag exists for current course *****/
|
/***** Check if this tag exists for current course *****/
|
||||||
if ((TagCod = Tst_GetTagCodFromTagTxt (Gbl.Test.TagText[NumTag])) < 0)
|
if ((TagCod = Tst_GetTagCodFromTagTxt (Gbl.Test.Tags.Txt[NumTag])) < 0)
|
||||||
/* This tag is new for current course. Add it to tags table */
|
/* This tag is new for current course. Add it to tags table */
|
||||||
TagCod = Tst_CreateNewTag (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.TagText[NumTag]);
|
TagCod = Tst_CreateNewTag (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.Tags.Txt[NumTag]);
|
||||||
|
|
||||||
/***** Insert tag in tst_question_tags *****/
|
/***** Insert tag in tst_question_tags *****/
|
||||||
sprintf (Query,"INSERT INTO tst_question_tags (QstCod,TagCod,TagInd)"
|
sprintf (Query,"INSERT INTO tst_question_tags (QstCod,TagCod,TagInd)"
|
||||||
|
|
|
@ -551,22 +551,21 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
|
||||||
Lay_ShowErrorAndExit ("Wrong type of answer.");
|
Lay_ShowErrorAndExit ("Wrong type of answer.");
|
||||||
|
|
||||||
/* Get tags */
|
/* Get tags */
|
||||||
Gbl.Test.NumTags = 0;
|
for (TagsElem = QuestionElem->FirstChild, Gbl.Test.Tags.Num = 0;
|
||||||
for (TagsElem = QuestionElem->FirstChild;
|
|
||||||
TagsElem != NULL;
|
TagsElem != NULL;
|
||||||
TagsElem = TagsElem->NextBrother)
|
TagsElem = TagsElem->NextBrother)
|
||||||
if (!strcmp (TagsElem->TagName,"tags"))
|
if (!strcmp (TagsElem->TagName,"tags"))
|
||||||
{
|
{
|
||||||
for (TagElem = TagsElem->FirstChild;
|
for (TagElem = TagsElem->FirstChild;
|
||||||
TagElem != NULL && Gbl.Test.NumTags < Tst_MAX_TAGS_PER_QUESTION;
|
TagElem != NULL && Gbl.Test.Tags.Num < Tst_MAX_TAGS_PER_QUESTION;
|
||||||
TagElem = TagElem->NextBrother)
|
TagElem = TagElem->NextBrother)
|
||||||
if (!strcmp (TagElem->TagName,"tag"))
|
if (!strcmp (TagElem->TagName,"tag"))
|
||||||
{
|
{
|
||||||
if (TagElem->Content)
|
if (TagElem->Content)
|
||||||
{
|
{
|
||||||
strncpy (Gbl.Test.TagText[Gbl.Test.NumTags],TagElem->Content,Tst_MAX_BYTES_TAG);
|
strncpy (Gbl.Test.Tags.Txt[Gbl.Test.Tags.Num],TagElem->Content,Tst_MAX_BYTES_TAG);
|
||||||
Gbl.Test.TagText[Gbl.Test.NumTags][Tst_MAX_BYTES_TAG] = '\0';
|
Gbl.Test.Tags.Txt[Gbl.Test.Tags.Num][Tst_MAX_BYTES_TAG] = '\0';
|
||||||
Gbl.Test.NumTags++;
|
Gbl.Test.Tags.Num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break; // Only first element "tags"
|
break; // Only first element "tags"
|
||||||
|
@ -1051,12 +1050,12 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
|
||||||
/***** Write the question tags *****/
|
/***** Write the question tags *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP COLOR%u\">",
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_TOP COLOR%u\">",
|
||||||
Gbl.RowEvenOdd);
|
Gbl.RowEvenOdd);
|
||||||
if (Gbl.Test.NumTags)
|
if (Gbl.Test.Tags.Num)
|
||||||
{
|
{
|
||||||
/***** Write the tags *****/
|
/***** Write the tags *****/
|
||||||
fprintf (Gbl.F.Out,"<table>");
|
fprintf (Gbl.F.Out,"<table>");
|
||||||
for (NumTag = 0;
|
for (NumTag = 0;
|
||||||
NumTag < Gbl.Test.NumTags;
|
NumTag < Gbl.Test.Tags.Num;
|
||||||
NumTag++)
|
NumTag++)
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s LEFT_TOP\">"
|
"<td class=\"%s LEFT_TOP\">"
|
||||||
|
@ -1067,7 +1066,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
|
||||||
"</td>"
|
"</td>"
|
||||||
"</tr>",
|
"</tr>",
|
||||||
ClassData,
|
ClassData,
|
||||||
ClassData,Gbl.Test.TagText[NumTag]);
|
ClassData,Gbl.Test.Tags.Txt[NumTag]);
|
||||||
fprintf (Gbl.F.Out,"</table>");
|
fprintf (Gbl.F.Out,"</table>");
|
||||||
}
|
}
|
||||||
else // no tags for this question
|
else // no tags for this question
|
||||||
|
|
Loading…
Reference in New Issue