mirror of https://github.com/acanas/swad-core.git
Version18.139.1
This commit is contained in:
parent
881deaeb67
commit
51f1483a77
|
@ -460,10 +460,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.139 (2019-08-03)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.139.1 (2019-08-03)"
|
||||
#define CSS_FILE "swad18.138.css"
|
||||
#define JS_FILE "swad18.130.2.js"
|
||||
/*
|
||||
Version 18.139.1: Aug 03, 2019 Get elapsed time in a question and in a match. (244216 lines)
|
||||
Version 18.139: Aug 03, 2019 Time of current match and current match question are stored in database. (244150 lines)
|
||||
1 change necessary in database:
|
||||
CREATE TABLE IF NOT EXISTS gam_time (MchCod INT NOT NULL,QstInd INT NOT NULL,ElapsedTime TIME NOT NULL DEFAULT 0,UNIQUE INDEX(MchCod,QstInd));
|
||||
|
|
78
swad_game.c
78
swad_game.c
|
@ -187,7 +187,12 @@ static void Gam_PutFormNewMatch (struct Game *Game);
|
|||
|
||||
static long Gam_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1]);
|
||||
static void Gam_UpdateMatchStatusInDB (struct Match *Match);
|
||||
|
||||
static void Gam_UpdateElapsedTimeInQuestion (struct Match *Match);
|
||||
static void Gam_GetElapsedTimeInQuestion (struct Match *Match,
|
||||
char HHHMMSS[3 + 1 + 2 + 1 + 2 + 1]);
|
||||
static void Gam_GetElapsedTimeInMatch (struct Match *Match,
|
||||
char HHHMMSS[3 + 1 + 2 + 1 + 2 + 1]);
|
||||
|
||||
static void Gam_SetMatchStatusToPrevQuestion (struct Match *Match);
|
||||
static void Gam_SetMatchStatusToNextQuestion (struct Match *Match);
|
||||
|
@ -3344,7 +3349,7 @@ static void Gam_UpdateMatchStatusInDB (struct Match *Match)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Update elapsed time in current question (by a teacher) **/
|
||||
/********** Update elapsed time in current question (by a teacher) ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Gam_UpdateElapsedTimeInQuestion (struct Match *Match)
|
||||
|
@ -3363,6 +3368,77 @@ static void Gam_UpdateElapsedTimeInQuestion (struct Match *Match)
|
|||
Cfg_SECONDS_TO_REFRESH_GAME);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get elapsed time in a match question ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Gam_GetElapsedTimeInQuestion (struct Match *Match,
|
||||
char HHHMMSS[3 + 1 + 2 + 1 + 2 + 1])
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumRows;
|
||||
|
||||
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
||||
"SELECT ElapsedTime"
|
||||
" FROM gam_time"
|
||||
" WHERE MchCod=%ld AND QstInd=%u",
|
||||
Match->MchCod,Match->Status.QstInd);
|
||||
if (NumRows)
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get the elapsed time (row[0]) */
|
||||
if (strlen (row[0]) > 2 + 1 + 2 + 1 + 2)
|
||||
Str_Copy (HHHMMSS,"+99:59:59",
|
||||
Gam_MAX_BYTES_TITLE);
|
||||
else
|
||||
Str_Copy (HHHMMSS,row[0],
|
||||
Gam_MAX_BYTES_TITLE);
|
||||
}
|
||||
else
|
||||
Str_Copy (HHHMMSS,"00:00:00",
|
||||
Gam_MAX_BYTES_TITLE);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get elapsed time in a match *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Gam_GetElapsedTimeInMatch (struct Match *Match,
|
||||
char HHHMMSS[3 + 1 + 2 + 1 + 2 + 1])
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumRows;
|
||||
|
||||
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
||||
"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ElapsedTime)))"
|
||||
" FROM gam_time WHERE MchCod=%ld",
|
||||
Match->MchCod);
|
||||
if (NumRows)
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get the elapsed time (row[0]) */
|
||||
if (strlen (row[0]) > 2 + 1 + 2 + 1 + 2)
|
||||
Str_Copy (HHHMMSS,"+99:59:59",
|
||||
Gam_MAX_BYTES_TITLE);
|
||||
else
|
||||
Str_Copy (HHHMMSS,row[0],
|
||||
Gam_MAX_BYTES_TITLE);
|
||||
}
|
||||
else
|
||||
Str_Copy (HHHMMSS,"00:00:00",
|
||||
Gam_MAX_BYTES_TITLE);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Show current match status (current question, answers...) (by a teacher) **/
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue