mirror of https://github.com/acanas/swad-core.git
Version 20.66.1: Apr 17, 2021 Code refactoring in database deletes.
This commit is contained in:
parent
4d80b0a917
commit
79f5581860
|
@ -1068,7 +1068,8 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
|
|||
|
||||
/***** Remove user as administrator of any degree *****/
|
||||
DB_QueryDELETE ("can not remove a user as administrator",
|
||||
"DELETE FROM usr_admins WHERE UsrCod=%ld",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrDat->UsrCod);
|
||||
|
||||
if (QuietOrVerbose == Cns_VERBOSE)
|
||||
|
|
|
@ -1371,7 +1371,7 @@ void Agd_RemoveEvent (void)
|
|||
DB_QueryDELETE ("can not remove event",
|
||||
"DELETE FROM agd_agendas"
|
||||
" WHERE AgdCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
" AND UsrCod=%ld",
|
||||
AgdEvent.AgdCod,
|
||||
AgdEvent.UsrCod);
|
||||
|
||||
|
|
|
@ -590,7 +590,8 @@ void Ann_RemoveAnnouncement (void)
|
|||
|
||||
/***** Remove users who have seen the announcement *****/
|
||||
DB_QueryDELETE ("can not remove announcement",
|
||||
"DELETE FROM ann_seen WHERE AnnCod=%ld",
|
||||
"DELETE FROM ann_seen"
|
||||
" WHERE AnnCod=%ld",
|
||||
AnnCod);
|
||||
|
||||
/***** Write message of success *****/
|
||||
|
|
|
@ -1675,7 +1675,7 @@ void Att_RemoveCrsAttEvents (long CrsCod)
|
|||
" USING att_events,"
|
||||
"att_groups"
|
||||
" WHERE att_events.CrsCod=%ld"
|
||||
" AND att_events.AttCod=att_groups.AttCod",
|
||||
" AND att_events.AttCod=att_groups.AttCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove attendance events *****/
|
||||
|
|
|
@ -1243,7 +1243,8 @@ void Ctr_RemoveCenter (void)
|
|||
|
||||
/***** Remove center *****/
|
||||
DB_QueryDELETE ("can not remove a center",
|
||||
"DELETE FROM ctr_centers WHERE CtrCod=%ld",
|
||||
"DELETE FROM ctr_centers"
|
||||
" WHERE CtrCod=%ld",
|
||||
Ctr_EditingCtr->CtrCod);
|
||||
|
||||
/***** Flush caches *****/
|
||||
|
|
|
@ -600,13 +600,14 @@ TODO: Salvador Romero Cort
|
|||
|
||||
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.66 (2021-04-17)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.66.1 (2021-04-17)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.6.2.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 20.66.1: Apr 17, 2021 Code refactoring in database deletes. (309123 lines)
|
||||
Version 20.66: Apr 17, 2021 Code refactoring in database updates. (308972 lines)
|
||||
Version 20.65.1: Apr 17, 2021 Code refactoring in database replaces. (308677 lines)
|
||||
Version 20.65: Apr 17, 2021 Code refactoring in database inserts. (308629 lines)
|
||||
|
|
|
@ -450,7 +450,7 @@ void Con_RemoveOldConnected (void)
|
|||
"DELETE FROM usr_connected"
|
||||
" WHERE UsrCod NOT IN"
|
||||
" (SELECT DISTINCT(UsrCod)"
|
||||
" FROM ses_sessions)");
|
||||
" FROM ses_sessions)");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -1903,12 +1903,14 @@ void Crs_RemoveCourseCompletely (long CrsCod)
|
|||
|
||||
/***** Remove course from table of last accesses to courses in database *****/
|
||||
DB_QueryDELETE ("can not remove a course",
|
||||
"DELETE FROM crs_last WHERE CrsCod=%ld",
|
||||
"DELETE FROM crs_last"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove course from table of courses in database *****/
|
||||
DB_QueryDELETE ("can not remove a course",
|
||||
"DELETE FROM crs_courses WHERE CrsCod=%ld",
|
||||
"DELETE FROM crs_courses"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1537,12 +1537,16 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
|||
|
||||
/***** Remove administrators of this degree *****/
|
||||
DB_QueryDELETE ("can not remove administrators of a degree",
|
||||
"DELETE FROM usr_admins WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_DEG),DegCod);
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_DEG),
|
||||
DegCod);
|
||||
|
||||
/***** Remove the degree *****/
|
||||
DB_QueryDELETE ("can not remove a degree",
|
||||
"DELETE FROM deg_degrees WHERE DegCod=%ld",
|
||||
"DELETE FROM deg_degrees"
|
||||
" WHERE DegCod=%ld",
|
||||
DegCod);
|
||||
|
||||
/***** Flush caches *****/
|
||||
|
|
|
@ -486,5 +486,7 @@ void Dup_RemoveUsrFromDuplicated (long UsrCod)
|
|||
{
|
||||
/***** Remove user from list of duplicated users *****/
|
||||
DB_QueryDELETE ("can not remove a user from possible duplicates",
|
||||
"DELETE FROM usr_duplicated WHERE UsrCod=%ld",UsrCod);
|
||||
"DELETE FROM usr_duplicated"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
|
|
@ -3073,7 +3073,8 @@ static void Enr_RemoveEnrolmentRequest (long CrsCod,long UsrCod)
|
|||
"DELETE FROM crs_requests"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
CrsCod,UsrCod);
|
||||
CrsCod,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4230,12 +4231,14 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
|||
"DELETE FROM crs_user_settings"
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
UsrDat->UsrCod,Crs->CrsCod);
|
||||
UsrDat->UsrCod,
|
||||
Crs->CrsCod);
|
||||
DB_QueryDELETE ("can not remove a user from a course",
|
||||
"DELETE FROM crs_users"
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Crs->CrsCod,UsrDat->UsrCod);
|
||||
Crs->CrsCod,
|
||||
UsrDat->UsrCod);
|
||||
|
||||
/***** Flush caches *****/
|
||||
Usr_FlushCachesUsr ();
|
||||
|
@ -4343,8 +4346,12 @@ static void Enr_EffectivelyRemAdm (struct UsrData *UsrDat,Hie_Lvl_Level_t Scope,
|
|||
/***** Remove user from the table of admins *****/
|
||||
DB_QueryDELETE ("can not remove an administrator",
|
||||
"DELETE FROM usr_admins"
|
||||
" WHERE UsrCod=%ld AND Scope='%s' AND Cod=%ld",
|
||||
UsrDat->UsrCod,Sco_GetDBStrFromScope (Scope),Cod);
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
UsrDat->UsrCod,
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_removed_as_administrator_of_Y,
|
||||
UsrDat->FullName,InsCtrDegName);
|
||||
|
|
32
swad_exam.c
32
swad_exam.c
|
@ -1159,9 +1159,10 @@ static void Exa_RemoveExamFromAllTables (long ExaCod)
|
|||
/***** Remove exam questions *****/
|
||||
DB_QueryDELETE ("can not remove exam questions",
|
||||
"DELETE FROM exa_set_questions"
|
||||
" USING exa_sets,exa_set_questions"
|
||||
" USING exa_sets,"
|
||||
"exa_set_questions"
|
||||
" WHERE exa_sets.ExaCod=%ld"
|
||||
" AND exa_sets.SetCod=exa_set_questions.SetCod",
|
||||
" AND exa_sets.SetCod=exa_set_questions.SetCod",
|
||||
ExaCod);
|
||||
|
||||
/***** Remove exam sets *****/
|
||||
|
@ -1172,7 +1173,8 @@ static void Exa_RemoveExamFromAllTables (long ExaCod)
|
|||
|
||||
/***** Remove exam *****/
|
||||
DB_QueryDELETE ("can not remove exam",
|
||||
"DELETE FROM exa_exams WHERE ExaCod=%ld",
|
||||
"DELETE FROM exa_exams"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod);
|
||||
}
|
||||
|
||||
|
@ -1195,28 +1197,34 @@ void Exa_RemoveCrsExams (long CrsCod)
|
|||
/***** Remove the answers in set of questions *****/
|
||||
DB_QueryDELETE ("can not remove answers in course exams",
|
||||
"DELETE FROM exa_set_answers"
|
||||
" USING exa_exams,exa_sets,exa_set_questions,exa_set_answers"
|
||||
" USING exa_exams,"
|
||||
"exa_sets,"
|
||||
"exa_set_questions,"
|
||||
"exa_set_answers"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sets.ExaCod",
|
||||
" AND exa_sets.SetCod=exa_set_questions.SetCod"
|
||||
" AND exa_set_questions.QstCod=exa_set_answers.QstCod",
|
||||
" AND exa_exams.ExaCod=exa_sets.ExaCod",
|
||||
" AND exa_sets.SetCod=exa_set_questions.SetCod"
|
||||
" AND exa_set_questions.QstCod=exa_set_answers.QstCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove the questions in set of questions *****/
|
||||
DB_QueryDELETE ("can not remove questions in course exams",
|
||||
"DELETE FROM exa_set_questions"
|
||||
" USING exa_exams,exa_sets,exa_set_questions"
|
||||
" USING exa_exams,"
|
||||
"exa_sets,"
|
||||
"exa_set_questions"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sets.ExaCod",
|
||||
" AND exa_sets.SetCod=exa_set_questions.SetCod",
|
||||
" AND exa_exams.ExaCod=exa_sets.ExaCod",
|
||||
" AND exa_sets.SetCod=exa_set_questions.SetCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove the sets of questions in exams *****/
|
||||
DB_QueryDELETE ("can not remove sets in course exams",
|
||||
"DELETE FROM exa_sets"
|
||||
" USING exa_exams,exa_sets"
|
||||
" USING exa_exams,"
|
||||
"exa_sets"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sets.ExaCod",
|
||||
" AND exa_exams.ExaCod=exa_sets.ExaCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove the exams *****/
|
||||
|
|
|
@ -1547,9 +1547,10 @@ void ExaPrn_RemovePrintsMadeByUsrInAllCrss (long UsrCod)
|
|||
/***** Remove exam prints questions for the given user *****/
|
||||
DB_QueryDELETE ("can not remove exam prints made by a user",
|
||||
"DELETE FROM exa_print_questions"
|
||||
" USING exa_prints,exa_print_questions"
|
||||
" USING exa_prints,"
|
||||
"exa_print_questions"
|
||||
" WHERE exa_prints.UsrCod=%ld"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
UsrCod);
|
||||
|
||||
/***** Remove exam prints made by the given user *****/
|
||||
|
@ -1568,23 +1569,30 @@ void ExaPrn_RemovePrintsMadeByUsrInCrs (long UsrCod,long CrsCod)
|
|||
/***** Remove questions of exams prints made by the given user in the given course *****/
|
||||
DB_QueryDELETE ("can not remove exams prints made by a user in a course",
|
||||
"DELETE FROM exa_print_questions"
|
||||
" USING exa_exams,exa_sessions,exa_prints,exa_print_questions"
|
||||
" USING exa_exams,"
|
||||
"exa_sessions,"
|
||||
"exa_prints,"
|
||||
"exa_print_questions"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.UsrCod=%ld"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
CrsCod,UsrCod);
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.UsrCod=%ld"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
CrsCod,
|
||||
UsrCod);
|
||||
|
||||
/***** Remove exams prints made by the given user in the given course *****/
|
||||
DB_QueryDELETE ("can not remove exams prints made by a user in a course",
|
||||
"DELETE FROM exa_prints"
|
||||
" USING exa_exams,exa_sessions,exa_prints"
|
||||
" USING exa_exams,"
|
||||
"exa_sessions,"
|
||||
"exa_prints"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.UsrCod=%ld",
|
||||
CrsCod,UsrCod);
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.UsrCod=%ld",
|
||||
CrsCod,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1596,19 +1604,24 @@ void ExaPrn_RemoveCrsPrints (long CrsCod)
|
|||
/***** Remove questions of exams prints made by the given user in the given course *****/
|
||||
DB_QueryDELETE ("can not remove exams prints in a course",
|
||||
"DELETE FROM exa_print_questions"
|
||||
" USING exa_exams,exa_sessions,exa_prints,exa_print_questions"
|
||||
" USING exa_exams,"
|
||||
"exa_sessions,"
|
||||
"exa_prints,"
|
||||
"exa_print_questions"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove exams prints made by the given user in the given course *****/
|
||||
DB_QueryDELETE ("can not remove exams prints in a course",
|
||||
"DELETE FROM exa_prints"
|
||||
" USING exa_exams,exa_sessions,exa_prints"
|
||||
" USING exa_exams,"
|
||||
"exa_sessions,"
|
||||
"exa_prints"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod",
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod",
|
||||
CrsCod);
|
||||
}
|
||||
|
|
|
@ -987,7 +987,8 @@ static void ExaSes_RemoveSessionFromAllTables (long SesCod)
|
|||
* TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints
|
||||
DB_QueryDELETE ("can not remove exam print questions in exam session",
|
||||
"DELETE FROM exa_print_questions"
|
||||
" USING exa_print_questions,exa_prints"
|
||||
" USING exa_print_questions,
|
||||
"exa_prints"
|
||||
" WHERE exa_prints.SesCod=%ld"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
SesCod);
|
||||
|
@ -999,12 +1000,14 @@ static void ExaSes_RemoveSessionFromAllTables (long SesCod)
|
|||
|
||||
/***** Remove groups associated to this exam session *****/
|
||||
DB_QueryDELETE ("can not remove groups associated to exam session",
|
||||
"DELETE FROM exa_groups WHERE SesCod=%ld",
|
||||
"DELETE FROM exa_groups"
|
||||
" WHERE SesCod=%ld",
|
||||
SesCod);
|
||||
|
||||
/***** Remove exam session from main table *****/
|
||||
DB_QueryDELETE ("can not remove exam session",
|
||||
"DELETE FROM exa_sessions WHERE SesCod=%ld",
|
||||
"DELETE FROM exa_sessions"
|
||||
" WHERE SesCod=%ld",
|
||||
SesCod);
|
||||
}
|
||||
|
||||
|
@ -1019,30 +1022,35 @@ void ExaSes_RemoveSessionsInExamFromAllTables (long ExaCod)
|
|||
* TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints
|
||||
DB_QueryDELETE ("can not remove exam print questions in exam",
|
||||
"DELETE FROM exa_print_questions"
|
||||
" USING exa_print_questions,exa_prints,exa_sessions"
|
||||
" USING exa_print_questions,
|
||||
"exa_prints,
|
||||
"exa_sessions"
|
||||
" WHERE exa_sessions.ExaCod=%ld"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
ExaCod);
|
||||
DB_QueryDELETE ("can not remove exam prints in exam",
|
||||
"DELETE FROM exa_prints"
|
||||
" USING exa_prints,exa_sessions"
|
||||
" USING exa_prints,
|
||||
"exa_sessions"
|
||||
" WHERE exa_sessions.ExaCod=%ld"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod",
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod",
|
||||
ExaCod);
|
||||
*/
|
||||
|
||||
/***** Remove groups associated to exam sessions of this exam *****/
|
||||
DB_QueryDELETE ("can not remove groups associated to sessions of an exam",
|
||||
"DELETE FROM exa_groups"
|
||||
" USING exa_sessions,exa_groups"
|
||||
" USING exa_sessions,"
|
||||
"exa_groups"
|
||||
" WHERE exa_sessions.ExaCod=%ld"
|
||||
" AND exa_sessions.SesCod=exa_groups.SesCod",
|
||||
" AND exa_sessions.SesCod=exa_groups.SesCod",
|
||||
ExaCod);
|
||||
|
||||
/***** Remove sessions from main table *****/
|
||||
DB_QueryDELETE ("can not remove sessions of an exam",
|
||||
"DELETE FROM exa_sessions WHERE ExaCod=%ld",
|
||||
"DELETE FROM exa_sessions"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod);
|
||||
}
|
||||
|
||||
|
@ -1057,36 +1065,44 @@ void ExaSes_RemoveSessionInCourseFromAllTables (long CrsCod)
|
|||
* TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints
|
||||
DB_QueryDELETE ("can not remove exam print questions in course",
|
||||
"DELETE FROM exa_print_questions"
|
||||
" USING exa_print_questions,exa_prints,exa_sessions,exa_exams"
|
||||
" USING exa_print_questions,
|
||||
"exa_prints,
|
||||
"exa_sessions,
|
||||
"exa_exams"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
" AND exa_exams.ExaCod=exa_sessions"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod"
|
||||
" AND exa_prints.PrnCod=exa_print_questions.PrnCod",
|
||||
CrsCod);
|
||||
DB_QueryDELETE ("can not remove exam print questions in course",
|
||||
"DELETE FROM exa_prints"
|
||||
" USING exa_prints,exa_sessions,exa_exams"
|
||||
" USING exa_prints,
|
||||
"exa_sessions,
|
||||
"exa_exams"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod",
|
||||
" AND exa_exams.ExaCod=exa_sessions"
|
||||
" AND exa_sessions.SesCod=exa_prints.SesCod",
|
||||
CrsCod);
|
||||
*/
|
||||
|
||||
/***** Remove sessions from table of sessions groups *****/
|
||||
DB_QueryDELETE ("can not remove sessions of a course",
|
||||
"DELETE FROM exa_groups"
|
||||
" USING exa_exams,exa_sessions,exa_groups"
|
||||
" USING exa_exams,"
|
||||
"exa_sessions,"
|
||||
"exa_groups"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_groups.SesCod",
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=exa_groups.SesCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove sessions from exam sessions table *****/
|
||||
DB_QueryDELETE ("can not remove sessions of a course",
|
||||
"DELETE FROM exa_sessions"
|
||||
" USING exa_exams,exa_sessions"
|
||||
" USING exa_exams,"
|
||||
"exa_sessions"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod",
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
|
@ -1105,11 +1121,13 @@ static void ExaSes_RemoveUsrSesResultsInCrs (long UsrCod,long CrsCod,const char
|
|||
/***** Remove sessions in course from secondary table *****/
|
||||
DB_QueryDELETE ("can not remove sessions of a user from table",
|
||||
"DELETE FROM %s"
|
||||
" USING exa_exams,exa_sessions,%s"
|
||||
" USING exa_exams,"
|
||||
"exa_sessions,"
|
||||
"%s"
|
||||
" WHERE exa_exams.CrsCod=%ld"
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=%s.SesCod"
|
||||
" AND %s.UsrCod=%ld",
|
||||
" AND exa_exams.ExaCod=exa_sessions.ExaCod"
|
||||
" AND exa_sessions.SesCod=%s.SesCod"
|
||||
" AND %s.UsrCod=%ld",
|
||||
TableName,
|
||||
TableName,
|
||||
CrsCod,
|
||||
|
@ -1648,7 +1666,8 @@ static void ExaSes_RemoveGroups (long SesCod)
|
|||
{
|
||||
/***** Remove all groups from one session *****/
|
||||
DB_QueryDELETE ("can not remove groups associated to a session",
|
||||
"DELETE FROM exa_groups WHERE SesCod=%ld",
|
||||
"DELETE FROM exa_groups"
|
||||
" WHERE SesCod=%ld",
|
||||
SesCod);
|
||||
}
|
||||
|
||||
|
@ -1661,7 +1680,8 @@ void ExaSes_RemoveGroup (long GrpCod)
|
|||
/***** Remove group from all the sessions *****/
|
||||
DB_QueryDELETE ("can not remove group"
|
||||
" from the associations between sessions and groups",
|
||||
"DELETE FROM exa_groups WHERE GrpCod=%ld",
|
||||
"DELETE FROM exa_groups"
|
||||
" WHERE GrpCod=%ld",
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -1796,18 +1796,21 @@ void ExaSet_RemoveSet (void)
|
|||
/* Remove questions associated to set */
|
||||
DB_QueryDELETE ("can not remove questions associated to set",
|
||||
"DELETE FROM exa_set_questions"
|
||||
" USING exa_set_questions,exa_sets"
|
||||
" USING exa_set_questions,"
|
||||
"exa_sets"
|
||||
" WHERE exa_set_questions.SetCod=%ld"
|
||||
" AND exa_set_questions.SetCod=exa_sets.SetCod"
|
||||
" AND exa_sets.ExaCod=%ld", // Extra check
|
||||
Set.SetCod,Set.ExaCod);
|
||||
" AND exa_set_questions.SetCod=exa_sets.SetCod"
|
||||
" AND exa_sets.ExaCod=%ld", // Extra check
|
||||
Set.SetCod,
|
||||
Set.ExaCod);
|
||||
|
||||
/* Remove the set itself */
|
||||
DB_QueryDELETE ("can not remove set",
|
||||
"DELETE FROM exa_sets"
|
||||
" WHERE SetCod=%ld"
|
||||
" AND ExaCod=%ld", // Extra check
|
||||
Set.SetCod,Set.ExaCod);
|
||||
" AND ExaCod=%ld", // Extra check
|
||||
Set.SetCod,
|
||||
Set.ExaCod);
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_ShowErrorAndExit ("The set to be removed does not exist.");
|
||||
|
||||
|
@ -2000,8 +2003,9 @@ void ExaSet_RemoveQstFromSet (void)
|
|||
DB_QueryDELETE ("can not remove a question from a set",
|
||||
"DELETE FROM exa_set_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND SetCod=%ld", // Extra check
|
||||
QstCod,Set.SetCod);
|
||||
" AND SetCod=%ld", // Extra check
|
||||
QstCod,
|
||||
Set.SetCod);
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_ShowErrorAndExit ("The question to be removed does not exist.");
|
||||
|
||||
|
|
|
@ -1350,7 +1350,8 @@ static void Fol_UnfollowUsr (struct UsrData *UsrDat)
|
|||
/***** Unfollow user in database *****/
|
||||
DB_QueryDELETE ("can not unfollow user",
|
||||
"DELETE FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
|
||||
" WHERE FollowerCod=%ld"
|
||||
" AND FollowedCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
UsrDat->UsrCod);
|
||||
|
||||
|
@ -1505,7 +1506,8 @@ void Fol_RemoveUsrFromUsrFollow (long UsrCod)
|
|||
{
|
||||
DB_QueryDELETE ("can not remove user from followers and followed",
|
||||
"DELETE FROM usr_follow"
|
||||
" WHERE FollowerCod=%ld OR FollowedCod=%ld",
|
||||
" WHERE FollowerCod=%ld"
|
||||
" OR FollowedCod=%ld",
|
||||
UsrCod,UsrCod);
|
||||
|
||||
/***** Flush cache *****/
|
||||
|
|
|
@ -4755,9 +4755,9 @@ void For_RemoveForums (Hie_Lvl_Level_t Scope,long ForumLocation)
|
|||
DB_QueryDELETE ("can not remove threads in forums",
|
||||
"DELETE FROM for_threads"
|
||||
" WHERE"
|
||||
" (for_threads.ForumType=%u"
|
||||
" OR"
|
||||
" for_threads.ForumType=%u)"
|
||||
" (for_threads.ForumType=%u"
|
||||
" OR"
|
||||
" for_threads.ForumType=%u)"
|
||||
" AND Location=%ld",
|
||||
ForumType[Scope].Usrs,
|
||||
ForumType[Scope].Tchs,
|
||||
|
|
18
swad_game.c
18
swad_game.c
|
@ -1219,12 +1219,14 @@ static void Gam_RemoveGameFromAllTables (long GamCod)
|
|||
|
||||
/***** Remove game question *****/
|
||||
DB_QueryDELETE ("can not remove game questions",
|
||||
"DELETE FROM gam_questions WHERE GamCod=%ld",
|
||||
"DELETE FROM gam_questions"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
|
||||
/***** Remove game *****/
|
||||
DB_QueryDELETE ("can not remove game",
|
||||
"DELETE FROM gam_games WHERE GamCod=%ld",
|
||||
"DELETE FROM gam_games"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
}
|
||||
|
||||
|
@ -1240,9 +1242,10 @@ void Gam_RemoveCrsGames (long CrsCod)
|
|||
/***** Remove the questions in games *****/
|
||||
DB_QueryDELETE ("can not remove questions in course games",
|
||||
"DELETE FROM gam_questions"
|
||||
" USING gam_games,gam_questions"
|
||||
" USING gam_games,"
|
||||
"gam_questions"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND gam_games.GamCod=gam_questions.GamCod",
|
||||
" AND gam_games.GamCod=gam_questions.GamCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove the games *****/
|
||||
|
@ -1813,10 +1816,11 @@ static void Gam_RemAnswersOfAQuestion (long GamCod,unsigned QstInd)
|
|||
/***** Remove answers from all matches of this game *****/
|
||||
DB_QueryDELETE ("can not remove the answers of a question",
|
||||
"DELETE FROM mch_answers"
|
||||
" USING mch_matches,mch_answers"
|
||||
" USING mch_matches,"
|
||||
"mch_answers"
|
||||
" WHERE mch_matches.GamCod=%ld" // From all matches of this game...
|
||||
" AND mch_matches.MchCod=mch_answers.MchCod"
|
||||
" AND mch_answers.QstInd=%u", // ...remove only answers to this question
|
||||
" AND mch_matches.MchCod=mch_answers.MchCod"
|
||||
" AND mch_answers.QstInd=%u", // ...remove only answers to this question
|
||||
GamCod,QstInd);
|
||||
}
|
||||
|
||||
|
|
|
@ -726,7 +726,9 @@ static void Inf_SetIHaveReadIntoDB (bool IHaveRead)
|
|||
/***** Remove I have read course information *****/
|
||||
DB_QueryDELETE ("can not set that I have not read course info",
|
||||
"DELETE FROM crs_info_read"
|
||||
" WHERE UsrCod=%ld AND CrsCod=%ld AND InfoType='%s'",
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld"
|
||||
" AND InfoType='%s'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
Inf_NamesInDBForInfoType[Gbl.Crs.Info.Type]);
|
||||
|
@ -741,7 +743,8 @@ void Inf_RemoveUsrFromCrsInfoRead (long UsrCod,long CrsCod)
|
|||
/***** Remove user's status about reading of course information *****/
|
||||
DB_QueryDELETE ("can not set that I have not read course info",
|
||||
"DELETE FROM crs_info_read"
|
||||
" WHERE UsrCod=%ld AND CrsCod=%ld",
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
UsrCod,CrsCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -1379,7 +1379,8 @@ void Ins_RemoveInstitution (void)
|
|||
|
||||
/***** Remove institution *****/
|
||||
DB_QueryDELETE ("can not remove an institution",
|
||||
"DELETE FROM ins_instits WHERE InsCod=%ld",
|
||||
"DELETE FROM ins_instits"
|
||||
" WHERE InsCod=%ld",
|
||||
Ins_EditingIns->InsCod);
|
||||
|
||||
/***** Flush caches *****/
|
||||
|
|
48
swad_match.c
48
swad_match.c
|
@ -1184,7 +1184,8 @@ static void Mch_RemoveMatchFromAllTables (long MchCod)
|
|||
|
||||
/***** Remove match from main table *****/
|
||||
DB_QueryDELETE ("can not remove match",
|
||||
"DELETE FROM mch_matches WHERE MchCod=%ld",
|
||||
"DELETE FROM mch_matches"
|
||||
" WHERE MchCod=%ld",
|
||||
MchCod);
|
||||
}
|
||||
|
||||
|
@ -1192,7 +1193,8 @@ static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName)
|
|||
{
|
||||
/***** Remove match from secondary table *****/
|
||||
DB_QueryDELETE ("can not remove match from table",
|
||||
"DELETE FROM %s WHERE MchCod=%ld",
|
||||
"DELETE FROM %s"
|
||||
" WHERE MchCod=%ld",
|
||||
TableName,
|
||||
MchCod);
|
||||
}
|
||||
|
@ -1214,7 +1216,8 @@ void Mch_RemoveMatchesInGameFromAllTables (long GamCod)
|
|||
|
||||
/***** Remove matches from main table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a game",
|
||||
"DELETE FROM mch_matches WHERE GamCod=%ld",
|
||||
"DELETE FROM mch_matches"
|
||||
" WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
}
|
||||
|
||||
|
@ -1223,9 +1226,10 @@ static void Mch_RemoveMatchesInGameFromTable (long GamCod,const char *TableName)
|
|||
/***** Remove matches in game from secondary table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a game from table",
|
||||
"DELETE FROM %s"
|
||||
" USING mch_matches,%s"
|
||||
" USING mch_matches,"
|
||||
"%s"
|
||||
" WHERE mch_matches.GamCod=%ld"
|
||||
" AND mch_matches.MchCod=%s.MchCod",
|
||||
" AND mch_matches.MchCod=%s.MchCod",
|
||||
TableName,
|
||||
TableName,
|
||||
GamCod,
|
||||
|
@ -1250,9 +1254,10 @@ void Mch_RemoveMatchesInCourseFromAllTables (long CrsCod)
|
|||
/***** Remove matches from main table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a course",
|
||||
"DELETE FROM mch_matches"
|
||||
" USING gam_games,mch_matches"
|
||||
" USING gam_games,"
|
||||
"mch_matches"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND gam_games.GamCod=mch_matches.GamCod",
|
||||
" AND gam_games.GamCod=mch_matches.GamCod",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
|
@ -1261,10 +1266,12 @@ static void Mch_RemoveMatchesInCourseFromTable (long CrsCod,const char *TableNam
|
|||
/***** Remove matches in course from secondary table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a course from table",
|
||||
"DELETE FROM %s"
|
||||
" USING gam_games,mch_matches,%s"
|
||||
" USING gam_games,"
|
||||
"mch_matches,"
|
||||
"%s"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
||||
" AND mch_matches.MchCod=%s.MchCod",
|
||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
||||
" AND mch_matches.MchCod=%s.MchCod",
|
||||
TableName,
|
||||
TableName,
|
||||
CrsCod,
|
||||
|
@ -1310,11 +1317,13 @@ static void Mch_RemoveMatchesMadeByUsrInCrsFromTable (long UsrCod,long CrsCod,co
|
|||
/***** Remove matches in course from secondary table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a user from table",
|
||||
"DELETE FROM %s"
|
||||
" USING gam_games,mch_matches,%s"
|
||||
" USING gam_games,"
|
||||
"mch_matches,"
|
||||
"%s"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
||||
" AND mch_matches.MchCod=%s.MchCod"
|
||||
" AND %s.UsrCod=%ld",
|
||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
||||
" AND mch_matches.MchCod=%s.MchCod"
|
||||
" AND %s.UsrCod=%ld",
|
||||
TableName,
|
||||
TableName,
|
||||
CrsCod,
|
||||
|
@ -1965,7 +1974,8 @@ void Mch_RemoveGroup (long GrpCod)
|
|||
/***** Remove group from all the matches *****/
|
||||
DB_QueryDELETE ("can not remove group"
|
||||
" from the associations between matches and groups",
|
||||
"DELETE FROM mch_groups WHERE GrpCod=%ld",
|
||||
"DELETE FROM mch_groups"
|
||||
" WHERE GrpCod=%ld",
|
||||
GrpCod);
|
||||
}
|
||||
|
||||
|
@ -4260,8 +4270,12 @@ static void Mch_RemoveMyAnswerToMatchQuestion (const struct Mch_Match *Match)
|
|||
{
|
||||
DB_QueryDELETE ("can not remove your answer to the match question",
|
||||
"DELETE FROM mch_answers"
|
||||
" WHERE MchCod=%ld AND UsrCod=%ld AND QstInd=%u",
|
||||
Match->MchCod,Gbl.Usrs.Me.UsrDat.UsrCod,Match->Status.QstInd);
|
||||
" WHERE MchCod=%ld"
|
||||
" AND UsrCod=%ld"
|
||||
" AND QstInd=%u",
|
||||
Match->MchCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Match->Status.QstInd);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -1642,7 +1642,8 @@ static void Msg_MoveSentMsgToDeleted (long MsgCod)
|
|||
|
||||
/* Delete message from msg_snt *****/
|
||||
DB_QueryDELETE ("can not remove a sent message",
|
||||
"DELETE FROM msg_snt WHERE MsgCod=%ld",
|
||||
"DELETE FROM msg_snt"
|
||||
" WHERE MsgCod=%ld",
|
||||
MsgCod);
|
||||
|
||||
/***** If message content is not longer necessary, move it to msg_content_deleted *****/
|
||||
|
@ -4109,8 +4110,10 @@ static void Msg_UnbanSender (void)
|
|||
/***** Remove pair (sender's code - my code) from table of banned senders *****/
|
||||
DB_QueryDELETE ("can not ban sender",
|
||||
"DELETE FROM msg_banned"
|
||||
" WHERE FromUsrCod=%ld AND ToUsrCod=%ld",
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
" WHERE FromUsrCod=%ld"
|
||||
" AND ToUsrCod=%ld",
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** Show alert with the change made *****/
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_From_this_time_you_can_receive_messages_from_X,
|
||||
|
@ -4142,7 +4145,8 @@ void Msg_RemoveUsrFromBanned (long UsrCod)
|
|||
from table of banned senders *****/
|
||||
DB_QueryDELETE ("can not remove user from table of banned users",
|
||||
"DELETE FROM msg_banned"
|
||||
" WHERE FromUsrCod=%ld OR ToUsrCod=%ld",
|
||||
" WHERE FromUsrCod=%ld"
|
||||
" OR ToUsrCod=%ld",
|
||||
UsrCod,UsrCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -1278,10 +1278,12 @@ void Prg_RemoveItem (void)
|
|||
/***** Remove program items *****/
|
||||
DB_QueryDELETE ("can not remove program item",
|
||||
"DELETE FROM prg_items"
|
||||
" WHERE CrsCod=%ld AND"
|
||||
" ItmInd>=%u AND ItmInd<=%u",
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND ItmInd>=%u"
|
||||
" AND ItmInd<=%u",
|
||||
Gbl.Hierarchy.Crs.CrsCod,
|
||||
ToRemove.Begin,ToRemove.End);
|
||||
ToRemove.Begin,
|
||||
ToRemove.End);
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Item_X_removed,Item.Title);
|
||||
|
@ -2176,7 +2178,8 @@ void Prg_RemoveCrsItems (long CrsCod)
|
|||
{
|
||||
/***** Remove program items *****/
|
||||
DB_QueryDELETE ("can not remove all the program items of a course",
|
||||
"DELETE FROM prg_items WHERE CrsCod=%ld",
|
||||
"DELETE FROM prg_items"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -4581,7 +4581,8 @@ void Prj_RemoveCrsProjects (long CrsCod)
|
|||
|
||||
/***** Remove configuration of projects in the course *****/
|
||||
DB_QueryDELETE ("can not remove configuration of projects of a course",
|
||||
"DELETE FROM prj_config WHERE CrsCod=%ld",
|
||||
"DELETE FROM prj_config"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove projects *****/
|
||||
|
|
|
@ -646,12 +646,14 @@ void Rec_RemoveFieldFromDB (void)
|
|||
|
||||
/***** Remove field from all records *****/
|
||||
DB_QueryDELETE ("can not remove field from all students' records",
|
||||
"DELETE FROM crs_records WHERE FieldCod=%ld",
|
||||
"DELETE FROM crs_records"
|
||||
" WHERE FieldCod=%ld",
|
||||
Gbl.Crs.Records.Field.FieldCod);
|
||||
|
||||
/***** Remove the field *****/
|
||||
DB_QueryDELETE ("can not remove field of record",
|
||||
"DELETE FROM crs_record_fields WHERE FieldCod=%ld",
|
||||
"DELETE FROM crs_record_fields"
|
||||
" WHERE FieldCod=%ld",
|
||||
Gbl.Crs.Records.Field.FieldCod);
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
|
@ -1921,7 +1923,8 @@ void Rec_UpdateCrsRecord (long UsrCod)
|
|||
/***** Remove text of the field of record course *****/
|
||||
DB_QueryDELETE ("can not remove field of record",
|
||||
"DELETE FROM crs_records"
|
||||
" WHERE UsrCod=%ld AND FieldCod=%ld",
|
||||
" WHERE UsrCod=%ld"
|
||||
" AND FieldCod=%ld",
|
||||
UsrCod,
|
||||
Gbl.Crs.Records.LstFields.Lst[NumField].FieldCod);
|
||||
}
|
||||
|
@ -1963,7 +1966,8 @@ void Rec_RemoveFieldsCrsRecordAll (long UsrCod)
|
|||
{
|
||||
/***** Remove text of the field of record course *****/
|
||||
DB_QueryDELETE ("can not remove user's records in all courses",
|
||||
"DELETE FROM crs_records WHERE UsrCod=%ld",
|
||||
"DELETE FROM crs_records"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -1622,12 +1622,15 @@ void Svy_RemoveSurvey (void)
|
|||
|
||||
/***** Remove all the users in this survey *****/
|
||||
DB_QueryDELETE ("can not remove users who are answered a survey",
|
||||
"DELETE FROM svy_users WHERE SvyCod=%ld",
|
||||
"DELETE FROM svy_users"
|
||||
" WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
|
||||
/***** Remove all the answers in this survey *****/
|
||||
DB_QueryDELETE ("can not remove answers of a survey",
|
||||
"DELETE FROM svy_answers USING svy_questions,svy_answers"
|
||||
"DELETE FROM svy_answers"
|
||||
" USING svy_questions,"
|
||||
"svy_answers"
|
||||
" WHERE svy_questions.SvyCod=%ld"
|
||||
" AND svy_questions.QstCod=svy_answers.QstCod",
|
||||
Svy.SvyCod);
|
||||
|
@ -1643,7 +1646,8 @@ void Svy_RemoveSurvey (void)
|
|||
|
||||
/***** Remove survey *****/
|
||||
DB_QueryDELETE ("can not remove survey",
|
||||
"DELETE FROM svy_surveys WHERE SvyCod=%ld",
|
||||
"DELETE FROM svy_surveys"
|
||||
" WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
|
||||
/***** Mark possible notifications as removed *****/
|
||||
|
@ -2565,29 +2569,39 @@ void Svy_RemoveSurveys (Hie_Lvl_Level_t Scope,long Cod)
|
|||
DB_QueryDELETE ("can not remove users"
|
||||
" who had answered surveys in a place on the hierarchy",
|
||||
"DELETE FROM svy_users"
|
||||
" USING svy_surveys,svy_users"
|
||||
" WHERE svy_surveys.Scope='%s' AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_users.SvyCod",
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
" USING svy_surveys,"
|
||||
"svy_users"
|
||||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_users.SvyCod",
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
|
||||
/***** Remove all the answers in course surveys *****/
|
||||
DB_QueryDELETE ("can not remove answers of surveys"
|
||||
" in a place on the hierarchy",
|
||||
"DELETE FROM svy_answers"
|
||||
" USING svy_surveys,svy_questions,svy_answers"
|
||||
" WHERE svy_surveys.Scope='%s' AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" AND svy_questions.QstCod=svy_answers.QstCod",
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
" USING svy_surveys,"
|
||||
"svy_questions,"
|
||||
"svy_answers"
|
||||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod"
|
||||
" AND svy_questions.QstCod=svy_answers.QstCod",
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
|
||||
/***** Remove all the questions in course surveys *****/
|
||||
DB_QueryDELETE ("can not remove questions of surveys"
|
||||
" in a place on the hierarchy",
|
||||
"DELETE FROM svy_questions"
|
||||
" USING svy_surveys,svy_questions"
|
||||
" WHERE svy_surveys.Scope='%s' AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod",
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
" USING svy_surveys,"
|
||||
"svy_questions"
|
||||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_questions.SvyCod",
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
|
||||
/***** Remove groups *****/
|
||||
DB_QueryDELETE ("can not remove all the groups"
|
||||
|
@ -2598,14 +2612,17 @@ void Svy_RemoveSurveys (Hie_Lvl_Level_t Scope,long Cod)
|
|||
" WHERE svy_surveys.Scope='%s'"
|
||||
" AND svy_surveys.Cod=%ld"
|
||||
" AND svy_surveys.SvyCod=svy_groups.SvyCod",
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
|
||||
/***** Remove course surveys *****/
|
||||
DB_QueryDELETE ("can not remove all the surveys"
|
||||
" in a place on the hierarchy",
|
||||
"DELETE FROM svy_surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_GetDBStrFromScope (Scope),Cod);
|
||||
" WHERE Scope='%s'"
|
||||
" AND Cod=%ld",
|
||||
Sco_GetDBStrFromScope (Scope),
|
||||
Cod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2931,7 +2948,8 @@ static void Svy_RemAnswersOfAQuestion (long QstCod)
|
|||
{
|
||||
/***** Remove answers *****/
|
||||
DB_QueryDELETE ("can not remove the answers of a question",
|
||||
"DELETE FROM svy_answers WHERE QstCod=%ld",
|
||||
"DELETE FROM svy_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
}
|
||||
|
||||
|
@ -3735,7 +3753,8 @@ void Svy_RemoveQst (void)
|
|||
|
||||
/* Remove the question itself */
|
||||
DB_QueryDELETE ("can not remove a question",
|
||||
"DELETE FROM svy_questions WHERE QstCod=%ld",
|
||||
"DELETE FROM svy_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
SvyQst.QstCod);
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_ShowErrorAndExit ("The question to be removed does not exist.");
|
||||
|
|
|
@ -657,7 +657,8 @@ void Tag_RemTagsFromQst (long QstCod)
|
|||
{
|
||||
/***** Remove tags *****/
|
||||
DB_QueryDELETE ("can not remove the tags of a question",
|
||||
"DELETE FROM tst_question_tags WHERE QstCod=%ld",
|
||||
"DELETE FROM tst_question_tags"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
}
|
||||
|
||||
|
|
28
swad_test.c
28
swad_test.c
|
@ -4856,8 +4856,10 @@ static void Tst_RemoveOneQstFromDB (long CrsCod,long QstCod)
|
|||
/* Remove the question itself */
|
||||
DB_QueryDELETE ("can not remove a question",
|
||||
"DELETE FROM tst_questions"
|
||||
" WHERE QstCod=%ld AND CrsCod=%ld",
|
||||
QstCod,CrsCod);
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
QstCod,
|
||||
CrsCod);
|
||||
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_ShowErrorAndExit ("Wrong question.");
|
||||
|
@ -5142,7 +5144,8 @@ void Tst_RemoveCrsTests (long CrsCod)
|
|||
|
||||
/***** Remove test configuration of the course *****/
|
||||
DB_QueryDELETE ("can not remove configuration of tests of a course",
|
||||
"DELETE FROM tst_config WHERE CrsCod=%ld",
|
||||
"DELETE FROM tst_config"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove associations between test questions
|
||||
|
@ -5150,14 +5153,16 @@ void Tst_RemoveCrsTests (long CrsCod)
|
|||
DB_QueryDELETE ("can not remove tags associated"
|
||||
" to questions of tests of a course",
|
||||
"DELETE FROM tst_question_tags"
|
||||
" USING tst_questions,tst_question_tags"
|
||||
" USING tst_questions,"
|
||||
"tst_question_tags"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod",
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove test tags in the course *****/
|
||||
DB_QueryDELETE ("can not remove tags of test of a course",
|
||||
"DELETE FROM tst_tags WHERE CrsCod=%ld",
|
||||
"DELETE FROM tst_tags"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove media associated to test questions in the course *****/
|
||||
|
@ -5167,14 +5172,16 @@ void Tst_RemoveCrsTests (long CrsCod)
|
|||
/***** Remove test answers in the course *****/
|
||||
DB_QueryDELETE ("can not remove answers of tests of a course",
|
||||
"DELETE FROM tst_answers"
|
||||
" USING tst_questions,tst_answers"
|
||||
" USING tst_questions,"
|
||||
"tst_answers"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_answers.QstCod",
|
||||
" AND tst_questions.QstCod=tst_answers.QstCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove test questions in the course *****/
|
||||
DB_QueryDELETE ("can not remove test questions of a course",
|
||||
"DELETE FROM tst_questions WHERE CrsCod=%ld",
|
||||
"DELETE FROM tst_questions"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
|
@ -5186,7 +5193,8 @@ static void Tst_RemAnsFromQst (long QstCod)
|
|||
{
|
||||
/***** Remove answers *****/
|
||||
DB_QueryDELETE ("can not remove the answers of a question",
|
||||
"DELETE FROM tst_answers WHERE QstCod=%ld",
|
||||
"DELETE FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -2812,9 +2812,10 @@ void TstPrn_RemovePrintsMadeByUsrInAllCrss (long UsrCod)
|
|||
/***** Remove test prints questions for the given user *****/
|
||||
DB_QueryDELETE ("can not remove test exams made by a user",
|
||||
"DELETE FROM tst_exam_questions"
|
||||
" USING tst_exams,tst_exam_questions"
|
||||
" USING tst_exams,"
|
||||
"tst_exam_questions"
|
||||
" WHERE tst_exams.UsrCod=%ld"
|
||||
" AND tst_exams.ExaCod=tst_exam_questions.ExaCod",
|
||||
" AND tst_exams.ExaCod=tst_exam_questions.ExaCod",
|
||||
UsrCod);
|
||||
|
||||
/***** Remove test prints made by the given user *****/
|
||||
|
@ -2833,15 +2834,20 @@ void TstPrn_RemovePrintsMadeByUsrInCrs (long UsrCod,long CrsCod)
|
|||
/***** Remove test exams made by the given user *****/
|
||||
DB_QueryDELETE ("can not remove test exams made by a user in a course",
|
||||
"DELETE FROM tst_exam_questions"
|
||||
" USING tst_exams,tst_exam_questions"
|
||||
" WHERE tst_exams.CrsCod=%ld AND tst_exams.UsrCod=%ld"
|
||||
" AND tst_exams.ExaCod=tst_exam_questions.ExaCod",
|
||||
CrsCod,UsrCod);
|
||||
" USING tst_exams,"
|
||||
"tst_exam_questions"
|
||||
" WHERE tst_exams.CrsCod=%ld"
|
||||
" AND tst_exams.UsrCod=%ld"
|
||||
" AND tst_exams.ExaCod=tst_exam_questions.ExaCod",
|
||||
CrsCod,
|
||||
UsrCod);
|
||||
|
||||
DB_QueryDELETE ("can not remove test exams made by a user in a course",
|
||||
"DELETE FROM tst_exams"
|
||||
" WHERE CrsCod=%ld AND UsrCod=%ld",
|
||||
CrsCod,UsrCod);
|
||||
" WHERE CrsCod=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
CrsCod,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2853,13 +2859,15 @@ void TstPrn_RemoveCrsPrints (long CrsCod)
|
|||
/***** Remove questions of test exams made in the course *****/
|
||||
DB_QueryDELETE ("can not remove test exams made in a course",
|
||||
"DELETE FROM tst_exam_questions"
|
||||
" USING tst_exams,tst_exam_questions"
|
||||
" USING tst_exams,"
|
||||
"tst_exam_questions"
|
||||
" WHERE tst_exams.CrsCod=%ld"
|
||||
" AND tst_exams.ExaCod=tst_exam_questions.ExaCod",
|
||||
" AND tst_exams.ExaCod=tst_exam_questions.ExaCod",
|
||||
CrsCod);
|
||||
|
||||
/***** Remove test exams made in the course *****/
|
||||
DB_QueryDELETE ("can not remove test exams made in a course",
|
||||
"DELETE FROM tst_exams WHERE CrsCod=%ld",
|
||||
"DELETE FROM tst_exams"
|
||||
" WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
}
|
||||
|
|
|
@ -375,7 +375,7 @@ void Tml_DB_RemoveNote (long NotCod)
|
|||
DB_QueryDELETE ("can not remove a note",
|
||||
"DELETE FROM tml_notes"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND UsrCod=%ld", // Extra check: author
|
||||
" AND UsrCod=%ld", // Extra check: author
|
||||
NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
@ -388,7 +388,8 @@ void Tml_DB_RemoveAllNotesUsr (long UsrCod)
|
|||
{
|
||||
/***** Remove all notes created by user *****/
|
||||
DB_QueryDELETE ("can not remove notes",
|
||||
"DELETE FROM tml_notes WHERE UsrCod=%ld",
|
||||
"DELETE FROM tml_notes"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
|
@ -647,8 +648,8 @@ void Tml_DB_RemoveCommPub (long PubCod)
|
|||
DB_QueryDELETE ("can not remove comment",
|
||||
"DELETE FROM tml_pubs"
|
||||
" WHERE PubCod=%ld"
|
||||
" AND PublisherCod=%ld" // Extra check: author
|
||||
" AND PubType=%u", // Extra check: it's a comment
|
||||
" AND PublisherCod=%ld" // Extra check: author
|
||||
" AND PubType=%u", // Extra check: it's a comment
|
||||
PubCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
|
@ -663,11 +664,13 @@ void Tml_DB_RemoveAllCommsInAllNotesOf (long UsrCod)
|
|||
/***** Remove all comments in all notes of the user *****/
|
||||
DB_QueryDELETE ("can not remove comments",
|
||||
"DELETE FROM tml_comments"
|
||||
" USING tml_notes,tml_pubs,tml_comments"
|
||||
" USING tml_notes,"
|
||||
"tml_pubs,"
|
||||
"tml_comments"
|
||||
" WHERE tml_notes.UsrCod=%ld"
|
||||
" AND tml_notes.NotCod=tml_pubs.NotCod"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod",
|
||||
" AND tml_notes.NotCod=tml_pubs.NotCod"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod",
|
||||
UsrCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
}
|
||||
|
||||
|
@ -680,11 +683,13 @@ void Tml_DB_RemoveAllCommsMadeBy (long UsrCod)
|
|||
/***** Remove all comments made by this user in any note *****/
|
||||
DB_QueryDELETE ("can not remove comments",
|
||||
"DELETE FROM tml_comments"
|
||||
" USING tml_pubs,tml_comments"
|
||||
" USING tml_pubs,"
|
||||
"tml_comments"
|
||||
" WHERE tml_pubs.PublisherCod=%ld"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod",
|
||||
UsrCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments.PubCod",
|
||||
UsrCod,
|
||||
(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -974,9 +979,10 @@ void Tml_DB_RemoveAllPubsPublishedByAnyUsrOfNotesAuthoredBy (long UsrCod)
|
|||
and related to notes authored by this user *****/
|
||||
DB_QueryDELETE ("can not remove publications",
|
||||
"DELETE FROM tml_pubs"
|
||||
" USING tml_notes,tml_pubs"
|
||||
" USING tml_notes,"
|
||||
"tml_pubs"
|
||||
" WHERE tml_notes.UsrCod=%ld"
|
||||
" AND tml_notes.NotCod=tml_pubs.NotCod",
|
||||
" AND tml_notes.NotCod=tml_pubs.NotCod",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
|
@ -988,7 +994,8 @@ void Tml_DB_RemoveAllPubsPublishedBy (long UsrCod)
|
|||
{
|
||||
/***** Remove all publications published by the user *****/
|
||||
DB_QueryDELETE ("can not remove publications",
|
||||
"DELETE FROM tml_pubs WHERE PublisherCod=%ld",
|
||||
"DELETE FROM tml_pubs"
|
||||
" WHERE PublisherCod=%ld",
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
|
@ -1075,9 +1082,11 @@ void Tml_DB_UnmarkAsFav (Tml_Usr_FavSha_t FavSha,long Cod)
|
|||
/***** Delete the mark as favourite from database *****/
|
||||
DB_QueryDELETE ("can not unfavourite",
|
||||
"DELETE FROM %s"
|
||||
" WHERE %s=%ld AND UsrCod=%ld",
|
||||
" WHERE %s=%ld"
|
||||
" AND UsrCod=%ld",
|
||||
Tml_DB_TableFav[FavSha],
|
||||
Tml_DB_FieldFav[FavSha],Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
Tml_DB_FieldFav[FavSha],Cod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1088,8 +1097,10 @@ void Tml_DB_RemoveAllFavsMadeByUsr (Tml_Usr_FavSha_t FavSha,long UsrCod)
|
|||
{
|
||||
/* Remove all favs made by this user to any note/comment */
|
||||
DB_QueryDELETE ("can not remove favs",
|
||||
"DELETE FROM %s WHERE UsrCod=%ld",
|
||||
Tml_DB_TableFav[FavSha],UsrCod);
|
||||
"DELETE FROM %s"
|
||||
" WHERE UsrCod=%ld",
|
||||
Tml_DB_TableFav[FavSha],
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1101,10 +1112,11 @@ void Tml_DB_RemoveAllFavsToPubsBy (Tml_Usr_FavSha_t FavSha,long UsrCod)
|
|||
/***** Remove all favs to notes/comments of this user *****/
|
||||
DB_QueryDELETE ("can not remove favs",
|
||||
"DELETE FROM %s"
|
||||
" USING tml_pubs,%s"
|
||||
" USING tml_pubs,"
|
||||
"%s"
|
||||
" WHERE tml_pubs.PublisherCod=%ld" // Author of the comment
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=%s.PubCod",
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=%s.PubCod",
|
||||
Tml_DB_TableFav[FavSha],
|
||||
Tml_DB_TableFav[FavSha],
|
||||
UsrCod,
|
||||
|
@ -1122,12 +1134,15 @@ void Tml_DB_RemoveAllFavsToAllCommsInAllNotesBy (long UsrCod)
|
|||
in all notes authored by this user *****/
|
||||
DB_QueryDELETE ("can not remove favs",
|
||||
"DELETE FROM tml_comments_fav"
|
||||
" USING tml_notes,tml_pubs,tml_comments_fav"
|
||||
" USING tml_notes,"
|
||||
"tml_pubs,"
|
||||
"tml_comments_fav"
|
||||
" WHERE tml_notes.UsrCod=%ld" // Author of the note
|
||||
" AND tml_notes.NotCod=tml_pubs.NotCod"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments_fav.PubCod",
|
||||
UsrCod,(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
" AND tml_notes.NotCod=tml_pubs.NotCod"
|
||||
" AND tml_pubs.PubType=%u"
|
||||
" AND tml_pubs.PubCod=tml_comments_fav.PubCod",
|
||||
UsrCod,
|
||||
(unsigned) Tml_Pub_COMMENT_TO_NOTE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1199,8 +1214,8 @@ void Tml_DB_RemoveSharedPub (long NotCod)
|
|||
DB_QueryDELETE ("can not remove a publication",
|
||||
"DELETE FROM tml_pubs"
|
||||
" WHERE NotCod=%ld"
|
||||
" AND PublisherCod=%ld"
|
||||
" AND PubType=%u", // Extra check: shared note
|
||||
" AND PublisherCod=%ld"
|
||||
" AND PubType=%u", // Extra check: shared note
|
||||
NotCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(unsigned) Tml_Pub_SHARED_NOTE);
|
||||
|
|
Loading…
Reference in New Issue