mirror of https://github.com/acanas/swad-core.git
Version 20.52: Mar 28, 2021 Code refactoring in database selects.
This commit is contained in:
parent
bad9767bd1
commit
9af1bbaa51
366
swad_API.c
366
swad_API.c
|
@ -497,7 +497,8 @@ static int API_CheckCourseAndGroupCodes (struct soap *soap,
|
|||
|
||||
/***** Query if course code already exists in database *****/
|
||||
if (DB_QueryCOUNT ("can not get course",
|
||||
"SELECT COUNT(*) FROM crs_courses"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod) != 1)
|
||||
return soap_sender_fault (soap,
|
||||
|
@ -598,7 +599,9 @@ static int API_GetCurrentDegCodFromCurrentCrsCod (void)
|
|||
|
||||
/***** Check that key does not exist in database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the degree of a course",
|
||||
"SELECT DegCod FROM crs_courses WHERE CrsCod=%ld",
|
||||
"SELECT DegCod"
|
||||
" FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod)) // Course found in table of courses
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -633,7 +636,8 @@ static bool API_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
|
|||
"FirstName," // row[2]
|
||||
"Photo," // row[3]
|
||||
"DATE_FORMAT(Birthday,'%%Y%%m%%d')" // row[4]
|
||||
" FROM usr_data WHERE UsrCod=%ld",
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrDat->UsrCod) != 1)
|
||||
return false;
|
||||
|
||||
|
@ -837,7 +841,8 @@ static int API_CheckParamsNewAccount (char *NewNickWithArr, // Input
|
|||
|
||||
/***** 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"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE Nickname='%s'",
|
||||
NewNickWithoutArr)) // A nickname of another user is the same that this nickname
|
||||
return API_CHECK_NEW_ACCOUNT_NICKNAME_REGISTERED_BY_ANOTHER_USER;
|
||||
|
@ -850,8 +855,10 @@ static int API_CheckParamsNewAccount (char *NewNickWithArr, // Input
|
|||
{
|
||||
/***** Check if the new email matches any of the confirmed emails of other users *****/
|
||||
if (DB_QueryCOUNT ("can not check if email already existed",
|
||||
"SELECT COUNT(*) FROM usr_emails"
|
||||
" WHERE E_mail='%s' AND Confirmed='Y'",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_emails"
|
||||
" WHERE E_mail='%s'"
|
||||
" AND Confirmed='Y'",
|
||||
NewEmail)) // An email of another user is the same that my email
|
||||
return API_CHECK_NEW_ACCOUNT_EMAIL_REGISTERED_BY_ANOTHER_USER;
|
||||
}
|
||||
|
@ -922,11 +929,13 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
|||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's data",
|
||||
"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_data.Password='%s'",
|
||||
UsrIDNickOrEmail,userPassword);
|
||||
" AND usr_nicknames.UsrCod=usr_data.UsrCod"
|
||||
" AND usr_data.Password='%s'",
|
||||
UsrIDNickOrEmail,
|
||||
userPassword);
|
||||
}
|
||||
else if (Mai_CheckIfEmailIsValid (UsrIDNickOrEmail)) // 2: It's an email
|
||||
{
|
||||
|
@ -935,11 +944,12 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
|||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's data",
|
||||
"SELECT usr_emails.UsrCod"
|
||||
" FROM usr_emails,usr_data"
|
||||
" FROM usr_emails,usr_data"
|
||||
" WHERE usr_emails.E_mail='%s'"
|
||||
" AND usr_emails.UsrCod=usr_data.UsrCod"
|
||||
" AND usr_data.Password='%s'",
|
||||
UsrIDNickOrEmail,userPassword);
|
||||
" AND usr_emails.UsrCod=usr_data.UsrCod"
|
||||
" AND usr_data.Password='%s'",
|
||||
UsrIDNickOrEmail,
|
||||
userPassword);
|
||||
}
|
||||
else // 3: It's not a nickname nor email
|
||||
{
|
||||
|
@ -1284,7 +1294,8 @@ int swad__getNewPassword (struct soap *soap,
|
|||
/* User has typed a nickname */
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's data",
|
||||
"SELECT UsrCod FROM usr_nicknames"
|
||||
"SELECT UsrCod"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE Nickname='%s'",
|
||||
UsrIDNickOrEmail);
|
||||
}
|
||||
|
@ -1294,7 +1305,8 @@ int swad__getNewPassword (struct soap *soap,
|
|||
// TODO: Get only if email confirmed?
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get user's data",
|
||||
"SELECT UsrCod FROM usr_emails"
|
||||
"SELECT UsrCod"
|
||||
" FROM usr_emails"
|
||||
" WHERE E_mail='%s'",
|
||||
UsrIDNickOrEmail);
|
||||
}
|
||||
|
@ -2591,13 +2603,19 @@ int swad__getAttendanceEvents (struct soap *soap,
|
|||
/***** Query list of attendance events *****/
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
||||
"SELECT AttCod,Hidden,UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime) AS ST,"
|
||||
"UNIX_TIMESTAMP(EndTime) AS ET,"
|
||||
"CommentTchVisible,Title,Txt"
|
||||
" FROM att_events"
|
||||
"SELECT AttCod,"
|
||||
"Hidden,"
|
||||
"UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime) AS ST,"
|
||||
"UNIX_TIMESTAMP(EndTime) AS ET,"
|
||||
"CommentTchVisible,"
|
||||
"Title,"
|
||||
"Txt"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod=%d"
|
||||
" ORDER BY ST DESC,ET DESC,Title DESC",
|
||||
" ORDER BY ST DESC,"
|
||||
"ET DESC,"
|
||||
"Title DESC",
|
||||
courseCode);
|
||||
|
||||
getAttendanceEventsOut->eventsArray.__size =
|
||||
|
@ -3068,9 +3086,12 @@ int swad__getAttendanceUsers (struct soap *soap,
|
|||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get users"
|
||||
" in an attendance event",
|
||||
"SELECT u.UsrCod,u.Present"
|
||||
" FROM (SELECT UsrCod,Present"
|
||||
" FROM att_users WHERE AttCod=%ld"
|
||||
"SELECT u.UsrCod,"
|
||||
"u.Present"
|
||||
" FROM (SELECT UsrCod,"
|
||||
"Present"
|
||||
" FROM att_users"
|
||||
" WHERE AttCod=%ld"
|
||||
" UNION %s) AS u,"
|
||||
"usr_data"
|
||||
" WHERE u.UsrCod=usr_data.UsrCod"
|
||||
|
@ -3572,7 +3593,8 @@ static int API_GetMyLanguage (struct soap *soap)
|
|||
|
||||
/***** Get user's language *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get user's language",
|
||||
"SELECT Language FROM usr_data"
|
||||
"SELECT Language"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) != 1)
|
||||
return soap_receiver_fault (soap,
|
||||
|
@ -3716,12 +3738,16 @@ int swad__sendMessage (struct soap *soap,
|
|||
{
|
||||
/***** Check if the original message was really received by me *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not check original message",
|
||||
"SELECT SUM(N) FROM"
|
||||
" (SELECT COUNT(*) AS N FROM msg_rcv"
|
||||
" WHERE UsrCod=%ld AND MsgCod=%ld"
|
||||
" UNION"
|
||||
" SELECT COUNT(*) AS N FROM msg_rcv_deleted"
|
||||
" WHERE UsrCod=%ld AND MsgCod=%ld) AS T",
|
||||
"SELECT SUM(N)"
|
||||
" FROM (SELECT COUNT(*) AS N"
|
||||
" FROM msg_rcv"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND MsgCod=%ld"
|
||||
" UNION"
|
||||
" SELECT COUNT(*) AS N"
|
||||
" FROM msg_rcv_deleted"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND MsgCod=%ld) AS T",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,(long) messageCode,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,(long) messageCode))
|
||||
return soap_sender_fault (soap,
|
||||
|
@ -3746,12 +3772,15 @@ int swad__sendMessage (struct soap *soap,
|
|||
/***** Get the recipient of the message *****/
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not check original message",
|
||||
"SELECT UsrCod FROM msg_snt"
|
||||
"SELECT UsrCod"
|
||||
" FROM msg_snt"
|
||||
" WHERE MsgCod=%ld"
|
||||
" UNION "
|
||||
"SELECT UsrCod FROM msg_snt_deleted"
|
||||
"SELECT UsrCod"
|
||||
" FROM msg_snt_deleted"
|
||||
" WHERE MsgCod=%ld",
|
||||
(long) messageCode,(long) messageCode);
|
||||
(long) messageCode,
|
||||
(long) messageCode);
|
||||
if (NumRows) // Message found in any of the two tables of sent messages
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3774,7 +3803,10 @@ int swad__sendMessage (struct soap *soap,
|
|||
/***** Build query for recipients from database *****/
|
||||
if (ReplyUsrCod > 0)
|
||||
snprintf (Query,API_MAX_BYTES_QUERY_RECIPIENTS + 1,
|
||||
"SELECT UsrCod FROM usr_data WHERE UsrCod=%ld",ReplyUsrCod);
|
||||
"SELECT UsrCod"
|
||||
" FROM usr_data"
|
||||
" WHERE UsrCod=%ld",
|
||||
ReplyUsrCod);
|
||||
else
|
||||
Query[0] = '\0';
|
||||
|
||||
|
@ -3802,7 +3834,8 @@ int swad__sendMessage (struct soap *soap,
|
|||
{
|
||||
if (ReplyUsrCod > 0)
|
||||
Str_Concat (Query," UNION ",API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||
Str_Concat (Query,"SELECT UsrCod FROM usr_nicknames"
|
||||
Str_Concat (Query,"SELECT UsrCod"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE Nickname IN ('",
|
||||
API_MAX_BYTES_QUERY_RECIPIENTS);
|
||||
FirstNickname = false;
|
||||
|
@ -4131,8 +4164,14 @@ static int API_GetTstConfig (long CrsCod)
|
|||
|
||||
/***** Query database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get test configuration",
|
||||
"SELECT Pluggable,Min,Def,Max,MinTimeNxtTstPerQst,Visibility"
|
||||
" FROM tst_config WHERE CrsCod=%ld",
|
||||
"SELECT Pluggable," // row[0]
|
||||
"Min," // row[1]
|
||||
"Def," // row[2]
|
||||
"Max," // row[3]
|
||||
"MinTimeNxtTstPerQst," // row[4]
|
||||
"Visibility" // row[5]
|
||||
" FROM tst_config"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod))
|
||||
{
|
||||
/***** Get minimun, default and maximum *****/
|
||||
|
@ -4166,20 +4205,23 @@ static int API_GetNumTestQuestionsInCrs (long CrsCod)
|
|||
return
|
||||
(int) DB_QueryCOUNT ("can not get number of test questions",
|
||||
"SELECT COUNT(*)"
|
||||
" 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",
|
||||
CrsCod,CrsCod,CrsCod);
|
||||
" 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",
|
||||
CrsCod,
|
||||
CrsCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4286,9 +4328,11 @@ static int API_GetTstTags (struct soap *soap,
|
|||
|
||||
/***** Get available tags from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get test tags",
|
||||
"SELECT TagCod,TagTxt"
|
||||
" FROM tst_tags"
|
||||
" WHERE CrsCod=%ld AND TagHidden='N'"
|
||||
"SELECT TagCod," // row[0]
|
||||
"TagTxt" // row[1]
|
||||
" FROM tst_tags"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND TagHidden='N'"
|
||||
" ORDER BY TagTxt",
|
||||
CrsCod);
|
||||
|
||||
|
@ -4345,24 +4389,28 @@ static int API_GetTstQuestions (struct soap *soap,
|
|||
// DISTINCTROW is necessary to not repeat questions
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get test questions",
|
||||
"SELECT DISTINCTROW tst_questions.QstCod,"
|
||||
"tst_questions.AnsType,tst_questions.Shuffle,"
|
||||
"tst_questions.Stem,tst_questions.Feedback"
|
||||
" FROM tst_questions,tst_question_tags,tst_tags"
|
||||
"SELECT DISTINCTROW tst_questions.QstCod," // row[0]
|
||||
"tst_questions.AnsType," // row[1]
|
||||
"tst_questions.Shuffle," // row[2]
|
||||
"tst_questions.Stem," // row[3]
|
||||
"tst_questions.Feedback" // row[4]
|
||||
" 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.EditTime>=FROM_UNIXTIME(%ld)"
|
||||
" OR "
|
||||
"tst_tags.ChangeTime>=FROM_UNIXTIME(%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.EditTime>=FROM_UNIXTIME(%ld)"
|
||||
" OR "
|
||||
"tst_tags.ChangeTime>=FROM_UNIXTIME(%ld))"
|
||||
" ORDER BY QstCod",
|
||||
CrsCod,CrsCod,CrsCod,
|
||||
BeginTime,
|
||||
|
@ -4437,26 +4485,33 @@ static int API_GetTstAnswers (struct soap *soap,
|
|||
/***** Get recent test questions from database *****/
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get test answers",
|
||||
"SELECT QstCod,AnsInd,Correct,Answer,Feedback"
|
||||
" FROM tst_answers WHERE QstCod IN "
|
||||
"(SELECT tst_questions.QstCod"
|
||||
" 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.EditTime>=FROM_UNIXTIME(%ld)"
|
||||
" OR "
|
||||
"tst_tags.ChangeTime>=FROM_UNIXTIME(%ld)"
|
||||
")"
|
||||
")"
|
||||
" ORDER BY QstCod,AnsInd",
|
||||
"SELECT QstCod,"
|
||||
"AnsInd,"
|
||||
"Correct,"
|
||||
"Answer,"
|
||||
"Feedback"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod IN "
|
||||
"(SELECT tst_questions.QstCod"
|
||||
" 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.EditTime>=FROM_UNIXTIME(%ld)"
|
||||
" OR "
|
||||
"tst_tags.ChangeTime>=FROM_UNIXTIME(%ld)))"
|
||||
" ORDER BY QstCod,"
|
||||
"AnsInd",
|
||||
CrsCod,CrsCod,CrsCod,
|
||||
BeginTime,
|
||||
BeginTime);
|
||||
|
@ -4528,26 +4583,31 @@ static int API_GetTstQuestionTags (struct soap *soap,
|
|||
/***** Get recent test questions from database *****/
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get test question tags",
|
||||
"SELECT QstCod,TagCod,TagInd"
|
||||
" FROM tst_question_tags WHERE QstCod IN "
|
||||
"(SELECT tst_questions.QstCod"
|
||||
" 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.EditTime>=FROM_UNIXTIME(%ld)"
|
||||
" OR "
|
||||
"tst_tags.ChangeTime>=FROM_UNIXTIME(%ld)"
|
||||
")"
|
||||
")"
|
||||
" ORDER BY QstCod,TagInd",
|
||||
"SELECT QstCod,"
|
||||
"TagCod,"
|
||||
"TagInd"
|
||||
" FROM tst_question_tags"
|
||||
" WHERE QstCod IN "
|
||||
"(SELECT tst_questions.QstCod"
|
||||
" 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.EditTime>=FROM_UNIXTIME(%ld)"
|
||||
" OR "
|
||||
"tst_tags.ChangeTime>=FROM_UNIXTIME(%ld)))"
|
||||
" ORDER BY QstCod,"
|
||||
"TagInd",
|
||||
CrsCod,CrsCod,CrsCod,
|
||||
BeginTime,
|
||||
BeginTime);
|
||||
|
@ -4680,29 +4740,32 @@ int swad__getTrivialQuestion (struct soap *soap,
|
|||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get test questions",
|
||||
"SELECT DISTINCTROW "
|
||||
"tst_questions.QstCod,"
|
||||
"tst_questions.AnsType,"
|
||||
"tst_questions.Shuffle,"
|
||||
"tst_questions.Stem,"
|
||||
"tst_questions.Feedback,"
|
||||
"tst_questions.Score/tst_questions.NumHits AS S"
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
"tst_questions.QstCod," // row[0]
|
||||
"tst_questions.AnsType," // row[1]
|
||||
"tst_questions.Shuffle," // row[2]
|
||||
"tst_questions.Stem," // row[3]
|
||||
"tst_questions.Feedback," // row[4]
|
||||
"tst_questions.Score/"
|
||||
"tst_questions.NumHits AS S" // row[5]
|
||||
" FROM crs_courses,"
|
||||
"tst_questions"
|
||||
" WHERE crs_courses.DegCod IN (%s)"
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='unique_choice'"
|
||||
" AND tst_questions.NumHits>0"
|
||||
" AND tst_questions.QstCod NOT IN"
|
||||
" (SELECT tst_question_tags.QstCod"
|
||||
" FROM crs_courses,"
|
||||
"tst_tags,"
|
||||
"tst_question_tags"
|
||||
" WHERE crs_courses.DegCod IN (%s)"
|
||||
" AND crs_courses.CrsCod=tst_tags.CrsCod"
|
||||
" AND tst_tags.TagHidden='Y'"
|
||||
" AND tst_tags.TagCod=tst_question_tags.TagCod)"
|
||||
" HAVING S>='%f' AND S<='%f'"
|
||||
" ORDER BY RAND() LIMIT 1",
|
||||
" AND crs_courses.CrsCod=tst_questions.CrsCod"
|
||||
" AND tst_questions.AnsType='unique_choice'"
|
||||
" AND tst_questions.NumHits>0"
|
||||
" AND tst_questions.QstCod NOT IN"
|
||||
" (SELECT tst_question_tags.QstCod"
|
||||
" FROM crs_courses,"
|
||||
"tst_tags,"
|
||||
"tst_question_tags"
|
||||
" WHERE crs_courses.DegCod IN (%s)"
|
||||
" AND crs_courses.CrsCod=tst_tags.CrsCod"
|
||||
" AND tst_tags.TagHidden='Y'"
|
||||
" AND tst_tags.TagCod=tst_question_tags.TagCod)"
|
||||
" HAVING S>='%f'"
|
||||
" AND S<='%f'"
|
||||
" ORDER BY RAND()"
|
||||
" LIMIT 1",
|
||||
DegreesStr,DegreesStr,
|
||||
lowerScore,upperScore);
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
|
@ -4765,12 +4828,17 @@ int swad__getTrivialQuestion (struct soap *soap,
|
|||
if (QstCod > 0)
|
||||
{
|
||||
/***** Get answer from database *****/
|
||||
NumRows =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get test answers",
|
||||
"SELECT QstCod,AnsInd,Correct,Answer,Feedback"
|
||||
" FROM tst_answers WHERE QstCod=%ld"
|
||||
" ORDER BY AnsInd",
|
||||
QstCod);
|
||||
NumRows = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get test answers",
|
||||
"SELECT QstCod," // row[0]
|
||||
"AnsInd," // row[1]
|
||||
"Correct," // row[2]
|
||||
"Answer," // row[3]
|
||||
"Feedback" // row[4]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY AnsInd",
|
||||
QstCod);
|
||||
|
||||
getTrivialQuestionOut->answersArray.__size = (int) NumRows;
|
||||
|
||||
|
@ -4885,11 +4953,11 @@ int swad__getGames (struct soap *soap,
|
|||
"gam_games.Visibility," // row[5]
|
||||
"gam_games.Title," // row[6]
|
||||
"gam_games.Txt" // row[7]
|
||||
" FROM gam_games"
|
||||
" LEFT JOIN mch_matches"
|
||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||
" FROM gam_games"
|
||||
" LEFT JOIN mch_matches"
|
||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND Hidden='N'"
|
||||
" AND Hidden='N'"
|
||||
" GROUP BY gam_games.GamCod"
|
||||
" ORDER BY StartTime DESC,"
|
||||
"EndTime DESC,"
|
||||
|
@ -5401,10 +5469,12 @@ static void API_GetListGrpsInGameFromDB (struct soap *soap,
|
|||
size_t Length;
|
||||
|
||||
/***** Get list of groups *****/
|
||||
NumGrps =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get groups of a match",
|
||||
"SELECT GrpCod FROM mch_groups WHERE MchCod=%ld",
|
||||
MchCod);
|
||||
NumGrps = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get groups of a match",
|
||||
"SELECT GrpCod"
|
||||
" FROM mch_groups"
|
||||
" WHERE MchCod=%ld",
|
||||
MchCod);
|
||||
if (NumGrps == 0)
|
||||
*ListGroups = NULL;
|
||||
else // Groups found
|
||||
|
|
|
@ -659,8 +659,10 @@ static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_F
|
|||
/* 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",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_nicknames"
|
||||
" WHERE Nickname='%s'"
|
||||
" AND UsrCod<>%ld",
|
||||
NewNickWithoutArr,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod)) // A nickname of another user is the same that this nickname
|
||||
{
|
||||
|
@ -686,8 +688,10 @@ static bool Acc_GetParamsNewAccount (char NewNickWithoutArr[Nck_MAX_BYTES_NICK_F
|
|||
/* Check if the new email matches
|
||||
any of the confirmed emails of other users */
|
||||
if (DB_QueryCOUNT ("can not check if email already existed",
|
||||
"SELECT COUNT(*) FROM usr_emails"
|
||||
" WHERE E_mail='%s' AND Confirmed='Y'",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_emails"
|
||||
" WHERE E_mail='%s'"
|
||||
" AND Confirmed='Y'",
|
||||
NewEmail)) // An email of another user is the same that my email
|
||||
{
|
||||
Error = true;
|
||||
|
|
|
@ -1151,7 +1151,8 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
|||
{
|
||||
/* Make query */
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get agenda events",
|
||||
"SELECT AgdCod FROM agd_agendas"
|
||||
"SELECT AgdCod"
|
||||
" FROM agd_agendas"
|
||||
" WHERE %s%s%s%s"
|
||||
" ORDER BY %s",
|
||||
UsrSubQuery,
|
||||
|
@ -1300,9 +1301,9 @@ static void Agd_GetEventTxtFromDB (struct Agd_Event *AgdEvent,
|
|||
/***** Get text of event from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get event text",
|
||||
"SELECT Txt" // row[0]
|
||||
" FROM agd_agendas"
|
||||
" FROM agd_agendas"
|
||||
" WHERE AgdCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
" AND UsrCod=%ld",
|
||||
AgdEvent->AgdCod,
|
||||
AgdEvent->UsrCod);
|
||||
|
||||
|
@ -1865,7 +1866,7 @@ unsigned Agd_GetNumEventsFromUsr (long UsrCod)
|
|||
/***** Get number of events in a course from database *****/
|
||||
return (unsigned) DB_QueryCOUNT ("can not get number of events from user",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM agd_agendas"
|
||||
" FROM agd_agendas"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
@ -1887,7 +1888,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Lvl_Level_t Scope)
|
|||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of users with events",
|
||||
"SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM agd_agendas"
|
||||
" FROM agd_agendas"
|
||||
" WHERE UsrCod>0");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
|
@ -1992,7 +1993,7 @@ unsigned Agd_GetNumEvents (Hie_Lvl_Level_t Scope)
|
|||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of events",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM agd_agendas"
|
||||
" FROM agd_agendas"
|
||||
" WHERE UsrCod>0");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
|
|
|
@ -104,7 +104,7 @@ void Ann_ShowAllAnnouncements (void)
|
|||
"Roles," // row[2]
|
||||
"Subject," // row[3]
|
||||
"Content" // row[4]
|
||||
" FROM ann_announcements"
|
||||
" FROM ann_announcements"
|
||||
" ORDER BY AnnCod DESC");
|
||||
}
|
||||
else if (Gbl.Usrs.Me.Logged)
|
||||
|
@ -117,7 +117,7 @@ void Ann_ShowAllAnnouncements (void)
|
|||
"Roles," // row[2]
|
||||
"Subject," // row[3]
|
||||
"Content" // row[4]
|
||||
" FROM ann_announcements"
|
||||
" FROM ann_announcements"
|
||||
" WHERE (Roles&%u)<>0 " // All my roles in different courses
|
||||
" ORDER BY AnnCod DESC",
|
||||
(unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss);
|
||||
|
@ -131,8 +131,9 @@ void Ann_ShowAllAnnouncements (void)
|
|||
"Roles," // row[2]
|
||||
"Subject," // row[3]
|
||||
"Content" // row[4]
|
||||
" FROM ann_announcements"
|
||||
" WHERE Status=%u AND (Roles&%u)<>0 "
|
||||
" FROM ann_announcements"
|
||||
" WHERE Status=%u"
|
||||
" AND (Roles&%u)<>0 "
|
||||
" ORDER BY AnnCod DESC",
|
||||
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,
|
||||
(unsigned) (1 << Rol_UNK));
|
||||
|
@ -234,13 +235,13 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
|
|||
"SELECT AnnCod," // row[0]
|
||||
"Subject," // row[1]
|
||||
"Content" // row[2]
|
||||
" FROM ann_announcements"
|
||||
" FROM ann_announcements"
|
||||
" WHERE Status=%u"
|
||||
" AND (Roles&%u)<>0 " // All my roles in different courses
|
||||
" AND AnnCod NOT IN"
|
||||
" (SELECT AnnCod"
|
||||
" FROM ann_seen"
|
||||
" WHERE UsrCod=%ld)"
|
||||
" FROM ann_seen"
|
||||
" WHERE UsrCod=%ld)"
|
||||
" ORDER BY AnnCod DESC", // Newest first
|
||||
(unsigned) Ann_ACTIVE_ANNOUNCEMENT,
|
||||
(unsigned) Gbl.Usrs.Me.UsrDat.Roles.InCrss,
|
||||
|
|
|
@ -695,7 +695,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
|||
if (Gbl.Crs.Grps.WhichGrps == Grp_MY_GROUPS)
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||
"SELECT AsgCod"
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" AND ("
|
||||
// Assignment is for the whole course
|
||||
|
@ -719,7 +719,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
|||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignments",
|
||||
"SELECT AsgCod"
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
|
@ -776,7 +776,7 @@ void Asg_GetDataOfAssignmentByCod (struct Asg_Assignment *Asg)
|
|||
"NOW() BETWEEN StartTime AND EndTime," // row[5]
|
||||
"Title," // row[6]
|
||||
"Folder" // row[7]
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE AsgCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
Asg->AsgCod,
|
||||
|
@ -814,7 +814,7 @@ void Asg_GetDataOfAssignmentByFolder (struct Asg_Assignment *Asg)
|
|||
"NOW() BETWEEN StartTime AND EndTime," // row[5]
|
||||
"Title," // row[6]
|
||||
"Folder" // row[7]
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND Folder='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
|
@ -941,7 +941,7 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT
|
|||
/***** Get text of assignment from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment text",
|
||||
"SELECT Txt" // row[0]
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE AsgCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
AsgCod,
|
||||
|
@ -984,7 +984,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
NumRows = DB_QuerySELECT (&mysql_res,"can not get assignment title and text",
|
||||
"SELECT Title," // row[0]
|
||||
"Txt" // row[1]
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE AsgCod=%ld",
|
||||
AsgCod);
|
||||
|
||||
|
@ -1202,9 +1202,10 @@ static bool Asg_CheckIfSimilarAssignmentExists (const char *Field,const char *Va
|
|||
/***** Get number of assignments with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar assignments",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND %s='%s' AND AsgCod<>%ld",
|
||||
" AND %s='%s'"
|
||||
" AND AsgCod<>%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Field,Value,AsgCod) != 0);
|
||||
}
|
||||
|
@ -1841,7 +1842,7 @@ static bool Asg_CheckIfIBelongToCrsOrGrpsThisAssignment (long AsgCod)
|
|||
/***** Get if I can do an assignment from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if I can do an assignment",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE AsgCod=%ld"
|
||||
" AND ("
|
||||
// Assignment is for the whole course
|
||||
|
@ -1880,65 +1881,65 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Lvl_Level_t Scope)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod>0");
|
||||
case Hie_Lvl_CTY:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT asg_assignments.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"courses,"
|
||||
"asg_assignments"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"courses,"
|
||||
"asg_assignments"
|
||||
" 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=asg_assignments.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=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
case Hie_Lvl_INS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT asg_assignments.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" 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=asg_assignments.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
case Hie_Lvl_CTR:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT asg_assignments.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
case Hie_Lvl_DEG:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT asg_assignments.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"asg_assignments"
|
||||
" FROM crs_courses,"
|
||||
"asg_assignments"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
case Hie_Lvl_CRS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with assignments",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
|
@ -1966,66 +1967,66 @@ unsigned Asg_GetNumAssignments (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(NumNotif)" // row[1]
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(asg_assignments.NumNotif)" // row[1]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" 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=asg_assignments.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=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*)," // row[0]
|
||||
"SUM(asg_assignments.NumNotif)" // row[1]
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(asg_assignments.NumNotif)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"asg_assignments"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(asg_assignments.NumNotif)"
|
||||
" FROM crs_courses,"
|
||||
"asg_assignments"
|
||||
" FROM crs_courses,"
|
||||
"asg_assignments"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
" AND crs_courses.CrsCod=asg_assignments.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of assignments",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumNotif)"
|
||||
" FROM asg_assignments"
|
||||
" FROM asg_assignments"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
|
|
|
@ -700,7 +700,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
|||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance events",
|
||||
"SELECT AttCod"
|
||||
" FROM att_events"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod=%ld%s"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
|
@ -770,13 +770,16 @@ bool Att_GetDataOfAttEventByCod (struct Att_Event *Event)
|
|||
{
|
||||
/***** Build query *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance event data",
|
||||
"SELECT AttCod,CrsCod,Hidden,UsrCod,"
|
||||
"UNIX_TIMESTAMP(StartTime),"
|
||||
"UNIX_TIMESTAMP(EndTime),"
|
||||
"NOW() BETWEEN StartTime AND EndTime,"
|
||||
"CommentTchVisible,"
|
||||
"Title"
|
||||
" FROM att_events"
|
||||
"SELECT AttCod," // row[0]
|
||||
"CrsCod," // row[1]
|
||||
"Hidden," // row[2]
|
||||
"UsrCod," // row[3]
|
||||
"UNIX_TIMESTAMP(StartTime)," // row[4]
|
||||
"UNIX_TIMESTAMP(EndTime)," // row[5]
|
||||
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
||||
"CommentTchVisible," // row[7]
|
||||
"Title" // row[8]
|
||||
" FROM att_events"
|
||||
" WHERE AttCod=%ld",
|
||||
Event->AttCod);
|
||||
|
||||
|
@ -870,8 +873,10 @@ static void Att_GetAttEventDescriptionFromDB (long AttCod,char Description[Cns_M
|
|||
|
||||
/***** Get text of attendance event from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get attendance event text",
|
||||
"SELECT Txt FROM att_events"
|
||||
" WHERE AttCod=%ld AND CrsCod=%ld",
|
||||
"SELECT Txt"
|
||||
" FROM att_events"
|
||||
" WHERE AttCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
AttCod,Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
|
@ -1067,9 +1072,11 @@ static bool Att_CheckIfSimilarAttEventExists (const char *Field,const char *Valu
|
|||
/***** Get number of attendance events
|
||||
with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar attendance events",
|
||||
"SELECT COUNT(*) FROM att_events"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND %s='%s' AND AttCod<>%ld",
|
||||
" AND %s='%s'"
|
||||
" AND AttCod<>%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Field,Value,AttCod) != 0);
|
||||
}
|
||||
|
@ -1697,12 +1704,12 @@ void Att_RemoveCrsAttEvents (long CrsCod)
|
|||
unsigned Att_GetNumAttEventsInCrs (long CrsCod)
|
||||
{
|
||||
/***** Get number of attendance events in a course from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of attendance events"
|
||||
" in course",
|
||||
"SELECT COUNT(*) FROM att_events"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of attendance events in course",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1723,49 +1730,49 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope)
|
|||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM att_events"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
||||
"SELECT COUNT(DISTINCT att_events.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" 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=att_events.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
||||
"SELECT COUNT(DISTINCT att_events.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
||||
"SELECT COUNT(DISTINCT att_events.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"att_events"
|
||||
" FROM crs_courses,"
|
||||
"att_events"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
" AND crs_courses.Status=0"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with attendance events",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM att_events"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
|
@ -1802,51 +1809,52 @@ unsigned Att_GetNumAttEvents (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
{
|
||||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
||||
"SELECT COUNT(*),SUM(NumNotif)"
|
||||
" FROM att_events"
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumNotif)"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod>0");
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(att_events.NumNotif)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(att_events.NumNotif)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"att_events"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(att_events.NumNotif)"
|
||||
" FROM crs_courses,"
|
||||
"att_events"
|
||||
" FROM crs_courses,"
|
||||
"att_events"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
" AND crs_courses.CrsCod=att_events.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of attendance events",
|
||||
"SELECT COUNT(*),"
|
||||
"SUM(NumNotif)"
|
||||
" FROM att_events"
|
||||
" FROM att_events"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
|
@ -3071,12 +3079,12 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events)
|
|||
else // No students attended to this event
|
||||
{
|
||||
/***** Get groups associated to an attendance event from database *****/
|
||||
NumGrpsInThisEvent = (unsigned) DB_QuerySELECT (&mysql_res,"can not get groups"
|
||||
" of an attendance event",
|
||||
"SELECT GrpCod" // row[0]
|
||||
" FROM att_groups"
|
||||
" WHERE att_groups.AttCod=%ld",
|
||||
Events->Lst[NumAttEvent].AttCod);
|
||||
NumGrpsInThisEvent = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get groups of an attendance event",
|
||||
"SELECT GrpCod" // row[0]
|
||||
" FROM att_groups"
|
||||
" WHERE att_groups.AttCod=%ld",
|
||||
Events->Lst[NumAttEvent].AttCod);
|
||||
if (NumGrpsInThisEvent) // This event is associated to groups
|
||||
/* Get groups associated to this event */
|
||||
for (NumGrpInThisEvent = 0;
|
||||
|
|
|
@ -147,7 +147,7 @@ void Ban_SeeBanners (void)
|
|||
"FullName," // row[3]
|
||||
"Img," // row[4]
|
||||
"WWW" // row[5]
|
||||
" FROM ban_banners"
|
||||
" FROM ban_banners"
|
||||
" WHERE Hidden='N'"
|
||||
" ORDER BY ShortName");
|
||||
Ban_GetListBanners (&Banners,&mysql_res,NumRows);
|
||||
|
|
|
@ -903,7 +903,8 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams)
|
|||
"SELECT ExaCod," // row[0]
|
||||
"DATE(ExamDate)" // row[1]
|
||||
" FROM cfe_exams"
|
||||
" WHERE CrsCod=%ld AND Status=%u"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND Status=%u"
|
||||
" ORDER BY ExamDate DESC",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
|
||||
|
|
123
swad_center.c
123
swad_center.c
|
@ -130,15 +130,15 @@ void Ctr_SeeCtrWithPendingDegs (void)
|
|||
case Rol_CTR_ADM:
|
||||
NumCtrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get centers with pending degrees",
|
||||
"SELECT deg_degrees.CtrCod,"
|
||||
"COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_admin,"
|
||||
"ctr_centers"
|
||||
"SELECT deg_degrees.CtrCod," // row[0]
|
||||
"COUNT(*)" // row[1]
|
||||
" FROM deg_degrees,"
|
||||
"ctr_admin,"
|
||||
"ctr_centers"
|
||||
" WHERE (deg_degrees.Status & %u)<>0"
|
||||
" AND deg_degrees.CtrCod=ctr_admin.CtrCod"
|
||||
" AND ctr_admin.UsrCod=%ld"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND deg_degrees.CtrCod=ctr_admin.CtrCod"
|
||||
" AND ctr_admin.UsrCod=%ld"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" GROUP BY deg_degrees.CtrCod"
|
||||
" ORDER BY ctr_centers.ShortName",
|
||||
(unsigned) Deg_STATUS_BIT_PENDING,
|
||||
|
@ -149,10 +149,10 @@ void Ctr_SeeCtrWithPendingDegs (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get centers with pending degrees",
|
||||
"SELECT deg_degrees.CtrCod,"
|
||||
"COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers"
|
||||
" WHERE (deg_degrees.Status & %u)<>0"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
|
||||
" GROUP BY deg_degrees.CtrCod"
|
||||
" ORDER BY ctr_centers.ShortName",
|
||||
(unsigned) Deg_STATUS_BIT_PENDING);
|
||||
|
@ -567,7 +567,7 @@ void Ctr_GetBasicListOfCenters (long InsCod)
|
|||
"ShortName," // row[ 8]
|
||||
"FullName," // row[ 9]
|
||||
"WWW" // row[10]
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" ORDER BY FullName",
|
||||
InsCod);
|
||||
|
@ -636,9 +636,9 @@ void Ctr_GetFullListOfCenters (long InsCod)
|
|||
"ctr_centers.FullName," // row[ 9]
|
||||
"ctr_centers.WWW," // row[10]
|
||||
"COUNT(*) AS NumUsrs" // row[11]
|
||||
" FROM ctr_centers,usr_data"
|
||||
" FROM ctr_centers,usr_data"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=usr_data.CtrCod"
|
||||
" AND ctr_centers.CtrCod=usr_data.CtrCod"
|
||||
" GROUP BY ctr_centers.CtrCod)"
|
||||
" UNION "
|
||||
"(SELECT CtrCod," // row[ 0]
|
||||
|
@ -653,12 +653,14 @@ void Ctr_GetFullListOfCenters (long InsCod)
|
|||
"FullName," // row[ 9]
|
||||
"WWW," // row[10]
|
||||
"0 AS NumUsrs" // row[11]
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND CtrCod NOT IN"
|
||||
" (SELECT DISTINCT CtrCod FROM usr_data))"
|
||||
" AND CtrCod NOT IN"
|
||||
" (SELECT DISTINCT CtrCod"
|
||||
" FROM usr_data))"
|
||||
" ORDER BY %s",
|
||||
InsCod,InsCod,
|
||||
InsCod,
|
||||
InsCod,
|
||||
OrderBySubQuery[Gbl.Hierarchy.Ctrs.SelectedOrder]);
|
||||
|
||||
if (NumRows) // Centers found...
|
||||
|
@ -732,7 +734,7 @@ bool Ctr_GetDataOfCenterByCod (struct Ctr_Center *Ctr)
|
|||
"ShortName," // row[ 8]
|
||||
"FullName," // row[ 9]
|
||||
"WWW" // row[10]
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" WHERE CtrCod=%ld",
|
||||
Ctr->CtrCod);
|
||||
if (NumRows) // Center found...
|
||||
|
@ -801,7 +803,9 @@ long Ctr_GetInsCodOfCenterByCod (long CtrCod)
|
|||
{
|
||||
/***** Get the institution code of a center from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the institution of a center",
|
||||
"SELECT InsCod FROM ctr_centers WHERE CtrCod=%ld",
|
||||
"SELECT InsCod"
|
||||
" FROM ctr_centers"
|
||||
" WHERE CtrCod=%ld",
|
||||
CtrCod) == 1)
|
||||
{
|
||||
/***** Get the institution code of this center *****/
|
||||
|
@ -830,7 +834,9 @@ void Ctr_GetShortNameOfCenterByCod (struct Ctr_Center *Ctr)
|
|||
{
|
||||
/***** Get the short name of a center from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a center",
|
||||
"SELECT ShortName FROM ctr_centers WHERE CtrCod=%ld",
|
||||
"SELECT ShortName"
|
||||
" FROM ctr_centers"
|
||||
" WHERE CtrCod=%ld",
|
||||
Ctr->CtrCod) == 1)
|
||||
{
|
||||
/***** Get the short name of this center *****/
|
||||
|
@ -892,7 +898,7 @@ void Ctr_WriteSelectorOfCenter (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get centers",
|
||||
"SELECT DISTINCT CtrCod,"
|
||||
"ShortName"
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" ORDER BY ShortName",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
|
@ -1435,9 +1441,15 @@ bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
|
|||
/***** Get number of centers with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name of a center"
|
||||
" already existed",
|
||||
"SELECT COUNT(*) FROM ctr_centers"
|
||||
" WHERE InsCod=%ld AND %s='%s' AND CtrCod<>%ld",
|
||||
InsCod,FieldName,Name,CtrCod) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND %s='%s'"
|
||||
" AND CtrCod<>%ld",
|
||||
InsCod,
|
||||
FieldName,
|
||||
Name,
|
||||
CtrCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1953,10 +1965,10 @@ static unsigned Ctr_GetNumCtrsInCty (long CtyCod)
|
|||
Gbl.Cache.NumCtrsInCty.NumCtrs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers in a country",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_Lvl_CTY,Gbl.Cache.NumCtrsInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInCty.NumCtrs);
|
||||
|
@ -2000,7 +2012,9 @@ unsigned Ctr_GetNumCtrsInIns (long InsCod)
|
|||
Gbl.Cache.NumCtrsInIns.InsCod = InsCod;
|
||||
Gbl.Cache.NumCtrsInIns.NumCtrs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers in an institution",
|
||||
"SELECT COUNT(*) FROM ctr_centers WHERE InsCod=%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld",
|
||||
InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS,Hie_Lvl_INS,Gbl.Cache.NumCtrsInIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCtrsInIns.NumCtrs);
|
||||
|
@ -2036,8 +2050,10 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void)
|
|||
/* Ccoordinates 0, 0 means not set ==> don't show map */
|
||||
NumCtrsWithMap = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers with map",
|
||||
"SELECT COUNT(*) FROM ctr_centers"
|
||||
" WHERE Latitude<>0 OR Longitude<>0");
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers"
|
||||
" WHERE Latitude<>0"
|
||||
" OR Longitude<>0");
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap);
|
||||
}
|
||||
|
@ -2062,12 +2078,12 @@ unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod)
|
|||
NumCtrsWithMap = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers with map",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND (ctr_centers.Latitude<>0"
|
||||
" OR ctr_centers.Longitude<>0)",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND (ctr_centers.Latitude<>0"
|
||||
" OR ctr_centers.Longitude<>0)",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_CTY,CtyCod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap);
|
||||
|
@ -2092,9 +2108,11 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod)
|
|||
/* Ccoordinates 0, 0 means not set ==> don't show map */
|
||||
NumCtrsWithMap = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers with map",
|
||||
"SELECT COUNT(*) FROM ctr_centers"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND (Latitude<>0 OR Longitude<>0)",
|
||||
" AND (Latitude<>0"
|
||||
" OR Longitude<>0)",
|
||||
InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_MAP,Hie_Lvl_INS,InsCod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithMap);
|
||||
|
@ -2112,9 +2130,12 @@ unsigned Ctr_GetNumCtrsInPlc (long PlcCod)
|
|||
/***** Get number of centers (of the current institution) in a place *****/
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of centers in a place",
|
||||
"SELECT COUNT(*) FROM ctr_centers"
|
||||
" WHERE InsCod=%ld AND PlcCod=%ld",
|
||||
Gbl.Hierarchy.Ins.InsCod,PlcCod);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND PlcCod=%ld",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
PlcCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2134,11 +2155,11 @@ unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
|
|||
NumCtrsWithDegs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers with degrees",
|
||||
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
SubQuery);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_DEGS,Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithDegs);
|
||||
|
@ -2164,13 +2185,13 @@ unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery,
|
|||
NumCtrsWithCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of centers with courses",
|
||||
"SELECT COUNT(DISTINCT ctr_centers.CtrCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
SubQuery);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTRS_WITH_CRSS,Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumCtrsWithCrss);
|
||||
|
|
|
@ -517,7 +517,8 @@ static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution)
|
|||
|
||||
/***** Get photo attribution from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
||||
"SELECT PhotoAttribution FROM ctr_centers"
|
||||
"SELECT PhotoAttribution"
|
||||
" FROM ctr_centers"
|
||||
" WHERE CtrCod=%ld",
|
||||
CtrCod))
|
||||
{
|
||||
|
|
|
@ -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.51.49 (2021-03-26)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.52 (2021-03-28)"
|
||||
#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.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:
|
||||
RENAME TABLE usr_IDs TO usr_ids;
|
||||
|
|
|
@ -356,7 +356,7 @@ static unsigned Cht_GetNumUsrsInChatRoom (const char *RoomCode)
|
|||
/***** Get number of users connected to chat rooms from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get number of users"
|
||||
" connected to a chat room",
|
||||
"SELECT NumUsrs"
|
||||
"SELECT NumUsrs" // row[0]
|
||||
" FROM cht_rooms"
|
||||
" WHERE RoomCode='%s'",
|
||||
RoomCode))
|
||||
|
|
|
@ -466,7 +466,7 @@ static unsigned Con_GetConnectedUsrsTotal (Rol_Role_t Role)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of connected users",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_connected"
|
||||
" FROM usr_connected"
|
||||
" WHERE RoleInLastCrs=%u",
|
||||
(unsigned) Role);
|
||||
}
|
||||
|
|
110
swad_country.c
110
swad_country.c
|
@ -126,12 +126,12 @@ void Cty_SeeCtyWithPendingInss (void)
|
|||
NumCtys = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get countries"
|
||||
" with pending institutions",
|
||||
"SELECT ins_instits.CtyCod,"
|
||||
"COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
"SELECT ins_instits.CtyCod," // row[0]
|
||||
"COUNT(*)" // row[1]
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE (ins_instits.Status & %u)<>0"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod"
|
||||
" GROUP BY ins_instits.CtyCod"
|
||||
" ORDER BY cty_countrs.Name_%s",
|
||||
(unsigned) Ins_STATUS_BIT_PENDING,
|
||||
|
@ -763,7 +763,7 @@ void Cty_GetBasicListOfCountries (void)
|
|||
"SELECT CtyCod," // row[0]
|
||||
"Alpha2," // row[1]
|
||||
"Name_%s" // row[2]
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" ORDER BY Name_%s",
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
|
@ -876,8 +876,8 @@ void Cty_GetFullListOfCountries (void)
|
|||
"%s" // row[...]
|
||||
"%s" // row[...]
|
||||
"COUNT(*) AS NumUsrs" // row[...]
|
||||
" FROM cty_countrs,"
|
||||
"usr_data"
|
||||
" FROM cty_countrs,"
|
||||
"usr_data"
|
||||
" WHERE cty_countrs.CtyCod=usr_data.CtyCod"
|
||||
" GROUP BY cty_countrs.CtyCod)"
|
||||
" UNION "
|
||||
|
@ -886,9 +886,10 @@ void Cty_GetFullListOfCountries (void)
|
|||
"%s" // row[...]
|
||||
"%s" // row[...]
|
||||
"0 AS NumUsrs" // row[...]
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" WHERE CtyCod NOT IN"
|
||||
" (SELECT DISTINCT CtyCod FROM usr_data))"
|
||||
" (SELECT DISTINCT CtyCod"
|
||||
" FROM usr_data))"
|
||||
" ORDER BY %s",
|
||||
SubQueryNam1,SubQueryWWW1,
|
||||
SubQueryNam2,SubQueryWWW2,OrderBySubQuery);
|
||||
|
@ -973,7 +974,7 @@ void Cty_WriteSelectorOfCountry (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get countries",
|
||||
"SELECT DISTINCT CtyCod," // row[0]
|
||||
"Name_%s" // row[1]
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" ORDER BY Name_%s",
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
|
@ -1082,7 +1083,7 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty)
|
|||
"SELECT Alpha2," // row[0]
|
||||
"Name_%s," // row[1]
|
||||
"WWW_%s" // row[2]
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" WHERE CtyCod='%03ld'",
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],
|
||||
|
@ -1153,7 +1154,7 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
|
|||
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the name of a country",
|
||||
"SELECT Name_%s" // row[0]
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" WHERE CtyCod='%03ld'",
|
||||
Lan_STR_LANG_ID[Language],CtyCod)) // Country found...
|
||||
{
|
||||
|
@ -1476,7 +1477,7 @@ static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod)
|
|||
return (DB_QueryCOUNT ("can not check if the numeric code"
|
||||
" of a country already existed",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" WHERE CtyCod='%03ld'",
|
||||
CtyCod) != 0);
|
||||
}
|
||||
|
@ -1491,7 +1492,7 @@ static bool Cty_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1])
|
|||
return (DB_QueryCOUNT ("can not check if the alphabetic code"
|
||||
" of a country already existed",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" WHERE Alpha2='%s'",
|
||||
Alpha2) != 0);
|
||||
}
|
||||
|
@ -1508,9 +1509,9 @@ static bool Cty_CheckIfCountryNameExists (Lan_Language_t Language,const char *Na
|
|||
return (DB_QueryCOUNT ("can not check if the name"
|
||||
" of a country already existed",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" WHERE Name_%s='%s'"
|
||||
" AND CtyCod<>'%03ld'",
|
||||
" AND CtyCod<>'%03ld'",
|
||||
Lan_STR_LANG_ID[Language],Name,
|
||||
CtyCod) != 0);
|
||||
}
|
||||
|
@ -1939,8 +1940,8 @@ unsigned Cty_GetCachedNumCtysWithInss (void)
|
|||
NumCtysWithInss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with institutions",
|
||||
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits"
|
||||
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod");
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_INSS,Hie_Lvl_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithInss);
|
||||
|
@ -1965,11 +1966,11 @@ unsigned Cty_GetCachedNumCtysWithCtrs (void)
|
|||
NumCtysWithCtrs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with centers",
|
||||
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod");
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod");
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_Lvl_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithCtrs);
|
||||
}
|
||||
|
@ -1991,13 +1992,13 @@ unsigned Cty_GetCachedNumCtysWithDegs (void)
|
|||
NumCtysWithDegs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with degrees",
|
||||
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod");
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod");
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_Lvl_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithDegs);
|
||||
}
|
||||
|
@ -2021,15 +2022,15 @@ unsigned Cty_GetCachedNumCtysWithCrss (void)
|
|||
NumCtysWithCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with courses",
|
||||
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE cty_countrs.CtyCod=ins_instits.CtyCod"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod");
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod");
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CRSS,Hie_Lvl_SYS,-1L,
|
||||
FigCch_UNSIGNED,&NumCtysWithCrss);
|
||||
}
|
||||
|
@ -2060,18 +2061,19 @@ unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery,
|
|||
NumCtysWithUsrs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of countries with users",
|
||||
"SELECT COUNT(DISTINCT cty_countrs.CtyCod)"
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users"
|
||||
" WHERE %scty_countrs.CtyCod=ins_instits.CtyCod"
|
||||
" 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=crs_users.CrsCod"
|
||||
" AND crs_users.Role=%u",
|
||||
" FROM cty_countrs,"
|
||||
"ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users"
|
||||
" WHERE %s"
|
||||
"cty_countrs.CtyCod=ins_instits.CtyCod"
|
||||
" 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=crs_users.CrsCod"
|
||||
" AND crs_users.Role=%u",
|
||||
SubQuery,(unsigned) Role);
|
||||
FigCch_UpdateFigureIntoCache (FigureCtys[Role],Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumCtysWithUsrs);
|
||||
|
@ -2205,12 +2207,12 @@ bool Cty_GetIfMapIsAvailable (long CtyCod)
|
|||
if (DB_QuerySELECT (&mysql_res,"can not get if map is available",
|
||||
"SELECT EXISTS"
|
||||
"(SELECT *"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND (ctr_centers.Latitude<>0"
|
||||
" OR ctr_centers.Longitude<>0))",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND (ctr_centers.Latitude<>0"
|
||||
" OR ctr_centers.Longitude<>0))",
|
||||
CtyCod))
|
||||
{
|
||||
/* Get if map is available */
|
||||
|
|
|
@ -250,12 +250,12 @@ static void CtyCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
|||
"AVG(ctr_centers.Longitude)," // row[1]
|
||||
"GREATEST(MAX(ctr_centers.Latitude)-MIN(ctr_centers.Latitude),"
|
||||
"MAX(ctr_centers.Longitude)-MIN(ctr_centers.Longitude))" // row[2]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.Latitude<>0"
|
||||
" AND ctr_centers.Longitude<>0",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.Latitude<>0"
|
||||
" AND ctr_centers.Longitude<>0",
|
||||
Gbl.Hierarchy.Cty.CtyCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
|
@ -300,16 +300,16 @@ static void CtyCfg_Map (void)
|
|||
Map_AddTileLayer ();
|
||||
|
||||
/* Get centers with coordinates */
|
||||
NumCtrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get centers"
|
||||
" with coordinates",
|
||||
"SELECT ctr_centers.CtrCod" // row[0]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.Latitude<>0"
|
||||
" AND ctr_centers.Longitude<>0",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
NumCtrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get centers with coordinates",
|
||||
"SELECT ctr_centers.CtrCod" // row[0]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.Latitude<>0"
|
||||
" AND ctr_centers.Longitude<>0",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
||||
/* Add a marker and a popup for each center */
|
||||
for (NumCtr = 0;
|
||||
|
@ -584,7 +584,7 @@ static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution)
|
|||
/***** Get photo attribution from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
||||
"SELECT MapAttribution"
|
||||
" FROM cty_countrs"
|
||||
" FROM cty_countrs"
|
||||
" WHERE CtyCod=%ld",
|
||||
CtyCod))
|
||||
{
|
||||
|
|
115
swad_course.c
115
swad_course.c
|
@ -448,14 +448,14 @@ unsigned Crs_GetNumCrssInCty (long CtyCod)
|
|||
Gbl.Cache.NumCrssInCty.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a country",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" 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 ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_CTY,Gbl.Cache.NumCrssInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInCty.NumCrss);
|
||||
|
@ -500,12 +500,12 @@ unsigned Crs_GetNumCrssInIns (long InsCod)
|
|||
Gbl.Cache.NumCrssInIns.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in an institution",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_INS,Gbl.Cache.NumCrssInIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInIns.NumCrss);
|
||||
|
@ -550,10 +550,10 @@ unsigned Crs_GetNumCrssInCtr (long CtrCod)
|
|||
Gbl.Cache.NumCrssInCtr.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a center",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
CtrCod);
|
||||
return Gbl.Cache.NumCrssInCtr.NumCrss;
|
||||
}
|
||||
|
@ -599,7 +599,9 @@ unsigned Crs_GetNumCrssInDeg (long DegCod)
|
|||
Gbl.Cache.NumCrssInDeg.DegCod = DegCod;
|
||||
Gbl.Cache.NumCrssInDeg.NumCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of courses in a degree",
|
||||
"SELECT COUNT(*) FROM crs_courses WHERE DegCod=%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_CRSS,Hie_Lvl_DEG,Gbl.Cache.NumCrssInDeg.DegCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumCrssInDeg.NumCrss);
|
||||
|
@ -692,9 +694,9 @@ void Crs_WriteSelectorOfCourse (void)
|
|||
/***** Get courses belonging to the current degree from database *****/
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod,"
|
||||
"ShortName"
|
||||
" FROM crs_courses"
|
||||
"SELECT CrsCod," // row[0]
|
||||
"ShortName" // row[1]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" ORDER BY ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
|
@ -768,33 +770,37 @@ static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses)
|
|||
case Crs_ACTIVE_COURSES:
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod,"
|
||||
"DegCod,"
|
||||
"Year,"
|
||||
"InsCrsCod,"
|
||||
"Status,"
|
||||
"RequesterUsrCod,"
|
||||
"ShortName,"
|
||||
"FullName"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld AND Status=0"
|
||||
" ORDER BY Year,ShortName",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"DegCod," // row[1]
|
||||
"Year," // row[2]
|
||||
"InsCrsCod," // row[3]
|
||||
"Status," // row[4]
|
||||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND Status=0"
|
||||
" ORDER BY Year,"
|
||||
"ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Crs_ALL_COURSES_EXCEPT_REMOVED:
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod,"
|
||||
"DegCod,"
|
||||
"Year,"
|
||||
"InsCrsCod,"
|
||||
"Status,"
|
||||
"RequesterUsrCod,"
|
||||
"ShortName,"
|
||||
"FullName"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld AND (Status & %u)=0"
|
||||
" ORDER BY Year,ShortName",
|
||||
"SELECT CrsCod," // row[0]
|
||||
"DegCod," // row[1]
|
||||
"Year," // row[2]
|
||||
"InsCrsCod," // row[3]
|
||||
"Status," // row[4]
|
||||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND (Status & %u)=0"
|
||||
" ORDER BY Year,"
|
||||
"ShortName",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
(unsigned) Crs_STATUS_BIT_REMOVED);
|
||||
break;
|
||||
|
@ -1797,7 +1803,7 @@ bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs)
|
|||
"RequesterUsrCod," // row[5]
|
||||
"ShortName," // row[6]
|
||||
"FullName" // row[7]
|
||||
" FROM crs_courses"
|
||||
" FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
Crs->CrsCod)) // Course found...
|
||||
{
|
||||
|
@ -1864,12 +1870,12 @@ static void Crs_GetShortNamesByCod (long CrsCod,
|
|||
{
|
||||
/***** Get the short name of a degree from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a course",
|
||||
"SELECT crs_courses.ShortName,"
|
||||
"deg_degrees.ShortName"
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees"
|
||||
"SELECT crs_courses.ShortName," // row[0]
|
||||
"deg_degrees.ShortName" // row[1]
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees"
|
||||
" WHERE crs_courses.CrsCod=%ld"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod",
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod",
|
||||
CrsCod) == 1)
|
||||
{
|
||||
/***** Get the course short name and degree short name *****/
|
||||
|
@ -2327,10 +2333,17 @@ bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name
|
|||
/***** Get number of courses in a year of a degree and with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name"
|
||||
" of a course already existed",
|
||||
"SELECT COUNT(*) FROM crs_courses"
|
||||
" WHERE DegCod=%ld AND Year=%u"
|
||||
" AND %s='%s' AND CrsCod<>%ld",
|
||||
DegCod,Year,FieldName,Name,CrsCod) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld"
|
||||
" AND Year=%u"
|
||||
" AND %s='%s'"
|
||||
" AND CrsCod<>%ld",
|
||||
DegCod,
|
||||
Year,
|
||||
FieldName,
|
||||
Name,
|
||||
CrsCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -3835,7 +3835,8 @@ unsigned long DB_GetNumRowsTable (const char *Table)
|
|||
{
|
||||
/***** Get total number of rows from database *****/
|
||||
return DB_QueryCOUNT ("can not get number of rows in table",
|
||||
"SELECT COUNT(*) FROM %s",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM %s",
|
||||
Table);
|
||||
}
|
||||
|
||||
|
|
106
swad_degree.c
106
swad_degree.c
|
@ -129,16 +129,16 @@ void Deg_SeeDegWithPendingCrss (void)
|
|||
case Rol_DEG_ADM:
|
||||
NumDegs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get degrees with pending courses",
|
||||
"SELECT crs_courses.DegCod,"
|
||||
"COUNT(*)"
|
||||
" FROM usr_admins,"
|
||||
"crs_courses,"
|
||||
"deg_degrees"
|
||||
"SELECT crs_courses.DegCod," // row[0]
|
||||
"COUNT(*)" // row[1]
|
||||
" FROM usr_admins,"
|
||||
"crs_courses,"
|
||||
"deg_degrees"
|
||||
" WHERE usr_admins.UsrCod=%ld"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=crs_courses.DegCod"
|
||||
" AND (crs_courses.Status & %u)<>0"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=crs_courses.DegCod"
|
||||
" AND (crs_courses.Status & %u)<>0"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" GROUP BY crs_courses.DegCod"
|
||||
" ORDER BY deg_degrees.ShortName",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
|
@ -148,12 +148,12 @@ void Deg_SeeDegWithPendingCrss (void)
|
|||
case Rol_SYS_ADM:
|
||||
NumDegs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get degrees with pending courses",
|
||||
"SELECT crs_courses.DegCod,"
|
||||
"COUNT(*)"
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees"
|
||||
"SELECT crs_courses.DegCod," // row[0]
|
||||
"COUNT(*)" // row[1]
|
||||
" FROM crs_courses,"
|
||||
"deg_degrees"
|
||||
" WHERE (crs_courses.Status & %u)<>0"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" AND crs_courses.DegCod=deg_degrees.DegCod"
|
||||
" GROUP BY crs_courses.DegCod"
|
||||
" ORDER BY deg_degrees.ShortName",
|
||||
(unsigned) Crs_STATUS_BIT_PENDING);
|
||||
|
@ -277,13 +277,14 @@ void Deg_WriteSelectorOfDegree (void)
|
|||
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
|
||||
{
|
||||
/***** Get degrees belonging to the current center from database *****/
|
||||
NumDegs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get degrees"
|
||||
" of a center",
|
||||
"SELECT DegCod,ShortName"
|
||||
" FROM deg_degrees"
|
||||
" WHERE CtrCod=%ld"
|
||||
" ORDER BY ShortName",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
NumDegs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get degrees of a center",
|
||||
"SELECT DegCod," // row[0]
|
||||
"ShortName" // row[1]
|
||||
" FROM deg_degrees"
|
||||
" WHERE CtrCod=%ld"
|
||||
" ORDER BY ShortName",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
|
||||
/***** Get degrees of this center *****/
|
||||
for (NumDeg = 0;
|
||||
|
@ -1138,7 +1139,7 @@ void Deg_GetListDegsInCurrentCtr (void)
|
|||
"ShortName," // row[5]
|
||||
"FullName," // row[6]
|
||||
"WWW" // row[7]
|
||||
" FROM deg_degrees"
|
||||
" FROM deg_degrees"
|
||||
" WHERE CtrCod=%ld"
|
||||
" ORDER BY FullName",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
|
@ -1375,7 +1376,8 @@ bool Deg_GetDataOfDegreeByCod (struct Deg_Degree *Deg)
|
|||
"ShortName," // row[5]
|
||||
"FullName," // row[6]
|
||||
"WWW" // row[7]
|
||||
" FROM deg_degrees WHERE DegCod=%ld",
|
||||
" FROM deg_degrees"
|
||||
" WHERE DegCod=%ld",
|
||||
Deg->DegCod)) // Degree found...
|
||||
{
|
||||
/***** Get data of degree *****/
|
||||
|
@ -1436,7 +1438,9 @@ void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg)
|
|||
{
|
||||
/***** Get the short name of a degree from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a degree",
|
||||
"SELECT ShortName FROM deg_degrees WHERE DegCod=%ld",
|
||||
"SELECT ShortName"
|
||||
" FROM deg_degrees"
|
||||
" WHERE DegCod=%ld",
|
||||
Deg->DegCod) == 1)
|
||||
{
|
||||
/***** Get the short name of this degree *****/
|
||||
|
@ -1463,7 +1467,9 @@ long Deg_GetCtrCodOfDegreeByCod (long DegCod)
|
|||
{
|
||||
/***** Get the center code of a degree from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the center of a degree",
|
||||
"SELECT CtrCod FROM deg_degrees WHERE DegCod=%ld",
|
||||
"SELECT CtrCod"
|
||||
" FROM deg_degrees"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod) == 1)
|
||||
{
|
||||
/***** Get the center code of this degree *****/
|
||||
|
@ -1493,10 +1499,10 @@ long Deg_GetInsCodOfDegreeByCod (long DegCod)
|
|||
/***** Get the institution code of a degree from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the institution of a degree",
|
||||
"SELECT ctr_centers.InsCod"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers"
|
||||
" FROM deg_degrees,"
|
||||
"ctr_centers"
|
||||
" WHERE deg_degrees.DegCod=%ld"
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod",
|
||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod",
|
||||
DegCod) == 1)
|
||||
{
|
||||
/***** Get the institution code of this degree *****/
|
||||
|
@ -1527,7 +1533,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
|||
/***** Get courses of a degree from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||
"SELECT CrsCod"
|
||||
" FROM crs_courses"
|
||||
" FROM crs_courses"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
|
||||
|
@ -1690,9 +1696,14 @@ bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name,
|
|||
/***** Get number of degrees with a type and a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name of a degree"
|
||||
" already existed",
|
||||
"SELECT COUNT(*) FROM deg_degrees"
|
||||
" WHERE CtrCod=%ld AND %s='%s' AND DegCod<>%ld",
|
||||
CtrCod,FieldName,Name,DegCod) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees"
|
||||
" WHERE CtrCod=%ld"
|
||||
" AND %s='%s'"
|
||||
" AND DegCod<>%ld",
|
||||
CtrCod,
|
||||
FieldName,Name,
|
||||
DegCod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1955,12 +1966,12 @@ unsigned Deg_GetNumDegsInCty (long CtyCod)
|
|||
Gbl.Cache.NumDegsInCty.NumDegs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of degrees in a country",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
CtyCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_Lvl_CTY,Gbl.Cache.NumDegsInCty.CtyCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInCty.NumDegs);
|
||||
|
@ -2005,10 +2016,10 @@ unsigned Deg_GetNumDegsInIns (long InsCod)
|
|||
Gbl.Cache.NumDegsInIns.NumDegs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of degrees in an institution",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
InsCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_Lvl_INS,Gbl.Cache.NumDegsInIns.InsCod,
|
||||
FigCch_UNSIGNED,&Gbl.Cache.NumDegsInIns.NumDegs);
|
||||
|
@ -2052,7 +2063,8 @@ unsigned Deg_GetNumDegsInCtr (long CtrCod)
|
|||
Gbl.Cache.NumDegsInCtr.CtrCod = CtrCod;
|
||||
Gbl.Cache.NumDegsInCtr.NumDegs =
|
||||
(unsigned) DB_QueryCOUNT ("can not get the number of degrees in a center",
|
||||
"SELECT COUNT(*) FROM deg_degrees"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees"
|
||||
" WHERE CtrCod=%ld",
|
||||
CtrCod);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS,Hie_Lvl_CTR,Gbl.Cache.NumDegsInCtr.CtrCod,
|
||||
|
@ -2090,13 +2102,13 @@ unsigned Deg_GetCachedNumDegsWithCrss (const char *SubQuery,
|
|||
NumDegsWithCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of degrees with courses",
|
||||
"SELECT COUNT(DISTINCT deg_degrees.DegCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
SubQuery);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_DEGS_WITH_CRSS,Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumDegsWithCrss);
|
||||
|
|
|
@ -606,7 +606,8 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
"(SELECT deg_types.DegTypCod," // row[0]
|
||||
"deg_types.DegTypName," // row[1]
|
||||
"COUNT(deg_degrees.DegCod) AS NumDegs" // row[2]
|
||||
" FROM deg_degrees,deg_types"
|
||||
" FROM deg_degrees,"
|
||||
"deg_types"
|
||||
" WHERE deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" GROUP BY deg_degrees.DegTypCod)"
|
||||
" UNION "
|
||||
|
@ -616,9 +617,10 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
// do not use '0' because
|
||||
// NumDegs will be casted to string
|
||||
// and order will be wrong
|
||||
" FROM deg_types"
|
||||
" FROM deg_types"
|
||||
" WHERE DegTypCod NOT IN"
|
||||
" (SELECT DegTypCod FROM deg_degrees))"
|
||||
" (SELECT DegTypCod"
|
||||
" FROM deg_degrees))"
|
||||
" ORDER BY %s",
|
||||
OrderBySubQuery[Order]);
|
||||
break;
|
||||
|
@ -629,14 +631,14 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
"SELECT deg_types.DegTypCod," // row[0]
|
||||
"deg_types.DegTypName," // row[1]
|
||||
"COUNT(deg_degrees.DegCod) AS NumDegs" // row[2]
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"deg_types"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"deg_types"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" GROUP BY deg_degrees.DegTypCod"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
|
@ -649,12 +651,12 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
"SELECT deg_types.DegTypCod," // row[0]
|
||||
"deg_types.DegTypName," // row[1]
|
||||
"COUNT(deg_degrees.DegCod) AS NumDegs" // row[2]
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"deg_types"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"deg_types"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" GROUP BY deg_degrees.DegTypCod"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
|
@ -667,9 +669,10 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
"SELECT deg_types.DegTypCod," // row[0]
|
||||
"deg_types.DegTypName," // row[1]
|
||||
"COUNT(deg_degrees.DegCod) AS NumDegs" // row[2]
|
||||
" FROM deg_degrees,deg_types"
|
||||
" FROM deg_degrees,"
|
||||
"deg_types"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" GROUP BY deg_degrees.DegTypCod"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
|
@ -683,9 +686,10 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
"SELECT deg_types.DegTypCod," // row[0]
|
||||
"deg_types.DegTypName," // row[1]
|
||||
"COUNT(deg_degrees.DegCod) AS NumDegs" // row[2]
|
||||
" FROM deg_degrees,deg_types"
|
||||
" FROM deg_degrees,"
|
||||
"deg_types"
|
||||
" WHERE deg_degrees.DegCod=%ld"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" AND deg_degrees.DegTypCod=deg_types.DegTypCod"
|
||||
" GROUP BY deg_degrees.DegTypCod"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
|
@ -851,7 +855,8 @@ static unsigned DT_CountNumDegsOfType (long DegTypCod)
|
|||
/***** Get number of degrees of a type from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of degrees of a type",
|
||||
"SELECT COUNT(*) FROM deg_degrees"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees"
|
||||
" WHERE DegTypCod=%ld",
|
||||
DegTypCod);
|
||||
}
|
||||
|
@ -877,7 +882,9 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
|
|||
|
||||
/***** Get the name of a type of degree from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get the name of a type of degree",
|
||||
"SELECT DegTypName FROM deg_types WHERE DegTypCod=%ld",
|
||||
"SELECT DegTypName"
|
||||
" FROM deg_types"
|
||||
" WHERE DegTypCod=%ld",
|
||||
DegTyp->DegTypCod);
|
||||
if (NumRows == 1)
|
||||
{
|
||||
|
@ -923,7 +930,8 @@ static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
|||
|
||||
/***** Get degrees of a type from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get degrees of a type",
|
||||
"SELECT DegCod FROM deg_degrees"
|
||||
"SELECT DegCod"
|
||||
" FROM deg_degrees"
|
||||
" WHERE DegTypCod=%ld",
|
||||
DegTypCod);
|
||||
|
||||
|
@ -1027,8 +1035,10 @@ static bool DT_CheckIfDegreeTypeNameExists (const char *DegTypName,long DegTypCo
|
|||
/***** Get number of degree types with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name of a type of degree"
|
||||
" already existed",
|
||||
"SELECT COUNT(*) FROM deg_types"
|
||||
" WHERE DegTypName='%s' AND DegTypCod<>%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_types"
|
||||
" WHERE DegTypName='%s'"
|
||||
" AND DegTypCod<>%ld",
|
||||
DegTypName,DegTypCod) != 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -517,7 +517,8 @@ unsigned Dpt_GetNumDepartmentsInInstitution (long InsCod)
|
|||
/***** Get number of departments in an institution from database *****/
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of departments in an institution",
|
||||
"SELECT COUNT(*) FROM dpt_departments"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM dpt_departments"
|
||||
" WHERE InsCod=%ld",
|
||||
InsCod);
|
||||
}
|
||||
|
@ -833,7 +834,8 @@ static bool Dpt_CheckIfDepartmentNameExists (const char *FieldName,const char *N
|
|||
{
|
||||
/***** Get number of departments with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the department name already existed",
|
||||
"SELECT COUNT(*) FROM dpt_departments"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM dpt_departments"
|
||||
" WHERE %s='%s'"
|
||||
" AND DptCod<>%ld",
|
||||
FieldName,Name,
|
||||
|
@ -1131,7 +1133,8 @@ unsigned Dpt_GetNumDptsInIns (long InsCod)
|
|||
Gbl.Cache.NumDptsInIns.InsCod = InsCod;
|
||||
Gbl.Cache.NumDptsInIns.NumDpts = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of departments in an institution",
|
||||
"SELECT COUNT(*) FROM departments"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM departments"
|
||||
" WHERE InsCod=%ld",
|
||||
InsCod);
|
||||
return Gbl.Cache.NumDptsInIns.NumDpts;
|
||||
|
|
|
@ -144,12 +144,15 @@ void Dup_ListDuplicateUsrs (void)
|
|||
Hlp_USERS_Duplicates_possibly_duplicate_users,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Make query *****/
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get possibly"
|
||||
" duplicate users",
|
||||
"SELECT UsrCod,COUNT(*) AS N,UNIX_TIMESTAMP(MIN(InformTime)) AS T"
|
||||
" FROM usr_duplicated"
|
||||
" GROUP BY UsrCod"
|
||||
" ORDER BY N DESC,T DESC");
|
||||
NumUsrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get possibly duplicate users",
|
||||
"SELECT UsrCod,"
|
||||
"COUNT(*) AS N,"
|
||||
"UNIX_TIMESTAMP(MIN(InformTime)) AS T"
|
||||
" FROM usr_duplicated"
|
||||
" GROUP BY UsrCod"
|
||||
" ORDER BY N DESC,"
|
||||
"T DESC");
|
||||
|
||||
/***** List possible duplicated users *****/
|
||||
if (NumUsrs)
|
||||
|
@ -293,8 +296,12 @@ static void Dup_ListSimilarUsrs (void)
|
|||
Gbl.Usrs.Other.UsrDat.FrstName);
|
||||
else
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get similar users",
|
||||
"SELECT DISTINCT UsrCod FROM usr_ids"
|
||||
" WHERE UsrID IN (SELECT UsrID FROM usr_ids WHERE UsrCod=%ld)",
|
||||
"SELECT DISTINCT UsrCod"
|
||||
" FROM usr_ids"
|
||||
" WHERE UsrID IN"
|
||||
" (SELECT UsrID"
|
||||
" FROM usr_ids"
|
||||
" WHERE UsrCod=%ld)",
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod);
|
||||
|
||||
/***** List possible similar users *****/
|
||||
|
@ -401,7 +408,8 @@ static bool Dup_CheckIfUsrIsDup (long UsrCod)
|
|||
{
|
||||
return (DB_QueryCOUNT ("can not if user is in list"
|
||||
" of possible duplicate users",
|
||||
"SELECT COUNT(*) FROM usr_duplicated"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_duplicated"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod) != 0);
|
||||
}
|
||||
|
|
278
swad_exam.c
278
swad_exam.c
|
@ -833,11 +833,11 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
|||
"SELECT exa_exams.ExaCod," // row[0]
|
||||
"MIN(exa_sessions.StartTime) AS StartTime," // row[1]
|
||||
"MAX(exa_sessions.EndTime) AS EndTime" // row[2]
|
||||
" FROM exa_exams"
|
||||
" LEFT JOIN exa_sessions"
|
||||
" ON exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" FROM exa_exams"
|
||||
" LEFT JOIN exa_sessions"
|
||||
" ON exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
"%s"
|
||||
"%s"
|
||||
" GROUP BY exa_exams.ExaCod"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
|
@ -964,7 +964,7 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
|
|||
"MaxGrade," // row[4]
|
||||
"Visibility," // row[5]
|
||||
"Title" // row[6]
|
||||
" FROM exa_exams"
|
||||
" FROM exa_exams"
|
||||
" WHERE ExaCod=%ld",
|
||||
Exam->ExaCod);
|
||||
if (NumRows) // Exam found...
|
||||
|
@ -1020,7 +1020,7 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
|
|||
NumRows = DB_QuerySELECT (&mysql_res,"can not get exam data",
|
||||
"SELECT UNIX_TIMESTAMP(MIN(StartTime))," // row[0]
|
||||
"UNIX_TIMESTAMP(MAX(EndTime))" // row[1]
|
||||
" FROM exa_sessions"
|
||||
" FROM exa_sessions"
|
||||
" WHERE ExaCod=%ld",
|
||||
Exam->ExaCod);
|
||||
if (NumRows)
|
||||
|
@ -1073,7 +1073,9 @@ void Exa_GetExamTxtFromDB (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
|
|||
|
||||
/***** Get text of exam from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get exam text",
|
||||
"SELECT Txt FROM exa_exams WHERE ExaCod=%ld",
|
||||
"SELECT Txt" // row[0]
|
||||
" FROM exa_exams"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
|
@ -1388,10 +1390,13 @@ static bool Exa_CheckIfSimilarExamExists (const struct Exa_Exam *Exam)
|
|||
{
|
||||
/***** Get number of exams with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar exams",
|
||||
"SELECT COUNT(*) FROM exa_exams"
|
||||
" WHERE CrsCod=%ld AND Title='%s'"
|
||||
" AND ExaCod<>%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,Exam->Title,
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_exams"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND Title='%s'"
|
||||
" AND ExaCod<>%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Exam->Title,
|
||||
Exam->ExaCod) != 0);
|
||||
}
|
||||
|
||||
|
@ -1770,8 +1775,10 @@ long Exa_GetQstCodFromQstInd (long ExaCod,unsigned QstInd)
|
|||
|
||||
/***** Get question code of the question to be moved up *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get question code",
|
||||
"SELECT QstCod FROM exa_set_questions"
|
||||
" WHERE ExaCod=%ld AND QstInd=%u",
|
||||
"SELECT QstCod"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
ExaCod,QstInd))
|
||||
Lay_ShowErrorAndExit ("Error: wrong question index.");
|
||||
|
||||
|
@ -1802,9 +1809,12 @@ unsigned Exa_GetPrevQuestionIndexInExam (long ExaCod,unsigned QstInd)
|
|||
// Although indexes are always continuous...
|
||||
// ...this implementation works even with non continuous indexes
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get previous question index",
|
||||
"SELECT MAX(QstInd) FROM exa_set_questions"
|
||||
" WHERE ExaCod=%ld AND QstInd<%u",
|
||||
ExaCod,QstInd))
|
||||
"SELECT MAX(QstInd)"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND QstInd<%u",
|
||||
ExaCod,
|
||||
QstInd))
|
||||
Lay_ShowErrorAndExit ("Error: previous question index not found.");
|
||||
|
||||
/***** Get previous question index (row[0]) *****/
|
||||
|
@ -1836,8 +1846,10 @@ unsigned Exa_GetNextQuestionIndexInExam (long ExaCod,unsigned QstInd)
|
|||
// Although indexes are always continuous...
|
||||
// ...this implementation works even with non continuous indexes
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get next question index",
|
||||
"SELECT MIN(QstInd) FROM exa_set_questions"
|
||||
" WHERE ExaCod=%ld AND QstInd>%u",
|
||||
"SELECT MIN(QstInd)"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND QstInd>%u",
|
||||
ExaCod,QstInd))
|
||||
Lay_ShowErrorAndExit ("Error: next question index not found.");
|
||||
|
||||
|
@ -1897,60 +1909,60 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
|||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM exa_exams");
|
||||
" FROM exa_exams");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" 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=exa_exams.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=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM crs_courses,"
|
||||
"exa_exams"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM exa_exams"
|
||||
" FROM exa_exams"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
|
@ -1987,60 +1999,60 @@ unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope)
|
|||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_exams");
|
||||
" FROM exa_exams");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" 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=exa_exams.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=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses,"
|
||||
"exa_exams"
|
||||
" FROM crs_courses,"
|
||||
"exa_exams"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_exams"
|
||||
" FROM exa_exams"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
|
@ -2075,85 +2087,86 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
|||
{
|
||||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM exa_exams,exa_set_questions"
|
||||
" WHERE exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable");
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_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=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_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=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM crs_courses,"
|
||||
"exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=exa_exams.CrsCod"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE exa_exams.Cod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||
" FROM exa_exams,"
|
||||
"exa_set_questions"
|
||||
" WHERE exa_exams.Cod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_set_questions.ExaCod"
|
||||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
|
@ -2187,9 +2200,10 @@ void Exa_GetScoreRange (long ExaCod,double *MinScore,double *MaxScore)
|
|||
NumRows = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||
"SELECT COUNT(tst_answers.AnsInd) AS N"
|
||||
" FROM tst_answers,exa_set_questions"
|
||||
" FROM tst_answers,"
|
||||
"exa_set_questions"
|
||||
" WHERE exa_set_questions.ExaCod=%ld"
|
||||
" AND exa_set_questions.QstCod=tst_answers.QstCod"
|
||||
" AND exa_set_questions.QstCod=tst_answers.QstCod"
|
||||
" GROUP BY tst_answers.QstCod",
|
||||
ExaCod);
|
||||
for (NumRow = 0, *MinScore = *MaxScore = 0.0;
|
||||
|
|
|
@ -265,7 +265,7 @@ void ExaPrn_GetDataOfPrintByPrnCod (struct ExaPrn_Print *Print)
|
|||
"NumQstsNotBlank," // row[6]
|
||||
"Sent," // row[7]
|
||||
"Score" // row[8]
|
||||
" FROM exa_prints"
|
||||
" FROM exa_prints"
|
||||
" WHERE PrnCod=%ld",
|
||||
Print->PrnCod);
|
||||
|
||||
|
@ -293,9 +293,9 @@ void ExaPrn_GetDataOfPrintBySesCodAndUsrCod (struct ExaPrn_Print *Print)
|
|||
"NumQstsNotBlank," // row[6]
|
||||
"Sent," // row[7]
|
||||
"Score" // row[8]
|
||||
" FROM exa_prints"
|
||||
" FROM exa_prints"
|
||||
" WHERE SesCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
" AND UsrCod=%ld",
|
||||
Print->SesCod,
|
||||
Print->UsrCod);
|
||||
|
||||
|
@ -374,7 +374,7 @@ static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,lon
|
|||
"SELECT SetCod," // row[0]
|
||||
"NumQstsToPrint," // row[1]
|
||||
"Title" // row[2]
|
||||
" FROM exa_sets"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld"
|
||||
" ORDER BY SetInd",
|
||||
ExaCod);
|
||||
|
@ -440,7 +440,7 @@ static unsigned ExaPrn_GetSomeQstsFromSetToPrint (struct ExaPrn_Print *Print,
|
|||
"SELECT QstCod," // row[0]
|
||||
"AnsType," // row[1]
|
||||
"Shuffle" // row[2]
|
||||
" FROM exa_set_questions"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE SetCod=%ld"
|
||||
" ORDER BY RAND()" // Don't use RAND(NOW()) because the same ordering will be repeated across sets
|
||||
" LIMIT %u",
|
||||
|
@ -617,7 +617,7 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
|
|||
"Score," // row[2]
|
||||
"Indexes," // row[3]
|
||||
"Answers" // row[4]
|
||||
" FROM exa_print_questions"
|
||||
" FROM exa_print_questions"
|
||||
" WHERE PrnCod=%ld"
|
||||
" ORDER BY QstInd",
|
||||
Print->PrnCod);
|
||||
|
@ -1276,7 +1276,7 @@ static void ExaPrn_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 exa_set_answers"
|
||||
" FROM exa_set_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ static void ExaPrn_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 exa_set_answers"
|
||||
" FROM exa_set_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -1341,7 +1341,7 @@ static void ExaPrn_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 exa_set_answers"
|
||||
" FROM exa_set_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -1366,7 +1366,7 @@ static void ExaPrn_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 exa_set_answers"
|
||||
" FROM exa_set_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY AnsInd",
|
||||
Question->QstCod);
|
||||
|
@ -1395,7 +1395,7 @@ static void ExaPrn_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 exa_set_answers"
|
||||
" FROM exa_set_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod);
|
||||
|
||||
|
@ -1437,8 +1437,9 @@ static void ExaPrn_GetAnswerFromDB (struct ExaPrn_Print *Print,long QstCod,
|
|||
/***** Get questions of an exam print from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get answer in an exam print",
|
||||
"SELECT Answers"
|
||||
" FROM exa_print_questions"
|
||||
" WHERE PrnCod=%ld AND QstCod=%ld",
|
||||
" FROM exa_print_questions"
|
||||
" WHERE PrnCod=%ld"
|
||||
" AND QstCod=%ld",
|
||||
Print->PrnCod,QstCod))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1484,11 +1485,12 @@ static void ExaPrn_GetNumQstsNotBlank (struct ExaPrn_Print *Print)
|
|||
{
|
||||
/***** Count number of questions not blank in exam print in database *****/
|
||||
Print->NumQsts.NotBlank = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of questions not blank",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_print_questions"
|
||||
" WHERE PrnCod=%ld AND Answers<>''",
|
||||
Print->PrnCod);
|
||||
DB_QueryCOUNT ("can not get number of questions not blank",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_print_questions"
|
||||
" WHERE PrnCod=%ld"
|
||||
" AND Answers<>''",
|
||||
Print->PrnCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1506,7 +1508,7 @@ static void ExaPrn_ComputeTotalScoreOfPrint (struct ExaPrn_Print *Print)
|
|||
/***** Compute total score of exam print *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get score of exam print",
|
||||
"SELECT SUM(Score)"
|
||||
" FROM exa_print_questions"
|
||||
" FROM exa_print_questions"
|
||||
" WHERE PrnCod=%ld",
|
||||
Print->PrnCod))
|
||||
{
|
||||
|
|
|
@ -436,14 +436,14 @@ static void ExaRes_ListAllResultsInExa (struct Exa_Exams *Exams,long ExaCod)
|
|||
|
||||
/***** Get all users who have answered any session question in this exam *****/
|
||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in exam",
|
||||
"SELECT users.UsrCod FROM"
|
||||
" (SELECT DISTINCT exa_prints.UsrCod AS UsrCod" // row[0]
|
||||
" FROM exa_prints,exa_sessions,exa_exams"
|
||||
" WHERE exa_sessions.ExaCod=%ld"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||
" AND exa_exams.CrsCod=%ld)" // Extra check
|
||||
" AS users,usr_data"
|
||||
"SELECT users.UsrCod" // row[0]
|
||||
" FROM (SELECT DISTINCT exa_prints.UsrCod AS UsrCod"
|
||||
" FROM exa_prints,exa_sessions,exa_exams"
|
||||
" WHERE exa_sessions.ExaCod=%ld"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||
" AND exa_exams.CrsCod=%ld) AS users," // Extra check
|
||||
"usr_data"
|
||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||
" ORDER BY usr_data.Surname1,"
|
||||
"usr_data.Surname2,"
|
||||
|
@ -532,14 +532,14 @@ static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
|||
|
||||
/***** Get all users who have answered any session question in this exam *****/
|
||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in session",
|
||||
"SELECT users.UsrCod FROM"
|
||||
" (SELECT exa_prints.UsrCod AS UsrCod" // row[0]
|
||||
" FROM exa_prints,exa_sessions,exa_exams"
|
||||
" WHERE exa_prints.SesCod=%ld"
|
||||
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||
" AND exa_exams.CrsCod=%ld)" // Extra check
|
||||
" AS users,usr_data"
|
||||
"SELECT users.UsrCod"
|
||||
" FROM (SELECT exa_prints.UsrCod AS UsrCod" // row[0]
|
||||
" FROM exa_prints,exa_sessions,exa_exams"
|
||||
" WHERE exa_prints.SesCod=%ld"
|
||||
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||
" AND exa_exams.CrsCod=%ld) AS users," // Extra check
|
||||
"usr_data"
|
||||
" WHERE users.UsrCod=usr_data.UsrCod"
|
||||
" ORDER BY usr_data.Surname1,"
|
||||
"usr_data.Surname2,"
|
||||
|
@ -923,15 +923,15 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
NumResults =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get sessions results",
|
||||
"SELECT exa_prints.PrnCod" // row[0]
|
||||
" FROM exa_prints,exa_sessions,exa_exams"
|
||||
" FROM exa_prints,exa_sessions,exa_exams"
|
||||
" WHERE exa_prints.UsrCod=%ld"
|
||||
"%s" // Session subquery
|
||||
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
||||
"%s" // Hidden sessions subquery
|
||||
"%s" // Exams subquery
|
||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||
"%s" // Hidden exams subquery
|
||||
" AND exa_exams.CrsCod=%ld" // Extra check
|
||||
"%s" // Session subquery
|
||||
" AND exa_prints.SesCod=exa_sessions.SesCod"
|
||||
"%s" // Hidden sessions subquery
|
||||
"%s" // Exams subquery
|
||||
" AND exa_sessions.ExaCod=exa_exams.ExaCod"
|
||||
"%s" // Hidden exams subquery
|
||||
" AND exa_exams.CrsCod=%ld" // Extra check
|
||||
" ORDER BY exa_sessions.Title",
|
||||
UsrDat->UsrCod,
|
||||
SesSubQuery,
|
||||
|
@ -1578,7 +1578,7 @@ static void ExaRes_ComputeValidPrintScore (struct ExaPrn_Print *Print)
|
|||
QuestionExists = (DB_QuerySELECT (&mysql_res,"can not get a question",
|
||||
"SELECT Invalid," // row[0]
|
||||
"AnsType" // row[1]
|
||||
" FROM exa_set_questions"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
Question.QstCod) != 0);
|
||||
if (QuestionExists)
|
||||
|
|
|
@ -210,7 +210,7 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams,
|
|||
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
||||
"Title," // row[7]
|
||||
"ShowUsrResults" // row[8]
|
||||
" FROM exa_sessions"
|
||||
" FROM exa_sessions"
|
||||
" WHERE ExaCod=%ld%s%s"
|
||||
" ORDER BY SesCod",
|
||||
Exam->ExaCod,HiddenSubQuery,GroupsSubQuery);
|
||||
|
@ -313,11 +313,12 @@ void ExaSes_GetDataOfSessionByCod (struct ExaSes_Session *Session)
|
|||
"NOW() BETWEEN StartTime AND EndTime," // row[6]
|
||||
"Title," // row[7]
|
||||
"ShowUsrResults" // row[8]
|
||||
" FROM exa_sessions"
|
||||
" FROM exa_sessions"
|
||||
" WHERE SesCod=%ld"
|
||||
" AND ExaCod IN" // Extra check
|
||||
" (SELECT ExaCod FROM exa_exams"
|
||||
" WHERE CrsCod='%ld')",
|
||||
" AND ExaCod IN" // Extra check
|
||||
" (SELECT ExaCod"
|
||||
" FROM exa_exams"
|
||||
" WHERE CrsCod='%ld')",
|
||||
Session->SesCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
if (NumRows) // Session found...
|
||||
|
@ -1685,7 +1686,8 @@ unsigned ExaSes_GetNumSessionsInExam (long ExaCod)
|
|||
/***** Get number of sessions in an exam from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of sessions of an exam",
|
||||
"SELECT COUNT(*) FROM exa_sessions"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_sessions"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod);
|
||||
}
|
||||
|
@ -1703,9 +1705,10 @@ unsigned ExaSes_GetNumOpenSessionsInExam (long ExaCod)
|
|||
/***** Get number of open sessions in an exam from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of open sessions of an exam",
|
||||
"SELECT COUNT(*) FROM exa_sessions"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_sessions"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND NOW() BETWEEN StartTime AND EndTime",
|
||||
" AND NOW() BETWEEN StartTime AND EndTime",
|
||||
ExaCod);
|
||||
}
|
||||
|
||||
|
@ -1718,7 +1721,9 @@ bool ExaSes_CheckIfICanAnswerThisSession (const struct Exa_Exam *Exam,
|
|||
{
|
||||
/***** 1. Sessions in hidden exams are not accesible
|
||||
2. Hidden or closed sessions are not accesible *****/
|
||||
if (Exam->Hidden || Session->Hidden || !Session->Open)
|
||||
if (Exam->Hidden ||
|
||||
Session->Hidden ||
|
||||
!Session->Open)
|
||||
return false;
|
||||
|
||||
/***** Exam is visible, session is visible and open ==>
|
||||
|
|
|
@ -190,7 +190,8 @@ static unsigned ExaSet_GetNumQstsInSet (long SetCod)
|
|||
/***** Get number of questions in set from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of questions in a set",
|
||||
"SELECT COUNT(*) FROM exa_set_questions"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE SetCod=%ld",
|
||||
SetCod);
|
||||
}
|
||||
|
@ -220,7 +221,7 @@ void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set)
|
|||
"SetInd," // row[2]
|
||||
"NumQstsToPrint," // row[3]
|
||||
"Title" // row[4]
|
||||
" FROM exa_sets"
|
||||
" FROM exa_sets"
|
||||
" WHERE SetCod=%ld",
|
||||
Set->SetCod)) // Set found...
|
||||
{
|
||||
|
@ -266,11 +267,14 @@ static bool ExaSet_CheckIfSimilarSetExists (const struct ExaSet_Set *Set,
|
|||
{
|
||||
/***** Get number of set of questions with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar sets of questions",
|
||||
"SELECT COUNT(*) FROM exa_sets,exa_exams"
|
||||
" WHERE exa_sets.ExaCod=%ld AND exa_sets.Title='%s'"
|
||||
" AND exa_sets.SetCod<>%ld"
|
||||
" AND exa_sets.ExaCod=exa_exams.ExaCod"
|
||||
" AND exa_exams.CrsCod=%ld", // Extra check
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_sets,"
|
||||
"exa_exams"
|
||||
" WHERE exa_sets.ExaCod=%ld"
|
||||
" AND exa_sets.Title='%s'"
|
||||
" AND exa_sets.SetCod<>%ld"
|
||||
" AND exa_sets.ExaCod=exa_exams.ExaCod"
|
||||
" AND exa_exams.CrsCod=%ld", // Extra check
|
||||
Set->ExaCod,Title,
|
||||
Set->SetCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod) != 0);
|
||||
|
@ -624,7 +628,8 @@ unsigned ExaSet_GetNumSetsExam (long ExaCod)
|
|||
/***** Get number of sets in an exam from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of sets in an exam",
|
||||
"SELECT COUNT(*) FROM exa_sets"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod);
|
||||
}
|
||||
|
@ -641,7 +646,8 @@ unsigned ExaSet_GetNumQstsExam (long ExaCod)
|
|||
|
||||
/***** Get total number of questions to appear in exam print *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get number of questions in an exam print",
|
||||
"SELECT SUM(NumQstsToPrint) FROM exa_sets"
|
||||
"SELECT SUM(NumQstsToPrint)"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod))
|
||||
Lay_ShowErrorAndExit ("Error: wrong question index.");
|
||||
|
@ -784,9 +790,10 @@ static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod)
|
|||
|
||||
/***** Get set index from set code *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get set index",
|
||||
"SELECT SetInd FROM exa_sets"
|
||||
"SELECT SetInd"
|
||||
" FROM exa_sets"
|
||||
" WHERE SetCod=%u"
|
||||
" AND ExaCod=%ld", // Extra check
|
||||
" AND ExaCod=%ld", // Extra check
|
||||
SetCod,ExaCod))
|
||||
Lay_ShowErrorAndExit ("Error: wrong set code.");
|
||||
|
||||
|
@ -812,8 +819,10 @@ static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd)
|
|||
|
||||
/***** Get set code from set index *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get set code",
|
||||
"SELECT SetCod FROM exa_sets"
|
||||
" WHERE ExaCod=%ld AND SetInd=%u",
|
||||
"SELECT SetCod"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND SetInd=%u",
|
||||
ExaCod,SetInd))
|
||||
Lay_ShowErrorAndExit ("Error: wrong set index.");
|
||||
|
||||
|
@ -843,7 +852,7 @@ static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod)
|
|||
/***** Get maximum set index in an exam from database *****/
|
||||
DB_QuerySELECT (&mysql_res,"can not get max set index",
|
||||
"SELECT MAX(SetInd)"
|
||||
" FROM exa_sets"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod);
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -873,8 +882,10 @@ static unsigned ExaSet_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd)
|
|||
// Although indexes are always continuous...
|
||||
// ...this implementation works even with non continuous indexes
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get previous set index",
|
||||
"SELECT MAX(SetInd) FROM exa_sets"
|
||||
" WHERE ExaCod=%ld AND SetInd<%u",
|
||||
"SELECT MAX(SetInd)"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND SetInd<%u",
|
||||
ExaCod,SetInd))
|
||||
Lay_ShowErrorAndExit ("Error: previous set index not found.");
|
||||
|
||||
|
@ -907,8 +918,10 @@ static unsigned ExaSet_GetNextSetIndexInExam (long ExaCod,unsigned SetInd)
|
|||
// Although indexes are always continuous...
|
||||
// ...this implementation works even with non continuous indexes
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get next set index",
|
||||
"SELECT MIN(SetInd) FROM exa_sets"
|
||||
" WHERE ExaCod=%ld AND SetInd>%u",
|
||||
"SELECT MIN(SetInd)"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld"
|
||||
" AND SetInd>%u",
|
||||
ExaCod,SetInd))
|
||||
Lay_ShowErrorAndExit ("Error: next set index not found.");
|
||||
|
||||
|
@ -950,7 +963,7 @@ void ExaSet_ListExamSets (struct Exa_Exams *Exams,
|
|||
"SetInd," // row[1]
|
||||
"NumQstsToPrint," // row[2]
|
||||
"Title" // row[3]
|
||||
" FROM exa_sets"
|
||||
" FROM exa_sets"
|
||||
" WHERE ExaCod=%ld"
|
||||
" ORDER BY SetInd",
|
||||
Exam->ExaCod);
|
||||
|
@ -997,7 +1010,7 @@ static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams,
|
|||
NumQsts = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get exam questions",
|
||||
"SELECT QstCod" // row[0]
|
||||
" FROM exa_set_questions"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE SetCod=%ld"
|
||||
" ORDER BY Stem",
|
||||
Set->SetCod);
|
||||
|
@ -1369,7 +1382,7 @@ Tst_AnswerType_t ExaSet_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 exa_set_questions"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod))
|
||||
Lay_ShowErrorAndExit ("Question does not exist.");
|
||||
|
@ -1403,7 +1416,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
|||
"Stem," // row[3]
|
||||
"Feedback," // row[4]
|
||||
"MedCod" // row[5]
|
||||
" FROM exa_set_questions"
|
||||
" FROM exa_set_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
Question->QstCod) != 0);
|
||||
|
||||
|
@ -1531,7 +1544,7 @@ void ExaSet_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
|
|||
"Feedback," // row[2]
|
||||
"MedCod," // row[3]
|
||||
"Correct" // row[4]
|
||||
" FROM exa_set_answers"
|
||||
" FROM exa_set_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
|
|
190
swad_figure.c
190
swad_figure.c
|
@ -1077,7 +1077,7 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" GROUP BY InsCod"
|
||||
" ORDER BY N DESC");
|
||||
break;
|
||||
|
@ -1086,10 +1086,10 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY N DESC",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
@ -1102,7 +1102,7 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ctr_centers"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" GROUP BY InsCod"
|
||||
" ORDER BY N DESC",
|
||||
|
@ -1147,8 +1147,8 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" GROUP BY InsCod"
|
||||
" ORDER BY N DESC");
|
||||
|
@ -1158,12 +1158,12 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY N DESC",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
@ -1176,10 +1176,10 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY N DESC",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
|
@ -1223,11 +1223,11 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" GROUP BY InsCod"
|
||||
" ORDER BY N DESC");
|
||||
break;
|
||||
|
@ -1236,14 +1236,14 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" 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 ins_instits.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY N DESC",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
@ -1256,12 +1256,12 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void)
|
|||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*) AS N"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY N DESC",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
|
@ -1393,7 +1393,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
|||
NumInss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT InsCod,COUNT(*) AS N"
|
||||
" FROM usr_data"
|
||||
" FROM usr_data"
|
||||
" WHERE InsCod>0"
|
||||
" GROUP BY InsCod"
|
||||
" ORDER BY N DESC");
|
||||
|
@ -1402,9 +1402,9 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
|||
NumInss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT usr_data.InsCod,COUNT(*) AS N"
|
||||
" FROM ins_instits,usr_data"
|
||||
" FROM ins_instits,usr_data"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=usr_data.InsCod"
|
||||
" AND ins_instits.InsCod=usr_data.InsCod"
|
||||
" GROUP BY usr_data.InsCod"
|
||||
" ORDER BY N DESC",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
@ -1416,7 +1416,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
|||
NumInss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT InsCod,COUNT(*) AS N"
|
||||
" FROM usr_data"
|
||||
" FROM usr_data"
|
||||
" WHERE InsCod=%ld"
|
||||
" GROUP BY InsCod"
|
||||
" ORDER BY N DESC",
|
||||
|
@ -4065,31 +4065,31 @@ static void Fig_GetAndShowFollowStats (void)
|
|||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(N) FROM " // row[0]
|
||||
"(SELECT COUNT(%s) AS N"
|
||||
" FROM usr_follow"
|
||||
" GROUP BY %s) AS F",
|
||||
"SELECT AVG(N)" // row[0]
|
||||
" FROM (SELECT COUNT(%s) AS N"
|
||||
" FROM usr_follow"
|
||||
" GROUP BY %s) AS F",
|
||||
FieldDB[Fol],
|
||||
FieldDB[1 - Fol]);
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(N) FROM " // row[0]
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" 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=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
"SELECT AVG(N)" // row[0]
|
||||
" FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" 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=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
FieldDB[Fol],
|
||||
Gbl.Hierarchy.Cty.CtyCod,
|
||||
FieldDB[Fol],
|
||||
|
@ -4098,19 +4098,19 @@ static void Fig_GetAndShowFollowStats (void)
|
|||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(N) FROM " // row[0]
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
"SELECT AVG(N)" // row[0]
|
||||
" FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
FieldDB[Fol],
|
||||
Gbl.Hierarchy.Ins.InsCod,
|
||||
FieldDB[Fol],
|
||||
|
@ -4119,17 +4119,17 @@ static void Fig_GetAndShowFollowStats (void)
|
|||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(N) FROM " // row[0]
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
"SELECT AVG(N)" // row[0]
|
||||
" FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
FieldDB[Fol],
|
||||
Gbl.Hierarchy.Ctr.CtrCod,
|
||||
FieldDB[Fol],
|
||||
|
@ -4138,15 +4138,15 @@ static void Fig_GetAndShowFollowStats (void)
|
|||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(N) FROM " // row[0]
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
"SELECT AVG(N)" // row[0]
|
||||
" FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM crs_courses,"
|
||||
"crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=crs_users.CrsCod"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
FieldDB[Fol],
|
||||
Gbl.Hierarchy.Deg.DegCod,
|
||||
FieldDB[Fol],
|
||||
|
@ -4155,13 +4155,13 @@ static void Fig_GetAndShowFollowStats (void)
|
|||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions"
|
||||
" per survey",
|
||||
"SELECT AVG(N) FROM " // row[0]
|
||||
"(SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE crs_users.CrsCod=%ld"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
"SELECT AVG(N)" // row[0]
|
||||
" FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N"
|
||||
" FROM crs_users,"
|
||||
"usr_follow"
|
||||
" WHERE crs_users.CrsCod=%ld"
|
||||
" AND crs_users.UsrCod=usr_follow.%s"
|
||||
" GROUP BY %s) AS F",
|
||||
FieldDB[Fol],
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
FieldDB[Fol],
|
||||
|
@ -5806,7 +5806,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery)
|
|||
NumUsrs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get the number of users who have chosen an option",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_data WHERE %s",
|
||||
" FROM usr_data WHERE %s",
|
||||
SubQuery);
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
|
|
|
@ -138,7 +138,7 @@ bool FigCch_GetFigureFromCache (FigCch_FigureCached_t Figure,
|
|||
/***** Get figure's value if cached and recent *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get cached figure value",
|
||||
"SELECT %s" // row[0]
|
||||
" FROM fig_figures"
|
||||
" FROM fig_figures"
|
||||
" WHERE Figure=%u"
|
||||
" AND Scope='%s'"
|
||||
" AND Cod=%ld"
|
||||
|
|
|
@ -7113,7 +7113,7 @@ static bool Brw_GetMyClipboard (void)
|
|||
"WorksUsrCod," // row[2]
|
||||
"FileType," // row[3]
|
||||
"Path" // row[4]
|
||||
" FROM brw_clipboards"
|
||||
" FROM brw_clipboards"
|
||||
" WHERE UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
|
@ -9420,12 +9420,15 @@ bool Brw_CheckIfFileOrFolderIsHidden (struct FileMetadata *FileMetadata)
|
|||
2) the argument Path begins by 'x/', where x is a path stored in database
|
||||
*/
|
||||
return (DB_QueryCOUNT ("can not check if a file or folder is hidden",
|
||||
"SELECT COUNT(*) FROM brw_files"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM brw_files"
|
||||
" WHERE FileBrowser=%u"
|
||||
" AND Cod=%ld"
|
||||
" AND ZoneUsrCod=%ld"
|
||||
" AND Hidden='Y'"
|
||||
" AND (Path='%s' OR LOCATE(CONCAT(Path,'/'),'%s')=1)",
|
||||
" AND (Path='%s'"
|
||||
" OR"
|
||||
" LOCATE(CONCAT(Path,'/'),'%s')=1)",
|
||||
FileMetadata->FileBrowser,
|
||||
FileMetadata->Cod,
|
||||
FileMetadata->ZoneUsrCod,
|
||||
|
@ -10382,7 +10385,8 @@ long Brw_GetFilCodByPath (const char *Path,bool OnlyIfPublic)
|
|||
" WHERE FileBrowser=%u"
|
||||
" AND Cod=%ld"
|
||||
" AND ZoneUsrCod=%ld"
|
||||
" AND Path='%s'%s",
|
||||
" AND Path='%s'"
|
||||
"%s",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,ZoneUsrCod,
|
||||
Path,
|
||||
|
@ -11758,7 +11762,9 @@ static long Brw_GetPublisherOfSubtree (void)
|
|||
" FROM brw_files"
|
||||
" WHERE FileBrowser=%u"
|
||||
" AND Cod=%ld"
|
||||
" AND (Path='%s' OR Path LIKE '%s/%%')",
|
||||
" AND (Path='%s'"
|
||||
" OR"
|
||||
" Path LIKE '%s/%%')",
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,
|
||||
Gbl.FileBrowser.FilFolLnk.Full,
|
||||
|
|
|
@ -135,9 +135,9 @@ void Fir_CheckFirewallAndExitIfTooManyRequests (void)
|
|||
/***** Get number of clicks from database *****/
|
||||
NumClicks = DB_QueryCOUNT ("can not check firewall log",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM fir_log"
|
||||
" FROM fir_log"
|
||||
" WHERE IP='%s'"
|
||||
" AND ClickTime>FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
" AND ClickTime>FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
|
||||
Gbl.IP,
|
||||
Fw_CHECK_INTERVAL);
|
||||
|
||||
|
|
|
@ -461,8 +461,10 @@ bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod)
|
|||
|
||||
/***** Check if a user is a follower of another user *****/
|
||||
return (DB_QueryCOUNT ("can not get if a user is a follower of another one",
|
||||
"SELECT COUNT(*) FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld"
|
||||
" AND FollowedCod=%ld",
|
||||
FollowerCod,FollowedCod) != 0);
|
||||
}
|
||||
|
||||
|
@ -499,12 +501,14 @@ void Fol_GetNumFollow (long UsrCod,
|
|||
Gbl.Cache.Follow.UsrCod = UsrCod;
|
||||
*NumFollowing = Gbl.Cache.Follow.NumFollowing =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of followed",
|
||||
"SELECT COUNT(*) FROM usr_follow"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld",
|
||||
UsrCod);
|
||||
*NumFollowers = Gbl.Cache.Follow.NumFollowers =
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of followers",
|
||||
"SELECT COUNT(*) FROM usr_follow"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_follow"
|
||||
" WHERE FollowedCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
@ -681,7 +685,8 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
|||
{
|
||||
/***** Check if a user is a follower of another user *****/
|
||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get followed users",
|
||||
"SELECT FollowedCod FROM usr_follow"
|
||||
"SELECT FollowedCod"
|
||||
" FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld"
|
||||
" ORDER BY FollowTime DESC",
|
||||
UsrDat->UsrCod);
|
||||
|
@ -765,7 +770,8 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
|||
{
|
||||
/***** Check if a user is a follower of another user *****/
|
||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get followers",
|
||||
"SELECT FollowerCod FROM usr_follow"
|
||||
"SELECT FollowerCod"
|
||||
" FROM usr_follow"
|
||||
" WHERE FollowedCod=%ld"
|
||||
" ORDER BY FollowTime DESC",
|
||||
UsrDat->UsrCod);
|
||||
|
@ -1372,9 +1378,9 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
case Hie_Lvl_SYS:
|
||||
NumUsrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get ranking",
|
||||
"SELECT FollowedCod,"
|
||||
"COUNT(FollowerCod) AS N"
|
||||
" FROM usr_follow"
|
||||
"SELECT FollowedCod," // row[0]
|
||||
"COUNT(FollowerCod) AS N" // row[1]
|
||||
" FROM usr_follow"
|
||||
" GROUP BY FollowedCod"
|
||||
" ORDER BY N DESC,"
|
||||
"FollowedCod"
|
||||
|
@ -1526,8 +1532,8 @@ void Fol_CreateTmpTableMeAndUsrsIFollow (void)
|
|||
" SELECT %ld AS UsrCod" // Me
|
||||
" UNION"
|
||||
" SELECT FollowedCod AS UsrCod" // Users I follow
|
||||
" FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld",
|
||||
" FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
|
342
swad_game.c
342
swad_game.c
|
@ -899,11 +899,11 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
|||
"SELECT gam_games.GamCod," // row[0]
|
||||
"MIN(mch_matches.StartTime) AS StartTime," // row[1]
|
||||
"MAX(mch_matches.EndTime) AS EndTime" // row[2]
|
||||
" FROM gam_games"
|
||||
" LEFT JOIN mch_matches"
|
||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||
" FROM gam_games"
|
||||
" LEFT JOIN mch_matches"
|
||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
"%s"
|
||||
"%s"
|
||||
" GROUP BY gam_games.GamCod"
|
||||
" ORDER BY %s",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
|
@ -1028,11 +1028,11 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game)
|
|||
"gam_games.MaxGrade," // row[4]
|
||||
"gam_games.Visibility," // row[5]
|
||||
"gam_games.Title" // row[6]
|
||||
" FROM gam_games"
|
||||
" LEFT JOIN mch_matches"
|
||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||
" FROM gam_games"
|
||||
" LEFT JOIN mch_matches"
|
||||
" ON gam_games.GamCod=mch_matches.GamCod"
|
||||
" WHERE gam_games.GamCod=%ld"
|
||||
" AND gam_games.CrsCod='%ld'", // Extra check
|
||||
" AND gam_games.CrsCod='%ld'", // Extra check
|
||||
Game->GamCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
if (NumRows) // Game found...
|
||||
|
@ -1138,7 +1138,9 @@ static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
|
|||
|
||||
/***** Get text of game from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get game text",
|
||||
"SELECT Txt FROM gam_games WHERE GamCod=%ld",
|
||||
"SELECT Txt"
|
||||
" FROM gam_games"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
|
@ -1350,10 +1352,13 @@ static bool Gam_CheckIfSimilarGameExists (const struct Gam_Game *Game)
|
|||
{
|
||||
/***** Get number of games with a field value from database *****/
|
||||
return (DB_QueryCOUNT ("can not get similar games",
|
||||
"SELECT COUNT(*) FROM gam_games"
|
||||
" WHERE CrsCod=%ld AND Title='%s'"
|
||||
" AND GamCod<>%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,Game->Title,
|
||||
"SELECT COUNT(*)"
|
||||
" FROM gam_games"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND Title='%s'"
|
||||
" AND GamCod<>%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Game->Title,
|
||||
Game->GamCod) != 0);
|
||||
}
|
||||
|
||||
|
@ -1724,11 +1729,12 @@ static void Gam_UpdateGame (struct Gam_Game *Game,const char *Txt)
|
|||
unsigned Gam_GetNumQstsGame (long GamCod)
|
||||
{
|
||||
/***** Get nuumber of questions in a game from database *****/
|
||||
return
|
||||
(unsigned) DB_QueryCOUNT ("can not get number of questions of a game",
|
||||
"SELECT COUNT(*) FROM gam_questions"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of questions of a game",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM gam_questions"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1846,9 +1852,12 @@ static unsigned Gam_GetQstIndFromQstCod (long GamCod,long QstCod)
|
|||
|
||||
/***** Get question index in a game given the question code *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get question index",
|
||||
"SELECT QstInd FROM gam_questions"
|
||||
" WHERE GamCod=%ld AND QstCod=%ld",
|
||||
GamCod,QstCod))
|
||||
"SELECT QstInd" // row[0]
|
||||
" FROM gam_questions"
|
||||
" WHERE GamCod=%ld"
|
||||
" AND QstCod=%ld",
|
||||
GamCod,
|
||||
QstCod))
|
||||
{
|
||||
/***** Get question code (row[0]) *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1875,8 +1884,10 @@ long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd)
|
|||
|
||||
/***** Get question code of the question to be moved up *****/
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get question code",
|
||||
"SELECT QstCod FROM gam_questions"
|
||||
" WHERE GamCod=%ld AND QstInd=%u",
|
||||
"SELECT QstCod"
|
||||
" FROM gam_questions"
|
||||
" WHERE GamCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
GamCod,QstInd))
|
||||
Lay_ShowErrorAndExit ("Error: wrong question index.");
|
||||
|
||||
|
@ -1906,7 +1917,7 @@ static unsigned Gam_GetMaxQuestionIndexInGame (long GamCod)
|
|||
/***** Get maximum question index in a game from database *****/
|
||||
DB_QuerySELECT (&mysql_res,"can not get last question index",
|
||||
"SELECT MAX(QstInd)"
|
||||
" FROM gam_questions"
|
||||
" FROM gam_questions"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1936,9 +1947,12 @@ unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd)
|
|||
// Although indexes are always continuous...
|
||||
// ...this implementation works even with non continuous indexes
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get previous question index",
|
||||
"SELECT MAX(QstInd) FROM gam_questions"
|
||||
" WHERE GamCod=%ld AND QstInd<%u",
|
||||
GamCod,QstInd))
|
||||
"SELECT MAX(QstInd)" // row[0]
|
||||
" FROM gam_questions"
|
||||
" WHERE GamCod=%ld"
|
||||
" AND QstInd<%u",
|
||||
GamCod,
|
||||
QstInd))
|
||||
Lay_ShowErrorAndExit ("Error: previous question index not found.");
|
||||
|
||||
/***** Get previous question index (row[0]) *****/
|
||||
|
@ -1970,9 +1984,12 @@ unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd)
|
|||
// Although indexes are always continuous...
|
||||
// ...this implementation works even with non continuous indexes
|
||||
if (!DB_QuerySELECT (&mysql_res,"can not get next question index",
|
||||
"SELECT MIN(QstInd) FROM gam_questions"
|
||||
" WHERE GamCod=%ld AND QstInd>%u",
|
||||
GamCod,QstInd))
|
||||
"SELECT MIN(QstInd)"
|
||||
" FROM gam_questions"
|
||||
" WHERE GamCod=%ld"
|
||||
" AND QstInd>%u",
|
||||
GamCod,
|
||||
QstInd))
|
||||
Lay_ShowErrorAndExit ("Error: next question index not found.");
|
||||
|
||||
/***** Get next question index (row[0]) *****/
|
||||
|
@ -2005,7 +2022,7 @@ static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game
|
|||
DB_QuerySELECT (&mysql_res,"can not get game questions",
|
||||
"SELECT QstInd," // row[0]
|
||||
"QstCod" // row[1]
|
||||
" FROM gam_questions"
|
||||
" FROM gam_questions"
|
||||
" WHERE GamCod=%ld"
|
||||
" ORDER BY QstInd",
|
||||
Game->GamCod);
|
||||
|
@ -2666,60 +2683,60 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with games",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM gam_games");
|
||||
" FROM gam_games");
|
||||
case Hie_Lvl_CTY:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with games",
|
||||
"SELECT COUNT(DISTINCT gam_games.CrsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" 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=gam_games.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=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
case Hie_Lvl_INS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with games",
|
||||
"SELECT COUNT(DISTINCT gam_games.CrsCod)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
case Hie_Lvl_CTR:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with games",
|
||||
"SELECT COUNT(DISTINCT gam_games.CrsCod)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
case Hie_Lvl_DEG:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with games",
|
||||
"SELECT COUNT(DISTINCT gam_games.CrsCod)"
|
||||
" FROM crs_courses,"
|
||||
"gam_games"
|
||||
" FROM crs_courses,"
|
||||
"gam_games"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
case Hie_Lvl_CRS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of courses with games",
|
||||
"SELECT COUNT(DISTINCT CrsCod)"
|
||||
" FROM gam_games"
|
||||
" FROM gam_games"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
|
@ -2741,60 +2758,60 @@ unsigned Gam_GetNumGames (Hie_Lvl_Level_t Scope)
|
|||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of games",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM gam_games");
|
||||
" FROM gam_games");
|
||||
case Hie_Lvl_CTY:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of games",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" 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=gam_games.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=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
case Hie_Lvl_INS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of games",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
case Hie_Lvl_CTR:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of games",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
case Hie_Lvl_DEG:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of games",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_courses,"
|
||||
"gam_games"
|
||||
" FROM crs_courses,"
|
||||
"gam_games"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
case Hie_Lvl_CRS:
|
||||
return (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of games",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM gam_games"
|
||||
" FROM gam_games"
|
||||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
|
@ -2817,86 +2834,86 @@ double Gam_GetNumQstsPerCrsGame (Hie_Lvl_Level_t Scope)
|
|||
{
|
||||
case Hie_Lvl_SYS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable");
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable");
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_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=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_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=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE ctr_centers.InsCod=%ld"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM deg_degrees,"
|
||||
"crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE deg_degrees.CtrCod=%ld"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM crs_courses,"
|
||||
"gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE crs_courses.DegCod=%ld"
|
||||
" AND crs_courses.CrsCod=gam_games.CrsCod"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per game",
|
||||
"SELECT AVG(NumQsts) FROM"
|
||||
" (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE gam_games.Cod=%ld"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
"SELECT AVG(NumQsts)"
|
||||
" FROM (SELECT COUNT(gam_questions.QstCod) AS NumQsts"
|
||||
" FROM gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE gam_games.Cod=%ld"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod"
|
||||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
|
@ -2925,18 +2942,16 @@ void Gam_ShowTstTagsPresentInAGame (long GamCod)
|
|||
|
||||
/***** Get all tags of questions in this game *****/
|
||||
NumTags = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get tags"
|
||||
" present in a match result",
|
||||
"SELECT tst_tags.TagTxt" // row[0]
|
||||
" FROM"
|
||||
" (SELECT DISTINCT(tst_question_tags.TagCod)"
|
||||
" FROM tst_question_tags,gam_questions"
|
||||
" WHERE gam_questions.GamCod=%ld"
|
||||
" AND gam_questions.QstCod=tst_question_tags.QstCod)"
|
||||
" AS TagsCods,tst_tags"
|
||||
" WHERE TagsCods.TagCod=tst_tags.TagCod"
|
||||
" ORDER BY tst_tags.TagTxt",
|
||||
GamCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get tags present in a match result",
|
||||
"SELECT tst_tags.TagTxt" // row[0]
|
||||
" FROM (SELECT DISTINCT(tst_question_tags.TagCod)"
|
||||
" FROM tst_question_tags,gam_questions"
|
||||
" WHERE gam_questions.GamCod=%ld"
|
||||
" AND gam_questions.QstCod=tst_question_tags.QstCod) AS TagsCods,"
|
||||
"tst_tags"
|
||||
" WHERE TagsCods.TagCod=tst_tags.TagCod"
|
||||
" ORDER BY tst_tags.TagTxt",
|
||||
GamCod);
|
||||
Tst_ShowTagList (NumTags,mysql_res);
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
@ -2957,13 +2972,14 @@ void Gam_GetScoreRange (long GamCod,double *MinScore,double *MaxScore)
|
|||
|
||||
/***** Get maximum score of a game from database *****/
|
||||
NumRows = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||
"SELECT COUNT(tst_answers.AnsInd) AS N"
|
||||
" FROM tst_answers,gam_questions"
|
||||
" WHERE gam_questions.GamCod=%ld"
|
||||
" AND gam_questions.QstCod=tst_answers.QstCod"
|
||||
" GROUP BY tst_answers.QstCod",
|
||||
GamCod);
|
||||
DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
||||
"SELECT COUNT(tst_answers.AnsInd) AS N"
|
||||
" FROM tst_answers,"
|
||||
"gam_questions"
|
||||
" WHERE gam_questions.GamCod=%ld"
|
||||
" AND gam_questions.QstCod=tst_answers.QstCod"
|
||||
" GROUP BY tst_answers.QstCod",
|
||||
GamCod);
|
||||
for (NumRow = 0, *MinScore = *MaxScore = 0.0;
|
||||
NumRow < NumRows;
|
||||
NumRow++)
|
||||
|
|
30
swad_group.c
30
swad_group.c
|
@ -1770,9 +1770,13 @@ static bool Grp_CheckIfAssociatedToGrp (const char *Table,const char *Field,
|
|||
/***** Get if an assignment, attendance event, survey, exam event or match
|
||||
is associated to a given group from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if associated to a group",
|
||||
"SELECT COUNT(*) FROM %s"
|
||||
" WHERE %s=%ld AND GrpCod=%ld",
|
||||
Table,Field,Cod,GrpCod) != 0);
|
||||
"SELECT COUNT(*)"
|
||||
" FROM %s"
|
||||
" WHERE %s=%ld"
|
||||
" AND GrpCod=%ld",
|
||||
Table,
|
||||
Field,Cod,
|
||||
GrpCod) != 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1790,9 +1794,11 @@ bool Grp_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod)
|
|||
/***** Get if an assignment, attendance event, survey, exam event or match
|
||||
is associated to any group from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if associated to groups",
|
||||
"SELECT COUNT(*) FROM %s"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM %s"
|
||||
" WHERE %s=%ld",
|
||||
Table,Field,Cod) != 0);
|
||||
Table,
|
||||
Field,Cod) != 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3090,13 +3096,13 @@ unsigned long Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res)
|
|||
/***** Get groups of a type from database *****/
|
||||
// Don't use INNER JOIN because there are groups without assigned room
|
||||
return DB_QuerySELECT (mysql_res,"can not get groups of a type",
|
||||
"SELECT grp_groups.GrpCod,"
|
||||
"grp_groups.GrpName,"
|
||||
"grp_groups.RooCod,"
|
||||
"roo_rooms.ShortName,"
|
||||
"grp_groups.MaxStudents,"
|
||||
"grp_groups.Open,"
|
||||
"grp_groups.FileZones"
|
||||
"SELECT grp_groups.GrpCod," // row[0]
|
||||
"grp_groups.GrpName," // row[1]
|
||||
"grp_groups.RooCod," // row[2]
|
||||
"roo_rooms.ShortName," // row[3]
|
||||
"grp_groups.MaxStudents," // row[4]
|
||||
"grp_groups.Open," // row[5]
|
||||
"grp_groups.FileZones" // row[6]
|
||||
" FROM grp_groups"
|
||||
" LEFT JOIN roo_rooms"
|
||||
" ON grp_groups.RooCod=roo_rooms.RooCod"
|
||||
|
|
|
@ -660,44 +660,48 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
|||
struct Hie_Hierarchy Hie;
|
||||
|
||||
/***** Get institutions, centers, degrees admin by user from database *****/
|
||||
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions,"
|
||||
" centers, degrees"
|
||||
" admin by a user",
|
||||
"(SELECT %u AS S,-1 AS Cod,'' AS FullName"
|
||||
" FROM usr_admins"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s')"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,"
|
||||
"usr_admins.Cod,"
|
||||
"ins_instits.FullName"
|
||||
" FROM usr_admins,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.UsrCod=%ld"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ins_instits.InsCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,"
|
||||
"usr_admins.Cod,"
|
||||
"ctr_centers.FullName"
|
||||
" FROM usr_admins,"
|
||||
"ctr_centers"
|
||||
" WHERE usr_admins.UsrCod=%ld"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ctr_centers.CtrCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S,"
|
||||
"usr_admins.Cod,"
|
||||
"deg_degrees.FullName"
|
||||
" FROM usr_admins,deg_degrees"
|
||||
" WHERE usr_admins.UsrCod=%ld"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod)"
|
||||
" ORDER BY S,FullName",
|
||||
(unsigned) Hie_Lvl_SYS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_SYS),
|
||||
(unsigned) Hie_Lvl_INS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_INS),
|
||||
(unsigned) Hie_Lvl_CTR,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_CTR),
|
||||
(unsigned) Hie_Lvl_DEG,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG));
|
||||
NumRows = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get institutions, centers, degrees"
|
||||
" admin by a user",
|
||||
"(SELECT %u AS S," // row[0]
|
||||
"-1 AS Cod," // row[1]
|
||||
"'' AS FullName" // row[2]
|
||||
" FROM usr_admins"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s')"
|
||||
" UNION "
|
||||
"(SELECT %u AS S," // row[0]
|
||||
"usr_admins.Cod," // row[1]
|
||||
"ins_instits.FullName" // row[2]
|
||||
" FROM usr_admins,"
|
||||
"ins_instits"
|
||||
" WHERE usr_admins.UsrCod=%ld"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ins_instits.InsCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S," // row[0]
|
||||
"usr_admins.Cod," // row[1]
|
||||
"ctr_centers.FullName" // row[2]
|
||||
" FROM usr_admins,"
|
||||
"ctr_centers"
|
||||
" WHERE usr_admins.UsrCod=%ld"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=ctr_centers.CtrCod)"
|
||||
" UNION "
|
||||
"(SELECT %u AS S," // row[0]
|
||||
"usr_admins.Cod," // row[1]
|
||||
"deg_degrees.FullName" // row[2]
|
||||
" FROM usr_admins,"
|
||||
"deg_degrees"
|
||||
" WHERE usr_admins.UsrCod=%ld"
|
||||
" AND usr_admins.Scope='%s'"
|
||||
" AND usr_admins.Cod=deg_degrees.DegCod)"
|
||||
" ORDER BY S,"
|
||||
"FullName",
|
||||
(unsigned) Hie_Lvl_SYS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_SYS),
|
||||
(unsigned) Hie_Lvl_INS,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_INS),
|
||||
(unsigned) Hie_Lvl_CTR,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_CTR),
|
||||
(unsigned) Hie_Lvl_DEG,UsrCod,Sco_GetDBStrFromScope (Hie_Lvl_DEG));
|
||||
if (NumRows)
|
||||
/***** Get the list of degrees *****/
|
||||
for (NumRow = 1;
|
||||
|
|
|
@ -1375,7 +1375,9 @@ int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
|
|||
|
||||
/***** Get number of indicators of a course from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get number of indicators",
|
||||
"SELECT NumIndicators FROM crs_courses WHERE CrsCod=%ld",
|
||||
"SELECT NumIndicators"
|
||||
" FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod))
|
||||
{
|
||||
/***** Get row *****/
|
||||
|
|
69
swad_info.c
69
swad_info.c
|
@ -506,8 +506,11 @@ static bool Inf_CheckIfIHaveReadInfo (void)
|
|||
{
|
||||
/***** Get if info source is already stored in database *****/
|
||||
return (DB_QueryCOUNT ("can not get if I have read course info",
|
||||
"SELECT COUNT(*) FROM crs_info_read"
|
||||
" WHERE UsrCod=%ld AND CrsCod=%ld AND InfoType='%s'",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_info_read"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Inf_NamesInDBForInfoType[Gbl.Crs.Info.Type]) != 0);
|
||||
|
@ -534,11 +537,15 @@ bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void)
|
|||
/***** Get info types where students must read info *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get if you must read"
|
||||
" any course info",
|
||||
"SELECT InfoType FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld AND MustBeRead='Y'"
|
||||
" AND InfoType NOT IN"
|
||||
" (SELECT InfoType FROM crs_info_read"
|
||||
" WHERE UsrCod=%ld AND CrsCod=%ld)",
|
||||
"SELECT InfoType"
|
||||
" FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND MustBeRead='Y'"
|
||||
" AND InfoType NOT IN"
|
||||
" (SELECT InfoType"
|
||||
" FROM crs_info_read"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld)",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
|
@ -1408,23 +1415,30 @@ void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc)
|
|||
{
|
||||
/***** Get if info source is already stored in database *****/
|
||||
if (DB_QueryCOUNT ("can not get if info source is already stored in database",
|
||||
"SELECT COUNT(*) FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Inf_NamesInDBForInfoType[Gbl.Crs.Info.Type]))
|
||||
// Info is already stored in database, so update it
|
||||
{ // Update info source
|
||||
if (InfoSrc == Inf_INFO_SRC_NONE)
|
||||
DB_QueryUPDATE ("can not update info source",
|
||||
"UPDATE crs_info_src SET InfoSrc='%s',MustBeRead='N'"
|
||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||
"UPDATE crs_info_src"
|
||||
" SET InfoSrc='%s',"
|
||||
"MustBeRead='N'"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
Inf_NamesInDBForInfoSrc[Inf_INFO_SRC_NONE],
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Inf_NamesInDBForInfoType[Gbl.Crs.Info.Type]);
|
||||
else // MustBeRead remains unchanged
|
||||
DB_QueryUPDATE ("can not update info source",
|
||||
"UPDATE crs_info_src SET InfoSrc='%s'"
|
||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||
"UPDATE crs_info_src"
|
||||
" SET InfoSrc='%s'"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
Inf_NamesInDBForInfoSrc[InfoSrc],
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Inf_NamesInDBForInfoType[Gbl.Crs.Info.Type]);
|
||||
|
@ -1453,9 +1467,12 @@ Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType)
|
|||
|
||||
/***** Get info source for a specific type of info from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get info source",
|
||||
"SELECT InfoSrc FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||
CrsCod,Inf_NamesInDBForInfoType[InfoType]))
|
||||
"SELECT InfoSrc"
|
||||
" FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
CrsCod,
|
||||
Inf_NamesInDBForInfoType[InfoType]))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1491,9 +1508,13 @@ void Inf_GetAndCheckInfoSrcFromDB (struct Syl_Syllabus *Syllabus,
|
|||
|
||||
/***** Get info source for a specific type of info from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get info source",
|
||||
"SELECT InfoSrc,MustBeRead FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||
CrsCod,Inf_NamesInDBForInfoType[InfoType]);
|
||||
"SELECT InfoSrc,"
|
||||
"MustBeRead"
|
||||
" FROM crs_info_src"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
CrsCod,
|
||||
Inf_NamesInDBForInfoType[InfoType]);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
if (NumRows == 1)
|
||||
|
@ -1647,9 +1668,13 @@ void Inf_GetInfoTxtFromDB (long CrsCod,Inf_InfoType_t InfoType,
|
|||
/***** Get info source for a specific type of course information
|
||||
(bibliography, FAQ, links or evaluation) from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get info text",
|
||||
"SELECT InfoTxtHTML,InfoTxtMD FROM crs_info_txt"
|
||||
" WHERE CrsCod=%ld AND InfoType='%s'",
|
||||
CrsCod,Inf_NamesInDBForInfoType[InfoType]);
|
||||
"SELECT InfoTxtHTML,"
|
||||
"InfoTxtMD"
|
||||
" FROM crs_info_txt"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
CrsCod,
|
||||
Inf_NamesInDBForInfoType[InfoType]);
|
||||
|
||||
/***** The result of the query must have one row or none *****/
|
||||
if (NumRows == 1)
|
||||
|
|
|
@ -131,36 +131,34 @@ void Ins_SeeInsWithPendingCtrs (void)
|
|||
switch (Gbl.Usrs.Me.Role.Logged)
|
||||
{
|
||||
case Rol_INS_ADM:
|
||||
NumInss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions"
|
||||
" with pending centers",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"ins_admin,"
|
||||
"ins_instits"
|
||||
" WHERE (ctr_centers.Status & %u)<>0"
|
||||
" AND ctr_centers.InsCod=ins_admin.InsCod"
|
||||
" AND ins_admin.UsrCod=%ld"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY ins_instits.ShortName",
|
||||
(unsigned) Ctr_STATUS_BIT_PENDING,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
NumInss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get institutions with pending centers",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"ins_admin,"
|
||||
"ins_instits"
|
||||
" WHERE (ctr_centers.Status & %u)<>0"
|
||||
" AND ctr_centers.InsCod=ins_admin.InsCod"
|
||||
" AND ins_admin.UsrCod=%ld"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY ins_instits.ShortName",
|
||||
(unsigned) Ctr_STATUS_BIT_PENDING,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Rol_SYS_ADM:
|
||||
NumInss =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions"
|
||||
" with pending centers",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"ins_instits"
|
||||
" WHERE (ctr_centers.Status & %u)<>0"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY ins_instits.ShortName",
|
||||
(unsigned) Ctr_STATUS_BIT_PENDING);
|
||||
NumInss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get institutions with pending centers",
|
||||
"SELECT ctr_centers.InsCod,"
|
||||
"COUNT(*)"
|
||||
" FROM ctr_centers,"
|
||||
"ins_instits"
|
||||
" WHERE (ctr_centers.Status & %u)<>0"
|
||||
" AND ctr_centers.InsCod=ins_instits.InsCod"
|
||||
" GROUP BY ctr_centers.InsCod"
|
||||
" ORDER BY ins_instits.ShortName",
|
||||
(unsigned) Ctr_STATUS_BIT_PENDING);
|
||||
break;
|
||||
default: // Forbidden for other users
|
||||
return;
|
||||
|
@ -643,7 +641,7 @@ void Ins_GetBasicListOfInstitutions (long CtyCod)
|
|||
"ShortName," // row[4]
|
||||
"FullName," // row[5]
|
||||
"WWW" // row[6]
|
||||
" FROM ins_instits"
|
||||
" FROM ins_instits"
|
||||
" WHERE CtyCod=%ld"
|
||||
" ORDER BY FullName",
|
||||
CtyCod);
|
||||
|
@ -710,11 +708,12 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
|||
"ins_instits.RequesterUsrCod," // row[3]
|
||||
"ins_instits.ShortName," // row[4]
|
||||
"ins_instits.FullName," // row[5]
|
||||
"ins_instits.WWW," // row[6]
|
||||
"ins_instits.WWW," // row[6]
|
||||
"COUNT(*) AS NumUsrs" // row[7]
|
||||
" FROM ins_instits,usr_data"
|
||||
" FROM ins_instits,"
|
||||
"usr_data"
|
||||
" WHERE ins_instits.CtyCod=%ld"
|
||||
" AND ins_instits.InsCod=usr_data.InsCod"
|
||||
" AND ins_instits.InsCod=usr_data.InsCod"
|
||||
" GROUP BY ins_instits.InsCod)"
|
||||
" UNION "
|
||||
"(SELECT InsCod," // row[0]
|
||||
|
@ -725,12 +724,15 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
|||
"FullName," // row[5]
|
||||
"WWW," // row[6]
|
||||
"0 AS NumUsrs" // row[7]
|
||||
" FROM ins_instits"
|
||||
" WHERE CtyCod=%ld"
|
||||
" AND InsCod NOT IN"
|
||||
" (SELECT DISTINCT InsCod FROM usr_data))"
|
||||
" ORDER BY %s",
|
||||
CtyCod,CtyCod,OrderBySubQuery[Gbl.Hierarchy.Inss.SelectedOrder]);
|
||||
" FROM ins_instits"
|
||||
" WHERE CtyCod=%ld"
|
||||
" AND InsCod NOT IN"
|
||||
" (SELECT DISTINCT InsCod"
|
||||
" FROM usr_data))"
|
||||
" ORDER BY %s",
|
||||
CtyCod,
|
||||
CtyCod,
|
||||
OrderBySubQuery[Gbl.Hierarchy.Inss.SelectedOrder]);
|
||||
|
||||
if (NumRows) // Institutions found...
|
||||
{
|
||||
|
@ -818,7 +820,8 @@ bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins)
|
|||
"ShortName," // row[4]
|
||||
"FullName," // row[5]
|
||||
"WWW" // row[6]
|
||||
" FROM ins_instits WHERE InsCod=%ld",
|
||||
" FROM ins_instits"
|
||||
" WHERE InsCod=%ld",
|
||||
Ins->InsCod)) // Institution found...
|
||||
{
|
||||
/* Get institution data */
|
||||
|
@ -898,7 +901,8 @@ void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
|
|||
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name"
|
||||
" of an institution",
|
||||
"SELECT ShortName FROM ins_instits"
|
||||
"SELECT ShortName"
|
||||
" FROM ins_instits"
|
||||
" WHERE InsCod=%ld",
|
||||
Ins->InsCod) == 1)
|
||||
{
|
||||
|
@ -961,10 +965,10 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins,
|
|||
" of an institution",
|
||||
"SELECT ins_instits.ShortName," // row[0]
|
||||
"cty_countrs.Name_%s" // row[1]
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
" FROM ins_instits,"
|
||||
"cty_countrs"
|
||||
" WHERE ins_instits.InsCod=%ld"
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod",
|
||||
" AND ins_instits.CtyCod=cty_countrs.CtyCod",
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language],Ins->InsCod) == 1)
|
||||
{
|
||||
/* Get row */
|
||||
|
@ -1039,7 +1043,7 @@ void Ins_WriteSelectorOfInstitution (void)
|
|||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||
"SELECT DISTINCT InsCod,"
|
||||
"ShortName"
|
||||
" FROM ins_instits"
|
||||
" FROM ins_instits"
|
||||
" WHERE CtyCod=%ld"
|
||||
" ORDER BY ShortName",
|
||||
Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
@ -1533,8 +1537,11 @@ bool Ins_CheckIfInsNameExistsInCty (const char *FieldName,
|
|||
/***** Get number of institutions in current country with a name from database *****/
|
||||
return (DB_QueryCOUNT ("can not check if the name of an institution"
|
||||
" already existed",
|
||||
"SELECT COUNT(*) FROM ins_instits"
|
||||
" WHERE CtyCod=%ld AND %s='%s' AND InsCod<>%ld",
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits"
|
||||
" WHERE CtyCod=%ld"
|
||||
" AND %s='%s'"
|
||||
" AND InsCod<>%ld",
|
||||
CtyCod,FieldName,Name,InsCod) != 0);
|
||||
}
|
||||
|
||||
|
@ -1970,7 +1977,8 @@ unsigned Ins_GetNumInssInCty (long CtyCod)
|
|||
Gbl.Cache.NumInssInCty.NumInss =
|
||||
(unsigned) DB_QueryCOUNT ("can not get the number of institutions"
|
||||
" in a country",
|
||||
"SELECT COUNT(*) FROM ins_instits"
|
||||
"SELECT COUNT(*)"
|
||||
" FROM ins_instits"
|
||||
" WHERE CtyCod=%ld",
|
||||
CtyCod);
|
||||
Gbl.Cache.NumInssInCty.Valid = true;
|
||||
|
@ -2009,8 +2017,8 @@ unsigned Ins_GetCachedNumInssWithCtrs (const char *SubQuery,
|
|||
NumInssWithCtrs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of institutions with centers",
|
||||
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers"
|
||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod",
|
||||
SubQuery);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CTRS,Scope,Cod,
|
||||
|
@ -2037,11 +2045,11 @@ unsigned Ins_GetCachedNumInssWithDegs (const char *SubQuery,
|
|||
NumInssWithDegs = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of institutions with degrees",
|
||||
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees"
|
||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod",
|
||||
SubQuery);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_DEGS,Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithDegs);
|
||||
|
@ -2067,13 +2075,13 @@ unsigned Ins_GetCachedNumInssWithCrss (const char *SubQuery,
|
|||
NumInssWithCrss = (unsigned)
|
||||
DB_QueryCOUNT ("can not get number of institutions with courses",
|
||||
"SELECT COUNT(DISTINCT ins_instits.InsCod)"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" FROM ins_instits,"
|
||||
"ctr_centers,"
|
||||
"deg_degrees,"
|
||||
"crs_courses"
|
||||
" WHERE %sinstitutions.InsCod=ctr_centers.InsCod"
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
" AND ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||
" AND deg_degrees.DegCod=crs_courses.DegCod",
|
||||
SubQuery);
|
||||
FigCch_UpdateFigureIntoCache (FigCch_NUM_INSS_WITH_CRSS,Scope,Cod,
|
||||
FigCch_UNSIGNED,&NumInssWithCrss);
|
||||
|
@ -2240,9 +2248,12 @@ bool Ins_GetIfMapIsAvailable (long InsCod)
|
|||
(coordinates 0, 0 means not set ==> don't show map) *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get if map is available",
|
||||
"SELECT EXISTS"
|
||||
"(SELECT * FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND (Latitude<>0 OR Longitude<>0))",
|
||||
"(SELECT *"
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND (Latitude<>0"
|
||||
" OR"
|
||||
" Longitude<>0))",
|
||||
InsCod))
|
||||
{
|
||||
/* Get if map is available */
|
||||
|
|
|
@ -259,10 +259,10 @@ static void InsCfg_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 InsCod=%ld"
|
||||
" AND Latitude<>0"
|
||||
" AND Longitude<>0",
|
||||
" AND Latitude<>0"
|
||||
" AND Longitude<>0",
|
||||
Gbl.Hierarchy.Ins.InsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
|
@ -306,14 +306,14 @@ static void InsCfg_Map (void)
|
|||
Map_AddTileLayer ();
|
||||
|
||||
/* Get centers with coordinates */
|
||||
NumCtrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get centers"
|
||||
" with coordinates",
|
||||
"SELECT CtrCod" // row[0]
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND Latitude<>0"
|
||||
" AND Longitude<>0",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
NumCtrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get centers with coordinates",
|
||||
"SELECT CtrCod" // row[0]
|
||||
" FROM ctr_centers"
|
||||
" WHERE InsCod=%ld"
|
||||
" AND Latitude<>0"
|
||||
" AND Longitude<>0",
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
|
||||
/* Add a marker and a popup for each center */
|
||||
for (NumCtr = 0;
|
||||
|
|
|
@ -275,8 +275,9 @@ void Log_GetAndShowLastClicks (void)
|
|||
"InsCod," // row[5]
|
||||
"CtrCod," // row[6]
|
||||
"DegCod" // row[7]
|
||||
" FROM log_recent"
|
||||
" ORDER BY LogCod DESC LIMIT 20");
|
||||
" FROM log_recent"
|
||||
" ORDER BY LogCod DESC"
|
||||
" LIMIT 20");
|
||||
|
||||
/***** Write list of connected users *****/
|
||||
HTM_TABLE_BeginCenterPadding (1);
|
||||
|
|
72
swad_mail.c
72
swad_mail.c
|
@ -273,10 +273,13 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
|||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE T1 ENGINE=MEMORY"
|
||||
" SELECT SUBSTRING_INDEX(E_mail,'@',-1) AS Domain,COUNT(*) as N"
|
||||
" FROM usr_emails GROUP BY Domain");
|
||||
" FROM usr_emails"
|
||||
" GROUP BY Domain");
|
||||
|
||||
DB_Query ("can not create temporary table",
|
||||
"CREATE TEMPORARY TABLE T2 ENGINE=MEMORY SELECT * FROM T1");
|
||||
"CREATE TEMPORARY TABLE T2 ENGINE=MEMORY"
|
||||
" SELECT *"
|
||||
" FROM T1");
|
||||
|
||||
/***** Get mail domains from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get mail domains",
|
||||
|
@ -293,7 +296,8 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
|||
"0 AS N" // row[3]
|
||||
" FROM ntf_mail_domains"
|
||||
" WHERE Domain NOT IN"
|
||||
" (SELECT Domain COLLATE 'latin1_bin' FROM T2))"
|
||||
" (SELECT Domain COLLATE 'latin1_bin'"
|
||||
" FROM T2))"
|
||||
" ORDER BY %s", // COLLATE necessary to avoid error in comparisons
|
||||
OrderBySubQuery[Gbl.Mails.SelectedOrder]);
|
||||
|
||||
|
@ -1083,9 +1087,12 @@ bool Mai_GetEmailFromUsrCod (struct UsrData *UsrDat)
|
|||
|
||||
/***** Get current (last updated) user's nickname from database *****/
|
||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get email address",
|
||||
"SELECT E_mail,Confirmed FROM usr_emails"
|
||||
"SELECT E_mail,"
|
||||
"Confirmed"
|
||||
" FROM usr_emails"
|
||||
" WHERE UsrCod=%ld"
|
||||
" ORDER BY CreatTime DESC LIMIT 1",
|
||||
" ORDER BY CreatTime DESC"
|
||||
" LIMIT 1",
|
||||
UsrDat->UsrCod);
|
||||
|
||||
if (NumRows == 0)
|
||||
|
@ -1126,12 +1133,14 @@ long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
|
|||
{
|
||||
/***** Get user's code from database *****/
|
||||
/* Check if user code from table usr_emails is also in table usr_data */
|
||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get user's code",
|
||||
"SELECT usr_emails.UsrCod"
|
||||
" FROM usr_emails,usr_data"
|
||||
" WHERE usr_emails.E_mail='%s'"
|
||||
" AND usr_emails.UsrCod=usr_data.UsrCod",
|
||||
Email);
|
||||
NumUsrs = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get user's code",
|
||||
"SELECT usr_emails.UsrCod"
|
||||
" FROM usr_emails,"
|
||||
"usr_data"
|
||||
" WHERE usr_emails.E_mail='%s'"
|
||||
" AND usr_emails.UsrCod=usr_data.UsrCod",
|
||||
Email);
|
||||
if (NumUsrs == 0)
|
||||
/* User not found for this email ==> set user's code to void */
|
||||
UsrCod = -1L;
|
||||
|
@ -1253,14 +1262,14 @@ static void Mai_ShowFormChangeUsrEmail (bool ItsMe,
|
|||
Ale_ShowAlert (Ale_WARNING,Txt_Please_confirm_your_email_address);
|
||||
|
||||
/***** Get my emails *****/
|
||||
NumEmails = (unsigned) DB_QuerySELECT (&mysql_res,"can not get"
|
||||
" old email addresses"
|
||||
" of a user",
|
||||
"SELECT E_mail,Confirmed"
|
||||
" FROM usr_emails"
|
||||
" WHERE UsrCod=%ld"
|
||||
" ORDER BY CreatTime DESC",
|
||||
UsrDat->UsrCod);
|
||||
NumEmails = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get old email addresses of a user",
|
||||
"SELECT E_mail," // row[0]
|
||||
"Confirmed" // row[1]
|
||||
" FROM usr_emails"
|
||||
" WHERE UsrCod=%ld"
|
||||
" ORDER BY CreatTime DESC",
|
||||
UsrDat->UsrCod);
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWidePadding (2);
|
||||
|
@ -1617,23 +1626,30 @@ bool Mai_UpdateEmailInDB (const struct UsrData *UsrDat,const char NewEmail[Cns_M
|
|||
{
|
||||
/***** Check if the new email matches any of the confirmed emails of other users *****/
|
||||
if (DB_QueryCOUNT ("can not check if email already existed",
|
||||
"SELECT COUNT(*) FROM usr_emails"
|
||||
" WHERE E_mail='%s' AND Confirmed='Y'"
|
||||
" AND UsrCod<>%ld",
|
||||
NewEmail,UsrDat->UsrCod)) // An email of another user is the same that my email
|
||||
"SELECT COUNT(*)"
|
||||
" FROM usr_emails"
|
||||
" WHERE E_mail='%s'"
|
||||
" AND Confirmed='Y'"
|
||||
" AND UsrCod<>%ld",
|
||||
NewEmail,
|
||||
UsrDat->UsrCod)) // An email of another user is the same that my email
|
||||
return false; // Don't update
|
||||
|
||||
/***** Delete email (not confirmed) for other users *****/
|
||||
DB_QueryDELETE ("can not remove pending email for other users",
|
||||
"DELETE FROM usr_pending_emails"
|
||||
" WHERE E_mail='%s' AND UsrCod<>%ld",
|
||||
NewEmail,UsrDat->UsrCod);
|
||||
" WHERE E_mail='%s'"
|
||||
" AND UsrCod<>%ld",
|
||||
NewEmail,
|
||||
UsrDat->UsrCod);
|
||||
|
||||
DB_QueryDELETE ("can not remove not confirmed email for other users",
|
||||
"DELETE FROM usr_emails"
|
||||
" WHERE E_mail='%s' AND Confirmed='N'"
|
||||
" AND UsrCod<>%ld",
|
||||
NewEmail,UsrDat->UsrCod);
|
||||
" WHERE E_mail='%s'"
|
||||
" AND Confirmed='N'"
|
||||
" AND UsrCod<>%ld",
|
||||
NewEmail,
|
||||
UsrDat->UsrCod);
|
||||
|
||||
/***** Update email in database *****/
|
||||
DB_QueryREPLACE ("can not update email",
|
||||
|
|
14
swad_mark.c
14
swad_mark.c
|
@ -179,8 +179,8 @@ static void Mrk_GetNumRowsHeaderAndFooter (struct MarksProperties *Marks)
|
|||
" in header and footer",
|
||||
"SELECT mrk_marks.%s," // row[0]
|
||||
"mrk_marks.%s" // row[1]
|
||||
" FROM brw_files,"
|
||||
"mrk_marks"
|
||||
" FROM brw_files,"
|
||||
"mrk_marks"
|
||||
" WHERE brw_files.FileBrowser=%u"
|
||||
" AND brw_files.Cod=%ld"
|
||||
" AND brw_files.Path='%s'"
|
||||
|
@ -729,11 +729,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
/***** Get subject of message from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get the number of rows"
|
||||
" in header and footer",
|
||||
"SELECT brw_files.FileBrowser,"
|
||||
"brw_files.Cod,"
|
||||
"brw_files.Path,"
|
||||
"mrk_marks.Header,"
|
||||
"mrk_marks.Footer"
|
||||
"SELECT brw_files.FileBrowser," // row[0]
|
||||
"brw_files.Cod," // row[1]
|
||||
"brw_files.Path," // row[2]
|
||||
"mrk_marks.Header," // row[3]
|
||||
"mrk_marks.Footer" // row[4]
|
||||
" FROM brw_files,"
|
||||
"mrk_marks"
|
||||
" WHERE brw_files.FilCod=%ld"
|
||||
|
|
Loading…
Reference in New Issue