mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-14 12:44:09 +02:00
Version 20.56: Apr 04, 2021 Optimizations in database selects.
This commit is contained in:
parent
9dba8e5314
commit
3c20280f3a
22
swad_API.c
22
swad_API.c
|
@ -358,7 +358,7 @@ static int API_GetPlgCodFromAppKey (struct soap *soap,
|
||||||
const char *appKey)
|
const char *appKey)
|
||||||
{
|
{
|
||||||
/***** Get number of plugins with a IP address *****/
|
/***** Get number of plugins with a IP address *****/
|
||||||
Gbl.WebService.PlgCod = DB_QuerySELECTCod ("can not check application key",
|
Gbl.WebService.PlgCod = DB_QuerySELECTCode ("can not check application key",
|
||||||
"SELECT PlgCod"
|
"SELECT PlgCod"
|
||||||
" FROM plg_plugins"
|
" FROM plg_plugins"
|
||||||
" WHERE AppKey='%s'",
|
" WHERE AppKey='%s'",
|
||||||
|
@ -578,7 +578,7 @@ static int API_RemoveOldWSKeys (struct soap *soap)
|
||||||
static int API_GetCurrentDegCodFromCurrentCrsCod (void)
|
static int API_GetCurrentDegCodFromCurrentCrsCod (void)
|
||||||
{
|
{
|
||||||
/***** Check that key does not exist in database *****/
|
/***** Check that key does not exist in database *****/
|
||||||
Gbl.Hierarchy.Deg.DegCod = DB_QuerySELECTCod ("can not get the degree of a course",
|
Gbl.Hierarchy.Deg.DegCod = DB_QuerySELECTCode ("can not get the degree of a course",
|
||||||
"SELECT DegCod"
|
"SELECT DegCod"
|
||||||
" FROM crs_courses"
|
" FROM crs_courses"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
|
@ -895,7 +895,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
||||||
|
|
||||||
/* User has typed a nickname */
|
/* User has typed a nickname */
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCod ("can not get user's data",
|
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCode ("can not get user's data",
|
||||||
"SELECT usr_nicknames.UsrCod"
|
"SELECT usr_nicknames.UsrCod"
|
||||||
" FROM usr_nicknames,"
|
" FROM usr_nicknames,"
|
||||||
"usr_data"
|
"usr_data"
|
||||||
|
@ -909,7 +909,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
{
|
{
|
||||||
/* User has typed an email */
|
/* User has typed an email */
|
||||||
// TODO: Get only if email confirmed?
|
// TODO: Get only if email confirmed?
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCod ("can not get user's data",
|
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCode ("can not get user's data",
|
||||||
"SELECT usr_emails.UsrCod"
|
"SELECT usr_emails.UsrCod"
|
||||||
" FROM usr_emails,usr_data"
|
" FROM usr_emails,usr_data"
|
||||||
" WHERE usr_emails.E_mail='%s'"
|
" WHERE usr_emails.E_mail='%s'"
|
||||||
|
@ -927,7 +927,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
|
||||||
{
|
{
|
||||||
/* User has typed a valid user's ID (existing or not) */
|
/* User has typed a valid user's ID (existing or not) */
|
||||||
// TODO: Get only if ID confirmed?
|
// TODO: Get only if ID confirmed?
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCod ("can not get user's data",
|
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCode ("can not get user's data",
|
||||||
"SELECT usr_ids.UsrCod"
|
"SELECT usr_ids.UsrCod"
|
||||||
" FROM usr_ids,"
|
" FROM usr_ids,"
|
||||||
"usr_data"
|
"usr_data"
|
||||||
|
@ -1245,7 +1245,7 @@ int swad__getNewPassword (struct soap *soap,
|
||||||
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
Str_RemoveLeadingArrobas (UsrIDNickOrEmail);
|
||||||
|
|
||||||
/* User has typed a nickname */
|
/* User has typed a nickname */
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCod ("can not get user's data",
|
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCode ("can not get user's data",
|
||||||
"SELECT UsrCod"
|
"SELECT UsrCod"
|
||||||
" FROM usr_nicknames"
|
" FROM usr_nicknames"
|
||||||
" WHERE Nickname='%s'",
|
" WHERE Nickname='%s'",
|
||||||
|
@ -1254,7 +1254,7 @@ int swad__getNewPassword (struct soap *soap,
|
||||||
else if (Mai_CheckIfEmailIsValid (Gbl.Usrs.Me.UsrIdLogin)) // 2: It's an email
|
else if (Mai_CheckIfEmailIsValid (Gbl.Usrs.Me.UsrIdLogin)) // 2: It's an email
|
||||||
/* User has typed an email */
|
/* User has typed an email */
|
||||||
// TODO: Get only if email confirmed?
|
// TODO: Get only if email confirmed?
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCod ("can not get user's data",
|
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCode ("can not get user's data",
|
||||||
"SELECT UsrCod"
|
"SELECT UsrCod"
|
||||||
" FROM usr_emails"
|
" FROM usr_emails"
|
||||||
" WHERE E_mail='%s'",
|
" WHERE E_mail='%s'",
|
||||||
|
@ -1267,7 +1267,7 @@ int swad__getNewPassword (struct soap *soap,
|
||||||
if (ID_CheckIfUsrIDIsValid (UsrIDNickOrEmail))
|
if (ID_CheckIfUsrIDIsValid (UsrIDNickOrEmail))
|
||||||
/* User has typed a valid user's ID (existing or not) */
|
/* User has typed a valid user's ID (existing or not) */
|
||||||
// TODO: Get only if ID confirmed?
|
// TODO: Get only if ID confirmed?
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCod ("can not get user's data",
|
Gbl.Usrs.Me.UsrDat.UsrCod = DB_QuerySELECTCode ("can not get user's data",
|
||||||
"SELECT UsrCod"
|
"SELECT UsrCod"
|
||||||
" FROM usr_ids"
|
" FROM usr_ids"
|
||||||
" WHERE UsrID='%s'",
|
" WHERE UsrID='%s'",
|
||||||
|
@ -2697,7 +2697,7 @@ static void API_GetListGrpsInAttendanceEventFromDB (struct soap *soap,
|
||||||
NumGrp++)
|
NumGrp++)
|
||||||
{
|
{
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
GrpCod = DB_GetNextCod (mysql_res);
|
GrpCod = DB_GetNextCode (mysql_res);
|
||||||
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
|
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
|
||||||
"%ld",
|
"%ld",
|
||||||
GrpCod);
|
GrpCod);
|
||||||
|
@ -3704,7 +3704,7 @@ int swad__sendMessage (struct soap *soap,
|
||||||
"Original message does not exist");
|
"Original message does not exist");
|
||||||
|
|
||||||
/***** Get the recipient of the message *****/
|
/***** Get the recipient of the message *****/
|
||||||
ReplyUsrCod = DB_QuerySELECTCod ("can not check original message",
|
ReplyUsrCod = DB_QuerySELECTCode ("can not check original message",
|
||||||
"SELECT UsrCod"
|
"SELECT UsrCod"
|
||||||
" FROM msg_snt"
|
" FROM msg_snt"
|
||||||
" WHERE MsgCod=%ld"
|
" WHERE MsgCod=%ld"
|
||||||
|
@ -5418,7 +5418,7 @@ static void API_GetListGrpsInGameFromDB (struct soap *soap,
|
||||||
NumGrp++)
|
NumGrp++)
|
||||||
{
|
{
|
||||||
/* Get next group */
|
/* Get next group */
|
||||||
GrpCod = DB_GetNextCod (mysql_res);
|
GrpCod = DB_GetNextCode (mysql_res);
|
||||||
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
|
snprintf (GrpCodStr,sizeof (GrpCodStr),NumGrp ? ",%ld" :
|
||||||
"%ld",
|
"%ld",
|
||||||
GrpCod);
|
GrpCod);
|
||||||
|
|
|
@ -238,7 +238,7 @@ void Acc_CheckIfEmptyAccountExists (void)
|
||||||
{
|
{
|
||||||
/***** Get user's data from query result *****/
|
/***** Get user's data from query result *****/
|
||||||
/* Get user's code */
|
/* Get user's code */
|
||||||
UsrDat.UsrCod = DB_GetNextCod (mysql_res);
|
UsrDat.UsrCod = DB_GetNextCode (mysql_res);
|
||||||
|
|
||||||
/* Get user's data */
|
/* Get user's data */
|
||||||
Usr_GetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS);
|
Usr_GetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS);
|
||||||
|
|
|
@ -1175,7 +1175,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
||||||
NumEvent < Agenda->Num;
|
NumEvent < Agenda->Num;
|
||||||
NumEvent++)
|
NumEvent++)
|
||||||
/* Get next event code */
|
/* Get next event code */
|
||||||
if ((Agenda->LstAgdCods[NumEvent] = DB_GetNextCod (mysql_res)) < 0)
|
if ((Agenda->LstAgdCods[NumEvent] = DB_GetNextCode (mysql_res)) < 0)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong event code.");
|
Lay_ShowErrorAndExit ("Error: wrong event code.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -740,7 +740,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
||||||
NumAsg++)
|
NumAsg++)
|
||||||
{
|
{
|
||||||
/* Get next assignment code */
|
/* Get next assignment code */
|
||||||
if ((Assignments->LstAsgCods[NumAsg] = DB_GetNextCod (mysql_res)) < 0)
|
if ((Assignments->LstAsgCods[NumAsg] = DB_GetNextCode (mysql_res)) < 0)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong assignment code.");
|
Lay_ShowErrorAndExit ("Error: wrong assignment code.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -720,7 +720,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
||||||
NumAttEvent++)
|
NumAttEvent++)
|
||||||
{
|
{
|
||||||
/* Get next attendance event code */
|
/* Get next attendance event code */
|
||||||
if ((Events->Lst[NumAttEvent].AttCod = DB_GetNextCod (mysql_res)) < 0)
|
if ((Events->Lst[NumAttEvent].AttCod = DB_GetNextCode (mysql_res)) < 0)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong attendance event code.");
|
Lay_ShowErrorAndExit ("Error: wrong attendance event code.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3069,7 +3069,7 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events)
|
||||||
NumGrpInThisEvent++)
|
NumGrpInThisEvent++)
|
||||||
{
|
{
|
||||||
/* Get next group associated to this event */
|
/* Get next group associated to this event */
|
||||||
if ((GrpCodInThisEvent = DB_GetNextCod (mysql_res)) > 0)
|
if ((GrpCodInThisEvent = DB_GetNextCode (mysql_res)) > 0)
|
||||||
/* Check if this group is selected */
|
/* Check if this group is selected */
|
||||||
for (NumGrpSel = 0;
|
for (NumGrpSel = 0;
|
||||||
NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps &&
|
NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps &&
|
||||||
|
|
|
@ -423,7 +423,7 @@ void Cfe_PrintCallForExam (void)
|
||||||
|
|
||||||
/***** Get the code of the call for exam *****/
|
/***** Get the code of the call for exam *****/
|
||||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||||
Lay_ShowErrorAndExit ("Code of call for exam is missing.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Read call for exam from the database *****/
|
/***** Read call for exam from the database *****/
|
||||||
Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod);
|
Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod);
|
||||||
|
@ -452,7 +452,7 @@ void Cfe_ReqRemoveCallForExam (void)
|
||||||
|
|
||||||
/***** Get the code of the call for exam *****/
|
/***** Get the code of the call for exam *****/
|
||||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||||
Lay_ShowErrorAndExit ("Code of call for exam is missing.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Show question and button to remove call for exam *****/
|
/***** Show question and button to remove call for exam *****/
|
||||||
/* Begin alert */
|
/* Begin alert */
|
||||||
|
@ -488,7 +488,7 @@ void Cfe_RemoveCallForExam1 (void)
|
||||||
|
|
||||||
/***** Get the code of the call for exam *****/
|
/***** Get the code of the call for exam *****/
|
||||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||||
Lay_ShowErrorAndExit ("Code of call for exam is missing.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Mark the call for exam as deleted in the database *****/
|
/***** Mark the call for exam as deleted in the database *****/
|
||||||
DB_QueryUPDATE ("can not remove call for exam",
|
DB_QueryUPDATE ("can not remove call for exam",
|
||||||
|
@ -536,7 +536,7 @@ void Cfe_HideCallForExam (void)
|
||||||
|
|
||||||
/***** Get the code of the call for exam *****/
|
/***** Get the code of the call for exam *****/
|
||||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||||
Lay_ShowErrorAndExit ("Code of call for exam is missing.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Mark the call for exam as hidden in the database *****/
|
/***** Mark the call for exam as hidden in the database *****/
|
||||||
DB_QueryUPDATE ("can not hide call for exam",
|
DB_QueryUPDATE ("can not hide call for exam",
|
||||||
|
@ -567,7 +567,7 @@ void Cfe_UnhideCallForExam (void)
|
||||||
|
|
||||||
/***** Get the code of the call for exam *****/
|
/***** Get the code of the call for exam *****/
|
||||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||||
Lay_ShowErrorAndExit ("Code of call for exam is missing.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Mark the call for exam as visible in the database *****/
|
/***** Mark the call for exam as visible in the database *****/
|
||||||
DB_QueryUPDATE ("can not unhide call for exam",
|
DB_QueryUPDATE ("can not unhide call for exam",
|
||||||
|
@ -683,7 +683,6 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams,
|
||||||
extern const char *Txt_No_calls_for_exams_of_X;
|
extern const char *Txt_No_calls_for_exams_of_X;
|
||||||
char SubQueryStatus[64];
|
char SubQueryStatus[64];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumExaAnn;
|
unsigned long NumExaAnn;
|
||||||
unsigned long NumExaAnns;
|
unsigned long NumExaAnns;
|
||||||
long ExaCod;
|
long ExaCod;
|
||||||
|
@ -731,10 +730,8 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams,
|
||||||
NumExaAnn++)
|
NumExaAnn++)
|
||||||
{
|
{
|
||||||
/***** Get the code of the call for exam (row[0]) *****/
|
/***** Get the code of the call for exam (row[0]) *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
if ((ExaCod = DB_GetNextCode (mysql_res)) <= 0)
|
||||||
|
Lay_WrongCallForExamExit ();
|
||||||
if (sscanf (row[0],"%ld",&ExaCod) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Wrong code of call for exam.");
|
|
||||||
|
|
||||||
/***** Allocate memory for the call for exam *****/
|
/***** Allocate memory for the call for exam *****/
|
||||||
Cfe_AllocMemCallForExam (CallsForExams);
|
Cfe_AllocMemCallForExam (CallsForExams);
|
||||||
|
@ -934,7 +931,7 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams)
|
||||||
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Year,
|
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Year,
|
||||||
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Month,
|
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Month,
|
||||||
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Day) != 3)
|
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Day) != 3)
|
||||||
Lay_ShowErrorAndExit ("Wrong date of exam.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Increment number of elements in list *****/
|
/***** Increment number of elements in list *****/
|
||||||
CallsForExams->NumCallsForExams++;
|
CallsForExams->NumCallsForExams++;
|
||||||
|
@ -999,7 +996,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
||||||
|
|
||||||
/***** The result of the query must have one row *****/
|
/***** The result of the query must have one row *****/
|
||||||
if (NumExaAnns != 1)
|
if (NumExaAnns != 1)
|
||||||
Lay_ShowErrorAndExit ("Error when getting data of a call for exam.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/***** Get the data of the call for exam *****/
|
/***** Get the data of the call for exam *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -1009,9 +1006,9 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
||||||
|
|
||||||
/* Status of the call for exam (row[1]) */
|
/* Status of the call for exam (row[1]) */
|
||||||
if (sscanf (row[1],"%u",&UnsignedNum) != 1)
|
if (sscanf (row[1],"%u",&UnsignedNum) != 1)
|
||||||
Lay_ShowErrorAndExit ("Wrong status.");
|
Lay_WrongCallForExamExit ();
|
||||||
if (UnsignedNum >= Cfe_NUM_STATUS)
|
if (UnsignedNum >= Cfe_NUM_STATUS)
|
||||||
Lay_ShowErrorAndExit ("Wrong status.");
|
Lay_WrongCallForExamExit ();
|
||||||
CallsForExams->CallForExam.Status = (Cfe_Status_t) UnsignedNum;
|
CallsForExams->CallForExam.Status = (Cfe_Status_t) UnsignedNum;
|
||||||
|
|
||||||
/* Name of the course (row[2]) */
|
/* Name of the course (row[2]) */
|
||||||
|
@ -1020,7 +1017,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
||||||
|
|
||||||
/* Year (row[3]) */
|
/* Year (row[3]) */
|
||||||
if (sscanf (row[3],"%u",&CallsForExams->CallForExam.Year) != 1)
|
if (sscanf (row[3],"%u",&CallsForExams->CallForExam.Year) != 1)
|
||||||
Lay_ShowErrorAndExit ("Wrong year.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/* Exam session (row[4]) */
|
/* Exam session (row[4]) */
|
||||||
Str_Copy (CallsForExams->CallForExam.Session,row[4],
|
Str_Copy (CallsForExams->CallForExam.Session,row[4],
|
||||||
|
@ -1034,7 +1031,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
||||||
&Hour,
|
&Hour,
|
||||||
&Minute,
|
&Minute,
|
||||||
&Second) != 6)
|
&Second) != 6)
|
||||||
Lay_ShowErrorAndExit ("Wrong date of call for exam.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/* Date of exam (row[6]) */
|
/* Date of exam (row[6]) */
|
||||||
if (sscanf (row[6],"%04u-%02u-%02u %02u:%02u:%02u",
|
if (sscanf (row[6],"%04u-%02u-%02u %02u:%02u:%02u",
|
||||||
|
@ -1044,7 +1041,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
||||||
&CallsForExams->CallForExam.StartTime.Hour,
|
&CallsForExams->CallForExam.StartTime.Hour,
|
||||||
&CallsForExams->CallForExam.StartTime.Minute,
|
&CallsForExams->CallForExam.StartTime.Minute,
|
||||||
&Second) != 6)
|
&Second) != 6)
|
||||||
Lay_ShowErrorAndExit ("Wrong date of exam.");
|
Lay_WrongCallForExamExit ();
|
||||||
snprintf (CallsForExams->CallForExam.ExamDate.YYYYMMDD,
|
snprintf (CallsForExams->CallForExam.ExamDate.YYYYMMDD,
|
||||||
sizeof (CallsForExams->CallForExam.ExamDate.YYYYMMDD),"%04u%02u%02u",
|
sizeof (CallsForExams->CallForExam.ExamDate.YYYYMMDD),"%04u%02u%02u",
|
||||||
CallsForExams->CallForExam.ExamDate.Year,
|
CallsForExams->CallForExam.ExamDate.Year,
|
||||||
|
@ -1056,7 +1053,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
||||||
&CallsForExams->CallForExam.Duration.Hour,
|
&CallsForExams->CallForExam.Duration.Hour,
|
||||||
&CallsForExams->CallForExam.Duration.Minute,
|
&CallsForExams->CallForExam.Duration.Minute,
|
||||||
&Second) != 3)
|
&Second) != 3)
|
||||||
Lay_ShowErrorAndExit ("Wrong duration of exam.");
|
Lay_WrongCallForExamExit ();
|
||||||
|
|
||||||
/* Place (row[8]), exam mode (row[9]), structure (row[10]),
|
/* Place (row[8]), exam mode (row[9]), structure (row[10]),
|
||||||
documentation required (row[11]), material required (row[12]),
|
documentation required (row[11]), material required (row[12]),
|
||||||
|
|
|
@ -147,8 +147,8 @@ void Ctr_SeeCtrWithPendingDegs (void)
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
NumCtrs = (unsigned)
|
NumCtrs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get centers with pending degrees",
|
DB_QuerySELECT (&mysql_res,"can not get centers with pending degrees",
|
||||||
"SELECT deg_degrees.CtrCod,"
|
"SELECT deg_degrees.CtrCod," // row[0]
|
||||||
"COUNT(*)"
|
"COUNT(*)" // row[1]
|
||||||
" FROM deg_degrees,"
|
" FROM deg_degrees,"
|
||||||
"ctr_centers"
|
"ctr_centers"
|
||||||
" WHERE (deg_degrees.Status & %u)<>0"
|
" WHERE (deg_degrees.Status & %u)<>0"
|
||||||
|
@ -795,29 +795,16 @@ static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row)
|
||||||
|
|
||||||
long Ctr_GetInsCodOfCenterByCod (long CtrCod)
|
long Ctr_GetInsCodOfCenterByCod (long CtrCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
/***** Trivial check: center code should be > 0 *****/
|
||||||
MYSQL_ROW row;
|
if (CtrCod <= 0)
|
||||||
long InsCod = -1L;
|
return -1L;
|
||||||
|
|
||||||
if (CtrCod > 0)
|
|
||||||
{
|
|
||||||
/***** Get the institution code of a center from database *****/
|
/***** Get the institution code of a center from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get the institution of a center",
|
return DB_QuerySELECTCode ("can not get the institution of a center",
|
||||||
"SELECT InsCod"
|
"SELECT InsCod"
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" WHERE CtrCod=%ld",
|
" WHERE CtrCod=%ld",
|
||||||
CtrCod) == 1)
|
CtrCod);
|
||||||
{
|
|
||||||
/***** Get the institution code of this center *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return InsCod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -834,7 +821,7 @@ void Ctr_GetShortNameOfCenterByCod (struct Ctr_Center *Ctr)
|
||||||
{
|
{
|
||||||
/***** Get the short name of a center from database *****/
|
/***** Get the short name of a center from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a center",
|
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a center",
|
||||||
"SELECT ShortName"
|
"SELECT ShortName" // row[0]
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" WHERE CtrCod=%ld",
|
" WHERE CtrCod=%ld",
|
||||||
Ctr->CtrCod) == 1)
|
Ctr->CtrCod) == 1)
|
||||||
|
@ -896,8 +883,8 @@ void Ctr_WriteSelectorOfCenter (void)
|
||||||
/***** Get centers from database *****/
|
/***** Get centers from database *****/
|
||||||
NumCtrs = (unsigned)
|
NumCtrs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get centers",
|
DB_QuerySELECT (&mysql_res,"can not get centers",
|
||||||
"SELECT DISTINCT CtrCod,"
|
"SELECT DISTINCT CtrCod," // row[0]
|
||||||
"ShortName"
|
"ShortName" // row[1]
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" WHERE InsCod=%ld"
|
" WHERE InsCod=%ld"
|
||||||
" ORDER BY ShortName",
|
" ORDER BY ShortName",
|
||||||
|
|
|
@ -517,7 +517,7 @@ static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution)
|
||||||
|
|
||||||
/***** Get photo attribution from database *****/
|
/***** Get photo attribution from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
||||||
"SELECT PhotoAttribution"
|
"SELECT PhotoAttribution" // row[0]
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" WHERE CtrCod=%ld",
|
" WHERE CtrCod=%ld",
|
||||||
CtrCod))
|
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.
|
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.55 (2021-04-04)"
|
#define Log_PLATFORM_VERSION "SWAD 20.56 (2021-04-04)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.6.2.js"
|
#define JS_FILE "swad20.6.2.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 20.56: Apr 04, 2021 Optimizations in database selects. (309296 lines)
|
||||||
Version 20.55: Apr 04, 2021 Optimizations in database selects. (309500 lines)
|
Version 20.55: Apr 04, 2021 Optimizations in database selects. (309500 lines)
|
||||||
Version 20.54: Mar 30, 2021 Statistics about agendas. (309539 lines)
|
Version 20.54: Mar 30, 2021 Statistics about agendas. (309539 lines)
|
||||||
Version 20.53.1: Mar 30, 2021 Optimizations in database selects. (309459 lines)
|
Version 20.53.1: Mar 30, 2021 Optimizations in database selects. (309459 lines)
|
||||||
|
|
|
@ -271,7 +271,6 @@ static void CtyCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
||||||
static void CtyCfg_Map (void)
|
static void CtyCfg_Map (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
struct Coordinates CtyAvgCoord;
|
struct Coordinates CtyAvgCoord;
|
||||||
unsigned Zoom;
|
unsigned Zoom;
|
||||||
unsigned NumCtrs;
|
unsigned NumCtrs;
|
||||||
|
@ -317,10 +316,7 @@ static void CtyCfg_Map (void)
|
||||||
NumCtr++)
|
NumCtr++)
|
||||||
{
|
{
|
||||||
/* Get next center */
|
/* Get next center */
|
||||||
row = mysql_fetch_row (mysql_res);
|
Ctr.CtrCod = DB_GetNextCode (mysql_res);
|
||||||
|
|
||||||
/* Get center code (row[0]) */
|
|
||||||
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Get data of center */
|
/* Get data of center */
|
||||||
Ctr_GetDataOfCenterByCod (&Ctr);
|
Ctr_GetDataOfCenterByCod (&Ctr);
|
||||||
|
@ -583,7 +579,7 @@ static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution)
|
||||||
|
|
||||||
/***** Get photo attribution from database *****/
|
/***** Get photo attribution from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
||||||
"SELECT MapAttribution"
|
"SELECT MapAttribution" // row[0]
|
||||||
" FROM cty_countrs"
|
" FROM cty_countrs"
|
||||||
" WHERE CtyCod=%ld",
|
" WHERE CtyCod=%ld",
|
||||||
CtyCod))
|
CtyCod))
|
||||||
|
|
|
@ -2992,7 +2992,6 @@ void Crs_RemoveOldCrss (void)
|
||||||
unsigned MonthsWithoutAccess;
|
unsigned MonthsWithoutAccess;
|
||||||
unsigned long SecondsWithoutAccess;
|
unsigned long SecondsWithoutAccess;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumCrs;
|
unsigned long NumCrs;
|
||||||
unsigned long NumCrss;
|
unsigned long NumCrss;
|
||||||
unsigned NumCrssRemoved = 0;
|
unsigned NumCrssRemoved = 0;
|
||||||
|
@ -3029,8 +3028,7 @@ void Crs_RemoveOldCrss (void)
|
||||||
NumCrs < NumCrss;
|
NumCrs < NumCrss;
|
||||||
NumCrs++)
|
NumCrs++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
CrsCod = DB_GetNextCode (mysql_res);
|
||||||
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
Crs_RemoveCourseCompletely (CrsCod);
|
Crs_RemoveCourseCompletely (CrsCod);
|
||||||
NumCrssRemoved++;
|
NumCrssRemoved++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3808,7 +3808,7 @@ unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
|
||||||
/*** Make a SELECT query for a unique row with one long code from database ***/
|
/*** Make a SELECT query for a unique row with one long code from database ***/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
long DB_QuerySELECTCod (const char *MsgError,
|
long DB_QuerySELECTCode (const char *MsgError,
|
||||||
const char *fmt,...)
|
const char *fmt,...)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
@ -3826,7 +3826,7 @@ long DB_QuerySELECTCod (const char *MsgError,
|
||||||
|
|
||||||
/***** Do SELECT query *****/
|
/***** Do SELECT query *****/
|
||||||
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError)) // Row found
|
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError)) // Row found
|
||||||
Cod = DB_GetNextCod (mysql_res);
|
Cod = DB_GetNextCode (mysql_res);
|
||||||
else
|
else
|
||||||
Cod = -1L;
|
Cod = -1L;
|
||||||
|
|
||||||
|
@ -3870,7 +3870,7 @@ static unsigned long DB_QuerySELECTusingQueryStr (char *Query,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Each row of the result should hold a code (long) */
|
/* Each row of the result should hold a code (long) */
|
||||||
|
|
||||||
long DB_GetNextCod (MYSQL_RES *mysql_res)
|
long DB_GetNextCode (MYSQL_RES *mysql_res)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
|
|
@ -41,9 +41,9 @@ void DB_BuildQuery (char **Query,const char *fmt,...);
|
||||||
|
|
||||||
unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
|
unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
|
||||||
const char *fmt,...);
|
const char *fmt,...);
|
||||||
long DB_QuerySELECTCod (const char *MsgError,
|
long DB_QuerySELECTCode (const char *MsgError,
|
||||||
const char *fmt,...);
|
const char *fmt,...);
|
||||||
long DB_GetNextCod (MYSQL_RES *mysql_res);
|
long DB_GetNextCode (MYSQL_RES *mysql_res);
|
||||||
unsigned long DB_GetNumRowsTable (const char *Table);
|
unsigned long DB_GetNumRowsTable (const char *Table);
|
||||||
unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...);
|
unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...);
|
||||||
|
|
||||||
|
|
|
@ -802,7 +802,7 @@ void Dat_GetBrowserTimeZone (char BrowserTimeZone[Dat_MAX_BYTES_TIME_ZONE + 1])
|
||||||
/* Try to convert a date from server time zone to browser time zone */
|
/* Try to convert a date from server time zone to browser time zone */
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not check if time zone name"
|
if (DB_QuerySELECT (&mysql_res,"can not check if time zone name"
|
||||||
" is usable",
|
" is usable",
|
||||||
"SELECT CONVERT_TZ(NOW(),@@session.time_zone,'%s')",
|
"SELECT CONVERT_TZ(NOW(),@@session.time_zone,'%s')", // row[0]
|
||||||
BrowserTimeZone))
|
BrowserTimeZone))
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
|
@ -1438,7 +1438,7 @@ void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg)
|
||||||
{
|
{
|
||||||
/***** Get the short name of a degree from database *****/
|
/***** Get the short name of a degree from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a degree",
|
if (DB_QuerySELECT (&mysql_res,"can not get the short name of a degree",
|
||||||
"SELECT ShortName"
|
"SELECT ShortName" // row[0]
|
||||||
" FROM deg_degrees"
|
" FROM deg_degrees"
|
||||||
" WHERE DegCod=%ld",
|
" WHERE DegCod=%ld",
|
||||||
Deg->DegCod) == 1)
|
Deg->DegCod) == 1)
|
||||||
|
@ -1459,29 +1459,16 @@ void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg)
|
||||||
|
|
||||||
long Deg_GetCtrCodOfDegreeByCod (long DegCod)
|
long Deg_GetCtrCodOfDegreeByCod (long DegCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
/***** Trivial check: degree code should be > 0 *****/
|
||||||
MYSQL_ROW row;
|
if (DegCod <= 0)
|
||||||
long CtrCod = -1L;
|
return -1L;
|
||||||
|
|
||||||
if (DegCod > 0)
|
|
||||||
{
|
|
||||||
/***** Get the center code of a degree from database *****/
|
/***** Get the center code of a degree from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get the center of a degree",
|
return DB_QuerySELECTCode ("can not get the center of a degree",
|
||||||
"SELECT CtrCod"
|
"SELECT CtrCod"
|
||||||
" FROM deg_degrees"
|
" FROM deg_degrees"
|
||||||
" WHERE DegCod=%ld",
|
" WHERE DegCod=%ld",
|
||||||
DegCod) == 1)
|
DegCod);
|
||||||
{
|
|
||||||
/***** Get the center code of this degree *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
CtrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return CtrCod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1490,31 +1477,18 @@ long Deg_GetCtrCodOfDegreeByCod (long DegCod)
|
||||||
|
|
||||||
long Deg_GetInsCodOfDegreeByCod (long DegCod)
|
long Deg_GetInsCodOfDegreeByCod (long DegCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
/***** Trivial check: degree code should be > 0 *****/
|
||||||
MYSQL_ROW row;
|
if (DegCod <= 0)
|
||||||
long InsCod = -1L;
|
return -1L;
|
||||||
|
|
||||||
if (DegCod > 0)
|
|
||||||
{
|
|
||||||
/***** Get the institution code of a degree from database *****/
|
/***** Get the institution code of a degree from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get the institution of a degree",
|
return DB_QuerySELECTCode ("can not get the institution of a degree",
|
||||||
"SELECT ctr_centers.InsCod"
|
"SELECT ctr_centers.InsCod"
|
||||||
" FROM deg_degrees,"
|
" FROM deg_degrees,"
|
||||||
"ctr_centers"
|
"ctr_centers"
|
||||||
" WHERE deg_degrees.DegCod=%ld"
|
" WHERE deg_degrees.DegCod=%ld"
|
||||||
" AND deg_degrees.CtrCod=ctr_centers.CtrCod",
|
" AND deg_degrees.CtrCod=ctr_centers.CtrCod",
|
||||||
DegCod) == 1)
|
DegCod);
|
||||||
{
|
|
||||||
/***** Get the institution code of this degree *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
||||||
return InsCod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1524,7 +1498,6 @@ long Deg_GetInsCodOfDegreeByCod (long DegCod)
|
||||||
void Deg_RemoveDegreeCompletely (long DegCod)
|
void Deg_RemoveDegreeCompletely (long DegCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
long CrsCod;
|
long CrsCod;
|
||||||
|
@ -1532,7 +1505,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
||||||
|
|
||||||
/***** Get courses of a degree from database *****/
|
/***** Get courses of a degree from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get courses of a degree",
|
||||||
"SELECT CrsCod"
|
"SELECT CrsCod" // row[0]
|
||||||
" FROM crs_courses"
|
" FROM crs_courses"
|
||||||
" WHERE DegCod=%ld",
|
" WHERE DegCod=%ld",
|
||||||
DegCod);
|
DegCod);
|
||||||
|
@ -1543,10 +1516,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
||||||
NumRow++)
|
NumRow++)
|
||||||
{
|
{
|
||||||
/* Get next course */
|
/* Get next course */
|
||||||
row = mysql_fetch_row (mysql_res);
|
if ((CrsCod = DB_GetNextCode (mysql_res)) < 0)
|
||||||
|
|
||||||
/* Get course code (row[0]) */
|
|
||||||
if ((CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
||||||
Lay_ShowErrorAndExit ("Wrong code of course.");
|
Lay_ShowErrorAndExit ("Wrong code of course.");
|
||||||
|
|
||||||
/* Remove course */
|
/* Remove course */
|
||||||
|
|
|
@ -882,7 +882,7 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
|
||||||
|
|
||||||
/***** Get the name of a type of degree from database *****/
|
/***** 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",
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get the name of a type of degree",
|
||||||
"SELECT DegTypName"
|
"SELECT DegTypName" // row[0]
|
||||||
" FROM deg_types"
|
" FROM deg_types"
|
||||||
" WHERE DegTypCod=%ld",
|
" WHERE DegTypCod=%ld",
|
||||||
DegTyp->DegTypCod);
|
DegTyp->DegTypCod);
|
||||||
|
@ -923,14 +923,13 @@ bool DT_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp)
|
||||||
static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumRows;
|
unsigned long NumRows;
|
||||||
unsigned long NumRow;
|
unsigned long NumRow;
|
||||||
long DegCod;
|
long DegCod;
|
||||||
|
|
||||||
/***** Get degrees of a type from database *****/
|
/***** Get degrees of a type from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get degrees of a type",
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get degrees of a type",
|
||||||
"SELECT DegCod"
|
"SELECT DegCod" // row[0]
|
||||||
" FROM deg_degrees"
|
" FROM deg_degrees"
|
||||||
" WHERE DegTypCod=%ld",
|
" WHERE DegTypCod=%ld",
|
||||||
DegTypCod);
|
DegTypCod);
|
||||||
|
@ -941,10 +940,7 @@ static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
||||||
NumRow++)
|
NumRow++)
|
||||||
{
|
{
|
||||||
/* Get next degree */
|
/* Get next degree */
|
||||||
row = mysql_fetch_row (mysql_res);
|
if ((DegCod = DB_GetNextCode (mysql_res)) < 0)
|
||||||
|
|
||||||
/* Get degree code (row[0]) */
|
|
||||||
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
||||||
Lay_ShowErrorAndExit ("Wrong code of degree.");
|
Lay_ShowErrorAndExit ("Wrong code of degree.");
|
||||||
|
|
||||||
/* Remove degree */
|
/* Remove degree */
|
||||||
|
@ -956,7 +952,8 @@ static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
||||||
|
|
||||||
/***** Remove the degree type *****/
|
/***** Remove the degree type *****/
|
||||||
DB_QueryDELETE ("can not remove a type of degree",
|
DB_QueryDELETE ("can not remove a type of degree",
|
||||||
"DELETE FROM deg_types WHERE DegTypCod=%ld",
|
"DELETE FROM deg_types"
|
||||||
|
" WHERE DegTypCod=%ld",
|
||||||
DegTypCod);
|
DegTypCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,9 +146,9 @@ void Dup_ListDuplicateUsrs (void)
|
||||||
/***** Make query *****/
|
/***** Make query *****/
|
||||||
NumUsrs = (unsigned)
|
NumUsrs = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get possibly duplicate users",
|
DB_QuerySELECT (&mysql_res,"can not get possibly duplicate users",
|
||||||
"SELECT UsrCod,"
|
"SELECT UsrCod," // row[0]
|
||||||
"COUNT(*) AS N,"
|
"COUNT(*) AS N," // row[1]
|
||||||
"UNIX_TIMESTAMP(MIN(InformTime)) AS T"
|
"UNIX_TIMESTAMP(MIN(InformTime)) AS T" // row[2]
|
||||||
" FROM usr_duplicated"
|
" FROM usr_duplicated"
|
||||||
" GROUP BY UsrCod"
|
" GROUP BY UsrCod"
|
||||||
" ORDER BY N DESC,"
|
" ORDER BY N DESC,"
|
||||||
|
@ -263,7 +263,6 @@ static void Dup_ListSimilarUsrs (void)
|
||||||
extern const char *Txt_Similar_users;
|
extern const char *Txt_Similar_users;
|
||||||
struct UsrData UsrDat;
|
struct UsrData UsrDat;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsr;
|
unsigned NumUsr;
|
||||||
|
|
||||||
|
@ -325,10 +324,8 @@ static void Dup_ListSimilarUsrs (void)
|
||||||
NumUsr < NumUsrs;
|
NumUsr < NumUsrs;
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
/* Get user code */
|
||||||
|
UsrDat.UsrCod = DB_GetNextCode (mysql_res);
|
||||||
/* Get user code (row[0]) */
|
|
||||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS))
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS))
|
||||||
{
|
{
|
||||||
/* Get if user has accepted all his/her courses */
|
/* Get if user has accepted all his/her courses */
|
||||||
|
|
|
@ -515,9 +515,8 @@ void Enr_GetNotifEnrolment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
||||||
SummaryStr[0] = '\0'; // Return nothing on error
|
SummaryStr[0] = '\0'; // Return nothing on error
|
||||||
|
|
||||||
/***** Get user's role in course from database *****/
|
/***** Get user's role in course from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get user's role"
|
if (DB_QuerySELECT (&mysql_res,"can not get user's role in course",
|
||||||
" in course",
|
"SELECT Role" // row[0]
|
||||||
"SELECT Role"
|
|
||||||
" FROM crs_users"
|
" FROM crs_users"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod=%ld",
|
" AND UsrCod=%ld",
|
||||||
|
@ -866,7 +865,6 @@ void Enr_RemoveOldUsrs (void)
|
||||||
unsigned MonthsWithoutAccess;
|
unsigned MonthsWithoutAccess;
|
||||||
time_t SecondsWithoutAccess;
|
time_t SecondsWithoutAccess;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumUsr;
|
unsigned long NumUsr;
|
||||||
unsigned long NumUsrs;
|
unsigned long NumUsrs;
|
||||||
unsigned NumUsrsEliminated = 0;
|
unsigned NumUsrsEliminated = 0;
|
||||||
|
@ -884,13 +882,16 @@ void Enr_RemoveOldUsrs (void)
|
||||||
|
|
||||||
/***** Get old users from database *****/
|
/***** Get old users from database *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get old users",
|
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get old users",
|
||||||
"SELECT UsrCod FROM"
|
"SELECT UsrCod"
|
||||||
"("
|
" FROM (SELECT UsrCod"
|
||||||
"SELECT UsrCod FROM usr_last WHERE"
|
" FROM usr_last"
|
||||||
" LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
" WHERE LastTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"SELECT UsrCod FROM usr_data WHERE"
|
"SELECT UsrCod"
|
||||||
" UsrCod NOT IN (SELECT UsrCod FROM usr_last)"
|
" FROM usr_data"
|
||||||
|
" WHERE UsrCod NOT IN"
|
||||||
|
" (SELECT UsrCod"
|
||||||
|
" FROM usr_last)"
|
||||||
") AS candidate_usrs"
|
") AS candidate_usrs"
|
||||||
" WHERE UsrCod NOT IN"
|
" WHERE UsrCod NOT IN"
|
||||||
" (SELECT DISTINCT UsrCod"
|
" (SELECT DISTINCT UsrCod"
|
||||||
|
@ -911,8 +912,7 @@ void Enr_RemoveOldUsrs (void)
|
||||||
NumUsr < NumUsrs;
|
NumUsr < NumUsrs;
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
UsrDat.UsrCod = DB_GetNextCode (mysql_res);
|
||||||
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // If user's data exist...
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS)) // If user's data exist...
|
||||||
{
|
{
|
||||||
Acc_CompletelyEliminateAccount (&UsrDat,Cns_QUIET);
|
Acc_CompletelyEliminateAccount (&UsrDat,Cns_QUIET);
|
||||||
|
@ -1973,8 +1973,6 @@ void Enr_SignUpInCrs (void)
|
||||||
extern const char *Txt_You_were_already_enroled_as_X_in_the_course_Y;
|
extern const char *Txt_You_were_already_enroled_as_X_in_the_course_Y;
|
||||||
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
extern const char *Txt_Your_request_for_enrolment_as_X_in_the_course_Y_has_been_accepted_for_processing;
|
extern const char *Txt_Your_request_for_enrolment_as_X_in_the_course_Y_has_been_accepted_for_processing;
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
Rol_Role_t RoleFromForm;
|
Rol_Role_t RoleFromForm;
|
||||||
bool Notify;
|
bool Notify;
|
||||||
long ReqCod = -1L;
|
long ReqCod = -1L;
|
||||||
|
@ -2000,20 +1998,13 @@ void Enr_SignUpInCrs (void)
|
||||||
Rol_WrongRoleExit ();
|
Rol_WrongRoleExit ();
|
||||||
|
|
||||||
/***** Try to get and old request of the same user in the same course from database *****/
|
/***** Try to get and old request of the same user in the same course from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get enrolment request",
|
ReqCod = DB_QuerySELECTCode ("can not get enrolment request",
|
||||||
"SELECT ReqCod"
|
"SELECT ReqCod"
|
||||||
" FROM crs_requests"
|
" FROM crs_requests"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod=%ld",
|
" AND UsrCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod))
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
{
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
/* Get request code (row[0]) */
|
|
||||||
ReqCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
/* Free structure that stores the query result */
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
/***** Request user in current course in database *****/
|
/***** Request user in current course in database *****/
|
||||||
if (ReqCod > 0) // Old request exists in database
|
if (ReqCod > 0) // Old request exists in database
|
||||||
|
@ -3049,29 +3040,21 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
||||||
|
|
||||||
static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod)
|
static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
long ReqCod;
|
long ReqCod;
|
||||||
|
|
||||||
/***** Mark possible notifications as removed
|
/***** Mark possible notifications as removed
|
||||||
Important: do this before removing the request *****/
|
Important: do this before removing the request *****/
|
||||||
/* Request request code (returns 0 or 1 rows) */
|
/* Request request code (returns 0 or 1 rows) */
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get request code",
|
ReqCod = DB_QuerySELECTCode ("can not get request code",
|
||||||
"SELECT ReqCod"
|
"SELECT ReqCod"
|
||||||
" FROM crs_requests"
|
" FROM crs_requests"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
" AND UsrCod=%ld",
|
" AND UsrCod=%ld",
|
||||||
CrsCod,UsrCod)) // Request exists
|
CrsCod,
|
||||||
{
|
UsrCod);
|
||||||
/* Get request code */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
ReqCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Mark possible notifications as removed */
|
/* Mark possible notifications as removed */
|
||||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_ENROLMENT_REQUEST,ReqCod);
|
Ntf_MarkNotifAsRemoved (Ntf_EVENT_ENROLMENT_REQUEST,ReqCod);
|
||||||
}
|
|
||||||
/* Free structure that stores the query result */
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
/***** Remove enrolment request *****/
|
/***** Remove enrolment request *****/
|
||||||
DB_QueryDELETE ("can not remove a request for enrolment",
|
DB_QueryDELETE ("can not remove a request for enrolment",
|
||||||
|
|
119
swad_exam.c
119
swad_exam.c
|
@ -1774,12 +1774,14 @@ long Exa_GetQstCodFromQstInd (long ExaCod,unsigned QstInd)
|
||||||
long QstCod;
|
long QstCod;
|
||||||
|
|
||||||
/***** Get question code of the question to be moved up *****/
|
/***** Get question code of the question to be moved up *****/
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get question code",
|
QstCod = DB_QuerySELECTCode ("can not get question code",
|
||||||
"SELECT QstCod"
|
"SELECT QstCod"
|
||||||
" FROM exa_set_questions"
|
" FROM exa_set_questions"
|
||||||
" WHERE ExaCod=%ld"
|
" WHERE ExaCod=%ld"
|
||||||
" AND QstInd=%u",
|
" AND QstInd=%u",
|
||||||
ExaCod,QstInd))
|
ExaCod,
|
||||||
|
QstInd);
|
||||||
|
if (QstCod <= 0)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong question index.");
|
Lay_ShowErrorAndExit ("Error: wrong question index.");
|
||||||
|
|
||||||
/***** Get question code (row[0]) *****/
|
/***** Get question code (row[0]) *****/
|
||||||
|
@ -1809,7 +1811,7 @@ unsigned Exa_GetPrevQuestionIndexInExam (long ExaCod,unsigned QstInd)
|
||||||
// Although indexes are always continuous...
|
// Although indexes are always continuous...
|
||||||
// ...this implementation works even with non continuous indexes
|
// ...this implementation works even with non continuous indexes
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get previous question index",
|
if (!DB_QuerySELECT (&mysql_res,"can not get previous question index",
|
||||||
"SELECT MAX(QstInd)"
|
"SELECT MAX(QstInd)" // row[0]
|
||||||
" FROM exa_set_questions"
|
" FROM exa_set_questions"
|
||||||
" WHERE ExaCod=%ld"
|
" WHERE ExaCod=%ld"
|
||||||
" AND QstInd<%u",
|
" AND QstInd<%u",
|
||||||
|
@ -1846,7 +1848,7 @@ unsigned Exa_GetNextQuestionIndexInExam (long ExaCod,unsigned QstInd)
|
||||||
// Although indexes are always continuous...
|
// Although indexes are always continuous...
|
||||||
// ...this implementation works even with non continuous indexes
|
// ...this implementation works even with non continuous indexes
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get next question index",
|
if (!DB_QuerySELECT (&mysql_res,"can not get next question index",
|
||||||
"SELECT MIN(QstInd)"
|
"SELECT MIN(QstInd)" // row[0]
|
||||||
" FROM exa_set_questions"
|
" FROM exa_set_questions"
|
||||||
" WHERE ExaCod=%ld"
|
" WHERE ExaCod=%ld"
|
||||||
" AND QstInd>%u",
|
" AND QstInd>%u",
|
||||||
|
@ -1899,20 +1901,15 @@ bool Exa_CheckIfEditable (const struct Exa_Exam *Exam)
|
||||||
|
|
||||||
unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumCourses;
|
|
||||||
|
|
||||||
/***** Get number of courses with exams from database *****/
|
/***** Get number of courses with exams from database *****/
|
||||||
switch (Scope)
|
switch (Scope)
|
||||||
{
|
{
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
return DB_QueryCOUNT ("can not get number of courses with exams",
|
||||||
"SELECT COUNT(DISTINCT CrsCod)"
|
"SELECT COUNT(DISTINCT CrsCod)"
|
||||||
" FROM exa_exams");
|
" FROM exa_exams");
|
||||||
break;
|
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
return DB_QueryCOUNT ("can not get number of courses with exams",
|
||||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||||
" FROM ins_instits,"
|
" FROM ins_instits,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
|
@ -1925,9 +1922,8 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Ins.InsCod);
|
Gbl.Hierarchy.Ins.InsCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_INS:
|
case Hie_Lvl_INS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
return DB_QueryCOUNT ("can not get number of courses with exams",
|
||||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
|
@ -1938,9 +1934,8 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Ins.InsCod);
|
Gbl.Hierarchy.Ins.InsCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_CTR:
|
case Hie_Lvl_CTR:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
return DB_QueryCOUNT ("can not get number of courses with exams",
|
||||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||||
" FROM deg_degrees,"
|
" FROM deg_degrees,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
|
@ -1949,37 +1944,24 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_DEG:
|
case Hie_Lvl_DEG:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
return DB_QueryCOUNT ("can not get number of courses with exams",
|
||||||
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
"SELECT COUNT(DISTINCT exa_exams.CrsCod)"
|
||||||
" FROM crs_courses,"
|
" FROM crs_courses,"
|
||||||
"exa_exams"
|
"exa_exams"
|
||||||
" WHERE crs_courses.DegCod=%ld"
|
" WHERE crs_courses.DegCod=%ld"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Deg.DegCod);
|
Gbl.Hierarchy.Deg.DegCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of courses with exams",
|
return DB_QueryCOUNT ("can not get number of courses with exams",
|
||||||
"SELECT COUNT(DISTINCT CrsCod)"
|
"SELECT COUNT(DISTINCT CrsCod)"
|
||||||
" FROM exa_exams"
|
" FROM exa_exams"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
return 0; // Not reached
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get number of exams *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
if (sscanf (row[0],"%u",&NumCourses) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting number of courses with exams.");
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return NumCourses;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1989,20 +1971,15 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
||||||
|
|
||||||
unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope)
|
unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumExams;
|
|
||||||
|
|
||||||
/***** Get number of exams from database *****/
|
/***** Get number of exams from database *****/
|
||||||
switch (Scope)
|
switch (Scope)
|
||||||
{
|
{
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
return DB_QueryCOUNT ("can not get number of exams",
|
||||||
"SELECT COUNT(*)"
|
"SELECT COUNT(*)"
|
||||||
" FROM exa_exams");
|
" FROM exa_exams");
|
||||||
break;
|
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
return DB_QueryCOUNT ("can not get number of exams",
|
||||||
"SELECT COUNT(*)"
|
"SELECT COUNT(*)"
|
||||||
" FROM ins_instits,"
|
" FROM ins_instits,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
|
@ -2015,9 +1992,8 @@ unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope)
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Cty.CtyCod);
|
Gbl.Hierarchy.Cty.CtyCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_INS:
|
case Hie_Lvl_INS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
return DB_QueryCOUNT ("can not get number of exams",
|
||||||
"SELECT COUNT(*)"
|
"SELECT COUNT(*)"
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
|
@ -2028,9 +2004,8 @@ unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope)
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Ins.InsCod);
|
Gbl.Hierarchy.Ins.InsCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_CTR:
|
case Hie_Lvl_CTR:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
return DB_QueryCOUNT ("can not get number of exams",
|
||||||
"SELECT COUNT(*)"
|
"SELECT COUNT(*)"
|
||||||
" FROM deg_degrees,"
|
" FROM deg_degrees,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
|
@ -2039,37 +2014,24 @@ unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope)
|
||||||
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
" AND deg_degrees.DegCod=crs_courses.DegCod"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Ctr.CtrCod);
|
Gbl.Hierarchy.Ctr.CtrCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_DEG:
|
case Hie_Lvl_DEG:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
return DB_QueryCOUNT ("can not get number of exams",
|
||||||
"SELECT COUNT(*)"
|
"SELECT COUNT(*)"
|
||||||
" FROM crs_courses,"
|
" FROM crs_courses,"
|
||||||
"exa_exams"
|
"exa_exams"
|
||||||
" WHERE crs_courses.DegCod=%ld"
|
" WHERE crs_courses.DegCod=%ld"
|
||||||
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
" AND crs_courses.CrsCod=exa_exams.CrsCod",
|
||||||
Gbl.Hierarchy.Deg.DegCod);
|
Gbl.Hierarchy.Deg.DegCod);
|
||||||
break;
|
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of exams",
|
return DB_QueryCOUNT ("can not get number of exams",
|
||||||
"SELECT COUNT(*)"
|
"SELECT COUNT(*)"
|
||||||
" FROM exa_exams"
|
" FROM exa_exams"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
Lay_WrongScopeExit ();
|
Lay_WrongScopeExit ();
|
||||||
break;
|
return 0; // Not reached
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get number of exams *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
if (sscanf (row[0],"%u",&NumExams) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting number of exams.");
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return NumExams;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2087,7 +2049,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
||||||
{
|
{
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||||
"SELECT AVG(NumQsts)"
|
"SELECT AVG(NumQsts)" // row[0]
|
||||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||||
" FROM exa_exams,"
|
" FROM exa_exams,"
|
||||||
"exa_set_questions"
|
"exa_set_questions"
|
||||||
|
@ -2096,7 +2058,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||||
"SELECT AVG(NumQsts)"
|
"SELECT AVG(NumQsts)" // row[0]
|
||||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||||
" FROM ins_instits,"
|
" FROM ins_instits,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
|
@ -2115,7 +2077,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_INS:
|
case Hie_Lvl_INS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||||
"SELECT AVG(NumQsts)"
|
"SELECT AVG(NumQsts)" // row[0]
|
||||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
|
@ -2132,7 +2094,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTR:
|
case Hie_Lvl_CTR:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||||
"SELECT AVG(NumQsts)"
|
"SELECT AVG(NumQsts)" // row[0]
|
||||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||||
" FROM deg_degrees,"
|
" FROM deg_degrees,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
|
@ -2147,7 +2109,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_DEG:
|
case Hie_Lvl_DEG:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||||
"SELECT AVG(NumQsts)"
|
"SELECT AVG(NumQsts)" // row[0]
|
||||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||||
" FROM crs_courses,"
|
" FROM crs_courses,"
|
||||||
"exa_exams,"
|
"exa_exams,"
|
||||||
|
@ -2160,7 +2122,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
DB_QuerySELECT (&mysql_res,"can not get number of questions per exam",
|
||||||
"SELECT AVG(NumQsts)"
|
"SELECT AVG(NumQsts)" // row[0]
|
||||||
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
" FROM (SELECT COUNT(exa_set_questions.QstCod) AS NumQsts"
|
||||||
" FROM exa_exams,"
|
" FROM exa_exams,"
|
||||||
"exa_set_questions"
|
"exa_set_questions"
|
||||||
|
@ -2190,39 +2152,22 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
||||||
|
|
||||||
void Exa_GetScoreRange (long ExaCod,double *MinScore,double *MaxScore)
|
void Exa_GetScoreRange (long ExaCod,double *MinScore,double *MaxScore)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumRows;
|
|
||||||
unsigned NumRow;
|
|
||||||
unsigned NumAnswers;
|
unsigned NumAnswers;
|
||||||
|
|
||||||
/***** Get maximum score of an exam from database *****/
|
/***** Get number of answers of exam from database *****/
|
||||||
NumRows = (unsigned)
|
NumAnswers = DB_QueryCOUNT ("can not get data of a question",
|
||||||
DB_QuerySELECT (&mysql_res,"can not get data of a question",
|
"SELECT COUNT(tst_answers.AnsInd)"
|
||||||
"SELECT COUNT(tst_answers.AnsInd) AS N"
|
|
||||||
" FROM tst_answers,"
|
" FROM tst_answers,"
|
||||||
"exa_set_questions"
|
"exa_set_questions"
|
||||||
" WHERE exa_set_questions.ExaCod=%ld"
|
" 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",
|
" GROUP BY tst_answers.QstCod",
|
||||||
ExaCod);
|
ExaCod);
|
||||||
for (NumRow = 0, *MinScore = *MaxScore = 0.0;
|
|
||||||
NumRow < NumRows;
|
|
||||||
NumRow++)
|
|
||||||
{
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get min answers (row[0]) */
|
|
||||||
if (sscanf (row[0],"%u",&NumAnswers) != 1)
|
|
||||||
NumAnswers = 0;
|
|
||||||
|
|
||||||
/* Accumulate minimum and maximum score */
|
|
||||||
if (NumAnswers < 2)
|
if (NumAnswers < 2)
|
||||||
Lay_ShowErrorAndExit ("Wrong number of answers.");
|
Lay_ShowErrorAndExit ("Wrong number of answers.");
|
||||||
|
|
||||||
|
/***** Set minimum and maximum scores *****/
|
||||||
|
*MinScore = *MaxScore = 0.0;
|
||||||
*MinScore += -1.0 / (double) (NumAnswers - 1);
|
*MinScore += -1.0 / (double) (NumAnswers - 1);
|
||||||
*MaxScore += 1.0;
|
*MaxScore += 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
}
|
|
||||||
|
|
|
@ -609,9 +609,8 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
|
||||||
unsigned NumQst;
|
unsigned NumQst;
|
||||||
|
|
||||||
/***** Get questions of an exam print from database *****/
|
/***** Get questions of an exam print from database *****/
|
||||||
Print->NumQsts.All =
|
Print->NumQsts.All = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get questions"
|
DB_QuerySELECT (&mysql_res,"can not get questions of an exam print",
|
||||||
" of an exam print",
|
|
||||||
"SELECT QstCod," // row[0]
|
"SELECT QstCod," // row[0]
|
||||||
"SetCod," // row[1]
|
"SetCod," // row[1]
|
||||||
"Score," // row[2]
|
"Score," // row[2]
|
||||||
|
@ -1273,8 +1272,8 @@ static void ExaPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question)
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM exa_set_answers"
|
" FROM exa_set_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
|
@ -1300,8 +1299,8 @@ static void ExaPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question)
|
||||||
double Tmp;
|
double Tmp;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM exa_set_answers"
|
" FROM exa_set_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
|
@ -1338,8 +1337,8 @@ static void ExaPrn_GetCorrectTF_AnswerFromDB (struct Tst_Question *Question)
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM exa_set_answers"
|
" FROM exa_set_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
|
@ -1363,8 +1362,8 @@ static void ExaPrn_GetCorrectChoAnswerFromDB (struct Tst_Question *Question)
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Correct" // row[0]
|
"SELECT Correct" // row[0]
|
||||||
" FROM exa_set_answers"
|
" FROM exa_set_answers"
|
||||||
" WHERE QstCod=%ld"
|
" WHERE QstCod=%ld"
|
||||||
|
@ -1392,8 +1391,8 @@ static void ExaPrn_GetCorrectTxtAnswerFromDB (struct Tst_Question *Question)
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
|
|
||||||
/***** Query database *****/
|
/***** Query database *****/
|
||||||
Question->Answer.NumOptions =
|
Question->Answer.NumOptions = (unsigned)
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
DB_QuerySELECT (&mysql_res,"can not get answers of a question",
|
||||||
"SELECT Answer" // row[0]
|
"SELECT Answer" // row[0]
|
||||||
" FROM exa_set_answers"
|
" FROM exa_set_answers"
|
||||||
" WHERE QstCod=%ld",
|
" WHERE QstCod=%ld",
|
||||||
|
@ -1436,7 +1435,7 @@ static void ExaPrn_GetAnswerFromDB (struct ExaPrn_Print *Print,long QstCod,
|
||||||
|
|
||||||
/***** Get questions of an exam print from database *****/
|
/***** Get questions of an exam print from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get answer in an exam print",
|
if (DB_QuerySELECT (&mysql_res,"can not get answer in an exam print",
|
||||||
"SELECT Answers"
|
"SELECT Answers" // row[0]
|
||||||
" FROM exa_print_questions"
|
" FROM exa_print_questions"
|
||||||
" WHERE PrnCod=%ld"
|
" WHERE PrnCod=%ld"
|
||||||
" AND QstCod=%ld",
|
" AND QstCod=%ld",
|
||||||
|
@ -1507,7 +1506,7 @@ static void ExaPrn_ComputeTotalScoreOfPrint (struct ExaPrn_Print *Print)
|
||||||
|
|
||||||
/***** Compute total score of exam print *****/
|
/***** Compute total score of exam print *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get score of exam print",
|
if (DB_QuerySELECT (&mysql_res,"can not get score of exam print",
|
||||||
"SELECT SUM(Score)"
|
"SELECT SUM(Score)" // row[0]
|
||||||
" FROM exa_print_questions"
|
" FROM exa_print_questions"
|
||||||
" WHERE PrnCod=%ld",
|
" WHERE PrnCod=%ld",
|
||||||
Print->PrnCod))
|
Print->PrnCod))
|
||||||
|
|
|
@ -427,7 +427,6 @@ void ExaRes_ShowAllResultsInExa (void)
|
||||||
static void ExaRes_ListAllResultsInExa (struct Exa_Exams *Exams,long ExaCod)
|
static void ExaRes_ListAllResultsInExa (struct Exa_Exams *Exams,long ExaCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumUsrs;
|
unsigned long NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned long NumUsr;
|
||||||
|
|
||||||
|
@ -450,17 +449,13 @@ static void ExaRes_ListAllResultsInExa (struct Exa_Exams *Exams,long ExaCod)
|
||||||
"usr_data.FirstName",
|
"usr_data.FirstName",
|
||||||
ExaCod,
|
ExaCod,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
if (NumUsrs)
|
|
||||||
{
|
|
||||||
/***** List sessions results for each user *****/
|
/***** List sessions results for each user *****/
|
||||||
for (NumUsr = 0;
|
for (NumUsr = 0;
|
||||||
NumUsr < NumUsrs;
|
NumUsr < NumUsrs;
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
/* Get session code */
|
||||||
row = mysql_fetch_row (mysql_res);
|
if ((Gbl.Usrs.Other.UsrDat.UsrCod = DB_GetNextCode (mysql_res)) > 0)
|
||||||
|
|
||||||
/* Get session code (row[0]) */
|
|
||||||
if ((Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
||||||
if (Usr_CheckIfICanViewTstExaMchResult (&Gbl.Usrs.Other.UsrDat))
|
if (Usr_CheckIfICanViewTstExaMchResult (&Gbl.Usrs.Other.UsrDat))
|
||||||
{
|
{
|
||||||
|
@ -468,8 +463,6 @@ static void ExaRes_ListAllResultsInExa (struct Exa_Exams *Exams,long ExaCod)
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
ExaRes_ShowResults (Exams,Usr_OTHER,-1L,ExaCod,NULL);
|
ExaRes_ShowResults (Exams,Usr_OTHER,-1L,ExaCod,NULL);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -523,7 +516,6 @@ void ExaRes_ShowAllResultsInSes (void)
|
||||||
static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumUsrs;
|
unsigned long NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned long NumUsr;
|
||||||
|
|
||||||
|
@ -532,7 +524,7 @@ static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
||||||
|
|
||||||
/***** Get all users who have answered any session question in this exam *****/
|
/***** Get all users who have answered any session question in this exam *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in session",
|
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get users in session",
|
||||||
"SELECT users.UsrCod"
|
"SELECT users.UsrCod" // row[0]
|
||||||
" FROM (SELECT exa_prints.UsrCod AS UsrCod" // row[0]
|
" FROM (SELECT exa_prints.UsrCod AS UsrCod" // row[0]
|
||||||
" FROM exa_prints,exa_sessions,exa_exams"
|
" FROM exa_prints,exa_sessions,exa_exams"
|
||||||
" WHERE exa_prints.SesCod=%ld"
|
" WHERE exa_prints.SesCod=%ld"
|
||||||
|
@ -546,17 +538,13 @@ static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
||||||
"usr_data.FirstName",
|
"usr_data.FirstName",
|
||||||
SesCod,
|
SesCod,
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
if (NumUsrs)
|
|
||||||
{
|
|
||||||
/***** List sessions results for each user *****/
|
/***** List sessions results for each user *****/
|
||||||
for (NumUsr = 0;
|
for (NumUsr = 0;
|
||||||
NumUsr < NumUsrs;
|
NumUsr < NumUsrs;
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get session code (row[0]) */
|
/* Get session code (row[0]) */
|
||||||
if ((Gbl.Usrs.Other.UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
|
if ((Gbl.Usrs.Other.UsrDat.UsrCod = DB_GetNextCode (mysql_res)) > 0)
|
||||||
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS))
|
||||||
if (Usr_CheckIfICanViewTstExaMchResult (&Gbl.Usrs.Other.UsrDat))
|
if (Usr_CheckIfICanViewTstExaMchResult (&Gbl.Usrs.Other.UsrDat))
|
||||||
{
|
{
|
||||||
|
@ -564,8 +552,6 @@ static void ExaRes_ListAllResultsInSes (struct Exa_Exams *Exams,long SesCod)
|
||||||
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat);
|
||||||
ExaRes_ShowResults (Exams,Usr_OTHER,SesCod,-1L,NULL);
|
ExaRes_ShowResults (Exams,Usr_OTHER,SesCod,-1L,NULL);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -814,7 +800,6 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
||||||
char *HidExaSubQuery;
|
char *HidExaSubQuery;
|
||||||
char *ExaSubQuery;
|
char *ExaSubQuery;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
struct UsrData *UsrDat;
|
struct UsrData *UsrDat;
|
||||||
unsigned NumResults;
|
unsigned NumResults;
|
||||||
unsigned NumResult;
|
unsigned NumResult;
|
||||||
|
@ -955,10 +940,8 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
||||||
NumResult < NumResults;
|
NumResult < NumResults;
|
||||||
NumResult++)
|
NumResult++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get print code (row[0]) */
|
/* Get print code (row[0]) */
|
||||||
if ((Print.PrnCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((Print.PrnCod = DB_GetNextCode (mysql_res)) < 0)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of exam print.");
|
Lay_ShowErrorAndExit ("Wrong code of exam print.");
|
||||||
|
|
||||||
/* Get print data */
|
/* Get print data */
|
||||||
|
|
|
@ -646,7 +646,7 @@ unsigned ExaSet_GetNumQstsExam (long ExaCod)
|
||||||
|
|
||||||
/***** Get total number of questions to appear in exam print *****/
|
/***** 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",
|
if (!DB_QuerySELECT (&mysql_res,"can not get number of questions in an exam print",
|
||||||
"SELECT SUM(NumQstsToPrint)"
|
"SELECT SUM(NumQstsToPrint)" // row[0]
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE ExaCod=%ld",
|
" WHERE ExaCod=%ld",
|
||||||
ExaCod))
|
ExaCod))
|
||||||
|
@ -790,7 +790,7 @@ static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod)
|
||||||
|
|
||||||
/***** Get set index from set code *****/
|
/***** Get set index from set code *****/
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get set index",
|
if (!DB_QuerySELECT (&mysql_res,"can not get set index",
|
||||||
"SELECT SetInd"
|
"SELECT SetInd" // row[0]
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE SetCod=%u"
|
" WHERE SetCod=%u"
|
||||||
" AND ExaCod=%ld", // Extra check
|
" AND ExaCod=%ld", // Extra check
|
||||||
|
@ -813,27 +813,19 @@ static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod)
|
||||||
|
|
||||||
static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd)
|
static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
long SetCod;
|
long SetCod;
|
||||||
|
|
||||||
/***** Get set code from set index *****/
|
/***** Get set code from set index *****/
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get set code",
|
SetCod = DB_QuerySELECTCode ("can not get set code",
|
||||||
"SELECT SetCod"
|
"SELECT SetCod"
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE ExaCod=%ld"
|
" WHERE ExaCod=%ld"
|
||||||
" AND SetInd=%u",
|
" AND SetInd=%u",
|
||||||
ExaCod,SetInd))
|
ExaCod,
|
||||||
|
SetInd);
|
||||||
|
if (SetCod <= 0)
|
||||||
Lay_ShowErrorAndExit ("Error: wrong set index.");
|
Lay_ShowErrorAndExit ("Error: wrong set index.");
|
||||||
|
|
||||||
/***** Get set code (row[0]) *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
if ((SetCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
|
||||||
Lay_ShowErrorAndExit ("Error: wrong set code.");
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return SetCod;
|
return SetCod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,7 +843,7 @@ static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod)
|
||||||
|
|
||||||
/***** Get maximum set index in an exam from database *****/
|
/***** Get maximum set index in an exam from database *****/
|
||||||
DB_QuerySELECT (&mysql_res,"can not get max set index",
|
DB_QuerySELECT (&mysql_res,"can not get max set index",
|
||||||
"SELECT MAX(SetInd)"
|
"SELECT MAX(SetInd)" // row[0]
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE ExaCod=%ld",
|
" WHERE ExaCod=%ld",
|
||||||
ExaCod);
|
ExaCod);
|
||||||
|
@ -882,7 +874,7 @@ static unsigned ExaSet_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd)
|
||||||
// Although indexes are always continuous...
|
// Although indexes are always continuous...
|
||||||
// ...this implementation works even with non continuous indexes
|
// ...this implementation works even with non continuous indexes
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get previous set index",
|
if (!DB_QuerySELECT (&mysql_res,"can not get previous set index",
|
||||||
"SELECT MAX(SetInd)"
|
"SELECT MAX(SetInd)" // row[0]
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE ExaCod=%ld"
|
" WHERE ExaCod=%ld"
|
||||||
" AND SetInd<%u",
|
" AND SetInd<%u",
|
||||||
|
@ -918,7 +910,7 @@ static unsigned ExaSet_GetNextSetIndexInExam (long ExaCod,unsigned SetInd)
|
||||||
// Although indexes are always continuous...
|
// Although indexes are always continuous...
|
||||||
// ...this implementation works even with non continuous indexes
|
// ...this implementation works even with non continuous indexes
|
||||||
if (!DB_QuerySELECT (&mysql_res,"can not get next set index",
|
if (!DB_QuerySELECT (&mysql_res,"can not get next set index",
|
||||||
"SELECT MIN(SetInd)"
|
"SELECT MIN(SetInd)" // row[0]
|
||||||
" FROM exa_sets"
|
" FROM exa_sets"
|
||||||
" WHERE ExaCod=%ld"
|
" WHERE ExaCod=%ld"
|
||||||
" AND SetInd>%u",
|
" AND SetInd>%u",
|
||||||
|
@ -1280,7 +1272,6 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
|
||||||
extern const char *Txt_No_INDEX;
|
extern const char *Txt_No_INDEX;
|
||||||
extern const char *Txt_Question;
|
extern const char *Txt_Question;
|
||||||
unsigned NumQst;
|
unsigned NumQst;
|
||||||
MYSQL_ROW row;
|
|
||||||
struct Tst_Question Question;
|
struct Tst_Question Question;
|
||||||
char *Anchor;
|
char *Anchor;
|
||||||
static Act_Action_t NextAction[Tst_NUM_VALIDITIES] =
|
static Act_Action_t NextAction[Tst_NUM_VALIDITIES] =
|
||||||
|
@ -1321,12 +1312,8 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams,
|
||||||
Tst_QstConstructor (&Question);
|
Tst_QstConstructor (&Question);
|
||||||
|
|
||||||
/***** Get question data *****/
|
/***** Get question data *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
/* Get question code */
|
||||||
/*
|
Exams->QstCod = Question.QstCod = DB_GetNextCode (mysql_res);
|
||||||
row[0] QstCod
|
|
||||||
*/
|
|
||||||
/* Get question code (row[0]) */
|
|
||||||
Exams->QstCod = Question.QstCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
ExaSet_GetQstDataFromDB (&Question);
|
ExaSet_GetQstDataFromDB (&Question);
|
||||||
|
|
||||||
/***** Build anchor string *****/
|
/***** Build anchor string *****/
|
||||||
|
|
|
@ -1079,8 +1079,8 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void)
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT InsCod,"
|
"SELECT InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" GROUP BY InsCod"
|
" GROUP BY InsCod"
|
||||||
" ORDER BY N DESC");
|
" ORDER BY N DESC");
|
||||||
|
@ -1088,8 +1088,8 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void)
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ins_instits,"
|
" FROM ins_instits,"
|
||||||
"ctr_centers"
|
"ctr_centers"
|
||||||
" WHERE ins_instits.CtyCod=%ld"
|
" WHERE ins_instits.CtyCod=%ld"
|
||||||
|
@ -1104,8 +1104,8 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void)
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT InsCod,"
|
"SELECT InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ctr_centers"
|
" FROM ctr_centers"
|
||||||
" WHERE InsCod=%ld"
|
" WHERE InsCod=%ld"
|
||||||
" GROUP BY InsCod"
|
" GROUP BY InsCod"
|
||||||
|
@ -1149,8 +1149,8 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void)
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees"
|
"deg_degrees"
|
||||||
" WHERE ctr_centers.CtrCod=deg_degrees.CtrCod"
|
" WHERE ctr_centers.CtrCod=deg_degrees.CtrCod"
|
||||||
|
@ -1160,8 +1160,8 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void)
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ins_instits,"
|
" FROM ins_instits,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
"deg_degrees"
|
"deg_degrees"
|
||||||
|
@ -1178,8 +1178,8 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void)
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees"
|
"deg_degrees"
|
||||||
" WHERE ctr_centers.InsCod=%ld"
|
" WHERE ctr_centers.InsCod=%ld"
|
||||||
|
@ -1225,8 +1225,8 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void)
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"crs_courses"
|
"crs_courses"
|
||||||
|
@ -1238,8 +1238,8 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void)
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ins_instits,"
|
" FROM ins_instits,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
|
@ -1258,8 +1258,8 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void)
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(*) AS N"
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"crs_courses"
|
"crs_courses"
|
||||||
|
@ -1307,8 +1307,8 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void)
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(DISTINCT crs_users.UsrCod) AS N"
|
"COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1]
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
|
@ -1322,8 +1322,8 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void)
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(DISTINCT crs_users.UsrCod) AS N"
|
"COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1]
|
||||||
" FROM ins_instits,"
|
" FROM ins_instits,"
|
||||||
"ctr_centers,"
|
"ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
|
@ -1344,8 +1344,8 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void)
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumInss = (unsigned)
|
NumInss = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT ctr_centers.InsCod,"
|
"SELECT ctr_centers.InsCod," // row[0]
|
||||||
"COUNT(DISTINCT crs_users.UsrCod) AS N"
|
"COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1]
|
||||||
" FROM ctr_centers,"
|
" FROM ctr_centers,"
|
||||||
"deg_degrees,"
|
"deg_degrees,"
|
||||||
"crs_courses,"
|
"crs_courses,"
|
||||||
|
@ -1396,7 +1396,8 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumInss =
|
NumInss =
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT InsCod,COUNT(*) AS N"
|
"SELECT InsCod," // row[0]
|
||||||
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM usr_data"
|
" FROM usr_data"
|
||||||
" WHERE InsCod>0"
|
" WHERE InsCod>0"
|
||||||
" GROUP BY InsCod"
|
" GROUP BY InsCod"
|
||||||
|
@ -1405,7 +1406,8 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
NumInss =
|
NumInss =
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT usr_data.InsCod,COUNT(*) AS N"
|
"SELECT usr_data.InsCod," // row[0]
|
||||||
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM ins_instits,usr_data"
|
" FROM ins_instits,usr_data"
|
||||||
" WHERE ins_instits.CtyCod=%ld"
|
" WHERE ins_instits.CtyCod=%ld"
|
||||||
" AND ins_instits.InsCod=usr_data.InsCod"
|
" AND ins_instits.InsCod=usr_data.InsCod"
|
||||||
|
@ -1419,7 +1421,8 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
||||||
case Hie_Lvl_CRS:
|
case Hie_Lvl_CRS:
|
||||||
NumInss =
|
NumInss =
|
||||||
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions",
|
||||||
"SELECT InsCod,COUNT(*) AS N"
|
"SELECT InsCod," // row[0]
|
||||||
|
"COUNT(*) AS N" // row[1]
|
||||||
" FROM usr_data"
|
" FROM usr_data"
|
||||||
" WHERE InsCod=%ld"
|
" WHERE InsCod=%ld"
|
||||||
" GROUP BY InsCod"
|
" GROUP BY InsCod"
|
||||||
|
@ -3583,8 +3586,8 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumRows =
|
NumRows =
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(*),"
|
"SELECT COUNT(*)," // row[0]
|
||||||
"COUNT(DISTINCT UsrCod)"
|
"COUNT(DISTINCT UsrCod)" // row[1]
|
||||||
" FROM tml_notes WHERE NoteType=%u",
|
" FROM tml_notes WHERE NoteType=%u",
|
||||||
NoteType);
|
NoteType);
|
||||||
break;
|
break;
|
||||||
|
@ -3735,8 +3738,8 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
||||||
case Hie_Lvl_SYS:
|
case Hie_Lvl_SYS:
|
||||||
NumRows =
|
NumRows =
|
||||||
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
DB_QuerySELECT (&mysql_res,"can not get number of social notes",
|
||||||
"SELECT COUNT(*),"
|
"SELECT COUNT(*)," // row[0]
|
||||||
"COUNT(DISTINCT UsrCod)"
|
"COUNT(DISTINCT UsrCod)" // row[1]
|
||||||
" FROM tml_notes");
|
" FROM tml_notes");
|
||||||
break;
|
break;
|
||||||
case Hie_Lvl_CTY:
|
case Hie_Lvl_CTY:
|
||||||
|
|
|
@ -2671,7 +2671,6 @@ static void Brw_SetPathFileBrowser (void)
|
||||||
bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
|
bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsr;
|
unsigned NumUsr;
|
||||||
long UsrCod;
|
long UsrCod;
|
||||||
|
@ -2692,8 +2691,7 @@ bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName)
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
/* Get next user */
|
/* Get next user */
|
||||||
row = mysql_fetch_row (mysql_res);
|
UsrCod = DB_GetNextCode (mysql_res);
|
||||||
UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Check if folder exists */
|
/* Check if folder exists */
|
||||||
snprintf (PathFolder,sizeof (PathFolder),"%s/usr/%02u/%ld/%s/%s",
|
snprintf (PathFolder,sizeof (PathFolder),"%s/usr/%02u/%ld/%s/%s",
|
||||||
|
@ -2782,7 +2780,6 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
||||||
extern const char *Txt_Folders_renamed;
|
extern const char *Txt_Folders_renamed;
|
||||||
extern const char *Txt_Folders_not_renamed;
|
extern const char *Txt_Folders_not_renamed;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsr;
|
unsigned NumUsr;
|
||||||
long UsrCod;
|
long UsrCod;
|
||||||
|
@ -2795,8 +2792,8 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
||||||
unsigned NumUsrsSuccess = 0;
|
unsigned NumUsrsSuccess = 0;
|
||||||
|
|
||||||
/***** Get all the users belonging to current course from database *****/
|
/***** Get all the users belonging to current course from database *****/
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get users"
|
NumUsrs = (unsigned)
|
||||||
" from current course",
|
DB_QuerySELECT (&mysql_res,"can not get users from current course",
|
||||||
"SELECT UsrCod" // row[0]
|
"SELECT UsrCod" // row[0]
|
||||||
" FROM crs_users"
|
" FROM crs_users"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
|
@ -2808,8 +2805,7 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
/* Get next user */
|
/* Get next user */
|
||||||
row = mysql_fetch_row (mysql_res);
|
UsrCod = DB_GetNextCode (mysql_res);
|
||||||
UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Rename folder if exists */
|
/* Rename folder if exists */
|
||||||
snprintf (PathOldFolder,sizeof (PathOldFolder),"%s/usr/%02u/%ld/%s/%s",
|
snprintf (PathOldFolder,sizeof (PathOldFolder),"%s/usr/%02u/%ld/%s/%s",
|
||||||
|
@ -2838,8 +2834,7 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
/* Get next user */
|
/* Get next user */
|
||||||
row = mysql_fetch_row (mysql_res);
|
UsrCod = DB_GetNextCode (mysql_res);
|
||||||
UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Rename folder if exists */
|
/* Rename folder if exists */
|
||||||
snprintf (PathOldFolder,sizeof (PathOldFolder),"%s/usr/%02u/%ld/%s/%s",
|
snprintf (PathOldFolder,sizeof (PathOldFolder),"%s/usr/%02u/%ld/%s/%s",
|
||||||
|
@ -2908,15 +2903,14 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con
|
||||||
void Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (const char *FolderName)
|
void Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (const char *FolderName)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
unsigned NumUsr;
|
unsigned NumUsr;
|
||||||
long UsrCod;
|
long UsrCod;
|
||||||
char PathFolder[PATH_MAX * 2 + 128];
|
char PathFolder[PATH_MAX * 2 + 128];
|
||||||
|
|
||||||
/***** Get all the users belonging to current course from database *****/
|
/***** Get all the users belonging to current course from database *****/
|
||||||
NumUsrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get users"
|
NumUsrs = (unsigned)
|
||||||
" from current course",
|
DB_QuerySELECT (&mysql_res,"can not get users from current course",
|
||||||
"SELECT UsrCod" // row[0]
|
"SELECT UsrCod" // row[0]
|
||||||
" FROM crs_users"
|
" FROM crs_users"
|
||||||
" WHERE CrsCod=%ld",
|
" WHERE CrsCod=%ld",
|
||||||
|
@ -2928,8 +2922,7 @@ void Brw_RemoveFoldersAssignmentsIfExistForAllUsrs (const char *FolderName)
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
/* Get next user */
|
/* Get next user */
|
||||||
row = mysql_fetch_row (mysql_res);
|
UsrCod = DB_GetNextCode (mysql_res);
|
||||||
UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Remove tree if exists */
|
/* Remove tree if exists */
|
||||||
snprintf (PathFolder,sizeof (PathFolder),"%s/usr/%02u/%ld/%s/%s",
|
snprintf (PathFolder,sizeof (PathFolder),"%s/usr/%02u/%ld/%s/%s",
|
||||||
|
@ -9381,7 +9374,7 @@ bool Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (Brw_FileType_t FileType,const cha
|
||||||
/***** Get if a file or folder is hidden from database *****/
|
/***** Get if a file or folder is hidden from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not check if a file is hidden",
|
if (DB_QuerySELECT (&mysql_res,"can not check if a file is hidden",
|
||||||
"SELECT Hidden" // row[0]
|
"SELECT Hidden" // row[0]
|
||||||
" FROM brw_files" // row[1]
|
" FROM brw_files"
|
||||||
" WHERE FileBrowser=%u"
|
" WHERE FileBrowser=%u"
|
||||||
" AND Cod=%ld"
|
" AND Cod=%ld"
|
||||||
" AND ZoneUsrCod=%ld"
|
" AND ZoneUsrCod=%ld"
|
||||||
|
@ -10374,12 +10367,9 @@ long Brw_GetFilCodByPath (const char *Path,bool OnlyIfPublic)
|
||||||
{
|
{
|
||||||
long Cod = Brw_GetCodForFiles ();
|
long Cod = Brw_GetCodForFiles ();
|
||||||
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
|
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
long FilCod;
|
|
||||||
|
|
||||||
/***** Get code of a file from database *****/
|
/***** Get code of a file from database *****/
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get file code",
|
return DB_QuerySELECTCode ("can not get file code",
|
||||||
"SELECT FilCod"
|
"SELECT FilCod"
|
||||||
" FROM brw_files"
|
" FROM brw_files"
|
||||||
" WHERE FileBrowser=%u"
|
" WHERE FileBrowser=%u"
|
||||||
|
@ -10388,24 +10378,11 @@ long Brw_GetFilCodByPath (const char *Path,bool OnlyIfPublic)
|
||||||
" AND Path='%s'"
|
" AND Path='%s'"
|
||||||
"%s",
|
"%s",
|
||||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||||
Cod,ZoneUsrCod,
|
Cod,
|
||||||
|
ZoneUsrCod,
|
||||||
Path,
|
Path,
|
||||||
OnlyIfPublic ? " AND Public='Y'" :
|
OnlyIfPublic ? " AND Public='Y'" :
|
||||||
""))
|
"");
|
||||||
{
|
|
||||||
/* Get row */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get file code (row[0]) */
|
|
||||||
FilCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
FilCod = -1L;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return FilCod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -11749,15 +11726,11 @@ static bool Brw_CheckIfICanModifyPrjAssFileOrFolder (void)
|
||||||
|
|
||||||
static long Brw_GetPublisherOfSubtree (void)
|
static long Brw_GetPublisherOfSubtree (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumRows;
|
|
||||||
long PublisherUsrCod;
|
|
||||||
long Cod = Brw_GetCodForFiles ();
|
long Cod = Brw_GetCodForFiles ();
|
||||||
|
|
||||||
/***** Get all common files that are equal to full path (including filename)
|
/***** Get all common files that are equal to full path (including filename)
|
||||||
or that are under that full path from database *****/
|
or that are under that full path from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get publishers of files",
|
return DB_QuerySELECTCode ("can not get publishers of files",
|
||||||
"SELECT DISTINCT(PublisherUsrCod)"
|
"SELECT DISTINCT(PublisherUsrCod)"
|
||||||
" FROM brw_files"
|
" FROM brw_files"
|
||||||
" WHERE FileBrowser=%u"
|
" WHERE FileBrowser=%u"
|
||||||
|
@ -11769,21 +11742,6 @@ static long Brw_GetPublisherOfSubtree (void)
|
||||||
Cod,
|
Cod,
|
||||||
Gbl.FileBrowser.FilFolLnk.Full,
|
Gbl.FileBrowser.FilFolLnk.Full,
|
||||||
Gbl.FileBrowser.FilFolLnk.Full);
|
Gbl.FileBrowser.FilFolLnk.Full);
|
||||||
|
|
||||||
/***** Check all common files that are equal to full path (including filename)
|
|
||||||
or that are under that full path *****/
|
|
||||||
if (NumRows == 1) // Get the publisher of the file(s)
|
|
||||||
{
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
PublisherUsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
PublisherUsrCod = -1L;
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return PublisherUsrCod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -675,7 +675,6 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Following;
|
extern const char *Txt_Following;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumUsrs;
|
unsigned long NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned long NumUsr;
|
||||||
struct UsrData FollowingUsrDat;
|
struct UsrData FollowingUsrDat;
|
||||||
|
@ -685,7 +684,7 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
/***** Check if a user is a follower of another user *****/
|
/***** Check if a user is a follower of another user *****/
|
||||||
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get followed users",
|
NumUsrs = DB_QuerySELECT (&mysql_res,"can not get followed users",
|
||||||
"SELECT FollowedCod"
|
"SELECT FollowedCod" // row[0]
|
||||||
" FROM usr_follow"
|
" FROM usr_follow"
|
||||||
" WHERE FollowerCod=%ld"
|
" WHERE FollowerCod=%ld"
|
||||||
" ORDER BY FollowTime DESC",
|
" ORDER BY FollowTime DESC",
|
||||||
|
@ -705,11 +704,8 @@ static void Fol_ListFollowingUsr (struct UsrData *UsrDat)
|
||||||
NumUsr < NumUsrs;
|
NumUsr < NumUsrs;
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
/***** Get user *****/
|
/***** Get user's code *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
FollowingUsrDat.UsrCod = DB_GetNextCode (mysql_res);
|
||||||
|
|
||||||
/* Get user's code (row[0]) */
|
|
||||||
FollowingUsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/***** Show user *****/
|
/***** Show user *****/
|
||||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
||||||
|
@ -759,7 +755,6 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Followers;
|
extern const char *Txt_Followers;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumUsrs;
|
unsigned long NumUsrs;
|
||||||
unsigned long NumUsr;
|
unsigned long NumUsr;
|
||||||
struct UsrData FollowerUsrDat;
|
struct UsrData FollowerUsrDat;
|
||||||
|
@ -790,11 +785,8 @@ static void Fol_ListFollowersUsr (struct UsrData *UsrDat)
|
||||||
NumUsr < NumUsrs;
|
NumUsr < NumUsrs;
|
||||||
NumUsr++)
|
NumUsr++)
|
||||||
{
|
{
|
||||||
/***** Get user and number of clicks *****/
|
/***** Get user's code *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
FollowerUsrDat.UsrCod = DB_GetNextCode (mysql_res);
|
||||||
|
|
||||||
/* Get user's code (row[0]) */
|
|
||||||
FollowerUsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/***** Show user *****/
|
/***** Show user *****/
|
||||||
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
if ((NumUsr % Fol_NUM_COLUMNS_FOLLOW) == 0)
|
||||||
|
|
72
swad_forum.c
72
swad_forum.c
|
@ -731,9 +731,8 @@ static void For_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT +
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Get subject of a thread from database *****/
|
/***** Get subject of a thread from database *****/
|
||||||
DB_QuerySELECT (&mysql_res,"can not get the subject"
|
DB_QuerySELECT (&mysql_res,"can not get the subject of a thread of a forum",
|
||||||
" of a thread of a forum",
|
"SELECT for_posts.Subject" // row[0]
|
||||||
"SELECT for_posts.Subject"
|
|
||||||
" FROM for_threads,"
|
" FROM for_threads,"
|
||||||
"for_posts"
|
"for_posts"
|
||||||
" WHERE for_threads.ThrCod=%ld"
|
" WHERE for_threads.ThrCod=%ld"
|
||||||
|
@ -827,12 +826,10 @@ static void For_UpdateThrLastPst (long ThrCod,long LastPstCod)
|
||||||
|
|
||||||
static long For_GetLastPstCod (long ThrCod)
|
static long For_GetLastPstCod (long ThrCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
long LastPstCod;
|
long LastPstCod;
|
||||||
|
|
||||||
/***** Get the code of the last post of a thread from database *****/
|
/***** Get the code of the last post of a thread from database *****/
|
||||||
DB_QuerySELECT (&mysql_res,"can not get the most recent post"
|
LastPstCod = DB_QuerySELECTCode ("can not get the most recent post"
|
||||||
" of a thread of a forum",
|
" of a thread of a forum",
|
||||||
"SELECT PstCod"
|
"SELECT PstCod"
|
||||||
" FROM for_posts"
|
" FROM for_posts"
|
||||||
|
@ -840,10 +837,7 @@ static long For_GetLastPstCod (long ThrCod)
|
||||||
" ORDER BY CreatTime DESC"
|
" ORDER BY CreatTime DESC"
|
||||||
" LIMIT 1",
|
" LIMIT 1",
|
||||||
ThrCod);
|
ThrCod);
|
||||||
|
if (LastPstCod <= 0)
|
||||||
/***** Write the subject of the thread *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
if (sscanf (row[0],"%ld",&LastPstCod) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting the most recent post of a thread of a forum.");
|
Lay_ShowErrorAndExit ("Error when getting the most recent post of a thread of a forum.");
|
||||||
|
|
||||||
return LastPstCod;
|
return LastPstCod;
|
||||||
|
@ -894,29 +888,12 @@ static unsigned For_GetNumOfReadersOfThr (long ThrCod)
|
||||||
|
|
||||||
static unsigned For_GetNumOfWritersInThr (long ThrCod)
|
static unsigned For_GetNumOfWritersInThr (long ThrCod)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumWriters;
|
|
||||||
|
|
||||||
/***** Get number of distinct writers in a thread from database *****/
|
/***** Get number of distinct writers in a thread from database *****/
|
||||||
DB_QuerySELECT (&mysql_res,"can not get the number of writers"
|
return DB_QueryCOUNT ("can not get the number of writers in a thread of a forum",
|
||||||
" in a thread of a forum",
|
|
||||||
"SELECT COUNT(DISTINCT UsrCod)"
|
"SELECT COUNT(DISTINCT UsrCod)"
|
||||||
" FROM for_posts"
|
" FROM for_posts"
|
||||||
" WHERE ThrCod=%ld",
|
" WHERE ThrCod=%ld",
|
||||||
ThrCod);
|
ThrCod);
|
||||||
|
|
||||||
/* Get row with number of writers */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get number of writers (row[0]) */
|
|
||||||
if (sscanf (row[0],"%u",&NumWriters) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when getting the number of writers in a thread of a forum.");
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return NumWriters;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2473,7 +2450,6 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
|
||||||
extern const char *Txt_ReaBRders;
|
extern const char *Txt_ReaBRders;
|
||||||
char SubQuery[256];
|
char SubQuery[256];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
char FrameTitle[128 + For_MAX_BYTES_FORUM_NAME];
|
char FrameTitle[128 + For_MAX_BYTES_FORUM_NAME];
|
||||||
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
|
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
|
||||||
unsigned NumThr;
|
unsigned NumThr;
|
||||||
|
@ -2531,13 +2507,9 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
|
||||||
for (NumThr = PaginationThrs.FirstItemVisible, NumThrInScreen = 0;
|
for (NumThr = PaginationThrs.FirstItemVisible, NumThrInScreen = 0;
|
||||||
NumThr <= PaginationThrs.LastItemVisible;
|
NumThr <= PaginationThrs.LastItemVisible;
|
||||||
NumThr++, NumThrInScreen++)
|
NumThr++, NumThrInScreen++)
|
||||||
{
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get thread code(row[0]) */
|
/* Get thread code(row[0]) */
|
||||||
if ((ThrCods[NumThrInScreen] = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((ThrCods[NumThrInScreen] = DB_GetNextCode (mysql_res)) < 0)
|
||||||
Lay_ShowErrorAndExit ("Error when getting thread of a forum.");
|
Lay_ShowErrorAndExit ("Error when getting thread of a forum.");
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
@ -3688,12 +3660,12 @@ static void For_GetThreadData (struct For_Thread *Thr)
|
||||||
/***** Get data of a thread from database *****/
|
/***** Get data of a thread from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
|
||||||
" of a thread of a forum",
|
" of a thread of a forum",
|
||||||
"SELECT m0.PstCod,"
|
"SELECT m0.PstCod," // row[0]
|
||||||
"m1.PstCod,"
|
"m1.PstCod," // row[1]
|
||||||
"m0.UsrCod,"
|
"m0.UsrCod," // row[2]
|
||||||
"m1.UsrCod,"
|
"m1.UsrCod," // row[3]
|
||||||
"UNIX_TIMESTAMP(m0.CreatTime),"
|
"UNIX_TIMESTAMP(m0.CreatTime)," // row[4]
|
||||||
"UNIX_TIMESTAMP(m1.CreatTime),"
|
"UNIX_TIMESTAMP(m1.CreatTime)," // row[5]
|
||||||
"m0.Subject"
|
"m0.Subject"
|
||||||
" FROM for_threads,"
|
" FROM for_threads,"
|
||||||
"for_posts AS m0,"
|
"for_posts AS m0,"
|
||||||
|
@ -4555,31 +4527,13 @@ static bool For_CheckIfICanMoveThreads (void)
|
||||||
|
|
||||||
static long For_GetThrInMyClipboard (void)
|
static long For_GetThrInMyClipboard (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned long NumRows;
|
|
||||||
long ThrCod = -1L;
|
|
||||||
|
|
||||||
/***** Get if there is a thread ready to move in my clipboard from database *****/
|
/***** Get if there is a thread ready to move in my clipboard from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not check if there is"
|
return DB_QuerySELECTCode ("can not check if there is"
|
||||||
" any thread ready to be moved",
|
" any thread ready to be moved",
|
||||||
"SELECT ThrCod"
|
"SELECT ThrCod"
|
||||||
" FROM for_clipboards"
|
" FROM for_clipboards"
|
||||||
" WHERE UsrCod=%ld",
|
" WHERE UsrCod=%ld",
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
|
||||||
if (NumRows == 1)
|
|
||||||
{
|
|
||||||
/* Get thread code */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
if (sscanf (row[0],"%ld",&ThrCod) != 1)
|
|
||||||
Lay_ShowErrorAndExit ("Error when checking if there is any thread ready to be moved.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return ThrCod;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1429,6 +1429,15 @@ void Lay_WrongProjectExit (void)
|
||||||
Lay_ShowErrorAndExit ("Wrong project.");
|
Lay_ShowErrorAndExit ("Wrong project.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********** Write error message and exit when wrong call for exam ************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Lay_WrongCallForExamExit (void)
|
||||||
|
{
|
||||||
|
Lay_ShowErrorAndExit ("Wrong call for exam.");
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** Write error message and exit when wrong exam *****************/
|
/************** Write error message and exit when wrong exam *****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -74,6 +74,7 @@ void Lay_WrongScopeExit (void);
|
||||||
void Lay_WrongOrderExit (void);
|
void Lay_WrongOrderExit (void);
|
||||||
void Lay_WrongTypeOfViewExit (void);
|
void Lay_WrongTypeOfViewExit (void);
|
||||||
void Lay_WrongProjectExit (void);
|
void Lay_WrongProjectExit (void);
|
||||||
|
void Lay_WrongCallForExamExit (void);
|
||||||
void Lay_WrongExamExit (void);
|
void Lay_WrongExamExit (void);
|
||||||
void Lay_WrongSetExit (void);
|
void Lay_WrongSetExit (void);
|
||||||
void Lay_WrongExamSessionExit (void);
|
void Lay_WrongExamSessionExit (void);
|
||||||
|
|
|
@ -1929,7 +1929,6 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
|
||||||
|
|
||||||
void Med_RemoveMediaFromAllRows (unsigned NumMedia,MYSQL_RES *mysql_res)
|
void Med_RemoveMediaFromAllRows (unsigned NumMedia,MYSQL_RES *mysql_res)
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumMed;
|
unsigned NumMed;
|
||||||
long MedCod;
|
long MedCod;
|
||||||
|
|
||||||
|
@ -1938,9 +1937,8 @@ void Med_RemoveMediaFromAllRows (unsigned NumMedia,MYSQL_RES *mysql_res)
|
||||||
NumMed < NumMedia;
|
NumMed < NumMedia;
|
||||||
NumMed++)
|
NumMed++)
|
||||||
{
|
{
|
||||||
/***** Get media code (row[0]) *****/
|
/***** Get media code *****/
|
||||||
row = mysql_fetch_row (mysql_res);
|
MedCod = DB_GetNextCode (mysql_res);
|
||||||
MedCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/***** Remove media files *****/
|
/***** Remove media files *****/
|
||||||
Med_RemoveMedia (MedCod);
|
Med_RemoveMedia (MedCod);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user