mirror of https://github.com/acanas/swad-core.git
Version 16.251.5
This commit is contained in:
parent
ee37f2023f
commit
da3a9ce439
|
@ -590,7 +590,6 @@ CREATE TABLE IF NOT EXISTS gam_answers (
|
|||
QstCod INT NOT NULL,
|
||||
AnsInd TINYINT NOT NULL,
|
||||
NumUsrs INT NOT NULL DEFAULT 0,
|
||||
Answer TEXT NOT NULL,
|
||||
UNIQUE INDEX(QstCod,AnsInd));
|
||||
--
|
||||
-- Table gam_grp: stores the groups associated to each game
|
||||
|
|
|
@ -505,7 +505,6 @@ Assessment:
|
|||
NEW. ActEdiOneGamQst Edit a new question for a game
|
||||
NEW. ActGamLstTstQst List test questions to select one or several questions
|
||||
NEW. ActAddTstQstToGam Add selected test questions to game
|
||||
NEW. ActRcvGamQst Receive a question of a game
|
||||
NEW. ActReqRemGamQst Request the removal of a question of a game
|
||||
NEW. ActRemGamQst Confirm the removal of a question of a game
|
||||
|
||||
|
@ -1983,7 +1982,6 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActEdiOneGamQst */{1662,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_RequestEditQuestion ,NULL},
|
||||
/* ActGamLstTstQst */{1666,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Tst_ListQuestionsToSelect ,NULL},
|
||||
/* ActAddTstQstToGam */{1667,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_AddTstQuestionsToGame ,NULL},
|
||||
/* ActRcvGamQst */{1663,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_ReceiveQst ,NULL},
|
||||
/* ActReqRemGamQst */{1664,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_RequestRemoveQst ,NULL},
|
||||
/* ActRemGamQst */{1665,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_RemoveQst ,NULL},
|
||||
|
||||
|
@ -4708,7 +4706,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
|
|||
ActHidGam, // #1660
|
||||
ActShoGam, // #1661
|
||||
ActEdiOneGamQst, // #1662
|
||||
ActRcvGamQst, // #1663
|
||||
-1, // #1663 (obsolete action)
|
||||
ActReqRemGamQst, // #1664
|
||||
ActRemGamQst, // #1665
|
||||
ActGamLstTstQst, // #1666
|
||||
|
|
|
@ -57,7 +57,7 @@ typedef enum
|
|||
|
||||
typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
|
||||
|
||||
#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 33 + 24 + 115 + 91 + 416 + 165 + 172 + 42 + 14 + 97)
|
||||
#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 33 + 24 + 115 + 90 + 416 + 165 + 172 + 42 + 14 + 97)
|
||||
|
||||
#define Act_MAX_ACTION_COD 1667
|
||||
|
||||
|
@ -517,19 +517,18 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
|
|||
#define ActEdiOneGamQst (ActChgCalCrs1stDay + 77)
|
||||
#define ActGamLstTstQst (ActChgCalCrs1stDay + 78)
|
||||
#define ActAddTstQstToGam (ActChgCalCrs1stDay + 79)
|
||||
#define ActRcvGamQst (ActChgCalCrs1stDay + 80)
|
||||
#define ActReqRemGamQst (ActChgCalCrs1stDay + 81)
|
||||
#define ActRemGamQst (ActChgCalCrs1stDay + 82)
|
||||
#define ActReqRemGamQst (ActChgCalCrs1stDay + 80)
|
||||
#define ActRemGamQst (ActChgCalCrs1stDay + 81)
|
||||
|
||||
#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 83)
|
||||
#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 84)
|
||||
#define ActEdiExaAnn (ActChgCalCrs1stDay + 85)
|
||||
#define ActRcvExaAnn (ActChgCalCrs1stDay + 86)
|
||||
#define ActPrnExaAnn (ActChgCalCrs1stDay + 87)
|
||||
#define ActReqRemExaAnn (ActChgCalCrs1stDay + 88)
|
||||
#define ActRemExaAnn (ActChgCalCrs1stDay + 89)
|
||||
#define ActHidExaAnn (ActChgCalCrs1stDay + 90)
|
||||
#define ActShoExaAnn (ActChgCalCrs1stDay + 91)
|
||||
#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 82)
|
||||
#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 83)
|
||||
#define ActEdiExaAnn (ActChgCalCrs1stDay + 84)
|
||||
#define ActRcvExaAnn (ActChgCalCrs1stDay + 85)
|
||||
#define ActPrnExaAnn (ActChgCalCrs1stDay + 86)
|
||||
#define ActReqRemExaAnn (ActChgCalCrs1stDay + 87)
|
||||
#define ActRemExaAnn (ActChgCalCrs1stDay + 88)
|
||||
#define ActHidExaAnn (ActChgCalCrs1stDay + 89)
|
||||
#define ActShoExaAnn (ActChgCalCrs1stDay + 90)
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Files tab **********************************/
|
||||
|
|
|
@ -238,15 +238,20 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.251.4 (2017-09-01)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.251.5 (2017-09-01)"
|
||||
#define CSS_FILE "swad16.235.1.css"
|
||||
#define JS_FILE "swad16.206.3.js"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
||||
/*
|
||||
// TODO: "Error when getting answers of a question"
|
||||
Version 16.251.4: Sep 01, 2017 Listing games for remote control. Not finished. (? lines)
|
||||
Version 16.251.5: Sep 01, 2017 Listing games for remote control. Not finished. (227045 lines)
|
||||
1 change necessary in database:
|
||||
ALTER TABLE gam_answers DROP COLUMN Answer;
|
||||
UPDATE actions SET Obsolete='Y' WHERE ActCod='1663';
|
||||
|
||||
Version 16.251.4: Sep 01, 2017 Listing games for remote control. Not finished. (227184 lines)
|
||||
2 changes necessary in database:
|
||||
DROP TABLE IF EXISTS gam_questions;
|
||||
CREATE TABLE IF NOT EXISTS gam_questions (GamCod INT NOT NULL,QstCod INT NOT NULL,QstInd INT NOT NULL DEFAULT 0,INDEX(GamCod),INDEX(QstCod));
|
||||
|
||||
|
|
|
@ -1281,15 +1281,13 @@ mysql> DESCRIBE gam_answers;
|
|||
| QstCod | int(11) | NO | PRI | NULL | |
|
||||
| AnsInd | tinyint(4) | NO | PRI | NULL | |
|
||||
| NumUsrs | int(11) | NO | | 0 | |
|
||||
| Answer | text | NO | | NULL | |
|
||||
+---------+------------+------+-----+---------+-------+
|
||||
4 rows in set (0.00 sec)
|
||||
3 rows in set (0,00 sec)
|
||||
*/
|
||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_answers ("
|
||||
"QstCod INT NOT NULL,"
|
||||
"AnsInd TINYINT NOT NULL,"
|
||||
"NumUsrs INT NOT NULL DEFAULT 0,"
|
||||
"Answer TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
|
||||
"UNIQUE INDEX(QstCod,AnsInd))");
|
||||
|
||||
/***** Table gam_grp *****/
|
||||
|
|
|
@ -137,10 +137,10 @@ static void Rmt_PutParamQstCod (long QstCod);
|
|||
static long Rmt_GetParamQstCod (void);
|
||||
static void Rmt_RemAnswersOfAQuestion (long QstCod);
|
||||
static Rmt_AnswerType_t Rmt_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeBD);
|
||||
static bool Rmt_CheckIfAnswerExists (long QstCod,unsigned AnsInd);
|
||||
// static bool Rmt_CheckIfAnswerExists (long QstCod,unsigned AnsInd);
|
||||
static unsigned Rmt_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res);
|
||||
static bool Rmt_AllocateTextChoiceAnswer (struct GameQuestion *GameQst,unsigned NumAns);
|
||||
static void Rmt_FreeTextChoiceAnswers (struct GameQuestion *GameQst,unsigned NumAnswers);
|
||||
// static void Rmt_FreeTextChoiceAnswers (struct GameQuestion *GameQst,unsigned NumAnswers);
|
||||
static void Rmt_FreeTextChoiceAnswer (struct GameQuestion *GameQst,unsigned NumAns);
|
||||
|
||||
static unsigned Rmt_GetQstIndFromQstCod (long QstCod);
|
||||
|
@ -157,7 +157,7 @@ static void Rmt_WriteQstStem (const char *Stem);
|
|||
static void Rmt_WriteAnswersOfAQst (struct Game *Game,struct GameQuestion *GameQst,bool PutFormAnswerGame);
|
||||
static void Rmt_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs);
|
||||
|
||||
static void Rmt_PutIconToRemoveOneQst (void);
|
||||
// static void Rmt_PutIconToRemoveOneQst (void);
|
||||
static void Rmt_PutParamsRemoveOneQst (void);
|
||||
|
||||
static void Rmt_ReceiveAndStoreUserAnswersToAGame (long GamCod);
|
||||
|
@ -1541,13 +1541,6 @@ void Rmt_RemoveGame (void)
|
|||
Game.GamCod);
|
||||
DB_QueryDELETE (Query,"can not remove users who are answered a game");
|
||||
|
||||
/***** Remove all the answers in this game *****/
|
||||
sprintf (Query,"DELETE FROM gam_answers USING gam_questions,gam_answers"
|
||||
" WHERE gam_questions.GamCod=%ld"
|
||||
" AND gam_questions.QstCod=gam_answers.QstCod",
|
||||
Game.GamCod);
|
||||
DB_QueryDELETE (Query,"can not remove answers of a game");
|
||||
|
||||
/***** Remove all the questions in this game *****/
|
||||
sprintf (Query,"DELETE FROM gam_questions"
|
||||
" WHERE GamCod=%ld",
|
||||
|
@ -2652,36 +2645,57 @@ static Rmt_AnswerType_t Rmt_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTy
|
|||
/*****************************************************************************/
|
||||
/*********** Check if an answer of a question exists in database *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
static bool Rmt_CheckIfAnswerExists (long QstCod,unsigned AnsInd)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get answers of a question from database *****/
|
||||
***** Get answers of a question from database *****
|
||||
sprintf (Query,"SELECT COUNT(*) FROM gam_answers"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
QstCod,AnsInd);
|
||||
return (DB_QueryCOUNT (Query,"can not check if an answer exists") != 0);
|
||||
}
|
||||
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/************** Get answers of a game question from database ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned Rmt_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res)
|
||||
{
|
||||
char Query[256];
|
||||
char Query[1024];
|
||||
unsigned long NumRows;
|
||||
|
||||
/***** Get answers of a question from database *****/
|
||||
sprintf (Query,"SELECT AnsInd,NumUsrs,Answer FROM gam_answers"
|
||||
" WHERE QstCod=%ld ORDER BY AnsInd",
|
||||
QstCod);
|
||||
sprintf (Query,"SELECT AnsInd,NumUsrs,Answer FROM"
|
||||
"("
|
||||
"SELECT tst_answers.AnsInd AS AnsInd,"
|
||||
"gam_answers.NumUsrs AS NumUsrs,tst_answers.Answer AS Answer"
|
||||
" FROM tst_answers,gam_answers"
|
||||
" WHERE tst_answers.QstCod=%ld"
|
||||
" AND gam_answers.QstCod=%ld"
|
||||
" AND tst_answers.QstCod=gam_answers.QstCod"
|
||||
" AND tst_answers.AnsInd=gam_answers.AnsInd"
|
||||
" UNION "
|
||||
"SELECT AnsInd,0 AS NumUsrs,Answer FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND NOT EXISTS"
|
||||
" (SELECT * FROM gam_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND tst_answers.QstCod=gam_answers.QstCod"
|
||||
" AND tst_answers.AnsInd=gam_answers.AnsInd)"
|
||||
") AS answers"
|
||||
" ORDER BY AnsInd",
|
||||
QstCod,QstCod,
|
||||
QstCod,QstCod);
|
||||
NumRows = DB_QuerySELECT (Query,mysql_res,"can not get answers of a question");
|
||||
|
||||
/***** Count number of rows of result *****/
|
||||
if (NumRows == 0)
|
||||
{
|
||||
Ale_ShowAlert (Ale_ERROR,"Error when getting answers of a question.");
|
||||
Ale_ShowAlert (Ale_INFO,Query);
|
||||
}
|
||||
|
||||
return (unsigned) NumRows;
|
||||
}
|
||||
|
@ -2705,7 +2719,7 @@ static bool Rmt_AllocateTextChoiceAnswer (struct GameQuestion *GameQst,unsigned
|
|||
/*****************************************************************************/
|
||||
/******************** Free memory of all choice answers **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
static void Rmt_FreeTextChoiceAnswers (struct GameQuestion *GameQst,unsigned NumAnswers)
|
||||
{
|
||||
unsigned NumAns;
|
||||
|
@ -2715,7 +2729,7 @@ static void Rmt_FreeTextChoiceAnswers (struct GameQuestion *GameQst,unsigned Num
|
|||
NumAns++)
|
||||
Rmt_FreeTextChoiceAnswer (GameQst,NumAns);
|
||||
}
|
||||
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/********************** Free memory of a choice answer ***********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -2730,9 +2744,9 @@ static void Rmt_FreeTextChoiceAnswer (struct GameQuestion *GameQst,unsigned NumA
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Receive a question of a game **********************/
|
||||
/************************ Receive a question of a game ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
void Rmt_ReceiveQst (void)
|
||||
{
|
||||
extern const char *Txt_You_must_type_the_stem_of_the_question;
|
||||
|
@ -2749,28 +2763,28 @@ void Rmt_ReceiveQst (void)
|
|||
bool ThereIsEndOfAnswers;
|
||||
bool Error = false;
|
||||
|
||||
/***** Initialize new question to zero *****/
|
||||
***** Initialize new question to zero *****
|
||||
Rmt_InitQst (&GameQst);
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get game code */
|
||||
***** Get parameters from form *****
|
||||
* Get game code *
|
||||
if ((Game.GamCod = Rmt_GetParamGameCod ()) == -1L)
|
||||
Lay_ShowErrorAndExit ("Code of game is missing.");
|
||||
|
||||
/* Get question code */
|
||||
* Get question code *
|
||||
GameQst.QstCod = Rmt_GetParamQstCod ();
|
||||
|
||||
/* Get answer type */
|
||||
* Get answer type *
|
||||
GameQst.AnswerType = (Rmt_AnswerType_t)
|
||||
Par_GetParToUnsignedLong ("AnswerType",
|
||||
0,
|
||||
Rmt_NUM_ANS_TYPES - 1,
|
||||
(unsigned long) Rmt_ANSWER_TYPE_DEFAULT);
|
||||
|
||||
/* Get question text */
|
||||
* Get question text *
|
||||
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT);
|
||||
|
||||
/* Get the texts of the answers */
|
||||
* Get the texts of the answers *
|
||||
for (NumAns = 0;
|
||||
NumAns < Rmt_MAX_ANSWERS_PER_QUESTION;
|
||||
NumAns++)
|
||||
|
@ -2781,7 +2795,7 @@ void Rmt_ReceiveQst (void)
|
|||
Par_GetParToHTML (AnsStr,GameQst.AnsChoice[NumAns].Text,Rmt_MAX_BYTES_ANSWER);
|
||||
}
|
||||
|
||||
/***** Make sure that stem and answer are not empty *****/
|
||||
***** Make sure that stem and answer are not empty *****
|
||||
if (Txt[0])
|
||||
{
|
||||
if (GameQst.AnsChoice[0].Text[0]) // If the first answer has been filled
|
||||
|
@ -2826,12 +2840,12 @@ void Rmt_ReceiveQst (void)
|
|||
Tst_ShowFormAskSelectTstsForGame (Game.GamCod);
|
||||
else
|
||||
{
|
||||
/***** Form is received OK ==> insert question and answer in the database *****/
|
||||
***** Form is received OK ==> insert question and answer in the database *****
|
||||
if (GameQst.QstCod < 0) // It's a new question
|
||||
{
|
||||
GameQst.QstInd = Rmt_GetNextQuestionIndexInGame (Game.GamCod);
|
||||
|
||||
/* Insert question in the table of questions */
|
||||
* Insert question in the table of questions *
|
||||
sprintf (Query,"INSERT INTO gam_questions"
|
||||
" (GamCod,QstInd,AnsType,Stem)"
|
||||
" VALUES"
|
||||
|
@ -2841,7 +2855,7 @@ void Rmt_ReceiveQst (void)
|
|||
}
|
||||
else // It's an existing question
|
||||
{
|
||||
/* Update question */
|
||||
* Update question *
|
||||
sprintf (Query,"UPDATE gam_questions SET Stem='%s',AnsType='%s'"
|
||||
" WHERE QstCod=%ld AND GamCod=%ld",
|
||||
Txt,Rmt_StrAnswerTypesDB[GameQst.AnswerType],
|
||||
|
@ -2849,7 +2863,7 @@ void Rmt_ReceiveQst (void)
|
|||
DB_QueryUPDATE (Query,"can not update question");
|
||||
}
|
||||
|
||||
/* Insert, update or delete answers in the answers table */
|
||||
* Insert, update or delete answers in the answers table *
|
||||
for (NumAns = 0;
|
||||
NumAns < Rmt_MAX_ANSWERS_PER_QUESTION;
|
||||
NumAns++)
|
||||
|
@ -2857,7 +2871,7 @@ void Rmt_ReceiveQst (void)
|
|||
{
|
||||
if (GameQst.AnsChoice[NumAns].Text[0]) // Answer is not empty
|
||||
{
|
||||
/* Update answer text */
|
||||
* Update answer text *
|
||||
sprintf (Query,"UPDATE gam_answers SET Answer='%s'"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
GameQst.AnsChoice[NumAns].Text,GameQst.QstCod,NumAns);
|
||||
|
@ -2865,7 +2879,7 @@ void Rmt_ReceiveQst (void)
|
|||
}
|
||||
else // Answer is empty
|
||||
{
|
||||
/* Delete answer from database */
|
||||
* Delete answer from database *
|
||||
sprintf (Query,"DELETE FROM gam_answers"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
GameQst.QstCod,NumAns);
|
||||
|
@ -2876,7 +2890,7 @@ void Rmt_ReceiveQst (void)
|
|||
{
|
||||
if (GameQst.AnsChoice[NumAns].Text[0]) // Answer is not empty
|
||||
{
|
||||
/* Create answer into database */
|
||||
* Create answer into database *
|
||||
sprintf (Query,"INSERT INTO gam_answers"
|
||||
" (QstCod,AnsInd,NumUsrs,Answer)"
|
||||
" VALUES"
|
||||
|
@ -2886,19 +2900,19 @@ void Rmt_ReceiveQst (void)
|
|||
}
|
||||
}
|
||||
|
||||
/***** List the questions of this game, including the new one just inserted into the database *****/
|
||||
***** List the questions of this game, including the new one just inserted into the database *****
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_game_has_been_modified);
|
||||
}
|
||||
|
||||
/***** Free answers *****/
|
||||
***** Free answers *****
|
||||
Rmt_FreeTextChoiceAnswers (&GameQst,Rmt_MAX_ANSWERS_PER_QUESTION);
|
||||
|
||||
/***** Show current game *****/
|
||||
***** Show current game *****
|
||||
Rmt_ShowOneGame (Game.GamCod,&GameQst,true);
|
||||
}
|
||||
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/******************* Get next question index in a game *********************/
|
||||
/******************** Get next question index in a game **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned Rmt_GetQstIndFromQstCod (long QstCod)
|
||||
|
@ -2982,8 +2996,7 @@ static void Rmt_ListGameQuestions (struct Game *Game,struct GameQuestion *GameQs
|
|||
unsigned NumQsts;
|
||||
unsigned NumQst;
|
||||
bool Editing = (Gbl.Action.Act == ActEdiOneGam ||
|
||||
Gbl.Action.Act == ActEdiOneGamQst ||
|
||||
Gbl.Action.Act == ActRcvGamQst);
|
||||
Gbl.Action.Act == ActEdiOneGamQst);
|
||||
bool PutFormAnswerGame = Game->Status.ICanAnswer && !Editing;
|
||||
|
||||
/***** Get data of questions from database *****/
|
||||
|
@ -3427,12 +3440,12 @@ static void Rmt_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
|
|||
/*****************************************************************************/
|
||||
/********************* Put icon to remove one question ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
static void Rmt_PutIconToRemoveOneQst (void)
|
||||
{
|
||||
Ico_PutContextualIconToRemove (ActReqRemGamQst,Rmt_PutParamsRemoveOneQst);
|
||||
}
|
||||
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/****************** Put parameter to remove one question *********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -3630,7 +3643,8 @@ static void Rmt_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
|
|||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Increase number of users who have selected the answer AnsInd in the question QstCod *****/
|
||||
/***** Increase number of users who have selected
|
||||
the answer AnsInd in the question QstCod *****/
|
||||
sprintf (Query,"UPDATE gam_answers SET NumUsrs=NumUsrs+1"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
QstCod,AnsInd);
|
||||
|
@ -3638,7 +3652,7 @@ static void Rmt_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Register that I have answered this game *****************/
|
||||
/******************* Register that I have answered a game ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Rmt_RegisterIHaveAnsweredGame (long GamCod)
|
||||
|
@ -3654,7 +3668,7 @@ static void Rmt_RegisterIHaveAnsweredGame (long GamCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Register that you have answered this game ******************/
|
||||
/******************** Check if I have answered a game ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static bool Rmt_CheckIfIHaveAnsweredGame (long GamCod)
|
||||
|
@ -3669,7 +3683,7 @@ static bool Rmt_CheckIfIHaveAnsweredGame (long GamCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Register that you have answered this game *****************/
|
||||
/************** Get number of users who have answered a game *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned Rmt_GetNumUsrsWhoHaveAnsweredGame (long GamCod)
|
||||
|
@ -3683,7 +3697,7 @@ static unsigned Rmt_GetNumUsrsWhoHaveAnsweredGame (long GamCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get number of courses with games *********************/
|
||||
/********************* Get number of courses with games **********************/
|
||||
/*****************************************************************************/
|
||||
// Returns the number of courses with games for courses
|
||||
// in this location (all the platform, current degree or current course)
|
||||
|
@ -3772,7 +3786,7 @@ unsigned Rmt_GetNumCoursesWithCrsGames (Sco_Scope_t Scope)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get number of games for courses **********************/
|
||||
/********************* Get number of games for courses ***********************/
|
||||
/*****************************************************************************/
|
||||
// Returns the number of games for courses
|
||||
// in this location (all the platform, current degree or current course)
|
||||
|
@ -3871,7 +3885,7 @@ unsigned Rmt_GetNumCrsGames (Sco_Scope_t Scope,unsigned *NumNotif)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Get average number of questions per course game **************/
|
||||
/************* Get average number of questions per course game ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
float Rmt_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
||||
|
@ -3972,4 +3986,3 @@ float Rmt_GetNumQstsPerCrsGame (Sco_Scope_t Scope)
|
|||
|
||||
return NumQstsPerGame;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ void Rmt_RemoveGroupsOfType (long GrpTypCod);
|
|||
void Rmt_RemoveGames (Sco_Scope_t Scope,long Cod);
|
||||
|
||||
void Rmt_RequestEditQuestion (void);
|
||||
void Rmt_ReceiveQst (void);
|
||||
// void Rmt_ReceiveQst (void);
|
||||
|
||||
void Rmt_AddTstQuestionsToGame (void);
|
||||
|
||||
|
|
204
swad_test.c
204
swad_test.c
|
@ -1381,210 +1381,6 @@ void Tst_ShowFormAskSelectTstsForGame (long GamCod)
|
|||
|
||||
/* Free structure that stores the query result */
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
extern const char *Hlp_ASSESSMENT_Games_questions;
|
||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||
extern const char *Txt_Question;
|
||||
extern const char *Txt_New_question;
|
||||
extern const char *Txt_Stem;
|
||||
extern const char *Txt_Type;
|
||||
extern const char *Txt_SURVEY_STR_ANSWER_TYPES[Rmt_NUM_ANS_TYPES];
|
||||
extern const char *Txt_Save;
|
||||
extern const char *Txt_Create_question;
|
||||
char Query[256];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumAns;
|
||||
unsigned NumAnswers = 0;
|
||||
Rmt_AnswerType_t AnsType;
|
||||
|
||||
if (Gbl.Action.Act == ActEdiOneGamQst) // If no receiving the question, but editing a new or existing question
|
||||
{
|
||||
if ((GameQst->QstCod > 0)) // If parameter QstCod received ==> question already exists in the database
|
||||
{
|
||||
***** Get the type of answer and the stem from the database *****
|
||||
* Get the question from database *
|
||||
sprintf (Query,"SELECT QstInd,AnsType,Stem FROM gam_questions"
|
||||
" WHERE QstCod=%ld AND GamCod=%ld",
|
||||
GameQst->QstCod,GamCod);
|
||||
DB_QuerySELECT (Query,&mysql_res,"can not get a question");
|
||||
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
* Get question index inside game (row[0]) *
|
||||
if (sscanf (row[0],"%u",&(GameQst->QstInd)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error: wrong question index.");
|
||||
|
||||
* Get the type of answer (row[1]) *
|
||||
GameQst->AnswerType = Rmt_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
|
||||
|
||||
* Get the stem of the question from the database (row[2]) *
|
||||
Str_Copy (Txt,row[2],
|
||||
Cns_MAX_BYTES_TEXT);
|
||||
|
||||
* Free structure that stores the query result *
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
***** Get the answers from the database *****
|
||||
NumAnswers = Rmt_GetAnswersQst (GameQst->QstCod,&mysql_res); // Result: AnsInd,NumUsrs,Answer
|
||||
for (NumAns = 0;
|
||||
NumAns < NumAnswers;
|
||||
NumAns++)
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
if (NumAnswers > Rmt_MAX_ANSWERS_PER_QUESTION)
|
||||
Lay_ShowErrorAndExit ("Wrong answer.");
|
||||
if (!Rmt_AllocateTextChoiceAnswer (GameQst,NumAns))
|
||||
Lay_ShowErrorAndExit (Gbl.Alert.Txt);
|
||||
|
||||
Str_Copy (GameQst->AnsChoice[NumAns].Text,row[2],
|
||||
Rmt_MAX_BYTES_ANSWER);
|
||||
}
|
||||
* Free structure that stores the query result *
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
}
|
||||
|
||||
***** Start box *****
|
||||
if (GameQst->QstCod > 0) // If the question already has assigned a code
|
||||
{
|
||||
* Parameters for contextual icon *
|
||||
Gbl.Games.GamCodToEdit = GamCod;
|
||||
Gbl.Games.GamQstCodToEdit = GameQst->QstCod;
|
||||
|
||||
sprintf (Gbl.Title,"%s %u",
|
||||
Txt_Question,GameQst->QstInd + 1); // Question index may be 0, 1, 2, 3,...
|
||||
Box_StartBox (NULL,Gbl.Title,Rmt_PutIconToRemoveOneQst,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
}
|
||||
else
|
||||
Box_StartBox (NULL,Txt_New_question,NULL,
|
||||
Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE);
|
||||
|
||||
***** Start form *****
|
||||
Act_FormStart (ActRcvGamQst);
|
||||
Rmt_PutParamGameCod (GamCod);
|
||||
if (GameQst->QstCod > 0) // If the question already has assigned a code
|
||||
Rmt_PutParamQstCod (GameQst->QstCod);
|
||||
|
||||
***** Start table *****
|
||||
Tbl_StartTableWide (2);
|
||||
|
||||
***** Stem *****
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"RIGHT_TOP\">"
|
||||
"<label for=\"Txt\" class=\"%s\">%s:</label>"
|
||||
"</td>"
|
||||
"<td class=\"LEFT_TOP\">"
|
||||
"<textarea id=\"Txt\" name=\"Txt\""
|
||||
" cols=\"60\" rows=\"4\">"
|
||||
"%s"
|
||||
"</textarea>"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
The_ClassForm[Gbl.Prefs.Theme],Txt_Stem,
|
||||
Txt);
|
||||
|
||||
***** Type of answer *****
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"%s RIGHT_TOP\">"
|
||||
"%s:"
|
||||
"</td>"
|
||||
"<td class=\"%s LEFT_TOP\">",
|
||||
The_ClassForm[Gbl.Prefs.Theme],
|
||||
Txt_Type,
|
||||
The_ClassForm[Gbl.Prefs.Theme]);
|
||||
for (AnsType = (Rmt_AnswerType_t) 0;
|
||||
AnsType < Rmt_NUM_ANS_TYPES;
|
||||
AnsType++)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<label>"
|
||||
"<input type=\"radio\" name=\"AnswerType\""
|
||||
" value=\"%u\"",
|
||||
(unsigned) AnsType);
|
||||
if (AnsType == GameQst->AnswerType)
|
||||
fprintf (Gbl.F.Out," checked=\"checked\"");
|
||||
fprintf (Gbl.F.Out," />"
|
||||
"%s"
|
||||
"</label><br />",
|
||||
Txt_SURVEY_STR_ANSWER_TYPES[AnsType]);
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</td>"
|
||||
"</tr>");
|
||||
|
||||
***** Answers *****
|
||||
* Unique or multiple choice answers *
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td></td>"
|
||||
"<td class=\"LEFT_TOP\">");
|
||||
Tbl_StartTable (2);
|
||||
for (NumAns = 0;
|
||||
NumAns < Rmt_MAX_ANSWERS_PER_QUESTION;
|
||||
NumAns++)
|
||||
{
|
||||
* Label with the number of the answer *
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"RIGHT_TOP\">"
|
||||
"<label for=\"AnsStr%u\" class=\"%s\">%u)</label>"
|
||||
"</td>",
|
||||
NumAns,The_ClassForm[Gbl.Prefs.Theme],NumAns + 1);
|
||||
|
||||
* Answer text *
|
||||
fprintf (Gbl.F.Out,"<td class=\"RIGHT_TOP\">"
|
||||
"<textarea id=\"AnsStr%u\" name=\"AnsStr%u\""
|
||||
" cols=\"50\" rows=\"1\">",
|
||||
NumAns,NumAns);
|
||||
if (GameQst->AnsChoice[NumAns].Text)
|
||||
fprintf (Gbl.F.Out,"%s",GameQst->AnsChoice[NumAns].Text);
|
||||
fprintf (Gbl.F.Out,"</textarea>"
|
||||
"</td>"
|
||||
"</tr>");
|
||||
}
|
||||
Tbl_EndTable ();
|
||||
fprintf (Gbl.F.Out,"</td>"
|
||||
"</tr>");
|
||||
|
||||
***** End table *****
|
||||
Tbl_EndTable ();
|
||||
|
||||
***** Send button *****
|
||||
if (GameQst->QstCod > 0) // If the question already has assigned a code
|
||||
Btn_PutConfirmButton (Txt_Save);
|
||||
else
|
||||
Btn_PutCreateButton (Txt_Create_question);
|
||||
|
||||
***** End form *****
|
||||
Act_FormEnd ();
|
||||
|
||||
***** End box *****
|
||||
Box_EndBox ();
|
||||
|
||||
***** Free memory for answers *****
|
||||
Rmt_FreeTextChoiceAnswers (GameQst,NumAnswers);
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue