mirror of https://github.com/acanas/swad-core.git
Version19.5
This commit is contained in:
parent
2ca71e4120
commit
e07fbb1e72
|
@ -640,7 +640,7 @@ CREATE TABLE IF NOT EXISTS mch_matches (
|
|||
QstCod INT NOT NULL DEFAULT -1,
|
||||
QstStartTime DATETIME NOT NULL,
|
||||
ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y',
|
||||
Showing ENUM('stem','answers','results') NOT NULL DEFAULT 'stem',
|
||||
Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing',
|
||||
UNIQUE INDEX(MchCod),
|
||||
INDEX(GamCod));
|
||||
--
|
||||
|
|
|
@ -462,12 +462,23 @@ ps2pdf source.ps destination.pdf
|
|||
/*
|
||||
can not remove the groups associated to matches of a game
|
||||
Type of answer not valid in a game.
|
||||
|
||||
|
||||
¿Eliminar botón de reset en un juego? Tal vez sí, para simplificar. No tiene sentido resetear todas las partidas de un juego.
|
||||
¿Poner botón de reset en una partida? No parece necesario, basta con eliminarla y crear otra
|
||||
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.4.2 (2019-09-17)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.5 (2019-09-17)"
|
||||
#define CSS_FILE "swad19.3.css"
|
||||
#define JS_FILE "swad18.130.2.js"
|
||||
/*
|
||||
Version 19.5: Sep 17, 2019 Fixed bugs related with edition of games.
|
||||
Fixed bugs related with behaviour of matches. (244691 lines)
|
||||
2 changes necessary in database:
|
||||
ALTER TABLE mch_matches DROP COLUMN Showing;
|
||||
ALTER TABLE mch_matches ADD COLUMN Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing' AFTER ShowResults;
|
||||
|
||||
Version 19.4.2: Sep 17, 2019 Fixed bug when removing a question in a game. (244654 lines)
|
||||
Version 19.4.1: Sep 17, 2019 Fixed bug when removing a question in a game. (244650 lines)
|
||||
Version 19.4: Sep 17, 2019 Changes in games ans matches tables. (244644 lines)
|
||||
|
|
|
@ -1369,21 +1369,21 @@ mysql> DESCRIBE mch_groups;
|
|||
/***** Table mch_matches *****/
|
||||
/*
|
||||
mysql> DESCRIBE mch_matches;
|
||||
+--------------+----------------------------------+------+-----+---------+----------------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------------+----------------------------------+------+-----+---------+----------------+
|
||||
| MchCod | int(11) | NO | PRI | NULL | auto_increment |
|
||||
| GamCod | int(11) | NO | MUL | NULL | |
|
||||
| UsrCod | int(11) | NO | | NULL | |
|
||||
| StartTime | datetime | NO | | NULL | |
|
||||
| EndTime | datetime | NO | | NULL | |
|
||||
| Title | varchar(2047) | NO | | NULL | |
|
||||
| QstInd | int(11) | NO | | 0 | |
|
||||
| QstCod | int(11) | NO | | -1 | |
|
||||
| QstStartTime | datetime | NO | | NULL | |
|
||||
| ShowResults | enum('N','Y') | NO | | Y | |
|
||||
| Showing | enum('stem','answers','results') | NO | | stem | |
|
||||
+--------------+----------------------------------+------+-----+---------+----------------+
|
||||
+--------------+--------------------------------------------+------+-----+---------+----------------+
|
||||
| Field | Type | Null | Key | Default | Extra |
|
||||
+--------------+--------------------------------------------+------+-----+---------+----------------+
|
||||
| MchCod | int(11) | NO | PRI | NULL | auto_increment |
|
||||
| GamCod | int(11) | NO | MUL | NULL | |
|
||||
| UsrCod | int(11) | NO | | NULL | |
|
||||
| StartTime | datetime | NO | | NULL | |
|
||||
| EndTime | datetime | NO | | NULL | |
|
||||
| Title | varchar(2047) | NO | | NULL | |
|
||||
| QstInd | int(11) | NO | | 0 | |
|
||||
| QstCod | int(11) | NO | | -1 | |
|
||||
| QstStartTime | datetime | NO | | NULL | |
|
||||
| ShowResults | enum('N','Y') | NO | | Y | |
|
||||
| Showing | enum('nothing','stem','answers','results') | NO | | nothing | |
|
||||
+--------------+--------------------------------------------+------+-----+---------+----------------+
|
||||
11 rows in set (0.00 sec)
|
||||
*/
|
||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS mch_matches ("
|
||||
|
@ -1397,7 +1397,7 @@ mysql> DESCRIBE mch_matches;
|
|||
"QstCod INT NOT NULL DEFAULT -1,"
|
||||
"QstStartTime DATETIME NOT NULL,"
|
||||
"ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y',"
|
||||
"Showing ENUM('stem','answers','request','results') NOT NULL DEFAULT 'stem',"
|
||||
"Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing',"
|
||||
"UNIQUE INDEX(MchCod),"
|
||||
"INDEX(GamCod)");
|
||||
|
||||
|
|
28
swad_game.c
28
swad_game.c
|
@ -1604,18 +1604,17 @@ static void Gam_ListGameQuestions (struct Game *Game)
|
|||
extern const char *Hlp_ASSESSMENT_Games_questions;
|
||||
extern const char *Txt_Questions;
|
||||
extern const char *Txt_This_game_has_no_questions;
|
||||
extern const char *Txt_Done;
|
||||
MYSQL_RES *mysql_res;
|
||||
unsigned NumQsts;
|
||||
bool Editing = (Gbl.Action.Act == ActEdiOneGam ||
|
||||
Gbl.Action.Act == ActAddOneGamQst);
|
||||
Tst_ActionToDoWithQuestions_t ActionToDoWithQuestions;
|
||||
Gbl.Action.Act == ActAddOneGamQst); // TODO: Ampliar casos en los que se está editando para que se muestre el botón de Añadir preguntas
|
||||
// Tst_ActionToDoWithQuestions_t ActionToDoWithQuestions;
|
||||
|
||||
/***** How to show the questions ******/
|
||||
if (Editing)
|
||||
ActionToDoWithQuestions = Tst_SHOW_GAME_RESULT;
|
||||
else
|
||||
ActionToDoWithQuestions = Tst_SHOW_GAME_TO_ANSWER;
|
||||
// if (Editing)
|
||||
// ActionToDoWithQuestions = Tst_SHOW_GAME_RESULT;
|
||||
//else
|
||||
// ActionToDoWithQuestions = Tst_SHOW_GAME_TO_ANSWER;
|
||||
|
||||
/***** Get data of questions from database *****/
|
||||
NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||
|
@ -1638,19 +1637,8 @@ static void Gam_ListGameQuestions (struct Game *Game)
|
|||
Hlp_ASSESSMENT_Games_questions,Box_NOT_CLOSABLE);
|
||||
|
||||
if (NumQsts)
|
||||
{
|
||||
/***** Show the table with the questions *****/
|
||||
Gam_ListOneOrMoreQuestionsForEdition (Game->GamCod,NumQsts,mysql_res);
|
||||
|
||||
if (ActionToDoWithQuestions == Tst_SHOW_GAME_TO_ANSWER)
|
||||
{
|
||||
/***** Button to create/modify game *****/
|
||||
Btn_PutConfirmButton (Txt_Done);
|
||||
|
||||
/***** End form *****/
|
||||
Frm_EndForm ();
|
||||
}
|
||||
}
|
||||
else // This game has no questions
|
||||
Ale_ShowAlert (Ale_INFO,Txt_This_game_has_no_questions);
|
||||
|
||||
|
@ -1844,10 +1832,10 @@ static void Gam_ListOneOrMoreQuestionsForEdition (long GamCod,unsigned NumQsts,
|
|||
Tbl_EndTable ();
|
||||
|
||||
/***** Button to add a new question *****/
|
||||
Gam_PutButtonToAddNewQuestions ();
|
||||
// Gam_PutButtonToAddNewQuestions ();
|
||||
|
||||
/***** End box *****/
|
||||
Box_EndBox ();
|
||||
// Box_EndBox ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
171
swad_match.c
171
swad_match.c
|
@ -68,14 +68,15 @@ extern struct Globals Gbl;
|
|||
/******************************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Mch_NUM_SHOWING 3
|
||||
#define Mch_NUM_SHOWING 4
|
||||
typedef enum
|
||||
{
|
||||
Mch_NOTHING, // Don't show anything
|
||||
Mch_STEM, // Showing only the question stem
|
||||
Mch_ANSWERS, // Showing the question stem and the answers
|
||||
Mch_RESULTS, // Showing the results
|
||||
} Mch_Showing_t;
|
||||
#define Mch_SHOWING_DEFAULT Mch_STEM
|
||||
#define Mch_SHOWING_DEFAULT Mch_NOTHING
|
||||
|
||||
struct Match
|
||||
{
|
||||
|
@ -91,7 +92,7 @@ struct Match
|
|||
time_t QstStartTimeUTC;
|
||||
bool ShowResults;
|
||||
Mch_Showing_t Showing;
|
||||
bool BeingPlayed;
|
||||
bool Playing;
|
||||
unsigned NumPlayers;
|
||||
} Status;
|
||||
};
|
||||
|
@ -102,6 +103,7 @@ struct Match
|
|||
|
||||
const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
|
||||
{
|
||||
"nothing",
|
||||
"stem",
|
||||
"answers",
|
||||
"results",
|
||||
|
@ -150,7 +152,13 @@ static void Mch_GetElapsedTime (unsigned NumRows,MYSQL_RES *mysql_res,
|
|||
struct Time *Time);
|
||||
|
||||
static void Mch_SetMatchStatusToPrev (struct Match *Match);
|
||||
static void Mch_SetMatchStatusToPrevQst (struct Match *Match);
|
||||
static void Mch_SetMatchStatusToStart (struct Match *Match);
|
||||
|
||||
static void Mch_SetMatchStatusToNext (struct Match *Match);
|
||||
static void Mch_SetMatchStatusToNextQst (struct Match *Match);
|
||||
static void Mch_SetMatchStatusToEnd (struct Match *Match);
|
||||
|
||||
static void Mch_ShowMatchStatusForTch (struct Match *Match);
|
||||
static void Mch_ShowMatchStatusForStd (struct Match *Match);
|
||||
static bool Mch_CheckIfIPlayThisMatchBasedOnGrps (long MchCod);
|
||||
|
@ -318,7 +326,7 @@ static void Mch_GetDataOfMatchByCod (struct Match *Match)
|
|||
Match->Status.QstStartTimeUTC = (time_t) 0;
|
||||
Match->Status.ShowResults = true;
|
||||
Match->Status.Showing = Mch_STEM;
|
||||
Match->Status.BeingPlayed = false;
|
||||
Match->Status.Playing = false;
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
@ -642,9 +650,9 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
|
|||
|
||||
/***** Get whether the match is being played or not *****/
|
||||
if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished
|
||||
Match->Status.BeingPlayed = false;
|
||||
Match->Status.Playing = false;
|
||||
else // Unfinished
|
||||
Match->Status.BeingPlayed = Mch_GetIfMatchIsBeingPlayed (Match->MchCod);
|
||||
Match->Status.Playing = Mch_GetIfMatchIsBeingPlayed (Match->MchCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1074,7 +1082,7 @@ static void Mch_UpdateMatchStatusInDB (struct Match *Match)
|
|||
Mch_ShowingStringsDB[Match->Status.Showing],
|
||||
Match->MchCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
if (Match->Status.BeingPlayed)
|
||||
if (Match->Status.Playing)
|
||||
/* Update match as being played */
|
||||
Mch_UpdateMatchAsBeingPlayed (Match->MchCod);
|
||||
else
|
||||
|
@ -1089,7 +1097,7 @@ static void Mch_UpdateMatchStatusInDB (struct Match *Match)
|
|||
static void Mch_UpdateElapsedTimeInQuestion (struct Match *Match)
|
||||
{
|
||||
/***** Update elapsed time in current question in database *****/
|
||||
if (Match->Status.BeingPlayed &&
|
||||
if (Match->Status.Playing &&
|
||||
Match->Status.QstInd > 0 &&
|
||||
Match->Status.QstInd < Mch_AFTER_LAST_QUESTION)
|
||||
DB_QueryINSERT ("can not update elapsed time in question",
|
||||
|
@ -1194,7 +1202,7 @@ void Mch_PauseMatchTch (void)
|
|||
Mch_GetDataOfMatchByCod (&Match);
|
||||
|
||||
/***** Update status *****/
|
||||
Match.Status.BeingPlayed = false; // Resume match
|
||||
Match.Status.Playing = false; // Pause match
|
||||
|
||||
/***** Update match status in database *****/
|
||||
Mch_UpdateMatchStatusInDB (&Match);
|
||||
|
@ -1226,7 +1234,7 @@ void Mch_ResumeMatchTch (void)
|
|||
{
|
||||
if (Match.Status.QstInd == 0) // Match has been created, but it has not started
|
||||
Mch_SetMatchStatusToNext (&Match);
|
||||
Match.Status.BeingPlayed = true; // Start/resume match
|
||||
Match.Status.Playing = true; // Start/resume match
|
||||
}
|
||||
|
||||
/***** Update match status in database *****/
|
||||
|
@ -1332,33 +1340,50 @@ void Mch_ForwardMatchTch (void)
|
|||
static void Mch_SetMatchStatusToPrev (struct Match *Match)
|
||||
{
|
||||
/***** What to show *****/
|
||||
switch (Match->Status.Showing)
|
||||
{
|
||||
case Mch_STEM:
|
||||
Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
|
||||
Mch_ANSWERS;
|
||||
if (Match->Status.QstInd == 0) // Start
|
||||
Mch_SetMatchStatusToStart (Match);
|
||||
else if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // End
|
||||
Mch_SetMatchStatusToPrevQst (Match);
|
||||
else // Between start and end
|
||||
switch (Match->Status.Showing)
|
||||
{
|
||||
case Mch_NOTHING:
|
||||
case Mch_STEM:
|
||||
Mch_SetMatchStatusToPrevQst (Match);
|
||||
break;
|
||||
case Mch_ANSWERS:
|
||||
Match->Status.Showing = Mch_STEM;
|
||||
break;
|
||||
case Mch_RESULTS:
|
||||
Match->Status.Showing = Mch_ANSWERS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/***** Get index of the previous question *****/
|
||||
Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
if (Match->Status.QstInd == 0) // Start of questions has been reached
|
||||
{
|
||||
Match->Status.QstCod = -1L; // No previous questions
|
||||
Match->Status.BeingPlayed = false; // Match is not being played
|
||||
}
|
||||
else
|
||||
Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
break;
|
||||
case Mch_ANSWERS:
|
||||
Match->Status.Showing = Mch_STEM;
|
||||
break;
|
||||
case Mch_RESULTS:
|
||||
Match->Status.Showing = Mch_ANSWERS;
|
||||
break;
|
||||
static void Mch_SetMatchStatusToPrevQst (struct Match *Match)
|
||||
{
|
||||
/***** Get index of the previous question *****/
|
||||
Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
if (Match->Status.QstInd == 0) // Start of questions has been reached
|
||||
Mch_SetMatchStatusToStart (Match);
|
||||
else
|
||||
{
|
||||
Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
|
||||
Mch_ANSWERS;
|
||||
}
|
||||
}
|
||||
|
||||
static void Mch_SetMatchStatusToStart (struct Match *Match)
|
||||
{
|
||||
Match->Status.QstInd = 0; // Before first question
|
||||
Match->Status.QstCod = -1L;
|
||||
Match->Status.Playing = false;
|
||||
Match->Status.Showing = Mch_NOTHING;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Set match status to next (forward) status ******************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1366,37 +1391,56 @@ static void Mch_SetMatchStatusToPrev (struct Match *Match)
|
|||
static void Mch_SetMatchStatusToNext (struct Match *Match)
|
||||
{
|
||||
/***** What to show *****/
|
||||
switch (Match->Status.Showing)
|
||||
{
|
||||
case Mch_STEM:
|
||||
Match->Status.Showing = Mch_ANSWERS;
|
||||
break;
|
||||
case Mch_ANSWERS:
|
||||
Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
|
||||
Mch_STEM;
|
||||
break;
|
||||
case Mch_RESULTS:
|
||||
Match->Status.Showing = Mch_STEM;
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Go to next question? *****/
|
||||
if (Match->Status.Showing == Mch_STEM)
|
||||
{
|
||||
/***** Get index of the next question *****/
|
||||
Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
if (Match->Status.QstInd < Mch_AFTER_LAST_QUESTION) // Unfinished
|
||||
Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
else // Finished
|
||||
if (Match->Status.QstInd == 0) // Start
|
||||
Mch_SetMatchStatusToNextQst (Match);
|
||||
else if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // End
|
||||
Mch_SetMatchStatusToEnd (Match);
|
||||
else // Between start and end
|
||||
switch (Match->Status.Showing)
|
||||
{
|
||||
Match->Status.QstCod = -1L; // No more questions
|
||||
Match->Status.BeingPlayed = false;
|
||||
case Mch_NOTHING:
|
||||
Match->Status.Showing = Mch_STEM;
|
||||
break;
|
||||
case Mch_STEM:
|
||||
Match->Status.Showing = Mch_ANSWERS;
|
||||
break;
|
||||
case Mch_ANSWERS:
|
||||
if (Match->Status.ShowResults)
|
||||
Match->Status.Showing = Mch_RESULTS;
|
||||
else
|
||||
Mch_SetMatchStatusToNextQst (Match);
|
||||
break;
|
||||
case Mch_RESULTS:
|
||||
Mch_SetMatchStatusToNextQst (Match);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void Mch_SetMatchStatusToNextQst (struct Match *Match)
|
||||
{
|
||||
/***** Get index of the next question *****/
|
||||
Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
|
||||
/***** Get question code *****/
|
||||
if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished
|
||||
Mch_SetMatchStatusToEnd (Match);
|
||||
else // Unfinished
|
||||
{
|
||||
Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod,
|
||||
Match->Status.QstInd);
|
||||
Match->Status.Showing = Mch_STEM;
|
||||
}
|
||||
}
|
||||
|
||||
static void Mch_SetMatchStatusToEnd (struct Match *Match)
|
||||
{
|
||||
Match->Status.QstInd = Mch_AFTER_LAST_QUESTION; // After last question
|
||||
Match->Status.QstCod = -1L;
|
||||
Match->Status.Playing = false;
|
||||
Match->Status.Showing = Mch_NOTHING;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Show current match status (number, question, answers, button) *******/
|
||||
/*****************************************************************************/
|
||||
|
@ -1459,7 +1503,7 @@ static void Mch_ShowMatchStatusForStd (struct Match *Match)
|
|||
/***** Update players ******/
|
||||
Mch_RegisterMeAsPlayerInMatch (Match->MchCod);
|
||||
|
||||
if (Match->Status.BeingPlayed)
|
||||
if (Match->Status.Playing)
|
||||
/* Show current question and possible answers */
|
||||
Mch_ShowQuestionAndAnswersStd (Match);
|
||||
else // Not being played
|
||||
|
@ -1536,7 +1580,7 @@ static void Mch_ShowLeftColumnTch (struct Match *Match)
|
|||
Mch_ShowNumPlayers (Match);
|
||||
|
||||
/***** Number of users who have answered this question *****/
|
||||
if (Match->Status.BeingPlayed)
|
||||
if (Match->Status.Playing)
|
||||
{
|
||||
NumAnswerersQst = Mch_GetNumUsrsWhoHaveAnswerQst (Match->MchCod,
|
||||
Match->Status.QstInd);
|
||||
|
@ -1619,7 +1663,7 @@ static void Mch_PutMatchControlButtons (struct Match *Match)
|
|||
|
||||
/***** Center button *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"MATCH_BUTTON_CENTER_CONTAINER\">");
|
||||
if (Match->Status.BeingPlayed) // Being played
|
||||
if (Match->Status.Playing) // Being played
|
||||
/* Put button to pause match */
|
||||
Mch_PutBigButton (ActPauMchTch,
|
||||
Match->MchCod,
|
||||
|
@ -1768,11 +1812,12 @@ static void Mch_ShowQuestionAndAnswersTch (struct Match *Match)
|
|||
/* Write answers? */
|
||||
switch (Match->Status.Showing)
|
||||
{
|
||||
case Mch_NOTHING:
|
||||
case Mch_STEM:
|
||||
/* Don't write anything */
|
||||
break;
|
||||
case Mch_ANSWERS:
|
||||
if (Match->Status.BeingPlayed) // Being played
|
||||
if (Match->Status.Playing) // Being played
|
||||
/* Write answers */
|
||||
Tst_WriteAnswersMatchResult (Match->MchCod,
|
||||
Match->Status.QstInd,
|
||||
|
|
|
@ -71,7 +71,7 @@ typedef enum
|
|||
typedef enum
|
||||
{
|
||||
Tst_SHOW_TEST_TO_ANSWER, // Showing a test to a student
|
||||
Tst_SHOW_TEST_RESULT, // Showing the assessment of a test
|
||||
Tst_SHOW_TEST_RESULT, // Showing the assessment of a test
|
||||
Tst_EDIT_TEST, // Editing test questions
|
||||
Tst_SELECT_QUESTIONS_FOR_GAME, // Selecting test questions for a game
|
||||
Tst_SHOW_GAME_TO_ANSWER, // Showing a game to a student
|
||||
|
|
Loading…
Reference in New Issue