Version19.203

This commit is contained in:
acanas 2020-04-27 16:00:53 +02:00
parent 5307de7a02
commit 767e1511b1
10 changed files with 247 additions and 180 deletions

View File

@ -516,9 +516,7 @@ CREATE TABLE IF NOT EXISTS exa_participants (
-- --
CREATE TABLE IF NOT EXISTS exa_questions ( CREATE TABLE IF NOT EXISTS exa_questions (
SetCod INT NOT NULL, SetCod INT NOT NULL,
QstInd INT NOT NULL,
QstCod INT NOT NULL, QstCod INT NOT NULL,
UNIQUE INDEX(SetCod,QstInd),
UNIQUE INDEX(SetCod,QstCod)); UNIQUE INDEX(SetCod,QstCod));
-- --
-- Table exa_results: stores exam results -- Table exa_results: stores exam results

View File

@ -730,7 +730,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
[ActReqAddQstExaSet ] = {1885,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,ExaSet_ReqSelectQstsToAddToSet ,NULL}, [ActReqAddQstExaSet ] = {1885,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,ExaSet_ReqSelectQstsToAddToSet ,NULL},
[ActLstTstQstForSet ] = {1886,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_ListQstsToAddToSet ,NULL}, [ActLstTstQstForSet ] = {1886,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_ListQstsToAddToSet ,NULL},
[ActAddQstToExa ] = {1887,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_AddQstsToSet ,NULL}, [ActAddQstToExa ] = {1887,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_AddQstsToSet ,NULL},
[ActReqRemExaQst ] = {1888,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RequestRemoveQst ,NULL}, [ActReqRemSetQst ] = {1888,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RequestRemoveQst ,NULL},
[ActRemExaQst ] = {1889,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RemoveQst ,NULL}, [ActRemExaQst ] = {1889,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RemoveQst ,NULL},
[ActSeeGam ] = {1650,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_SeeOneGame ,NULL}, [ActSeeGam ] = {1650,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_SeeOneGame ,NULL},
@ -3698,7 +3698,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActReqAddQstExaSet, // #1885 ActReqAddQstExaSet, // #1885
ActLstTstQstForSet, // #1886 ActLstTstQstForSet, // #1886
ActAddQstToExa, // #1887 ActAddQstToExa, // #1887
ActReqRemExaQst, // #1888 ActReqRemSetQst, // #1888
ActRemExaQst, // #1889 ActRemExaQst, // #1889
-1, // #1890 (obsolete action) -1, // #1890 (obsolete action)
-1, // #1891 (obsolete action) -1, // #1891 (obsolete action)

View File

@ -695,7 +695,7 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActReqAddQstExaSet (ActChgCrsTT1stDay + 167) #define ActReqAddQstExaSet (ActChgCrsTT1stDay + 167)
#define ActLstTstQstForSet (ActChgCrsTT1stDay + 168) #define ActLstTstQstForSet (ActChgCrsTT1stDay + 168)
#define ActAddQstToExa (ActChgCrsTT1stDay + 169) #define ActAddQstToExa (ActChgCrsTT1stDay + 169)
#define ActReqRemExaQst (ActChgCrsTT1stDay + 170) #define ActReqRemSetQst (ActChgCrsTT1stDay + 170)
#define ActRemExaQst (ActChgCrsTT1stDay + 171) #define ActRemExaQst (ActChgCrsTT1stDay + 171)
#define ActSeeGam (ActChgCrsTT1stDay + 172) #define ActSeeGam (ActChgCrsTT1stDay + 172)

View File

@ -544,10 +544,16 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.202 (2020-04-27)" #define Log_PLATFORM_VERSION "SWAD 19.203 (2020-04-27)"
#define CSS_FILE "swad19.193.1.css" #define CSS_FILE "swad19.193.1.css"
#define JS_FILE "swad19.193.1.js" #define JS_FILE "swad19.193.1.js"
/* /*
Version 19.203: Apr 27, 2020 List questions in every set of questions. (300606 lines)
3 changes necessary in database:
ALTER TABLE exa_questions DROP INDEX SetCod,DROP INDEX SetCod_2;
ALTER TABLE exa_questions DROP COLUMN QstInd;
ALTER TABLE exa_questions ADD UNIQUE INDEX(SetCod,QstCod);
Version 19.202: Apr 27, 2020 Form to add questions to set of questions. (300558 lines) Version 19.202: Apr 27, 2020 Form to add questions to set of questions. (300558 lines)
5 changes necessary in database: 5 changes necessary in database:
ALTER TABLE exa_questions CHANGE COLUMN QstInd QstInd INT NOT NULL AFTER SetCod; ALTER TABLE exa_questions CHANGE COLUMN QstInd QstInd INT NOT NULL AFTER SetCod;

View File

@ -1144,16 +1144,13 @@ mysql> DESCRIBE exa_questions;
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+ +--------+---------+------+-----+---------+-------+
| SetCod | int(11) | NO | PRI | NULL | | | SetCod | int(11) | NO | PRI | NULL | |
| QstInd | int(11) | NO | PRI | NULL | | | QstCod | int(11) | NO | PRI | NULL | |
| QstCod | int(11) | NO | | NULL | |
+--------+---------+------+-----+---------+-------+ +--------+---------+------+-----+---------+-------+
3 rows in set (0.00 sec) 2 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_questions (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_questions ("
"SetCod INT NOT NULL," "SetCod INT NOT NULL,"
"QstInd INT NOT NULL,"
"QstCod INT NOT NULL," "QstCod INT NOT NULL,"
"UNIQUE INDEX(SetCod,QstInd),"
"UNIQUE INDEX(SetCod,QstCod))"); "UNIQUE INDEX(SetCod,QstCod))");
/***** Table exa_results *****/ /***** Table exa_results *****/

View File

@ -181,7 +181,6 @@ static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod);
static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd); static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd);
static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod); static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod);
static unsigned ExaSet_GetMaxQuestionIndexInSet (long SetCod);
static unsigned ExaSet_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd); static unsigned ExaSet_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd);
static unsigned ExaSet_GetNextSetIndexInExam (long ExaCod,unsigned SetInd); static unsigned ExaSet_GetNextSetIndexInExam (long ExaCod,unsigned SetInd);
@ -189,9 +188,12 @@ static unsigned ExaSet_GetNextSetIndexInExam (long ExaCod,unsigned SetInd);
static void ExaSet_ListExamSets (struct Exa_Exams *Exams, static void ExaSet_ListExamSets (struct Exa_Exams *Exams,
struct Exa_Exam *Exam, struct Exa_Exam *Exam,
struct ExaSet_Set *Set); struct ExaSet_Set *Set);
static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams,
const struct Exa_Exam *Exam,
const struct ExaSet_Set *Set);
static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam); static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam);
static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
long ExaCod, const struct Exa_Exam *Exam,
unsigned MaxSetInd, unsigned MaxSetInd,
unsigned NumSets, unsigned NumSets,
MYSQL_RES *mysql_res, MYSQL_RES *mysql_res,
@ -200,12 +202,15 @@ static void ExaSet_PutTableHeadingForSets (void);
static void ExaSet_ResetSet (struct ExaSet_Set *Set); static void ExaSet_ResetSet (struct ExaSet_Set *Set);
// static void Exa_PutParamSetCod (void *SetCod); // static void Exa_PutParamSetCod (void *SetCod);
static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
unsigned NumQsts,
MYSQL_RES *mysql_res,
bool ICanEditQuestions);
static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
long ExaCod,unsigned NumQsts, long ExaCod,unsigned NumQsts,
MYSQL_RES *mysql_res, MYSQL_RES *mysql_res,
bool ICanEditQuestions); bool ICanEditQuestions);
static void Exa_ListQuestionForEdition (const struct Tst_Question *Question,
unsigned QstInd,bool QuestionExists);
static void Exa_PutIconToAddNewQuestions (void *Exams); static void Exa_PutIconToAddNewQuestions (void *Exams);
static void Exa_PutButtonToAddNewQuestions (struct Exa_Exams *Exams); static void Exa_PutButtonToAddNewQuestions (struct Exa_Exams *Exams);
@ -2537,35 +2542,6 @@ static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod)
return SetInd; return SetInd;
} }
/*****************************************************************************/
/************ Get maximum question index in a set of questions ***************/
/*****************************************************************************/
// Question index can be 1, 2, 3...
// Return 0 if no questions
static unsigned ExaSet_GetMaxQuestionIndexInSet (long SetCod)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned QstInd = 0; // Default value if no questions in set
/***** Get maximum question index in an exam from database *****/
DB_QuerySELECT (&mysql_res,"can not get max question index",
"SELECT MAX(QstInd)"
" FROM exa_questions"
" WHERE SetCod=%ld",
SetCod);
row = mysql_fetch_row (mysql_res);
if (row[0]) // There are questions
if (sscanf (row[0],"%u",&QstInd) != 1)
Lay_ShowErrorAndExit ("Error when getting max question index.");
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
return QstInd;
}
/*****************************************************************************/ /*****************************************************************************/
/*********** Get previous set index to a given set index in an exam **********/ /*********** Get previous set index to a given set index in an exam **********/
/*****************************************************************************/ /*****************************************************************************/
@ -2741,8 +2717,8 @@ static void ExaSet_ListExamSets (struct Exa_Exams *Exams,
/***** Show table with sets *****/ /***** Show table with sets *****/
if (NumSets) if (NumSets)
ExaSet_ListOneOrMoreSetsForEdition (Exams, ExaSet_ListOneOrMoreSetsForEdition (Exams,Exam,
Exam->ExaCod,MaxSetInd, MaxSetInd,
NumSets,mysql_res, NumSets,mysql_res,
ICanEditSets); ICanEditSets);
else // This exam has no sets else // This exam has no sets
@ -2762,6 +2738,56 @@ static void ExaSet_ListExamSets (struct Exa_Exams *Exams,
/************************ List the questions of an exam ***********************/ /************************ List the questions of an exam ***********************/
/*****************************************************************************/ /*****************************************************************************/
static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams,
const struct Exa_Exam *Exam,
const struct ExaSet_Set *Set)
{
extern const char *Hlp_ASSESSMENT_Exams_questions;
extern const char *Txt_Questions;
MYSQL_RES *mysql_res;
unsigned NumQsts;
bool ICanEditQuestions = Exa_CheckIfEditable (Exam);
/***** Get data of questions from database *****/
NumQsts = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get exam questions",
"SELECT exa_questions.QstCod" // row[0]
" FROM exa_questions,tst_questions"
" WHERE exa_questions.SetCod=%ld"
" AND exa_questions.QstCod=tst_questions.QstCod"
" ORDER BY tst_questions.Stem",
Set->SetCod);
/***** Begin box *****/
if (ICanEditQuestions)
Box_BoxBegin (NULL,Txt_Questions,
Exa_PutIconToAddNewQuestions,Exams,
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
else
Box_BoxBegin (NULL,Txt_Questions,
NULL,NULL,
Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE);
/***** Show table with questions *****/
if (NumQsts)
ExaSet_ListOneOrMoreQuestionsForEdition (Exams,NumQsts,mysql_res,
ICanEditQuestions);
/***** Put button to add a new question in this set *****/
if (ICanEditQuestions) // I can edit questions
Exa_PutButtonToAddNewQuestions (Exams);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** End box *****/
Box_BoxEnd ();
}
/*****************************************************************************/
/************************ List the questions of an exam ***********************/
/*****************************************************************************/
static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam) static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam)
{ {
extern const char *Hlp_ASSESSMENT_Exams_questions; extern const char *Hlp_ASSESSMENT_Exams_questions;
@ -2816,7 +2842,7 @@ static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam
/*****************************************************************************/ /*****************************************************************************/
static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
long ExaCod, const struct Exa_Exam *Exam,
unsigned MaxSetInd, unsigned MaxSetInd,
unsigned NumSets, unsigned NumSets,
MYSQL_RES *mysql_res, MYSQL_RES *mysql_res,
@ -2827,8 +2853,8 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
extern const char *Txt_Move_down_X; extern const char *Txt_Move_down_X;
extern const char *Txt_Movement_not_allowed; extern const char *Txt_Movement_not_allowed;
unsigned NumSet; unsigned NumSet;
MYSQL_ROW row;
struct ExaSet_Set Set; struct ExaSet_Set Set;
MYSQL_ROW row;
char *Anchor = NULL; char *Anchor = NULL;
char StrSetInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char StrSetInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
@ -2871,7 +2897,6 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
ExaSet_MAX_BYTES_TITLE); ExaSet_MAX_BYTES_TITLE);
/* Initialize context */ /* Initialize context */
Exams->ExaCod = ExaCod;
Exams->SetCod = Set.SetCod; Exams->SetCod = Set.SetCod;
Exams->SetInd = Set.SetInd; Exams->SetInd = Set.SetInd;
@ -2964,7 +2989,10 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
/***** Questions *****/ /***** Questions *****/
HTM_TD_Begin ("colspan=\"3\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("colspan=\"3\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
Exa_PutButtonToAddNewQuestions (Exams);
/* List questions */
ExaSet_ListSetQuestions (Exams,Exam,&Set);
HTM_TD_End (); HTM_TD_End ();
/***** End second row *****/ /***** End second row *****/
@ -3027,6 +3055,104 @@ static void Exa_PutParamSetCod (void *SetCod) // Should be a pointer to long
Par_PutHiddenParamLong (NULL,"SetCod",*((long *) SetCod)); Par_PutHiddenParamLong (NULL,"SetCod",*((long *) SetCod));
} }
*/ */
/*****************************************************************************/
/********************* List exam questions for edition ***********************/
/*****************************************************************************/
static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
unsigned NumQsts,
MYSQL_RES *mysql_res,
bool ICanEditQuestions)
{
extern const char *Txt_Questions;
extern const char *Txt_No_INDEX;
extern const char *Txt_Code;
extern const char *Txt_Tags;
extern const char *Txt_Question;
unsigned NumQst;
MYSQL_ROW row;
struct Tst_Question Question;
bool QuestionExists;
char *Anchor = NULL;
/***** Build anchor string *****/
Frm_SetAnchorStr (Exams->SetCod,&Anchor);
/***** Write the heading *****/
HTM_TABLE_BeginWideMarginPadding (2);
HTM_TR_Begin (NULL);
HTM_TH_Empty (1);
HTM_TH (1,1,"CT",Txt_No_INDEX);
HTM_TH (1,1,"CT",Txt_Code);
HTM_TH (1,1,"CT",Txt_Tags);
HTM_TH (1,1,"CT",Txt_Question);
HTM_TR_End ();
/***** Write rows *****/
for (NumQst = 0;
NumQst < NumQsts;
NumQst++)
{
Gbl.RowEvenOdd = NumQst % 2;
/***** Create test question *****/
Tst_QstConstructor (&Question);
/***** Get question data *****/
row = mysql_fetch_row (mysql_res);
/*
row[0] QstCod
*/
/* Get question code (row[0]) */
Question.QstCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Begin row *****/
HTM_TR_Begin (NULL);
/***** Icons *****/
HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
/* Put icon to remove the question */
if (ICanEditQuestions)
{
Frm_StartForm (ActReqRemSetQst);
ExaSet_PutParamsOneSet (Exams);
Tst_PutParamQstCod (&Question.QstCod);
Ico_PutIconRemove ();
Frm_EndForm ();
}
else
Ico_PutIconRemovalNotAllowed ();
/* Put icon to edit the question */
if (ICanEditQuestions)
Ico_PutContextualIconToEdit (ActEdiOneTstQst,NULL,
Tst_PutParamQstCod,&Question.QstCod);
HTM_TD_End ();
/***** Question *****/
QuestionExists = Tst_GetQstDataFromDB (&Question);
Tst_ListQuestionForEdition (&Question,NumQst + 1,QuestionExists,Anchor);
/***** End row *****/
HTM_TR_End ();
/***** Destroy test question *****/
Tst_QstDestructor (&Question);
}
/***** End table *****/
HTM_TABLE_End ();
/***** Free anchor string *****/
Frm_FreeAnchorStr (Anchor);
}
/*****************************************************************************/ /*****************************************************************************/
/********************* List exam questions for edition ***********************/ /********************* List exam questions for edition ***********************/
/*****************************************************************************/ /*****************************************************************************/
@ -3097,7 +3223,7 @@ static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
/* Put icon to remove the question */ /* Put icon to remove the question */
if (ICanEditQuestions) if (ICanEditQuestions)
{ {
Frm_StartForm (ActReqRemExaQst); Frm_StartForm (ActReqRemSetQst);
Exa_PutParams (Exams); Exa_PutParams (Exams);
Exa_PutParamQstInd (QstInd); Exa_PutParamQstInd (QstInd);
Ico_PutIconRemove (); Ico_PutIconRemove ();
@ -3115,7 +3241,7 @@ static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
/***** Question *****/ /***** Question *****/
QuestionExists = Tst_GetQstDataFromDB (&Question); QuestionExists = Tst_GetQstDataFromDB (&Question);
Exa_ListQuestionForEdition (&Question,QstInd,QuestionExists); Tst_ListQuestionForEdition (&Question,QstInd,QuestionExists,NULL);
HTM_TR_End (); HTM_TR_End ();
@ -3127,61 +3253,6 @@ static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
HTM_TABLE_End (); HTM_TABLE_End ();
} }
/*****************************************************************************/
/********************** List exam question for edition ***********************/
/*****************************************************************************/
static void Exa_ListQuestionForEdition (const struct Tst_Question *Question,
unsigned QstInd,bool QuestionExists)
{
extern const char *Txt_Question_removed;
/***** Number of question and answer type (row[1]) *****/
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
Tst_WriteNumQst (QstInd);
if (QuestionExists)
Tst_WriteAnswerType (Question->Answer.Type);
HTM_TD_End ();
/***** Write question code *****/
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
HTM_TxtF ("%ld&nbsp;",Question->QstCod);
HTM_TD_End ();
/***** Write the question tags *****/
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
if (QuestionExists)
Tst_GetAndWriteTagsQst (Question->QstCod);
HTM_TD_End ();
/***** Write stem (row[3]) and media *****/
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
if (QuestionExists)
{
/* Write stem */
Tst_WriteQstStem (Question->Stem,"TEST_EDI",
true); // Visible
/* Show media */
Med_ShowMedia (&Question->Media,
"TEST_MED_EDIT_LIST_STEM_CONTAINER",
"TEST_MED_EDIT_LIST_STEM");
/* Show feedback */
Tst_WriteQstFeedback (Question->Feedback,"TEST_EDI_LIGHT");
/* Show answers */
Tst_WriteAnswersListing (Question);
}
else
{
HTM_SPAN_Begin ("class=\"DAT_LIGHT\"");
HTM_Txt (Txt_Question_removed);
HTM_SPAN_End ();
}
HTM_TD_End ();
}
/*****************************************************************************/ /*****************************************************************************/
/***************** Put icon to add a new questions to exam *******************/ /***************** Put icon to add a new questions to exam *******************/
/*****************************************************************************/ /*****************************************************************************/
@ -3224,7 +3295,6 @@ void ExaSet_AddQstsToSet (void)
const char *Ptr; const char *Ptr;
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1]; char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
long QstCod; long QstCod;
unsigned MaxQstInd;
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
@ -3277,16 +3347,13 @@ void ExaSet_AddQstsToSet (void)
if (sscanf (LongStr,"%ld",&QstCod) != 1) if (sscanf (LongStr,"%ld",&QstCod) != 1)
Lay_ShowErrorAndExit ("Wrong question code."); Lay_ShowErrorAndExit ("Wrong question code.");
/* Get current maximum index */
MaxQstInd = ExaSet_GetMaxQuestionIndexInSet (Set.SetCod); // 0 if no questions
/* Insert question in the table of questions */ /* Insert question in the table of questions */
DB_QueryINSERT ("can not add question to set", DB_QueryINSERT ("can not add question to set",
"INSERT INTO exa_questions" "INSERT INTO exa_questions"
" (SetCod,QstInd,QstCod)" " (SetCod,QstCod)"
" VALUES" " VALUES"
" (%ld,%u,%ld)", " (%ld,%ld)",
Set.SetCod,MaxQstInd + 1,QstCod); Set.SetCod,QstCod);
} }
} }
else else

View File

@ -158,9 +158,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
long GamCod,unsigned NumQsts, long GamCod,unsigned NumQsts,
MYSQL_RES *mysql_res, MYSQL_RES *mysql_res,
bool ICanEditQuestions); bool ICanEditQuestions);
static void Gam_ListQuestionForEdition (const struct Tst_Question *Question,
unsigned QstInd,bool QuestionExists,
const char *Anchor);
static void Gam_PutIconToAddNewQuestions (void *Games); static void Gam_PutIconToAddNewQuestions (void *Games);
static void Gam_PutButtonToAddNewQuestions (struct Gam_Games *Games); static void Gam_PutButtonToAddNewQuestions (struct Gam_Games *Games);
@ -1998,9 +1996,9 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
struct Tst_Question Question; struct Tst_Question Question;
unsigned QstInd; unsigned QstInd;
unsigned MaxQstInd; unsigned MaxQstInd;
char *Anchor = NULL;
char StrQstInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char StrQstInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
bool QuestionExists; bool QuestionExists;
char *Anchor = NULL;
/***** Get maximum question index *****/ /***** Get maximum question index *****/
MaxQstInd = Gam_GetMaxQuestionIndexInGame (GamCod); // 0 is no questions in game MaxQstInd = Gam_GetMaxQuestionIndexInGame (GamCod); // 0 is no questions in game
@ -2049,8 +2047,6 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
Games->QstInd = QstInd; Games->QstInd = QstInd;
/***** Build anchor string *****/ /***** Build anchor string *****/
// The same question may appear more than once.
// In that case, the page will be positioned in the first occurrence.
Frm_SetAnchorStr (Question.QstCod,&Anchor); Frm_SetAnchorStr (Question.QstCod,&Anchor);
/***** Begin row *****/ /***** Begin row *****/
@ -2106,7 +2102,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
/***** Question *****/ /***** Question *****/
QuestionExists = Tst_GetQstDataFromDB (&Question); QuestionExists = Tst_GetQstDataFromDB (&Question);
Gam_ListQuestionForEdition (&Question,QstInd,QuestionExists,Anchor); Tst_ListQuestionForEdition (&Question,QstInd,QuestionExists,Anchor);
/***** End row *****/ /***** End row *****/
HTM_TR_End (); HTM_TR_End ();
@ -2122,64 +2118,6 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
HTM_TABLE_End (); HTM_TABLE_End ();
} }
/*****************************************************************************/
/********************** List game question for edition ***********************/
/*****************************************************************************/
static void Gam_ListQuestionForEdition (const struct Tst_Question *Question,
unsigned QstInd,bool QuestionExists,
const char *Anchor)
{
extern const char *Txt_Question_removed;
/***** Number of question and answer type (row[1]) *****/
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
Tst_WriteNumQst (QstInd);
if (QuestionExists)
Tst_WriteAnswerType (Question->Answer.Type);
HTM_TD_End ();
/***** Write question code *****/
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
HTM_TxtF ("%ld&nbsp;",Question->QstCod);
HTM_TD_End ();
/***** Write the question tags *****/
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
if (QuestionExists)
Tst_GetAndWriteTagsQst (Question->QstCod);
HTM_TD_End ();
/***** Write stem (row[3]) and media *****/
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
HTM_ARTICLE_Begin (Anchor);
if (QuestionExists)
{
/* Write stem */
Tst_WriteQstStem (Question->Stem,"TEST_EDI",
true); // Visible
/* Show media */
Med_ShowMedia (&Question->Media,
"TEST_MED_EDIT_LIST_STEM_CONTAINER",
"TEST_MED_EDIT_LIST_STEM");
/* Show feedback */
Tst_WriteQstFeedback (Question->Feedback,"TEST_EDI_LIGHT");
/* Show answers */
Tst_WriteAnswersListing (Question);
}
else
{
HTM_SPAN_Begin ("class=\"DAT_LIGHT\"");
HTM_Txt (Txt_Question_removed);
HTM_SPAN_End ();
}
HTM_ARTICLE_End ();
HTM_TD_End ();
}
/*****************************************************************************/ /*****************************************************************************/
/***************** Put icon to add a new questions to game *******************/ /***************** Put icon to add a new questions to game *******************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -940,6 +940,64 @@ static void Tst_WriteQstAndAnsSeeing (const struct TstRes_Result *Result,
HTM_TR_End (); HTM_TR_End ();
} }
/*****************************************************************************/
/******************* List exam/game question for edition *********************/
/*****************************************************************************/
void Tst_ListQuestionForEdition (const struct Tst_Question *Question,
unsigned QstInd,bool QuestionExists,
const char *Anchor)
{
extern const char *Txt_Question_removed;
/***** Number of question and answer type (row[1]) *****/
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
Tst_WriteNumQst (QstInd);
if (QuestionExists)
Tst_WriteAnswerType (Question->Answer.Type);
HTM_TD_End ();
/***** Write question code *****/
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
HTM_TxtF ("%ld&nbsp;",Question->QstCod);
HTM_TD_End ();
/***** Write the question tags *****/
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
if (QuestionExists)
Tst_GetAndWriteTagsQst (Question->QstCod);
HTM_TD_End ();
/***** Write stem (row[3]) and media *****/
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
HTM_ARTICLE_Begin (Anchor);
if (QuestionExists)
{
/* Write stem */
Tst_WriteQstStem (Question->Stem,"TEST_EDI",
true); // Visible
/* Show media */
Med_ShowMedia (&Question->Media,
"TEST_MED_EDIT_LIST_STEM_CONTAINER",
"TEST_MED_EDIT_LIST_STEM");
/* Show feedback */
Tst_WriteQstFeedback (Question->Feedback,"TEST_EDI_LIGHT");
/* Show answers */
Tst_WriteAnswersListing (Question);
}
else
{
HTM_SPAN_Begin ("class=\"DAT_LIGHT\"");
HTM_Txt (Txt_Question_removed);
HTM_SPAN_End ();
}
HTM_ARTICLE_End ();
HTM_TD_End ();
}
/*****************************************************************************/ /*****************************************************************************/
/********************* Write the number of a test question *******************/ /********************* Write the number of a test question *******************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -161,6 +161,9 @@ void Tst_AssessTest (void);
void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res); void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res);
void Tst_ListQuestionForEdition (const struct Tst_Question *Question,
unsigned QstInd,bool QuestionExists,
const char *Anchor);
void Tst_WriteNumQst (unsigned NumQst); void Tst_WriteNumQst (unsigned NumQst);
void Tst_WriteAnswerType (Tst_AnswerType_t AnswerType); void Tst_WriteAnswerType (Tst_AnswerType_t AnswerType);
void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible); void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible);

View File

@ -11045,7 +11045,7 @@ const char *Txt_Actions[Act_NUM_ACTIONS] =
"" // Precisa de tradução "" // Precisa de tradução
#endif #endif
, ,
[ActReqRemExaQst] = [ActReqRemSetQst] =
#if L==1 // ca #if L==1 // ca
"" // Necessita traducció "" // Necessita traducció
#elif L==2 // de #elif L==2 // de