Version 18.11.23

This commit is contained in:
Antonio Cañas Vargas 2018-11-03 01:45:36 +01:00
parent 56cc0f530d
commit 8c2707a529
25 changed files with 433 additions and 390 deletions

View File

@ -728,7 +728,10 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
CommentsLength = strlen (UsrDat->Comments);
else
CommentsLength = 0;
DB_BuildQuery ("INSERT INTO usr_data"
UsrDat->UsrCod =
DB_QueryINSERTandReturnCode ("can not create user",
"INSERT INTO usr_data"
" (EncryptedUsrCod,Password,"
"Surname1,Surname2,FirstName,Sex,"
"Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
@ -767,7 +770,6 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
"",
(unsigned) Mnu_MENU_DEFAULT,
(unsigned) Cfg_DEFAULT_COLUMNS);
UsrDat->UsrCod = DB_QueryINSERTandReturnCode_new ("can not create user");
/* Insert user's IDs as confirmed */
for (NumID = 0;

View File

@ -1710,7 +1710,9 @@ void Agd_RecFormEvent (void)
static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt)
{
/***** Create a new event *****/
DB_BuildQuery ("INSERT INTO agendas"
AgdEvent->AgdCod =
DB_QueryINSERTandReturnCode ("can not create new event",
"INSERT INTO agendas"
" (UsrCod,StartTime,EndTime,Event,Location,Txt)"
" VALUES"
" (%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
@ -1721,7 +1723,6 @@ static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt)
AgdEvent->Event,
AgdEvent->Location,
Txt);
AgdEvent->AgdCod = DB_QueryINSERTandReturnCode_new ("can not create new event");
}
/*****************************************************************************/

View File

@ -1495,7 +1495,9 @@ static void Asg_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,unsigne
static void Asg_CreateAssignment (struct Assignment *Asg,const char *Txt)
{
/***** Create a new assignment *****/
DB_BuildQuery ("INSERT INTO assignments"
Asg->AsgCod =
DB_QueryINSERTandReturnCode ("can not create new assignment",
"INSERT INTO assignments"
" (CrsCod,UsrCod,StartTime,EndTime,Title,Folder,Txt)"
" VALUES"
" (%ld,%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
@ -1507,7 +1509,6 @@ static void Asg_CreateAssignment (struct Assignment *Asg,const char *Txt)
Asg->Title,
Asg->Folder,
Txt);
Asg->AsgCod = DB_QueryINSERTandReturnCode_new ("can not create new assignment");
/***** Create groups *****/
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)

View File

@ -1355,7 +1355,9 @@ void Att_RecFormAttEvent (void)
void Att_CreateAttEvent (struct AttendanceEvent *Att,const char *Txt)
{
/***** Create a new attendance event *****/
DB_BuildQuery ("INSERT INTO att_events"
Att->AttCod =
DB_QueryINSERTandReturnCode ("can not create new attendance event",
"INSERT INTO att_events"
" (CrsCod,Hidden,UsrCod,"
"StartTime,EndTime,CommentTchVisible,Title,Txt)"
" VALUES"
@ -1371,7 +1373,6 @@ void Att_CreateAttEvent (struct AttendanceEvent *Att,const char *Txt)
'N',
Att->Title,
Txt);
Att->AttCod = DB_QueryINSERTandReturnCode_new ("can not create new attendance event");
/***** Create groups *****/
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)

View File

@ -2816,7 +2816,9 @@ static void Ctr_CreateCentre (unsigned Status)
extern const char *Txt_Created_new_centre_X;
/***** Create a new centre *****/
DB_BuildQuery ("INSERT INTO centres"
Gbl.Ctrs.EditingCtr.CtrCod =
DB_QueryINSERTandReturnCode ("can not create a new centre",
"INSERT INTO centres"
" (InsCod,PlcCod,Status,RequesterUsrCod,"
"ShortName,FullName,WWW,PhotoAttribution)"
" VALUES"
@ -2829,7 +2831,6 @@ static void Ctr_CreateCentre (unsigned Status)
Gbl.Ctrs.EditingCtr.ShrtName,
Gbl.Ctrs.EditingCtr.FullName,
Gbl.Ctrs.EditingCtr.WWW);
Gbl.Ctrs.EditingCtr.CtrCod = DB_QueryINSERTandReturnCode_new ("can not create a new centre");
/***** Write message to show the change made
and put button to go to centre created *****/

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.11.22 (2018-11-02)"
#define Log_PLATFORM_VERSION "SWAD 18.11.23 (2018-11-03)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.11.23: Nov 03, 2018 Joining building and performing query into one function. (236630 lines)
Version 18.11.22: Nov 02, 2018 Joining building and performing query into one function. (236589 lines)
Version 18.11.21: Nov 02, 2018 Joining building and performing query into one function. (236580 lines)
Version 18.11.20: Nov 02, 2018 Joining building and performing query into one function. (236585 lines)

View File

@ -1929,16 +1929,20 @@ static void Crs_CreateCourse (unsigned Status)
extern const char *Txt_Created_new_course_X;
/***** Insert new course into pending requests *****/
DB_BuildQuery ("INSERT INTO courses"
" (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,ShortName,FullName)"
Gbl.Degs.EditingCrs.CrsCod =
DB_QueryINSERTandReturnCode ("can not create a new course",
"INSERT INTO courses"
" (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,"
"ShortName,FullName)"
" VALUES"
" (%ld,%u,'%s',%u,%ld,'%s','%s')",
" (%ld,%u,'%s',%u,%ld,"
"'%s','%s')",
Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year,
Gbl.Degs.EditingCrs.InstitutionalCrsCod,
Status,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Degs.EditingCrs.ShrtName,Gbl.Degs.EditingCrs.FullName);
Gbl.Degs.EditingCrs.CrsCod = DB_QueryINSERTandReturnCode_new ("can not create a new course");
Gbl.Degs.EditingCrs.ShrtName,
Gbl.Degs.EditingCrs.FullName);
/***** Create success message *****/
Gbl.Alert.Type = Ale_SUCCESS;

View File

@ -3244,19 +3244,31 @@ void DB_QueryINSERT_old (char **Query,const char *MsgError)
/** Make an INSERT query in database and return code of last inserted item ***/
/*****************************************************************************/
long DB_QueryINSERTandReturnCode_new (const char *MsgError)
long DB_QueryINSERTandReturnCode (const char *MsgError,const char *fmt,...)
{
va_list ap;
int NumBytesPrinted;
char *Query = NULL;
int Result;
va_start (ap,fmt);
NumBytesPrinted = vasprintf (&Query,fmt,ap);
va_end (ap);
if (NumBytesPrinted < 0) // If memory allocation wasn't possible,
// or some other error occurs,
// vasprintf will return -1
Lay_NotEnoughMemoryExit ();
/***** Check that query string pointer
does point to an allocated string *****/
if (Gbl.DB.QueryPtr == NULL)
if (Query == NULL)
Lay_ShowErrorAndExit ("Wrong query string.");
/***** Query database and free query string pointer *****/
Result = mysql_query (&Gbl.mysql,Gbl.DB.QueryPtr); // Returns 0 on success
free ((void *) Gbl.DB.QueryPtr);
Gbl.DB.QueryPtr = NULL;
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Query);
Query = NULL;
if (Result)
DB_ExitOnMySQLError (MsgError);

View File

@ -51,7 +51,7 @@ unsigned long DB_QueryCOUNT_old (char **Query,const char *MsgError);
void DB_QueryINSERT (const char *MsgError,const char *fmt,...);
void DB_QueryINSERT_old (char **Query,const char *MsgError);
long DB_QueryINSERTandReturnCode_new (const char *MsgError);
long DB_QueryINSERTandReturnCode (const char *MsgError,const char *fmt,...);
void DB_QueryREPLACE (const char *MsgError,const char *fmt,...);

View File

@ -1144,7 +1144,9 @@ static void Deg_CreateDegree (unsigned Status)
extern const char *Txt_Created_new_degree_X;
/***** Create a new degree *****/
DB_BuildQuery ("INSERT INTO degrees (CtrCod,DegTypCod,Status,"
Gbl.Degs.EditingDeg.DegCod =
DB_QueryINSERTandReturnCode ("can not create a new degree",
"INSERT INTO degrees (CtrCod,DegTypCod,Status,"
"RequesterUsrCod,ShortName,FullName,WWW)"
" VALUES (%ld,%ld,%u,%ld,'%s','%s','%s')",
Gbl.Degs.EditingDeg.CtrCod,
@ -1154,7 +1156,6 @@ static void Deg_CreateDegree (unsigned Status)
Gbl.Degs.EditingDeg.ShrtName,
Gbl.Degs.EditingDeg.FullName,
Gbl.Degs.EditingDeg.WWW);
Gbl.Degs.EditingDeg.DegCod = DB_QueryINSERTandReturnCode_new ("can not create a new degree");
/***** Write message to show the change made
and put button to go to degree created *****/

View File

@ -2054,16 +2054,15 @@ void Enr_SignUpInCrs (void)
DB_QueryUPDATE_new ("can not update enrolment request");
}
else // No request in database for this user in this course
{
DB_BuildQuery ("INSERT INTO crs_usr_requests"
ReqCod =
DB_QueryINSERTandReturnCode ("can not save enrolment request",
"INSERT INTO crs_usr_requests"
" (CrsCod,UsrCod,Role,RequestTime)"
" VALUES"
" (%ld,%ld,%u,NOW())",
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) RoleFromForm);
ReqCod = DB_QueryINSERTandReturnCode_new ("can not save enrolment request");
}
/***** Show confirmation message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -734,7 +734,9 @@ static long Exa_AddExamAnnouncementToDB (void)
long ExaCod;
/***** Add exam announcement *****/
DB_BuildQuery ("INSERT INTO exam_announcements "
ExaCod =
DB_QueryINSERTandReturnCode ("can not create a new exam announcement",
"INSERT INTO exam_announcements "
"(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession,"
"CallDate,ExamDate,Duration,"
"Place,ExamMode,Structure,DocRequired,MatRequired,MatAllowed,OtherInfo)"
@ -761,7 +763,6 @@ static long Exa_AddExamAnnouncementToDB (void)
Gbl.ExamAnns.ExaDat.MatRequired,
Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnns.ExaDat.OtherInfo);
ExaCod = DB_QueryINSERTandReturnCode_new ("can not create a new exam announcement");
return ExaCod;
}

View File

@ -11831,7 +11831,9 @@ long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType,
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
/***** Add path to the database *****/
DB_BuildQuery ("INSERT INTO files"
return
DB_QueryINSERTandReturnCode ("can not add path to database",
"INSERT INTO files"
" (FileBrowser,Cod,ZoneUsrCod,"
"PublisherUsrCod,FileType,Path,Hidden,Public,License)"
" VALUES"
@ -11845,7 +11847,6 @@ long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType,
IsPublic ? 'Y' :
'N',
(unsigned) License);
return DB_QueryINSERTandReturnCode_new ("can not add path to database");
}
/*****************************************************************************/

View File

@ -507,7 +507,9 @@ static long For_InsertForumPst (long ThrCod,long UsrCod,
Img_MoveImageToDefinitiveDirectory (Image);
/***** Insert forum post in the database *****/
DB_BuildQuery ("INSERT INTO forum_post"
PstCod =
DB_QueryINSERTandReturnCode ("can not create a new post in a forum",
"INSERT INTO forum_post"
" (ThrCod,UsrCod,CreatTime,ModifTime,NumNotif,"
"Subject,Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
@ -518,7 +520,6 @@ static long For_InsertForumPst (long ThrCod,long UsrCod,
Image->Name,
Image->Title ? Image->Title : "",
Image->URL ? Image->URL : "");
PstCod = DB_QueryINSERTandReturnCode_new ("can not create a new post in a forum");
return PstCod;
}
@ -595,14 +596,15 @@ static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod)
static long For_InsertForumThread (long FirstPstCod)
{
/***** Insert new thread in the database *****/
DB_BuildQuery ("INSERT INTO forum_thread"
return
DB_QueryINSERTandReturnCode ("can not create a new thread in a forum",
"INSERT INTO forum_thread"
" (ForumType,Location,FirstPstCod,LastPstCod)"
" VALUES"
" (%u,%ld,%ld,%ld)",
(unsigned) Gbl.Forum.ForumSelected.Type,
Gbl.Forum.ForumSelected.Location,
FirstPstCod,FirstPstCod);
return DB_QueryINSERTandReturnCode_new ("can not create a new thread in a forum");
}
/*****************************************************************************/

View File

@ -2180,7 +2180,9 @@ static void Gam_CreateGame (struct Game *Game,const char *Txt)
extern const char *Txt_Created_new_game_X;
/***** Create a new game *****/
DB_BuildQuery ("INSERT INTO games"
Game->GamCod =
DB_QueryINSERTandReturnCode ("can not create new game",
"INSERT INTO games"
" (Scope,Cod,Hidden,Roles,UsrCod,StartTime,EndTime,Title,Txt)"
" VALUES"
" ('%s',%ld,'N',%u,%ld,"
@ -2193,7 +2195,6 @@ static void Gam_CreateGame (struct Game *Game,const char *Txt)
Game->TimeUTC[Gam_END_TIME ],
Game->Title,
Txt);
Game->GamCod = DB_QueryINSERTandReturnCode_new ("can not create new game");
/***** Create groups *****/
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)

View File

@ -3825,7 +3825,9 @@ static bool Grp_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long
static void Grp_CreateGroupType (void)
{
/***** Create a new group type *****/
DB_BuildQuery ("INSERT INTO crs_grp_types"
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod =
DB_QueryINSERTandReturnCode ("can not create type of group",
"INSERT INTO crs_grp_types"
" (CrsCod,GrpTypName,Mandatory,Multiple,MustBeOpened,OpenTime)"
" VALUES"
" (%ld,'%s','%c','%c','%c',FROM_UNIXTIME(%ld))",
@ -3837,7 +3839,6 @@ static void Grp_CreateGroupType (void)
Gbl.CurrentCrs.Grps.GrpTyp.MustBeOpened ? 'Y' :
'N',
(long) Gbl.CurrentCrs.Grps.GrpTyp.OpenTimeUTC);
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = DB_QueryINSERTandReturnCode_new ("can not create type of group");
}
/*****************************************************************************/

View File

@ -2412,7 +2412,9 @@ static void Ins_CreateInstitution (unsigned Status)
extern const char *Txt_Created_new_institution_X;
/***** Create a new institution *****/
DB_BuildQuery ("INSERT INTO institutions"
Gbl.Inss.EditingIns.InsCod =
DB_QueryINSERTandReturnCode ("can not create institution",
"INSERT INTO institutions"
" (CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW)"
" VALUES"
" (%ld,%u,%ld,'%s','%s','%s')",
@ -2422,7 +2424,6 @@ static void Ins_CreateInstitution (unsigned Status)
Gbl.Inss.EditingIns.ShrtName,
Gbl.Inss.EditingIns.FullName,
Gbl.Inss.EditingIns.WWW);
Gbl.Inss.EditingIns.InsCod = DB_QueryINSERTandReturnCode_new ("can not create institution");
/***** Write message to show the change made
and put button to go to institution created *****/

View File

@ -1313,7 +1313,9 @@ static long Msg_InsertNewMsg (const char *Subject,const char *Content,
Img_MoveImageToDefinitiveDirectory (Image);
/***** Insert message subject and content in the database *****/
DB_BuildQuery ("INSERT INTO msg_content"
MsgCod =
DB_QueryINSERTandReturnCode ("can not create message",
"INSERT INTO msg_content"
" (Subject,Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
" ('%s','%s','%s','%s','%s')",
@ -1321,7 +1323,6 @@ static long Msg_InsertNewMsg (const char *Subject,const char *Content,
Image->Name,
Image->Title ? Image->Title : "",
Image->URL ? Image->URL : "");
MsgCod = DB_QueryINSERTandReturnCode_new ("can not create message");
/***** Insert message in sent messages *****/
DB_QueryINSERT ("can not create message",

View File

@ -165,13 +165,15 @@ void Not_ReceiveNotice (void)
static long Not_InsertNoticeInDB (const char *Content)
{
/***** Insert notice in the database *****/
DB_BuildQuery ("INSERT INTO notices"
return
DB_QueryINSERTandReturnCode ("can not create notice",
"INSERT INTO notices"
" (CrsCod,UsrCod,CreatTime,Content,Status)"
" VALUES"
" (%ld,%ld,NOW(),'%s',%u)",
Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
Content,(unsigned) Not_ACTIVE_NOTICE);
return DB_QueryINSERTandReturnCode_new ("can not create notice");
}
/*****************************************************************************/

View File

@ -3314,7 +3314,9 @@ static void Prj_CreateProject (struct Project *Prj)
Prj->ModifTime = Gbl.StartExecutionTimeUTC;
/***** Create a new project *****/
DB_BuildQuery ("INSERT INTO projects"
Prj->PrjCod =
DB_QueryINSERTandReturnCode ("can not create new project",
"INSERT INTO projects"
" (CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal,"
"CreatTime,ModifTime,"
"Title,Description,Knowledge,Materials,URL)"
@ -3337,7 +3339,6 @@ static void Prj_CreateProject (struct Project *Prj)
Prj->Knowledge,
Prj->Materials,
Prj->URL);
Prj->PrjCod = DB_QueryINSERTandReturnCode_new ("can not create new project");
/***** Insert creator as first tutor *****/
DB_QueryINSERT ("can not add tutor",

View File

@ -1950,12 +1950,14 @@ void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod,struct Soci
}
/***** Store social note *****/
DB_BuildQuery ("INSERT INTO social_notes"
SocPub->NotCod =
DB_QueryINSERTandReturnCode ("can not create new social note",
"INSERT INTO social_notes"
" (NoteType,Cod,UsrCod,HieCod,Unavailable,TimeNote)"
" VALUES"
" (%u,%ld,%ld,%ld,'N',NOW())",
(unsigned) NoteType,Cod,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod);
SocPub->NotCod = DB_QueryINSERTandReturnCode_new ("can not create new social note");
(unsigned) NoteType,
Cod,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod);
/***** Publish social note in timeline *****/
SocPub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -2122,14 +2124,15 @@ void Soc_MarkSocialNotesChildrenOfFolderAsUnavailable (const char *Path)
static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub)
{
/***** Publish social note in timeline *****/
DB_BuildQuery ("INSERT INTO social_pubs"
SocPub->PubCod =
DB_QueryINSERTandReturnCode ("can not publish social note",
"INSERT INTO social_pubs"
" (NotCod,PublisherCod,PubType,TimePublish)"
" VALUES"
" (%ld,%ld,%u,NOW())",
SocPub->NotCod,
SocPub->PublisherCod,
(unsigned) SocPub->PubType);
SocPub->PubCod = DB_QueryINSERTandReturnCode_new ("can not publish social note");
}
/*****************************************************************************/
@ -2300,7 +2303,9 @@ static long Soc_ReceiveSocialPost (void)
/***** Publish *****/
/* Insert post content in the database */
DB_BuildQuery ("INSERT INTO social_posts"
PstCod =
DB_QueryINSERTandReturnCode ("can not create post",
"INSERT INTO social_posts"
" (Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
" ('%s','%s','%s','%s')",
@ -2310,7 +2315,6 @@ static long Soc_ReceiveSocialPost (void)
Image.Title) ? Image.Title : "",
(Image.Name[0] && // Save image URL only if image attached
Image.URL ) ? Image.URL : "");
PstCod = DB_QueryINSERTandReturnCode_new ("can not create post");
/* Insert post in social notes */
Soc_StoreAndPublishSocialNote (Soc_NOTE_SOCIAL_POST,PstCod,&SocPub);

View File

@ -293,7 +293,9 @@ void Sta_LogAccess (const char *Comments)
/***** Insert access into database *****/
/* Log access in historical log (log_full) */
DB_BuildQuery ("INSERT INTO log_full "
LogCod =
DB_QueryINSERTandReturnCode ("can not log access (full)",
"INSERT INTO log_full "
"(ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
" VALUES "
@ -310,7 +312,6 @@ void Sta_LogAccess (const char *Comments)
Gbl.TimeGenerationInMicroseconds,
Gbl.TimeSendInMicroseconds,
Gbl.IP);
LogCod = DB_QueryINSERTandReturnCode_new ("can not log access (full)");
/* Log access in recent log (log_recent) */
DB_QueryINSERT ("can not log access (recent)",

View File

@ -2253,7 +2253,9 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
extern const char *Txt_Created_new_survey_X;
/***** Create a new survey *****/
DB_BuildQuery ("INSERT INTO surveys"
Svy->SvyCod =
DB_QueryINSERTandReturnCode ("can not create new survey",
"INSERT INTO surveys"
" (Scope,Cod,Hidden,Roles,UsrCod,StartTime,EndTime,Title,Txt)"
" VALUES"
" ('%s',%ld,'N',%u,%ld,"
@ -2266,7 +2268,6 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
Svy->TimeUTC[Svy_END_TIME ],
Svy->Title,
Txt);
Svy->SvyCod = DB_QueryINSERTandReturnCode_new ("can not create new survey");
/***** Create groups *****/
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)
@ -3022,13 +3023,14 @@ void Svy_ReceiveQst (void)
SvyQst.QstInd = Svy_GetNextQuestionIndexInSvy (SvyCod);
/* Insert question in the table of questions */
DB_BuildQuery ("INSERT INTO svy_questions"
SvyQst.QstCod =
DB_QueryINSERTandReturnCode ("can not create question",
"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_new ("can not create question");
}
else // It's an existing question
{

View File

@ -6301,12 +6301,13 @@ static long Tst_GetTagCodFromTagTxt (const char *TagTxt)
static long Tst_CreateNewTag (long CrsCod,const char *TagTxt)
{
/***** Insert new tag into tst_tags table *****/
DB_BuildQuery ("INSERT INTO tst_tags"
return
DB_QueryINSERTandReturnCode ("can not create new tag",
"INSERT INTO tst_tags"
" (CrsCod,ChangeTime,TagTxt,TagHidden)"
" VALUES"
" (%ld,NOW(),'%s','N')",
CrsCod,TagTxt);
return DB_QueryINSERTandReturnCode_new ("can not create new tag");
}
/*****************************************************************************/
@ -6541,7 +6542,9 @@ static void Tst_InsertOrUpdateQstIntoDB (void)
if (Gbl.Test.QstCod < 0) // It's a new question
{
/***** Insert question in the table of questions *****/
DB_BuildQuery ("INSERT INTO tst_questions"
Gbl.Test.QstCod =
DB_QueryINSERTandReturnCode ("can not create question",
"INSERT INTO tst_questions"
" (CrsCod,EditTime,AnsType,Shuffle,"
"Stem,Feedback,ImageName,ImageTitle,ImageURL,"
"NumHits,Score)"
@ -6558,7 +6561,6 @@ static void Tst_InsertOrUpdateQstIntoDB (void)
Gbl.Test.Image.Name,
Gbl.Test.Image.Title ? Gbl.Test.Image.Title : "",
Gbl.Test.Image.URL ? Gbl.Test.Image.URL : "");
Gbl.Test.QstCod = DB_QueryINSERTandReturnCode_new ("can not create question");
/* Update image status */
if (Gbl.Test.Image.Name[0])
@ -7593,7 +7595,9 @@ void Tst_SelDatesToSeeMyTestResults (void)
static long Tst_CreateTestResultInDB (void)
{
/***** Insert new test result into table *****/
DB_BuildQuery ("INSERT INTO tst_exams"
return
DB_QueryINSERTandReturnCode ("can not create new test result",
"INSERT INTO tst_exams"
" (CrsCod,UsrCod,AllowTeachers,TstTime,NumQsts)"
" VALUES"
" (%ld,%ld,'%c',NOW(),%u)",
@ -7602,7 +7606,6 @@ static long Tst_CreateTestResultInDB (void)
Gbl.Test.AllowTeachers ? 'Y' :
'N',
Gbl.Test.NumQsts);
return DB_QueryINSERTandReturnCode_new ("can not create new test result");
}
/*****************************************************************************/

View File

@ -3424,16 +3424,16 @@ static int Svc_SendMessageToUsr (long OriginalMsgCod,
if (!MsgAlreadyInserted) // The message is inserted only once in the table of messages sent
{
/***** Insert message subject and body in the database *****/
/* Build query */
DB_BuildQuery ("INSERT INTO msg_content"
/* Get the code of the inserted item */
NewMsgCod =
DB_QueryINSERTandReturnCode ("can not create message",
"INSERT INTO msg_content"
" (Subject,Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
" ('%s','%s','','','')",
Subject,Content);
/* Get the code of the inserted item */
NewMsgCod = DB_QueryINSERTandReturnCode_new ("can not create message");
/***** Insert message in sent messages *****/
/* Insert message in sent messages */
DB_QueryINSERT ("can not create message",
"INSERT INTO msg_snt"
" (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)"
@ -3528,17 +3528,16 @@ int swad__sendNotice (struct soap *soap,
"Requester must be a teacher");
/***** Insert notice in the database *****/
/* Build query */
DB_BuildQuery ("INSERT INTO notices"
/* Get the code of the inserted item */
NotCod =
DB_QueryINSERTandReturnCode ("can not create message",
"INSERT INTO notices"
" (CrsCod,UsrCod,CreatTime,Content,Status)"
" VALUES"
" (%ld,%ld,NOW(),'%s',%u)",
Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod,
body,(unsigned) Not_ACTIVE_NOTICE);
/* Get the code of the inserted item */
NotCod = DB_QueryINSERTandReturnCode_new ("can not create message");
/***** Create notifications *****/
// TODO: create notifications
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!