mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-01 06:15:31 +02:00
Version 17.0.3
This commit is contained in:
parent
69afbde17f
commit
f63a0c9b90
|
@ -2389,6 +2389,7 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
.GAM_PLAY_CONTAINER
|
.GAM_PLAY_CONTAINER
|
||||||
{
|
{
|
||||||
box-sizing:border-box;
|
box-sizing:border-box;
|
||||||
|
display:table;
|
||||||
margin:5%;
|
margin:5%;
|
||||||
}
|
}
|
||||||
.GAM_PLAY_NUM_QST
|
.GAM_PLAY_NUM_QST
|
||||||
|
@ -2401,17 +2402,20 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
font-size:48pt;
|
font-size:48pt;
|
||||||
font-weight:bold;
|
font-weight:bold;
|
||||||
}
|
}
|
||||||
.GAM_PLAY_QST_STEM
|
.GAM_PLAY_QST_CONTAINER
|
||||||
{
|
{
|
||||||
width:85%;
|
width:85%;
|
||||||
float:left;
|
float:left;
|
||||||
/* position:relative; */
|
/* position:relative; */
|
||||||
padding-bottom:24pt;
|
}
|
||||||
|
.GAM_PLAY_QST
|
||||||
|
{
|
||||||
color:#404040;
|
color:#404040;
|
||||||
font-size:24pt;
|
font-size:24pt;
|
||||||
}
|
}
|
||||||
.GAM_PLAY_CONTINUE_CONTAINER
|
.GAM_PLAY_CONTINUE_CONTAINER
|
||||||
{
|
{
|
||||||
|
clear:all;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
}
|
}
|
||||||
.GAM_PLAY_CONTINUE_CONTAINER a
|
.GAM_PLAY_CONTINUE_CONTAINER a
|
||||||
|
|
|
@ -494,6 +494,7 @@ Assessment:
|
||||||
NEW. ActPlyGam Start playing a game
|
NEW. ActPlyGam Start playing a game
|
||||||
NEW. ActPlyGam1stQst Show first question when playing a game
|
NEW. ActPlyGam1stQst Show first question when playing a game
|
||||||
NEW. ActPlyGamNxtQst Show next question when playing a game
|
NEW. ActPlyGamNxtQst Show next question when playing a game
|
||||||
|
NEW. ActPlyGamAns Show answers of current question when playing a game
|
||||||
NEW. ActAnsGam Answer a game
|
NEW. ActAnsGam Answer a game
|
||||||
NEW. ActFrmNewGam Form to create a new game
|
NEW. ActFrmNewGam Form to create a new game
|
||||||
NEW. ActEdiOneGam Edit one game
|
NEW. ActEdiOneGam Edit one game
|
||||||
|
@ -1959,6 +1960,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
||||||
/* ActPlyGam */{1670,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_PlayGame ,NULL},
|
/* ActPlyGam */{1670,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_PlayGame ,NULL},
|
||||||
/* ActPlyGam1stQst */{1671,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_PlayGameNextQuestion ,NULL},
|
/* ActPlyGam1stQst */{1671,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_PlayGameNextQuestion ,NULL},
|
||||||
/* ActPlyGamNxtQst */{1672,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_PlayGameNextQuestion ,NULL},
|
/* ActPlyGamNxtQst */{1672,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_PlayGameNextQuestion ,NULL},
|
||||||
|
/* ActPlyGamAns */{1673,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_PlayGameShowAnswers ,NULL},
|
||||||
/* ActAnsGam */{1651,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ReceiveGameAnswers ,NULL},
|
/* ActAnsGam */{1651,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ReceiveGameAnswers ,NULL},
|
||||||
/* ActFrmNewGam */{1652,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestCreatOrEditGame ,NULL},
|
/* ActFrmNewGam */{1652,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestCreatOrEditGame ,NULL},
|
||||||
/* ActEdiOneGam */{1653,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestCreatOrEditGame ,NULL},
|
/* ActEdiOneGam */{1653,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestCreatOrEditGame ,NULL},
|
||||||
|
@ -4726,6 +4728,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
|
||||||
ActPlyGam, // #1670
|
ActPlyGam, // #1670
|
||||||
ActPlyGam1stQst, // #1671
|
ActPlyGam1stQst, // #1671
|
||||||
ActPlyGamNxtQst, // #1672
|
ActPlyGamNxtQst, // #1672
|
||||||
|
ActPlyGamAns, // #1673
|
||||||
};
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -58,9 +58,9 @@ 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_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 33 + 24 + 115 + 95 + 416 + 165 + 172 + 42 + 14 + 97)
|
#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 33 + 24 + 115 + 96 + 416 + 165 + 172 + 42 + 14 + 97)
|
||||||
|
|
||||||
#define Act_MAX_ACTION_COD 1672
|
#define Act_MAX_ACTION_COD 1673
|
||||||
|
|
||||||
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 12
|
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 12
|
||||||
|
|
||||||
|
@ -490,51 +490,52 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
|
||||||
#define ActPlyGam (ActChgCalCrs1stDay + 50)
|
#define ActPlyGam (ActChgCalCrs1stDay + 50)
|
||||||
#define ActPlyGam1stQst (ActChgCalCrs1stDay + 51)
|
#define ActPlyGam1stQst (ActChgCalCrs1stDay + 51)
|
||||||
#define ActPlyGamNxtQst (ActChgCalCrs1stDay + 52)
|
#define ActPlyGamNxtQst (ActChgCalCrs1stDay + 52)
|
||||||
#define ActAnsGam (ActChgCalCrs1stDay + 53)
|
#define ActPlyGamAns (ActChgCalCrs1stDay + 53)
|
||||||
#define ActFrmNewGam (ActChgCalCrs1stDay + 54)
|
#define ActAnsGam (ActChgCalCrs1stDay + 54)
|
||||||
#define ActEdiOneGam (ActChgCalCrs1stDay + 55)
|
#define ActFrmNewGam (ActChgCalCrs1stDay + 55)
|
||||||
#define ActNewGam (ActChgCalCrs1stDay + 56)
|
#define ActEdiOneGam (ActChgCalCrs1stDay + 56)
|
||||||
#define ActChgGam (ActChgCalCrs1stDay + 57)
|
#define ActNewGam (ActChgCalCrs1stDay + 57)
|
||||||
#define ActReqRemGam (ActChgCalCrs1stDay + 58)
|
#define ActChgGam (ActChgCalCrs1stDay + 58)
|
||||||
#define ActRemGam (ActChgCalCrs1stDay + 59)
|
#define ActReqRemGam (ActChgCalCrs1stDay + 59)
|
||||||
#define ActReqRstGam (ActChgCalCrs1stDay + 60)
|
#define ActRemGam (ActChgCalCrs1stDay + 60)
|
||||||
#define ActRstGam (ActChgCalCrs1stDay + 61)
|
#define ActReqRstGam (ActChgCalCrs1stDay + 61)
|
||||||
#define ActHidGam (ActChgCalCrs1stDay + 62)
|
#define ActRstGam (ActChgCalCrs1stDay + 62)
|
||||||
#define ActShoGam (ActChgCalCrs1stDay + 63)
|
#define ActHidGam (ActChgCalCrs1stDay + 63)
|
||||||
#define ActAddOneGamQst (ActChgCalCrs1stDay + 64)
|
#define ActShoGam (ActChgCalCrs1stDay + 64)
|
||||||
#define ActGamLstTstQst (ActChgCalCrs1stDay + 65)
|
#define ActAddOneGamQst (ActChgCalCrs1stDay + 65)
|
||||||
#define ActAddTstQstToGam (ActChgCalCrs1stDay + 66)
|
#define ActGamLstTstQst (ActChgCalCrs1stDay + 66)
|
||||||
#define ActReqRemGamQst (ActChgCalCrs1stDay + 67)
|
#define ActAddTstQstToGam (ActChgCalCrs1stDay + 67)
|
||||||
#define ActRemGamQst (ActChgCalCrs1stDay + 68)
|
#define ActReqRemGamQst (ActChgCalCrs1stDay + 68)
|
||||||
#define ActUp_GamQst (ActChgCalCrs1stDay + 69)
|
#define ActRemGamQst (ActChgCalCrs1stDay + 69)
|
||||||
#define ActDwnGamQst (ActChgCalCrs1stDay + 70)
|
#define ActUp_GamQst (ActChgCalCrs1stDay + 70)
|
||||||
|
#define ActDwnGamQst (ActChgCalCrs1stDay + 71)
|
||||||
|
|
||||||
#define ActSeeOneSvy (ActChgCalCrs1stDay + 71)
|
#define ActSeeOneSvy (ActChgCalCrs1stDay + 72)
|
||||||
#define ActAnsSvy (ActChgCalCrs1stDay + 72)
|
#define ActAnsSvy (ActChgCalCrs1stDay + 73)
|
||||||
#define ActFrmNewSvy (ActChgCalCrs1stDay + 73)
|
#define ActFrmNewSvy (ActChgCalCrs1stDay + 74)
|
||||||
#define ActEdiOneSvy (ActChgCalCrs1stDay + 74)
|
#define ActEdiOneSvy (ActChgCalCrs1stDay + 75)
|
||||||
#define ActNewSvy (ActChgCalCrs1stDay + 75)
|
#define ActNewSvy (ActChgCalCrs1stDay + 76)
|
||||||
#define ActChgSvy (ActChgCalCrs1stDay + 76)
|
#define ActChgSvy (ActChgCalCrs1stDay + 77)
|
||||||
#define ActReqRemSvy (ActChgCalCrs1stDay + 77)
|
#define ActReqRemSvy (ActChgCalCrs1stDay + 78)
|
||||||
#define ActRemSvy (ActChgCalCrs1stDay + 78)
|
#define ActRemSvy (ActChgCalCrs1stDay + 79)
|
||||||
#define ActReqRstSvy (ActChgCalCrs1stDay + 79)
|
#define ActReqRstSvy (ActChgCalCrs1stDay + 80)
|
||||||
#define ActRstSvy (ActChgCalCrs1stDay + 80)
|
#define ActRstSvy (ActChgCalCrs1stDay + 81)
|
||||||
#define ActHidSvy (ActChgCalCrs1stDay + 81)
|
#define ActHidSvy (ActChgCalCrs1stDay + 82)
|
||||||
#define ActShoSvy (ActChgCalCrs1stDay + 82)
|
#define ActShoSvy (ActChgCalCrs1stDay + 83)
|
||||||
#define ActEdiOneSvyQst (ActChgCalCrs1stDay + 83)
|
#define ActEdiOneSvyQst (ActChgCalCrs1stDay + 84)
|
||||||
#define ActRcvSvyQst (ActChgCalCrs1stDay + 84)
|
#define ActRcvSvyQst (ActChgCalCrs1stDay + 85)
|
||||||
#define ActReqRemSvyQst (ActChgCalCrs1stDay + 85)
|
#define ActReqRemSvyQst (ActChgCalCrs1stDay + 86)
|
||||||
#define ActRemSvyQst (ActChgCalCrs1stDay + 86)
|
#define ActRemSvyQst (ActChgCalCrs1stDay + 87)
|
||||||
|
|
||||||
#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 87)
|
#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 88)
|
||||||
#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 88)
|
#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 89)
|
||||||
#define ActEdiExaAnn (ActChgCalCrs1stDay + 89)
|
#define ActEdiExaAnn (ActChgCalCrs1stDay + 90)
|
||||||
#define ActRcvExaAnn (ActChgCalCrs1stDay + 90)
|
#define ActRcvExaAnn (ActChgCalCrs1stDay + 91)
|
||||||
#define ActPrnExaAnn (ActChgCalCrs1stDay + 91)
|
#define ActPrnExaAnn (ActChgCalCrs1stDay + 92)
|
||||||
#define ActReqRemExaAnn (ActChgCalCrs1stDay + 92)
|
#define ActReqRemExaAnn (ActChgCalCrs1stDay + 93)
|
||||||
#define ActRemExaAnn (ActChgCalCrs1stDay + 93)
|
#define ActRemExaAnn (ActChgCalCrs1stDay + 94)
|
||||||
#define ActHidExaAnn (ActChgCalCrs1stDay + 94)
|
#define ActHidExaAnn (ActChgCalCrs1stDay + 95)
|
||||||
#define ActShoExaAnn (ActChgCalCrs1stDay + 95)
|
#define ActShoExaAnn (ActChgCalCrs1stDay + 96)
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************************** Files tab **********************************/
|
/******************************** Files tab **********************************/
|
||||||
|
|
|
@ -250,13 +250,17 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 17.0.2 (2017-09-14)"
|
#define Log_PLATFORM_VERSION "SWAD 17.0.3 (2017-09-14)"
|
||||||
#define CSS_FILE "swad17.0.css"
|
#define CSS_FILE "swad17.0.css"
|
||||||
#define JS_FILE "swad16.206.3.js"
|
#define JS_FILE "swad16.206.3.js"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 17.0.3: Sep 14, 2017 Action to show current question with answers when playing a game. (227350 lines)
|
||||||
|
1 change necessary in database:
|
||||||
|
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1673','es','N','Mostrar respuestas de pregunta juego');
|
||||||
|
|
||||||
Version 17.0.2: Sep 14, 2017 Action to show next question when playing a game. (227293 lines)
|
Version 17.0.2: Sep 14, 2017 Action to show next question when playing a game. (227293 lines)
|
||||||
2 changes necessary in database:
|
2 changes necessary in database:
|
||||||
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1671','es','N','Mostrar primera pregunta juego');
|
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1671','es','N','Mostrar primera pregunta juego');
|
||||||
|
|
120
swad_game.c
120
swad_game.c
|
@ -125,11 +125,11 @@ static void Gam_PutParamQstInd (unsigned QstInd);
|
||||||
static unsigned Gam_GetParamQstInd (void);
|
static unsigned Gam_GetParamQstInd (void);
|
||||||
static void Gam_RemAnswersOfAQuestion (long QstCod);
|
static void Gam_RemAnswersOfAQuestion (long QstCod);
|
||||||
|
|
||||||
static unsigned Gam_GetQstIndFromQstCod (long GamCod,long QstCod);
|
static int Gam_GetQstIndFromQstCod (long GamCod,long QstCod); // TODO: Remove this function because a question code can be repeated
|
||||||
static long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd);
|
static long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd);
|
||||||
static int Gam_GetMaxQuestionIndexInGame (long GamCod);
|
static int Gam_GetMaxQuestionIndexInGame (long GamCod);
|
||||||
static unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd);
|
static int Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd);
|
||||||
static unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd);
|
static int Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd);
|
||||||
static void Gam_ListGameQuestions (struct Game *Game);
|
static void Gam_ListGameQuestions (struct Game *Game);
|
||||||
static void Gam_ListOneOrMoreQuestionsForEdition (struct Game *Game,
|
static void Gam_ListOneOrMoreQuestionsForEdition (struct Game *Game,
|
||||||
unsigned NumQsts,
|
unsigned NumQsts,
|
||||||
|
@ -151,6 +151,8 @@ static void Gam_ExchangeQuestions (long GamCod,
|
||||||
unsigned QstIndTop,unsigned QstIndBottom);
|
unsigned QstIndTop,unsigned QstIndBottom);
|
||||||
|
|
||||||
static void Gam_PutBigButtonToStartGame (long GamCod);
|
static void Gam_PutBigButtonToStartGame (long GamCod);
|
||||||
|
|
||||||
|
static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers);
|
||||||
static void Gam_PutBigButtonToContinue (Act_Action_t NextAction,
|
static void Gam_PutBigButtonToContinue (Act_Action_t NextAction,
|
||||||
long GamCod,unsigned QstInd);
|
long GamCod,unsigned QstInd);
|
||||||
|
|
||||||
|
@ -2565,28 +2567,30 @@ static void Gam_RemAnswersOfAQuestion (long QstCod)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Get next question index in a game **********************/
|
/******************** Get next question index in a game **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
// TODO: Remove this function because a question code can be repeated
|
||||||
|
|
||||||
static unsigned Gam_GetQstIndFromQstCod (long GamCod,long QstCod)
|
static int Gam_GetQstIndFromQstCod (long GamCod,long QstCod)
|
||||||
{
|
{
|
||||||
char Query[256];
|
char Query[256];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned QstInd = 0;
|
int QstInd = -1;
|
||||||
|
|
||||||
/***** Get number of games with a field value from database *****/
|
/***** Get number of games with a field value from database *****/
|
||||||
sprintf (Query,"SELECT QstInd FROM gam_questions"
|
sprintf (Query,"SELECT QstInd FROM gam_questions"
|
||||||
" WHERE GamCod=%ld AND QstCod=%ld",
|
" WHERE GamCod=%ld AND QstCod=%ld",
|
||||||
GamCod,QstCod);
|
GamCod,QstCod);
|
||||||
if (!DB_QuerySELECT (Query,&mysql_res,"can not get question index"))
|
if (!DB_QuerySELECT (Query,&mysql_res,"can not get question index"))
|
||||||
{
|
{
|
||||||
Ale_ShowAlert (Ale_INFO,Query);
|
Ale_ShowAlert (Ale_INFO,Query);
|
||||||
Lay_ShowErrorAndExit ("Error when getting question index.");
|
Lay_ShowErrorAndExit ("Error when getting question index.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get question index (row[0]) *****/
|
/***** Get question index (row[0]) *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
if (sscanf (row[0],"%u",&QstInd) != 1)
|
if (row[0])
|
||||||
Lay_ShowErrorAndExit ("Error when getting question index.");
|
if (sscanf (row[0],"%d",&QstInd) != 1)
|
||||||
|
Lay_ShowErrorAndExit ("Error when getting question index.");
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -2654,13 +2658,15 @@ static int Gam_GetMaxQuestionIndexInGame (long GamCod)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********** Get previous question index to a given index in a game **********/
|
/*********** Get previous question index to a given index in a game **********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
// Question index can be 0, 1, 2,...
|
||||||
|
// Return -1 if no previous question
|
||||||
|
|
||||||
static unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd)
|
static int Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd)
|
||||||
{
|
{
|
||||||
char Query[256];
|
char Query[256];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned PrevQstInd;
|
int PrevQstInd = -1;
|
||||||
|
|
||||||
/***** Get previous question index in a game from database *****/
|
/***** Get previous question index in a game from database *****/
|
||||||
// Although indexes are always continuous...
|
// Although indexes are always continuous...
|
||||||
|
@ -2673,8 +2679,9 @@ static unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd)
|
||||||
|
|
||||||
/***** Get previous question index (row[0]) *****/
|
/***** Get previous question index (row[0]) *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
if (sscanf (row[0],"%u",&PrevQstInd) != 1)
|
if (row[0])
|
||||||
Lay_ShowErrorAndExit ("Error when getting previous question index.");
|
if (sscanf (row[0],"%d",&PrevQstInd) != 1)
|
||||||
|
Lay_ShowErrorAndExit ("Error when getting previous question index.");
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -2685,13 +2692,15 @@ static unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************* Get next question index to a given index in a game ************/
|
/************* Get next question index to a given index in a game ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
// Question index can be 0, 1, 2,...
|
||||||
|
// Return -1 if no next question
|
||||||
|
|
||||||
static unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd)
|
static int Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd)
|
||||||
{
|
{
|
||||||
char Query[256];
|
char Query[256];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NextQstInd;
|
int NextQstInd = -1;
|
||||||
|
|
||||||
/***** Get next question index in a game from database *****/
|
/***** Get next question index in a game from database *****/
|
||||||
// Although indexes are always continuous...
|
// Although indexes are always continuous...
|
||||||
|
@ -2704,8 +2713,9 @@ static unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd)
|
||||||
|
|
||||||
/***** Get next question index (row[0]) *****/
|
/***** Get next question index (row[0]) *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
if (sscanf (row[0],"%u",&NextQstInd) != 1)
|
if (row[0])
|
||||||
Lay_ShowErrorAndExit ("Error when getting next question index.");
|
if (sscanf (row[0],"%d",&NextQstInd) != 1)
|
||||||
|
Lay_ShowErrorAndExit ("Error when getting next question index.");
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -3233,7 +3243,7 @@ void Gam_RequestRemoveQst (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||||
|
|
||||||
/* Get question index */
|
/* Get question index */
|
||||||
QstInd = Gam_GetQstIndFromQstCod (Game.GamCod,QstCod);
|
QstInd = (unsigned) Gam_GetQstIndFromQstCod (Game.GamCod,QstCod); // TODO: Remove this function because a question code can be repeated
|
||||||
|
|
||||||
/***** Show question and button to remove question *****/
|
/***** Show question and button to remove question *****/
|
||||||
Gbl.Games.CurrentGamCod = Game.GamCod;
|
Gbl.Games.CurrentGamCod = Game.GamCod;
|
||||||
|
@ -3273,7 +3283,7 @@ void Gam_RemoveQst (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||||
|
|
||||||
/* Get question index */
|
/* Get question index */
|
||||||
QstInd = Gam_GetQstIndFromQstCod (Game.GamCod,QstCod);
|
QstInd = (unsigned) Gam_GetQstIndFromQstCod (Game.GamCod,QstCod); // TODO: Remove this function because a question code can be repeated
|
||||||
|
|
||||||
/***** Remove the question from all the tables *****/
|
/***** Remove the question from all the tables *****/
|
||||||
/* Remove answers from this test question */
|
/* Remove answers from this test question */
|
||||||
|
@ -3312,8 +3322,8 @@ void Gam_MoveUpQst (void)
|
||||||
extern const char *Txt_The_question_has_been_moved_up;
|
extern const char *Txt_The_question_has_been_moved_up;
|
||||||
struct Game Game;
|
struct Game Game;
|
||||||
long QstCod;
|
long QstCod;
|
||||||
unsigned QstIndTop;
|
int QstIndTop;
|
||||||
unsigned QstIndBottom;
|
int QstIndBottom;
|
||||||
|
|
||||||
/***** Get parameters from form *****/
|
/***** Get parameters from form *****/
|
||||||
/* Get game code */
|
/* Get game code */
|
||||||
|
@ -3325,17 +3335,19 @@ void Gam_MoveUpQst (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||||
|
|
||||||
/* Get question index */
|
/* Get question index */
|
||||||
QstIndBottom = Gam_GetQstIndFromQstCod (Game.GamCod,QstCod);
|
QstIndBottom = Gam_GetQstIndFromQstCod (Game.GamCod,QstCod); // TODO: Remove this function because a question code can be repeated
|
||||||
|
|
||||||
/***** Move up question *****/
|
/***** Move up question *****/
|
||||||
if (QstIndBottom > 0)
|
if (QstIndBottom > 0)
|
||||||
{
|
{
|
||||||
/* Indexes of questions to be exchanged */
|
/* Indexes of questions to be exchanged */
|
||||||
QstIndTop = Gam_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom);
|
QstIndTop = Gam_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom);
|
||||||
|
if (QstIndTop < 0)
|
||||||
|
Lay_ShowErrorAndExit ("Wrong index of question.");
|
||||||
|
|
||||||
/* Exchange questions */
|
/* Exchange questions */
|
||||||
Gam_ExchangeQuestions (Game.GamCod,
|
Gam_ExchangeQuestions (Game.GamCod,
|
||||||
QstIndTop,QstIndBottom);
|
(unsigned) QstIndTop,(unsigned) QstIndBottom);
|
||||||
|
|
||||||
/* Success alert */
|
/* Success alert */
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_question_has_been_moved_up);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_question_has_been_moved_up);
|
||||||
|
@ -3357,8 +3369,8 @@ void Gam_MoveDownQst (void)
|
||||||
extern const char *Txt_The_question_has_been_moved_down;
|
extern const char *Txt_The_question_has_been_moved_down;
|
||||||
struct Game Game;
|
struct Game Game;
|
||||||
long QstCod;
|
long QstCod;
|
||||||
unsigned QstIndTop;
|
int QstIndTop;
|
||||||
unsigned QstIndBottom;
|
int QstIndBottom;
|
||||||
int MaxQstInd; // -1 if no questions
|
int MaxQstInd; // -1 if no questions
|
||||||
|
|
||||||
/***** Get parameters from form *****/
|
/***** Get parameters from form *****/
|
||||||
|
@ -3371,20 +3383,23 @@ void Gam_MoveDownQst (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||||
|
|
||||||
/* Get question index */
|
/* Get question index */
|
||||||
QstIndTop = Gam_GetQstIndFromQstCod (Game.GamCod,QstCod);
|
QstIndTop = Gam_GetQstIndFromQstCod (Game.GamCod,QstCod); // TODO: Remove this function because a question code can be repeated
|
||||||
|
|
||||||
/* Get maximum question index */
|
/* Get maximum question index */
|
||||||
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod);
|
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod);
|
||||||
|
|
||||||
/***** Move down question *****/
|
/***** Move down question *****/
|
||||||
if (MaxQstInd > 0)
|
if (MaxQstInd > 0)
|
||||||
if (QstIndTop < (unsigned) MaxQstInd)
|
if (QstIndTop < MaxQstInd)
|
||||||
{
|
{
|
||||||
/* Indexes of questions to be exchanged */
|
/* Indexes of questions to be exchanged */
|
||||||
QstIndBottom = Gam_GetNextQuestionIndexInGame (Game.GamCod,QstIndTop);
|
QstIndBottom = Gam_GetNextQuestionIndexInGame (Game.GamCod,QstIndTop);
|
||||||
|
if (QstIndBottom < 0)
|
||||||
|
Lay_ShowErrorAndExit ("Wrong index of question.");
|
||||||
|
|
||||||
/* Exchange questions */
|
/* Exchange questions */
|
||||||
Gam_ExchangeQuestions (Game.GamCod,QstIndTop,QstIndBottom);
|
Gam_ExchangeQuestions (Game.GamCod,
|
||||||
|
(unsigned) QstIndTop,(unsigned) QstIndBottom);
|
||||||
|
|
||||||
/* Success alert */
|
/* Success alert */
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_question_has_been_moved_down);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_question_has_been_moved_down);
|
||||||
|
@ -3501,12 +3516,31 @@ static void Gam_PutBigButtonToStartGame (long GamCod)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Gam_PlayGameNextQuestion (void)
|
void Gam_PlayGameNextQuestion (void)
|
||||||
|
{
|
||||||
|
Gam_PlayGameShowQuestionAndAnswers (false); // Don't show answers
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************ Show question and its answers when playing a game **************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Gam_PlayGameShowAnswers (void)
|
||||||
|
{
|
||||||
|
Gam_PlayGameShowQuestionAndAnswers (true); // Show answers
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************ Show question and its answers when playing a game **************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Gam_PlayGameShowQuestionAndAnswers (bool ShowAnswers)
|
||||||
{
|
{
|
||||||
char Query[256];
|
char Query[256];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
struct Game Game;
|
struct Game Game;
|
||||||
unsigned QstInd;
|
unsigned QstInd;
|
||||||
|
int NxtQstInd;
|
||||||
|
|
||||||
/***** Get parameters *****/
|
/***** Get parameters *****/
|
||||||
/* Get game code */
|
/* Get game code */
|
||||||
|
@ -3539,6 +3573,7 @@ void Gam_PlayGameNextQuestion (void)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/***** Show question *****/
|
/***** Show question *****/
|
||||||
|
/* Start container for number and question */
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_CONTAINER\">");
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_CONTAINER\">");
|
||||||
|
|
||||||
/* Write number of question */
|
/* Write number of question */
|
||||||
|
@ -3546,16 +3581,31 @@ void Gam_PlayGameNextQuestion (void)
|
||||||
QstInd + 1);
|
QstInd + 1);
|
||||||
|
|
||||||
/* Write the stem (row[1]) and the image (row[2], row[3], row[4]) */
|
/* Write the stem (row[1]) and the image (row[2], row[3], row[4]) */
|
||||||
Tst_WriteQstStem (row[1],"GAM_PLAY_QST_STEM");
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_QST_CONTAINER\">");
|
||||||
|
Tst_WriteQstStem (row[1],"GAM_PLAY_QST");
|
||||||
Img_GetImageNameTitleAndURLFromRow (row[2],row[3],row[4],&Gbl.Test.Image);
|
Img_GetImageNameTitleAndURLFromRow (row[2],row[3],row[4],&Gbl.Test.Image);
|
||||||
Img_ShowImage (&Gbl.Test.Image,
|
Img_ShowImage (&Gbl.Test.Image,
|
||||||
"TEST_IMG_EDIT_LIST_STEM_CONTAINER",
|
"TEST_IMG_EDIT_LIST_STEM_CONTAINER",
|
||||||
"TEST_IMG_EDIT_LIST_STEM");
|
"TEST_IMG_EDIT_LIST_STEM");
|
||||||
|
if (ShowAnswers)
|
||||||
/***** Put button to show answers *****/
|
fprintf (Gbl.F.Out,"answers");
|
||||||
Gam_PutBigButtonToContinue (ActPlyGamNxtQst,Game.GamCod,QstInd);
|
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
|
|
||||||
|
/* End container for number and question */
|
||||||
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
|
|
||||||
|
/***** Put button to continue *****/
|
||||||
|
if (ShowAnswers)
|
||||||
|
{
|
||||||
|
/* Get index of the next question */
|
||||||
|
NxtQstInd = Gam_GetNextQuestionIndexInGame (Game.GamCod,QstInd);
|
||||||
|
if (NxtQstInd > 0)
|
||||||
|
/* Put button to show next question */
|
||||||
|
Gam_PutBigButtonToContinue (ActPlyGamNxtQst,Game.GamCod,(unsigned) NxtQstInd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Put button to show answers */
|
||||||
|
Gam_PutBigButtonToContinue (ActPlyGamAns,Game.GamCod,QstInd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3577,8 +3627,8 @@ static void Gam_PutBigButtonToContinue (Act_Action_t NextAction,
|
||||||
|
|
||||||
/***** Put icon with link *****/
|
/***** Put icon with link *****/
|
||||||
Act_LinkFormSubmit (Txt_Continue,"GAM_PLAY_CONTINUE ICO_HIGHLIGHT",NULL);
|
Act_LinkFormSubmit (Txt_Continue,"GAM_PLAY_CONTINUE ICO_HIGHLIGHT",NULL);
|
||||||
fprintf (Gbl.F.Out,"<img src=\"%s/step-forward64x64.png\" alt=\"%s\" title=\"%s\""
|
fprintf (Gbl.F.Out,"<img src=\"%s/step-forward64x64.png\""
|
||||||
" class=\"ICO64x64\" />"
|
" alt=\"%s\" title=\"%s\" class=\"ICO64x64\" />"
|
||||||
"<br />"
|
"<br />"
|
||||||
"%s",
|
"%s",
|
||||||
Gbl.Prefs.IconsURL,Txt_Continue,Txt_Continue,
|
Gbl.Prefs.IconsURL,Txt_Continue,Txt_Continue,
|
||||||
|
|
|
@ -126,6 +126,7 @@ void Gam_PlayGame (void);
|
||||||
|
|
||||||
void Gam_ReceiveGameAnswers (void);
|
void Gam_ReceiveGameAnswers (void);
|
||||||
void Gam_PlayGameNextQuestion (void);
|
void Gam_PlayGameNextQuestion (void);
|
||||||
|
void Gam_PlayGameShowAnswers (void);
|
||||||
|
|
||||||
unsigned Gam_GetNumCoursesWithCrsGames (Sco_Scope_t Scope);
|
unsigned Gam_GetNumCoursesWithCrsGames (Sco_Scope_t Scope);
|
||||||
unsigned Gam_GetNumCrsGames (Sco_Scope_t Scope);
|
unsigned Gam_GetNumCrsGames (Sco_Scope_t Scope);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user