mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-05 00:05:23 +02:00
Version 18.9.1
This commit is contained in:
parent
b2037c42ac
commit
8a4e127382
|
@ -355,10 +355,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.9 (2018-10-28)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.9.1 (2018-10-29)"
|
||||
#define CSS_FILE "swad18.4.css"
|
||||
#define JS_FILE "swad17.17.1.js"
|
||||
/*
|
||||
Version 18.9.1: Oct 29, 2018 Some sprintf for database queries changed by internal function. (236049 lines)
|
||||
Version 18.9: Oct 28, 2018 Some sprintf for database queries changed by internal function. (236082 lines)
|
||||
Version 18.8.18: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236105 lines)
|
||||
Version 18.8.17: Oct 28, 2018 Some asprintf for database queries changed by internal function. (236116 lines)
|
||||
|
|
|
@ -422,13 +422,11 @@ void Sta_LogAccess (const char *Comments)
|
|||
|
||||
void Sta_RemoveOldEntriesRecentLog (void)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Remove all expired clipboards *****/
|
||||
sprintf (Query,"DELETE LOW_PRIORITY FROM log_recent"
|
||||
DB_BuildQuery ("DELETE LOW_PRIORITY FROM log_recent"
|
||||
" WHERE ClickTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-'%lu')",
|
||||
Sta_SECONDS_IN_RECENT_LOG);
|
||||
DB_QueryDELETE (Query,"can not remove old entries from recent log");
|
||||
Sta_SECONDS_IN_RECENT_LOG);
|
||||
DB_QueryDELETE_new ("can not remove old entries from recent log");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
153
swad_survey.c
153
swad_survey.c
|
@ -1526,7 +1526,6 @@ void Svy_AskRemSurvey (void)
|
|||
void Svy_RemoveSurvey (void)
|
||||
{
|
||||
extern const char *Txt_Survey_X_removed;
|
||||
char Query[512];
|
||||
struct Survey Svy;
|
||||
struct SurveyQuestion SvyQst;
|
||||
|
||||
|
@ -1543,30 +1542,30 @@ void Svy_RemoveSurvey (void)
|
|||
Lay_ShowErrorAndExit ("You can not remove this survey.");
|
||||
|
||||
/***** Remove all the users in this survey *****/
|
||||
sprintf (Query,"DELETE FROM svy_users WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE (Query,"can not remove users who are answered a survey");
|
||||
DB_BuildQuery ("DELETE FROM svy_users WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE_new ("can not remove users who are answered a survey");
|
||||
|
||||
/***** Remove all the answers in this survey *****/
|
||||
sprintf (Query,"DELETE FROM svy_answers USING svy_questions,svy_answers"
|
||||
DB_BuildQuery ("DELETE FROM svy_answers USING svy_questions,svy_answers"
|
||||
" WHERE svy_questions.SvyCod=%ld"
|
||||
" AND svy_questions.QstCod=svy_answers.QstCod",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE (Query,"can not remove answers of a survey");
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE_new ("can not remove answers of a survey");
|
||||
|
||||
/***** Remove all the questions in this survey *****/
|
||||
sprintf (Query,"DELETE FROM svy_questions"
|
||||
DB_BuildQuery ("DELETE FROM svy_questions"
|
||||
" WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE (Query,"can not remove questions of a survey");
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE_new ("can not remove questions of a survey");
|
||||
|
||||
/***** Remove all the groups of this survey *****/
|
||||
Svy_RemoveAllTheGrpsAssociatedToAndSurvey (Svy.SvyCod);
|
||||
|
||||
/***** Remove survey *****/
|
||||
sprintf (Query,"DELETE FROM surveys WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE (Query,"can not remove survey");
|
||||
DB_BuildQuery ("DELETE FROM surveys WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE_new ("can not remove survey");
|
||||
|
||||
/***** Mark possible notifications as removed *****/
|
||||
Ntf_MarkNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod);
|
||||
|
@ -1643,7 +1642,6 @@ static void Svy_PutButtonToResetSurvey (void)
|
|||
void Svy_ResetSurvey (void)
|
||||
{
|
||||
extern const char *Txt_Survey_X_reset;
|
||||
char Query[512];
|
||||
struct Survey Svy;
|
||||
struct SurveyQuestion SvyQst;
|
||||
|
||||
|
@ -1660,16 +1658,16 @@ void Svy_ResetSurvey (void)
|
|||
Lay_ShowErrorAndExit ("You can not reset this survey.");
|
||||
|
||||
/***** Remove all the users in this survey *****/
|
||||
sprintf (Query,"DELETE FROM svy_users WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE (Query,"can not remove users who are answered a survey");
|
||||
DB_BuildQuery ("DELETE FROM svy_users WHERE SvyCod=%ld",
|
||||
Svy.SvyCod);
|
||||
DB_QueryDELETE_new ("can not remove users who are answered a survey");
|
||||
|
||||
/***** Reset all the answers in this survey *****/
|
||||
sprintf (Query,"UPDATE svy_answers,svy_questions SET svy_answers.NumUsrs=0"
|
||||
DB_BuildQuery ("UPDATE svy_answers,svy_questions SET svy_answers.NumUsrs=0"
|
||||
" WHERE svy_questions.SvyCod=%ld"
|
||||
" AND svy_questions.QstCod=svy_answers.QstCod",
|
||||
Svy.SvyCod);
|
||||
DB_QueryUPDATE (Query,"can not reset answers of a survey");
|
||||
Svy.SvyCod);
|
||||
DB_QueryUPDATE_new ("can not reset answers of a survey");
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),
|
||||
|
@ -2369,12 +2367,9 @@ bool Svy_CheckIfSvyIsAssociatedToGrp (long SvyCod,long GrpCod)
|
|||
|
||||
static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Remove groups of the survey *****/
|
||||
sprintf (Query,"DELETE FROM svy_grp WHERE SvyCod=%ld",
|
||||
SvyCod);
|
||||
DB_QueryDELETE (Query,"can not remove the groups associated to a survey");
|
||||
DB_BuildQuery ("DELETE FROM svy_grp WHERE SvyCod=%ld",SvyCod);
|
||||
DB_QueryDELETE_new ("can not remove the groups associated to a survey");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2383,13 +2378,10 @@ static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod)
|
|||
|
||||
void Svy_RemoveGroup (long GrpCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Remove group from all the surveys *****/
|
||||
sprintf (Query,"DELETE FROM svy_grp WHERE GrpCod=%ld",
|
||||
GrpCod);
|
||||
DB_QueryDELETE (Query,"can not remove group"
|
||||
" from the associations between surveys and groups");
|
||||
DB_BuildQuery ("DELETE FROM svy_grp WHERE GrpCod=%ld",GrpCod);
|
||||
DB_QueryDELETE_new ("can not remove group"
|
||||
" from the associations between surveys and groups");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2398,15 +2390,13 @@ void Svy_RemoveGroup (long GrpCod)
|
|||
|
||||
void Svy_RemoveGroupsOfType (long GrpTypCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Remove group from all the surveys *****/
|
||||
sprintf (Query,"DELETE FROM svy_grp USING crs_grp,svy_grp"
|
||||
DB_BuildQuery ("DELETE FROM svy_grp USING crs_grp,svy_grp"
|
||||
" WHERE crs_grp.GrpTypCod=%ld"
|
||||
" AND crs_grp.GrpCod=svy_grp.GrpCod",
|
||||
GrpTypCod);
|
||||
DB_QueryDELETE (Query,"can not remove groups of a type"
|
||||
" from the associations between surveys and groups");
|
||||
GrpTypCod);
|
||||
DB_QueryDELETE_new ("can not remove groups of a type"
|
||||
" from the associations between surveys and groups");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2508,48 +2498,47 @@ static void Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (struct Survey *Svy)
|
|||
void Svy_RemoveSurveys (Sco_Scope_t Scope,long Cod)
|
||||
{
|
||||
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
|
||||
char Query[512];
|
||||
|
||||
/***** Remove all the users in course surveys *****/
|
||||
sprintf (Query,"DELETE FROM svy_users"
|
||||
DB_BuildQuery ("DELETE FROM svy_users"
|
||||
" USING surveys,svy_users"
|
||||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_users.SvyCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE (Query,"can not remove users"
|
||||
" who had answered surveys in a place on the hierarchy");
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE_new ("can not remove users"
|
||||
" who had answered surveys in a place on the hierarchy");
|
||||
|
||||
/***** Remove all the answers in course surveys *****/
|
||||
sprintf (Query,"DELETE FROM svy_answers"
|
||||
DB_BuildQuery ("DELETE FROM svy_answers"
|
||||
" USING surveys,svy_questions,svy_answers"
|
||||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_questions.SvyCod"
|
||||
" AND svy_questions.QstCod=svy_answers.QstCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE (Query,"can not remove answers of surveys in a place on the hierarchy");
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE_new ("can not remove answers of surveys in a place on the hierarchy");
|
||||
|
||||
/***** Remove all the questions in course surveys *****/
|
||||
sprintf (Query,"DELETE FROM svy_questions"
|
||||
DB_BuildQuery ("DELETE FROM svy_questions"
|
||||
" USING surveys,svy_questions"
|
||||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_questions.SvyCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE (Query,"can not remove questions of surveys in a place on the hierarchy");
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE_new ("can not remove questions of surveys in a place on the hierarchy");
|
||||
|
||||
/***** Remove groups *****/
|
||||
sprintf (Query,"DELETE FROM svy_grp"
|
||||
DB_BuildQuery ("DELETE FROM svy_grp"
|
||||
" USING surveys,svy_grp"
|
||||
" WHERE surveys.Scope='%s' AND surveys.Cod=%ld"
|
||||
" AND surveys.SvyCod=svy_grp.SvyCod",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE (Query,"can not remove all the groups"
|
||||
" associated to surveys of a course");
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE_new ("can not remove all the groups"
|
||||
" associated to surveys of a course");
|
||||
|
||||
/***** Remove course surveys *****/
|
||||
sprintf (Query,"DELETE FROM surveys"
|
||||
DB_BuildQuery ("DELETE FROM surveys"
|
||||
" WHERE Scope='%s' AND Cod=%ld",
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE (Query,"can not remove all the surveys in a place on the hierarchy");
|
||||
Sco_ScopeDB[Scope],Cod);
|
||||
DB_QueryDELETE_new ("can not remove all the surveys in a place on the hierarchy");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2852,12 +2841,9 @@ static long Svy_GetParamQstCod (void)
|
|||
|
||||
static void Svy_RemAnswersOfAQuestion (long QstCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Remove answers *****/
|
||||
sprintf (Query,"DELETE FROM svy_answers WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
DB_QueryDELETE (Query,"can not remove the answers of a question");
|
||||
DB_BuildQuery ("DELETE FROM svy_answers WHERE QstCod=%ld",QstCod);
|
||||
DB_QueryDELETE_new ("can not remove the answers of a question");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2970,7 +2956,6 @@ void Svy_ReceiveQst (void)
|
|||
extern const char *Txt_You_must_type_at_least_the_first_two_answers;
|
||||
extern const char *Txt_The_survey_has_been_modified;
|
||||
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
||||
char Query[512 + Cns_MAX_BYTES_TEXT];
|
||||
long SvyCod;
|
||||
struct SurveyQuestion SvyQst;
|
||||
unsigned NumAns;
|
||||
|
@ -3064,21 +3049,22 @@ void Svy_ReceiveQst (void)
|
|||
SvyQst.QstInd = Svy_GetNextQuestionIndexInSvy (SvyCod);
|
||||
|
||||
/* Insert question in the table of questions */
|
||||
sprintf (Query,"INSERT INTO svy_questions"
|
||||
DB_BuildQuery ("INSERT INTO svy_questions"
|
||||
" (SvyCod,QstInd,AnsType,Stem)"
|
||||
" VALUES"
|
||||
" (%ld,%u,'%s','%s')",
|
||||
SvyCod,SvyQst.QstInd,Svy_StrAnswerTypesDB[SvyQst.AnswerType],Txt);
|
||||
SvyQst.QstCod = DB_QueryINSERTandReturnCode (Query,"can not create question");
|
||||
SvyCod,SvyQst.QstInd,
|
||||
Svy_StrAnswerTypesDB[SvyQst.AnswerType],Txt);
|
||||
SvyQst.QstCod = DB_QueryINSERTandReturnCode_new ("can not create question");
|
||||
}
|
||||
else // It's an existing question
|
||||
{
|
||||
/* Update question */
|
||||
sprintf (Query,"UPDATE svy_questions SET Stem='%s',AnsType='%s'"
|
||||
DB_BuildQuery ("UPDATE svy_questions SET Stem='%s',AnsType='%s'"
|
||||
" WHERE QstCod=%ld AND SvyCod=%ld",
|
||||
Txt,Svy_StrAnswerTypesDB[SvyQst.AnswerType],
|
||||
SvyQst.QstCod,SvyCod);
|
||||
DB_QueryUPDATE (Query,"can not update question");
|
||||
Txt,Svy_StrAnswerTypesDB[SvyQst.AnswerType],
|
||||
SvyQst.QstCod,SvyCod);
|
||||
DB_QueryUPDATE_new ("can not update question");
|
||||
}
|
||||
|
||||
/* Insert, update or delete answers in the answers table */
|
||||
|
@ -3090,18 +3076,18 @@ void Svy_ReceiveQst (void)
|
|||
if (SvyQst.AnsChoice[NumAns].Text[0]) // Answer is not empty
|
||||
{
|
||||
/* Update answer text */
|
||||
sprintf (Query,"UPDATE svy_answers SET Answer='%s'"
|
||||
DB_BuildQuery ("UPDATE svy_answers SET Answer='%s'"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
SvyQst.AnsChoice[NumAns].Text,SvyQst.QstCod,NumAns);
|
||||
DB_QueryUPDATE (Query,"can not update answer");
|
||||
SvyQst.AnsChoice[NumAns].Text,SvyQst.QstCod,NumAns);
|
||||
DB_QueryUPDATE_new ("can not update answer");
|
||||
}
|
||||
else // Answer is empty
|
||||
{
|
||||
/* Delete answer from database */
|
||||
sprintf (Query,"DELETE FROM svy_answers"
|
||||
DB_BuildQuery ("DELETE FROM svy_answers"
|
||||
" WHERE QstCod=%ld AND AnsInd=%u",
|
||||
SvyQst.QstCod,NumAns);
|
||||
DB_QueryDELETE (Query,"can not delete answer");
|
||||
SvyQst.QstCod,NumAns);
|
||||
DB_QueryDELETE_new ("can not delete answer");
|
||||
}
|
||||
}
|
||||
else // If this answer does not exist...
|
||||
|
@ -3109,12 +3095,12 @@ void Svy_ReceiveQst (void)
|
|||
if (SvyQst.AnsChoice[NumAns].Text[0]) // Answer is not empty
|
||||
{
|
||||
/* Create answer into database */
|
||||
sprintf (Query,"INSERT INTO svy_answers"
|
||||
DB_BuildQuery ("INSERT INTO svy_answers"
|
||||
" (QstCod,AnsInd,NumUsrs,Answer)"
|
||||
" VALUES"
|
||||
" (%ld,%u,0,'%s')",
|
||||
SvyQst.QstCod,NumAns,SvyQst.AnsChoice[NumAns].Text);
|
||||
DB_QueryINSERT (Query,"can not create answer");
|
||||
SvyQst.QstCod,NumAns,SvyQst.AnsChoice[NumAns].Text);
|
||||
DB_QueryINSERT_new ("can not create answer");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3618,7 +3604,6 @@ void Svy_RequestRemoveQst (void)
|
|||
void Svy_RemoveQst (void)
|
||||
{
|
||||
extern const char *Txt_Question_removed;
|
||||
char Query[512];
|
||||
long SvyCod;
|
||||
struct SurveyQuestion SvyQst;
|
||||
|
||||
|
@ -3642,17 +3627,17 @@ void Svy_RemoveQst (void)
|
|||
Svy_RemAnswersOfAQuestion (SvyQst.QstCod);
|
||||
|
||||
/* Remove the question itself */
|
||||
sprintf (Query,"DELETE FROM svy_questions WHERE QstCod=%ld",
|
||||
SvyQst.QstCod);
|
||||
DB_QueryDELETE (Query,"can not remove a question");
|
||||
DB_BuildQuery ("DELETE FROM svy_questions WHERE QstCod=%ld",
|
||||
SvyQst.QstCod);
|
||||
DB_QueryDELETE_new ("can not remove a question");
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_ShowErrorAndExit ("The question to be removed does not exist.");
|
||||
|
||||
/* Change index of questions greater than this */
|
||||
sprintf (Query,"UPDATE svy_questions SET QstInd=QstInd-1"
|
||||
DB_BuildQuery ("UPDATE svy_questions SET QstInd=QstInd-1"
|
||||
" WHERE SvyCod=%ld AND QstInd>%u",
|
||||
SvyCod,SvyQst.QstInd);
|
||||
DB_QueryUPDATE (Query,"can not update indexes of questions");
|
||||
SvyCod,SvyQst.QstInd);
|
||||
DB_QueryUPDATE_new ("can not update indexes of questions");
|
||||
|
||||
/***** Write message *****/
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed);
|
||||
|
|
170
swad_test.c
170
swad_test.c
|
@ -728,21 +728,19 @@ static bool Tst_CheckIfNextTstAllowed (void)
|
|||
|
||||
static void Tst_SetTstStatus (unsigned NumTst,Tst_Status_t TstStatus)
|
||||
{
|
||||
char Query[256 + Cns_BYTES_SESSION_ID];
|
||||
|
||||
/***** Delete old status from expired sessions *****/
|
||||
sprintf (Query,"DELETE FROM tst_status"
|
||||
DB_BuildQuery ("DELETE FROM tst_status"
|
||||
" WHERE SessionId NOT IN (SELECT SessionId FROM sessions)");
|
||||
DB_QueryDELETE (Query,"can not remove old status of tests");
|
||||
DB_QueryDELETE_new ("can not remove old status of tests");
|
||||
|
||||
/***** Update database *****/
|
||||
sprintf (Query,"REPLACE INTO tst_status"
|
||||
DB_BuildQuery ("REPLACE INTO tst_status"
|
||||
" (SessionId,CrsCod,NumTst,Status)"
|
||||
" VALUES"
|
||||
" ('%s',%ld,%u,%u)",
|
||||
Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
NumTst,(unsigned) TstStatus);
|
||||
DB_QueryREPLACE (Query,"can not update status of test");
|
||||
Gbl.Session.Id,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
NumTst,(unsigned) TstStatus);
|
||||
DB_QueryREPLACE_new ("can not update status of test");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1549,7 +1547,6 @@ void Tst_RenameTag (void)
|
|||
extern const char *Txt_The_tag_X_has_not_changed;
|
||||
char OldTagTxt[Tst_MAX_BYTES_TAG + 1];
|
||||
char NewTagTxt[Tst_MAX_BYTES_TAG + 1];
|
||||
char Query[1024 + 2 * Tst_MAX_BYTES_TAG];
|
||||
long ExistingTagCod;
|
||||
long OldTagCod;
|
||||
bool ComplexRenaming;
|
||||
|
@ -1606,56 +1603,54 @@ void Tst_RenameTag (void)
|
|||
|
||||
/* Create a temporary table with all the question codes
|
||||
that had the new tag as one of their tags */
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS tst_question_tags_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary table");
|
||||
sprintf (Query,"CREATE TEMPORARY TABLE tst_question_tags_tmp"
|
||||
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS tst_question_tags_tmp");
|
||||
DB_Query_new ("can not remove temporary table");
|
||||
|
||||
DB_BuildQuery ("CREATE TEMPORARY TABLE tst_question_tags_tmp"
|
||||
" ENGINE=MEMORY"
|
||||
" SELECT QstCod FROM tst_question_tags"
|
||||
" WHERE TagCod=%ld",
|
||||
ExistingTagCod);
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not create temporary table");
|
||||
ExistingTagCod);
|
||||
DB_Query_new ("can not create temporary table");
|
||||
|
||||
/* Remove old tag in questions where it would be repeated */
|
||||
// New tag existed for a question ==> delete old tag
|
||||
sprintf (Query,"DELETE FROM tst_question_tags"
|
||||
DB_BuildQuery ("DELETE FROM tst_question_tags"
|
||||
" WHERE TagCod=%ld"
|
||||
" AND QstCod IN"
|
||||
" (SELECT QstCod FROM tst_question_tags_tmp)",
|
||||
OldTagCod);
|
||||
DB_QueryDELETE (Query,"can not remove a tag from some questions");
|
||||
OldTagCod);
|
||||
DB_QueryDELETE_new ("can not remove a tag from some questions");
|
||||
|
||||
/* Change old tag to new tag in questions where it would not be repeated */
|
||||
// New tag did not exist for a question ==> change old tag to new tag
|
||||
sprintf (Query,"UPDATE tst_question_tags"
|
||||
DB_BuildQuery ("UPDATE tst_question_tags"
|
||||
" SET TagCod=%ld"
|
||||
" WHERE TagCod=%ld"
|
||||
" AND QstCod NOT IN"
|
||||
" (SELECT QstCod FROM tst_question_tags_tmp)",
|
||||
ExistingTagCod,
|
||||
OldTagCod);
|
||||
DB_QueryUPDATE (Query,"can not update a tag in some questions");
|
||||
ExistingTagCod,
|
||||
OldTagCod);
|
||||
DB_QueryUPDATE_new ("can not update a tag in some questions");
|
||||
|
||||
/* Drop temporary table, no longer necessary */
|
||||
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS tst_question_tags_tmp");
|
||||
if (mysql_query (&Gbl.mysql,Query))
|
||||
DB_ExitOnMySQLError ("can not remove temporary table");
|
||||
DB_BuildQuery ("DROP TEMPORARY TABLE IF EXISTS tst_question_tags_tmp");
|
||||
DB_Query_new ("can not remove temporary table");
|
||||
|
||||
/***** Delete old tag from tst_tags
|
||||
because it is not longer used *****/
|
||||
sprintf (Query,"DELETE FROM tst_tags WHERE TagCod=%ld",
|
||||
OldTagCod);
|
||||
DB_QueryDELETE (Query,"can not remove old tag");
|
||||
DB_BuildQuery ("DELETE FROM tst_tags WHERE TagCod=%ld",
|
||||
OldTagCod);
|
||||
DB_QueryDELETE_new ("can not remove old tag");
|
||||
}
|
||||
else // Renaming is easy
|
||||
{
|
||||
/***** Simple update replacing each instance of the old tag by the new tag *****/
|
||||
sprintf (Query,"UPDATE tst_tags SET TagTxt='%s',ChangeTime=NOW()"
|
||||
DB_BuildQuery ("UPDATE tst_tags SET TagTxt='%s',ChangeTime=NOW()"
|
||||
" WHERE tst_tags.CrsCod=%ld"
|
||||
" AND tst_tags.TagTxt='%s'",
|
||||
NewTagTxt,Gbl.CurrentCrs.Crs.CrsCod,OldTagTxt);
|
||||
DB_QueryUPDATE (Query,"can not update tag");
|
||||
NewTagTxt,Gbl.CurrentCrs.Crs.CrsCod,OldTagTxt);
|
||||
DB_QueryUPDATE_new ("can not update tag");
|
||||
}
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
|
@ -6421,7 +6416,6 @@ static void Tst_PutParamsRemoveQst (void)
|
|||
void Tst_RemoveQst (void)
|
||||
{
|
||||
extern const char *Txt_Question_removed;
|
||||
char Query[256];
|
||||
bool EditingOnlyThisQst;
|
||||
|
||||
/***** Get the question code *****/
|
||||
|
@ -6444,10 +6438,10 @@ void Tst_RemoveQst (void)
|
|||
Tst_RemoveUnusedTagsFromCurrentCrs ();
|
||||
|
||||
/* Remove the question itself */
|
||||
sprintf (Query,"DELETE FROM tst_questions"
|
||||
DB_BuildQuery ("DELETE FROM tst_questions"
|
||||
" WHERE QstCod=%ld AND CrsCod=%ld",
|
||||
Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove a question");
|
||||
Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove a question");
|
||||
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_ShowErrorAndExit ("The question to be removed does not exist or belongs to another course.");
|
||||
|
@ -6754,12 +6748,10 @@ static void Tst_InsertAnswersIntoDB (void)
|
|||
|
||||
static void Tst_RemAnsFromQst (void)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Remove answers *****/
|
||||
sprintf (Query,"DELETE FROM tst_answers WHERE QstCod=%ld",
|
||||
Gbl.Test.QstCod);
|
||||
DB_QueryDELETE (Query,"can not remove the answers of a question");
|
||||
DB_BuildQuery ("DELETE FROM tst_answers WHERE QstCod=%ld",
|
||||
Gbl.Test.QstCod);
|
||||
DB_QueryDELETE_new ("can not remove the answers of a question");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -6768,12 +6760,10 @@ static void Tst_RemAnsFromQst (void)
|
|||
|
||||
static void Tst_RemTagsFromQst (void)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
/***** Remove tags *****/
|
||||
sprintf (Query,"DELETE FROM tst_question_tags WHERE QstCod=%ld",
|
||||
Gbl.Test.QstCod);
|
||||
DB_QueryDELETE (Query,"can not remove the tags of a question");
|
||||
DB_BuildQuery ("DELETE FROM tst_question_tags WHERE QstCod=%ld",
|
||||
Gbl.Test.QstCod);
|
||||
DB_QueryDELETE_new ("can not remove the tags of a question");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -6782,18 +6772,16 @@ static void Tst_RemTagsFromQst (void)
|
|||
|
||||
static void Tst_RemoveUnusedTagsFromCurrentCrs (void)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Remove unused tags from tst_tags *****/
|
||||
sprintf (Query,"DELETE FROM tst_tags"
|
||||
DB_BuildQuery ("DELETE FROM tst_tags"
|
||||
" WHERE CrsCod=%ld AND TagCod NOT IN"
|
||||
" (SELECT DISTINCT tst_question_tags.TagCod"
|
||||
" FROM tst_questions,tst_question_tags"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod)",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove unused tags");
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove unused tags");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8556,20 +8544,18 @@ static void Tst_GetTestResultQuestionsFromDB (long TstCod)
|
|||
|
||||
void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Remove test results made by the specified user *****/
|
||||
sprintf (Query,"DELETE FROM tst_exam_questions"
|
||||
DB_BuildQuery ("DELETE FROM tst_exam_questions"
|
||||
" USING tst_exams,tst_exam_questions"
|
||||
" WHERE tst_exams.UsrCod=%ld"
|
||||
" AND tst_exams.TstCod=tst_exam_questions.TstCod",
|
||||
UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove test results made by a user");
|
||||
UsrCod);
|
||||
DB_QueryDELETE_new ("can not remove test results made by a user");
|
||||
|
||||
sprintf (Query,"DELETE FROM tst_exams"
|
||||
DB_BuildQuery ("DELETE FROM tst_exams"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove test results made by a user");
|
||||
UsrCod);
|
||||
DB_QueryDELETE_new ("can not remove test results made by a user");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8578,20 +8564,18 @@ void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod)
|
|||
|
||||
void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Remove test results made by the specified user *****/
|
||||
sprintf (Query,"DELETE FROM tst_exam_questions"
|
||||
DB_BuildQuery ("DELETE FROM tst_exam_questions"
|
||||
" USING tst_exams,tst_exam_questions"
|
||||
" WHERE tst_exams.CrsCod=%ld AND tst_exams.UsrCod=%ld"
|
||||
" AND tst_exams.TstCod=tst_exam_questions.TstCod",
|
||||
CrsCod,UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove test results made by a user in a course");
|
||||
CrsCod,UsrCod);
|
||||
DB_QueryDELETE_new ("can not remove test results made by a user in a course");
|
||||
|
||||
sprintf (Query,"DELETE FROM tst_exams"
|
||||
DB_BuildQuery ("DELETE FROM tst_exams"
|
||||
" WHERE CrsCod=%ld AND UsrCod=%ld",
|
||||
CrsCod,UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove test results made by a user in a course");
|
||||
CrsCod,UsrCod);
|
||||
DB_QueryDELETE_new ("can not remove test results made by a user in a course");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8600,20 +8584,18 @@ void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod)
|
|||
|
||||
void Tst_RemoveCrsTestResults (long CrsCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Remove questions of test results made in the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_exam_questions"
|
||||
DB_BuildQuery ("DELETE FROM tst_exam_questions"
|
||||
" USING tst_exams,tst_exam_questions"
|
||||
" WHERE tst_exams.CrsCod=%ld"
|
||||
" AND tst_exams.TstCod=tst_exam_questions.TstCod",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove test results made in a course");
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove test results made in a course");
|
||||
|
||||
/***** Remove test results made in the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_exams WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove test results made in a course");
|
||||
DB_BuildQuery ("DELETE FROM tst_exams WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove test results made in a course");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8622,37 +8604,35 @@ void Tst_RemoveCrsTestResults (long CrsCod)
|
|||
|
||||
void Tst_RemoveCrsTests (long CrsCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Remove tests status in the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_status WHERE CrsCod=%ld",CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove status of tests of a course");
|
||||
DB_BuildQuery ("DELETE FROM tst_status WHERE CrsCod=%ld",CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove status of tests of a course");
|
||||
|
||||
/***** Remove test configuration of the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_config WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove configuration of tests of a course");
|
||||
DB_BuildQuery ("DELETE FROM tst_config WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove configuration of tests of a course");
|
||||
|
||||
/***** Remove associations between test questions
|
||||
and test tags in the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_question_tags"
|
||||
DB_BuildQuery ("DELETE FROM tst_question_tags"
|
||||
" USING tst_questions,tst_question_tags"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_question_tags.QstCod",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove tags associated to questions of tests of a course");
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove tags associated to questions of tests of a course");
|
||||
|
||||
/***** Remove test tags in the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_tags WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove tags of test of a course");
|
||||
DB_BuildQuery ("DELETE FROM tst_tags WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove tags of test of a course");
|
||||
|
||||
/***** Remove test answers in the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_answers USING tst_questions,tst_answers"
|
||||
DB_BuildQuery ("DELETE FROM tst_answers USING tst_questions,tst_answers"
|
||||
" WHERE tst_questions.CrsCod=%ld"
|
||||
" AND tst_questions.QstCod=tst_answers.QstCod",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove answers of tests of a course");
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove answers of tests of a course");
|
||||
|
||||
/***** Remove files with images associated
|
||||
to test questions in the course *****/
|
||||
|
@ -8660,7 +8640,7 @@ void Tst_RemoveCrsTests (long CrsCod)
|
|||
Tst_RemoveAllImgFilesFromStemOfAllQstsInCrs (CrsCod);
|
||||
|
||||
/***** Remove test questions in the course *****/
|
||||
sprintf (Query,"DELETE FROM tst_questions WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove test questions of a course");
|
||||
DB_BuildQuery ("DELETE FROM tst_questions WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove test questions of a course");
|
||||
}
|
||||
|
|
|
@ -558,9 +558,6 @@ void TT_ShowTimeTable (long UsrCod)
|
|||
|
||||
static void TT_WriteCrsTimeTableIntoDB (long CrsCod)
|
||||
{
|
||||
char Query[512 +
|
||||
TT_MAX_BYTES_PLACE +
|
||||
Grp_MAX_BYTES_GROUP_NAME];
|
||||
unsigned Weekday;
|
||||
unsigned Interval;
|
||||
unsigned Hour;
|
||||
|
@ -568,9 +565,9 @@ static void TT_WriteCrsTimeTableIntoDB (long CrsCod)
|
|||
unsigned Column;
|
||||
|
||||
/***** Remove former timetable *****/
|
||||
sprintf (Query,"DELETE FROM timetable_crs WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE (Query,"can not remove former timetable");
|
||||
DB_BuildQuery ("DELETE FROM timetable_crs WHERE CrsCod=%ld",
|
||||
CrsCod);
|
||||
DB_QueryDELETE_new ("can not remove former timetable");
|
||||
|
||||
/***** Go across the timetable inserting classes into database *****/
|
||||
for (Weekday = 0;
|
||||
|
@ -587,22 +584,22 @@ static void TT_WriteCrsTimeTableIntoDB (long CrsCod)
|
|||
if (TT_TimeTable[Weekday][Interval].Columns[Column].IntervalType == TT_FIRST_INTERVAL &&
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals)
|
||||
{
|
||||
sprintf (Query,"INSERT INTO timetable_crs"
|
||||
DB_BuildQuery ("INSERT INTO timetable_crs"
|
||||
" (CrsCod,GrpCod,Weekday,StartTime,Duration,"
|
||||
"ClassType,Place,GroupName)"
|
||||
" VALUES"
|
||||
" (%ld,%ld,%u,'%02u:%02u:00',SEC_TO_TIME(%u),"
|
||||
"'%s','%s','%s')",
|
||||
CrsCod,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].GrpCod,
|
||||
Weekday,
|
||||
Hour,Min,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
|
||||
Gbl.TimeTable.Config.SecondsPerInterval,
|
||||
TT_ClassTypeDB[TT_TimeTable[Weekday][Interval].Columns[Column].ClassType],
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].Place,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].Group);
|
||||
DB_QueryINSERT (Query,"can not create course timetable");
|
||||
CrsCod,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].GrpCod,
|
||||
Weekday,
|
||||
Hour,Min,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
|
||||
Gbl.TimeTable.Config.SecondsPerInterval,
|
||||
TT_ClassTypeDB[TT_TimeTable[Weekday][Interval].Columns[Column].ClassType],
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].Place,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].Group);
|
||||
DB_QueryINSERT_new ("can not create course timetable");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -612,8 +609,6 @@ static void TT_WriteCrsTimeTableIntoDB (long CrsCod)
|
|||
|
||||
static void TT_WriteTutTimeTableIntoDB (long UsrCod)
|
||||
{
|
||||
char Query[512 +
|
||||
TT_MAX_BYTES_PLACE];
|
||||
unsigned Weekday;
|
||||
unsigned Interval;
|
||||
unsigned Hour;
|
||||
|
@ -621,9 +616,8 @@ static void TT_WriteTutTimeTableIntoDB (long UsrCod)
|
|||
unsigned Column;
|
||||
|
||||
/***** Remove former timetable *****/
|
||||
sprintf (Query,"DELETE FROM timetable_tut WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove former timetable");
|
||||
DB_BuildQuery ("DELETE FROM timetable_tut WHERE UsrCod=%ld",UsrCod);
|
||||
DB_QueryDELETE_new ("can not remove former timetable");
|
||||
|
||||
/***** Loop over timetable *****/
|
||||
for (Weekday = 0;
|
||||
|
@ -640,17 +634,17 @@ static void TT_WriteTutTimeTableIntoDB (long UsrCod)
|
|||
if (TT_TimeTable[Weekday][Interval].Columns[Column].IntervalType == TT_FIRST_INTERVAL &&
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals)
|
||||
{
|
||||
sprintf (Query,"INSERT INTO timetable_tut"
|
||||
DB_BuildQuery ("INSERT INTO timetable_tut"
|
||||
" (UsrCod,Weekday,StartTime,Duration,Place)"
|
||||
" VALUES"
|
||||
" (%ld,%u,'%02u:%02u:00',SEC_TO_TIME(%u),'%s')",
|
||||
UsrCod,
|
||||
Weekday,
|
||||
Hour,Min,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
|
||||
Gbl.TimeTable.Config.SecondsPerInterval,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].Place);
|
||||
DB_QueryINSERT (Query,"can not create office timetable");
|
||||
UsrCod,
|
||||
Weekday,
|
||||
Hour,Min,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals *
|
||||
Gbl.TimeTable.Config.SecondsPerInterval,
|
||||
TT_TimeTable[Weekday][Interval].Columns[Column].Place);
|
||||
DB_QueryINSERT_new ("can not create office timetable");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
19
swad_user.c
19
swad_user.c
|
@ -2548,19 +2548,17 @@ static bool Usr_CheckIfMyBirthdayHasNotBeenCongratulated (void)
|
|||
|
||||
static void Usr_InsertMyBirthday (void)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Delete old birthdays *****/
|
||||
sprintf (Query,"DELETE FROM birthdays_today WHERE Today<>CURDATE()");
|
||||
DB_QueryDELETE (Query,"can not delete old birthdays");
|
||||
DB_BuildQuery ("DELETE FROM birthdays_today WHERE Today<>CURDATE()");
|
||||
DB_QueryDELETE_new ("can not delete old birthdays");
|
||||
|
||||
/***** Insert new birthday *****/
|
||||
sprintf (Query,"INSERT INTO birthdays_today"
|
||||
DB_BuildQuery ("INSERT INTO birthdays_today"
|
||||
" (UsrCod,Today)"
|
||||
" VALUES"
|
||||
" (%ld,CURDATE())",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
DB_QueryINSERT (Query,"can not insert birthday");
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
DB_QueryINSERT_new ("can not insert birthday");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8960,11 +8958,8 @@ bool Usr_CheckIfUsrBanned (long UsrCod)
|
|||
|
||||
void Usr_RemoveUsrFromUsrBanned (long UsrCod)
|
||||
{
|
||||
char Query[128];
|
||||
|
||||
sprintf (Query,"DELETE FROM usr_banned WHERE UsrCod=%ld",
|
||||
UsrCod);
|
||||
DB_QueryDELETE (Query,"can not remove user from users banned");
|
||||
DB_BuildQuery ("DELETE FROM usr_banned WHERE UsrCod=%ld",UsrCod);
|
||||
DB_QueryDELETE_new ("can not remove user from users banned");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue
Block a user