Version18.122.2

This commit is contained in:
Antonio Cañas Vargas 2019-05-20 12:26:15 +02:00
parent 2ea138f471
commit 91f6886e86
7 changed files with 220 additions and 78 deletions

View File

@ -598,6 +598,21 @@ CREATE TABLE IF NOT EXISTS forum_thread (
UNIQUE INDEX(FirstPstCod),
UNIQUE INDEX(LastPstCod));
--
-- Table games: stores the games
--
CREATE TABLE IF NOT EXISTS games (
GamCod INT NOT NULL AUTO_INCREMENT,
CrsCod INT NOT NULL DEFAULT -1,
Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',
NumNotif INT NOT NULL DEFAULT 0,
UsrCod INT NOT NULL,
StartTime DATETIME NOT NULL,
EndTime DATETIME NOT NULL,
Title VARCHAR(2047) NOT NULL,
Txt TEXT NOT NULL,
UNIQUE INDEX(GamCod),
INDEX(CrsCod));
--
-- Table gam_answers: stores the answers to the games
--
CREATE TABLE IF NOT EXISTS gam_answers (
@ -614,6 +629,17 @@ CREATE TABLE IF NOT EXISTS gam_grp (
GrpCod INT NOT NULL,
UNIQUE INDEX(GamCod,GrpCod));
--
-- Table gam_playing: stores the games beeing played currently
--
CREATE TABLE IF NOT EXISTS gam_playing (
GamCod INT NOT NULL,
QstCod INT NOT NULL DEFAULT -1,
QstInd INT NOT NULL DEFAULT 0,
ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N',
GamStart DATETIME NOT NULL,
QstStart DATETIME NOT NULL,
UNIQUE INDEX(GamCod));
--
-- Table gam_questions: stores the questions in the games
--
CREATE TABLE IF NOT EXISTS gam_questions (
@ -630,21 +656,6 @@ CREATE TABLE IF NOT EXISTS gam_users (
UsrCod INT NOT NULL,
UNIQUE INDEX(GamCod,UsrCod));
--
-- Table games: stores the games
--
CREATE TABLE IF NOT EXISTS games (
GamCod INT NOT NULL AUTO_INCREMENT,
CrsCod INT NOT NULL DEFAULT -1,
Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',
NumNotif INT NOT NULL DEFAULT 0,
UsrCod INT NOT NULL,
StartTime DATETIME NOT NULL,
EndTime DATETIME NOT NULL,
Title VARCHAR(2047) NOT NULL,
Txt TEXT NOT NULL,
UNIQUE INDEX(GamCod),
INDEX(CrsCod));
--
-- Table hidden_params: stores some hidden parameters passed from a page to another using database instead of forms
--
CREATE TABLE IF NOT EXISTS hidden_params (

View File

@ -605,11 +605,15 @@ Assessment:
452. ActReqRemSvyQst Request the removal of a question of a survey
453. ActRemSvyQst Confirm the removal of a question of a survey
454. ActSeeGam Show one game
455. ActStrGamTch Start playing a game
456. ActGamTch1stQst Show first question when playing a game
457. ActGamTchNxtQst Show next question when playing a game
458. ActGamTchAns Show answers of current question when playing a game
454. ActSeeGam Show one game
455. ActStrGamTch Start a game (by a teacher)
456. ActGamTch1stQst Show first question when playing a game (by a teacher)
457. ActGamTchNxtQst Show next question when playing a game (by a teacher)
458. ActGamTchAns Show answers of current question when playing a game (by a teacher)
NEW. ActPlyGamStd Play a game (by a student)
NEW. ActGamStdCurQst Show current question when playing a game (by a student)
459. ActAnsGam Answer a game
460. ActFrmNewGam Form to create a new game
461. ActEdiOneGam Edit one game
@ -2141,7 +2145,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
/* ActGamTchNxtQst */{1672,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_GameTchNextQuestion ,NULL},
/* ActGamTchAns */{1673,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,NULL ,Gam_GameTchShowAnswers ,NULL},
/* ActPlyGamStd */{1779,-1,TabUnk,ActSeeAllGam ,0x208,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_PlayGameStd ,NULL},
/* ActPlyGamStd */{1779,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_PlayGameStd ,NULL},
/* ActGamStdCurQst */{1780,-1,TabUnk,ActSeeAllGam ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Gam_GameStdCurrentQuestion ,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},
@ -4865,7 +4870,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActStrGamTch, // #1670
ActGamTch1stQst, // #1671
ActGamTchNxtQst, // #1672
ActGamTchAns, // #1673
ActGamTchAns, // #1673
ActSeePrj, // #1674
ActFrmNewPrj, // #1675
ActEdiOnePrj, // #1676
@ -4972,6 +4977,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActLckAllPrj, // #1777
ActUnlAllPrj, // #1778
ActPlyGamStd, // #1779
ActGamStdCurQst, // #1780
};
/*****************************************************************************/

View File

@ -64,9 +64,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 + 8 + 61 + 38 + 12 + 42 + 36 + 19 + 110 + 164 + 437 + 176 + 169 + 15 + 67)
#define Act_NUM_ACTIONS (1 + 8 + 61 + 38 + 12 + 42 + 36 + 19 + 110 + 165 + 437 + 176 + 169 + 15 + 67)
#define Act_MAX_ACTION_COD 1779
#define Act_MAX_ACTION_COD 1780
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
@ -610,55 +610,56 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActSeeGam (ActChgCrsTT1stDay + 116)
#define ActStrGamTch (ActChgCrsTT1stDay + 117)
#define ActGamTch1stQst (ActChgCrsTT1stDay + 118)
#define ActGamTchNxtQst (ActChgCrsTT1stDay + 119)
#define ActGamTch1stQst (ActChgCrsTT1stDay + 118)
#define ActGamTchNxtQst (ActChgCrsTT1stDay + 119)
#define ActGamTchAns (ActChgCrsTT1stDay + 120)
#define ActPlyGamStd (ActChgCrsTT1stDay + 121)
#define ActAnsGam (ActChgCrsTT1stDay + 122)
#define ActFrmNewGam (ActChgCrsTT1stDay + 123)
#define ActEdiOneGam (ActChgCrsTT1stDay + 124)
#define ActNewGam (ActChgCrsTT1stDay + 125)
#define ActChgGam (ActChgCrsTT1stDay + 126)
#define ActReqRemGam (ActChgCrsTT1stDay + 127)
#define ActRemGam (ActChgCrsTT1stDay + 128)
#define ActReqRstGam (ActChgCrsTT1stDay + 129)
#define ActRstGam (ActChgCrsTT1stDay + 130)
#define ActHidGam (ActChgCrsTT1stDay + 131)
#define ActShoGam (ActChgCrsTT1stDay + 132)
#define ActAddOneGamQst (ActChgCrsTT1stDay + 133)
#define ActGamLstTstQst (ActChgCrsTT1stDay + 134)
#define ActAddTstQstToGam (ActChgCrsTT1stDay + 135)
#define ActReqRemGamQst (ActChgCrsTT1stDay + 136)
#define ActRemGamQst (ActChgCrsTT1stDay + 137)
#define ActUp_GamQst (ActChgCrsTT1stDay + 138)
#define ActDwnGamQst (ActChgCrsTT1stDay + 139)
#define ActGamStdCurQst (ActChgCrsTT1stDay + 122)
#define ActAnsGam (ActChgCrsTT1stDay + 123)
#define ActFrmNewGam (ActChgCrsTT1stDay + 124)
#define ActEdiOneGam (ActChgCrsTT1stDay + 125)
#define ActNewGam (ActChgCrsTT1stDay + 126)
#define ActChgGam (ActChgCrsTT1stDay + 127)
#define ActReqRemGam (ActChgCrsTT1stDay + 128)
#define ActRemGam (ActChgCrsTT1stDay + 129)
#define ActReqRstGam (ActChgCrsTT1stDay + 130)
#define ActRstGam (ActChgCrsTT1stDay + 131)
#define ActHidGam (ActChgCrsTT1stDay + 132)
#define ActShoGam (ActChgCrsTT1stDay + 133)
#define ActAddOneGamQst (ActChgCrsTT1stDay + 134)
#define ActGamLstTstQst (ActChgCrsTT1stDay + 135)
#define ActAddTstQstToGam (ActChgCrsTT1stDay + 136)
#define ActReqRemGamQst (ActChgCrsTT1stDay + 137)
#define ActRemGamQst (ActChgCrsTT1stDay + 138)
#define ActUp_GamQst (ActChgCrsTT1stDay + 139)
#define ActDwnGamQst (ActChgCrsTT1stDay + 140)
#define ActSeeSvy (ActChgCrsTT1stDay + 140)
#define ActAnsSvy (ActChgCrsTT1stDay + 141)
#define ActFrmNewSvy (ActChgCrsTT1stDay + 142)
#define ActEdiOneSvy (ActChgCrsTT1stDay + 143)
#define ActNewSvy (ActChgCrsTT1stDay + 144)
#define ActChgSvy (ActChgCrsTT1stDay + 145)
#define ActReqRemSvy (ActChgCrsTT1stDay + 146)
#define ActRemSvy (ActChgCrsTT1stDay + 147)
#define ActReqRstSvy (ActChgCrsTT1stDay + 148)
#define ActRstSvy (ActChgCrsTT1stDay + 149)
#define ActHidSvy (ActChgCrsTT1stDay + 150)
#define ActShoSvy (ActChgCrsTT1stDay + 151)
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 152)
#define ActRcvSvyQst (ActChgCrsTT1stDay + 153)
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 154)
#define ActRemSvyQst (ActChgCrsTT1stDay + 155)
#define ActSeeSvy (ActChgCrsTT1stDay + 141)
#define ActAnsSvy (ActChgCrsTT1stDay + 142)
#define ActFrmNewSvy (ActChgCrsTT1stDay + 143)
#define ActEdiOneSvy (ActChgCrsTT1stDay + 144)
#define ActNewSvy (ActChgCrsTT1stDay + 145)
#define ActChgSvy (ActChgCrsTT1stDay + 146)
#define ActReqRemSvy (ActChgCrsTT1stDay + 147)
#define ActRemSvy (ActChgCrsTT1stDay + 148)
#define ActReqRstSvy (ActChgCrsTT1stDay + 149)
#define ActRstSvy (ActChgCrsTT1stDay + 150)
#define ActHidSvy (ActChgCrsTT1stDay + 151)
#define ActShoSvy (ActChgCrsTT1stDay + 152)
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 153)
#define ActRcvSvyQst (ActChgCrsTT1stDay + 154)
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 155)
#define ActRemSvyQst (ActChgCrsTT1stDay + 156)
#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 156)
#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 157)
#define ActEdiExaAnn (ActChgCrsTT1stDay + 158)
#define ActRcvExaAnn (ActChgCrsTT1stDay + 159)
#define ActPrnExaAnn (ActChgCrsTT1stDay + 160)
#define ActReqRemExaAnn (ActChgCrsTT1stDay + 161)
#define ActRemExaAnn (ActChgCrsTT1stDay + 162)
#define ActHidExaAnn (ActChgCrsTT1stDay + 163)
#define ActShoExaAnn (ActChgCrsTT1stDay + 164)
#define ActSeeOneExaAnn (ActChgCrsTT1stDay + 157)
#define ActSeeDatExaAnn (ActChgCrsTT1stDay + 158)
#define ActEdiExaAnn (ActChgCrsTT1stDay + 159)
#define ActRcvExaAnn (ActChgCrsTT1stDay + 160)
#define ActPrnExaAnn (ActChgCrsTT1stDay + 161)
#define ActReqRemExaAnn (ActChgCrsTT1stDay + 162)
#define ActRemExaAnn (ActChgCrsTT1stDay + 163)
#define ActHidExaAnn (ActChgCrsTT1stDay + 164)
#define ActShoExaAnn (ActChgCrsTT1stDay + 165)
/*****************************************************************************/
/******************************** Files tab **********************************/

View File

@ -448,10 +448,15 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.122.1 (2019-05-18)"
#define Log_PLATFORM_VERSION "SWAD 18.122.2 (2019-05-18)"
#define CSS_FILE "swad18.112.1.css"
#define JS_FILE "swad18.116.5.js"
/*
Version 18.122.2: May 20, 2019 New action to show current question (in a game beeing played) to a student. (242378 lines)
2 changes necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1780','es','N','Mostrar juego a estudiante');
CREATE TABLE IF NOT EXISTS gam_playing (GamCod INT NOT NULL,QstCod INT NOT NULL DEFAULT -1,QstInd INT NOT NULL DEFAULT 0,ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N',GamStart DATETIME NOT NULL,QstStart DATETIME NOT NULL,UNIQUE INDEX(GamCod));
Version 18.122.1: May 20, 2019 New action to play game by a student. (242257 lines)
2 changes necessary in database:
UPDATE actions SET Txt='Preparar para comenzar juego' WHERE ActCod='1670' AND Language='es';

View File

@ -1370,6 +1370,30 @@ mysql> DESCRIBE gam_grp;
"GrpCod INT NOT NULL,"
"UNIQUE INDEX(GamCod,GrpCod))");
/***** Table gam_playing *****/
/*
mysql> DESCRIBE gam_playing;
+----------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+---------------+------+-----+---------+-------+
| GamCod | int(11) | NO | PRI | NULL | |
| QstCod | int(11) | NO | | -1 | |
| QstInd | int(11) | NO | | 0 | |
| ShowingAnswers | enum('N','Y') | NO | | N | |
| GamStart | datetime | NO | | NULL | |
| QstStart | datetime | NO | | NULL | |
+----------------+---------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_playing ("
"GamCod INT NOT NULL,"
"QstCod INT NOT NULL DEFAULT -1,"
"QstInd INT NOT NULL DEFAULT 0,"
"ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N',"
"GamStart DATETIME NOT NULL,"
"QstStart DATETIME NOT NULL,"
"UNIQUE INDEX(GamCod))");
/***** Table gam_questions *****/
/*
mysql> DESCRIBE gam_questions;

View File

@ -618,13 +618,26 @@ static void Gam_ShowOneGame (long GamCod,
/* Possible button to answer this game */
if (Game.Status.ICanAnswer)
{
Frm_StartForm (ActStrGamTch);
Gam_PutParamGameCod (Game.GamCod);
Gam_PutHiddenParamGameOrder ();
Grp_PutParamWhichGrps ();
Pag_PutHiddenParamPagNum (Pag_GAMES,Gbl.Games.CurrentPage);
Btn_PutCreateButtonInline (Txt_Play);
Frm_EndForm ();
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_STD:
/* Icon to play game */
Frm_StartForm (ActPlyGamStd);
Gam_PutParamGameCod (Game.GamCod);
Btn_PutCreateButtonInline (Txt_Play);
Frm_EndForm ();
break;
case Rol_NET:
case Rol_TCH:
/* Icon to start game */
Frm_StartForm (ActStrGamTch);
Gam_PutParamGameCod (Game.GamCod);
Btn_PutCreateButtonInline (Txt_Start_game);
Frm_EndForm ();
break;
default:
break;
}
}
fprintf (Gbl.F.Out,"</div>");
@ -2982,7 +2995,7 @@ static void Gam_PutBigButtonToPlayGameStd (long GamCod)
extern const char *Txt_Play;
/***** Start form *****/
Frm_StartForm (ActPlyGamStd);
Frm_StartForm (ActGamStdCurQst);
Gam_PutParamGameCod (GamCod);
Gam_PutParamQstInd (0); // Start by first question in game
@ -3145,6 +3158,86 @@ static void Gam_PutBigButtonToContinue (Act_Action_t NextAction,
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/***** Show current question to a student when he/she is playing a game ******/
/*****************************************************************************/
void Gam_GameStdCurrentQuestion (void)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
struct Game Game;
unsigned QstInd;
long QstCod;
bool ShowAnswers = true; // TODO: Get whether to show answers from a database table
/***** Get parameters *****/
/* Get game code */
if ((Game.GamCod = Gam_GetParamGameCod ()) == -1L)
Lay_ShowErrorAndExit ("Code of game is missing.");
/* Get question index */
QstInd = Gam_GetParamQstInd (); // TODO: Get current question from a database table
/***** Get data of question from database *****/
if (!DB_QuerySELECT (&mysql_res,"can not get data of a question",
"SELECT tst_questions.QstCod," // row[0]
"tst_questions.AnsType," // row[1]
"tst_questions.Stem," // row[2]
"tst_questions.MedCod" // row[3]
" 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))
Ale_ShowAlert (Ale_ERROR,"Question doesn't exist.");
row = mysql_fetch_row (mysql_res);
/***** Show question *****/
/* Start container for number and 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);
fprintf (Gbl.F.Out,"<div class=\"GAM_PLAY_QST_CONTAINER\">");
/* Write stem (row[2]) */
Tst_WriteQstStem (row[2],"GAM_PLAY_QST");
/* Get media (row[3]) */
Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[3]);
Med_GetMediaDataByCod (&Gbl.Test.Media);
/* Show media */
Med_ShowMedia (&Gbl.Test.Media,
"TEST_MED_EDIT_LIST_STEM_CONTAINER",
"TEST_MED_EDIT_LIST_STEM");
/* Write answers? */
if (ShowAnswers)
{
/* Get question code (row[0]) */
if ((QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Lay_ShowErrorAndExit ("Error: wrong question code.");
/* Get answer type (row[1]) */
Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
/* Write answers */
Tst_WriteAnswersGameResult (&Game,QstInd,QstCod,
"GAM_PLAY_QST",false); // Don't show result
}
else
fprintf (Gbl.F.Out,"&nbsp;");
fprintf (Gbl.F.Out,"</div>");
/***** End container for question *****/
fprintf (Gbl.F.Out,"</div>");
}
/*****************************************************************************/
/************************ Receive answers of a game ************************/
/*****************************************************************************/

View File

@ -125,6 +125,8 @@ void Gam_ReceiveGameAnswers (void);
void Gam_GameTchNextQuestion (void);
void Gam_GameTchShowAnswers (void);
void Gam_GameStdCurrentQuestion (void);
unsigned Gam_GetNumCoursesWithGames (Hie_Level_t Scope);
unsigned Gam_GetNumGames (Hie_Level_t Scope);
float Gam_GetNumQstsPerCrsGame (Hie_Level_t Scope);