mirror of https://github.com/acanas/swad-core.git
Version 21.16.1: Sep 24, 2021 Queries moved to module swad_match_database.
This commit is contained in:
parent
f0681a98aa
commit
fb7bc2b0c8
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.16 (2021-09-24)"
|
#define Log_PLATFORM_VERSION "SWAD 21.16.1 (2021-09-24)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 21.16.1: Sep 24, 2021 Queries moved to module swad_match_database. (317054 lines)
|
||||||
Version 21.16: Sep 24, 2021 New module swad_match_database for database queries related to game matches. (316995 lines)
|
Version 21.16: Sep 24, 2021 New module swad_match_database for database queries related to game matches. (316995 lines)
|
||||||
Version 21.15: Sep 24, 2021 New module swad_mark_database for database queries related to files of marks. (316792 lines)
|
Version 21.15: Sep 24, 2021 New module swad_mark_database for database queries related to files of marks. (316792 lines)
|
||||||
Version 21.14.1: Sep 23, 2021 Queries moved to module swad_mail_database. (316687 lines)
|
Version 21.14.1: Sep 23, 2021 Queries moved to module swad_mail_database. (316687 lines)
|
||||||
|
|
|
@ -1356,7 +1356,6 @@ bool ExaSes_CheckIfICanListThisSessionBasedOnGrps (long SesCod)
|
||||||
/***** Check if I belong to any of the groups
|
/***** Check if I belong to any of the groups
|
||||||
associated to the exam session *****/
|
associated to the exam session *****/
|
||||||
return Exa_DB_CheckIfICanListThisSessionBasedOnGrps (SesCod);
|
return Exa_DB_CheckIfICanListThisSessionBasedOnGrps (SesCod);
|
||||||
break;
|
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
|
|
133
swad_match.c
133
swad_match.c
|
@ -283,56 +283,11 @@ void Mch_ListMatches (struct Gam_Games *Games,
|
||||||
{
|
{
|
||||||
extern const char *Hlp_ASSESSMENT_Games_matches;
|
extern const char *Hlp_ASSESSMENT_Games_matches;
|
||||||
extern const char *Txt_Matches;
|
extern const char *Txt_Matches;
|
||||||
char *SubQuery;
|
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned NumMatches;
|
unsigned NumMatches;
|
||||||
|
|
||||||
/***** Get data of matches from database *****/
|
/***** Get data of matches from database *****/
|
||||||
/* Fill subquery for game */
|
NumMatches = Mch_DB_GetMatches (&mysql_res,Game->GamCod);
|
||||||
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
|
||||||
{
|
|
||||||
if (asprintf (&SubQuery," AND"
|
|
||||||
" (MchCod NOT IN"
|
|
||||||
" (SELECT MchCod"
|
|
||||||
" FROM mch_groups)"
|
|
||||||
" OR"
|
|
||||||
" MchCod IN"
|
|
||||||
" (SELECT mch_groups.MchCod"
|
|
||||||
" FROM grp_users,"
|
|
||||||
"mch_groups"
|
|
||||||
" WHERE grp_users.UsrCod=%ld"
|
|
||||||
" AND grp_users.GrpCod=mch_groups.GrpCod))",
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
|
||||||
Err_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
|
||||||
if (asprintf (&SubQuery,"%s","") < 0)
|
|
||||||
Err_NotEnoughMemoryExit ();
|
|
||||||
|
|
||||||
/* Make query */
|
|
||||||
NumMatches = (unsigned)
|
|
||||||
DB_QuerySELECT (&mysql_res,"can not get matches",
|
|
||||||
"SELECT MchCod," // row[ 0]
|
|
||||||
"GamCod," // row[ 1]
|
|
||||||
"UsrCod," // row[ 2]
|
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[ 3]
|
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[ 4]
|
|
||||||
"Title," // row[ 5]
|
|
||||||
"QstInd," // row[ 6]
|
|
||||||
"QstCod," // row[ 7]
|
|
||||||
"Showing," // row[ 8]
|
|
||||||
"Countdown," // row[ 9]
|
|
||||||
"NumCols," // row[10]
|
|
||||||
"ShowQstResults," // row[11]
|
|
||||||
"ShowUsrResults" // row[12]
|
|
||||||
" FROM mch_matches"
|
|
||||||
" WHERE GamCod=%ld%s"
|
|
||||||
" ORDER BY MchCod",
|
|
||||||
Game->GamCod,
|
|
||||||
SubQuery);
|
|
||||||
|
|
||||||
/* Free allocated memory for subquery */
|
|
||||||
free (SubQuery);
|
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Games->GamCod = Game->GamCod;
|
Games->GamCod = Game->GamCod;
|
||||||
|
@ -391,33 +346,9 @@ void Mch_ListMatches (struct Gam_Games *Games,
|
||||||
void Mch_GetDataOfMatchByCod (struct Mch_Match *Match)
|
void Mch_GetDataOfMatchByCod (struct Mch_Match *Match)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned NumRows;
|
|
||||||
|
|
||||||
/***** Get data of match from database *****/
|
/***** Get data of match from database *****/
|
||||||
NumRows = (unsigned)
|
if (Mch_DB_GetDataOfMatchByCod (&mysql_res,Match->MchCod)) // Match found...
|
||||||
DB_QuerySELECT (&mysql_res,"can not get matches",
|
|
||||||
"SELECT MchCod," // row[ 0]
|
|
||||||
"GamCod," // row[ 1]
|
|
||||||
"UsrCod," // row[ 2]
|
|
||||||
"UNIX_TIMESTAMP(StartTime)," // row[ 3]
|
|
||||||
"UNIX_TIMESTAMP(EndTime)," // row[ 4]
|
|
||||||
"Title," // row[ 5]
|
|
||||||
"QstInd," // row[ 6]
|
|
||||||
"QstCod," // row[ 7]
|
|
||||||
"Showing," // row[ 8]
|
|
||||||
"Countdown," // row[ 9]
|
|
||||||
"NumCols," // row[10]
|
|
||||||
"ShowQstResults," // row[11]
|
|
||||||
"ShowUsrResults" // row[12]
|
|
||||||
" FROM mch_matches"
|
|
||||||
" WHERE MchCod=%ld"
|
|
||||||
" AND GamCod IN" // Extra check
|
|
||||||
" (SELECT GamCod"
|
|
||||||
" FROM gam_games"
|
|
||||||
" WHERE CrsCod='%ld')",
|
|
||||||
Match->MchCod,
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
if (NumRows) // Match found...
|
|
||||||
/* Get match data from row */
|
/* Get match data from row */
|
||||||
Mch_GetMatchDataFromRow (mysql_res,Match);
|
Mch_GetMatchDataFromRow (mysql_res,Match);
|
||||||
else
|
else
|
||||||
|
@ -760,19 +691,7 @@ static void Mch_GetAndWriteNamesOfGrpsAssociatedToMatch (const struct Mch_Match
|
||||||
unsigned NumGrp;
|
unsigned NumGrp;
|
||||||
|
|
||||||
/***** Get groups associated to a match from database *****/
|
/***** Get groups associated to a match from database *****/
|
||||||
NumGrps = (unsigned)
|
NumGrps = Mch_DB_GetGrpsAssociatedToMatch (&mysql_res,Match->MchCod);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get groups of a match",
|
|
||||||
"SELECT grp_types.GrpTypName," // row[0]
|
|
||||||
"grp_groups.GrpName" // row[1]
|
|
||||||
" FROM mch_groups,"
|
|
||||||
"grp_groups,"
|
|
||||||
"grp_types"
|
|
||||||
" WHERE mch_groups.MchCod=%ld"
|
|
||||||
" AND mch_groups.GrpCod=grp_groups.GrpCod"
|
|
||||||
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
|
||||||
" ORDER BY grp_types.GrpTypName,"
|
|
||||||
"grp_groups.GrpName",
|
|
||||||
Match->MchCod);
|
|
||||||
|
|
||||||
HTM_DIV_Begin ("class=\"ASG_GRP\"");
|
HTM_DIV_Begin ("class=\"ASG_GRP\"");
|
||||||
|
|
||||||
|
@ -967,13 +886,7 @@ void Mch_ToggleVisResultsMchUsr (void)
|
||||||
|
|
||||||
/***** Toggle visibility of match results *****/
|
/***** Toggle visibility of match results *****/
|
||||||
Match.Status.ShowUsrResults = !Match.Status.ShowUsrResults;
|
Match.Status.ShowUsrResults = !Match.Status.ShowUsrResults;
|
||||||
DB_QueryUPDATE ("can not toggle visibility of match results",
|
Mch_DB_UpdateVisResultsMchUsr (Match.MchCod,Match.Status.ShowUsrResults);
|
||||||
"UPDATE mch_matches"
|
|
||||||
" SET ShowUsrResults='%c'"
|
|
||||||
" WHERE MchCod=%ld",
|
|
||||||
Match.Status.ShowUsrResults ? 'Y' :
|
|
||||||
'N',
|
|
||||||
Match.MchCod);
|
|
||||||
|
|
||||||
/***** Show current game *****/
|
/***** Show current game *****/
|
||||||
Gam_ShowOnlyOneGame (&Games,&Game,
|
Gam_ShowOnlyOneGame (&Games,&Game,
|
||||||
|
@ -1583,7 +1496,7 @@ void Mch_ChangeMatch (void)
|
||||||
static void Mch_UpdateMatchTitleAndGrps (const struct Mch_Match *Match)
|
static void Mch_UpdateMatchTitleAndGrps (const struct Mch_Match *Match)
|
||||||
{
|
{
|
||||||
/***** Update match title into database *****/
|
/***** Update match title into database *****/
|
||||||
Mch_DB_UpdateMatchTitle (Match);
|
Mch_DB_UpdateMatchTitle (Match->MchCod,Match->Title);
|
||||||
|
|
||||||
/***** Update groups associated to the match *****/
|
/***** Update groups associated to the match *****/
|
||||||
Mch_DB_RemoveMatchFromTable (Match->MchCod,"mch_groups"); // Remove all groups associated to this match
|
Mch_DB_RemoveMatchFromTable (Match->MchCod,"mch_groups"); // Remove all groups associated to this match
|
||||||
|
@ -1828,14 +1741,9 @@ static void Mch_GetElapsedTimeInQuestion (const struct Mch_Match *Match,
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
NumRows = (unsigned)
|
NumRows = Mch_DB_GetElapsedTimeInQuestion (&mysql_res,
|
||||||
DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
Match->MchCod,
|
||||||
"SELECT ElapsedTime" // row[0]
|
Match->Status.QstInd);
|
||||||
" FROM mch_times"
|
|
||||||
" WHERE MchCod=%ld"
|
|
||||||
" AND QstInd=%u",
|
|
||||||
Match->MchCod,
|
|
||||||
Match->Status.QstInd);
|
|
||||||
|
|
||||||
/***** Get elapsed time from query result *****/
|
/***** Get elapsed time from query result *****/
|
||||||
Mch_GetElapsedTime (NumRows,mysql_res,Time);
|
Mch_GetElapsedTime (NumRows,mysql_res,Time);
|
||||||
|
@ -1855,12 +1763,7 @@ static void Mch_GetElapsedTimeInMatch (const struct Mch_Match *Match,
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
NumRows = (unsigned)
|
NumRows = Mch_DB_GetElapsedTimeInMatch (&mysql_res,Match->MchCod);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
|
||||||
"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ElapsedTime)))" // row[0]
|
|
||||||
" FROM mch_times"
|
|
||||||
" WHERE MchCod=%ld",
|
|
||||||
Match->MchCod);
|
|
||||||
|
|
||||||
/***** Get elapsed time from query result *****/
|
/***** Get elapsed time from query result *****/
|
||||||
Mch_GetElapsedTime (NumRows,mysql_res,Time);
|
Mch_GetElapsedTime (NumRows,mysql_res,Time);
|
||||||
|
@ -2249,23 +2152,7 @@ bool Mch_CheckIfICanPlayThisMatchBasedOnGrps (const struct Mch_Match *Match)
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
/***** Check if I belong to any of the groups
|
/***** Check if I belong to any of the groups
|
||||||
associated to the match *****/
|
associated to the match *****/
|
||||||
return (DB_QueryCOUNT ("can not check if I can play a match",
|
return Mch_DB_CheckIfICanPlayThisMatchBasedOnGrps (Match->MchCod);
|
||||||
"SELECT COUNT(*)"
|
|
||||||
" FROM mch_matches"
|
|
||||||
" WHERE MchCod=%ld"
|
|
||||||
" AND (MchCod NOT IN"
|
|
||||||
" (SELECT MchCod"
|
|
||||||
" FROM mch_groups)"
|
|
||||||
" OR"
|
|
||||||
" MchCod IN"
|
|
||||||
" (SELECT mch_groups.MchCod"
|
|
||||||
" FROM grp_users,"
|
|
||||||
"mch_groups"
|
|
||||||
" WHERE grp_users.UsrCod=%ld"
|
|
||||||
" AND grp_users.GrpCod=mch_groups.GrpCod))",
|
|
||||||
Match->MchCod,
|
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
|
|
||||||
break;
|
|
||||||
case Rol_NET:
|
case Rol_NET:
|
||||||
/***** Only if I am the creator *****/
|
/***** Only if I am the creator *****/
|
||||||
return (Match->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
return (Match->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
|
|
@ -165,14 +165,116 @@ void Mch_DB_UpdateMatchStatus (const struct Mch_Match *Match)
|
||||||
/********************* Update title of an existing match *********************/
|
/********************* Update title of an existing match *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Mch_DB_UpdateMatchTitle (const struct Mch_Match *Match)
|
void Mch_DB_UpdateMatchTitle (long MchCod,
|
||||||
|
const char Title[Gam_MAX_BYTES_TITLE + 1])
|
||||||
{
|
{
|
||||||
DB_QueryUPDATE ("can not update match",
|
DB_QueryUPDATE ("can not update match",
|
||||||
"UPDATE mch_matches"
|
"UPDATE mch_matches"
|
||||||
" SET Title='%s'"
|
" SET Title='%s'"
|
||||||
" WHERE MchCod=%ld",
|
" WHERE MchCod=%ld",
|
||||||
Match->Title,
|
Title,
|
||||||
Match->MchCod);
|
MchCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Toggle visibility of match results *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Mch_DB_UpdateVisResultsMchUsr (long MchCod,bool ShowUsrResults)
|
||||||
|
{
|
||||||
|
DB_QueryUPDATE ("can not toggle visibility of match results",
|
||||||
|
"UPDATE mch_matches"
|
||||||
|
" SET ShowUsrResults='%c'"
|
||||||
|
" WHERE MchCod=%ld",
|
||||||
|
ShowUsrResults ? 'Y' :
|
||||||
|
'N',
|
||||||
|
MchCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************** Get match data using its code ************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetDataOfMatchByCod (MYSQL_RES **mysql_res,long MchCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get matches",
|
||||||
|
"SELECT MchCod," // row[ 0]
|
||||||
|
"GamCod," // row[ 1]
|
||||||
|
"UsrCod," // row[ 2]
|
||||||
|
"UNIX_TIMESTAMP(StartTime)," // row[ 3]
|
||||||
|
"UNIX_TIMESTAMP(EndTime)," // row[ 4]
|
||||||
|
"Title," // row[ 5]
|
||||||
|
"QstInd," // row[ 6]
|
||||||
|
"QstCod," // row[ 7]
|
||||||
|
"Showing," // row[ 8]
|
||||||
|
"Countdown," // row[ 9]
|
||||||
|
"NumCols," // row[10]
|
||||||
|
"ShowQstResults," // row[11]
|
||||||
|
"ShowUsrResults" // row[12]
|
||||||
|
" FROM mch_matches"
|
||||||
|
" WHERE MchCod=%ld"
|
||||||
|
" AND GamCod IN" // Extra check
|
||||||
|
" (SELECT GamCod"
|
||||||
|
" FROM gam_games"
|
||||||
|
" WHERE CrsCod='%ld')",
|
||||||
|
MchCod,
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************* Get the matches of a game *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetMatches (MYSQL_RES **mysql_res,long GamCod)
|
||||||
|
{
|
||||||
|
char *SubQuery;
|
||||||
|
|
||||||
|
/***** Fill subquery for game *****/
|
||||||
|
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
||||||
|
{
|
||||||
|
if (asprintf (&SubQuery," AND"
|
||||||
|
" (MchCod NOT IN"
|
||||||
|
" (SELECT MchCod"
|
||||||
|
" FROM mch_groups)"
|
||||||
|
" OR"
|
||||||
|
" MchCod IN"
|
||||||
|
" (SELECT mch_groups.MchCod"
|
||||||
|
" FROM grp_users,"
|
||||||
|
"mch_groups"
|
||||||
|
" WHERE grp_users.UsrCod=%ld"
|
||||||
|
" AND grp_users.GrpCod=mch_groups.GrpCod))",
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||||
|
Err_NotEnoughMemoryExit ();
|
||||||
|
}
|
||||||
|
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||||
|
if (asprintf (&SubQuery,"%s","") < 0)
|
||||||
|
Err_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
/***** Make query *****/
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get matches",
|
||||||
|
"SELECT MchCod," // row[ 0]
|
||||||
|
"GamCod," // row[ 1]
|
||||||
|
"UsrCod," // row[ 2]
|
||||||
|
"UNIX_TIMESTAMP(StartTime)," // row[ 3]
|
||||||
|
"UNIX_TIMESTAMP(EndTime)," // row[ 4]
|
||||||
|
"Title," // row[ 5]
|
||||||
|
"QstInd," // row[ 6]
|
||||||
|
"QstCod," // row[ 7]
|
||||||
|
"Showing," // row[ 8]
|
||||||
|
"Countdown," // row[ 9]
|
||||||
|
"NumCols," // row[10]
|
||||||
|
"ShowQstResults," // row[11]
|
||||||
|
"ShowUsrResults" // row[12]
|
||||||
|
" FROM mch_matches"
|
||||||
|
" WHERE GamCod=%ld%s"
|
||||||
|
" ORDER BY MchCod",
|
||||||
|
GamCod,
|
||||||
|
SubQuery);
|
||||||
|
|
||||||
|
/***** Free allocated memory for subquery *****/
|
||||||
|
free (SubQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -362,6 +464,51 @@ void Mch_DB_AssociateGroupToMatch (long MchCod,long GrpCod)
|
||||||
GrpCod);
|
GrpCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** Get groups associated to a match from database ***************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetGrpsAssociatedToMatch (MYSQL_RES **mysql_res,long MchCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get groups of a match",
|
||||||
|
"SELECT grp_types.GrpTypName," // row[0]
|
||||||
|
"grp_groups.GrpName" // row[1]
|
||||||
|
" FROM mch_groups,"
|
||||||
|
"grp_groups,"
|
||||||
|
"grp_types"
|
||||||
|
" WHERE mch_groups.MchCod=%ld"
|
||||||
|
" AND mch_groups.GrpCod=grp_groups.GrpCod"
|
||||||
|
" AND grp_groups.GrpTypCod=grp_types.GrpTypCod"
|
||||||
|
" ORDER BY grp_types.GrpTypName,"
|
||||||
|
"grp_groups.GrpName",
|
||||||
|
MchCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************ Check if I belong to any of the groups of a match **************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool Mch_DB_CheckIfICanPlayThisMatchBasedOnGrps (long MchCod)
|
||||||
|
{
|
||||||
|
return (DB_QueryCOUNT ("can not check if I can play a match",
|
||||||
|
"SELECT COUNT(*)"
|
||||||
|
" FROM mch_matches"
|
||||||
|
" WHERE MchCod=%ld"
|
||||||
|
" AND (MchCod NOT IN"
|
||||||
|
" (SELECT MchCod"
|
||||||
|
" FROM mch_groups)"
|
||||||
|
" OR"
|
||||||
|
" MchCod IN"
|
||||||
|
" (SELECT mch_groups.MchCod"
|
||||||
|
" FROM grp_users,"
|
||||||
|
"mch_groups"
|
||||||
|
" WHERE grp_users.UsrCod=%ld"
|
||||||
|
" AND grp_users.GrpCod=mch_groups.GrpCod))",
|
||||||
|
MchCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************* Remove one group from all matches *********************/
|
/********************* Remove one group from all matches *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -461,3 +608,34 @@ void Mch_DB_UpdateElapsedTimeInQuestion (long MchCod,long QstInd)
|
||||||
Cfg_SECONDS_TO_REFRESH_MATCH_TCH);
|
Cfg_SECONDS_TO_REFRESH_MATCH_TCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************* Get elapsed time in a match question ********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetElapsedTimeInQuestion (MYSQL_RES **mysql_res,
|
||||||
|
long MchCod,unsigned QstInd)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get elapsed time",
|
||||||
|
"SELECT ElapsedTime" // row[0]
|
||||||
|
" FROM mch_times"
|
||||||
|
" WHERE MchCod=%ld"
|
||||||
|
" AND QstInd=%u",
|
||||||
|
MchCod,
|
||||||
|
QstInd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Get elapsed time in a match *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetElapsedTimeInMatch (MYSQL_RES **mysql_res,long MchCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get elapsed time",
|
||||||
|
"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ElapsedTime)))" // row[0]
|
||||||
|
" FROM mch_times"
|
||||||
|
" WHERE MchCod=%ld",
|
||||||
|
MchCod);
|
||||||
|
}
|
||||||
|
|
|
@ -44,8 +44,12 @@
|
||||||
//------------------------------- Matches -------------------------------------
|
//------------------------------- Matches -------------------------------------
|
||||||
long Mch_DB_CreateMatch (long GamCod,char Title[Mch_MAX_BYTES_TITLE + 1]);
|
long Mch_DB_CreateMatch (long GamCod,char Title[Mch_MAX_BYTES_TITLE + 1]);
|
||||||
void Mch_DB_UpdateMatchStatus (const struct Mch_Match *Match);
|
void Mch_DB_UpdateMatchStatus (const struct Mch_Match *Match);
|
||||||
void Mch_DB_UpdateMatchTitle (const struct Mch_Match *Match);
|
void Mch_DB_UpdateMatchTitle (long MchCod,
|
||||||
|
const char Title[Gam_MAX_BYTES_TITLE + 1]);
|
||||||
|
void Mch_DB_UpdateVisResultsMchUsr (long MchCod,bool ShowUsrResults);
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetDataOfMatchByCod (MYSQL_RES **mysql_res,long MchCod);
|
||||||
|
unsigned Mch_DB_GetMatches (MYSQL_RES **mysql_res,long GamCod);
|
||||||
Mch_Showing_t Mch_DB_GetShowingFromStr (const char *Str);
|
Mch_Showing_t Mch_DB_GetShowingFromStr (const char *Str);
|
||||||
unsigned Mch_DB_GetNumMchsInGame (long GamCod);
|
unsigned Mch_DB_GetNumMchsInGame (long GamCod);
|
||||||
unsigned Mch_DB_GetNumUnfinishedMchsInGame (long GamCod);
|
unsigned Mch_DB_GetNumUnfinishedMchsInGame (long GamCod);
|
||||||
|
@ -62,6 +66,9 @@ void Mch_DB_RemoveMatchesMadeByUsrInCrsFromTable (long UsrCod,long CrsCod,
|
||||||
//---------------------------------Groups -------------------------------------
|
//---------------------------------Groups -------------------------------------
|
||||||
void Mch_DB_AssociateGroupToMatch (long MchCod,long GrpCod);
|
void Mch_DB_AssociateGroupToMatch (long MchCod,long GrpCod);
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetGrpsAssociatedToMatch (MYSQL_RES **mysql_res,long MchCod);
|
||||||
|
bool Mch_DB_CheckIfICanPlayThisMatchBasedOnGrps (long MchCod);
|
||||||
|
|
||||||
void Mch_DB_RemoveGroup (long GrpCod);
|
void Mch_DB_RemoveGroup (long GrpCod);
|
||||||
void Mch_DB_RemoveGroupsOfType (long GrpTypCod);
|
void Mch_DB_RemoveGroupsOfType (long GrpTypCod);
|
||||||
|
|
||||||
|
@ -77,4 +84,8 @@ void Mch_DB_GetIndexes (long MchCod,unsigned QstInd,
|
||||||
//----------------------------- Elapsed times ---------------------------------
|
//----------------------------- Elapsed times ---------------------------------
|
||||||
void Mch_DB_UpdateElapsedTimeInQuestion (long MchCod,long QstInd);
|
void Mch_DB_UpdateElapsedTimeInQuestion (long MchCod,long QstInd);
|
||||||
|
|
||||||
|
unsigned Mch_DB_GetElapsedTimeInQuestion (MYSQL_RES **mysql_res,
|
||||||
|
long MchCod,unsigned QstInd);
|
||||||
|
unsigned Mch_DB_GetElapsedTimeInMatch (MYSQL_RES **mysql_res,long MchCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue