mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-14 04:36:32 +02:00
Version18.131
This commit is contained in:
parent
37f8eb3b53
commit
08886f915b
|
@ -2564,13 +2564,15 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************** Games ************************************/
|
/********************************** Games ************************************/
|
||||||
.GAM_PLAY_TCH_CONTAINER
|
.GAM_PLAY_CONTAINER
|
||||||
{
|
{
|
||||||
box-sizing:border-box;
|
box-sizing:border-box;
|
||||||
display:table;
|
display:table;
|
||||||
margin:5%;
|
margin:5%;
|
||||||
width:90%;
|
width:90%;
|
||||||
|
text-align:center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.GAM_PLAY_TCH_NUM_QST
|
.GAM_PLAY_TCH_NUM_QST
|
||||||
{
|
{
|
||||||
width:15%;
|
width:15%;
|
||||||
|
@ -2609,14 +2611,6 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
font-size:16pt;
|
font-size:16pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
.GAM_PLAY_STD_CONTAINER
|
|
||||||
{
|
|
||||||
box-sizing:border-box;
|
|
||||||
display:table;
|
|
||||||
margin:5%;
|
|
||||||
width:90%;
|
|
||||||
text-align:center;
|
|
||||||
}
|
|
||||||
.GAM_PLAY_STD_WAIT
|
.GAM_PLAY_STD_WAIT
|
||||||
{
|
{
|
||||||
box-sizing:border-box;
|
box-sizing:border-box;
|
|
@ -2147,12 +2147,12 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
||||||
/* ActFrmNewMch */{1670,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestNewMatch ,NULL},
|
/* ActFrmNewMch */{1670,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestNewMatch ,NULL},
|
||||||
/* ActReqRemMch */{1783,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestRemoveMatch ,NULL},
|
/* ActReqRemMch */{1783,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestRemoveMatch ,NULL},
|
||||||
/* ActRemMch */{1784,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RemoveMatch ,NULL},
|
/* ActRemMch */{1784,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RemoveMatch ,NULL},
|
||||||
/* ActNewMch */{1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_CreateAndStartNewMatch ,NULL},
|
/* ActNewMch */{1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_CreateNewMatch ,NULL},
|
||||||
/* ActResMch */{1785,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_ResumeUnfinishedMatch ,NULL},
|
/* ActResMch */{1785,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_ResumeUnfinishedMatch ,NULL},
|
||||||
/* ActNxtMch */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_NextStatusMatch ,NULL},
|
/* 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},
|
/* ActShoMch */{1786,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ShowFinishedMatchResults ,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},
|
/* ActPlyMchStd */{1780,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Gam_GetMatchBeingPlayed ,Gam_ShowMatchToMeAsStd ,NULL},
|
||||||
/* ActRefMchStd */{1782,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_AJAX_RFRESH,Gam_GetMatchBeingPlayed ,Gam_RefreshCurrentMatchStd ,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},
|
/* ActAnsGam */{1651,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ReceiveGameAnswers ,NULL},
|
||||||
|
|
|
@ -458,10 +458,11 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 18.130.2 (2019-07-04)"
|
#define Log_PLATFORM_VERSION "SWAD 18.131 (2019-07-04)"
|
||||||
#define CSS_FILE "swad18.123.css"
|
#define CSS_FILE "swad18.131.css"
|
||||||
#define JS_FILE "swad18.130.2.js"
|
#define JS_FILE "swad18.130.2.js"
|
||||||
/*
|
/*
|
||||||
|
Version 18.131: Jul 04, 2019 Changes in matches. (243426 lines)
|
||||||
Version 18.130.2: Jul 04, 2019 Changes in listing of games and matches for students. (243429 lines)
|
Version 18.130.2: Jul 04, 2019 Changes in listing of games and matches for students. (243429 lines)
|
||||||
1 change necessary in database:
|
1 change necessary in database:
|
||||||
UPDATE actions SET Obsolete='Y' WHERE ActCod=1779;
|
UPDATE actions SET Obsolete='Y' WHERE ActCod=1779;
|
||||||
|
|
428
swad_game.c
428
swad_game.c
|
@ -183,12 +183,12 @@ static void Gam_PutFormNewMatch (struct Game *Game);
|
||||||
static void Gam_CreateMatch (struct Match *Match);
|
static void Gam_CreateMatch (struct Match *Match);
|
||||||
static void Gam_UpdateMatchBeingPlayed (struct Match *Match);
|
static void Gam_UpdateMatchBeingPlayed (struct Match *Match);
|
||||||
|
|
||||||
|
static void Gam_ShowMatchStatusForTch (struct Match *Match);
|
||||||
static void Gam_ShowAlertFinishedMatch (void);
|
static void Gam_ShowAlertFinishedMatch (void);
|
||||||
static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match);
|
static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match);
|
||||||
static void Gam_PutBigButtonToContinue (long MchCod);
|
static void Gam_PutBigButton (long MchCod,const char *Txt,const char *Icon);
|
||||||
static void Gam_PutBigButtonToFinishMatch (long GamCod);
|
|
||||||
|
|
||||||
static void Gam_ShowQuestionBeingPlayed (struct Match *Match);
|
static void Gam_ShowMatchStatusForStd (struct Match *Match);
|
||||||
|
|
||||||
static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod);
|
static void Gam_ReceiveAndStoreUserAnswersToAGame (long GamCod);
|
||||||
static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd);
|
static void Gam_IncreaseAnswerInDB (long QstCod,unsigned AnsInd);
|
||||||
|
@ -2759,7 +2759,7 @@ void Gam_GetDataOfMatchByCod (struct Match *Match)
|
||||||
Match->Status.QstInd = 0;
|
Match->Status.QstInd = 0;
|
||||||
Match->Status.QstCod = -1L;
|
Match->Status.QstCod = -1L;
|
||||||
Match->Status.QstStartTimeUTC = (time_t) 0;
|
Match->Status.QstStartTimeUTC = (time_t) 0;
|
||||||
Match->Status.ShowingAnswers = false;
|
Match->Status.ShowingAnswers = false;
|
||||||
Match->Status.Finished = false;
|
Match->Status.Finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3024,12 +3024,12 @@ static void Gam_GetMatchDataFromRow (MYSQL_RES *mysql_res,
|
||||||
/* Get whether the match is finished or not (row(10)) */
|
/* Get whether the match is finished or not (row(10)) */
|
||||||
Match->Status.Finished = (row[10][0] == 'Y');
|
Match->Status.Finished = (row[10][0] == 'Y');
|
||||||
|
|
||||||
/* If question index is 0 ==> the game is finished */
|
// /* If question index is 0 ==> the game is finished */
|
||||||
if (Match->Status.QstInd == 0)
|
// if (Match->Status.QstInd == 0)
|
||||||
{
|
// {
|
||||||
Match->Status.QstCod = -1L;
|
// Match->Status.QstCod = -1L;
|
||||||
Match->Status.Finished = true;
|
// Match->Status.Finished = true;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3060,7 +3060,7 @@ void Gam_RequestRemoveMatch (void)
|
||||||
/***** Show current game *****/
|
/***** Show current game *****/
|
||||||
Gam_ShowOneGame (Match.GamCod,
|
Gam_ShowOneGame (Match.GamCod,
|
||||||
true, // Show only this game
|
true, // Show only this game
|
||||||
true, // List game questions
|
false, // Do not list game questions
|
||||||
false); // Do not put form to start new match
|
false); // Do not put form to start new match
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3107,7 +3107,7 @@ void Gam_RemoveMatch (void)
|
||||||
/***** Show current game *****/
|
/***** Show current game *****/
|
||||||
Gam_ShowOneGame (Match.GamCod,
|
Gam_ShowOneGame (Match.GamCod,
|
||||||
true, // Show only this game
|
true, // Show only this game
|
||||||
true, // List game questions
|
false, // Do not list game questions
|
||||||
false); // Do not put form to start new match
|
false); // Do not put form to start new match
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3216,12 +3216,12 @@ static void Gam_PutFormNewMatch (struct Game *Game)
|
||||||
/********* Create a new match and show first question (by a teacher) *********/
|
/********* Create a new match and show first question (by a teacher) *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Gam_CreateAndStartNewMatch (void)
|
void Gam_CreateNewMatch (void)
|
||||||
{
|
{
|
||||||
struct Match Match;
|
struct Match Match;
|
||||||
|
|
||||||
/***** Get form parameters *****/
|
/***** Get form parameters *****/
|
||||||
/* Get game code */
|
/* Get match code */
|
||||||
if ((Match.GamCod = Gam_GetParamGameCod ()) == -1L)
|
if ((Match.GamCod = Gam_GetParamGameCod ()) == -1L)
|
||||||
Lay_ShowErrorAndExit ("Code of game is missing.");
|
Lay_ShowErrorAndExit ("Code of game is missing.");
|
||||||
|
|
||||||
|
@ -3237,8 +3237,8 @@ void Gam_CreateAndStartNewMatch (void)
|
||||||
/***** Free memory for list of selected groups *****/
|
/***** Free memory for list of selected groups *****/
|
||||||
Grp_FreeListCodSelectedGrps ();
|
Grp_FreeListCodSelectedGrps ();
|
||||||
|
|
||||||
/***** Show questions and possible answers *****/
|
/***** Show current match status *****/
|
||||||
Gam_PlayGameShowQuestionAndAnswers (&Match);
|
Gam_ShowMatchStatusForTch (&Match);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3249,19 +3249,10 @@ static void Gam_CreateMatch (struct Match *Match)
|
||||||
{
|
{
|
||||||
/***** Initialize new match *****/
|
/***** Initialize new match *****/
|
||||||
Match->UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; // Player (me)
|
Match->UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; // Player (me)
|
||||||
Match->Status.QstInd = Gam_GetFirstQuestionIndexInGame (Match->GamCod);
|
Match->Status.QstInd = 0; // Match has not started, so not the first question yet
|
||||||
if (Match->Status.QstInd > 0)
|
Match->Status.QstCod = -1L; // Non-existent question
|
||||||
{
|
Match->Status.ShowingAnswers = false; // Don't show answers initially
|
||||||
Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod,Match->Status.QstInd);
|
Match->Status.Finished = false; // Game finished
|
||||||
Match->Status.ShowingAnswers = false; // Don't show answers initially
|
|
||||||
Match->Status.Finished = false; // Game not finished
|
|
||||||
}
|
|
||||||
else // The game has no questions!
|
|
||||||
{
|
|
||||||
Match->Status.QstCod = -1L; // Non-existent question
|
|
||||||
Match->Status.ShowingAnswers = false; // Don't show answers initially
|
|
||||||
Match->Status.Finished = true; // Game not finished
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Insert this new match into database *****/
|
/***** Insert this new match into database *****/
|
||||||
Match->MchCod = DB_QueryINSERTandReturnCode ("can not create match",
|
Match->MchCod = DB_QueryINSERTandReturnCode ("can not create match",
|
||||||
|
@ -3299,19 +3290,8 @@ void Gam_ResumeUnfinishedMatch (void)
|
||||||
/***** Get data of the match from database *****/
|
/***** Get data of the match from database *****/
|
||||||
Gam_GetDataOfMatchByCod (&Match);
|
Gam_GetDataOfMatchByCod (&Match);
|
||||||
|
|
||||||
if (Match.Status.Finished)
|
/***** Show current match status *****/
|
||||||
Gam_ShowAlertFinishedMatch ();
|
Gam_ShowMatchStatusForTch (&Match);
|
||||||
else // Unfinished match
|
|
||||||
{
|
|
||||||
/***** In what question do we resume the match? *****/
|
|
||||||
if (Match.Status.QstInd == 0)
|
|
||||||
/* If current question index is 0 ==>
|
|
||||||
start playing the first question */
|
|
||||||
Match.Status.QstInd = Gam_GetFirstQuestionIndexInGame (Match.GamCod);
|
|
||||||
|
|
||||||
/***** Show questions and possible answers *****/
|
|
||||||
Gam_PlayGameShowQuestionAndAnswers (&Match);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3360,43 +3340,80 @@ void Gam_NextStatusMatch (void)
|
||||||
/***** If not yet finished, update status *****/
|
/***** If not yet finished, update status *****/
|
||||||
if (!Match.Status.Finished)
|
if (!Match.Status.Finished)
|
||||||
{
|
{
|
||||||
if (Match.Status.ShowingAnswers) // Showing answers currently
|
if (Match.Status.QstInd == 0) // Game has been created, but it has not started
|
||||||
{
|
{
|
||||||
/* Get index of the next question */
|
/* Get index of the first question */
|
||||||
NxtQstInd = Gam_GetNextQuestionIndexInGame (Match.GamCod,
|
NxtQstInd = Gam_GetFirstQuestionIndexInGame (Match.GamCod);
|
||||||
Match.Status.QstInd);
|
|
||||||
if (NxtQstInd) // Not last question
|
if (NxtQstInd) // Not last question
|
||||||
{
|
{
|
||||||
Match.Status.QstInd = NxtQstInd; // Go to the next question
|
Match.Status.QstInd = NxtQstInd; // Go to the next question
|
||||||
Match.Status.QstCod = Gam_GetQstCodFromQstInd (Match.GamCod,
|
Match.Status.QstCod = Gam_GetQstCodFromQstInd (Match.GamCod,
|
||||||
Match.Status.QstInd);
|
Match.Status.QstInd);
|
||||||
Match.Status.ShowingAnswers = false; // Don't show answers
|
Match.Status.Finished = false; // Game is not finished
|
||||||
Match.Status.Finished = false; // Game is not finished
|
|
||||||
}
|
}
|
||||||
else // No more questions
|
else // No more questions
|
||||||
{
|
{
|
||||||
Match.Status.QstInd = 0; // No more questions
|
Match.Status.QstInd = 0; // No more questions
|
||||||
Match.Status.QstCod = -1L; // No more questions
|
Match.Status.QstCod = -1L; // No more questions
|
||||||
Match.Status.ShowingAnswers = false; // Don't show answers
|
Match.Status.Finished = true; // Game is finished
|
||||||
Match.Status.Finished = true; // Game is finished
|
|
||||||
}
|
}
|
||||||
|
Match.Status.ShowingAnswers = false; // Don't show answers
|
||||||
}
|
}
|
||||||
else
|
else // Game has started
|
||||||
{
|
{
|
||||||
Match.Status.ShowingAnswers = true; // Show answers
|
if (Match.Status.ShowingAnswers) // Showing answers currently
|
||||||
Match.Status.Finished = false; // Game is not finished
|
{
|
||||||
}
|
/* Get index of the next question */
|
||||||
|
NxtQstInd = Gam_GetNextQuestionIndexInGame (Match.GamCod,
|
||||||
|
Match.Status.QstInd);
|
||||||
|
if (NxtQstInd) // Not last question
|
||||||
|
{
|
||||||
|
Match.Status.QstInd = NxtQstInd; // Go to the next question
|
||||||
|
Match.Status.QstCod = Gam_GetQstCodFromQstInd (Match.GamCod,
|
||||||
|
Match.Status.QstInd);
|
||||||
|
Match.Status.Finished = false; // Game is not finished
|
||||||
|
}
|
||||||
|
else // No more questions
|
||||||
|
{
|
||||||
|
Match.Status.QstInd = 0; // No more questions
|
||||||
|
Match.Status.QstCod = -1L; // No more questions
|
||||||
|
Match.Status.Finished = true; // Game is finished
|
||||||
|
}
|
||||||
|
Match.Status.ShowingAnswers = false; // Don't show answers
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Match.Status.Finished = false; // Game is not finished
|
||||||
|
Match.Status.ShowingAnswers = true; // Show answers
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Update match status in database */
|
/* Update match status in database */
|
||||||
Gam_UpdateMatchBeingPlayed (&Match);
|
Gam_UpdateMatchBeingPlayed (&Match);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Show status and questions *****/
|
/***** Show current match status *****/
|
||||||
if (Match.Status.Finished)
|
Gam_ShowMatchStatusForTch (&Match);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******* Show current match status (number, question, answers, button) *******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Gam_ShowMatchStatusForTch (struct Match *Match)
|
||||||
|
{
|
||||||
|
/***** Start container for match status *****/
|
||||||
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_CONTAINER\">");
|
||||||
|
|
||||||
|
/***** Show current match status *****/
|
||||||
|
if (Match->Status.Finished)
|
||||||
Gam_ShowAlertFinishedMatch ();
|
Gam_ShowAlertFinishedMatch ();
|
||||||
else
|
else // Unfinished match
|
||||||
/* Show questions and possible answers */
|
/***** Show current question and possible answers *****/
|
||||||
Gam_PlayGameShowQuestionAndAnswers (&Match);
|
Gam_PlayGameShowQuestionAndAnswers (Match);
|
||||||
|
|
||||||
|
/***** End container for match status *****/
|
||||||
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3408,7 +3425,7 @@ static void Gam_ShowAlertFinishedMatch (void)
|
||||||
extern const char *Txt_Finished_match;
|
extern const char *Txt_Finished_match;
|
||||||
|
|
||||||
/***** Show alert *****/
|
/***** Show alert *****/
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_Finished_match);
|
Ale_ShowAlert (Ale_INFO,Txt_Finished_match);
|
||||||
|
|
||||||
/***** Button to close browser tab *****/
|
/***** Button to close browser tab *****/
|
||||||
Btn_PutCloseTabButton ("Cerrar"); // TODO: Need translation!!!!!
|
Btn_PutCloseTabButton ("Cerrar"); // TODO: Need translation!!!!!
|
||||||
|
@ -3420,89 +3437,94 @@ static void Gam_ShowAlertFinishedMatch (void)
|
||||||
|
|
||||||
static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match)
|
static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match)
|
||||||
{
|
{
|
||||||
|
extern const char *Txt_Start_match;
|
||||||
|
extern const char *Txt_Continue;
|
||||||
|
extern const char *Txt_Finish;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NxtQstInd;
|
unsigned NxtQstInd;
|
||||||
|
|
||||||
/***** Get data of question from database *****/
|
/***** In what question do we resume the match? *****/
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
if (Match->Status.QstInd > 0)
|
||||||
"SELECT AnsType," // row[0]
|
{
|
||||||
"Stem," // row[1]
|
/***** Get data of question from database *****/
|
||||||
"MedCod" // row[2]
|
if (!DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||||
" FROM tst_questions"
|
"SELECT AnsType," // row[0]
|
||||||
" WHERE QstCod=%ld",
|
"Stem," // row[1]
|
||||||
Match->Status.QstCod))
|
"MedCod" // row[2]
|
||||||
Ale_ShowAlert (Ale_ERROR,"Question doesn't exist.");
|
" FROM tst_questions"
|
||||||
row = mysql_fetch_row (mysql_res);
|
" WHERE QstCod=%ld",
|
||||||
|
Match->Status.QstCod))
|
||||||
|
Ale_ShowAlert (Ale_ERROR,"Question doesn't exist.");
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/***** Show question *****/
|
/***** Show question *****/
|
||||||
/* Start container for number and question */
|
/* Write number of question */
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_CONTAINER\">");
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_NUM_QST\">%u</div>",
|
||||||
|
Match->Status.QstInd);
|
||||||
|
|
||||||
/* Write number of question */
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_QST_CONTAINER\">");
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_NUM_QST\">%u</div>",
|
|
||||||
Match->Status.QstInd);
|
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_QST_CONTAINER\">");
|
/* Get answer type (row[0]) */
|
||||||
|
Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]);
|
||||||
|
// TODO: Check that answer type is correct (unique choice)
|
||||||
|
|
||||||
/* Get answer type (row[0]) */
|
/* Write stem (row[1]) */
|
||||||
Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]);
|
Tst_WriteQstStem (row[1],"GAM_PLAY_TCH_QST");
|
||||||
// TODO: Check that answer type is correct (unique choice)
|
|
||||||
|
|
||||||
/* Write stem (row[1]) */
|
/* Get media (row[2]) */
|
||||||
Tst_WriteQstStem (row[1],"GAM_PLAY_TCH_QST");
|
Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||||
|
Med_GetMediaDataByCod (&Gbl.Test.Media);
|
||||||
|
|
||||||
/* Get media (row[2]) */
|
/* Show media */
|
||||||
Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[2]);
|
Med_ShowMedia (&Gbl.Test.Media,
|
||||||
Med_GetMediaDataByCod (&Gbl.Test.Media);
|
"TEST_MED_EDIT_LIST_STEM_CONTAINER",
|
||||||
|
"TEST_MED_EDIT_LIST_STEM");
|
||||||
|
|
||||||
/* Show media */
|
/* Write answers? */
|
||||||
Med_ShowMedia (&Gbl.Test.Media,
|
if (Match->Status.ShowingAnswers)
|
||||||
"TEST_MED_EDIT_LIST_STEM_CONTAINER",
|
/* Write answers */
|
||||||
"TEST_MED_EDIT_LIST_STEM");
|
Tst_WriteAnswersGameResult (Match->GamCod,
|
||||||
|
Match->Status.QstInd,
|
||||||
|
Match->Status.QstCod,
|
||||||
|
"GAM_PLAY_TCH_QST",false); // Don't show result
|
||||||
|
|
||||||
/* Write answers? */
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
if (Match->Status.ShowingAnswers)
|
}
|
||||||
/* Write answers */
|
|
||||||
Tst_WriteAnswersGameResult (Match->GamCod,
|
|
||||||
Match->Status.QstInd,
|
|
||||||
Match->Status.QstCod,
|
|
||||||
"GAM_PLAY_TCH_QST",false); // Don't show result
|
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
|
||||||
|
|
||||||
/***** Put button to continue *****/
|
/***** Put button to continue *****/
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_NXT_CONTAINER\">");
|
if (Match->Status.QstInd == 0)
|
||||||
if (Match->Status.ShowingAnswers)
|
/***** Put button to start first question *****/
|
||||||
{
|
Gam_PutBigButton (Match->MchCod,Txt_Start_match,"play.svg");
|
||||||
/* Get index of the next question */
|
|
||||||
NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
|
|
||||||
Match->Status.QstInd);
|
|
||||||
if (NxtQstInd) // Not last question
|
|
||||||
/* Put button to show next question */
|
|
||||||
Gam_PutBigButtonToContinue (Match->MchCod);
|
|
||||||
else // Last question
|
|
||||||
/* Put button to end */
|
|
||||||
Gam_PutBigButtonToFinishMatch (Match->MchCod);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
/* Put button to show answers */
|
{
|
||||||
Gam_PutBigButtonToContinue (Match->MchCod);
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_NXT_CONTAINER\">");
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
if (Match->Status.ShowingAnswers)
|
||||||
|
{
|
||||||
/***** End container for question *****/
|
/* Get index of the next question */
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
|
||||||
|
Match->Status.QstInd);
|
||||||
|
if (NxtQstInd) // Not last question
|
||||||
|
/* Put button to show next question */
|
||||||
|
Gam_PutBigButton (Match->MchCod,Txt_Continue,"step-forward.svg");
|
||||||
|
else // Last question
|
||||||
|
/* Put button to finish */
|
||||||
|
Gam_PutBigButton (Match->MchCod,Txt_Finish,"flag-checkered.svg");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* Put button to show answers */
|
||||||
|
Gam_PutBigButton (Match->MchCod,Txt_Continue,"step-forward.svg");
|
||||||
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********************** Put a big button to continue ************************/
|
/************************** Put a big button to start ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Gam_PutBigButtonToContinue (long MchCod)
|
static void Gam_PutBigButton (long MchCod,const char *Txt,const char *Icon)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Continue;
|
/***** Start container for button *****/
|
||||||
|
|
||||||
/***** Start container *****/
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_CONTINUE_CONTAINER\">");
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_TCH_CONTINUE_CONTAINER\">");
|
||||||
|
|
||||||
/***** Start form *****/
|
/***** Start form *****/
|
||||||
|
@ -3510,53 +3532,20 @@ static void Gam_PutBigButtonToContinue (long MchCod)
|
||||||
Gam_PutParamMatchCod (MchCod);
|
Gam_PutParamMatchCod (MchCod);
|
||||||
|
|
||||||
/***** Put icon with link *****/
|
/***** Put icon with link *****/
|
||||||
Frm_LinkFormSubmit (Txt_Continue,"GAM_PLAY_TCH_CONTINUE ICO_HIGHLIGHT",NULL);
|
Frm_LinkFormSubmit (Txt,"GAM_PLAY_TCH_CONTINUE ICO_HIGHLIGHT",NULL);
|
||||||
fprintf (Gbl.F.Out,"<img src=\"%s/step-forward.svg\""
|
fprintf (Gbl.F.Out,"<img src=\"%s/%s\""
|
||||||
" alt=\"%s\" title=\"%s\" class=\"ICO64x64\" />"
|
" alt=\"%s\" title=\"%s\" class=\"ICO64x64\" />"
|
||||||
"<br />"
|
"<br />"
|
||||||
"%s",
|
"%s",
|
||||||
Cfg_URL_ICON_PUBLIC,
|
Cfg_URL_ICON_PUBLIC,Icon,
|
||||||
Txt_Continue,Txt_Continue,
|
Txt,Txt,
|
||||||
Txt_Continue);
|
Txt);
|
||||||
fprintf (Gbl.F.Out,"</a>");
|
fprintf (Gbl.F.Out,"</a>");
|
||||||
|
|
||||||
/***** End form *****/
|
/***** End form *****/
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
|
||||||
/***** End container *****/
|
/***** End container for button *****/
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/******************** Put a big button to finish a match *********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static void Gam_PutBigButtonToFinishMatch (long MchCod)
|
|
||||||
{
|
|
||||||
extern const char *Txt_Finish;
|
|
||||||
|
|
||||||
/***** Start container *****/
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_CONTINUE_CONTAINER\">");
|
|
||||||
|
|
||||||
/***** Start form *****/
|
|
||||||
Frm_StartForm (ActNxtMch);
|
|
||||||
Gam_PutParamMatchCod (MchCod);
|
|
||||||
|
|
||||||
/***** Put icon with link *****/
|
|
||||||
Frm_LinkFormSubmit (Txt_Finish,"GAM_PLAY_CONTINUE ICO_HIGHLIGHT",NULL);
|
|
||||||
fprintf (Gbl.F.Out,"<img src=\"%s/flag-checkered.svg\""
|
|
||||||
" alt=\"%s\" title=\"%s\" class=\"ICO64x64\" />"
|
|
||||||
"<br />"
|
|
||||||
"%s",
|
|
||||||
Cfg_URL_ICON_PUBLIC,
|
|
||||||
Txt_Finish,Txt_Finish,
|
|
||||||
Txt_Finish);
|
|
||||||
fprintf (Gbl.F.Out,"</a>");
|
|
||||||
|
|
||||||
/***** End form *****/
|
|
||||||
Frm_EndForm ();
|
|
||||||
|
|
||||||
/***** End container *****/
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3584,7 +3573,7 @@ void Gam_GetMatchBeingPlayed (void)
|
||||||
/********* Show game being played to me as student in a new window ***********/
|
/********* Show game being played to me as student in a new window ***********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Gam_ShowNewMatchToMeAsStd (void)
|
void Gam_ShowMatchToMeAsStd (void)
|
||||||
{
|
{
|
||||||
struct Match Match;
|
struct Match Match;
|
||||||
|
|
||||||
|
@ -3592,9 +3581,13 @@ void Gam_ShowNewMatchToMeAsStd (void)
|
||||||
Match.MchCod = Gbl.Games.MchCodBeingPlayed;
|
Match.MchCod = Gbl.Games.MchCodBeingPlayed;
|
||||||
Gam_GetDataOfMatchByCod (&Match);
|
Gam_GetDataOfMatchByCod (&Match);
|
||||||
|
|
||||||
|
/***** Start container for match status *****/
|
||||||
|
fprintf (Gbl.F.Out,"<div id=\"game\" class=\"GAM_PLAY_CONTAINER\">");
|
||||||
|
|
||||||
/***** Show current question *****/
|
/***** Show current question *****/
|
||||||
fprintf (Gbl.F.Out,"<div id=\"game\" class=\"GAM_PLAY_STD_CONTAINER\">");
|
Gam_ShowMatchStatusForStd (&Match);
|
||||||
Gam_ShowQuestionBeingPlayed (&Match);
|
|
||||||
|
/***** End container for match status *****/
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3614,14 +3607,14 @@ void Gam_RefreshCurrentMatchStd (void)
|
||||||
Gam_GetDataOfMatchByCod (&Match);
|
Gam_GetDataOfMatchByCod (&Match);
|
||||||
|
|
||||||
/***** Show current question *****/
|
/***** Show current question *****/
|
||||||
Gam_ShowQuestionBeingPlayed (&Match);
|
Gam_ShowMatchStatusForStd (&Match);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************ Show current question being played for a student ***************/
|
/************ Show current question being played for a student ***************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Gam_ShowQuestionBeingPlayed (struct Match *Match)
|
static void Gam_ShowMatchStatusForStd (struct Match *Match)
|
||||||
{
|
{
|
||||||
bool IBelongToGroups;
|
bool IBelongToGroups;
|
||||||
unsigned NumOptions;
|
unsigned NumOptions;
|
||||||
|
@ -3633,62 +3626,67 @@ static void Gam_ShowQuestionBeingPlayed (struct Match *Match)
|
||||||
if (!IBelongToGroups)
|
if (!IBelongToGroups)
|
||||||
Lay_ShowErrorAndExit ("You can not play this match!");
|
Lay_ShowErrorAndExit ("You can not play this match!");
|
||||||
|
|
||||||
/***** Show question *****/
|
/***** Show current match status *****/
|
||||||
if (!Match->Status.Finished)
|
if (Match->Status.Finished)
|
||||||
|
Gam_ShowAlertFinishedMatch ();
|
||||||
|
else // Unfinished match
|
||||||
{
|
{
|
||||||
/***** Show question *****/
|
if (Match->Status.QstInd == 0) // Not yet started
|
||||||
/* Write number of question */
|
{
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_STD_NUM_QST\">%u</div>",
|
fprintf (Gbl.F.Out,"<img src=\"%s/wait.gif\""
|
||||||
Match->Status.QstInd);
|
" alt=\"Please wait\" title=\"%s\""
|
||||||
|
" class=\"GAM_PLAY_STD_WAIT\" />",
|
||||||
|
Cfg_URL_ICON_PUBLIC,
|
||||||
|
"Por favor, espere a que el juego comience..."); // TODO: Need translation!!!!!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/***** Show question *****/
|
||||||
|
/* Write number of question */
|
||||||
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_STD_NUM_QST\">%u</div>",
|
||||||
|
Match->Status.QstInd);
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_STD_QST_CONTAINER\">");
|
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_STD_QST_CONTAINER\">");
|
||||||
|
|
||||||
/* Write answers? */
|
/* Write answers? */
|
||||||
if (Match->Status.ShowingAnswers)
|
if (Match->Status.ShowingAnswers)
|
||||||
{
|
|
||||||
if (Tst_CheckIfQuestionIsValidForGame (Match->Status.QstCod))
|
|
||||||
{
|
{
|
||||||
/***** Start table *****/
|
if (Tst_CheckIfQuestionIsValidForGame (Match->Status.QstCod))
|
||||||
Tbl_StartTableWide (8);
|
|
||||||
|
|
||||||
/***** Write answers *****/
|
|
||||||
NumOptions = Tst_GetNumAnswersQst (Match->Status.QstCod);
|
|
||||||
for (NumOpt = 0;
|
|
||||||
NumOpt < NumOptions;
|
|
||||||
NumOpt++)
|
|
||||||
{
|
{
|
||||||
// if (NumOpt % 2 == 0)
|
/***** Start table *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>");
|
Tbl_StartTableWide (8);
|
||||||
|
|
||||||
/***** Write letter for this option *****/
|
/***** Write answers *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"GAM_PLAY_STD_CELL\">"
|
NumOptions = Tst_GetNumAnswersQst (Match->Status.QstCod);
|
||||||
"<div class=\"GAM_PLAY_STD_BUTTON BT_%c\">"
|
for (NumOpt = 0;
|
||||||
"%c"
|
NumOpt < NumOptions;
|
||||||
"</div>"
|
NumOpt++)
|
||||||
"</td>",
|
{
|
||||||
'A' + (char) NumOpt,
|
// if (NumOpt % 2 == 0)
|
||||||
'a' + (char) NumOpt);
|
fprintf (Gbl.F.Out,"<tr>");
|
||||||
|
|
||||||
// if (NumOpt % 2 == 1)
|
/***** Write letter for this option *****/
|
||||||
fprintf (Gbl.F.Out,"</tr>");
|
fprintf (Gbl.F.Out,"<td class=\"GAM_PLAY_STD_CELL\">"
|
||||||
|
"<div class=\"GAM_PLAY_STD_BUTTON BT_%c\">"
|
||||||
|
"%c"
|
||||||
|
"</div>"
|
||||||
|
"</td>",
|
||||||
|
'A' + (char) NumOpt,
|
||||||
|
'a' + (char) NumOpt);
|
||||||
|
|
||||||
|
// if (NumOpt % 2 == 1)
|
||||||
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** End table *****/
|
||||||
|
Tbl_EndTable ();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/***** End table *****/
|
Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game.");
|
||||||
Tbl_EndTable ();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game.");
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (Gbl.F.Out,"<img src=\"%s/wait.gif\""
|
|
||||||
" alt=\"Please wait\" title=\"%s\""
|
|
||||||
" class=\"GAM_PLAY_STD_WAIT\" />",
|
|
||||||
Cfg_URL_ICON_PUBLIC,
|
|
||||||
"Por favor, espere a que el juego comience..."); // TODO: Need translation!!!!!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,14 +124,14 @@ void Gam_RequestNewMatch (void);
|
||||||
// void Gam_PlayMatchStd (void);
|
// void Gam_PlayMatchStd (void);
|
||||||
|
|
||||||
void Gam_ReceiveGameAnswers (void);
|
void Gam_ReceiveGameAnswers (void);
|
||||||
void Gam_CreateAndStartNewMatch (void);
|
void Gam_CreateNewMatch (void);
|
||||||
void Gam_ResumeUnfinishedMatch (void);
|
void Gam_ResumeUnfinishedMatch (void);
|
||||||
void Gam_NextStatusMatch (void);
|
void Gam_NextStatusMatch (void);
|
||||||
|
|
||||||
void Gam_ShowFinishedMatchResults (void);
|
void Gam_ShowFinishedMatchResults (void);
|
||||||
|
|
||||||
void Gam_GetMatchBeingPlayed (void);
|
void Gam_GetMatchBeingPlayed (void);
|
||||||
void Gam_ShowNewMatchToMeAsStd (void);
|
void Gam_ShowMatchToMeAsStd (void);
|
||||||
void Gam_RefreshCurrentMatchStd (void);
|
void Gam_RefreshCurrentMatchStd (void);
|
||||||
|
|
||||||
unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope);
|
unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user