Version 17.0

This commit is contained in:
Antonio Cañas Vargas 2017-09-13 21:22:52 +02:00
parent 61e6492b60
commit 37eec0c39a
6 changed files with 179 additions and 59 deletions

View File

@ -2389,6 +2389,35 @@ a:hover img.CENTRE_PHOTO_SHOW
vertical-align:top;
}
/********************************** Games ************************************/
.GAM_PLAY_CONTAINER
{
box-sizing:border-box;
margin:5%;
text-align:left;
vertical-align:middle;
}
.GAM_PLAY_NUM_QST
{
display:inline-block;
width:15%;
float:left;
position:relative;
color:#808080;
font-size:48pt;
background:yellow;
}
.GAM_PLAY_QST_STEM
{
display:inline-block;
width:85%;
float:left;
position:relative;
color:#404040;
font-size:24pt;
background:pink;
}
/******************************* Time table **********************************/
#timetable
{

View File

@ -492,6 +492,7 @@ Assessment:
NEW. ActSeeOneGam Show one game
NEW. ActPlyGam Start playing a game
NEW. ActPlyGamNxtQst Show next question when playing a game
NEW. ActAnsGam Answer a game
NEW. ActFrmNewGam Form to create a new game
NEW. ActEdiOneGam Edit one game
@ -1955,6 +1956,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActSeeOneGam */{1650,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Gam_SeeOneGame ,NULL},
/* ActPlyGam */{1670,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Gam_PlayGame ,NULL},
/* ActPlyGamNxtQst */{1671,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BLNK_WINDOW,NULL ,Gam_PlayGameNextQuestion ,NULL},
/* ActAnsGam */{1651,-1,TabUnk,ActSeeAllGam ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Gam_ReceiveGameAnswers ,NULL},
/* ActFrmNewGam */{1652,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Gam_RequestCreatOrEditGame ,NULL},
/* ActEdiOneGam */{1653,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Gam_RequestCreatOrEditGame ,NULL},
@ -4720,6 +4722,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActUp_GamQst, // #1668
ActDwnGamQst, // #1669
ActPlyGam, // #1670
ActPlyGamNxtQst, // #1671
};
/*****************************************************************************/

View File

@ -57,9 +57,9 @@ 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 + 93 + 416 + 165 + 172 + 42 + 14 + 97)
#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 33 + 24 + 115 + 94 + 416 + 165 + 172 + 42 + 14 + 97)
#define Act_MAX_ACTION_COD 1670
#define Act_MAX_ACTION_COD 1671
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 12
@ -487,51 +487,52 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActSeeOneGam (ActChgCalCrs1stDay + 49)
#define ActPlyGam (ActChgCalCrs1stDay + 50)
#define ActAnsGam (ActChgCalCrs1stDay + 51)
#define ActFrmNewGam (ActChgCalCrs1stDay + 52)
#define ActEdiOneGam (ActChgCalCrs1stDay + 53)
#define ActNewGam (ActChgCalCrs1stDay + 54)
#define ActChgGam (ActChgCalCrs1stDay + 55)
#define ActReqRemGam (ActChgCalCrs1stDay + 56)
#define ActRemGam (ActChgCalCrs1stDay + 57)
#define ActReqRstGam (ActChgCalCrs1stDay + 58)
#define ActRstGam (ActChgCalCrs1stDay + 59)
#define ActHidGam (ActChgCalCrs1stDay + 60)
#define ActShoGam (ActChgCalCrs1stDay + 61)
#define ActAddOneGamQst (ActChgCalCrs1stDay + 62)
#define ActGamLstTstQst (ActChgCalCrs1stDay + 63)
#define ActAddTstQstToGam (ActChgCalCrs1stDay + 64)
#define ActReqRemGamQst (ActChgCalCrs1stDay + 65)
#define ActRemGamQst (ActChgCalCrs1stDay + 66)
#define ActUp_GamQst (ActChgCalCrs1stDay + 67)
#define ActDwnGamQst (ActChgCalCrs1stDay + 68)
#define ActPlyGamNxtQst (ActChgCalCrs1stDay + 51)
#define ActAnsGam (ActChgCalCrs1stDay + 52)
#define ActFrmNewGam (ActChgCalCrs1stDay + 53)
#define ActEdiOneGam (ActChgCalCrs1stDay + 54)
#define ActNewGam (ActChgCalCrs1stDay + 55)
#define ActChgGam (ActChgCalCrs1stDay + 56)
#define ActReqRemGam (ActChgCalCrs1stDay + 57)
#define ActRemGam (ActChgCalCrs1stDay + 58)
#define ActReqRstGam (ActChgCalCrs1stDay + 59)
#define ActRstGam (ActChgCalCrs1stDay + 60)
#define ActHidGam (ActChgCalCrs1stDay + 61)
#define ActShoGam (ActChgCalCrs1stDay + 62)
#define ActAddOneGamQst (ActChgCalCrs1stDay + 63)
#define ActGamLstTstQst (ActChgCalCrs1stDay + 64)
#define ActAddTstQstToGam (ActChgCalCrs1stDay + 65)
#define ActReqRemGamQst (ActChgCalCrs1stDay + 66)
#define ActRemGamQst (ActChgCalCrs1stDay + 67)
#define ActUp_GamQst (ActChgCalCrs1stDay + 68)
#define ActDwnGamQst (ActChgCalCrs1stDay + 69)
#define ActSeeOneSvy (ActChgCalCrs1stDay + 69)
#define ActAnsSvy (ActChgCalCrs1stDay + 70)
#define ActFrmNewSvy (ActChgCalCrs1stDay + 71)
#define ActEdiOneSvy (ActChgCalCrs1stDay + 72)
#define ActNewSvy (ActChgCalCrs1stDay + 73)
#define ActChgSvy (ActChgCalCrs1stDay + 74)
#define ActReqRemSvy (ActChgCalCrs1stDay + 75)
#define ActRemSvy (ActChgCalCrs1stDay + 76)
#define ActReqRstSvy (ActChgCalCrs1stDay + 77)
#define ActRstSvy (ActChgCalCrs1stDay + 78)
#define ActHidSvy (ActChgCalCrs1stDay + 79)
#define ActShoSvy (ActChgCalCrs1stDay + 80)
#define ActEdiOneSvyQst (ActChgCalCrs1stDay + 81)
#define ActRcvSvyQst (ActChgCalCrs1stDay + 82)
#define ActReqRemSvyQst (ActChgCalCrs1stDay + 83)
#define ActRemSvyQst (ActChgCalCrs1stDay + 84)
#define ActSeeOneSvy (ActChgCalCrs1stDay + 70)
#define ActAnsSvy (ActChgCalCrs1stDay + 71)
#define ActFrmNewSvy (ActChgCalCrs1stDay + 72)
#define ActEdiOneSvy (ActChgCalCrs1stDay + 73)
#define ActNewSvy (ActChgCalCrs1stDay + 74)
#define ActChgSvy (ActChgCalCrs1stDay + 75)
#define ActReqRemSvy (ActChgCalCrs1stDay + 76)
#define ActRemSvy (ActChgCalCrs1stDay + 77)
#define ActReqRstSvy (ActChgCalCrs1stDay + 78)
#define ActRstSvy (ActChgCalCrs1stDay + 79)
#define ActHidSvy (ActChgCalCrs1stDay + 80)
#define ActShoSvy (ActChgCalCrs1stDay + 81)
#define ActEdiOneSvyQst (ActChgCalCrs1stDay + 82)
#define ActRcvSvyQst (ActChgCalCrs1stDay + 83)
#define ActReqRemSvyQst (ActChgCalCrs1stDay + 84)
#define ActRemSvyQst (ActChgCalCrs1stDay + 85)
#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 85)
#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 86)
#define ActEdiExaAnn (ActChgCalCrs1stDay + 87)
#define ActRcvExaAnn (ActChgCalCrs1stDay + 88)
#define ActPrnExaAnn (ActChgCalCrs1stDay + 89)
#define ActReqRemExaAnn (ActChgCalCrs1stDay + 90)
#define ActRemExaAnn (ActChgCalCrs1stDay + 91)
#define ActHidExaAnn (ActChgCalCrs1stDay + 92)
#define ActShoExaAnn (ActChgCalCrs1stDay + 93)
#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 86)
#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 87)
#define ActEdiExaAnn (ActChgCalCrs1stDay + 88)
#define ActRcvExaAnn (ActChgCalCrs1stDay + 89)
#define ActPrnExaAnn (ActChgCalCrs1stDay + 90)
#define ActReqRemExaAnn (ActChgCalCrs1stDay + 91)
#define ActRemExaAnn (ActChgCalCrs1stDay + 92)
#define ActHidExaAnn (ActChgCalCrs1stDay + 93)
#define ActShoExaAnn (ActChgCalCrs1stDay + 94)
/*****************************************************************************/
/******************************** Files tab **********************************/

View File

@ -250,13 +250,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.254.2 (2017-09-13)"
#define CSS_FILE "swad16.252.2.css"
#define Log_PLATFORM_VERSION "SWAD 17.0 (2017-09-13)"
#define CSS_FILE "swad17.0.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
/*
Version 17.0: Sep 13, 2017 New action to display a game question. (227245 lines)
Version 16.254.2: Sep 13, 2017 Removed notifications in games.
Start playing a game.
Changes in pagination in games. (227141 lines)

View File

@ -121,6 +121,8 @@ static bool Gam_CheckIfICanDoThisGameBasedOnGrps (long GamCod);
static unsigned Gam_GetNumQstsGame (long GamCod);
static void Gam_PutParamQstCod (long QstCod);
static long Gam_GetParamQstCod (void);
static void Gam_PutParamQstInd (unsigned QstInd);
static unsigned Gam_GetParamQstInd (void);
static void Gam_RemAnswersOfAQuestion (long QstCod);
static unsigned Gam_GetQstIndFromQstCod (long GamCod,long QstCod);
@ -148,7 +150,7 @@ static void Gam_PutParamsOneQst (void);
static void Gam_ExchangeQuestions (long GamCod,
unsigned QstIndTop,unsigned QstIndBottom);
static void Gam_PutBigButtonToStartGame (void);
static void Gam_PutBigButtonToStartGame (long GamCod);
static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod);
static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd);
@ -682,7 +684,7 @@ static void Gam_ShowOneGame (long GamCod,
/***** Put big button to start playing *****/
if (PutButtonToStart)
Gam_PutBigButtonToStartGame ();
Gam_PutBigButtonToStartGame (Game.GamCod);
/***** End box *****/
if (ShowOnlyThisGame)
@ -779,20 +781,20 @@ static void Gam_WriteStatus (struct Game *Game)
}
/*****************************************************************************/
/********* Get parameter with the type or order in list of games ***********/
/********** Get parameter with the type or order in list of games ************/
/*****************************************************************************/
static void Gam_GetParamGameOrder (void)
{
Gbl.Games.SelectedOrder = (Gam_Order_t)
Par_GetParToUnsignedLong ("Order",
0,
Gam_NUM_ORDERS - 1,
(unsigned long) Gam_ORDER_DEFAULT);
Par_GetParToUnsignedLong ("Order",
0,
Gam_NUM_ORDERS - 1,
(unsigned long) Gam_ORDER_DEFAULT);
}
/*****************************************************************************/
/***** Put a hidden parameter with the type of order in list of games ******/
/****** Put a hidden parameter with the type of order in list of games *******/
/*****************************************************************************/
void Gam_PutHiddenParamGameOrder (void)
@ -2517,10 +2519,33 @@ static void Gam_PutParamQstCod (long QstCod)
static long Gam_GetParamQstCod (void)
{
/***** Get code of question *****/
return Par_GetParToLong ("QstCod");
}
/*****************************************************************************/
/****************** Write parameter with index of question *******************/
/*****************************************************************************/
static void Gam_PutParamQstInd (unsigned QstInd)
{
Par_PutHiddenParamUnsigned ("QstInd",QstInd);
}
/*****************************************************************************/
/******************* Get parameter with index of question ********************/
/*****************************************************************************/
static unsigned Gam_GetParamQstInd (void)
{
long LongInt;
LongInt = Par_GetParToLong ("QstInd");
if (LongInt < 0)
Lay_ShowErrorAndExit ("Wrong question index.");
return (unsigned) LongInt;
}
/*****************************************************************************/
/********************* Remove answers of a game question *******************/
/*****************************************************************************/
@ -3449,13 +3474,14 @@ void Gam_PlayGame (void)
/********************* Put a big button to start game ************************/
/*****************************************************************************/
static void Gam_PutBigButtonToStartGame (void)
static void Gam_PutBigButtonToStartGame (long GamCod)
{
extern const char *Txt_Play;
/***** Start form *****/
Act_FormStart (ActPlyGam);
Gam_PutParams ();
Act_FormStart (ActPlyGamNxtQst);
Gam_PutParamGameCod (GamCod);
Gam_PutParamQstInd (0); // Start by first question in game
/***** Put icon with link *****/
Act_LinkFormSubmit (Txt_Play,NULL,NULL);
@ -3468,6 +3494,65 @@ static void Gam_PutBigButtonToStartGame (void)
Act_FormEnd ();
}
/*****************************************************************************/
/**************** Show next question when playing a game *********************/
/*****************************************************************************/
void Gam_PlayGameNextQuestion (void)
{
char Query[256];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
struct Game Game;
unsigned QstInd;
/***** Get parameters *****/
/* Get game code */
if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of game is missing.");
/* Get question index */
QstInd = Gam_GetParamQstInd ();
/***** Get data of question from database *****/
/*
row[0] QstCod
row[1] Stem
row[2] ImageName
row[3] ImageTitle
row[4] ImageURL
*/
sprintf (Query,"SELECT tst_questions.QstCod,"
"tst_questions.Stem,"
"tst_questions.ImageName,"
"tst_questions.ImageTitle,"
"tst_questions.ImageURL"
" FROM gam_questions,tst_questions"
" WHERE gam_questions.GamCod=%ld"
" AND gam_questions.QstInd=%u"
" AND gam_questions.QstCod=tst_questions.QstCod",
Game.GamCod,QstInd);
if (!DB_QuerySELECT (Query,&mysql_res,"can not get data of a question"))
Ale_ShowAlert (Ale_WARNING,"Questions doesn't exist.");
row = mysql_fetch_row (mysql_res);
/***** Show question *****/
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_CONTAINER\">");
/* Write number of question */
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_NUM_QST\">%u</div>",
QstInd + 1);
/* Write the stem (row[1]) and the image (row[2], row[3], row[4]) */
Tst_WriteQstStem (row[1],"GAM_PLAY_QST_STEM");
Img_GetImageNameTitleAndURLFromRow (row[2],row[3],row[4],&Gbl.Test.Image);
Img_ShowImage (&Gbl.Test.Image,
"TEST_IMG_EDIT_LIST_STEM_CONTAINER",
"TEST_IMG_EDIT_LIST_STEM");
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/************************ Receive answers of a game ************************/
/*****************************************************************************/

View File

@ -125,6 +125,7 @@ void Gam_MoveDownQst (void);
void Gam_PlayGame (void);
void Gam_ReceiveGameAnswers (void);
void Gam_PlayGameNextQuestion (void);
unsigned Gam_GetNumCoursesWithCrsGames (Sco_Scope_t Scope);
unsigned Gam_GetNumCrsGames (Sco_Scope_t Scope);