Version19.9.2

This commit is contained in:
Antonio Cañas Vargas 2019-09-23 09:03:55 +02:00
parent a7d997a446
commit 8e3a5e671b
4 changed files with 64 additions and 27 deletions

View File

@ -663,6 +663,8 @@ CREATE TABLE IF NOT EXISTS mch_players (
CREATE TABLE IF NOT EXISTS mch_results (
MchCod INT NOT NULL,
UsrCod INT NOT NULL,
StartTime DATETIME NOT NULL,
EndTime DATETIME NOT NULL,
NumQsts INT NOT NULL DEFAULT 0,
NumQstsNotBlank INT NOT NULL DEFAULT 0,
Score DOUBLE PRECISION NOT NULL DEFAULT 0,

View File

@ -468,10 +468,15 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 19.9.1 (2019-09-23)"
#define Log_PLATFORM_VERSION "SWAD 19.9.2 (2019-09-23)"
#define CSS_FILE "swad19.3.css"
#define JS_FILE "swad18.130.2.js"
/*
Version 19.9.2: Sep 23, 2019 View matches results. Not finished. (245598 lines)
2 changes necessary in database:
DROP TABLE IF EXISTS mch_results;
CREATE TABLE IF NOT EXISTS mch_results (MchCod INT NOT NULL,UsrCod INT NOT NULL,StartTime DATETIME NOT NULL,EndTime DATETIME NOT NULL,NumQsts INT NOT NULL DEFAULT 0,NumQstsNotBlank INT NOT NULL DEFAULT 0,Score DOUBLE PRECISION NOT NULL DEFAULT 0,UNIQUE INDEX(MchCod,UsrCod));
Version 19.9.1: Sep 23, 2019 View matches results. Not finished. (245562 lines)
Version 19.9: Sep 23, 2019 View matches results. Not finished. (245579 lines)
2 changes necessary in database:

View File

@ -1436,20 +1436,24 @@ mysql> DESCRIBE mch_players;
/***** Table mch_results *****/
/*
mysql> DESCRIBE mch_results;
+-----------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+---------+------+-----+---------+-------+
| MchCod | int(11) | NO | PRI | NULL | |
| UsrCod | int(11) | NO | PRI | NULL | |
| NumQsts | int(11) | NO | | 0 | |
| NumQstsNotBlank | int(11) | NO | | 0 | |
| Score | double | NO | | 0 | |
+-----------------+---------+------+-----+---------+-------+
5 rows in set (0.00 sec)
+-----------------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+----------+------+-----+---------+-------+
| MchCod | int(11) | NO | PRI | NULL | |
| UsrCod | int(11) | NO | PRI | NULL | |
| StartTime | datetime | NO | | NULL | |
| EndTime | datetime | NO | | NULL | |
| NumQsts | int(11) | NO | | 0 | |
| NumQstsNotBlank | int(11) | NO | | 0 | |
| Score | double | NO | | 0 | |
+-----------------+----------+------+-----+---------+-------+
7 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS mch_results ("
"MchCod INT NOT NULL,"
"UsrCod INT NOT NULL,"
"StartTime DATETIME NOT NULL," // Time this user started to answer
"EndTime DATETIME NOT NULL," // Time this user finished to answer
"NumQsts INT NOT NULL DEFAULT 0,"
"NumQstsNotBlank INT NOT NULL DEFAULT 0,"
"Score DOUBLE PRECISION NOT NULL DEFAULT 0,"

View File

@ -2331,13 +2331,35 @@ void Mch_ReceiveQstAnsFromStd (void)
Mch_ComputeScore (&Match,NumQsts,&NumQstsNotBlank,&TotalScore);
Str_SetDecimalPointToUS (); // To print the floating point as a dot
DB_QueryREPLACE ("can not update match result",
"REPLACE mch_results"
" (MchCod,UsrCod,NumQsts,NumQstsNotBlank,Score)"
" VALUES"
" (%ld,%ld,%u,%u,'%lf')",
Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod,
NumQsts,NumQstsNotBlank,TotalScore);
if (DB_QueryCOUNT ("can not get if match result exists",
"SELECT COUNT(*) FROM mch_results"
" WHERE MchCod=%ld AND UsrCod=%ld",
Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod)) // Result exists
/* Update result */
DB_QueryUPDATE ("can not update match result",
"UPDATE mch_results"
" SET EndTime=NOW(),"
"NumQsts=%u,"
"NumQstsNotBlank=%u,"
"Score='%lf'"
" WHERE MchCod=%ld AND UsrCod=%ld",
NumQsts,NumQstsNotBlank,TotalScore,
Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod);
else // Result doesn't exist
/* Create result */
DB_QueryINSERT ("can not create match result",
"INSERT mch_results "
"(MchCod,UsrCod,StartTime,EndTime,NumQsts,NumQstsNotBlank,Score)"
" VALUES "
"(%ld," // MchCod
"%ld," // UsrCod
"NOW()," // StartTime
"NOW()," // EndTime
"%u," // NumQsts
"%u," // NumQstsNotBlank
"'%lf')", // Score
Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod,
NumQsts,NumQstsNotBlank,TotalScore);
Str_SetDecimalPointToLocal (); // Return to local system
}
@ -2492,7 +2514,7 @@ unsigned Mch_GetNumUsrsWhoHaveAnswerQst (long MchCod,unsigned QstInd)
/***** Get number of users who have answered
a question in match from database *****/
return
(unsigned) DB_QueryCOUNT ("can not get number of users who hasve answered a question",
(unsigned) DB_QueryCOUNT ("can not get number of users who have answered a question",
"SELECT COUNT(*) FROM mch_answers"
" WHERE MchCod=%ld AND QstInd=%u",
MchCod,QstInd);
@ -2522,7 +2544,7 @@ static unsigned Mch_GetNumUsrsWhoHaveAnswerMch (long MchCod)
/***** Get number of users who have answered
any question in match from database *****/
return
(unsigned) DB_QueryCOUNT ("can not get number of users who hasve answered a match",
(unsigned) DB_QueryCOUNT ("can not get number of users who have answered a match",
"SELECT COUNT(DISTINCT UsrCod) FROM mch_answers"
" WHERE MchCod=%ld",
MchCod);
@ -2812,7 +2834,7 @@ void Mch_ShowUsrsMchResults (void)
static void Mch_ShowHeaderMchResults (void)
{
extern const char *Txt_User[Usr_NUM_SEXS];
extern const char *Txt_Date;
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
extern const char *Txt_Questions;
extern const char *Txt_Non_blank_BR_questions;
extern const char *Txt_Total_BR_score;
@ -2824,7 +2846,10 @@ static void Mch_ShowHeaderMchResults (void)
"<th colspan=\"2\" class=\"CENTER_TOP\">"
"%s"
"</th>"
"<th class=\"RIGHT_TOP\">"
"<th class=\"LEFT_TOP\">"
"%s"
"</th>"
"<th class=\"LEFT_TOP\">"
"%s"
"</th>"
"<th class=\"RIGHT_TOP\">"
@ -2845,7 +2870,8 @@ static void Mch_ShowHeaderMchResults (void)
"<th></th>"
"</tr>",
Txt_User[Usr_SEX_UNKNOWN],
Txt_Date,
Txt_START_END_TIME[Dat_START_TIME],
Txt_START_END_TIME[Dat_END_TIME],
Txt_Questions,
Txt_Non_blank_BR_questions,
Txt_Total_BR_score,
@ -2881,8 +2907,8 @@ static void Mch_ShowMchResults (struct UsrData *UsrDat)
NumResults =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get matches results of a user",
"SELECT mch_results.MchCod," // row[0]
"UNIX_TIMESTAMP(mch_matches.StartTime)," // row[1]
"UNIX_TIMESTAMP(mch_matches.EndTime)," // row[2]
"UNIX_TIMESTAMP(mch_results.StartTime)," // row[1]
"UNIX_TIMESTAMP(mch_results.EndTime)," // row[2]
"mch_results.NumQsts," // row[3]
"mch_results.NumQstsNotBlank," // row[4]
"mch_results.Score" // row[5]
@ -2924,10 +2950,10 @@ static void Mch_ShowMchResults (struct UsrData *UsrDat)
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
StartEndTime++)
{
TimeUTC[0] = Dat_GetUNIXTimeFromStr (row[1 + StartEndTime]);
TimeUTC[StartEndTime] = Dat_GetUNIXTimeFromStr (row[1 + StartEndTime]);
UniqueId++;
fprintf (Gbl.F.Out,"<td id =\"mch_time_%u_%u\""
" class=\"%s RIGHT_TOP COLOR%u\">"
" class=\"%s LEFT_TOP COLOR%u\">"
"<script type=\"text/javascript\">"
"writeLocalDateHMSFromUTC('mch_time_%u_%u',"
"%ld,%u,',&nbsp;','%s',true,false,0x7);"