mirror of https://github.com/acanas/swad-core.git
Version18.130.2
This commit is contained in:
parent
db684f0ddf
commit
37f8eb3b53
|
@ -522,7 +522,7 @@ function refreshGame () {
|
|||
objXMLHttpReqGam = AJAXCreateObject();
|
||||
if (objXMLHttpReqGam) {
|
||||
var RefreshParams = RefreshParamNxtActGam + '&' +
|
||||
RefreshParamGamCod + '&' +
|
||||
RefreshParamMchCod + '&' +
|
||||
RefreshParamIdSes;
|
||||
|
||||
objXMLHttpReqGam.onreadystatechange = readGameData; // onreadystatechange must be lowercase
|
|
@ -613,9 +613,8 @@ Assessment:
|
|||
457. ActNxtMch Show next question when playing a game (by a teacher)
|
||||
NEW. ActShoMch Show finished match results
|
||||
|
||||
NEW. ActPlyMchStd Play a game (by a student)
|
||||
NEW. ActGamStdCurQst Show current question when playing a game (by a student)
|
||||
NEW. ActRefGamStd Refresh current question when playing a game (by a student)
|
||||
NEW. ActPlyMchStd Show current question when playing a game (by a student)
|
||||
NEW. ActRefMchStd Refresh current question when playing a game (by a student)
|
||||
|
||||
459. ActAnsGam Answer a game
|
||||
460. ActFrmNewGam Form to create a new game
|
||||
|
@ -2153,9 +2152,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
/* ActNxtMch */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_NextStatusMatch ,NULL},
|
||||
/* ActShoMch */{1786,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ShowFinishedMatchResults ,NULL},
|
||||
|
||||
/* ActPlyMchStd */{1779,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_PlayMatchStd ,NULL},
|
||||
/* ActGamStdCurQst */{1780,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowNewMatchToMeAsStd ,NULL},
|
||||
/* ActRefGamStd */{1782,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Gam_GetMatchBeingPlayed ,Gam_RefreshCurrentMatchStd ,NULL},
|
||||
/* ActPlyMchStd */{1780,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowNewMatchToMeAsStd ,NULL},
|
||||
/* ActRefMchStd */{1782,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Gam_GetMatchBeingPlayed ,Gam_RefreshCurrentMatchStd ,NULL},
|
||||
|
||||
/* ActAnsGam */{1651,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ReceiveGameAnswers ,NULL},
|
||||
/* ActFrmNewGam */{1652,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestCreatOrEditGame ,NULL},
|
||||
|
@ -4987,10 +4985,10 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
|
|||
ActReqUnlAllPrj, // #1776
|
||||
ActLckAllPrj, // #1777
|
||||
ActUnlAllPrj, // #1778
|
||||
ActPlyMchStd, // #1779
|
||||
ActGamStdCurQst, // #1780
|
||||
-1, // #1779 (obsolete action)
|
||||
ActPlyMchStd, // #1780
|
||||
-1, // #1781 (obsolete action)
|
||||
ActRefGamStd, // #1782
|
||||
ActRefMchStd, // #1782
|
||||
ActReqRemMch, // #1783
|
||||
ActRemMch, // #1784
|
||||
ActResMch, // #1785
|
||||
|
|
|
@ -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
|
||||
|
||||
#define Act_NUM_ACTIONS (1 + 4 + 64 + 38 + 12 + 42 + 36 + 19 + 110 + 169 + 437 + 176 + 169 + 16 + 68)
|
||||
#define Act_NUM_ACTIONS (1 + 4 + 64 + 38 + 12 + 42 + 36 + 19 + 110 + 168 + 437 + 176 + 169 + 16 + 68)
|
||||
|
||||
#define Act_MAX_ACTION_COD 1787
|
||||
|
||||
|
@ -615,53 +615,52 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
|
|||
#define ActNxtMch (ActChgCrsTT1stDay + 122)
|
||||
#define ActShoMch (ActChgCrsTT1stDay + 123)
|
||||
#define ActPlyMchStd (ActChgCrsTT1stDay + 124)
|
||||
#define ActGamStdCurQst (ActChgCrsTT1stDay + 125)
|
||||
#define ActRefGamStd (ActChgCrsTT1stDay + 126)
|
||||
#define ActAnsGam (ActChgCrsTT1stDay + 127)
|
||||
#define ActFrmNewGam (ActChgCrsTT1stDay + 128)
|
||||
#define ActEdiOneGam (ActChgCrsTT1stDay + 129)
|
||||
#define ActNewGam (ActChgCrsTT1stDay + 130)
|
||||
#define ActChgGam (ActChgCrsTT1stDay + 131)
|
||||
#define ActReqRemGam (ActChgCrsTT1stDay + 132)
|
||||
#define ActRemGam (ActChgCrsTT1stDay + 133)
|
||||
#define ActReqRstGam (ActChgCrsTT1stDay + 134)
|
||||
#define ActRstGam (ActChgCrsTT1stDay + 135)
|
||||
#define ActHidGam (ActChgCrsTT1stDay + 136)
|
||||
#define ActShoGam (ActChgCrsTT1stDay + 137)
|
||||
#define ActAddOneGamQst (ActChgCrsTT1stDay + 138)
|
||||
#define ActGamLstTstQst (ActChgCrsTT1stDay + 139)
|
||||
#define ActAddTstQstToGam (ActChgCrsTT1stDay + 140)
|
||||
#define ActReqRemGamQst (ActChgCrsTT1stDay + 141)
|
||||
#define ActRemGamQst (ActChgCrsTT1stDay + 142)
|
||||
#define ActUp_GamQst (ActChgCrsTT1stDay + 143)
|
||||
#define ActDwnGamQst (ActChgCrsTT1stDay + 144)
|
||||
#define ActRefMchStd (ActChgCrsTT1stDay + 125)
|
||||
#define ActAnsGam (ActChgCrsTT1stDay + 126)
|
||||
#define ActFrmNewGam (ActChgCrsTT1stDay + 127)
|
||||
#define ActEdiOneGam (ActChgCrsTT1stDay + 128)
|
||||
#define ActNewGam (ActChgCrsTT1stDay + 129)
|
||||
#define ActChgGam (ActChgCrsTT1stDay + 130)
|
||||
#define ActReqRemGam (ActChgCrsTT1stDay + 131)
|
||||
#define ActRemGam (ActChgCrsTT1stDay + 132)
|
||||
#define ActReqRstGam (ActChgCrsTT1stDay + 133)
|
||||
#define ActRstGam (ActChgCrsTT1stDay + 134)
|
||||
#define ActHidGam (ActChgCrsTT1stDay + 135)
|
||||
#define ActShoGam (ActChgCrsTT1stDay + 136)
|
||||
#define ActAddOneGamQst (ActChgCrsTT1stDay + 137)
|
||||
#define ActGamLstTstQst (ActChgCrsTT1stDay + 138)
|
||||
#define ActAddTstQstToGam (ActChgCrsTT1stDay + 139)
|
||||
#define ActReqRemGamQst (ActChgCrsTT1stDay + 140)
|
||||
#define ActRemGamQst (ActChgCrsTT1stDay + 141)
|
||||
#define ActUp_GamQst (ActChgCrsTT1stDay + 142)
|
||||
#define ActDwnGamQst (ActChgCrsTT1stDay + 143)
|
||||
|
||||
#define ActSeeSvy (ActChgCrsTT1stDay + 145)
|
||||
#define ActAnsSvy (ActChgCrsTT1stDay + 146)
|
||||
#define ActFrmNewSvy (ActChgCrsTT1stDay + 147)
|
||||
#define ActEdiOneSvy (ActChgCrsTT1stDay + 148)
|
||||
#define ActNewSvy (ActChgCrsTT1stDay + 149)
|
||||
#define ActChgSvy (ActChgCrsTT1stDay + 150)
|
||||
#define ActReqRemSvy (ActChgCrsTT1stDay + 151)
|
||||
#define ActRemSvy (ActChgCrsTT1stDay + 152)
|
||||
#define ActReqRstSvy (ActChgCrsTT1stDay + 153)
|
||||
#define ActRstSvy (ActChgCrsTT1stDay + 154)
|
||||
#define ActHidSvy (ActChgCrsTT1stDay + 155)
|
||||
#define ActShoSvy (ActChgCrsTT1stDay + 156)
|
||||
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 157)
|
||||
#define ActRcvSvyQst (ActChgCrsTT1stDay + 158)
|
||||
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 159)
|
||||
#define ActRemSvyQst (ActChgCrsTT1stDay + 160)
|
||||
#define ActSeeSvy (ActChgCrsTT1stDay + 144)
|
||||
#define ActAnsSvy (ActChgCrsTT1stDay + 145)
|
||||
#define ActFrmNewSvy (ActChgCrsTT1stDay + 146)
|
||||
#define ActEdiOneSvy (ActChgCrsTT1stDay + 147)
|
||||
#define ActNewSvy (ActChgCrsTT1stDay + 148)
|
||||
#define ActChgSvy (ActChgCrsTT1stDay + 149)
|
||||
#define ActReqRemSvy (ActChgCrsTT1stDay + 150)
|
||||
#define ActRemSvy (ActChgCrsTT1stDay + 151)
|
||||
#define ActReqRstSvy (ActChgCrsTT1stDay + 152)
|
||||
#define ActRstSvy (ActChgCrsTT1stDay + 153)
|
||||
#define ActHidSvy (ActChgCrsTT1stDay + 154)
|
||||
#define ActShoSvy (ActChgCrsTT1stDay + 155)
|
||||
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 156)
|
||||
#define ActRcvSvyQst (ActChgCrsTT1stDay + 157)
|
||||
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 158)
|
||||
#define ActRemSvyQst (ActChgCrsTT1stDay + 159)
|
||||
|
||||
#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 161)
|
||||
#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 162)
|
||||
#define ActEdiExaAnn (ActChgCrsTT1stDay + 163)
|
||||
#define ActRcvExaAnn (ActChgCrsTT1stDay + 164)
|
||||
#define ActPrnExaAnn (ActChgCrsTT1stDay + 165)
|
||||
#define ActReqRemExaAnn (ActChgCrsTT1stDay + 166)
|
||||
#define ActRemExaAnn (ActChgCrsTT1stDay + 167)
|
||||
#define ActHidExaAnn (ActChgCrsTT1stDay + 168)
|
||||
#define ActShoExaAnn (ActChgCrsTT1stDay + 169)
|
||||
#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 160)
|
||||
#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 161)
|
||||
#define ActEdiExaAnn (ActChgCrsTT1stDay + 162)
|
||||
#define ActRcvExaAnn (ActChgCrsTT1stDay + 163)
|
||||
#define ActPrnExaAnn (ActChgCrsTT1stDay + 164)
|
||||
#define ActReqRemExaAnn (ActChgCrsTT1stDay + 165)
|
||||
#define ActRemExaAnn (ActChgCrsTT1stDay + 166)
|
||||
#define ActHidExaAnn (ActChgCrsTT1stDay + 167)
|
||||
#define ActShoExaAnn (ActChgCrsTT1stDay + 168)
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Files tab **********************************/
|
||||
|
|
|
@ -458,10 +458,14 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.130.1 (2019-07-04)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.130.2 (2019-07-04)"
|
||||
#define CSS_FILE "swad18.123.css"
|
||||
#define JS_FILE "swad18.123.js"
|
||||
#define JS_FILE "swad18.130.2.js"
|
||||
/*
|
||||
Version 18.130.2: Jul 04, 2019 Changes in listing of games and matches for students. (243429 lines)
|
||||
1 change necessary in database:
|
||||
UPDATE actions SET Obsolete='Y' WHERE ActCod=1779;
|
||||
|
||||
Version 18.130.1: Jul 04, 2019 Changes in listing of games. (243505 lines)
|
||||
Version 18.130: Jul 04, 2019 Changes in listing of games. (243436 lines)
|
||||
1 change necessary in database:
|
||||
|
|
243
swad_game.c
243
swad_game.c
|
@ -108,7 +108,7 @@ unsigned Gam_CurrentQstInd = 0; // Used as parameter in contextual links
|
|||
/*****************************************************************************/
|
||||
|
||||
static void Gam_ListAllGames (void);
|
||||
static bool Gam_CheckIfICanCreateGame (void);
|
||||
static bool Gam_CheckIfICanEditGames (void);
|
||||
static void Gam_PutIconsListGames (void);
|
||||
static void Gam_PutIconToCreateNewGame (void);
|
||||
static void Gam_PutButtonToCreateNewGame (void);
|
||||
|
@ -116,8 +116,7 @@ static void Gam_PutParamsToCreateNewGame (void);
|
|||
static void Gam_ShowOneGame (long GamCod,
|
||||
bool ShowOnlyThisGame,
|
||||
bool ListGameQuestions,
|
||||
bool PutFormNewMatch,
|
||||
bool PutButtonToPlay);
|
||||
bool PutFormNewMatch);
|
||||
static void Gam_WriteAuthor (struct Game *Game);
|
||||
|
||||
static void Gam_PutFormsToRemEditOneGame (const struct Game *Game,
|
||||
|
@ -170,17 +169,16 @@ static void Gam_PutParamsOneQst (void);
|
|||
static void Gam_ExchangeQuestions (long GamCod,
|
||||
unsigned QstIndTop,unsigned QstIndBottom);
|
||||
|
||||
static void Gam_ListPlayedMatches (struct Game *Game,bool PutFormNewMatch);
|
||||
static void Gam_ListMatches (struct Game *Game,bool PutFormNewMatch);
|
||||
static void Gam_PutIconToPlayNewMatch (void);
|
||||
static void Gam_ListOneOrMoreMatchesForEdition (struct Game *Game,
|
||||
static void Gam_ListOneOrMoreMatches (struct Game *Game,
|
||||
unsigned NumMatches,
|
||||
MYSQL_RES *mysql_res);
|
||||
static void Gam_GetMatchDataFromRow (MYSQL_RES *mysql_res,
|
||||
struct Match *Match);
|
||||
static void Gam_PutButtonNewMatch (long GamCod);
|
||||
|
||||
static void Gam_PutBigButtonToPlayMatchTch (struct Game *Game);
|
||||
static void Gam_PutBigButtonToPlayMatchStd (long MchCod);
|
||||
static void Gam_PutFormNewMatch (struct Game *Game);
|
||||
|
||||
static void Gam_CreateMatch (struct Match *Match);
|
||||
static void Gam_UpdateMatchBeingPlayed (struct Match *Match);
|
||||
|
@ -255,8 +253,10 @@ static void Gam_ListAllGames (void)
|
|||
{
|
||||
/***** Table head *****/
|
||||
Tbl_StartTableWideMargin (2);
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<th class=\"CONTEXT_COL\"></th>"); // Column for contextual icons
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
if (Gam_CheckIfICanEditGames ())
|
||||
fprintf (Gbl.F.Out,"<th class=\"CONTEXT_COL\"></th>"); // Column for contextual icons
|
||||
|
||||
for (Order = (Gam_Order_t) 0;
|
||||
Order <= (Gam_Order_t) (Gam_NUM_ORDERS - 1);
|
||||
Order++)
|
||||
|
@ -286,9 +286,8 @@ static void Gam_ListAllGames (void)
|
|||
NumGame++)
|
||||
Gam_ShowOneGame (Gbl.Games.LstGamCods[NumGame - 1],
|
||||
false,
|
||||
false,
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false, // Do not list game questions
|
||||
false); // Do not put form to start new match
|
||||
|
||||
/***** End table *****/
|
||||
Tbl_EndTable ();
|
||||
|
@ -297,7 +296,7 @@ static void Gam_ListAllGames (void)
|
|||
Ale_ShowAlert (Ale_INFO,Txt_No_games);
|
||||
|
||||
/***** Button to create a new game *****/
|
||||
if (Gam_CheckIfICanCreateGame ())
|
||||
if (Gam_CheckIfICanEditGames ())
|
||||
Gam_PutButtonToCreateNewGame ();
|
||||
|
||||
/***** End box *****/
|
||||
|
@ -317,7 +316,7 @@ static void Gam_ListAllGames (void)
|
|||
/******************* Check if I can create a new game **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static bool Gam_CheckIfICanCreateGame (void)
|
||||
static bool Gam_CheckIfICanEditGames (void)
|
||||
{
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
|
@ -340,7 +339,7 @@ static bool Gam_CheckIfICanCreateGame (void)
|
|||
static void Gam_PutIconsListGames (void)
|
||||
{
|
||||
/***** Put icon to create a new game *****/
|
||||
if (Gam_CheckIfICanCreateGame ())
|
||||
if (Gam_CheckIfICanEditGames ())
|
||||
Gam_PutIconToCreateNewGame ();
|
||||
|
||||
/***** Put icon to show a figure *****/
|
||||
|
@ -404,9 +403,8 @@ void Gam_SeeOneGame (void)
|
|||
/***** Show game *****/
|
||||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false, // Do not list game questions
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -416,8 +414,7 @@ void Gam_SeeOneGame (void)
|
|||
static void Gam_ShowOneGame (long GamCod,
|
||||
bool ShowOnlyThisGame,
|
||||
bool ListGameQuestions,
|
||||
bool PutFormNewMatch,
|
||||
bool PutButtonToPlay)
|
||||
bool PutFormNewMatch)
|
||||
{
|
||||
extern const char *Hlp_ASSESSMENT_Games;
|
||||
extern const char *Txt_Game;
|
||||
|
@ -425,7 +422,6 @@ static void Gam_ShowOneGame (long GamCod,
|
|||
extern const char *Txt_View_game;
|
||||
extern const char *Txt_No_of_questions;
|
||||
extern const char *Txt_No_of_users;
|
||||
extern const char *Txt_Play;
|
||||
extern const char *Txt_New_match;
|
||||
char *Anchor = NULL;
|
||||
static unsigned UniqueId = 0;
|
||||
|
@ -453,38 +449,25 @@ static void Gam_ShowOneGame (long GamCod,
|
|||
fprintf (Gbl.F.Out,"<tr>");
|
||||
|
||||
/***** Icons related to this game *****/
|
||||
if (Game.Status.ICanEdit)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<td rowspan=\"2\" class=\"CONTEXT_COL");
|
||||
if (!ShowOnlyThisGame)
|
||||
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
|
||||
fprintf (Gbl.F.Out,"\">");
|
||||
|
||||
if (Game.Status.ICanEdit)
|
||||
/* Icons to remove/edit this game */
|
||||
Gam_PutFormsToRemEditOneGame (&Game,Anchor);
|
||||
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
/* Icon to play match */
|
||||
Lay_PutContextualLinkOnlyIcon (ActPlyMchStd,NULL,
|
||||
Gam_PutParams,
|
||||
"play.svg",
|
||||
Txt_Play);
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
if (ShowOnlyThisGame)
|
||||
/* Icon to start a new match */
|
||||
Lay_PutContextualLinkOnlyIcon (ActFrmNewMch,Gam_NEW_MATCH_SECTION_ID,
|
||||
Gam_PutParams,
|
||||
"play.svg",
|
||||
Txt_New_match);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
}
|
||||
|
||||
/***** Start date/time *****/
|
||||
UniqueId++;
|
||||
|
@ -597,22 +580,8 @@ static void Gam_ShowOneGame (long GamCod,
|
|||
|
||||
if (ShowOnlyThisGame)
|
||||
{
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
/* Put big button to play match */
|
||||
if (PutButtonToPlay)
|
||||
Gam_PutBigButtonToPlayMatchStd (Game.GamCod); // TODO: Change to match !!!!!!!!!!!!!!!!!!
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
/* List played matches */
|
||||
Gam_ListPlayedMatches (&Game,PutFormNewMatch);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/***** List matches *****/
|
||||
Gam_ListMatches (&Game,PutFormNewMatch);
|
||||
|
||||
/***** Write questions of this game *****/
|
||||
if (ListGameQuestions)
|
||||
|
@ -649,7 +618,6 @@ static void Gam_PutFormsToRemEditOneGame (const struct Game *Game,
|
|||
const char *Anchor)
|
||||
{
|
||||
extern const char *Txt_Reset;
|
||||
extern const char *Txt_Play;
|
||||
|
||||
/***** Put icon to remove game *****/
|
||||
Ico_PutContextualIconToRemove (ActReqRemGam,Gam_PutParams);
|
||||
|
@ -1225,7 +1193,7 @@ static bool Gam_CheckIfSimilarGameExists (struct Game *Game)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Put a form to create a new game *********************/
|
||||
/*********************** Put a form to create a new game *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Gam_RequestCreatOrEditGame (void)
|
||||
|
@ -1255,14 +1223,14 @@ void Gam_RequestCreatOrEditGame (void)
|
|||
if (ItsANewGame)
|
||||
{
|
||||
/***** Put link (form) to create new game *****/
|
||||
if (!Gam_CheckIfICanCreateGame ())
|
||||
if (!Gam_CheckIfICanEditGames ())
|
||||
Lay_ShowErrorAndExit ("You can not create a new game here.");
|
||||
|
||||
/* Initialize to empty game */
|
||||
Game.GamCod = -1L;
|
||||
Game.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
Game.TimeUTC[Gam_START_TIME] = Gbl.StartExecutionTimeUTC;
|
||||
Game.TimeUTC[Gam_END_TIME ] = Gbl.StartExecutionTimeUTC + (24 * 60 * 60); // +24 hours
|
||||
Game.TimeUTC[Gam_START_TIME] = (time_t) 0;
|
||||
Game.TimeUTC[Gam_END_TIME ] = (time_t) 0;
|
||||
Game.Title[0] = '\0';
|
||||
Game.NumQsts = 0;
|
||||
Game.NumUsrs = 0;
|
||||
|
@ -1314,9 +1282,6 @@ void Gam_RequestCreatOrEditGame (void)
|
|||
Txt_Title,
|
||||
Gam_MAX_CHARS_TITLE,Game.Title);
|
||||
|
||||
/***** Game start and end dates *****/
|
||||
// Dat_PutFormStartEndClientLocalDateTimes (Game.TimeUTC,Dat_FORM_SECONDS_ON);
|
||||
|
||||
/***** Game text *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"RIGHT_TOP\">"
|
||||
|
@ -1759,8 +1724,7 @@ void Gam_RequestNewQuestion (void)
|
|||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2287,8 +2251,7 @@ void Gam_AddTstQuestionsToGame (void)
|
|||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2465,8 +2428,7 @@ void Gam_RequestRemoveQst (void)
|
|||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2516,8 +2478,7 @@ void Gam_RemoveQst (void)
|
|||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2561,8 +2522,7 @@ void Gam_MoveUpQst (void)
|
|||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2616,8 +2576,7 @@ void Gam_MoveDownQst (void)
|
|||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2675,7 +2634,7 @@ static void Gam_ExchangeQuestions (long GamCod,
|
|||
/************************* List the matches of a game ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Gam_ListPlayedMatches (struct Game *Game,bool PutFormNewMatch)
|
||||
static void Gam_ListMatches (struct Game *Game,bool PutFormNewMatch)
|
||||
{
|
||||
extern const char *Hlp_ASSESSMENT_Games_matches;
|
||||
extern const char *Txt_Matches;
|
||||
|
@ -2687,8 +2646,7 @@ static void Gam_ListPlayedMatches (struct Game *Game,bool PutFormNewMatch)
|
|||
/* Fill subquery for game */
|
||||
if (Gbl.Crs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS)
|
||||
{
|
||||
if (asprintf (&SubQuery,"GamCod=%ld"
|
||||
" AND"
|
||||
if (asprintf (&SubQuery," AND"
|
||||
"(MchCod NOT IN"
|
||||
" (SELECT MchCod FROM gam_grp)"
|
||||
" OR"
|
||||
|
@ -2697,16 +2655,12 @@ static void Gam_ListPlayedMatches (struct Game *Game,bool PutFormNewMatch)
|
|||
" FROM gam_grp,crs_grp_usr"
|
||||
" WHERE crs_grp_usr.UsrCod=%ld"
|
||||
" AND gam_grp.GrpCod=crs_grp_usr.GrpCod))",
|
||||
Game->GamCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
{
|
||||
if (asprintf (&SubQuery,"GamCod=%ld",
|
||||
Game->GamCod) < 0)
|
||||
if (asprintf (&SubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Make query */
|
||||
NumMatches = (unsigned) DB_QuerySELECT (&mysql_res,"can not get matches",
|
||||
|
@ -2722,8 +2676,9 @@ static void Gam_ListPlayedMatches (struct Game *Game,bool PutFormNewMatch)
|
|||
"ShowingAnswers," // row[ 9]
|
||||
"Finished" // row[10]
|
||||
" FROM gam_matches"
|
||||
" WHERE %s"
|
||||
" WHERE GamCod=%ld%s"
|
||||
" ORDER BY MchCod",
|
||||
Game->GamCod,
|
||||
SubQuery);
|
||||
|
||||
/* Free allocated memory for subquery */
|
||||
|
@ -2736,16 +2691,25 @@ static void Gam_ListPlayedMatches (struct Game *Game,bool PutFormNewMatch)
|
|||
|
||||
if (NumMatches)
|
||||
/***** Show the table with the matches *****/
|
||||
Gam_ListOneOrMoreMatchesForEdition (Game,NumMatches,mysql_res);
|
||||
Gam_ListOneOrMoreMatches (Game,NumMatches,mysql_res);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
/***** Put button to play a new match in this game *****/
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
case Rol_SYS_ADM:
|
||||
if (PutFormNewMatch)
|
||||
Gam_PutBigButtonToPlayMatchTch (Game);
|
||||
Gam_PutFormNewMatch (Game); // Form to fill in data and start playing a new match
|
||||
else
|
||||
Gam_PutButtonNewMatch (Game->GamCod);
|
||||
Gam_PutButtonNewMatch (Game->GamCod); // Button to create a new match
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/***** End box *****/
|
||||
Box_EndBox ();
|
||||
|
@ -2820,7 +2784,7 @@ static void Gam_PutIconToPlayNewMatch (void)
|
|||
/*********************** List game matches for edition ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Gam_ListOneOrMoreMatchesForEdition (struct Game *Game,
|
||||
static void Gam_ListOneOrMoreMatches (struct Game *Game,
|
||||
unsigned NumMatches,
|
||||
MYSQL_RES *mysql_res)
|
||||
{
|
||||
|
@ -2829,6 +2793,7 @@ static void Gam_ListOneOrMoreMatchesForEdition (struct Game *Game,
|
|||
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
||||
extern const char *Txt_Match;
|
||||
extern const char *Txt_Status;
|
||||
extern const char *Txt_Play;
|
||||
extern const char *Txt_Resume;
|
||||
extern const char *Txt_Today;
|
||||
extern const char *Txt_View_game_results;
|
||||
|
@ -2886,18 +2851,6 @@ static void Gam_ListOneOrMoreMatchesForEdition (struct Game *Game,
|
|||
Ico_PutIconRemove ();
|
||||
Frm_EndForm ();
|
||||
|
||||
/* Put icon to continue playing an unfinished match */
|
||||
/*
|
||||
if (!Match.Status.Finished)
|
||||
{
|
||||
Gam_CurrentMchCod = Match.MchCod;
|
||||
Lay_PutContextualLinkOnlyIcon (ActResMch,NULL,
|
||||
Gam_PutParamCurrentMchCod,
|
||||
"play.svg",
|
||||
Txt_Resume);
|
||||
}
|
||||
*/
|
||||
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
/***** Number of match ******/
|
||||
|
@ -2968,12 +2921,32 @@ static void Gam_ListOneOrMoreMatchesForEdition (struct Game *Game,
|
|||
fprintf (Gbl.F.Out,"<div class=\"DAT\">%u/%u</div>",
|
||||
Match.Status.QstInd,Game->NumQsts);
|
||||
|
||||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_STD:
|
||||
/* Icon to play as student */
|
||||
Gam_CurrentMchCod = Match.MchCod;
|
||||
Lay_PutContextualLinkOnlyIcon (ActPlyMchStd,NULL,
|
||||
Gam_PutParamCurrentMchCod,
|
||||
"play.svg",
|
||||
Txt_Play);
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
case Rol_DEG_ADM:
|
||||
case Rol_CTR_ADM:
|
||||
case Rol_INS_ADM:
|
||||
case Rol_SYS_ADM:
|
||||
/* Icon to resume */
|
||||
Gam_CurrentMchCod = Match.MchCod;
|
||||
Lay_PutContextualLinkOnlyIcon (ActResMch,NULL,
|
||||
Gam_PutParamCurrentMchCod,
|
||||
"play.svg",
|
||||
Txt_Resume);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
|
@ -3088,8 +3061,7 @@ void Gam_RequestRemoveMatch (void)
|
|||
Gam_ShowOneGame (Match.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3136,8 +3108,7 @@ void Gam_RemoveMatch (void)
|
|||
Gam_ShowOneGame (Match.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3174,49 +3145,15 @@ void Gam_RequestNewMatch (void)
|
|||
/***** Show game *****/
|
||||
Gam_ShowOneGame (GamCod,
|
||||
true, // Show only this game
|
||||
false, // Do not list questions
|
||||
true, // Put form to start new match
|
||||
false); // Do not put button to play
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Start playing a game as a student ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Gam_PlayMatchStd (void)
|
||||
{
|
||||
struct Match Match;
|
||||
bool IBelongToGroups;
|
||||
|
||||
/***** Get parameters *****/
|
||||
Gam_GetParamOrder ();
|
||||
Grp_GetParamWhichGrps ();
|
||||
Gbl.Games.CurrentPage = Pag_GetParamPagNum (Pag_GAMES);
|
||||
|
||||
/***** Get match code *****/
|
||||
if ((Match.MchCod = Gam_GetParamMatchCod ()) == -1L)
|
||||
Lay_ShowErrorAndExit ("Code of match is missing.");
|
||||
|
||||
/***** Get data of the match from database *****/
|
||||
Gam_GetDataOfMatchByCod (&Match);
|
||||
|
||||
/***** Do I belong to valid groups to play this match? *****/
|
||||
IBelongToGroups = Gbl.Usrs.Me.IBelongToCurrentCrs &&
|
||||
Gam_CheckIfIPlayThisMatchBasedOnGrps (Match.MchCod);
|
||||
|
||||
/***** Show game *****/
|
||||
Gam_ShowOneGame (Match.GamCod,
|
||||
true, // Show only this game
|
||||
false, // Do not list questions
|
||||
false, // Do not put form to start new match
|
||||
IBelongToGroups); // Put button to play
|
||||
false, // Do not list game questions
|
||||
true); // Put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****** Put a big button to play match (start a new match) as a teacher ******/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Gam_PutBigButtonToPlayMatchTch (struct Game *Game)
|
||||
static void Gam_PutFormNewMatch (struct Game *Game)
|
||||
{
|
||||
extern const char *Hlp_ASSESSMENT_Games_new_match;
|
||||
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
||||
|
@ -3275,31 +3212,6 @@ static void Gam_PutBigButtonToPlayMatchTch (struct Game *Game)
|
|||
Lay_EndSection ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Put a big button to play match (join a match) as a student *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Gam_PutBigButtonToPlayMatchStd (long MchCod)
|
||||
{
|
||||
extern const char *Txt_Play;
|
||||
|
||||
/***** Start form *****/
|
||||
Frm_StartForm (ActGamStdCurQst);
|
||||
Gam_PutParamMatchCod (MchCod);
|
||||
Gam_PutParamQstInd (0); // Start by first question in game
|
||||
|
||||
/***** Put icon with link *****/
|
||||
Frm_LinkFormSubmit (Txt_Play,NULL,NULL);
|
||||
fprintf (Gbl.F.Out,"<img src=\"%s/play.svg\""
|
||||
" alt=\"%s\" title=\"%s\""
|
||||
" class=\"CONTEXT_OPT ICO_HIGHLIGHT ICO64x64\" />",
|
||||
Cfg_URL_ICON_PUBLIC,Txt_Play,Txt_Play);
|
||||
fprintf (Gbl.F.Out,"</a>");
|
||||
|
||||
/***** End form *****/
|
||||
Frm_EndForm ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Create a new match and show first question (by a teacher) *********/
|
||||
/*****************************************************************************/
|
||||
|
@ -3811,8 +3723,7 @@ void Gam_ReceiveGameAnswers (void)
|
|||
Gam_ShowOneGame (Game.GamCod,
|
||||
true, // Show only this game
|
||||
true, // List game questions
|
||||
false, // Do not put form to start new match
|
||||
false); // Do not put button to play
|
||||
false); // Do not put form to start new match
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -121,7 +121,7 @@ void Gam_RequestRemoveMatch (void);
|
|||
void Gam_RemoveMatch (void);
|
||||
|
||||
void Gam_RequestNewMatch (void);
|
||||
void Gam_PlayMatchStd (void);
|
||||
// void Gam_PlayMatchStd (void);
|
||||
|
||||
void Gam_ReceiveGameAnswers (void);
|
||||
void Gam_CreateAndStartNewMatch (void);
|
||||
|
|
|
@ -677,7 +677,7 @@ static void Lay_WriteScriptInit (void)
|
|||
case ActRemSocComGbl:
|
||||
RefreshNewTimeline = true;
|
||||
break;
|
||||
case ActGamStdCurQst:
|
||||
case ActPlyMchStd:
|
||||
RefreshGame = true;
|
||||
break;
|
||||
case ActLstClk:
|
||||
|
@ -790,10 +790,10 @@ static void Lay_WriteScriptParamsAJAX (void)
|
|||
Gbl.Usrs.Other.UsrDat.EncryptedUsrCod);
|
||||
break;
|
||||
/* Parameters related with game refreshing */
|
||||
case ActGamStdCurQst:
|
||||
case ActPlyMchStd:
|
||||
fprintf (Gbl.F.Out,"var RefreshParamNxtActGam = \"act=%ld\";\n"
|
||||
"var RefreshParamGamCod = \"GamCod=%ld\";\n",
|
||||
Act_GetActCod (ActRefGamStd),
|
||||
"var RefreshParamMchCod = \"MchCod=%ld\";\n",
|
||||
Act_GetActCod (ActRefMchStd),
|
||||
Gbl.Games.MchCodBeingPlayed);
|
||||
break;
|
||||
/* Parameter related with clicks refreshing */
|
||||
|
|
Loading…
Reference in New Issue