Version19.194.1

This commit is contained in:
acanas 2020-04-25 01:36:53 +02:00
parent f882a3beca
commit f50dc57cb6
17 changed files with 861 additions and 341 deletions

View File

@ -539,6 +539,8 @@ CREATE TABLE IF NOT EXISTS exa_sets (
SetCod INT NOT NULL AUTO_INCREMENT, SetCod INT NOT NULL AUTO_INCREMENT,
ExaCod INT NOT NULL, ExaCod INT NOT NULL,
SetInd INT NOT NULL DEFAULT 0, SetInd INT NOT NULL DEFAULT 0,
NumQstsToExam INT NOT NULL DEFAULT 0,
Title VARCHAR(2047) NOT NULL,
UNIQUE INDEX(SetCod), UNIQUE INDEX(SetCod),
INDEX(ExaCod,SetInd)); INDEX(ExaCod,SetInd));
-- --

View File

@ -717,11 +717,15 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
[ActRemExa ] = {1882,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RemoveExam ,NULL}, [ActRemExa ] = {1882,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RemoveExam ,NULL},
[ActHidExa ] = {1883,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_HideExam ,NULL}, [ActHidExa ] = {1883,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_HideExam ,NULL},
[ActShoExa ] = {1884,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_UnhideExam ,NULL}, [ActShoExa ] = {1884,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_UnhideExam ,NULL},
[ActAddOneExaSet ] = {1892,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,Exa_RequestNewSet ,NULL},
[ActReqRemExaSet ] = {1893,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RequestRemoveSet ,NULL}, [ActFrmNewExaSet ] = {1892,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,ExaSet_RequestCreatOrEditSet ,NULL},
[ActRemExaSet ] = {1894,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RemoveSet ,NULL}, [ActEdiOneExaSet ] = {1897,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_RequestCreatOrEditSet ,NULL},
[ActUp_ExaSet ] = {1895,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_MoveUpSet ,NULL}, [ActNewExaSet ] = {1898,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_RecFormSet ,NULL},
[ActDwnExaSet ] = {1896,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_MoveDownSet ,NULL}, [ActChgExaSet ] = {1899,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_RecFormSet ,NULL},
[ActReqRemExaSet ] = {1893,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_RequestRemoveSet ,NULL},
[ActRemExaSet ] = {1894,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_RemoveSet ,NULL},
[ActUp_ExaSet ] = {1895,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_MoveUpSet ,NULL},
[ActDwnExaSet ] = {1896,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_MoveDownSet ,NULL},
[ActAddOneExaQst ] = {1885,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,Exa_RequestNewQuestion ,NULL}, [ActAddOneExaQst ] = {1885,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,Exa_RequestNewQuestion ,NULL},
[ActLstTstQstForExa ] = {1886,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_ListQuestionsToSelect ,NULL}, [ActLstTstQstForExa ] = {1886,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_ListQuestionsToSelect ,NULL},
@ -3700,11 +3704,14 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActRemExaQst, // #1889 ActRemExaQst, // #1889
ActUp_ExaQst, // #1890 ActUp_ExaQst, // #1890
ActDwnExaQst, // #1891 ActDwnExaQst, // #1891
ActAddOneExaSet, // #1892 ActFrmNewExaSet, // #1892
ActReqRemExaSet, // #1893 ActReqRemExaSet, // #1893
ActRemExaSet, // #1894 ActRemExaSet, // #1894
ActUp_ExaSet, // #1895 ActUp_ExaSet, // #1895
ActDwnExaSet, // #1896 ActDwnExaSet, // #1896
ActEdiOneExaSet, // #1897
ActNewExaSet, // #1898
ActChgExaSet, // #1899
}; };
/*****************************************************************************/ /*****************************************************************************/

View File

@ -64,7 +64,7 @@ typedef enum
typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
#define Act_MAX_ACTION_COD 1896 #define Act_MAX_ACTION_COD 1899
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
@ -683,95 +683,98 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActRemExa (ActChgCrsTT1stDay + 156) #define ActRemExa (ActChgCrsTT1stDay + 156)
#define ActHidExa (ActChgCrsTT1stDay + 157) #define ActHidExa (ActChgCrsTT1stDay + 157)
#define ActShoExa (ActChgCrsTT1stDay + 158) #define ActShoExa (ActChgCrsTT1stDay + 158)
#define ActAddOneExaSet (ActChgCrsTT1stDay + 159) #define ActFrmNewExaSet (ActChgCrsTT1stDay + 159)
#define ActReqRemExaSet (ActChgCrsTT1stDay + 160) #define ActEdiOneExaSet (ActChgCrsTT1stDay + 160)
#define ActRemExaSet (ActChgCrsTT1stDay + 161) #define ActNewExaSet (ActChgCrsTT1stDay + 161)
#define ActUp_ExaSet (ActChgCrsTT1stDay + 162) #define ActChgExaSet (ActChgCrsTT1stDay + 162)
#define ActDwnExaSet (ActChgCrsTT1stDay + 163) #define ActReqRemExaSet (ActChgCrsTT1stDay + 163)
#define ActRemExaSet (ActChgCrsTT1stDay + 164)
#define ActUp_ExaSet (ActChgCrsTT1stDay + 165)
#define ActDwnExaSet (ActChgCrsTT1stDay + 166)
#define ActAddOneExaQst (ActChgCrsTT1stDay + 164) #define ActAddOneExaQst (ActChgCrsTT1stDay + 167)
#define ActLstTstQstForExa (ActChgCrsTT1stDay + 165) #define ActLstTstQstForExa (ActChgCrsTT1stDay + 168)
#define ActAddQstToExa (ActChgCrsTT1stDay + 166) #define ActAddQstToExa (ActChgCrsTT1stDay + 169)
#define ActReqRemExaQst (ActChgCrsTT1stDay + 167) #define ActReqRemExaQst (ActChgCrsTT1stDay + 170)
#define ActRemExaQst (ActChgCrsTT1stDay + 168) #define ActRemExaQst (ActChgCrsTT1stDay + 171)
#define ActUp_ExaQst (ActChgCrsTT1stDay + 169) #define ActUp_ExaQst (ActChgCrsTT1stDay + 172)
#define ActDwnExaQst (ActChgCrsTT1stDay + 170) #define ActDwnExaQst (ActChgCrsTT1stDay + 173)
#define ActSeeGam (ActChgCrsTT1stDay + 171) #define ActSeeGam (ActChgCrsTT1stDay + 174)
#define ActReqRemMch (ActChgCrsTT1stDay + 172) #define ActReqRemMch (ActChgCrsTT1stDay + 175)
#define ActRemMch (ActChgCrsTT1stDay + 173) #define ActRemMch (ActChgCrsTT1stDay + 176)
#define ActReqNewMch (ActChgCrsTT1stDay + 174) #define ActReqNewMch (ActChgCrsTT1stDay + 177)
#define ActNewMch (ActChgCrsTT1stDay + 175) #define ActNewMch (ActChgCrsTT1stDay + 178)
#define ActResMch (ActChgCrsTT1stDay + 176) #define ActResMch (ActChgCrsTT1stDay + 179)
#define ActBckMch (ActChgCrsTT1stDay + 177) #define ActBckMch (ActChgCrsTT1stDay + 180)
#define ActPlyPauMch (ActChgCrsTT1stDay + 178) #define ActPlyPauMch (ActChgCrsTT1stDay + 181)
#define ActFwdMch (ActChgCrsTT1stDay + 179) #define ActFwdMch (ActChgCrsTT1stDay + 182)
#define ActChgNumColMch (ActChgCrsTT1stDay + 180) #define ActChgNumColMch (ActChgCrsTT1stDay + 183)
#define ActChgVisResMchQst (ActChgCrsTT1stDay + 181) #define ActChgVisResMchQst (ActChgCrsTT1stDay + 184)
#define ActMchCntDwn (ActChgCrsTT1stDay + 182) #define ActMchCntDwn (ActChgCrsTT1stDay + 185)
#define ActRefMchTch (ActChgCrsTT1stDay + 183) #define ActRefMchTch (ActChgCrsTT1stDay + 186)
#define ActJoiMch (ActChgCrsTT1stDay + 184) #define ActJoiMch (ActChgCrsTT1stDay + 187)
#define ActSeeMchAnsQstStd (ActChgCrsTT1stDay + 185) #define ActSeeMchAnsQstStd (ActChgCrsTT1stDay + 188)
#define ActRemMchAnsQstStd (ActChgCrsTT1stDay + 186) #define ActRemMchAnsQstStd (ActChgCrsTT1stDay + 189)
#define ActAnsMchQstStd (ActChgCrsTT1stDay + 187) #define ActAnsMchQstStd (ActChgCrsTT1stDay + 190)
#define ActRefMchStd (ActChgCrsTT1stDay + 188) #define ActRefMchStd (ActChgCrsTT1stDay + 191)
#define ActSeeMyMchResCrs (ActChgCrsTT1stDay + 189) #define ActSeeMyMchResCrs (ActChgCrsTT1stDay + 192)
#define ActSeeMyMchResGam (ActChgCrsTT1stDay + 190) #define ActSeeMyMchResGam (ActChgCrsTT1stDay + 193)
#define ActSeeMyMchResMch (ActChgCrsTT1stDay + 191) #define ActSeeMyMchResMch (ActChgCrsTT1stDay + 194)
#define ActSeeOneMchResMe (ActChgCrsTT1stDay + 192) #define ActSeeOneMchResMe (ActChgCrsTT1stDay + 195)
#define ActReqSeeAllMchRes (ActChgCrsTT1stDay + 193) #define ActReqSeeAllMchRes (ActChgCrsTT1stDay + 196)
#define ActSeeAllMchResCrs (ActChgCrsTT1stDay + 194) #define ActSeeAllMchResCrs (ActChgCrsTT1stDay + 197)
#define ActSeeAllMchResGam (ActChgCrsTT1stDay + 195) #define ActSeeAllMchResGam (ActChgCrsTT1stDay + 198)
#define ActSeeAllMchResMch (ActChgCrsTT1stDay + 196) #define ActSeeAllMchResMch (ActChgCrsTT1stDay + 199)
#define ActSeeOneMchResOth (ActChgCrsTT1stDay + 197) #define ActSeeOneMchResOth (ActChgCrsTT1stDay + 200)
#define ActChgVisResMchUsr (ActChgCrsTT1stDay + 198) #define ActChgVisResMchUsr (ActChgCrsTT1stDay + 201)
#define ActFrmNewGam (ActChgCrsTT1stDay + 199) #define ActFrmNewGam (ActChgCrsTT1stDay + 202)
#define ActEdiOneGam (ActChgCrsTT1stDay + 200) #define ActEdiOneGam (ActChgCrsTT1stDay + 203)
#define ActNewGam (ActChgCrsTT1stDay + 201) #define ActNewGam (ActChgCrsTT1stDay + 204)
#define ActChgGam (ActChgCrsTT1stDay + 202) #define ActChgGam (ActChgCrsTT1stDay + 205)
#define ActReqRemGam (ActChgCrsTT1stDay + 203) #define ActReqRemGam (ActChgCrsTT1stDay + 206)
#define ActRemGam (ActChgCrsTT1stDay + 204) #define ActRemGam (ActChgCrsTT1stDay + 207)
#define ActHidGam (ActChgCrsTT1stDay + 205) #define ActHidGam (ActChgCrsTT1stDay + 208)
#define ActShoGam (ActChgCrsTT1stDay + 206) #define ActShoGam (ActChgCrsTT1stDay + 209)
#define ActAddOneGamQst (ActChgCrsTT1stDay + 207) #define ActAddOneGamQst (ActChgCrsTT1stDay + 210)
#define ActGamLstTstQst (ActChgCrsTT1stDay + 208) #define ActGamLstTstQst (ActChgCrsTT1stDay + 211)
#define ActAddTstQstToGam (ActChgCrsTT1stDay + 209) #define ActAddTstQstToGam (ActChgCrsTT1stDay + 212)
#define ActReqRemGamQst (ActChgCrsTT1stDay + 210) #define ActReqRemGamQst (ActChgCrsTT1stDay + 213)
#define ActRemGamQst (ActChgCrsTT1stDay + 211) #define ActRemGamQst (ActChgCrsTT1stDay + 214)
#define ActUp_GamQst (ActChgCrsTT1stDay + 212) #define ActUp_GamQst (ActChgCrsTT1stDay + 215)
#define ActDwnGamQst (ActChgCrsTT1stDay + 213) #define ActDwnGamQst (ActChgCrsTT1stDay + 216)
#define ActSeeSvy (ActChgCrsTT1stDay + 214) #define ActSeeSvy (ActChgCrsTT1stDay + 217)
#define ActAnsSvy (ActChgCrsTT1stDay + 215) #define ActAnsSvy (ActChgCrsTT1stDay + 218)
#define ActFrmNewSvy (ActChgCrsTT1stDay + 216) #define ActFrmNewSvy (ActChgCrsTT1stDay + 219)
#define ActEdiOneSvy (ActChgCrsTT1stDay + 217) #define ActEdiOneSvy (ActChgCrsTT1stDay + 220)
#define ActNewSvy (ActChgCrsTT1stDay + 218) #define ActNewSvy (ActChgCrsTT1stDay + 221)
#define ActChgSvy (ActChgCrsTT1stDay + 219) #define ActChgSvy (ActChgCrsTT1stDay + 222)
#define ActReqRemSvy (ActChgCrsTT1stDay + 220) #define ActReqRemSvy (ActChgCrsTT1stDay + 223)
#define ActRemSvy (ActChgCrsTT1stDay + 221) #define ActRemSvy (ActChgCrsTT1stDay + 224)
#define ActReqRstSvy (ActChgCrsTT1stDay + 222) #define ActReqRstSvy (ActChgCrsTT1stDay + 225)
#define ActRstSvy (ActChgCrsTT1stDay + 223) #define ActRstSvy (ActChgCrsTT1stDay + 226)
#define ActHidSvy (ActChgCrsTT1stDay + 224) #define ActHidSvy (ActChgCrsTT1stDay + 227)
#define ActShoSvy (ActChgCrsTT1stDay + 225) #define ActShoSvy (ActChgCrsTT1stDay + 228)
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 226) #define ActEdiOneSvyQst (ActChgCrsTT1stDay + 229)
#define ActRcvSvyQst (ActChgCrsTT1stDay + 227) #define ActRcvSvyQst (ActChgCrsTT1stDay + 230)
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 228) #define ActReqRemSvyQst (ActChgCrsTT1stDay + 231)
#define ActRemSvyQst (ActChgCrsTT1stDay + 229) #define ActRemSvyQst (ActChgCrsTT1stDay + 232)
#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 230) #define ActSeeOneExaAnn (ActChgCrsTT1stDay + 233)
#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 231) #define ActSeeDatExaAnn (ActChgCrsTT1stDay + 234)
#define ActEdiExaAnn (ActChgCrsTT1stDay + 232) #define ActEdiExaAnn (ActChgCrsTT1stDay + 235)
#define ActRcvExaAnn (ActChgCrsTT1stDay + 233) #define ActRcvExaAnn (ActChgCrsTT1stDay + 236)
#define ActPrnExaAnn (ActChgCrsTT1stDay + 234) #define ActPrnExaAnn (ActChgCrsTT1stDay + 237)
#define ActReqRemExaAnn (ActChgCrsTT1stDay + 235) #define ActReqRemExaAnn (ActChgCrsTT1stDay + 238)
#define ActRemExaAnn (ActChgCrsTT1stDay + 236) #define ActRemExaAnn (ActChgCrsTT1stDay + 239)
#define ActHidExaAnn (ActChgCrsTT1stDay + 237) #define ActHidExaAnn (ActChgCrsTT1stDay + 240)
#define ActShoExaAnn (ActChgCrsTT1stDay + 238) #define ActShoExaAnn (ActChgCrsTT1stDay + 241)
/*****************************************************************************/ /*****************************************************************************/
/******************************** Files tab **********************************/ /******************************** Files tab **********************************/

View File

@ -544,11 +544,18 @@ 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.194 (2020-04-24)" #define Log_PLATFORM_VERSION "SWAD 19.195 (2020-04-25)"
#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.194: Apr 24, 2020 New database table for question sets in exams. (298257 lines)
Version 19.195: Apr 25, 2020 Changes in sets of questions. (298699 lines)
2 changes necessary in database:
ALTER TABLE exa_sets ADD COLUMN NumQstsToExam INT NOT NULL DEFAULT 0 AFTER SetInd;
ALTER TABLE exa_sets ADD COLUMN Title VARCHAR(2047) NOT NULL AFTER NumQstsToExam;
Version 19.194.1: Apr 24, 2020 Translate messages related to sets of questions. (? lines)
Version 19.194: Apr 24, 2020 New database table for set of questions in exams. (298257 lines)
1 change necessary in database: 1 change necessary in database:
CREATE TABLE IF NOT EXISTS exa_sets (SetCod INT NOT NULL AUTO_INCREMENT,ExaCod INT NOT NULL,SetInd INT NOT NULL DEFAULT 0,UNIQUE INDEX(SetCod),INDEX(ExaCod,SetInd)); CREATE TABLE IF NOT EXISTS exa_sets (SetCod INT NOT NULL AUTO_INCREMENT,ExaCod INT NOT NULL,SetInd INT NOT NULL DEFAULT 0,UNIQUE INDEX(SetCod),INDEX(ExaCod,SetInd));

View File

@ -1185,19 +1185,23 @@ mysql> DESCRIBE exa_results;
/***** Table exa_sets *****/ /***** Table exa_sets *****/
/* /*
mysql> DESCRIBE exa_sets; mysql> DESCRIBE exa_sets;
+--------+---------+------+-----+---------+-------+ +---------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+ +---------------+---------------+------+-----+---------+----------------+
| SetCod | int(11) | NO | PRI | NULL | auto_increment |
| ExaCod | int(11) | NO | MUL | NULL | | | ExaCod | int(11) | NO | MUL | NULL | |
| QstCod | int(11) | NO | MUL | NULL | | | SetInd | int(11) | NO | | 0 | |
| QstInd | int(11) | NO | | 0 | | | NumQstsToExam | int(11) | NO | | 0 | |
+--------+---------+------+-----+---------+-------+ | Title | varchar(2047) | NO | | NULL | |
3 rows in set (0.01 sec) +---------------+---------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_sets (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS exa_sets ("
"SetCod INT NOT NULL AUTO_INCREMENT," "SetCod INT NOT NULL AUTO_INCREMENT,"
"ExaCod INT NOT NULL," "ExaCod INT NOT NULL,"
"SetInd INT NOT NULL DEFAULT 0," "SetInd INT NOT NULL DEFAULT 0,"
"NumQstsToExam INT NOT NULL DEFAULT 0,"
"Title VARCHAR(2047) NOT NULL," // ExaSet_MAX_BYTES_TITLE
"UNIQUE INDEX(SetCod)," "UNIQUE INDEX(SetCod),"
"INDEX(ExaCod,SetInd))"); "INDEX(ExaCod,SetInd))");

View File

@ -139,8 +139,16 @@ static void Exa_GetExamTxtFromDB (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
static void Exa_RemoveExamFromAllTables (long ExaCod); static void Exa_RemoveExamFromAllTables (long ExaCod);
static bool ExaSet_CheckIfSimilarSetExists (const struct ExaSet_Set *Set);
static bool Exa_CheckIfSimilarExamExists (const struct Exa_Exam *Exam); static bool Exa_CheckIfSimilarExamExists (const struct Exa_Exam *Exam);
static void ExaSet_PutFormsEditionSet (struct Exa_Exams *Exams,
struct Exa_Exam *Exam,
struct ExaSet_Set *Set,
bool ItsANewSet);
static void ExaSet_ReceiveSetFieldsFromForm (struct ExaSet_Set *Set);
static bool ExaSet_CheckSetFieldsReceivedFromForm (const struct ExaSet_Set *Set);
static void Exa_PutFormsEditionExam (struct Exa_Exams *Exams, static void Exa_PutFormsEditionExam (struct Exa_Exams *Exams,
struct Exa_Exam *Exam, struct Exa_Exam *Exam,
char Txt[Cns_MAX_BYTES_TEXT + 1], char Txt[Cns_MAX_BYTES_TEXT + 1],
@ -149,6 +157,9 @@ static void Exa_ReceiveExamFieldsFromForm (struct Exa_Exam *Exam,
char Txt[Cns_MAX_BYTES_TEXT + 1]); char Txt[Cns_MAX_BYTES_TEXT + 1]);
static bool Exa_CheckExamFieldsReceivedFromForm (const struct Exa_Exam *Exam); static bool Exa_CheckExamFieldsReceivedFromForm (const struct Exa_Exam *Exam);
static void ExaSet_CreateSet (struct ExaSet_Set *Set);
static void ExaSet_UpdateSet (struct ExaSet_Set *Set);
static void Exa_CreateExam (struct Exa_Exam *Exam,const char *Txt); static void Exa_CreateExam (struct Exa_Exam *Exam,const char *Txt);
static void Exa_UpdateExam (struct Exa_Exam *Exam,const char *Txt); static void Exa_UpdateExam (struct Exa_Exam *Exam,const char *Txt);
@ -158,12 +169,11 @@ static unsigned Exa_GetMaxSetIndexInExam (long ExaCod);
static unsigned Exa_GetMaxQuestionIndexInExam (long ExaCod); static unsigned Exa_GetMaxQuestionIndexInExam (long ExaCod);
static void Exa_ListExamSets (struct Exa_Exams *Exams,struct Exa_Exam *Exam); static void Exa_ListExamSets (struct Exa_Exams *Exams,struct Exa_Exam *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);
static void Exa_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
long ExaCod,unsigned NumSets, long ExaCod,unsigned NumSets,
MYSQL_RES *mysql_res, MYSQL_RES *mysql_res,
bool ICanEditSets); bool ICanEditSets);
static void Exa_SetConstructor (struct Exa_Set *Set); static void ExaSet_ResetSet (struct ExaSet_Set *Set);
static void Exa_SetDestructor (struct Exa_Set *Set);
static void Exa_PutParamSetCod (void *SetCod); static void Exa_PutParamSetCod (void *SetCod);
static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
long ExaCod,unsigned NumQsts, long ExaCod,unsigned NumQsts,
@ -238,7 +248,7 @@ void Exa_SeeAllExams (void)
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
/***** Get parameters *****/ /***** Get parameters *****/
Exa_GetParams (&Exams); // Return value ignored Exa_GetParams (&Exams);
/***** Show all exams *****/ /***** Show all exams *****/
Exa_ListAllExams (&Exams); Exa_ListAllExams (&Exams);
@ -460,8 +470,12 @@ void Exa_SeeOneExam (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Show exam *****/ /***** Show exam *****/
@ -750,7 +764,7 @@ static void Exa_PutFormsToRemEditOneExam (struct Exa_Exams *Exams,
} }
/*****************************************************************************/ /*****************************************************************************/
/************** Put parameter to move/remove one question set ****************/ /************** Put parameter to move/remove one set of questions ****************/
/*****************************************************************************/ /*****************************************************************************/
static void Exa_PutParamsOneSet (void *Exams) static void Exa_PutParamsOneSet (void *Exams)
@ -813,18 +827,28 @@ long Exa_GetParamExamCod (void)
return Par_GetParToLong ("ExaCod"); return Par_GetParToLong ("ExaCod");
} }
/*****************************************************************************/
/********************** Get parameter with code of set ***********************/
/*****************************************************************************/
long ExaSet_GetParamSetCod (void)
{
/***** Get code of set *****/
return Par_GetParToLong ("SetCod");
}
/*****************************************************************************/ /*****************************************************************************/
/******************* Get parameters used to edit an exam **********************/ /******************* Get parameters used to edit an exam **********************/
/*****************************************************************************/ /*****************************************************************************/
long Exa_GetParams (struct Exa_Exams *Exams) void Exa_GetParams (struct Exa_Exams *Exams)
{ {
/***** Get other parameters *****/ /***** Get other parameters *****/
Exams->SelectedOrder = Exa_GetParamOrder (); Exams->SelectedOrder = Exa_GetParamOrder ();
Exams->CurrentPage = Pag_GetParamPagNum (Pag_EXAMS); Exams->CurrentPage = Pag_GetParamPagNum (Pag_EXAMS);
/***** Get exam code *****/ /***** Get exam code *****/
return Exa_GetParamExamCod (); Exams->ExaCod = Exa_GetParamExamCod ();
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1001,6 +1025,39 @@ void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams)
} }
} }
/*****************************************************************************/
/*********************** Get set data using its code *************************/
/*****************************************************************************/
void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
/***** Get data of set from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get set data",
"SELECT SetInd" // row[0]
" FROM exa_sets"
" WHERE SetCod=%ld"
" AND ExaCod=%ld", // Extra check
Set->SetCod,Set->ExaCod);
if (NumRows) // Set found...
{
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get index of the set (row[0]) */
Set->SetInd = Str_ConvertStrToUnsigned (row[0]);
}
else
/* Initialize to empty set */
ExaSet_ResetSet (Set);
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/ /*****************************************************************************/
/********************** Get exam data using its code *************************/ /********************** Get exam data using its code *************************/
/*****************************************************************************/ /*****************************************************************************/
@ -1161,6 +1218,10 @@ void Exa_AskRemExam (void)
struct Exa_Exams Exams; struct Exa_Exams Exams;
struct Exa_Exam Exam; struct Exa_Exam Exam;
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
@ -1168,13 +1229,13 @@ void Exa_AskRemExam (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of the exam from database *****/ /***** Get data of the exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Show question and button to remove exam *****/ /***** Show question and button to remove exam *****/
Exams.ExaCod = Exam.ExaCod; Exams.ExaCod = Exam.ExaCod;
@ -1198,6 +1259,10 @@ void Exa_RemoveExam (void)
struct Exa_Exams Exams; struct Exa_Exams Exams;
struct Exa_Exam Exam; struct Exa_Exam Exam;
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
@ -1210,8 +1275,6 @@ void Exa_RemoveExam (void)
/***** Get data of the exam from database *****/ /***** Get data of the exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Remove exam from all tables *****/ /***** Remove exam from all tables *****/
Exa_RemoveExamFromAllTables (Exam.ExaCod); Exa_RemoveExamFromAllTables (Exam.ExaCod);
@ -1277,6 +1340,10 @@ void Exa_HideExam (void)
struct Exa_Exams Exams; struct Exa_Exams Exams;
struct Exa_Exam Exam; struct Exa_Exam Exam;
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
@ -1284,13 +1351,13 @@ void Exa_HideExam (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of the exam from database *****/ /***** Get data of the exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Hide exam *****/ /***** Hide exam *****/
DB_QueryUPDATE ("can not hide exam", DB_QueryUPDATE ("can not hide exam",
@ -1310,6 +1377,10 @@ void Exa_UnhideExam (void)
struct Exa_Exams Exams; struct Exa_Exams Exams;
struct Exa_Exam Exam; struct Exa_Exam Exam;
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
@ -1317,13 +1388,13 @@ void Exa_UnhideExam (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of the exam from database *****/ /***** Get data of the exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Show exam *****/ /***** Show exam *****/
DB_QueryUPDATE ("can not show exam", DB_QueryUPDATE ("can not show exam",
@ -1334,6 +1405,24 @@ void Exa_UnhideExam (void)
Exa_ListAllExams (&Exams); Exa_ListAllExams (&Exams);
} }
/*****************************************************************************/
/************** Check if the title of a set of questions exists **************/
/*****************************************************************************/
static bool ExaSet_CheckIfSimilarSetExists (const struct ExaSet_Set *Set)
{
/***** Get number of set of questions with a field value from database *****/
return (DB_QueryCOUNT ("can not get similar sets of questions",
"SELECT COUNT(*) FROM exa_sets,exa_exams"
" WHERE exa_sets.ExaCod=%ld AND exa_sets.Title='%s'"
" AND exa_sets.SetCod<>%ld"
" AND exa_sets.ExaCod=exa_exams.ExaCod"
" AND exa_exams.CrsCod=%ld", // Extra check
Set->ExaCod,Set->Title,
Set->SetCod,
Gbl.Hierarchy.Crs.CrsCod) != 0);
}
/*****************************************************************************/ /*****************************************************************************/
/******************* Check if the title of an exam exists *******************/ /******************* Check if the title of an exam exists *******************/
/*****************************************************************************/ /*****************************************************************************/
@ -1360,18 +1449,22 @@ void Exa_RequestCreatOrEditExam (void)
bool ItsANewExam; bool ItsANewExam;
char Txt[Cns_MAX_BYTES_TEXT + 1]; char Txt[Cns_MAX_BYTES_TEXT + 1];
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
/***** Reset exam *****/ /***** Reset exam *****/
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Get parameters *****/ /***** Get parameters *****/
ItsANewExam = ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0); Exa_GetParams (&Exams);
if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
ItsANewExam = (Exam.ExaCod <= 0);
/***** Get exam data *****/ /***** Get exam data *****/
if (ItsANewExam) if (ItsANewExam)
@ -1408,6 +1501,183 @@ void Exa_RequestCreatOrEditExam (void)
/********************* Put a form to create/edit an exam **********************/ /********************* Put a form to create/edit an exam **********************/
/*****************************************************************************/ /*****************************************************************************/
static void ExaSet_PutFormsEditionSet (struct Exa_Exams *Exams,
struct Exa_Exam *Exam,
struct ExaSet_Set *Set,
bool ItsANewSet)
{
// extern const char *Hlp_ASSESSMENT_Exams_new_set;
// extern const char *Hlp_ASSESSMENT_Exams_edit_set;
extern const char *The_ClassFormInBox[The_NUM_THEMES];
extern const char *Txt_New_set;
extern const char *Txt_Edit_set;
extern const char *Txt_Title;
extern const char *Txt_Number_of_questions_in_this_set_that_will_appear_in_the_exam;
extern const char *Txt_Create_set;
extern const char *Txt_Save_changes;
/***** Begin form *****/
Exams->ExaCod = Exam->ExaCod;
Frm_StartForm (ItsANewSet ? ActNewExaSet :
ActChgExaSet);
Exa_PutParams (Exams);
/***** Begin box and table *****/
if (ItsANewSet)
Box_BoxTableBegin (NULL,Txt_New_set,
NULL,NULL,
NULL,Box_NOT_CLOSABLE,2);
else
Box_BoxTableBegin (NULL,
Exam->Title[0] ? Exam->Title :
Txt_Edit_set,
NULL,NULL,
NULL,Box_NOT_CLOSABLE,2);
/***** Set title *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT","Title",Txt_Title);
/* Data */
HTM_TD_Begin ("class=\"LT\"");
HTM_INPUT_TEXT ("Title",ExaSet_MAX_CHARS_TITLE,Set->Title,false,
"id=\"Title\" required=\"required\""
" class=\"TITLE_DESCRIPTION_WIDTH\"");
HTM_TD_End ();
HTM_TR_End ();
/***** Number of questions in this set that will appear in the exam *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"%s RM\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
HTM_TxtF ("%s:",Txt_Number_of_questions_in_this_set_that_will_appear_in_the_exam);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LM\"");
HTM_INPUT_LONG ("NumQstsToExam",0,UINT_MAX,Set->NumQstsToExam,false,
"required=\"required\"");
HTM_TD_End ();
HTM_TR_End ();
/***** End table, send button and end box *****/
if (ItsANewSet)
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_set);
else
Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes);
/***** End form *****/
Frm_EndForm ();
}
/*****************************************************************************/
/**************** Receive form to create a new set of questions **************/
/*****************************************************************************/
void ExaSet_RecFormSet (void)
{
struct Exa_Exams Exams;
struct Exa_Exam Exam;
struct ExaSet_Set Set;
bool ItsANewSet;
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/
Exa_ResetExams (&Exams);
/***** Reset exam and set *****/
Exa_ResetExam (&Exam);
ExaSet_ResetSet (&Set);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
Set.SetCod = ExaSet_GetParamSetCod ();
ItsANewSet = (Exam.ExaCod <= 0);
/***** If I can edit exams ==> receive set from form *****/
ExaSet_ReceiveSetFieldsFromForm (&Set);
if (ExaSet_CheckSetFieldsReceivedFromForm (&Set))
{
/***** Create a new exam or update an existing one *****/
if (ItsANewSet)
ExaSet_CreateSet (&Set); // Add new set to database
else
ExaSet_UpdateSet (&Set); // Update set data in database
/***** Put forms to edit the set created or updated *****/
ExaSet_PutFormsEditionSet (&Exams,&Exam,&Set,
false); // No new set
/***** Show questions of the exam ready to be edited ******/
Exa_ListExamQuestions (&Exams,&Exam);
}
else
{
/***** Put forms to create/edit the set *****/
ExaSet_PutFormsEditionSet (&Exams,&Exam,&Set,ItsANewSet);
/***** Show exams or questions *****/
if (ItsANewSet)
/* Show exams again */
Exa_ListAllExams (&Exams);
else
/* Show questions of the exam ready to be edited */
Exa_ListExamQuestions (&Exams,&Exam);
}
}
static void ExaSet_ReceiveSetFieldsFromForm (struct ExaSet_Set *Set)
{
/***** Get set title *****/
Par_GetParToText ("Title",Set->Title,ExaSet_MAX_BYTES_TITLE);
/***** Get number of questions in set to appear in exam *****/
Set->NumQstsToExam = (unsigned) Par_GetParToUnsignedLong ("NumQstsToExam",
0,
UINT_MAX,
0);
}
static bool ExaSet_CheckSetFieldsReceivedFromForm (const struct ExaSet_Set *Set)
{
extern const char *Txt_Already_existed_a_set_of_questions_in_this_exam_with_the_title_X;
extern const char *Txt_You_must_specify_the_title_of_the_set_of_questions;
bool NewSetIsCorrect;
/***** Check if title is correct *****/
NewSetIsCorrect = true;
if (Set->Title[0]) // If there's an set title
{
/* If title of set was in database... */
if (ExaSet_CheckIfSimilarSetExists (Set))
{
NewSetIsCorrect = false;
Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_a_set_of_questions_in_this_exam_with_the_title_X,
Set->Title);
}
}
else // If there is not a set title
{
NewSetIsCorrect = false;
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_set_of_questions);
}
return NewSetIsCorrect;
}
/*****************************************************************************/
/********************* Put a form to create/edit an exam **********************/
/*****************************************************************************/
static void Exa_PutFormsEditionExam (struct Exa_Exams *Exams, static void Exa_PutFormsEditionExam (struct Exa_Exams *Exams,
struct Exa_Exam *Exam, struct Exa_Exam *Exam,
char Txt[Cns_MAX_BYTES_TEXT + 1], char Txt[Cns_MAX_BYTES_TEXT + 1],
@ -1522,22 +1792,24 @@ void Exa_RecFormExam (void)
bool ItsANewExam; bool ItsANewExam;
char Txt[Cns_MAX_BYTES_TEXT + 1]; char Txt[Cns_MAX_BYTES_TEXT + 1];
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
/***** Reset exam *****/ /***** Reset exam *****/
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Get parameters *****/ /***** Get parameters *****/
ItsANewExam = ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0); Exa_GetParams (&Exams);
if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
ItsANewExam = (Exam.ExaCod <= 0);
/***** If I can edit exams ==> receive exam from form *****/ /***** If I can edit exams ==> receive exam from form *****/
if (Exa_CheckIfICanEditExams ())
{
Exa_ReceiveExamFieldsFromForm (&Exam,Txt); Exa_ReceiveExamFieldsFromForm (&Exam,Txt);
if (Exa_CheckExamFieldsReceivedFromForm (&Exam)) if (Exa_CheckExamFieldsReceivedFromForm (&Exam))
{ {
@ -1568,9 +1840,6 @@ void Exa_RecFormExam (void)
Exa_ListExamQuestions (&Exams,&Exam); Exa_ListExamQuestions (&Exams,&Exam);
} }
} }
else
Lay_NoPermissionExit ();
}
static void Exa_ReceiveExamFieldsFromForm (struct Exa_Exam *Exam, static void Exa_ReceiveExamFieldsFromForm (struct Exa_Exam *Exam,
char Txt[Cns_MAX_BYTES_TEXT + 1]) char Txt[Cns_MAX_BYTES_TEXT + 1])
@ -1620,6 +1889,57 @@ static bool Exa_CheckExamFieldsReceivedFromForm (const struct Exa_Exam *Exam)
return NewExamIsCorrect; return NewExamIsCorrect;
} }
/*****************************************************************************/
/********************** Create a new set of questions ************************/
/*****************************************************************************/
static void ExaSet_CreateSet (struct ExaSet_Set *Set)
{
extern const char *Txt_Created_new_set_of_questions_X;
/***** Create a new exam *****/
Set->SetCod =
DB_QueryINSERTandReturnCode ("can not create new set of questions",
"INSERT INTO exa_sets"
" (ExaCod,SetInd,NumQstsToExam,Title)"
" VALUES"
" (%ld,'N',%ld,%.15lg,%u,'%s','%s')",
Set->ExaCod,
Set->SetInd,
Set->NumQstsToExam,
Set->Title);
/***** Write success message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_set_of_questions_X,
Set->Title);
}
/*****************************************************************************/
/******************** Update an existing set of questions ********************/
/*****************************************************************************/
static void ExaSet_UpdateSet (struct ExaSet_Set *Set)
{
extern const char *Txt_The_set_of_questions_has_been_modified;
/***** Update the data of the set of questions *****/
DB_QueryUPDATE ("can not update set of questions",
"UPDATE exa_exams"
" SET ExaCod=%ld,"
"SetInd=%u,"
"NumQstsToExam=%u,"
"Title='%s'"
" WHERE SetCod=%ld",
Set->ExaCod,
Set->SetInd,
Set->NumQstsToExam,
Set->Title,
Set->SetCod);
/***** Write success message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_The_set_of_questions_has_been_modified);
}
/*****************************************************************************/ /*****************************************************************************/
/**************************** Create a new exam ******************************/ /**************************** Create a new exam ******************************/
/*****************************************************************************/ /*****************************************************************************/
@ -1694,13 +2014,19 @@ unsigned Exa_GetNumQstsExam (long ExaCod)
} }
/*****************************************************************************/ /*****************************************************************************/
/************* Put a form to edit/create a question set in exam **************/ /************ Request the creation or edition of an set of questions *************/
/*****************************************************************************/ /*****************************************************************************/
void Exa_RequestNewSet (void) void ExaSet_RequestCreatOrEditSet (void)
{ {
struct Exa_Exams Exams; struct Exa_Exams Exams;
struct Exa_Exam Exam; struct Exa_Exam Exam;
struct ExaSet_Set Set;
bool ItsANewSet;
/***** Check if I can edit exams *****/
if (!Exa_CheckIfICanEditExams ())
Lay_NoPermissionExit ();
/***** Reset exams context *****/ /***** Reset exams context *****/
Exa_ResetExams (&Exams); Exa_ResetExams (&Exams);
@ -1708,26 +2034,45 @@ void Exa_RequestNewSet (void)
/***** Reset exam *****/ /***** Reset exam *****/
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Create set of questions *****/
ExaSet_ResetSet (&Set);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
ItsANewSet = ((Set.SetCod = ExaSet_GetParamSetCod ()) <= 0);
Lay_ShowErrorAndExit ("Wrong set.");
/***** Get exam data *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Get set data *****/
if (Exa_CheckIfEditable (&Exam)) if (ItsANewSet)
{ /* Initialize to empty set */
/***** Show form to create a new question in this exam *****/ ExaSet_ResetSet (&Set);
Exams.ExaCod = Exam.ExaCod;
Tst_RequestSelectTestsForExam (&Exams);
}
else else
Lay_NoPermissionExit (); /* Get set data from database */
ExaSet_GetDataOfSetByCod (&Set);
/***** Show current exam *****/ /***** Put forms to create/edit a set *****/
Exa_ShowOnlyOneExam (&Exams,&Exam, ExaSet_PutFormsEditionSet (&Exams,&Exam,&Set,ItsANewSet);
true, // List exam questions
false); // Do not put form to start new event /***** Show exams or questions *****/
if (ItsANewSet)
/* Show exams again */
Exa_ListAllExams (&Exams);
else
{
/* Show sets of the exam ready to be edited */
Exa_ListExamSets (&Exams,&Exam);
/* Show questions of the exam ready to be edited */
Exa_ListExamQuestions (&Exams,&Exam);
} }
}
/*****************************************************************************/ /*****************************************************************************/
/*************** Put a form to edit/create a question in exam ****************/ /*************** Put a form to edit/create a question in exam ****************/
@ -1745,8 +2090,12 @@ void Exa_RequestNewQuestion (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Check if exam has events *****/
@ -1781,8 +2130,12 @@ void Exa_ListQuestionsToSelect (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Check if exam has events *****/
@ -1797,7 +2150,7 @@ void Exa_ListQuestionsToSelect (void)
} }
/*****************************************************************************/ /*****************************************************************************/
/**************** Write parameter with index of question set *****************/ /**************** Write parameter with index of set of questions *****************/
/*****************************************************************************/ /*****************************************************************************/
void Exa_PutParamSetInd (unsigned SetInd) void Exa_PutParamSetInd (unsigned SetInd)
@ -2006,15 +2359,15 @@ unsigned Exa_GetNextQuestionIndexInExam (long ExaCod,unsigned QstInd)
static void Exa_ListExamSets (struct Exa_Exams *Exams,struct Exa_Exam *Exam) static void Exa_ListExamSets (struct Exa_Exams *Exams,struct Exa_Exam *Exam)
{ {
extern const char *Hlp_ASSESSMENT_Exams_question_sets; extern const char *Hlp_ASSESSMENT_Exams_question_sets;
extern const char *Txt_Question_sets; extern const char *Txt_Sets_of_questions;
extern const char *Txt_This_exam_has_no_question_sets; extern const char *Txt_This_exam_has_no_sets_of_questions;
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
unsigned NumSets; unsigned NumSets;
bool ICanEditSets = Exa_CheckIfEditable (Exam); bool ICanEditSets = Exa_CheckIfEditable (Exam);
/***** Get data of question sets from database *****/ /***** Get data of set of questionss from database *****/
NumSets = (unsigned) NumSets = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get exam question sets", DB_QuerySELECT (&mysql_res,"can not get exam set of questionss",
"SELECT SetInd," // row[0] "SELECT SetInd," // row[0]
"SetCod" // row[1] "SetCod" // row[1]
" FROM exa_sets" " FROM exa_sets"
@ -2025,24 +2378,24 @@ static void Exa_ListExamSets (struct Exa_Exams *Exams,struct Exa_Exam *Exam)
/***** Begin box *****/ /***** Begin box *****/
Exams->ExaCod = Exam->ExaCod; Exams->ExaCod = Exam->ExaCod;
if (ICanEditSets) if (ICanEditSets)
Box_BoxBegin (NULL,Txt_Question_sets, Box_BoxBegin (NULL,Txt_Sets_of_questions,
Exa_PutIconToAddNewSets,Exams, Exa_PutIconToAddNewSets,Exams,
Hlp_ASSESSMENT_Exams_question_sets,Box_NOT_CLOSABLE); Hlp_ASSESSMENT_Exams_question_sets,Box_NOT_CLOSABLE);
else else
Box_BoxBegin (NULL,Txt_Question_sets, Box_BoxBegin (NULL,Txt_Sets_of_questions,
NULL,NULL, NULL,NULL,
Hlp_ASSESSMENT_Exams_question_sets,Box_NOT_CLOSABLE); Hlp_ASSESSMENT_Exams_question_sets,Box_NOT_CLOSABLE);
/***** Show table with sets *****/ /***** Show table with sets *****/
if (NumSets) if (NumSets)
Exa_ListOneOrMoreSetsForEdition (Exams, ExaSet_ListOneOrMoreSetsForEdition (Exams,
Exam->ExaCod,NumSets,mysql_res, Exam->ExaCod,NumSets,mysql_res,
ICanEditSets); ICanEditSets);
else // This exam has no sets else // This exam has no sets
Ale_ShowAlert (Ale_INFO,Txt_This_exam_has_no_question_sets); Ale_ShowAlert (Ale_INFO,Txt_This_exam_has_no_sets_of_questions);
/***** Put button to add a new set in this exam *****/ /***** Put button to add a new set in this exam *****/
if (ICanEditSets) // I can edit question sets if (ICanEditSets) // I can edit set of questionss
Exa_PutButtonToAddNewSet (Exams); Exa_PutButtonToAddNewSet (Exams);
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -2109,22 +2462,22 @@ static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam
/************************* List exam sets for edition ************************/ /************************* List exam sets for edition ************************/
/*****************************************************************************/ /*****************************************************************************/
static void Exa_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
long ExaCod,unsigned NumSets, long ExaCod,unsigned NumSets,
MYSQL_RES *mysql_res, MYSQL_RES *mysql_res,
bool ICanEditSets) bool ICanEditSets)
{ {
extern const char *Txt_Question_sets; extern const char *Txt_Sets_of_questions;
extern const char *Txt_No_INDEX; extern const char *Txt_No_INDEX;
extern const char *Txt_Code; extern const char *Txt_Code;
extern const char *Txt_Tags; extern const char *Txt_Tags;
extern const char *Txt_Question_set; extern const char *Txt_Set_of_questions;
extern const char *Txt_Move_up_X; extern const char *Txt_Move_up_X;
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; MYSQL_ROW row;
struct Exa_Set Set; struct ExaSet_Set Set;
unsigned SetInd; unsigned SetInd;
unsigned MaxSetInd; unsigned MaxSetInd;
char StrSetInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; char StrSetInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
@ -2142,7 +2495,7 @@ static void Exa_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
HTM_TH (1,1,"CT",Txt_No_INDEX); HTM_TH (1,1,"CT",Txt_No_INDEX);
HTM_TH (1,1,"CT",Txt_Code); HTM_TH (1,1,"CT",Txt_Code);
HTM_TH (1,1,"CT",Txt_Tags); HTM_TH (1,1,"CT",Txt_Tags);
HTM_TH (1,1,"CT",Txt_Question_set); HTM_TH (1,1,"CT",Txt_Set_of_questions);
HTM_TR_End (); HTM_TR_End ();
@ -2153,8 +2506,8 @@ static void Exa_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
{ {
Gbl.RowEvenOdd = NumSet % 2; Gbl.RowEvenOdd = NumSet % 2;
/***** Create question set *****/ /***** Create set of questions *****/
Exa_SetConstructor (&Set); ExaSet_ResetSet (&Set);
/***** Get set data *****/ /***** Get set data *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -2231,9 +2584,6 @@ static void Exa_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
// Exa_ListSetForEdition (&Set,SetInd,SetExists); // Exa_ListSetForEdition (&Set,SetInd,SetExists);
HTM_TR_End (); HTM_TR_End ();
/***** Destroy question set *****/
Exa_SetDestructor (&Set);
} }
/***** End table *****/ /***** End table *****/
@ -2244,18 +2594,13 @@ static void Exa_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
/************************** Question set constructor *************************/ /************************** Question set constructor *************************/
/*****************************************************************************/ /*****************************************************************************/
static void Exa_SetConstructor (struct Exa_Set *Set) static void ExaSet_ResetSet (struct ExaSet_Set *Set)
{ {
Set->ExaCod = -1L;
Set->SetCod = -1L; Set->SetCod = -1L;
} Set->SetInd = 0;
Set->Title[0] = '\0';
/*****************************************************************************/ Set->NumQstsToExam = 0;
/*************************** Question set destructor *************************/
/*****************************************************************************/
static void Exa_SetDestructor (struct Exa_Set *Set)
{
Set->SetCod = -1L; // TODO: Remove
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2458,17 +2803,17 @@ static void Exa_ListQuestionForEdition (const struct Tst_Question *Question,
} }
/*****************************************************************************/ /*****************************************************************************/
/*************** Put icon to add a new question set to exam ******************/ /*************** Put icon to add a new set of questions to exam ******************/
/*****************************************************************************/ /*****************************************************************************/
static void Exa_PutIconToAddNewSets (void *Exams) static void Exa_PutIconToAddNewSets (void *Exams)
{ {
extern const char *Txt_Add_question_set; extern const char *Txt_New_set_of_questions;
/***** Put form to create a new question set *****/ /***** Put form to create a new set of questions *****/
Ico_PutContextualIconToAdd (ActAddOneExaSet,NULL, Ico_PutContextualIconToAdd (ActFrmNewExaSet,NULL,
Exa_PutParams,Exams, Exa_PutParams,Exams,
Txt_Add_question_set); Txt_New_set_of_questions);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2486,16 +2831,16 @@ static void Exa_PutIconToAddNewQuestions (void *Exams)
} }
/*****************************************************************************/ /*****************************************************************************/
/*************** Put button to add new question set to exam ******************/ /*************** Put button to add new set of questions to exam ******************/
/*****************************************************************************/ /*****************************************************************************/
static void Exa_PutButtonToAddNewSet (struct Exa_Exams *Exams) static void Exa_PutButtonToAddNewSet (struct Exa_Exams *Exams)
{ {
extern const char *Txt_Add_question_set; extern const char *Txt_New_set_of_questions;
Frm_StartForm (ActAddOneExaSet); Frm_StartForm (ActFrmNewExaSet);
Exa_PutParams (Exams); Exa_PutParams (Exams);
Btn_PutConfirmButton (Txt_Add_question_set); Btn_PutConfirmButton (Txt_New_set_of_questions);
Frm_EndForm (); Frm_EndForm ();
} }
@ -2534,8 +2879,12 @@ void Exa_AddQuestionsToExam (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Check if exam has events *****/
@ -2639,35 +2988,35 @@ static unsigned Exa_CountNumQuestionsInList (const struct Exa_Exams *Exams)
} }
/*****************************************************************************/ /*****************************************************************************/
/******************* Request the removal of a question set *******************/ /***************** Request the removal of a set of questions *****************/
/*****************************************************************************/ /*****************************************************************************/
void Exa_RequestRemoveSet (void) void ExaSet_RequestRemoveSet (void)
{ {
} }
/*****************************************************************************/ /*****************************************************************************/
/*************************** Remove a question set ***************************/ /************************* Remove a set of questions *************************/
/*****************************************************************************/ /*****************************************************************************/
void Exa_RemoveSet (void) void ExaSet_RemoveSet (void)
{ {
} }
/*****************************************************************************/ /*****************************************************************************/
/************** Move up position of a question set in an exam ****************/ /************ Move up position of a set of questions in an exam **************/
/*****************************************************************************/ /*****************************************************************************/
void Exa_MoveUpSet (void) void ExaSet_MoveUpSet (void)
{ {
} }
/*****************************************************************************/ /*****************************************************************************/
/************* Move down position of a question set in an exam ***************/ /*********** Move down position of a set of questions in an exam *************/
/*****************************************************************************/ /*****************************************************************************/
void Exa_MoveDownSet (void) void ExaSet_MoveDownSet (void)
{ {
} }
@ -2690,8 +3039,12 @@ void Exa_RequestRemoveQst (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Check if exam has events *****/
@ -2736,8 +3089,12 @@ void Exa_RemoveQst (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Check if exam has events *****/
@ -2803,8 +3160,12 @@ void Exa_MoveUpQst (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Check if exam has events *****/
@ -2861,8 +3222,12 @@ void Exa_MoveDownQst (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/ /***** Check if exam has events *****/
@ -3001,8 +3366,12 @@ void Exa_RequestNewEvent (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Show exam *****/ /***** Show exam *****/

View File

@ -38,6 +38,9 @@
#define Exa_MAX_CHARS_TITLE (128 - 1) // 127 #define Exa_MAX_CHARS_TITLE (128 - 1) // 127
#define Exa_MAX_BYTES_TITLE ((Exa_MAX_CHARS_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Exa_MAX_BYTES_TITLE ((Exa_MAX_CHARS_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
#define ExaSet_MAX_CHARS_TITLE (128 - 1) // 127
#define ExaSet_MAX_BYTES_TITLE ((ExaSet_MAX_CHARS_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
#define Exa_NUM_ORDERS 3 #define Exa_NUM_ORDERS 3
typedef enum typedef enum
{ {
@ -61,6 +64,7 @@ struct Exa_ExamSelected
bool Selected; // Is this exam selected when seeing match results? bool Selected; // Is this exam selected when seeing match results?
}; };
/* Exams context */
struct Exa_Exams struct Exa_Exams
{ {
bool LstIsRead; // Is the list already read from database... bool LstIsRead; // Is the list already read from database...
@ -73,6 +77,7 @@ struct Exa_Exams
char *ListQuestions; char *ListQuestions;
char *ExaCodsSelected; // String with selected exam codes separated by separator multiple char *ExaCodsSelected; // String with selected exam codes separated by separator multiple
long ExaCod; // Selected/current exam code long ExaCod; // Selected/current exam code
long SetCod; // Selected/current set code
long EvtCod; // Selected/current match code long EvtCod; // Selected/current match code
unsigned SetInd; // Current set index unsigned SetInd; // Current set index
unsigned QstInd; // Current question index unsigned QstInd; // Current question index
@ -95,9 +100,13 @@ struct Exa_Exam
unsigned NumUnfinishedEvts; // Number of unfinished events in the exam unsigned NumUnfinishedEvts; // Number of unfinished events in the exam
}; };
struct Exa_Set struct ExaSet_Set
{ {
long SetCod; long ExaCod; // Exam code
long SetCod; // Set code
unsigned SetInd; // Set index (position in the exam)
unsigned NumQstsToExam; // Number of questions in this set taht will appear in the exam
char Title[ExaSet_MAX_BYTES_TITLE + 1]; // Title of the set
}; };
/*****************************************************************************/ /*****************************************************************************/
@ -123,7 +132,8 @@ void Exa_SetCurrentExaCod (long ExaCod);
void Exa_PutParams (void *Exams); void Exa_PutParams (void *Exams);
void Exa_PutParamExamCod (long ExaCod); void Exa_PutParamExamCod (long ExaCod);
long Exa_GetParamExamCod (void); long Exa_GetParamExamCod (void);
long Exa_GetParams (struct Exa_Exams *Exams); long ExaSet_GetParamSetCod (void);
void Exa_GetParams (struct Exa_Exams *Exams);
void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder); void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder);
void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams); void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams);
@ -140,6 +150,7 @@ void Exa_UnhideExam (void);
void Exa_RequestCreatOrEditExam (void); void Exa_RequestCreatOrEditExam (void);
void ExaSet_RecFormSet (void);
void Exa_RecFormExam (void); void Exa_RecFormExam (void);
bool Mch_CheckIfMatchIsAssociatedToGrp (long EvtCod,long GrpCod); bool Mch_CheckIfMatchIsAssociatedToGrp (long EvtCod,long GrpCod);
@ -147,6 +158,7 @@ unsigned Exa_GetNumQstsExam (long ExaCod);
void Exa_RequestNewSet (void); void Exa_RequestNewSet (void);
void ExaSet_RequestCreatOrEditSet (void);
void Exa_RequestNewQuestion (void); void Exa_RequestNewQuestion (void);
void Exa_ListQuestionsToSelect (void); void Exa_ListQuestionsToSelect (void);
@ -159,11 +171,11 @@ unsigned Exa_GetNextQuestionIndexInExam (long ExaCod,unsigned QstInd);
void Exa_AddQuestionsToExam (void); void Exa_AddQuestionsToExam (void);
void Exa_RequestRemoveSet (void); void ExaSet_RequestRemoveSet (void);
void Exa_RemoveSet (void); void ExaSet_RemoveSet (void);
void Exa_MoveUpSet (void); void ExaSet_MoveUpSet (void);
void Exa_MoveDownSet (void); void ExaSet_MoveDownSet (void);
void Exa_RequestRemoveQst (void); void Exa_RequestRemoveQst (void);
void Exa_RemoveQst (void); void Exa_RemoveQst (void);

View File

@ -1292,22 +1292,22 @@ void ExaEvt_GetAndCheckParameters (struct Exa_Exams *Exams,
struct ExaEvt_Event *Event) struct ExaEvt_Event *Event)
{ {
/***** Get parameters *****/ /***** Get parameters *****/
/* Get parameters of exam */ Exa_GetParams (Exams);
if ((Exam->ExaCod = Exa_GetParams (Exams)) <= 0) if (Exams->ExaCod <= 0)
Lay_ShowErrorAndExit ("Code of exam is missing."); Lay_WrongExamExit ();
Exam->ExaCod = Exams->ExaCod;
Grp_GetParamWhichGroups (); Grp_GetParamWhichGroups ();
Exa_GetDataOfExamByCod (Exam);
/* Get exam event code */
if ((Event->EvtCod = ExaEvt_GetParamEvtCod ()) <= 0) if ((Event->EvtCod = ExaEvt_GetParamEvtCod ()) <= 0)
Lay_ShowErrorAndExit ("Code of exam event is missing."); Lay_WrongEventExit ();
/***** Get data of exam and event from database *****/
Exa_GetDataOfExamByCod (Exam);
ExaEvt_GetDataOfEventByCod (Event); ExaEvt_GetDataOfEventByCod (Event);
/***** Ensure parameters are correct *****/ /***** Ensure parameters are correct *****/
if (Exam->ExaCod != Event->ExaCod) if (Exam->ExaCod != Event->ExaCod ||
Lay_ShowErrorAndExit ("Wrong exam code."); Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
if (Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod) Lay_WrongExamExit ();
Lay_ShowErrorAndExit ("Event does not belong to this course.");
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -164,8 +164,12 @@ void ExaRes_ShowMyExaResultsInExa (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
/***** Get data of exam from database *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Exam begin *****/ /***** Exam begin *****/
@ -214,10 +218,12 @@ void ExaRes_ShowMyExaResultsInEvt (void)
ExaEvt_ResetEvent (&Event); ExaEvt_ResetEvent (&Event);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
if ((Event.EvtCod = ExaEvt_GetParamEvtCod ()) <= 0) if ((Event.EvtCod = ExaEvt_GetParamEvtCod ()) <= 0)
Lay_ShowErrorAndExit ("Code of event is missing."); Lay_WrongEventExit ();
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
ExaEvt_GetDataOfEventByCod (&Event); ExaEvt_GetDataOfEventByCod (&Event);
@ -366,8 +372,10 @@ void ExaRes_ShowAllExaResultsInExa (void)
Exa_ResetExam (&Exam); Exa_ResetExam (&Exam);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
/***** Exam begin *****/ /***** Exam begin *****/
@ -457,10 +465,14 @@ void ExaRes_ShowAllExaResultsInEvt (void)
ExaEvt_ResetEvent (&Event); ExaEvt_ResetEvent (&Event);
/***** Get parameters *****/ /***** Get parameters *****/
if ((Exam.ExaCod = Exa_GetParams (&Exams)) <= 0) Exa_GetParams (&Exams);
Lay_ShowErrorAndExit ("Code of exam is missing."); if (Exams.ExaCod <= 0)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
if ((Event.EvtCod = ExaEvt_GetParamEvtCod ()) <= 0) if ((Event.EvtCod = ExaEvt_GetParamEvtCod ()) <= 0)
Lay_ShowErrorAndExit ("Code of event is missing."); Lay_WrongEventExit ();
/***** Get data of exam and event *****/
Exa_GetDataOfExamByCod (&Exam); Exa_GetDataOfExamByCod (&Exam);
ExaEvt_GetDataOfEventByCod (&Event); ExaEvt_GetDataOfEventByCod (&Event);

View File

@ -4361,7 +4361,7 @@ static long For_GetThrInMyClipboard (void)
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
long ThrCod = -1L;; long ThrCod = -1L;
/***** Get if there is a thread ready to move in my clipboard from database *****/ /***** Get if there is a thread ready to move in my clipboard from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not check if there is" NumRows = DB_QuerySELECT (&mysql_res,"can not check if there is"

View File

@ -1484,6 +1484,24 @@ void Lay_WrongTypeOfViewExit (void)
Lay_ShowErrorAndExit ("Wrong type of view."); Lay_ShowErrorAndExit ("Wrong type of view.");
} }
/*****************************************************************************/
/************** Write error message and exit when wrong exam *****************/
/*****************************************************************************/
void Lay_WrongExamExit (void)
{
Lay_ShowErrorAndExit ("Wrong exam.");
}
/*****************************************************************************/
/************** Write error message and exit when wrong event ****************/
/*****************************************************************************/
void Lay_WrongEventExit (void)
{
Lay_ShowErrorAndExit ("Wrong event.");
}
/*****************************************************************************/ /*****************************************************************************/
/******* Write error message, close files, remove lock file, and exit ********/ /******* Write error message, close files, remove lock file, and exit ********/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -73,6 +73,8 @@ void Lay_NotEnoughMemoryExit (void);
void Lay_WrongScopeExit (void); void Lay_WrongScopeExit (void);
void Lay_WrongOrderExit (void); void Lay_WrongOrderExit (void);
void Lay_WrongTypeOfViewExit (void); void Lay_WrongTypeOfViewExit (void);
void Lay_WrongExamExit (void);
void Lay_WrongEventExit (void);
void Lay_NoPermissionExit (void); void Lay_NoPermissionExit (void);
void Lay_ShowErrorAndExit (const char *Txt); void Lay_ShowErrorAndExit (const char *Txt);

View File

@ -304,7 +304,7 @@ void Lnk_GetListLinks (void)
/***** Create list with places *****/ /***** Create list with places *****/
if ((Gbl.Links.Lst = (struct Link *) calloc (NumRows,sizeof (struct Link))) == NULL) if ((Gbl.Links.Lst = (struct Link *) calloc (NumRows,sizeof (struct Link))) == NULL)
Lay_NotEnoughMemoryExit ();; Lay_NotEnoughMemoryExit ();
/***** Get the links *****/ /***** Get the links *****/
for (NumLnk = 0; for (NumLnk = 0;

View File

@ -2352,7 +2352,7 @@ void TstRes_GetExamQuestionsFromDB (struct TstRes_Result *Result)
DB_FreeMySQLResult (&mysql_res); DB_FreeMySQLResult (&mysql_res);
if (NumQsts != Result->NumQsts) if (NumQsts != Result->NumQsts)
Lay_ShowErrorAndExit ("Wrong exam."); Lay_WrongExamExit ();
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -931,6 +931,69 @@ const char *Txt_Action =
"A&ccedil;&atilde;o"; "A&ccedil;&atilde;o";
#endif #endif
const char *Txt_Add_questions =
#if L==1 // ca
"Afegir preguntes";
#elif L==2 // de
"F&uuml;gen Fragen";
#elif L==3 // en
"Add questions";
#elif L==4 // es
"A&ntilde;adir preguntas";
#elif L==5 // fr
"Ajouter questions";
#elif L==6 // gn
"A&ntilde;adir preguntas"; // Okoteve traducción
#elif L==7 // it
"Aggiungere domande";
#elif L==8 // pl
"Dodaj pytania";
#elif L==9 // pt
"Adicionar perguntas";
#endif
const char *Txt_Add_this_ID =
#if L==1 // ca
"Afegir aquest ID";
#elif L==2 // de
"F&uuml;gen Sie diese Ausweis-Nr.";
#elif L==3 // en
"Add this ID";
#elif L==4 // es
"A&ntilde;adir este ID";
#elif L==5 // fr
"Ajouter ce num&eacute;ro d'identit&eacute;";
#elif L==6 // gn
"A&ntilde;adir este ID"; // Okoteve traducción
#elif L==7 // it
"Aggiungere questa carta d'identit&agrave;";
#elif L==8 // pl
"Dodaj ten identyfikator";
#elif L==9 // pt
"Adicionar este n&ordm; identif.";
#endif
const char *Txt_Add_USERS = // Warning: it is very important to include %s in the following sentences
#if L==1 // ca
"Afegir %s";
#elif L==2 // de
"F&uuml;gen %s";
#elif L==3 // en
"Add %s";
#elif L==4 // es
"A&ntilde;adir %s";
#elif L==5 // fr
"Ajouter %s";
#elif L==6 // gn
"A&ntilde;adir %s"; // Okoteve traducción
#elif L==7 // it
"Aggiungere %s";
#elif L==8 // pl
"Dodaj %s";
#elif L==9 // pt
"Adicionar %s";
#endif
const char *Txt_Administer_me = const char *Txt_Administer_me =
#if L==1 // ca #if L==1 // ca
"Administrarme"; "Administrarme";
@ -1843,69 +1906,6 @@ const char *Txt_Another_user_s_profile =
"Perfil de outro usu&aacute;rio"; "Perfil de outro usu&aacute;rio";
#endif #endif
const char *Txt_Add_questions =
#if L==1 // ca
"Afegir preguntes";
#elif L==2 // de
"F&uuml;gen Fragen";
#elif L==3 // en
"Add questions";
#elif L==4 // es
"A&ntilde;adir preguntas";
#elif L==5 // fr
"Ajouter questions";
#elif L==6 // gn
"A&ntilde;adir preguntas"; // Okoteve traducción
#elif L==7 // it
"Aggiungere domande";
#elif L==8 // pl
"Dodaj pytania";
#elif L==9 // pt
"Adicionar perguntas";
#endif
const char *Txt_Add_this_ID =
#if L==1 // ca
"Afegir aquest ID";
#elif L==2 // de
"F&uuml;gen Sie diese Ausweis-Nr.";
#elif L==3 // en
"Add this ID";
#elif L==4 // es
"A&ntilde;adir este ID";
#elif L==5 // fr
"Ajouter ce num&eacute;ro d'identit&eacute;";
#elif L==6 // gn
"A&ntilde;adir este ID"; // Okoteve traducción
#elif L==7 // it
"Aggiungere questa carta d'identit&agrave;";
#elif L==8 // pl
"Dodaj ten identyfikator";
#elif L==9 // pt
"Adicionar este n&ordm; identif.";
#endif
const char *Txt_Add_USERS = // Warning: it is very important to include %s in the following sentences
#if L==1 // ca
"Afegir %s";
#elif L==2 // de
"F&uuml;gen %s";
#elif L==3 // en
"Add %s";
#elif L==4 // es
"A&ntilde;adir %s";
#elif L==5 // fr
"Ajouter %s";
#elif L==6 // gn
"A&ntilde;adir %s"; // Okoteve traducción
#elif L==7 // it
"Aggiungere %s";
#elif L==8 // pl
"Dodaj %s";
#elif L==9 // pt
"Adicionar %s";
#endif
const char *Txt_Announcement_created = const char *Txt_Announcement_created =
#if L==1 // ca #if L==1 // ca
"Anunci creat."; "Anunci creat.";
@ -25328,6 +25328,27 @@ const char *Txt_New_room =
"Nova sala"; "Nova sala";
#endif #endif
const char *Txt_New_set_of_questions =
#if L==1 // ca
"Nou conjunt de preguntes";
#elif L==2 // de
"Neue Satz von Fragen";
#elif L==3 // en
"New set of questions";
#elif L==4 // es
"Nuevo conjunto de preguntas";
#elif L==5 // fr
"Nouveau ensemble de questions";
#elif L==6 // gn
"Nuevo conjunto de preguntas"; // Okoteve traducción
#elif L==7 // it
"Nuova serie di domande";
#elif L==8 // pl
"Nowy zestaw pyta&nacute;";
#elif L==9 // pt
"Novo conjunto de perguntas";
#endif
const char *Txt_New_TIMELINE_comment = const char *Txt_New_TIMELINE_comment =
#if L==1 // ca #if L==1 // ca
"Nou comentari"; "Nou comentari";
@ -40836,6 +40857,27 @@ const char *Txt_sessions =
"sess&otilde;es"; "sess&otilde;es";
#endif #endif
const char *Txt_Set_of_questions =
#if L==1 // ca
"Conjunt de preguntes";
#elif L==2 // de
"Satz von Fragen";
#elif L==3 // en
"Set of questions";
#elif L==4 // es
"Conjunto de preguntas";
#elif L==5 // fr
"Ensemble de questions";
#elif L==6 // gn
"Conjunto de preguntas"; // Okoteve traducción
#elif L==7 // it
"Serie di domande";
#elif L==8 // pl
"Zestaw pyta&nacute;";
#elif L==9 // pt
"Conjunto de perguntas";
#endif
const char *Txt_Set_password = const char *Txt_Set_password =
#if L==1 // ca #if L==1 // ca
"Establir contrasenya"; "Establir contrasenya";
@ -40878,6 +40920,27 @@ const char *Txt_Set_up =
"Instalar"; "Instalar";
#endif #endif
const char *Txt_Sets_of_questions =
#if L==1 // ca
"Conjunts de preguntes";
#elif L==2 // de
"S&auml;tze von Fragen";
#elif L==3 // en
"Sets of questions";
#elif L==4 // es
"Conjuntos de preguntas";
#elif L==5 // fr
"Ensembles de questions";
#elif L==6 // gn
"Conjuntos de preguntas"; // Okoteve traducción
#elif L==7 // it
"Serie di domande";
#elif L==8 // pl
"Zestaw&oacute;w pyta&nacute;";
#elif L==9 // pt
"Conjuntos de perguntas";
#endif
const char *Txt_Settings = const char *Txt_Settings =
#if L==1 // ca #if L==1 // ca
"Configuraci&oacute;"; "Configuraci&oacute;";
@ -51313,6 +51376,27 @@ const char *Txt_There_was_a_problem_sending_an_email_automatically =
"Ocorreu um problema ao enviar um email automaticamente."; "Ocorreu um problema ao enviar um email automaticamente.";
#endif #endif
const char *Txt_This_exam_has_no_sets_of_questions =
#if L==1 // ca
"Aquest examen no t&eacute; conjunts de preguntes.";
#elif L==2 // de
"Dieses Pr&uuml;fung hat keine s&auml;tze von Fragen.";
#elif L==3 // en
"This exam has no sets of questions.";
#elif L==4 // es
"Este examen no tiene conjuntos de preguntas.";
#elif L==5 // fr
"Cet examen n'a pas d'ensembles de questions.";
#elif L==6 // gn
"Este examen no tiene conjuntos de preguntas."; // Okoteve traducción
#elif L==7 // it
"Questo esame non ha serie di domande.";
#elif L==8 // pl
"Ten egzamin nie ma zestaw&oacute;w pyta&nacute;.";
#elif L==9 // pt
"Este exame n&atilde;o tem conjuntos de perguntas.";
#endif
const char *Txt_This_exam_has_no_questions = const char *Txt_This_exam_has_no_questions =
#if L==1 // ca #if L==1 // ca
"Aquest examen no t&eacute; preguntes."; "Aquest examen no t&eacute; preguntes.";

View File

@ -4664,7 +4664,7 @@ static void TL_RemoveCommentMediaAndDBEntries (long PubCod)
{ {
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
long MedCod;; long MedCod;
/***** Remove media associated to comment *****/ /***** Remove media associated to comment *****/
if (DB_QuerySELECT (&mysql_res,"can not get media", if (DB_QuerySELECT (&mysql_res,"can not get media",

View File

@ -329,7 +329,7 @@ void TT_ShowClassTimeTable (void)
}; };
struct TT_Timetable Timetable; struct TT_Timetable Timetable;
bool PrintView = (Gbl.Action.Act == ActPrnCrsTT || bool PrintView = (Gbl.Action.Act == ActPrnCrsTT ||
Gbl.Action.Act == ActPrnMyTT);; Gbl.Action.Act == ActPrnMyTT);
Grp_WhichGroups_t WhichGroups; Grp_WhichGroups_t WhichGroups;
/***** Initializations *****/ /***** Initializations *****/