mirror of https://github.com/acanas/swad-core.git
Version 20.53: Mar 29, 2021 Code refactoring in database selects.
This commit is contained in:
parent
9af1bbaa51
commit
b889e97639
|
@ -600,13 +600,14 @@ TODO: Salvador Romero Cort
|
|||
|
||||
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.52 (2021-03-28)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.53 (2021-03-29)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.6.2.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 20.53: Mar 29, 2021 Code refactoring in database selects. (309473 lines)
|
||||
Version 20.52: Mar 28, 2021 Code refactoring in database selects. (309103 lines)
|
||||
Version 20.51.49: Mar 26, 2021 User IDs database table renamed. (308816 lines)
|
||||
1 change necessary in database:
|
||||
|
|
294
swad_match.c
294
swad_match.c
|
@ -306,14 +306,15 @@ void Mch_ListMatches (struct Gam_Games *Games,
|
|||
{
|
||||
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))",
|
||||
" (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)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
@ -322,25 +323,26 @@ void Mch_ListMatches (struct Gam_Games *Games,
|
|||
Lay_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);
|
||||
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);
|
||||
|
@ -406,27 +408,28 @@ void Mch_GetDataOfMatchByCod (struct Mch_Match *Match)
|
|||
|
||||
/***** Get data of match from database *****/
|
||||
NumRows = (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')",
|
||||
Match->MchCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
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 */
|
||||
Mch_GetMatchDataFromRow (mysql_res,Match);
|
||||
|
@ -1789,9 +1792,9 @@ static void Mch_CreateIndexes (long GamCod,long MchCod)
|
|||
"gam_questions.QstInd," // row[1]
|
||||
"tst_questions.AnsType," // row[2]
|
||||
"tst_questions.Shuffle" // row[3]
|
||||
" FROM gam_questions,tst_questions"
|
||||
" FROM gam_questions,tst_questions"
|
||||
" WHERE gam_questions.GamCod=%ld"
|
||||
" AND gam_questions.QstCod=tst_questions.QstCod"
|
||||
" AND gam_questions.QstCod=tst_questions.QstCod"
|
||||
" ORDER BY gam_questions.QstInd",
|
||||
GamCod);
|
||||
|
||||
|
@ -1861,14 +1864,14 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd,
|
|||
|
||||
/***** Get questions of the game *****/
|
||||
NumAnss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get questions of a game",
|
||||
"SELECT AnsInd" // row[0]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
Question->Answer.Shuffle ? "RAND()" : // Use RAND() because is really random; RAND(NOW()) repeats order
|
||||
"AnsInd");
|
||||
DB_QuerySELECT (&mysql_res,"can not get questions of a game",
|
||||
"SELECT AnsInd" // row[0]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
Question->Answer.Shuffle ? "RAND()" : // Use RAND() because is really random; RAND(NOW()) repeats order
|
||||
"AnsInd");
|
||||
|
||||
/***** For each answer in question... *****/
|
||||
for (NumAns = 0;
|
||||
|
@ -1915,9 +1918,11 @@ void Mch_GetIndexes (long MchCod,unsigned QstInd,
|
|||
/***** Get indexes for a question from database *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||
"SELECT Indexes" // row[0]
|
||||
" FROM mch_indexes"
|
||||
" WHERE MchCod=%ld AND QstInd=%u",
|
||||
MchCod,QstInd))
|
||||
" FROM mch_indexes"
|
||||
" WHERE MchCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
MchCod,
|
||||
QstInd))
|
||||
Lay_ShowErrorAndExit ("No indexes found for a question.");
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -2067,11 +2072,14 @@ static void Mch_GetElapsedTimeInQuestion (const struct Mch_Match *Match,
|
|||
unsigned NumRows;
|
||||
|
||||
/***** Query database *****/
|
||||
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
||||
"SELECT ElapsedTime"
|
||||
" FROM mch_times"
|
||||
" WHERE MchCod=%ld AND QstInd=%u",
|
||||
Match->MchCod,Match->Status.QstInd);
|
||||
NumRows = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
||||
"SELECT ElapsedTime"
|
||||
" FROM mch_times"
|
||||
" WHERE MchCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
Match->MchCod,
|
||||
Match->Status.QstInd);
|
||||
|
||||
/***** Get elapsed time from query result *****/
|
||||
Mch_GetElapsedTime (NumRows,mysql_res,Time);
|
||||
|
@ -2091,10 +2099,12 @@ static void Mch_GetElapsedTimeInMatch (const struct Mch_Match *Match,
|
|||
unsigned NumRows;
|
||||
|
||||
/***** Query database *****/
|
||||
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
||||
"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ElapsedTime)))"
|
||||
" FROM mch_times WHERE MchCod=%ld",
|
||||
Match->MchCod);
|
||||
NumRows = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get elapsed time",
|
||||
"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(ElapsedTime)))"
|
||||
" FROM mch_times"
|
||||
" WHERE MchCod=%ld",
|
||||
Match->MchCod);
|
||||
|
||||
/***** Get elapsed time from query result *****/
|
||||
Mch_GetElapsedTime (NumRows,mysql_res,Time);
|
||||
|
@ -2480,11 +2490,12 @@ unsigned Mch_GetNumMchsInGame (long GamCod)
|
|||
return 0; // ...has no matches
|
||||
|
||||
/***** Get number of matches in a game from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of matches of a game",
|
||||
"SELECT COUNT(*) FROM mch_matches"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of matches of a game",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_matches"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2498,11 +2509,14 @@ unsigned Mch_GetNumUnfinishedMchsInGame (long GamCod)
|
|||
return 0; // ...has no matches
|
||||
|
||||
/***** Get number of matches in a game from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of unfinished matches of a game",
|
||||
"SELECT COUNT(*) FROM mch_matches"
|
||||
" WHERE GamCod=%ld AND Showing<>'%s'",
|
||||
GamCod,Mch_ShowingStringsDB[Mch_END]);
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of unfinished matches of a game",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_matches"
|
||||
" WHERE GamCod=%ld"
|
||||
" AND Showing<>'%s'",
|
||||
GamCod,
|
||||
Mch_ShowingStringsDB[Mch_END]);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2517,19 +2531,21 @@ bool Mch_CheckIfICanPlayThisMatchBasedOnGrps (const struct Mch_Match *Match)
|
|||
/***** Check if I belong to any of the groups
|
||||
associated to the match *****/
|
||||
return (DB_QueryCOUNT ("can not check if I can play a match",
|
||||
"SELECT COUNT(*) FROM mch_matches"
|
||||
"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);
|
||||
" 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:
|
||||
/***** Only if I am the creator *****/
|
||||
|
@ -3489,13 +3505,12 @@ static void Mch_ShowMatchScore (const struct Mch_Match *Match)
|
|||
|
||||
/***** Get maximum number of users *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get max users",
|
||||
"SELECT MAX(NumUsrs)"
|
||||
" FROM "
|
||||
"(SELECT COUNT(*) AS NumUsrs" // row[1]
|
||||
" FROM mch_results"
|
||||
" WHERE MchCod=%ld"
|
||||
" GROUP BY Score"
|
||||
" ORDER BY Score) AS Scores",
|
||||
"SELECT MAX(NumUsrs)" // row[1]
|
||||
" FROM (SELECT COUNT(*) AS NumUsrs"
|
||||
" FROM mch_results"
|
||||
" WHERE MchCod=%ld"
|
||||
" GROUP BY Score"
|
||||
" ORDER BY Score) AS Scores",
|
||||
Match->MchCod))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3515,7 +3530,7 @@ static void Mch_ShowMatchScore (const struct Mch_Match *Match)
|
|||
DB_QuerySELECT (&mysql_res,"can not get scores",
|
||||
"SELECT Score," // row[0]
|
||||
"COUNT(*) AS NumUsrs" // row[1]
|
||||
" FROM mch_results"
|
||||
" FROM mch_results"
|
||||
" WHERE MchCod=%ld"
|
||||
" GROUP BY Score"
|
||||
" ORDER BY Score DESC",
|
||||
|
@ -3832,7 +3847,8 @@ static bool Mch_GetIfMatchIsBeingPlayed (long MchCod)
|
|||
/***** Get if a match is being played or not *****/
|
||||
return
|
||||
(bool) (DB_QueryCOUNT ("can not get if match is being played",
|
||||
"SELECT COUNT(*) FROM mch_playing"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_playing"
|
||||
" WHERE MchCod=%ld",
|
||||
MchCod) != 0);
|
||||
}
|
||||
|
@ -3846,7 +3862,8 @@ static void Mch_GetNumPlayers (struct Mch_Match *Match)
|
|||
/***** Get number of players who are playing a match *****/
|
||||
Match->Status.NumPlayers =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of players",
|
||||
"SELECT COUNT(*) FROM mch_players"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_players"
|
||||
" WHERE MchCod=%ld",
|
||||
Match->MchCod);
|
||||
}
|
||||
|
@ -4101,11 +4118,13 @@ void Mch_GetQstAnsFromDB (long MchCod,long UsrCod,unsigned QstInd,
|
|||
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get user's answer to a match question",
|
||||
"SELECT NumOpt," // row[0]
|
||||
"AnsInd" // row[1]
|
||||
" FROM mch_answers"
|
||||
" FROM mch_answers"
|
||||
" WHERE MchCod=%ld"
|
||||
" AND UsrCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
MchCod,UsrCod,QstInd);
|
||||
" AND UsrCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
MchCod,
|
||||
UsrCod,
|
||||
QstInd);
|
||||
if (NumRows) // Answer found...
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -4255,18 +4274,18 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print)
|
|||
|
||||
/***** Get questions and answers of a match result *****/
|
||||
Print->NumQsts.All = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get questions and answers"
|
||||
" of a match result",
|
||||
"SELECT gam_questions.QstCod," // row[0]
|
||||
"gam_questions.QstInd," // row[1]
|
||||
"mch_indexes.Indexes" // row[2]
|
||||
" FROM mch_matches,gam_questions,mch_indexes"
|
||||
" WHERE mch_matches.MchCod=%ld"
|
||||
" AND mch_matches.GamCod=gam_questions.GamCod"
|
||||
" AND mch_matches.MchCod=mch_indexes.MchCod"
|
||||
" AND gam_questions.QstInd=mch_indexes.QstInd"
|
||||
" ORDER BY gam_questions.QstInd",
|
||||
Print->MchCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get questions and answers"
|
||||
" of a match result",
|
||||
"SELECT gam_questions.QstCod," // row[0]
|
||||
"gam_questions.QstInd," // row[1]
|
||||
"mch_indexes.Indexes" // row[2]
|
||||
" FROM mch_matches,gam_questions,mch_indexes"
|
||||
" WHERE mch_matches.MchCod=%ld"
|
||||
" AND mch_matches.GamCod=gam_questions.GamCod"
|
||||
" AND mch_matches.MchCod=mch_indexes.MchCod"
|
||||
" AND gam_questions.QstInd=mch_indexes.QstInd"
|
||||
" ORDER BY gam_questions.QstInd",
|
||||
Print->MchCod);
|
||||
for (NumQst = 0, Print->NumQsts.NotBlank = 0;
|
||||
NumQst < Print->NumQsts.All;
|
||||
NumQst++)
|
||||
|
@ -4340,11 +4359,14 @@ unsigned Mch_GetNumUsrsWhoAnsweredQst (long MchCod,unsigned QstInd)
|
|||
{
|
||||
/***** Get number of users who answered
|
||||
a question in a match from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users who answered a question",
|
||||
"SELECT COUNT(*) FROM mch_answers"
|
||||
" WHERE MchCod=%ld AND QstInd=%u",
|
||||
MchCod,QstInd);
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of users who answered a question",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_answers"
|
||||
" WHERE MchCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
MchCod,
|
||||
QstInd);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4355,11 +4377,16 @@ unsigned Mch_GetNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned An
|
|||
{
|
||||
/***** Get number of users who have chosen
|
||||
an answer of a question from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users who have chosen an answer",
|
||||
"SELECT COUNT(*) FROM mch_answers"
|
||||
" WHERE MchCod=%ld AND QstInd=%u AND AnsInd=%u",
|
||||
MchCod,QstInd,AnsInd);
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of users who have chosen an answer",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_answers"
|
||||
" WHERE MchCod=%ld"
|
||||
" AND QstInd=%u"
|
||||
" AND AnsInd=%u",
|
||||
MchCod,
|
||||
QstInd,
|
||||
AnsInd);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4371,11 +4398,12 @@ static unsigned Mch_GetNumUsrsWhoHavePlayedMch (long MchCod)
|
|||
/***** Get number of users who have played the match
|
||||
(users who have a result for this match, even blank result)
|
||||
from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users who have played a match",
|
||||
"SELECT COUNT(*) FROM mch_results"
|
||||
" WHERE MchCod=%ld",
|
||||
MchCod);
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of users who have played a match",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_results"
|
||||
" WHERE MchCod=%ld",
|
||||
MchCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -101,17 +101,20 @@ static void MchPrn_UpdateMyMatchPrintInDB (struct MchPrn_Print *Print)
|
|||
{
|
||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||
if (DB_QueryCOUNT ("can not get if match result exists",
|
||||
"SELECT COUNT(*) FROM mch_results"
|
||||
" WHERE MchCod=%ld AND UsrCod=%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM mch_results"
|
||||
" WHERE MchCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Print->MchCod,Print->UsrCod)) // Match print exists
|
||||
/* Update result */
|
||||
DB_QueryUPDATE ("can not update match result",
|
||||
"UPDATE mch_results"
|
||||
" SET EndTime=NOW(),"
|
||||
"NumQsts=%u,"
|
||||
"NumQstsNotBlank=%u,"
|
||||
"Score='%.15lg'"
|
||||
" WHERE MchCod=%ld AND UsrCod=%ld",
|
||||
" SET EndTime=NOW(),"
|
||||
"NumQsts=%u,"
|
||||
"NumQstsNotBlank=%u,"
|
||||
"Score='%.15lg'"
|
||||
" WHERE MchCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Print->NumQsts.All,
|
||||
Print->NumQsts.NotBlank,
|
||||
Print->Score,
|
||||
|
@ -153,12 +156,14 @@ void MchPrn_GetMatchPrintDataByMchCodAndUsrCod (struct MchPrn_Print *Print)
|
|||
"mch_results.NumQsts," // row[3]
|
||||
"mch_results.NumQstsNotBlank," // row[4]
|
||||
"mch_results.Score" // row[5]
|
||||
" FROM mch_results,mch_matches,gam_games"
|
||||
" FROM mch_results,"
|
||||
"mch_matches,"
|
||||
"gam_games"
|
||||
" WHERE mch_results.MchCod=%ld"
|
||||
" AND mch_results.UsrCod=%ld"
|
||||
" AND mch_results.MchCod=mch_matches.MchCod"
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
" AND gam_games.CrsCod=%ld", // Extra check
|
||||
" AND mch_results.UsrCod=%ld"
|
||||
" AND mch_results.MchCod=mch_matches.MchCod"
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
" AND gam_games.CrsCod=%ld", // Extra check
|
||||
Print->MchCod,Print->UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod) == 1)
|
||||
{
|
||||
|
|
|
@ -402,14 +402,16 @@ static void MchRes_ListAllMchResultsInGam (struct Gam_Games *Games,long GamCod)
|
|||
|
||||
/***** Get all users who have answered any match question in this game *****/
|
||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in game",
|
||||
"SELECT users.UsrCod FROM"
|
||||
" (SELECT DISTINCT mch_results.UsrCod AS UsrCod" // row[0]
|
||||
" FROM mch_results,mch_matches,gam_games"
|
||||
" WHERE mch_matches.GamCod=%ld"
|
||||
" AND mch_matches.MchCod=mch_results.MchCod"
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
" AND gam_games.CrsCod=%ld)" // Extra check
|
||||
" AS users,usr_data"
|
||||
"SELECT users.UsrCod" // row[0]
|
||||
" FROM (SELECT DISTINCT mch_results.UsrCod AS UsrCod"
|
||||
" FROM mch_results,"
|
||||
"mch_matches,"
|
||||
"gam_games"
|
||||
" WHERE mch_matches.GamCod=%ld"
|
||||
" AND mch_matches.MchCod=mch_results.MchCod"
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
" AND gam_games.CrsCod=%ld) AS users," // Extra check
|
||||
"usr_data"
|
||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||
" ORDER BY usr_data.Surname1,"
|
||||
"usr_data.Surname2,"
|
||||
|
@ -496,14 +498,16 @@ static void MchRes_ListAllMchResultsInMch (struct Gam_Games *Games,long MchCod)
|
|||
|
||||
/***** Get all users who have answered any match question in this game *****/
|
||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in match",
|
||||
"SELECT users.UsrCod FROM"
|
||||
" (SELECT mch_results.UsrCod AS UsrCod" // row[0]
|
||||
" FROM mch_results,mch_matches,gam_games"
|
||||
" WHERE mch_results.MchCod=%ld"
|
||||
" AND mch_results.MchCod=mch_matches.MchCod"
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
" AND gam_games.CrsCod=%ld)" // Extra check
|
||||
" AS users,usr_data"
|
||||
"SELECT users.UsrCod"
|
||||
" FROM (SELECT mch_results.UsrCod AS UsrCod" // row[0]
|
||||
" FROM mch_results,"
|
||||
"mch_matches,"
|
||||
"gam_games"
|
||||
" WHERE mch_results.MchCod=%ld"
|
||||
" AND mch_results.MchCod=mch_matches.MchCod"
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
" AND gam_games.CrsCod=%ld) AS users," // Extra check
|
||||
"usr_data"
|
||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||
" ORDER BY usr_data.Surname1,"
|
||||
"usr_data.Surname2,"
|
||||
|
@ -850,15 +854,17 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
|
|||
/***** Make database query *****/
|
||||
NumResults =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get matches results",
|
||||
"SELECT mch_results.MchCod" // row[0]
|
||||
" FROM mch_results,mch_matches,gam_games"
|
||||
"SELECT mch_results.MchCod" // row[0]
|
||||
" FROM mch_results,"
|
||||
"mch_matches,"
|
||||
"gam_games"
|
||||
" WHERE mch_results.UsrCod=%ld"
|
||||
"%s" // Match subquery
|
||||
" AND mch_results.MchCod=mch_matches.MchCod"
|
||||
"%s" // Games subquery
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
"%s" // Hidden games subquery
|
||||
" AND gam_games.CrsCod=%ld" // Extra check
|
||||
"%s" // Match subquery
|
||||
" AND mch_results.MchCod=mch_matches.MchCod"
|
||||
"%s" // Games subquery
|
||||
" AND mch_matches.GamCod=gam_games.GamCod"
|
||||
"%s" // Hidden games subquery
|
||||
" AND gam_games.CrsCod=%ld" // Extra check
|
||||
" ORDER BY mch_matches.Title",
|
||||
UsrDat->UsrCod,
|
||||
MchSubQuery,
|
||||
|
|
726
swad_message.c
726
swad_message.c
File diff suppressed because it is too large
Load Diff
|
@ -225,9 +225,12 @@ void Net_ShowWebsAndSocialNets (const struct UsrData *UsrDat)
|
|||
{
|
||||
/***** Check if exists the web / social network for this user *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get user's web / social network",
|
||||
"SELECT URL FROM usr_webs"
|
||||
" WHERE UsrCod=%ld AND Web='%s'",
|
||||
UsrDat->UsrCod,Net_WebsAndSocialNetworksDB[NumURL]))
|
||||
"SELECT URL"
|
||||
" FROM usr_webs"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Web='%s'",
|
||||
UsrDat->UsrCod,
|
||||
Net_WebsAndSocialNetworksDB[NumURL]))
|
||||
{
|
||||
/* Get URL */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -301,8 +304,10 @@ void Net_ShowFormMyWebsAndSocialNets (void)
|
|||
{
|
||||
/***** Get user's web / social network from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get user's web / social network",
|
||||
"SELECT URL FROM usr_webs"
|
||||
" WHERE UsrCod=%ld AND Web='%s'",
|
||||
"SELECT URL"
|
||||
" FROM usr_webs"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Web='%s'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Net_WebsAndSocialNetworksDB[NumURL]))
|
||||
{
|
||||
|
@ -459,9 +464,10 @@ void Net_ShowWebAndSocialNetworksStats (void)
|
|||
" with webs / social networks",
|
||||
"SELECT Web," // row[0]
|
||||
"COUNT(*) AS N" // row[1]
|
||||
" FROM usr_webs"
|
||||
" FROM usr_webs"
|
||||
" GROUP BY Web"
|
||||
" ORDER BY N DESC,Web");
|
||||
" ORDER BY N DESC,"
|
||||
"Web");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
NumRows = (unsigned)
|
||||
|
|
|
@ -121,8 +121,11 @@ bool Nck_GetNicknameFromUsrCod (long UsrCod,
|
|||
|
||||
/***** Get current (last updated) user's nickname from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get nickname",
|
||||
"SELECT Nickname FROM usr_nicknames"
|
||||
" WHERE UsrCod=%ld ORDER BY CreatTime DESC LIMIT 1",
|
||||
"SELECT Nickname"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE UsrCod=%ld"
|
||||
" ORDER BY CreatTime DESC"
|
||||
" LIMIT 1",
|
||||
UsrCod))
|
||||
{
|
||||
/* Get nickname */
|
||||
|
@ -166,9 +169,10 @@ long Nck_GetUsrCodFromNickname (const char *Nickname)
|
|||
/* Check if user code from table usr_nicknames is also in table usr_data */
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get user's code",
|
||||
"SELECT usr_nicknames.UsrCod"
|
||||
" FROM usr_nicknames,usr_data"
|
||||
" FROM usr_nicknames,"
|
||||
"usr_data"
|
||||
" WHERE usr_nicknames.Nickname='%s'"
|
||||
" AND usr_nicknames.UsrCod=usr_data.UsrCod",
|
||||
" AND usr_nicknames.UsrCod=usr_data.UsrCod",
|
||||
NickWithoutArr))
|
||||
{
|
||||
/* Get row */
|
||||
|
@ -237,7 +241,8 @@ static void Nck_ShowFormChangeUsrNickname (bool ItsMe,
|
|||
/***** Get my nicknames *****/
|
||||
NumNicks =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get nicknames of a user",
|
||||
"SELECT Nickname FROM usr_nicknames"
|
||||
"SELECT Nickname"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE UsrCod=%ld"
|
||||
" ORDER BY CreatTime DESC",
|
||||
UsrDat->UsrCod);
|
||||
|
@ -577,14 +582,20 @@ static void Nck_UpdateUsrNick (struct UsrData *UsrDat)
|
|||
{
|
||||
/***** Check if the new nickname matches any of my old nicknames *****/
|
||||
if (!DB_QueryCOUNT ("can not check if nickname already existed",
|
||||
"SELECT COUNT(*) FROM usr_nicknames"
|
||||
" WHERE UsrCod=%ld AND Nickname='%s'",
|
||||
UsrDat->UsrCod,NewNickWithoutArr)) // No matches
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Nickname='%s'",
|
||||
UsrDat->UsrCod,
|
||||
NewNickWithoutArr)) // No matches
|
||||
/***** Check if the new nickname matches any of the nicknames of other users *****/
|
||||
if (DB_QueryCOUNT ("can not check if nickname already existed",
|
||||
"SELECT COUNT(*) FROM usr_nicknames"
|
||||
" WHERE Nickname='%s' AND UsrCod<>%ld",
|
||||
NewNickWithoutArr,UsrDat->UsrCod)) // A nickname of another user is the same that user's nickname
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE Nickname='%s'"
|
||||
" AND UsrCod<>%ld",
|
||||
NewNickWithoutArr,
|
||||
UsrDat->UsrCod)) // A nickname of another user is the same that user's nickname
|
||||
Ale_CreateAlert (Ale_WARNING,Nck_NICKNAME_SECTION_ID,
|
||||
Txt_The_nickname_X_had_been_registered_by_another_user,
|
||||
NewNickWithoutArr);
|
||||
|
|
|
@ -337,17 +337,19 @@ void Not_RemoveNotice (void)
|
|||
"CreatTime,"
|
||||
"Content,"
|
||||
"NumNotif"
|
||||
" FROM not_notices"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
NotCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
" FROM not_notices"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/* Remove notice */
|
||||
DB_QueryDELETE ("can not remove notice",
|
||||
"DELETE FROM not_notices"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
NotCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Mark possible notifications as removed *****/
|
||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_NOTICE,NotCod);
|
||||
|
@ -584,8 +586,10 @@ static void Not_GetDataAndShowNotice (long NotCod)
|
|||
"Content," // row[2]
|
||||
"Status" // row[3]
|
||||
" FROM not_notices"
|
||||
" WHERE NotCod=%ld AND CrsCod=%ld",
|
||||
NotCod,Gbl.Hierarchy.Crs.CrsCod))
|
||||
" WHERE NotCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
NotCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -958,17 +962,17 @@ unsigned Not_GetNumNoticesDeleted (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(NumNotif)" // row[1]
|
||||
" FROM not_deleted");
|
||||
" FROM not_deleted");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of deleted notices",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(not_deleted.NumNotif)" // row[1]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_deleted"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"not_deleted"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
|
|
|
@ -1354,12 +1354,12 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
|||
" to be notified",
|
||||
"SELECT DISTINCT(PublisherCod)" // row[0]
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod="
|
||||
"(SELECT NotCod"
|
||||
" FROM tml_pubs"
|
||||
" WHERE PubCod=%ld)"
|
||||
" AND PublisherCod<>%ld",
|
||||
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
" WHERE NotCod=(SELECT NotCod"
|
||||
" FROM tml_pubs"
|
||||
" WHERE PubCod=%ld)"
|
||||
" AND PublisherCod<>%ld",
|
||||
Cod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Ntf_EVENT_TL_FAV: // New favourite to one of my social notes or comments
|
||||
case Ntf_EVENT_TL_SHARE: // New sharing of one of my social notes
|
||||
|
@ -1404,11 +1404,12 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
|
|||
" to be notified",
|
||||
"SELECT DISTINCT(UsrCod)" // row[0]
|
||||
" FROM for_posts"
|
||||
" WHERE ThrCod = (SELECT ThrCod"
|
||||
" FROM for_posts"
|
||||
" WHERE PstCod=%ld)"
|
||||
" WHERE ThrCod=(SELECT ThrCod"
|
||||
" FROM for_posts"
|
||||
" WHERE PstCod=%ld)"
|
||||
" AND UsrCod<>%ld",
|
||||
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
Cod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Ntf_EVENT_MESSAGE: // This function should not be called in this case
|
||||
return 0;
|
||||
|
|
|
@ -120,7 +120,7 @@ bool Pwd_CheckPendingPassword (void)
|
|||
|
||||
/***** Get pending password from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get pending password",
|
||||
"SELECT PendingPassword"
|
||||
"SELECT PendingPassword" // row[0]
|
||||
" FROM usr_pending_passwd"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||
|
@ -594,9 +594,12 @@ static unsigned Pwd_GetNumOtherUsrsWhoUseThisPassword (const char *EncryptedPass
|
|||
/***** Get number of other users who use a password from database *****/
|
||||
NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not check if a password is trivial",
|
||||
"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE Password='%s'%s",
|
||||
EncryptedPassword,SubQuery);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_data"
|
||||
" WHERE Password='%s'"
|
||||
"%s",
|
||||
EncryptedPassword,
|
||||
SubQuery);
|
||||
|
||||
/***** Free subquery *****/
|
||||
if (UsrCod > 0)
|
||||
|
|
55
swad_photo.c
55
swad_photo.c
|
@ -1502,7 +1502,9 @@ void Pho_RemoveObsoleteStatDegrees (void)
|
|||
{
|
||||
DB_QueryDELETE ("can not remove old degrees from stats",
|
||||
"DELETE FROM sta_degrees"
|
||||
" WHERE DegCod NOT IN (SELECT DegCod FROM deg_degrees)");
|
||||
" WHERE DegCod NOT IN"
|
||||
" (SELECT DegCod"
|
||||
" FROM deg_degrees)");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1520,7 +1522,8 @@ static long Pho_GetTimeAvgPhotoWasComputed (long DegCod)
|
|||
NumRows = DB_QuerySELECT (&mysql_res,"can not get last time"
|
||||
" an average photo was computed",
|
||||
"SELECT MIN(UNIX_TIMESTAMP(TimeAvgPhoto))"
|
||||
" FROM sta_degrees WHERE DegCod=%ld",
|
||||
" FROM sta_degrees"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
|
||||
if (NumRows == 1)
|
||||
|
@ -1555,7 +1558,8 @@ static long Pho_GetTimeToComputeAvgPhoto (long DegCod)
|
|||
/***** Get time to compute average photo from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get time to compute"
|
||||
" average photo",
|
||||
"SELECT TimeToComputeAvgPhoto FROM sta_degrees"
|
||||
"SELECT TimeToComputeAvgPhoto" // row[0]
|
||||
" FROM sta_degrees"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
|
||||
|
@ -2100,10 +2104,12 @@ static void Pho_GetMaxStdsPerDegree (struct Pho_DegPhotos *DegPhotos)
|
|||
/***** Get maximum number of students in a degree from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get maximum"
|
||||
" number of students in a degree",
|
||||
"SELECT MAX(NumStds),MAX(NumStdsWithPhoto),"
|
||||
"MAX(NumStdsWithPhoto/NumStds)"
|
||||
" FROM sta_degrees"
|
||||
" WHERE Sex='all' AND NumStds>0");
|
||||
"SELECT MAX(NumStds)," // row[0]
|
||||
"MAX(NumStdsWithPhoto)," // row[1]
|
||||
"MAX(NumStdsWithPhoto/NumStds)" // row[2]
|
||||
" FROM sta_degrees"
|
||||
" WHERE Sex='all'"
|
||||
" AND NumStds>0");
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
if (NumRows == 1)
|
||||
|
@ -2337,10 +2343,10 @@ static unsigned long Pho_BuildQueryOfDegrees (Pho_HowOrderDegrees_t HowOrderDegr
|
|||
case Pho_NUMBER_OF_STUDENTS:
|
||||
NumDegs = DB_QuerySELECT (mysql_res,"can not get degrees",
|
||||
"SELECT deg_degrees.DegCod"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" WHERE sta_degrees.Sex='all'"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" ORDER BY sta_degrees.NumStds DESC,"
|
||||
"sta_degrees.NumStdsWithPhoto DESC,"
|
||||
"deg_degrees.ShortName");
|
||||
|
@ -2348,10 +2354,10 @@ static unsigned long Pho_BuildQueryOfDegrees (Pho_HowOrderDegrees_t HowOrderDegr
|
|||
case Pho_NUMBER_OF_PHOTOS:
|
||||
NumDegs = DB_QuerySELECT (mysql_res,"can not get degrees",
|
||||
"SELECT deg_degrees.DegCod"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" WHERE sta_degrees.Sex='all'"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" ORDER BY sta_degrees.NumStdsWithPhoto DESC,"
|
||||
"sta_degrees.NumStds DESC,"
|
||||
"deg_degrees.ShortName");
|
||||
|
@ -2359,10 +2365,10 @@ static unsigned long Pho_BuildQueryOfDegrees (Pho_HowOrderDegrees_t HowOrderDegr
|
|||
case Pho_PERCENT:
|
||||
NumDegs = DB_QuerySELECT (mysql_res,"can not get degrees",
|
||||
"SELECT deg_degrees.DegCod"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" WHERE sta_degrees.Sex='all'"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" ORDER BY sta_degrees.NumStdsWithPhoto/"
|
||||
"sta_degrees.NumStds DESC,"
|
||||
"deg_degrees.ShortName");
|
||||
|
@ -2370,10 +2376,10 @@ static unsigned long Pho_BuildQueryOfDegrees (Pho_HowOrderDegrees_t HowOrderDegr
|
|||
case Pho_DEGREE_NAME:
|
||||
NumDegs = DB_QuerySELECT (mysql_res,"can not get degrees",
|
||||
"SELECT deg_degrees.DegCod"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" FROM deg_degrees,sta_degrees"
|
||||
" WHERE sta_degrees.Sex='all'"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" AND sta_degrees.NumStds>0"
|
||||
" AND deg_degrees.DegCod=sta_degrees.DegCod"
|
||||
" ORDER BY deg_degrees.ShortName");
|
||||
break;
|
||||
}
|
||||
|
@ -2395,10 +2401,13 @@ static void Pho_GetNumStdsInDegree (long DegCod,Usr_Sex_t Sex,int *NumStds,int *
|
|||
/***** Get the number of students in a degree from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the number of students"
|
||||
" in a degree",
|
||||
"SELECT NumStds,NumStdsWithPhoto"
|
||||
" FROM sta_degrees"
|
||||
" WHERE DegCod=%ld AND Sex='%s'",
|
||||
DegCod,Usr_StringsSexDB[Sex]);
|
||||
"SELECT NumStds,"
|
||||
"NumStdsWithPhoto"
|
||||
" FROM sta_degrees"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND Sex='%s'",
|
||||
DegCod,
|
||||
Usr_StringsSexDB[Sex]);
|
||||
|
||||
if (NumRows == 0)
|
||||
*NumStds = *NumStdsWithPhoto = -1;
|
||||
|
|
12
swad_place.c
12
swad_place.c
|
@ -464,9 +464,9 @@ void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc)
|
|||
{
|
||||
/***** Get data of a place from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a place",
|
||||
"(SELECT plc_places.ShortName,"
|
||||
"plc_places.FullName,"
|
||||
"COUNT(*)"
|
||||
"(SELECT plc_places.ShortName," // row[0]
|
||||
"plc_places.FullName," // row[1]
|
||||
"COUNT(*)" // row[2]
|
||||
" FROM plc_places,"
|
||||
"ctr_centers"
|
||||
" WHERE plc_places.PlcCod=%ld"
|
||||
|
@ -474,9 +474,9 @@ void Plc_GetDataOfPlaceByCod (struct Plc_Place *Plc)
|
|||
" AND ctr_centers.PlcCod=%ld"
|
||||
" GROUP BY plc_places.PlcCod)"
|
||||
" UNION "
|
||||
"(SELECT ShortName,"
|
||||
"FullName,"
|
||||
"0"
|
||||
"(SELECT ShortName," // row[0]
|
||||
"FullName," // row[1]
|
||||
"0" // row[2]
|
||||
" FROM plc_places"
|
||||
" WHERE PlcCod=%ld"
|
||||
" AND PlcCod NOT IN"
|
||||
|
|
|
@ -591,7 +591,8 @@ static bool Plg_CheckIfPluginNameExists (const char *Name,long PlgCod)
|
|||
/***** Get number of plugins with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name of a plugin"
|
||||
" already existed",
|
||||
"SELECT COUNT(*) FROM plg_plugins"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM plg_plugins"
|
||||
" WHERE Name='%s'"
|
||||
" AND PlgCod<>%ld",
|
||||
Name,PlgCod) != 0);
|
||||
|
|
|
@ -887,10 +887,12 @@ static unsigned long Prf_GetRankingFigure (long UsrCod,const char *FieldName)
|
|||
/***** Select number of rows with figure
|
||||
greater than the figure of this user *****/
|
||||
return DB_QueryCOUNT ("can not get ranking using a figure",
|
||||
"SELECT COUNT(*)+1 FROM usr_figures"
|
||||
"SELECT COUNT(*)+1"
|
||||
" FROM usr_figures"
|
||||
" WHERE UsrCod<>%ld" // Really not necessary here
|
||||
" AND %s>"
|
||||
"(SELECT %s FROM usr_figures WHERE UsrCod=%ld)",
|
||||
" AND %s>(SELECT %s"
|
||||
" FROM usr_figures"
|
||||
" WHERE UsrCod=%ld)",
|
||||
UsrCod,FieldName,FieldName,UsrCod);
|
||||
}
|
||||
|
||||
|
@ -902,7 +904,8 @@ static unsigned long Prf_GetNumUsrsWithFigure (const char *FieldName)
|
|||
{
|
||||
/***** Select number of rows with values already calculated *****/
|
||||
return DB_QueryCOUNT ("can not get number of users with a figure",
|
||||
"SELECT COUNT(*) FROM usr_figures"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_figures"
|
||||
" WHERE %s>=0",
|
||||
FieldName);
|
||||
}
|
||||
|
@ -916,20 +919,18 @@ static unsigned long Prf_GetRankingNumClicksPerDay (long UsrCod)
|
|||
/***** Select number of rows with number of clicks per day
|
||||
greater than the clicks per day of this user *****/
|
||||
return DB_QueryCOUNT ("can not get ranking using number of clicks per day",
|
||||
"SELECT COUNT(*)+1 FROM"
|
||||
" (SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1)"
|
||||
" AS NumClicksPerDay"
|
||||
" FROM usr_figures"
|
||||
" WHERE UsrCod<>%ld" // Necessary because the following comparison is not exact in floating point
|
||||
" AND NumClicks>0"
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0))"
|
||||
" AS TableNumClicksPerDay"
|
||||
"SELECT COUNT(*)+1"
|
||||
" FROM (SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1) AS NumClicksPerDay"
|
||||
" FROM usr_figures"
|
||||
" WHERE UsrCod<>%ld" // Necessary because the following comparison is not exact in floating point
|
||||
" AND NumClicks>0"
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0)) AS TableNumClicksPerDay"
|
||||
" WHERE NumClicksPerDay>"
|
||||
"(SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1)"
|
||||
" FROM usr_figures"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND NumClicks>0"
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0))",
|
||||
"(SELECT NumClicks/(DATEDIFF(NOW(),FirstClickTime)+1)"
|
||||
" FROM usr_figures"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND NumClicks>0"
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0))",
|
||||
UsrCod,UsrCod);
|
||||
}
|
||||
|
||||
|
@ -942,9 +943,10 @@ static unsigned long Prf_GetNumUsrsWithNumClicksPerDay (void)
|
|||
/***** Select number of rows with values already calculated *****/
|
||||
return DB_QueryCOUNT ("can not get number of users"
|
||||
" with number of clicks per day",
|
||||
"SELECT COUNT(*) FROM usr_figures"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_figures"
|
||||
" WHERE NumClicks>0"
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0)");
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0)");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1056,8 +1058,9 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
|
|||
/***** Get first click from log table *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get user's first click",
|
||||
"SELECT UNIX_TIMESTAMP("
|
||||
"(SELECT MIN(ClickTime) FROM log"
|
||||
" WHERE UsrCod=%ld)"
|
||||
"(SELECT MIN(ClickTime)"
|
||||
" FROM log"
|
||||
" WHERE UsrCod=%ld)"
|
||||
")",
|
||||
UsrCod))
|
||||
{
|
||||
|
@ -1100,7 +1103,8 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
|
|||
/***** Get number of clicks from database *****/
|
||||
UsrFigures.NumClicks =
|
||||
(long) DB_QueryCOUNT ("can not get number of clicks",
|
||||
"SELECT COUNT(*) FROM log"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM log"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
|
||||
|
@ -1439,16 +1443,17 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT UsrCod," // row[0]
|
||||
"%s" // row[1]
|
||||
" FROM usr_figures"
|
||||
" FROM usr_figures"
|
||||
" WHERE %s>0"
|
||||
" AND UsrCod NOT IN"
|
||||
" (SELECT UsrCod"
|
||||
" FROM usr_banned)"
|
||||
" AND UsrCod NOT IN"
|
||||
" (SELECT UsrCod"
|
||||
" FROM usr_banned)"
|
||||
" ORDER BY %s DESC,"
|
||||
"UsrCod"
|
||||
" LIMIT 100",
|
||||
FieldName,
|
||||
FieldName,FieldName);
|
||||
FieldName,
|
||||
FieldName);
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
NumUsrs = (unsigned)
|
||||
|
@ -1477,7 +1482,8 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
" LIMIT 100",
|
||||
FieldName,
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
FieldName,FieldName);
|
||||
FieldName,
|
||||
FieldName);
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
NumUsrs = (unsigned)
|
||||
|
@ -1504,7 +1510,8 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
" LIMIT 100",
|
||||
FieldName,
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
FieldName,FieldName);
|
||||
FieldName,
|
||||
FieldName);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
NumUsrs = (unsigned)
|
||||
|
@ -1668,14 +1675,15 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT UsrCod," // row[0]
|
||||
"NumClicks/(DATEDIFF(NOW(),"
|
||||
"FirstClickTime)+1) AS NumClicksPerDay" // row[1]
|
||||
" FROM usr_figures"
|
||||
"FirstClickTime)+1) AS NumClicksPerDay" // row[1]
|
||||
" FROM usr_figures"
|
||||
" WHERE NumClicks>0"
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0)"
|
||||
" AND UsrCod NOT IN"
|
||||
" (SELECT UsrCod"
|
||||
" FROM usr_banned)"
|
||||
" ORDER BY NumClicksPerDay DESC,UsrCod"
|
||||
" AND FirstClickTime>FROM_UNIXTIME(0)"
|
||||
" AND UsrCod NOT IN"
|
||||
" (SELECT UsrCod"
|
||||
" FROM usr_banned)"
|
||||
" ORDER BY NumClicksPerDay DESC,"
|
||||
"UsrCod"
|
||||
" LIMIT 100");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
|
|
123
swad_program.c
123
swad_program.c
|
@ -981,7 +981,7 @@ static void Prg_GetListItems (void)
|
|||
"ItmInd," // row[1]
|
||||
"Level," // row[2]
|
||||
"Hidden" // row[3]
|
||||
" FROM prg_items"
|
||||
" FROM prg_items"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" ORDER BY ItmInd",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
|
@ -1045,9 +1045,9 @@ static void Prg_GetDataOfItemByCod (struct ProgramItem *Item)
|
|||
"UNIX_TIMESTAMP(EndTime)," // row[6]
|
||||
"NOW() BETWEEN StartTime AND EndTime," // row[7]
|
||||
"Title" // row[8]
|
||||
" FROM prg_items"
|
||||
" FROM prg_items"
|
||||
" WHERE ItmCod=%ld"
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
Item->Hierarchy.ItmCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Get data of program item *****/
|
||||
|
@ -1165,9 +1165,10 @@ static void Prg_GetItemTxtFromDB (long ItmCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
|
|||
|
||||
/***** Get text of program item from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get program item text",
|
||||
"SELECT Txt FROM prg_items"
|
||||
"SELECT Txt"
|
||||
" FROM prg_items"
|
||||
" WHERE ItmCod=%ld"
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
ItmCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
|
@ -2189,65 +2190,65 @@ unsigned Prg_GetNumCoursesWithItems (Hie_Lvl_Level_t Scope)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with program items",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM prg_items"
|
||||
" FROM prg_items"
|
||||
" WHERE CrsCod>0");
|
||||
case Hie_Lvl_CTY:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with program items",
|
||||
"SELECT COUNT(DISTINCT prg_items.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
case Hie_Lvl_INS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with program items",
|
||||
"SELECT COUNT(DISTINCT prg_items.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
case Hie_Lvl_CTR:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with program items",
|
||||
"SELECT COUNT(DISTINCT prg_items.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
case Hie_Lvl_DEG:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with program items",
|
||||
"SELECT COUNT(DISTINCT prg_items.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"prg_items"
|
||||
" FROM crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
case Hie_Lvl_CRS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with program items",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM prg_items"
|
||||
" FROM prg_items"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
|
@ -2269,66 +2270,66 @@ unsigned Prg_GetNumItems (Hie_Lvl_Level_t Scope)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of program items",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM prg_items"
|
||||
" FROM prg_items"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of program items",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of program items",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of program items",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of program items",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses,"
|
||||
"prg_items"
|
||||
" FROM crs_courses,"
|
||||
"prg_items"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
" AND crs_courses.CrsCod=prg_items.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of program items",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM prg_items"
|
||||
" FROM prg_items"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
|
|
|
@ -2942,7 +2942,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
" FROM prj_projects,"
|
||||
"prj_users"
|
||||
" WHERE prj_projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
"%s%s%s"
|
||||
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
||||
" AND prj_users.UsrCod=%ld"
|
||||
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
||||
|
@ -2959,7 +2959,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
"prj_users"
|
||||
" ON prj_projects.DptCod=dpt_departments.DptCod"
|
||||
" WHERE prj_projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
"%s%s%s"
|
||||
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
||||
" AND prj_users.UsrCod=%ld"
|
||||
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
||||
|
@ -2995,7 +2995,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
" FROM prj_projects,"
|
||||
"prj_users"
|
||||
" WHERE prj_projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
"%s%s%s"
|
||||
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
||||
" AND prj_users.UsrCod IN (%s)"
|
||||
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
||||
|
@ -3012,7 +3012,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
"prj_users"
|
||||
" ON prj_projects.DptCod=dpt_departments.DptCod"
|
||||
" WHERE prj_projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
"%s%s%s"
|
||||
" AND prj_projects.PrjCod=prj_users.PrjCod"
|
||||
" AND prj_users.UsrCod IN (%s)"
|
||||
" GROUP BY prj_projects.PrjCod" // To not repeat projects (DISTINCT can not be used)
|
||||
|
@ -3044,7 +3044,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
"SELECT prj_projects.PrjCod"
|
||||
" FROM prj_projects"
|
||||
" WHERE prj_projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
"%s%s%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||
|
@ -3056,7 +3056,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
" FROM prj_projects LEFT JOIN dpt_departments"
|
||||
" ON prj_projects.DptCod=dpt_departments.DptCod"
|
||||
" WHERE prj_projects.CrsCod=%ld"
|
||||
"%s%s%s"
|
||||
"%s%s%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
PreNonSubQuery,HidVisSubQuery,DptCodSubQuery,
|
||||
|
@ -4153,7 +4153,8 @@ static void Prj_GetConfigPrjFromDB (struct Prj_Projects *Projects)
|
|||
/***** Get configuration of projects for current course from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get configuration of test",
|
||||
"SELECT Editable" // row[0]
|
||||
" FROM prj_config WHERE CrsCod=%ld",
|
||||
" FROM prj_config"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
if (NumRows == 0)
|
||||
|
|
|
@ -200,13 +200,16 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
|||
return;
|
||||
|
||||
/***** Get fields of records in a course from database *****/
|
||||
Gbl.Crs.Records.LstFields.Num =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get fields of records"
|
||||
" in a course",
|
||||
"SELECT FieldCod,FieldName,NumLines,Visibility"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld ORDER BY FieldName",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
Gbl.Crs.Records.LstFields.Num = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get fields of records in a course",
|
||||
"SELECT FieldCod,"
|
||||
"FieldName,"
|
||||
"NumLines,"
|
||||
"Visibility"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld"
|
||||
" ORDER BY FieldName",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** Get the fields of records *****/
|
||||
if (Gbl.Crs.Records.LstFields.Num)
|
||||
|
@ -520,9 +523,12 @@ unsigned long Rec_GetAllFieldsInCurrCrs (MYSQL_RES **mysql_res)
|
|||
/***** Get fields of records in current course from database *****/
|
||||
return DB_QuerySELECT (mysql_res,"can not get fields of records"
|
||||
" in a course",
|
||||
"SELECT FieldCod,FieldName,Visibility"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld ORDER BY FieldName",
|
||||
"SELECT FieldCod," // row[0]
|
||||
"FieldName," // row[1]
|
||||
"Visibility" // row[2]
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld"
|
||||
" ORDER BY FieldName",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
}
|
||||
|
||||
|
@ -589,7 +595,8 @@ unsigned Rec_CountNumRecordsInCurrCrsWithField (long FieldCod)
|
|||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of records"
|
||||
" with a given field not empty in a course",
|
||||
"SELECT COUNT(*) FROM crs_records"
|
||||
"SELECT COUNT(*)"
|
||||
v" FROM crs_records"
|
||||
" WHERE FieldCod=%ld",
|
||||
FieldCod);
|
||||
}
|
||||
|
@ -678,9 +685,12 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD
|
|||
/***** Get a field of a record in a course from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get a field of a record"
|
||||
" in a course",
|
||||
"SELECT FieldName,NumLines,Visibility"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld AND FieldCod=%ld",
|
||||
"SELECT FieldName," // row[0]
|
||||
"NumLines," // row[1]
|
||||
"Visibility" // row[2]
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND FieldCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,FieldCod);
|
||||
|
||||
/***** Count number of rows in result *****/
|
||||
|
@ -1846,8 +1856,10 @@ unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **m
|
|||
/***** Get the text of a field of a record from database *****/
|
||||
return DB_QuerySELECT (mysql_res,"can not get the text"
|
||||
" of a field of a record",
|
||||
"SELECT Txt FROM crs_records"
|
||||
" WHERE FieldCod=%ld AND UsrCod=%ld",
|
||||
"SELECT Txt"
|
||||
" FROM crs_records"
|
||||
" WHERE FieldCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
FieldCod,UsrCod);
|
||||
}
|
||||
|
||||
|
@ -1930,8 +1942,11 @@ void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs)
|
|||
/***** Remove text of the field of record course *****/
|
||||
DB_QueryDELETE ("can not remove user's record in a course",
|
||||
"DELETE FROM crs_records"
|
||||
" WHERE UsrCod=%ld AND FieldCod IN"
|
||||
" (SELECT FieldCod FROM crs_record_fields WHERE CrsCod=%ld)",
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND FieldCod IN"
|
||||
" (SELECT FieldCod"
|
||||
" FROM crs_record_fields"
|
||||
" WHERE CrsCod=%ld)",
|
||||
UsrCod,Crs->CrsCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -779,12 +779,14 @@ static void Rep_WriteSectionHitsPerAction (struct Rep_Report *Report)
|
|||
|
||||
/***** Make the query *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get clicks",
|
||||
"SELECT SQL_NO_CACHE ActCod,COUNT(*) AS N"
|
||||
" FROM log"
|
||||
"SELECT SQL_NO_CACHE ActCod," // row[0]
|
||||
"COUNT(*) AS N" // row[1]
|
||||
" FROM log"
|
||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
||||
" AND UsrCod=%ld"
|
||||
" AND UsrCod=%ld"
|
||||
" GROUP BY ActCod"
|
||||
" ORDER BY N DESC LIMIT %u",
|
||||
" ORDER BY N DESC"
|
||||
" LIMIT %u",
|
||||
(long) Report->UsrFigures.FirstClickTimeUTC,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Rep_MAX_ACTIONS);
|
||||
|
@ -922,30 +924,28 @@ static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report)
|
|||
DB_QuerySELECT (&mysql_res,"can not get last question index",
|
||||
"SELECT MAX(N) FROM ("
|
||||
// Clicks without course selected --------------------------
|
||||
"SELECT "
|
||||
"-1 AS CrsCod,"
|
||||
"YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
"%u AS Role,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM log"
|
||||
"SELECT -1 AS CrsCod,"
|
||||
"YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
"%u AS Role,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM log"
|
||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
||||
" AND UsrCod=%ld"
|
||||
" AND CrsCod<=0"
|
||||
" AND UsrCod=%ld"
|
||||
" AND CrsCod<=0"
|
||||
" GROUP BY Year"
|
||||
// ---------------------------------------------------------
|
||||
" UNION "
|
||||
// Clicks as student, non-editing teacher or teacher in courses
|
||||
"SELECT "
|
||||
"CrsCod,"
|
||||
"YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
"Role,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM log"
|
||||
"SELECT CrsCod,"
|
||||
"YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
"Role,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM log"
|
||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
||||
" AND UsrCod=%ld"
|
||||
" AND Role>=%u" // Student
|
||||
" AND Role<=%u" // Teacher
|
||||
" AND CrsCod>0"
|
||||
" AND UsrCod=%ld"
|
||||
" AND Role>=%u" // Student
|
||||
" AND Role<=%u" // Teacher
|
||||
" AND CrsCod>0"
|
||||
" GROUP BY CrsCod,Year,Role"
|
||||
// ---------------------------------------------------------
|
||||
") AS hits_per_crs_year",
|
||||
|
@ -1012,13 +1012,12 @@ static void Rep_GetAndWriteMyCurrentCrss (Rol_Role_t Role,
|
|||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get courses of a user",
|
||||
"SELECT my_courses.CrsCod," // row[0]
|
||||
"COUNT(*) AS N" // row[1]
|
||||
" FROM"
|
||||
" (SELECT CrsCod"
|
||||
" FROM crs_users"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Role=%u) AS my_courses" // It's imperative to use a derived table to not block crs_usr!
|
||||
" LEFT JOIN log"
|
||||
" ON (my_courses.CrsCod=log.CrsCod)"
|
||||
" FROM (SELECT CrsCod"
|
||||
" FROM crs_users"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Role=%u) AS my_courses" // It's imperative to use a derived table to not block crs_usr!
|
||||
" LEFT JOIN log"
|
||||
" ON (my_courses.CrsCod=log.CrsCod)"
|
||||
" WHERE log.UsrCod=%ld"
|
||||
" AND log.Role=%u"
|
||||
" GROUP BY my_courses.CrsCod"
|
||||
|
@ -1102,9 +1101,12 @@ static void Rep_GetAndWriteMyHistoricCrss (Rol_Role_t Role,
|
|||
/***** Get historic courses of a user from log *****/
|
||||
NumCrss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get courses of a user",
|
||||
"SELECT CrsCod,COUNT(*) AS N"
|
||||
" FROM log"
|
||||
" WHERE UsrCod=%ld AND Role=%u AND CrsCod>0"
|
||||
"SELECT CrsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM log"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Role=%u"
|
||||
" AND CrsCod>0"
|
||||
" GROUP BY CrsCod"
|
||||
" HAVING N>%u"
|
||||
" ORDER BY N DESC",
|
||||
|
@ -1240,11 +1242,12 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
|||
sprintf (SubQueryRol," AND Role=%u",(unsigned) Role);
|
||||
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get clicks",
|
||||
"SELECT SQL_NO_CACHE "
|
||||
"YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
"COUNT(*) FROM log"
|
||||
"SELECT SQL_NO_CACHE YEAR(CONVERT_TZ(ClickTime,@@session.time_zone,'UTC')) AS Year,"
|
||||
"COUNT(*) FROM log"
|
||||
" WHERE ClickTime>=FROM_UNIXTIME(%ld)"
|
||||
" AND UsrCod=%ld%s%s"
|
||||
" AND UsrCod=%ld"
|
||||
"%s"
|
||||
"%s"
|
||||
" GROUP BY Year"
|
||||
" ORDER BY Year DESC",
|
||||
(long) Report->UsrFigures.FirstClickTimeUTC,
|
||||
|
|
|
@ -467,10 +467,12 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
|
|||
NumCtys = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get countries",
|
||||
"SELECT CtyCod" // row[0]
|
||||
" FROM cty_countrs"
|
||||
" WHERE %s%s"
|
||||
" FROM cty_countrs"
|
||||
" WHERE %s"
|
||||
"%s"
|
||||
" ORDER BY Name_%s",
|
||||
SearchQuery,RangeQuery,
|
||||
SearchQuery,
|
||||
RangeQuery,
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
Cty_ListCtysFound (&mysql_res,NumCtys);
|
||||
return NumCtys;
|
||||
|
@ -505,14 +507,15 @@ static unsigned Sch_SearchInstitutionsInDB (const char *RangeQuery)
|
|||
NumInss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ins_instits.InsCod" // row[0]
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY ins_instits.FullName,"
|
||||
"cty_countrs.Name_%s",
|
||||
SearchQuery,RangeQuery,
|
||||
SearchQuery,
|
||||
RangeQuery,
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
Ins_ListInssFound (&mysql_res,NumInss);
|
||||
return NumInss;
|
||||
|
@ -544,13 +547,13 @@ static unsigned Sch_SearchCentersInDB (const char *RangeQuery)
|
|||
NumCtrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get centers",
|
||||
"SELECT ctr_centers.CtrCod" // row[0]
|
||||
" FROM ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" FROM ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY ctr_centers.FullName,"
|
||||
"ins_instits.FullName",
|
||||
SearchQuery,RangeQuery);
|
||||
|
@ -583,15 +586,15 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
|
|||
NumDegs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get degrees",
|
||||
"SELECT deg_degrees.DegCod" // row[0]
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY deg_degrees.FullName,"
|
||||
"ins_instits.FullName",
|
||||
SearchQuery,RangeQuery);
|
||||
|
@ -628,17 +631,17 @@ static unsigned Sch_SearchCoursesInDB (const char *RangeQuery)
|
|||
"crs_courses.Year," // row[4]
|
||||
"crs_courses.FullName," // row[5]
|
||||
"ctr_centers.ShortName" // row[6]
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE %s"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
"%s"
|
||||
" ORDER BY crs_courses.FullName,"
|
||||
"ins_instits.FullName,"
|
||||
"degrees.FullName,"
|
||||
|
@ -912,7 +915,9 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
|||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.FilCod IN (SELECT FilCod FROM my_files_crs)"
|
||||
" WHERE brw_files.FilCod IN"
|
||||
" (SELECT FilCod"
|
||||
" FROM my_files_crs)"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=crs_courses.CrsCod"
|
||||
|
@ -941,7 +946,9 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
|
|||
"ctr_centers,"
|
||||
"ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE brw_files.FilCod IN (SELECT FilCod FROM my_files_grp)"
|
||||
" WHERE brw_files.FilCod IN"
|
||||
" (SELECT FilCod"
|
||||
" FROM my_files_grp)"
|
||||
" AND %s"
|
||||
" AND brw_files.FileBrowser IN (%u,%u,%u,%u)"
|
||||
" AND brw_files.Cod=grp_groups.GrpCod"
|
||||
|
|
|
@ -399,8 +399,8 @@ void Ses_RemoveParamsFromExpiredSessions (void)
|
|||
DB_QueryDELETE ("can not remove session parameters of expired sessions",
|
||||
"DELETE FROM ses_params"
|
||||
" WHERE SessionId NOT IN"
|
||||
" (SELECT SessionId"
|
||||
" FROM ses_sessions)");
|
||||
" (SELECT SessionId"
|
||||
" FROM ses_sessions)");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -1789,7 +1789,9 @@ static void Sta_WriteLogComments (long LogCod)
|
|||
|
||||
/***** Get log comments from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get log comments",
|
||||
"SELECT Comments FROM log_comments WHERE LogCod=%ld",
|
||||
"SELECT Comments"
|
||||
" FROM log_comments"
|
||||
" WHERE LogCod=%ld",
|
||||
LogCod))
|
||||
{
|
||||
/***** Get and write comments *****/
|
||||
|
|
379
swad_survey.c
379
swad_survey.c
|
@ -1031,7 +1031,8 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
|||
/* Make query */
|
||||
if (SubQueryFilled)
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get surveys",
|
||||
"SELECT SvyCod FROM svy_surveys"
|
||||
"SELECT SvyCod"
|
||||
" FROM svy_surveys"
|
||||
" WHERE %s%s%s%s%s%s"
|
||||
" ORDER BY %s",
|
||||
SubQuery[Hie_Lvl_SYS],
|
||||
|
@ -1261,12 +1262,17 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy)
|
|||
|
||||
/***** Get data of survey from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get survey data",
|
||||
"SELECT SvyCod,Scope,Cod,Hidden,Roles,UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW() BETWEEN StartTime AND EndTime,"
|
||||
"Title"
|
||||
" FROM svy_surveys"
|
||||
"SELECT SvyCod," // row[0]
|
||||
"Scope," // row[1]
|
||||
"Cod," // row[2]
|
||||
"Hidden," // row[3]
|
||||
"Roles," // row[4]
|
||||
"UsrCod," // row[5]
|
||||
"UNIX_TIMESTAMP(StartTime)," // row[6]
|
||||
"UNIX_TIMESTAMP(EndTime)," // row[7]
|
||||
"NOW() BETWEEN StartTime AND EndTime," // row[8]
|
||||
"Title"
|
||||
" FROM svy_surveys"
|
||||
" WHERE SvyCod=%ld",
|
||||
Svy->SvyCod);
|
||||
|
||||
|
@ -1488,7 +1494,9 @@ static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1]
|
|||
|
||||
/***** Get text of survey from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get survey text",
|
||||
"SELECT Txt FROM svy_surveys WHERE SvyCod=%ld",
|
||||
"SELECT Txt"
|
||||
" FROM svy_surveys"
|
||||
" WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
|
@ -1526,7 +1534,7 @@ void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
if (DB_QuerySELECT (&mysql_res,"can not get groups of a survey",
|
||||
"SELECT Title," // row[0]
|
||||
"Txt" // row[1]
|
||||
" FROM svy_surveys"
|
||||
" FROM svy_surveys"
|
||||
" WHERE SvyCod=%ld",
|
||||
SvyCod) == 1)
|
||||
{
|
||||
|
@ -1851,11 +1859,16 @@ static bool Svy_CheckIfSimilarSurveyExists (struct Svy_Survey *Svy)
|
|||
{
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar surveys",
|
||||
"SELECT COUNT(*) FROM svy_surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld"
|
||||
" AND Title='%s' AND SvyCod<>%ld",
|
||||
Sco_GetDBStrFromScope (Svy->Scope),Svy->Cod,
|
||||
Svy->Title,Svy->SvyCod) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM svy_surveys"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld"
|
||||
" AND Title='%s'"
|
||||
" AND SvyCod<>%ld",
|
||||
Sco_GetDBStrFromScope (Svy->Scope),
|
||||
Svy->Cod,
|
||||
Svy->Title,
|
||||
Svy->SvyCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2613,16 +2626,16 @@ static bool Svy_CheckIfICanDoThisSurveyBasedOnGrps (long SvyCod)
|
|||
"SELECT COUNT(*)"
|
||||
" FROM svy_surveys"
|
||||
" WHERE SvyCod=%ld"
|
||||
" AND"
|
||||
" (SvyCod NOT IN"
|
||||
" (SELECT SvyCod FROM svy_groups)"
|
||||
" OR"
|
||||
" SvyCod IN"
|
||||
" (SELECT svy_groups.SvyCod"
|
||||
" FROM grp_users,"
|
||||
"svy_groups"
|
||||
" WHERE grp_users.UsrCod=%ld"
|
||||
" AND grp_users.GrpCod=svy_groups.GrpCod))",
|
||||
" AND (SvyCod NOT IN"
|
||||
" (SELECT SvyCod"
|
||||
" FROM svy_groups)"
|
||||
" OR"
|
||||
" SvyCod IN"
|
||||
" (SELECT svy_groups.SvyCod"
|
||||
" FROM grp_users,"
|
||||
"svy_groups"
|
||||
" WHERE grp_users.UsrCod=%ld"
|
||||
" AND grp_users.GrpCod=svy_groups.GrpCod))",
|
||||
SvyCod,Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
|
||||
}
|
||||
|
||||
|
@ -2635,7 +2648,8 @@ static unsigned Svy_GetNumQstsSvy (long SvyCod)
|
|||
/***** Get data of questions from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of questions of a survey",
|
||||
"SELECT COUNT(*) FROM svy_questions"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM svy_questions"
|
||||
" WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
}
|
||||
|
@ -2710,9 +2724,14 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
|||
/***** Get the type of answer and the stem from the database *****/
|
||||
/* Get the question from database */
|
||||
DB_QuerySELECT (&mysql_res,"can not get a question",
|
||||
"SELECT QstInd,AnsType,Stem FROM svy_questions"
|
||||
" WHERE QstCod=%ld AND SvyCod=%ld",
|
||||
SvyQst->QstCod,SvyCod);
|
||||
"SELECT QstInd," // row[0]
|
||||
"AnsType," // row[1]
|
||||
"Stem" // row[2]
|
||||
" FROM svy_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND SvyCod=%ld",
|
||||
SvyQst->QstCod,
|
||||
SvyCod);
|
||||
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -2948,8 +2967,10 @@ static bool Svy_CheckIfAnswerExists (long QstCod,unsigned AnsInd)
|
|||
{
|
||||
/***** Get answers of a question from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if an answer exists",
|
||||
"SELECT COUNT(*) FROM svy_answers"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM svy_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND AnsInd=%u",
|
||||
QstCod,AnsInd) != 0);
|
||||
}
|
||||
|
||||
|
@ -2963,8 +2984,12 @@ static unsigned Svy_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res)
|
|||
|
||||
/***** Get answers of a question from database *****/
|
||||
NumRows = DB_QuerySELECT (mysql_res,"can not get answers of a question",
|
||||
"SELECT AnsInd,NumUsrs,Answer FROM svy_answers"
|
||||
" WHERE QstCod=%ld ORDER BY AnsInd",
|
||||
"SELECT AnsInd,"
|
||||
"NumUsrs,"
|
||||
"Answer"
|
||||
" FROM svy_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY AnsInd",
|
||||
QstCod);
|
||||
|
||||
/***** Count number of rows of result *****/
|
||||
|
@ -3198,7 +3223,8 @@ static unsigned Svy_GetQstIndFromQstCod (long QstCod)
|
|||
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get question index",
|
||||
"SELECT QstInd FROM svy_questions"
|
||||
"SELECT QstInd"
|
||||
" FROM svy_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
|
||||
|
@ -3230,7 +3256,9 @@ static unsigned Svy_GetNextQuestionIndexInSvy (long SvyCod)
|
|||
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
DB_QuerySELECT (&mysql_res,"can not get last question index",
|
||||
"SELECT MAX(QstInd) FROM svy_questions WHERE SvyCod=%ld",
|
||||
"SELECT MAX(QstInd)"
|
||||
" FROM svy_questions"
|
||||
" WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
|
||||
/***** Get number of users *****/
|
||||
|
@ -3274,11 +3302,16 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys,
|
|||
bool PutFormAnswerSurvey = Svy->Status.ICanAnswer && !Editing;
|
||||
|
||||
/***** Get data of questions from database *****/
|
||||
NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||
"SELECT QstCod,QstInd,AnsType,Stem"
|
||||
" FROM svy_questions"
|
||||
" WHERE SvyCod=%ld ORDER BY QstInd",
|
||||
Svy->SvyCod);
|
||||
NumQsts = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||
"SELECT QstCod," // row[0]
|
||||
"QstInd," // row[1]
|
||||
"AnsType," // row[2]
|
||||
"Stem" // row[3]
|
||||
" FROM svy_questions"
|
||||
" WHERE SvyCod=%ld"
|
||||
" ORDER BY QstInd",
|
||||
Svy->SvyCod);
|
||||
|
||||
/***** Begin box *****/
|
||||
Surveys->SvyCod = Svy->SvyCod;
|
||||
|
@ -3789,8 +3822,10 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
|
|||
/***** Get questions of this survey from database *****/
|
||||
NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get questions"
|
||||
" of a survey",
|
||||
"SELECT QstCod FROM svy_questions"
|
||||
" WHERE SvyCod=%ld ORDER BY QstCod",
|
||||
"SELECT QstCod"
|
||||
" FROM svy_questions"
|
||||
" WHERE SvyCod=%ld"
|
||||
" ORDER BY QstCod",
|
||||
SvyCod);
|
||||
if (NumQsts)
|
||||
{
|
||||
|
@ -3868,9 +3903,12 @@ static bool Svy_CheckIfIHaveAnsweredSvy (long SvyCod)
|
|||
{
|
||||
/***** Get number of surveys with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if you have answered a survey",
|
||||
"SELECT COUNT(*) FROM svy_users"
|
||||
" WHERE SvyCod=%ld AND UsrCod=%ld",
|
||||
SvyCod,Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM svy_users"
|
||||
" WHERE SvyCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
SvyCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3883,7 +3921,8 @@ static unsigned Svy_GetNumUsrsWhoHaveAnsweredSvy (long SvyCod)
|
|||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users"
|
||||
" who have answered a survey",
|
||||
"SELECT COUNT(*) FROM svy_users"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM svy_users"
|
||||
" WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
}
|
||||
|
@ -3903,52 +3942,52 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Lvl_Level_t Scope)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with surveys",
|
||||
"SELECT COUNT(DISTINCT Cod)"
|
||||
" FROM svy_surveys"
|
||||
" FROM svy_surveys"
|
||||
" WHERE Scope='%s'",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
case Hie_Lvl_CTY:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with surveys",
|
||||
"SELECT COUNT(DISTINCT svy_surveys.Cod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
case Hie_Lvl_INS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with surveys",
|
||||
"SELECT COUNT(DISTINCT svy_surveys.Cod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
case Hie_Lvl_CTR:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with surveys",
|
||||
"SELECT COUNT(DISTINCT svy_surveys.Cod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
case Hie_Lvl_DEG:
|
||||
|
@ -3966,8 +4005,9 @@ unsigned Svy_GetNumCoursesWithCrsSurveys (Hie_Lvl_Level_t Scope)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with surveys",
|
||||
"SELECT COUNT(DISTINCT Cod)"
|
||||
" FROM svy_surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld",
|
||||
" FROM svy_surveys"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS),
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
|
@ -3994,7 +4034,7 @@ unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumNotif)"
|
||||
" FROM svy_surveys"
|
||||
" FROM svy_surveys"
|
||||
" WHERE Scope='%s'",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
|
@ -4002,17 +4042,17 @@ unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(svy_surveys.NumNotif)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
|
@ -4020,15 +4060,15 @@ unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(svy_surveys.NumNotif)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
|
@ -4036,13 +4076,13 @@ unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(svy_surveys.NumNotif)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
|
@ -4050,11 +4090,11 @@ unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(svy_surveys.NumNotif)"
|
||||
" FROM crs_courses,"
|
||||
"svy_surveys"
|
||||
" FROM crs_courses,"
|
||||
"svy_surveys"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
|
@ -4062,9 +4102,9 @@ unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of surveys",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumNotif)"
|
||||
" FROM svy_surveys"
|
||||
" FROM svy_surveys"
|
||||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND CrsCod=%ld",
|
||||
" AND CrsCod=%ld",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS),
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
|
@ -4109,101 +4149,102 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Lvl_Level_t Scope)
|
|||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM crs_courses,"
|
||||
"svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=svy_surveys.Cod"
|
||||
" AND svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS));
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE svy_surveys.Scope='%s' AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(svy_questions.QstCod) AS NumQsts"
|
||||
" FROM svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS),Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -207,9 +207,9 @@ static void SysCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
|||
"AVG(Longitude)," // row[1]
|
||||
"GREATEST(MAX(Latitude)-MIN(Latitude),"
|
||||
"MAX(Longitude)-MIN(Longitude))" // row[2]
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" WHERE Latitude<>0"
|
||||
" AND Longitude<>0") < 0)
|
||||
" AND Longitude<>0") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
free (Query);
|
||||
|
@ -256,9 +256,9 @@ static void SysCfg_Map (void)
|
|||
NumCtrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get centers with coordinates",
|
||||
"SELECT CtrCod" // row[0]
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" WHERE ctr_centers.Latitude<>0"
|
||||
" AND ctr_centers.Longitude<>0");
|
||||
" AND ctr_centers.Longitude<>0");
|
||||
|
||||
/* Add a marker and a popup for each center */
|
||||
for (NumCtr = 0;
|
||||
|
|
58
swad_tag.c
58
swad_tag.c
|
@ -129,7 +129,8 @@ bool Tag_CheckIfCurrentCrsHasTestTags (void)
|
|||
{
|
||||
/***** Get available tags from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if course has tags",
|
||||
"SELECT COUNT(*) FROM tst_tags"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM tst_tags"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod) != 0);
|
||||
}
|
||||
|
@ -146,7 +147,7 @@ unsigned Tag_GetAllTagsFromCurrentCrs (MYSQL_RES **mysql_res)
|
|||
"SELECT TagCod," // row[0]
|
||||
"TagTxt," // row[1]
|
||||
"TagHidden" // row[2]
|
||||
" FROM tst_tags"
|
||||
" FROM tst_tags"
|
||||
" WHERE CrsCod=%ld"
|
||||
" ORDER BY TagTxt",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
@ -163,8 +164,9 @@ unsigned Tag_GetEnabledTagsFromThisCrs (MYSQL_RES **mysql_res)
|
|||
return (unsigned) DB_QuerySELECT (mysql_res,"can not get available enabled tags",
|
||||
"SELECT TagCod," // row[0]
|
||||
"TagTxt" // row[1]
|
||||
" FROM tst_tags"
|
||||
" WHERE CrsCod=%ld AND TagHidden='N'"
|
||||
" FROM tst_tags"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND TagHidden='N'"
|
||||
" ORDER BY TagTxt",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
}
|
||||
|
@ -290,8 +292,9 @@ void Tag_RenameTag (void)
|
|||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE tst_question_tags_tmp"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT QstCod FROM tst_question_tags"
|
||||
" WHERE TagCod=%ld",
|
||||
" SELECT QstCod"
|
||||
" FROM tst_question_tags"
|
||||
" WHERE TagCod=%ld",
|
||||
ExistingTagCod);
|
||||
|
||||
/* Remove old tag in questions where it would be repeated */
|
||||
|
@ -299,18 +302,20 @@ void Tag_RenameTag (void)
|
|||
DB_QueryDELETE ("can not remove a tag from some questions",
|
||||
"DELETE FROM tst_question_tags"
|
||||
" WHERE TagCod=%ld"
|
||||
" AND QstCod IN"
|
||||
" (SELECT QstCod FROM tst_question_tags_tmp)",
|
||||
" AND QstCod IN"
|
||||
" (SELECT QstCod"
|
||||
" FROM tst_question_tags_tmp)",
|
||||
OldTagCod);
|
||||
|
||||
/* Change old tag to new tag in questions where it would not be repeated */
|
||||
// New tag did not exist for a question ==> change old tag to new tag
|
||||
DB_QueryUPDATE ("can not update a tag in some questions",
|
||||
"UPDATE tst_question_tags"
|
||||
" SET TagCod=%ld"
|
||||
" SET TagCod=%ld"
|
||||
" WHERE TagCod=%ld"
|
||||
" AND QstCod NOT IN"
|
||||
" (SELECT QstCod FROM tst_question_tags_tmp)",
|
||||
" AND QstCod NOT IN"
|
||||
" (SELECT QstCod"
|
||||
" FROM tst_question_tags_tmp)",
|
||||
ExistingTagCod,
|
||||
OldTagCod);
|
||||
|
||||
|
@ -321,17 +326,22 @@ void Tag_RenameTag (void)
|
|||
/***** Delete old tag from tst_tags
|
||||
because it is not longer used *****/
|
||||
DB_QueryDELETE ("can not remove old tag",
|
||||
"DELETE FROM tst_tags WHERE TagCod=%ld",
|
||||
"DELETE FROM tst_tags"
|
||||
" WHERE TagCod=%ld",
|
||||
OldTagCod);
|
||||
}
|
||||
else // Renaming is easy
|
||||
{
|
||||
/***** Simple update replacing each instance of the old tag by the new tag *****/
|
||||
DB_QueryUPDATE ("can not update tag",
|
||||
"UPDATE tst_tags SET TagTxt='%s',ChangeTime=NOW()"
|
||||
"UPDATE tst_tags"
|
||||
" SET TagTxt='%s',"
|
||||
"ChangeTime=NOW()"
|
||||
" WHERE tst_tags.CrsCod=%ld"
|
||||
" AND tst_tags.TagTxt='%s'",
|
||||
NewTagTxt,Gbl.Hierarchy.Crs.CrsCod,OldTagTxt);
|
||||
" AND tst_tags.TagTxt='%s'",
|
||||
NewTagTxt,
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
OldTagTxt);
|
||||
}
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
|
@ -359,8 +369,10 @@ static long Tag_GetTagCodFromTagTxt (const char *TagTxt)
|
|||
|
||||
/***** Get tag code from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get tag",
|
||||
"SELECT TagCod FROM tst_tags"
|
||||
" WHERE CrsCod=%ld AND TagTxt='%s'",
|
||||
"SELECT TagCod"
|
||||
" FROM tst_tags"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND TagTxt='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,TagTxt);
|
||||
if (NumRows == 1)
|
||||
{
|
||||
|
@ -664,11 +676,13 @@ void Tag_RemoveUnusedTagsFromCrs (long CrsCod)
|
|||
/***** Remove unused tags from tst_tags *****/
|
||||
DB_QueryDELETE ("can not remove unused tags",
|
||||
"DELETE FROM tst_tags"
|
||||
" WHERE CrsCod=%ld AND TagCod NOT IN"
|
||||
" (SELECT DISTINCT tst_question_tags.TagCod"
|
||||
" FROM tst_questions,tst_question_tags"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod)",
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND TagCod NOT IN"
|
||||
" (SELECT DISTINCT tst_question_tags.TagCod"
|
||||
" FROM tst_questions,"
|
||||
"tst_question_tags"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod)",
|
||||
CrsCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
|
500
swad_test.c
500
swad_test.c
|
@ -1361,7 +1361,7 @@ bool Tst_CheckIfCourseHaveTestsAndPluggableIsUnknown (void)
|
|||
/***** Get pluggability of tests for current course from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get configuration of test",
|
||||
"SELECT Pluggable" // row[0]
|
||||
" FROM tst_config"
|
||||
" FROM tst_config"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
|
@ -1757,7 +1757,7 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
|||
/***** Select questions *****/
|
||||
/* Start query */
|
||||
Str_Copy (Query,"SELECT tst_questions.QstCod" // row[0]
|
||||
" FROM tst_questions",Tst_MAX_BYTES_QUERY_TEST);
|
||||
" FROM tst_questions",Tst_MAX_BYTES_QUERY_TEST);
|
||||
if (!Test->Tags.All)
|
||||
Str_Concat (Query,",tst_question_tags,tst_tags",Tst_MAX_BYTES_QUERY_TEST);
|
||||
|
||||
|
@ -1908,16 +1908,17 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
"SELECT DISTINCTROW tst_questions.QstCod," // row[0]
|
||||
"tst_questions.AnsType," // row[1]
|
||||
"tst_questions.Shuffle" // row[2]
|
||||
" FROM tst_questions,tst_question_tags,tst_tags"
|
||||
" FROM tst_questions,tst_question_tags,tst_tags"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod NOT IN"
|
||||
" (SELECT tst_question_tags.QstCod"
|
||||
" FROM tst_tags,tst_question_tags"
|
||||
" WHERE tst_tags.CrsCod=%ld AND tst_tags.TagHidden='Y'"
|
||||
" AND tst_tags.TagCod=tst_question_tags.TagCod)"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod"
|
||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||
" AND tst_tags.CrsCod=%ld",
|
||||
" AND tst_questions.QstCod NOT IN"
|
||||
" (SELECT tst_question_tags.QstCod"
|
||||
" FROM tst_tags,tst_question_tags"
|
||||
" WHERE tst_tags.CrsCod=%ld"
|
||||
" AND tst_tags.TagHidden='Y'"
|
||||
" AND tst_tags.TagCod=tst_question_tags.TagCod)"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod"
|
||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||
" AND tst_tags.CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
@ -2671,7 +2672,7 @@ unsigned Tst_GetNumAnswersQst (long QstCod)
|
|||
{
|
||||
return (unsigned) DB_QueryCOUNT ("can not get number of answers of a question",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM tst_answers"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
}
|
||||
|
@ -2687,7 +2688,7 @@ void Tst_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
|
|||
"Feedback," // row[2]
|
||||
"MedCod," // row[3]
|
||||
"Correct" // row[4]
|
||||
" FROM tst_answers"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
|
@ -2912,10 +2913,11 @@ unsigned long Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res)
|
|||
/***** Get the tags of a question from database *****/
|
||||
return DB_QuerySELECT (mysql_res,"can not get the tags of a question",
|
||||
"SELECT tst_tags.TagTxt" // row[0]
|
||||
" FROM tst_question_tags,tst_tags"
|
||||
" FROM tst_question_tags,"
|
||||
"tst_tags"
|
||||
" WHERE tst_question_tags.QstCod=%ld"
|
||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||
" AND tst_tags.CrsCod=%ld"
|
||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||
" AND tst_tags.CrsCod=%ld"
|
||||
" ORDER BY tst_question_tags.TagInd",
|
||||
QstCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
}
|
||||
|
@ -3818,7 +3820,7 @@ Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod)
|
|||
/***** Get type of answer from database *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get the type of a question",
|
||||
"SELECT AnsType" // row[0]
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod))
|
||||
Lay_ShowErrorAndExit ("Question does not exist.");
|
||||
|
@ -3857,9 +3859,9 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
|
|||
"NumHits," // row[6]
|
||||
"NumHitsNotBlank," // row[7]
|
||||
"Score" // row[8]
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
Question->QstCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod) != 0);
|
||||
|
||||
|
@ -4018,15 +4020,17 @@ static long Tst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt)
|
|||
// Get media associated to stem
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get media",
|
||||
"SELECT MedCod" // row[0]
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld AND CrsCod=%ld",
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
QstCod,CrsCod);
|
||||
else
|
||||
// Get media associated to answer
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get media",
|
||||
"SELECT MedCod" // row[0]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND AnsInd=%u",
|
||||
QstCod,(unsigned) NumOpt);
|
||||
|
||||
if (NumRows)
|
||||
|
@ -4533,8 +4537,11 @@ bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question)
|
|||
NumQstsWithThisStem =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res_qst,"can not check"
|
||||
" if a question exists",
|
||||
"SELECT QstCod FROM tst_questions"
|
||||
" WHERE CrsCod=%ld AND AnsType='%s' AND Stem='%s'",
|
||||
"SELECT QstCod"
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND AnsType='%s'"
|
||||
" AND Stem='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Tst_StrAnswerTypesDB[Question->Answer.Type],
|
||||
Question->Stem);
|
||||
|
@ -4556,8 +4563,10 @@ bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question)
|
|||
NumOptsExistingQstInDB =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res_ans,"can not get the answer"
|
||||
" of a question",
|
||||
"SELECT Answer FROM tst_answers"
|
||||
" WHERE QstCod=%ld ORDER BY AnsInd",
|
||||
"SELECT Answer"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY AnsInd",
|
||||
Question->QstCod);
|
||||
|
||||
switch (Question->Answer.Type)
|
||||
|
@ -5214,9 +5223,9 @@ static void Tst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod)
|
|||
NumMedia =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
|
||||
"SELECT MedCod" // row[0]
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
QstCod,CrsCod);
|
||||
|
||||
/***** Go over result removing media *****/
|
||||
|
@ -5239,12 +5248,15 @@ static void Tst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod)
|
|||
NumMedia =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
|
||||
"SELECT tst_answers.MedCod" // row[0]
|
||||
" FROM tst_answers,tst_questions"
|
||||
" FROM tst_answers,"
|
||||
"tst_questions"
|
||||
" WHERE tst_answers.QstCod=%ld"
|
||||
" AND tst_answers.QstCod=tst_questions.QstCod"
|
||||
" AND tst_questions.CrsCod=%ld" // Extra check
|
||||
" AND tst_questions.QstCod=%ld", // Extra check
|
||||
QstCod,CrsCod,QstCod);
|
||||
" AND tst_answers.QstCod=tst_questions.QstCod"
|
||||
" AND tst_questions.CrsCod=%ld" // Extra check
|
||||
" AND tst_questions.QstCod=%ld", // Extra check
|
||||
QstCod,
|
||||
CrsCod,
|
||||
QstCod);
|
||||
|
||||
/***** Go over result removing media *****/
|
||||
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
||||
|
@ -5266,7 +5278,7 @@ static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod)
|
|||
NumMedia =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
|
||||
"SELECT MedCod" // row[0]
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
|
@ -5290,9 +5302,10 @@ static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod)
|
|||
NumMedia =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
|
||||
"SELECT tst_answers.MedCod" // row[0]
|
||||
" FROM tst_questions,tst_answers"
|
||||
" FROM tst_questions,"
|
||||
"tst_answers"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_answers.QstCod",
|
||||
" AND tst_questions.QstCod=tst_answers.QstCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Go over result removing media files *****/
|
||||
|
@ -5351,13 +5364,13 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM tst_questions");
|
||||
" FROM tst_questions");
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of test questions",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE AnsType='%s'",
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
break;
|
||||
|
@ -5367,33 +5380,33 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of test questions",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
break;
|
||||
|
@ -5403,29 +5416,29 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of test questions",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
break;
|
||||
|
@ -5435,25 +5448,25 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of test questions",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
break;
|
||||
|
@ -5463,21 +5476,21 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
else
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of test questions",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
break;
|
||||
|
@ -5487,7 +5500,7 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
else
|
||||
|
@ -5495,8 +5508,9 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
"SELECT COUNT(*),"
|
||||
"SUM(NumHits),"
|
||||
"SUM(Score)"
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld AND AnsType='%s'",
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND AnsType='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
break;
|
||||
|
@ -5548,12 +5562,12 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_Ans
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM tst_questions");
|
||||
" FROM tst_questions");
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE AnsType='%s'",
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
case Hie_Lvl_CTY:
|
||||
|
@ -5561,32 +5575,32 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_Ans
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
case Hie_Lvl_INS:
|
||||
|
@ -5594,28 +5608,28 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_Ans
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
case Hie_Lvl_CTR:
|
||||
|
@ -5623,24 +5637,24 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_Ans
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
case Hie_Lvl_DEG:
|
||||
|
@ -5648,20 +5662,20 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_Ans
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNTDISTINCT (tst_questions.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
case Hie_Lvl_CRS:
|
||||
|
@ -5669,16 +5683,16 @@ static unsigned Tst_GetNumCoursesWithTstQuestions (Hie_Lvl_Level_t Scope,Tst_Ans
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with test questions",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM tst_questions"
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND AnsType='%s'",
|
||||
" AND AnsType='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
default:
|
||||
|
@ -5704,20 +5718,20 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scop
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND tst_config.pluggable='%s'",
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Tst_StrAnswerTypesDB[AnsType],
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
case Hie_Lvl_CTY:
|
||||
|
@ -5725,39 +5739,39 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scop
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
Tst_StrAnswerTypesDB[AnsType],
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
@ -5766,35 +5780,35 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scop
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
Tst_StrAnswerTypesDB[AnsType],
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
@ -5803,31 +5817,31 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scop
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
Tst_StrAnswerTypesDB[AnsType],
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
@ -5836,27 +5850,27 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scop
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
Tst_StrAnswerTypesDB[AnsType],
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
@ -5865,23 +5879,23 @@ static unsigned Tst_GetNumCoursesWithPluggableTstQuestions (Hie_Lvl_Level_t Scop
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||
"SELECT COUNT(DISTINCT tst_questions.CrsCod)"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" FROM tst_questions,"
|
||||
"tst_config"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
" AND tst_questions.AnsType='%s'"
|
||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||
" AND tst_config.pluggable='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Tst_StrAnswerTypesDB[AnsType],
|
||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
||||
|
|
|
@ -99,7 +99,7 @@ void TstCfg_GetConfigFromDB (void)
|
|||
"Max," // row[3]
|
||||
"MinTimeNxtTstPerQst," // row[4]
|
||||
"Visibility" // row[5]
|
||||
" FROM tst_config"
|
||||
" FROM tst_config"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
|
|
|
@ -875,7 +875,7 @@ static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question)
|
|||
Question->Answer.NumOptions =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||
"SELECT Answer" // row[0]
|
||||
" FROM tst_answers"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -902,7 +902,7 @@ static void TstPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question)
|
|||
Question->Answer.NumOptions =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||
"SELECT Answer" // row[0]
|
||||
" FROM tst_answers"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -940,7 +940,7 @@ static void TstPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question)
|
|||
Question->Answer.NumOptions =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||
"SELECT Answer" // row[0]
|
||||
" FROM tst_answers"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -965,7 +965,7 @@ static void TstPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question)
|
|||
Question->Answer.NumOptions =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||
"SELECT Correct" // row[0]
|
||||
" FROM tst_answers"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY AnsInd",
|
||||
Question->QstCod);
|
||||
|
@ -994,7 +994,7 @@ static void TstPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question)
|
|||
Question->Answer.NumOptions =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||
"SELECT Answer" // row[0]
|
||||
" FROM tst_answers"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -2070,10 +2070,11 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat)
|
|||
NumPrints =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get test exams of a user",
|
||||
"SELECT ExaCod" // row[0]
|
||||
" FROM tst_exams"
|
||||
" WHERE CrsCod=%ld AND UsrCod=%ld"
|
||||
" AND EndTime>=FROM_UNIXTIME(%ld)"
|
||||
" AND StartTime<=FROM_UNIXTIME(%ld)"
|
||||
" FROM tst_exams"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld"
|
||||
" AND EndTime>=FROM_UNIXTIME(%ld)"
|
||||
" AND StartTime<=FROM_UNIXTIME(%ld)"
|
||||
" ORDER BY ExaCod",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
UsrDat->UsrCod,
|
||||
|
@ -2624,12 +2625,12 @@ static void TstPrn_ShowTagsPresentInAPrint (long ResCod)
|
|||
DB_QuerySELECT (&mysql_res,"can not get tags"
|
||||
" present in a test exam",
|
||||
"SELECT tst_tags.TagTxt" // row[0]
|
||||
" FROM"
|
||||
" (SELECT DISTINCT(tst_question_tags.TagCod)"
|
||||
" FROM tst_question_tags,tst_exam_questions"
|
||||
" WHERE tst_exam_questions.ExaCod=%ld"
|
||||
" AND tst_exam_questions.QstCod=tst_question_tags.QstCod)"
|
||||
" AS TagsCods,tst_tags"
|
||||
" FROM (SELECT DISTINCT(tst_question_tags.TagCod)"
|
||||
" FROM tst_question_tags,"
|
||||
"tst_exam_questions"
|
||||
" WHERE tst_exam_questions.ExaCod=%ld"
|
||||
" AND tst_exam_questions.QstCod=tst_question_tags.QstCod) AS TagsCods,"
|
||||
"tst_tags"
|
||||
" WHERE TagsCods.TagCod=tst_tags.TagCod"
|
||||
" ORDER BY tst_tags.TagTxt",
|
||||
ResCod);
|
||||
|
@ -2697,8 +2698,9 @@ void TstPrn_GetPrintDataByPrnCod (struct TstPrn_Print *Print)
|
|||
"Sent," // row[5]
|
||||
"AllowTeachers," // row[6]
|
||||
"Score" // row[7]
|
||||
" FROM tst_exams"
|
||||
" WHERE ExaCod=%ld AND CrsCod=%ld",
|
||||
" FROM tst_exams"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
Print->PrnCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod) == 1)
|
||||
{
|
||||
|
@ -2757,7 +2759,7 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
|
|||
"Score," // row[1]
|
||||
"Indexes," // row[2]
|
||||
"Answers" // row[3]
|
||||
" FROM tst_exam_questions"
|
||||
" FROM tst_exam_questions"
|
||||
" WHERE ExaCod=%ld"
|
||||
" ORDER BY QstInd",
|
||||
Print->PrnCod);
|
||||
|
|
|
@ -86,7 +86,8 @@ unsigned Tml_DB_GetWho (MYSQL_RES **mysql_res)
|
|||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get which timeline users",
|
||||
"SELECT TimelineUsrs" // row[0]
|
||||
" FROM usr_last WHERE UsrCod=%ld",
|
||||
" FROM usr_last"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
|
@ -98,7 +99,8 @@ void Tml_DB_UpdateWho (Usr_Who_t Who)
|
|||
{
|
||||
/***** Update which users in database *****/
|
||||
DB_QueryUPDATE ("can not update which timeline users",
|
||||
"UPDATE usr_last SET TimelineUsrs=%u"
|
||||
"UPDATE usr_last"
|
||||
" SET TimelineUsrs=%u"
|
||||
" WHERE UsrCod=%ld",
|
||||
(unsigned) Who,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
@ -125,7 +127,7 @@ unsigned Tml_DB_GetDataOfNoteByCod (long NotCod,MYSQL_RES **mysql_res)
|
|||
"HieCod," // row[4]
|
||||
"Unavailable," // row[5]
|
||||
"UNIX_TIMESTAMP(TimeNote)" // row[6]
|
||||
" FROM tml_notes"
|
||||
" FROM tml_notes"
|
||||
" WHERE NotCod=%ld",
|
||||
NotCod);
|
||||
}
|
||||
|
@ -142,9 +144,12 @@ long Tml_DB_GetPubCodOfOriginalNote (long NotCod)
|
|||
|
||||
/***** Get code of publication of the original note *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get code of publication",
|
||||
"SELECT PubCod FROM tml_pubs"
|
||||
" WHERE NotCod=%ld AND PubType=%u",
|
||||
NotCod,(unsigned) Tml_Pub_ORIGINAL_NOTE) == 1)
|
||||
"SELECT PubCod"
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PubType=%u",
|
||||
NotCod,
|
||||
(unsigned) Tml_Pub_ORIGINAL_NOTE) == 1)
|
||||
{ // Result should have a unique row
|
||||
/* Get code of publication (row[0]) */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -235,7 +240,9 @@ void Tml_DB_CreateTmpTableVisibleTimeline (void)
|
|||
"CREATE TEMPORARY TABLE tml_tmp_visible_timeline "
|
||||
"(NotCod BIGINT NOT NULL,UNIQUE INDEX(NotCod))"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT NotCod FROM tml_timelines WHERE SessionId='%s'",
|
||||
" SELECT NotCod"
|
||||
" FROM tml_timelines"
|
||||
" WHERE SessionId='%s'",
|
||||
Gbl.Session.Id);
|
||||
}
|
||||
|
||||
|
@ -290,7 +297,9 @@ mysql> SELECT SessionId,COUNT(*) FROM tml_timelines GROUP BY SessionId;
|
|||
DB_QueryINSERT ("can not insert notes in timeline",
|
||||
"INSERT IGNORE INTO tml_timelines"
|
||||
" (SessionId,NotCod)"
|
||||
" SELECT '%s',NotCod FROM tml_tmp_just_retrieved_notes",
|
||||
" SELECT '%s',"
|
||||
"NotCod"
|
||||
" FROM tml_tmp_just_retrieved_notes",
|
||||
Gbl.Session.Id);
|
||||
}
|
||||
|
||||
|
@ -409,7 +418,7 @@ unsigned Tml_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res)
|
|||
" of a post",
|
||||
"SELECT Txt," // row[0]
|
||||
"MedCod" // row[1]
|
||||
" FROM tml_posts"
|
||||
" FROM tml_posts"
|
||||
" WHERE PstCod=%ld",
|
||||
PstCod);
|
||||
}
|
||||
|
@ -464,8 +473,10 @@ void Tml_DB_RemoveAllPostsUsr (long UsrCod)
|
|||
DB_QueryDELETE ("can not remove posts",
|
||||
"DELETE FROM tml_posts"
|
||||
" WHERE PstCod IN"
|
||||
" (SELECT Cod FROM tml_notes"
|
||||
" WHERE UsrCod=%ld AND NoteType=%u)",
|
||||
" (SELECT Cod"
|
||||
" FROM tml_notes"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND NoteType=%u)",
|
||||
UsrCod,(unsigned) TL_NOTE_POST);
|
||||
}
|
||||
|
||||
|
@ -477,8 +488,10 @@ unsigned Tml_DB_GetNumCommsInNote (long NotCod)
|
|||
{
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of comments in a note",
|
||||
"SELECT COUNT(*) FROM tml_pubs"
|
||||
" WHERE NotCod=%ld AND PubType=%u",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PubType=%u",
|
||||
NotCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
}
|
||||
|
||||
|
@ -492,8 +505,9 @@ unsigned Tml_DB_GetComms (long NotCod,MYSQL_RES **mysql_res)
|
|||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get comments",
|
||||
"SELECT PubCod" // row[0]
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod=%ld AND PubType=%u",
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PubType=%u",
|
||||
NotCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
}
|
||||
|
||||
|
@ -513,10 +527,10 @@ unsigned Tml_DB_GetInitialComms (long NotCod,unsigned NumInitialCommsToGet,
|
|||
"UNIX_TIMESTAMP(tml_pubs.TimePublish)," // row[3]
|
||||
"tml_comments.Txt," // row[4]
|
||||
"tml_comments.MedCod" // row[5]
|
||||
" FROM tml_pubs,tml_comments"
|
||||
" FROM tml_pubs,tml_comments"
|
||||
" WHERE tml_pubs.NotCod=%ld"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod"
|
||||
" ORDER BY tml_pubs.PubCod"
|
||||
" LIMIT %lu",
|
||||
NotCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE,
|
||||
|
@ -534,20 +548,19 @@ unsigned Tml_DB_GetFinalComms (long NotCod,unsigned NumFinalCommsToGet,
|
|||
/***** Get final comments of a note from database *****/
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get comments",
|
||||
"SELECT * FROM "
|
||||
"("
|
||||
"SELECT tml_pubs.PubCod," // row[0]
|
||||
"tml_pubs.PublisherCod," // row[1]
|
||||
"tml_pubs.NotCod," // row[2]
|
||||
"UNIX_TIMESTAMP(tml_pubs.TimePublish)," // row[3]
|
||||
"tml_comments.Txt," // row[4]
|
||||
"tml_comments.MedCod" // row[5]
|
||||
" FROM tml_pubs,tml_comments"
|
||||
" WHERE tml_pubs.NotCod=%ld"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod"
|
||||
" ORDER BY tml_pubs.PubCod DESC LIMIT %u"
|
||||
") AS comments"
|
||||
"SELECT *"
|
||||
" FROM (SELECT tml_pubs.PubCod," // row[0]
|
||||
"tml_pubs.PublisherCod," // row[1]
|
||||
"tml_pubs.NotCod," // row[2]
|
||||
"UNIX_TIMESTAMP(tml_pubs.TimePublish)," // row[3]
|
||||
"tml_comments.Txt," // row[4]
|
||||
"tml_comments.MedCod" // row[5]
|
||||
" FROM tml_pubs,tml_comments"
|
||||
" WHERE tml_pubs.NotCod=%ld"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod"
|
||||
" ORDER BY tml_pubs.PubCod DESC"
|
||||
" LIMIT %u) AS comments"
|
||||
" ORDER BY PubCod",
|
||||
NotCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE,
|
||||
NumFinalCommsToGet);
|
||||
|
@ -573,10 +586,10 @@ unsigned Tml_DB_GetDataOfCommByCod (long PubCod,MYSQL_RES **mysql_res)
|
|||
"UNIX_TIMESTAMP(tml_pubs.TimePublish)," // row[3]
|
||||
"tml_comments.Txt," // row[4]
|
||||
"tml_comments.MedCod" // row[5]
|
||||
" FROM tml_pubs,tml_comments"
|
||||
" FROM tml_pubs,tml_comments"
|
||||
" WHERE tml_pubs.PubCod=%ld"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod",
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod",
|
||||
PubCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
}
|
||||
|
||||
|
@ -769,7 +782,9 @@ void Tml_DB_CreateSubQueryAlreadyExists (const struct Tml_Timeline *Timeline,
|
|||
};
|
||||
|
||||
snprintf (SubQueries->AlreadyExists,sizeof (SubQueries->AlreadyExists),
|
||||
" tml_pubs.NotCod NOT IN (SELECT NotCod FROM %s)",
|
||||
" tml_pubs.NotCod NOT IN"
|
||||
" (SELECT NotCod"
|
||||
" FROM %s)",
|
||||
Table[Timeline->WhatToGet]);
|
||||
}
|
||||
|
||||
|
@ -807,9 +822,10 @@ unsigned Tml_DB_SelectTheMostRecentPub (const struct Tml_Pub_SubQueries *SubQuer
|
|||
"tml_pubs.NotCod," // row[1]
|
||||
"tml_pubs.PublisherCod," // row[2]
|
||||
"tml_pubs.PubType" // row[3]
|
||||
" FROM tml_pubs%s"
|
||||
" FROM tml_pubs%s"
|
||||
" WHERE %s%s%s%s"
|
||||
" ORDER BY tml_pubs.PubCod DESC LIMIT 1",
|
||||
" ORDER BY tml_pubs.PubCod"
|
||||
" DESC LIMIT 1",
|
||||
SubQueries->TablePublishers,
|
||||
SubQueries->RangeBottom,
|
||||
SubQueries->RangeTop,
|
||||
|
@ -835,7 +851,8 @@ unsigned Tml_DB_GetDataOfPubByCod (long PubCod,MYSQL_RES **mysql_res)
|
|||
"NotCod," // row[1]
|
||||
"PublisherCod," // row[2]
|
||||
"PubType" // row[3]
|
||||
" FROM tml_pubs WHERE PubCod=%ld",
|
||||
" FROM tml_pubs"
|
||||
" WHERE PubCod=%ld",
|
||||
PubCod);
|
||||
}
|
||||
|
||||
|
@ -851,7 +868,8 @@ long Tml_DB_GetNotCodFromPubCod (long PubCod)
|
|||
|
||||
/***** Get code of note from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get code of note",
|
||||
"SELECT NotCod FROM tml_pubs"
|
||||
"SELECT NotCod"
|
||||
" FROM tml_pubs"
|
||||
" WHERE PubCod=%ld",
|
||||
PubCod) == 1) // Result should have a unique row
|
||||
{
|
||||
|
@ -908,7 +926,8 @@ unsigned long Tml_DB_GetNumPubsUsr (long UsrCod)
|
|||
{
|
||||
/***** Get number of posts from a user from database *****/
|
||||
return DB_QueryCOUNT ("can not get number of publications from a user",
|
||||
"SELECT COUNT(*) FROM tml_pubs"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM tml_pubs"
|
||||
" WHERE PublisherCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
@ -956,7 +975,7 @@ void Tml_DB_UpdateLastPubCodInSession (void)
|
|||
"UPDATE ses_sessions"
|
||||
" SET LastPubCod="
|
||||
"(SELECT IFNULL(MAX(PubCod),0)"
|
||||
" FROM tml_pubs)" // The most recent publication
|
||||
" FROM tml_pubs)" // The most recent publication
|
||||
" WHERE SessionId='%s'",
|
||||
Gbl.Session.Id);
|
||||
}
|
||||
|
@ -972,7 +991,7 @@ void Tml_DB_UpdateFirstLastPubCodsInSession (long FirstPubCod)
|
|||
" SET FirstPubCod=%ld,"
|
||||
"LastPubCod="
|
||||
"(SELECT IFNULL(MAX(PubCod),0)"
|
||||
" FROM tml_pubs)" // The most recent publication
|
||||
" FROM tml_pubs)" // The most recent publication
|
||||
" WHERE SessionId='%s'",
|
||||
FirstPubCod,
|
||||
Gbl.Session.Id);
|
||||
|
@ -1016,8 +1035,10 @@ bool Tml_DB_CheckIfFavedByUsr (Tml_Usr_FavSha_t FavSha,long Cod,long UsrCod)
|
|||
{
|
||||
/***** Check if a user has favourited a note/comment from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if a user has favourited",
|
||||
"SELECT COUNT(*) FROM %s"
|
||||
" WHERE %s=%ld AND UsrCod=%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM %s"
|
||||
" WHERE %s=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Tml_DB_TableFav[FavSha],
|
||||
Tml_DB_FieldFav[FavSha],Cod,UsrCod) != 0);
|
||||
}
|
||||
|
@ -1031,9 +1052,10 @@ unsigned Tml_DB_GetNumFavers (Tml_Usr_FavSha_t FavSha,long Cod,long UsrCod)
|
|||
/***** Get number of times (users) a note/comment has been favourited *****/
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of times has been favourited",
|
||||
"SELECT COUNT(*) FROM %s"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM %s"
|
||||
" WHERE %s=%ld"
|
||||
" AND UsrCod<>%ld", // Extra check
|
||||
" AND UsrCod<>%ld", // Extra check
|
||||
Tml_DB_TableFav[FavSha],
|
||||
Tml_DB_FieldFav[FavSha],Cod,
|
||||
UsrCod); // The author
|
||||
|
@ -1051,10 +1073,11 @@ unsigned Tml_DB_GetFavers (Tml_Usr_FavSha_t FavSha,
|
|||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get favers",
|
||||
"SELECT UsrCod" // row[0]
|
||||
" FROM %s"
|
||||
" FROM %s"
|
||||
" WHERE %s=%ld"
|
||||
" AND UsrCod<>%ld" // Extra check
|
||||
" ORDER BY FavCod LIMIT %u",
|
||||
" AND UsrCod<>%ld" // Extra check
|
||||
" ORDER BY FavCod"
|
||||
" LIMIT %u",
|
||||
Tml_DB_TableFav[FavSha],
|
||||
Tml_DB_FieldFav[FavSha],Cod,
|
||||
UsrCod,
|
||||
|
@ -1149,10 +1172,11 @@ void Tml_DB_RemoveAllFavsToAllCommsInAllNotesBy (long UsrCod)
|
|||
bool Tml_DB_CheckIfSharedByUsr (long NotCod,long UsrCod)
|
||||
{
|
||||
return (DB_QueryCOUNT ("can not check if a user has shared a note",
|
||||
"SELECT COUNT(*) FROM tml_pubs"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PublisherCod=%ld"
|
||||
" AND PubType=%u",
|
||||
" AND PublisherCod=%ld"
|
||||
" AND PubType=%u",
|
||||
NotCod,
|
||||
UsrCod,
|
||||
(unsigned) Tml_Pub_SHARED_NOTE) != 0);
|
||||
|
@ -1167,10 +1191,11 @@ unsigned Tml_DB_GetNumSharers (long NotCod,long UsrCod)
|
|||
/***** Get number of times (users) this note has been shared *****/
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of times a note has been shared",
|
||||
"SELECT COUNT(*) FROM tml_pubs"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PublisherCod<>%ld"
|
||||
" AND PubType=%u",
|
||||
" AND PublisherCod<>%ld"
|
||||
" AND PubType=%u",
|
||||
NotCod,
|
||||
UsrCod, // Author of the note
|
||||
(unsigned) Tml_Pub_SHARED_NOTE);
|
||||
|
@ -1187,11 +1212,12 @@ unsigned Tml_DB_GetSharers (long NotCod,long UsrCod,unsigned MaxUsrs,
|
|||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get users",
|
||||
"SELECT PublisherCod" // row[0]
|
||||
" FROM tml_pubs"
|
||||
" FROM tml_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PublisherCod<>%ld"
|
||||
" AND PubType=%u"
|
||||
" ORDER BY PubCod LIMIT %u",
|
||||
" AND PublisherCod<>%ld"
|
||||
" AND PubType=%u"
|
||||
" ORDER BY PubCod"
|
||||
" LIMIT %u",
|
||||
NotCod,
|
||||
UsrCod,
|
||||
(unsigned) Tml_Pub_SHARED_NOTE,
|
||||
|
|
283
swad_user.c
283
swad_user.c
|
@ -463,7 +463,8 @@ void Usr_GetUsrCodFromEncryptedUsrCod (struct UsrData *UsrDat)
|
|||
{
|
||||
/***** Get user's code from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get user's code",
|
||||
"SELECT UsrCod FROM usr_data"
|
||||
"SELECT UsrCod"
|
||||
" FROM usr_data"
|
||||
" WHERE EncryptedUsrCod='%s'",
|
||||
UsrDat->EnUsrCod);
|
||||
if (NumRows != 1)
|
||||
|
@ -528,8 +529,8 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat,Usr_GetPrefs_t GetPrefs)
|
|||
"NotifNtfEvents," // row[21]
|
||||
"EmailNtfEvents" // row[22]
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrDat->UsrCod);
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrDat->UsrCod);
|
||||
break;
|
||||
case Usr_GET_PREFS:
|
||||
default:
|
||||
|
@ -570,8 +571,8 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat,Usr_GetPrefs_t GetPrefs)
|
|||
"SideCols," // row[29]
|
||||
"ThirdPartyCookies" // row[30]
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrDat->UsrCod);
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrDat->UsrCod);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -755,7 +756,8 @@ static void Usr_GetMyLastData (void)
|
|||
"LastRole," // row[4]
|
||||
"UNIX_TIMESTAMP(LastTime)," // row[5]
|
||||
"UNIX_TIMESTAMP(LastAccNotif)" // row[6]
|
||||
" FROM usr_last WHERE UsrCod=%ld",
|
||||
" FROM usr_last"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
if (NumRows == 0)
|
||||
{
|
||||
|
@ -906,9 +908,14 @@ bool Usr_CheckIfUsrIsAdm (long UsrCod,Hie_Lvl_Level_t Scope,long Cod)
|
|||
{
|
||||
/***** Get if a user is administrator of a degree from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if a user is administrator",
|
||||
"SELECT COUNT(*) FROM usr_admins"
|
||||
" WHERE UsrCod=%ld AND Scope='%s' AND Cod=%ld",
|
||||
UsrCod,Sco_GetDBStrFromScope (Scope),Cod) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_admins"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
UsrCod,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -935,9 +942,12 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
|
|||
Gbl.Cache.UsrIsSuperuser.UsrCod = UsrCod;
|
||||
Gbl.Cache.UsrIsSuperuser.IsSuperuser =
|
||||
(DB_QueryCOUNT ("can not check if a user is superuser",
|
||||
"SELECT COUNT(*) FROM usr_admins"
|
||||
" WHERE UsrCod=%ld AND Scope='%s'",
|
||||
UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_SYS)) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_admins"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s'",
|
||||
UsrCod,
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_SYS)) != 0);
|
||||
return Gbl.Cache.UsrIsSuperuser.IsSuperuser;
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1073,8 @@ unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role)
|
|||
" FROM crs_users"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Role=%u",
|
||||
UsrCod,(unsigned) Role);
|
||||
UsrCod,
|
||||
(unsigned) Role);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1080,7 +1091,8 @@ unsigned Usr_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role)
|
|||
" WHERE UsrCod=%ld"
|
||||
" AND Role=%u"
|
||||
" AND Accepted='N'",
|
||||
UsrCod,(unsigned) Role);
|
||||
UsrCod,
|
||||
(unsigned) Role);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1131,7 +1143,7 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
|||
" SELECT CrsCod"
|
||||
" FROM crs_users"
|
||||
" WHERE UsrCod=%ld"
|
||||
"%s",
|
||||
"%s",
|
||||
UsrCod,SubQueryRole);
|
||||
|
||||
/***** Get the number of students/teachers in a course from database ******/
|
||||
|
@ -1149,7 +1161,8 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
|||
NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(DISTINCT crs_users.UsrCod)"
|
||||
" FROM crs_users,usr_courses_tmp"
|
||||
" FROM crs_users,"
|
||||
"usr_courses_tmp"
|
||||
" WHERE crs_users.CrsCod=usr_courses_tmp.CrsCod"
|
||||
" AND crs_users.Role IN (%s)",
|
||||
OthersRolesStr);
|
||||
|
@ -1753,7 +1766,9 @@ void Usr_GetMyCourses (void)
|
|||
NumCrss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get which courses"
|
||||
" you belong to",
|
||||
"SELECT CrsCod,Role,DegCod"
|
||||
"SELECT CrsCod,"
|
||||
"Role,"
|
||||
"DegCod"
|
||||
" FROM my_courses_tmp");
|
||||
for (NumCrs = 0;
|
||||
NumCrs < NumCrss;
|
||||
|
@ -2470,7 +2485,8 @@ bool Usr_ChkIfEncryptedUsrCodExists (const char EncryptedUsrCod[Cry_BYTES_ENCRYP
|
|||
/***** Get if an encrypted user's code already existed in database *****/
|
||||
return (DB_QueryCOUNT ("can not check if an encrypted user's code"
|
||||
" already existed",
|
||||
"SELECT COUNT(*) FROM usr_data"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_data"
|
||||
" WHERE EncryptedUsrCod='%s'",
|
||||
EncryptedUsrCod) != 0);
|
||||
}
|
||||
|
@ -3536,13 +3552,19 @@ void Usr_UpdateMyLastData (void)
|
|||
{
|
||||
/***** Check if it exists an entry for me *****/
|
||||
if (DB_QueryCOUNT ("can not get last user's click",
|
||||
"SELECT COUNT(*) FROM usr_last WHERE UsrCod=%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_last"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||
/***** Update my last accessed course, tab and time of click in database *****/
|
||||
// WhatToSearch, LastAccNotif remain unchanged
|
||||
DB_QueryUPDATE ("can not update last user's data",
|
||||
"UPDATE usr_last"
|
||||
" SET LastSco='%s',LastCod=%ld,LastAct=%ld,LastRole=%u,LastTime=NOW()"
|
||||
" SET LastSco='%s',"
|
||||
"LastCod=%ld,"
|
||||
"LastAct=%ld,"
|
||||
"LastRole=%u,"
|
||||
"LastTime=NOW()"
|
||||
" WHERE UsrCod=%ld",
|
||||
Sco_GetDBStrFromScope (Gbl.Hierarchy.Level),
|
||||
Gbl.Hierarchy.Cod,
|
||||
|
@ -4167,7 +4189,8 @@ unsigned Usr_GetNumUsrsWhoDontClaimToBelongToAnyCty (void)
|
|||
from database *****/
|
||||
Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
"SELECT COUNT(UsrCod)"
|
||||
" FROM usr_data"
|
||||
" WHERE CtyCod<0");
|
||||
Gbl.Cache.NumUsrsWhoDontClaimToBelongToAnyCty.Valid = true;
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,-1L,
|
||||
|
@ -4207,7 +4230,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToAnotherCty (void)
|
|||
from database *****/
|
||||
Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
"SELECT COUNT(UsrCod)"
|
||||
" FROM usr_data"
|
||||
" WHERE CtyCod=0");
|
||||
Gbl.Cache.NumUsrsWhoClaimToBelongToAnotherCty.Valid = true;
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTY,Hie_Lvl_CTY,0,
|
||||
|
@ -4262,7 +4286,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Cty_Countr *Cty)
|
|||
Gbl.Cache.NumUsrsWhoClaimToBelongToCty.NumUsrs =
|
||||
Cty->NumUsrsWhoClaimToBelongToCty.NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
"SELECT COUNT(UsrCod)"
|
||||
" FROM usr_data"
|
||||
" WHERE CtyCod=%ld",
|
||||
Cty->CtyCod);
|
||||
Cty->NumUsrsWhoClaimToBelongToCty.Valid = true;
|
||||
|
@ -4318,7 +4343,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins)
|
|||
Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs =
|
||||
Ins->NumUsrsWhoClaimToBelongToIns.NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
"SELECT COUNT(UsrCod)"
|
||||
" FROM usr_data"
|
||||
" WHERE InsCod=%ld",
|
||||
Ins->InsCod);
|
||||
Ins->NumUsrsWhoClaimToBelongToIns.Valid = true;
|
||||
|
@ -4374,7 +4400,8 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Ctr_Center *Ctr)
|
|||
Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs =
|
||||
Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(UsrCod) FROM usr_data"
|
||||
"SELECT COUNT(UsrCod)"
|
||||
" FROM usr_data"
|
||||
" WHERE CtrCod=%ld",
|
||||
Ctr->CtrCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_USRS_BELONG_CTR,Hie_Lvl_CTR,Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.CtrCod,
|
||||
|
@ -5089,7 +5116,9 @@ void Usr_CreateTmpTableAndSearchCandidateUsrs (const char SearchQuery[Sch_MAX_BY
|
|||
*/
|
||||
sprintf (Query,"CREATE TEMPORARY TABLE candidate_users"
|
||||
" (UsrCod INT NOT NULL,UNIQUE INDEX(UsrCod)) ENGINE=MEMORY"
|
||||
" SELECT UsrCod FROM usr_data WHERE %s",
|
||||
" SELECT UsrCod"
|
||||
" FROM usr_data"
|
||||
" WHERE %s",
|
||||
SearchQuery);
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not create temporary table");
|
||||
|
@ -5151,10 +5180,10 @@ static void Usr_GetAdmsLst (Hie_Lvl_Level_t Scope)
|
|||
case Hie_Lvl_SYS: // All admins
|
||||
DB_BuildQuery (&Query,
|
||||
"SELECT %s"
|
||||
" FROM usr_data"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod IN "
|
||||
"(SELECT DISTINCT UsrCod"
|
||||
" FROM usr_admins)"
|
||||
"(SELECT DISTINCT UsrCod"
|
||||
" FROM usr_admins)"
|
||||
" ORDER BY Surname1,"
|
||||
"Surname2,"
|
||||
"FirstName,"
|
||||
|
@ -5165,37 +5194,38 @@ static void Usr_GetAdmsLst (Hie_Lvl_Level_t Scope)
|
|||
// and admins of the institutions, centers and degrees in the current country
|
||||
DB_BuildQuery (&Query,
|
||||
"SELECT %s"
|
||||
" FROM usr_data"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod IN "
|
||||
"(SELECT UsrCod FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"ctr_centers,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=%ld)"
|
||||
" FROM usr_admins,"
|
||||
"ctr_centers,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" AND ins_instits.CtyCod=%ld)"
|
||||
" ORDER BY Surname1,"
|
||||
"Surname2,"
|
||||
"FirstName,"
|
||||
|
@ -5211,31 +5241,32 @@ static void Usr_GetAdmsLst (Hie_Lvl_Level_t Scope)
|
|||
// and admins of the centers and degrees in the current institution
|
||||
DB_BuildQuery (&Query,
|
||||
"SELECT %s"
|
||||
" FROM usr_data"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s' AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"ctr_centers"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=%ld)"
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"ctr_centers"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"deg_degrees,"
|
||||
"ctr_centers"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND ctr_centers.InsCod=%ld)"
|
||||
" ORDER BY Surname1,"
|
||||
"Surname2,"
|
||||
"FirstName,"
|
||||
|
@ -5252,26 +5283,28 @@ static void Usr_GetAdmsLst (Hie_Lvl_Level_t Scope)
|
|||
// and admins of the degrees in the current center
|
||||
DB_BuildQuery (&Query,
|
||||
"SELECT %s"
|
||||
" FROM usr_data"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s' AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s' AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"deg_degrees"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=%ld)"
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT usr_admins.UsrCod"
|
||||
" FROM usr_admins,"
|
||||
"deg_degrees"
|
||||
" WHERE usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod"
|
||||
" AND deg_degrees.CtrCod=%ld)"
|
||||
" ORDER BY Surname1,"
|
||||
"Surname2,"
|
||||
"FirstName,"
|
||||
|
@ -5286,23 +5319,26 @@ static void Usr_GetAdmsLst (Hie_Lvl_Level_t Scope)
|
|||
// and admins of the current institution, center or degree
|
||||
DB_BuildQuery (&Query,
|
||||
"SELECT %s"
|
||||
" FROM usr_data"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s' AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s' AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s' AND Cod=%ld)"
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s')"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld)"
|
||||
" OR UsrCod IN "
|
||||
"(SELECT UsrCod"
|
||||
" FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld)"
|
||||
" ORDER BY Surname1,"
|
||||
"Surname2,"
|
||||
"FirstName,"
|
||||
|
@ -5375,7 +5411,9 @@ static void Usr_GetGstsLst (Hie_Lvl_Level_t Scope)
|
|||
DB_BuildQuery (&Query,
|
||||
"SELECT %s"
|
||||
" FROM usr_data"
|
||||
" WHERE (CtyCod=%ld OR InsCtyCod=%ld)"
|
||||
" WHERE (CtyCod=%ld"
|
||||
" OR"
|
||||
" InsCtyCod=%ld)"
|
||||
" AND UsrCod NOT IN"
|
||||
" (SELECT UsrCod"
|
||||
" FROM crs_users)"
|
||||
|
@ -9313,7 +9351,8 @@ bool Usr_ChkIfUsrCodExists (long UsrCod)
|
|||
|
||||
/***** Get if a user exists in database *****/
|
||||
return (DB_QueryCOUNT ("can not check if a user exists",
|
||||
"SELECT COUNT(*) FROM usr_data"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod) != 0);
|
||||
}
|
||||
|
@ -9361,7 +9400,8 @@ unsigned Usr_GetTotalNumberOfUsersInPlatform (void)
|
|||
/***** Get number of users from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of users",
|
||||
"SELECT COUNT(UsrCod) FROM usr_data");
|
||||
"SELECT COUNT(UsrCod)"
|
||||
" FROM usr_data");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -10060,7 +10100,8 @@ double Usr_GetCachedNumUsrsPerCrs (Hie_Lvl_Level_t Scope,long Cod,Rol_Role_t Rol
|
|||
bool Usr_CheckIfUsrBanned (long UsrCod)
|
||||
{
|
||||
return (DB_QueryCOUNT ("can not check if user is banned",
|
||||
"SELECT COUNT(*) FROM usr_banned"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_banned"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod) != 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue