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,46 +728,48 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
CommentsLength = strlen (UsrDat->Comments); CommentsLength = strlen (UsrDat->Comments);
else else
CommentsLength = 0; CommentsLength = 0;
DB_BuildQuery ("INSERT INTO usr_data"
" (EncryptedUsrCod,Password," UsrDat->UsrCod =
"Surname1,Surname2,FirstName,Sex," DB_QueryINSERTandReturnCode ("can not create user",
"Theme,IconSet,Language,FirstDayOfWeek,DateFormat," "INSERT INTO usr_data"
"PhotoVisibility,ProfileVisibility," " (EncryptedUsrCod,Password,"
"CtyCod," "Surname1,Surname2,FirstName,Sex,"
"LocalAddress,LocalPhone," "Theme,IconSet,Language,FirstDayOfWeek,DateFormat,"
"FamilyAddress,FamilyPhone," "PhotoVisibility,ProfileVisibility,"
"OriginPlace,Birthday,Comments," "CtyCod,"
"Menu,SideCols,NotifNtfEvents,EmailNtfEvents)" "LocalAddress,LocalPhone,"
" VALUES" "FamilyAddress,FamilyPhone,"
" ('%s','%s'," "OriginPlace,Birthday,Comments,"
"'%s','%s','%s','%s'," "Menu,SideCols,NotifNtfEvents,EmailNtfEvents)"
"'%s','%s','%s',%u,%u," " VALUES"
"'%s','%s'," " ('%s','%s',"
"%ld," "'%s','%s','%s','%s',"
"'%s','%s'," "'%s','%s','%s',%u,%u,"
"'%s','%s','%s'," "'%s','%s',"
"%s,'%s'," "%ld,"
"%u,%u,-1,0)", "'%s','%s',"
UsrDat->EncryptedUsrCod, "'%s','%s','%s',"
UsrDat->Password, "%s,'%s',"
UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName, "%u,%u,-1,0)",
Usr_StringsSexDB[UsrDat->Sex], UsrDat->EncryptedUsrCod,
The_ThemeId[UsrDat->Prefs.Theme], UsrDat->Password,
Ico_IconSetId[UsrDat->Prefs.IconSet], UsrDat->Surname1,UsrDat->Surname2,UsrDat->FirstName,
Txt_STR_LANG_ID[UsrDat->Prefs.Language], Usr_StringsSexDB[UsrDat->Sex],
Cal_FIRST_DAY_OF_WEEK_DEFAULT, The_ThemeId[UsrDat->Prefs.Theme],
(unsigned) Dat_FORMAT_DEFAULT, Ico_IconSetId[UsrDat->Prefs.IconSet],
Pri_VisibilityDB[UsrDat->PhotoVisibility], Txt_STR_LANG_ID[UsrDat->Prefs.Language],
Pri_VisibilityDB[UsrDat->ProfileVisibility], Cal_FIRST_DAY_OF_WEEK_DEFAULT,
UsrDat->CtyCod, (unsigned) Dat_FORMAT_DEFAULT,
UsrDat->LocalAddress ,UsrDat->LocalPhone, Pri_VisibilityDB[UsrDat->PhotoVisibility],
UsrDat->FamilyAddress,UsrDat->FamilyPhone,UsrDat->OriginPlace, Pri_VisibilityDB[UsrDat->ProfileVisibility],
BirthdayStrDB, UsrDat->CtyCod,
CommentsLength ? UsrDat->Comments : UsrDat->LocalAddress ,UsrDat->LocalPhone,
"", UsrDat->FamilyAddress,UsrDat->FamilyPhone,UsrDat->OriginPlace,
(unsigned) Mnu_MENU_DEFAULT, BirthdayStrDB,
(unsigned) Cfg_DEFAULT_COLUMNS); CommentsLength ? UsrDat->Comments :
UsrDat->UsrCod = DB_QueryINSERTandReturnCode_new ("can not create user"); "",
(unsigned) Mnu_MENU_DEFAULT,
(unsigned) Cfg_DEFAULT_COLUMNS);
/* Insert user's IDs as confirmed */ /* Insert user's IDs as confirmed */
for (NumID = 0; for (NumID = 0;

View File

@ -1710,18 +1710,19 @@ void Agd_RecFormEvent (void)
static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt) static void Agd_CreateEvent (struct AgendaEvent *AgdEvent,const char *Txt)
{ {
/***** Create a new event *****/ /***** Create a new event *****/
DB_BuildQuery ("INSERT INTO agendas" AgdEvent->AgdCod =
" (UsrCod,StartTime,EndTime,Event,Location,Txt)" DB_QueryINSERTandReturnCode ("can not create new event",
" VALUES" "INSERT INTO agendas"
" (%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld)," " (UsrCod,StartTime,EndTime,Event,Location,Txt)"
"'%s','%s','%s')", " VALUES"
AgdEvent->UsrCod, " (%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
AgdEvent->TimeUTC[Agd_START_TIME], "'%s','%s','%s')",
AgdEvent->TimeUTC[Agd_END_TIME ], AgdEvent->UsrCod,
AgdEvent->Event, AgdEvent->TimeUTC[Agd_START_TIME],
AgdEvent->Location, AgdEvent->TimeUTC[Agd_END_TIME ],
Txt); AgdEvent->Event,
AgdEvent->AgdCod = DB_QueryINSERTandReturnCode_new ("can not create new event"); AgdEvent->Location,
Txt);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1495,19 +1495,20 @@ static void Asg_UpdateNumUsrsNotifiedByEMailAboutAssignment (long AsgCod,unsigne
static void Asg_CreateAssignment (struct Assignment *Asg,const char *Txt) static void Asg_CreateAssignment (struct Assignment *Asg,const char *Txt)
{ {
/***** Create a new assignment *****/ /***** Create a new assignment *****/
DB_BuildQuery ("INSERT INTO assignments" Asg->AsgCod =
" (CrsCod,UsrCod,StartTime,EndTime,Title,Folder,Txt)" DB_QueryINSERTandReturnCode ("can not create new assignment",
" VALUES" "INSERT INTO assignments"
" (%ld,%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld)," " (CrsCod,UsrCod,StartTime,EndTime,Title,Folder,Txt)"
"'%s','%s','%s')", " VALUES"
Gbl.CurrentCrs.Crs.CrsCod, " (%ld,%ld,FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
Gbl.Usrs.Me.UsrDat.UsrCod, "'%s','%s','%s')",
Asg->TimeUTC[Dat_START_TIME], Gbl.CurrentCrs.Crs.CrsCod,
Asg->TimeUTC[Dat_END_TIME ], Gbl.Usrs.Me.UsrDat.UsrCod,
Asg->Title, Asg->TimeUTC[Dat_START_TIME],
Asg->Folder, Asg->TimeUTC[Dat_END_TIME ],
Txt); Asg->Title,
Asg->AsgCod = DB_QueryINSERTandReturnCode_new ("can not create new assignment"); Asg->Folder,
Txt);
/***** Create groups *****/ /***** Create groups *****/
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps) if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)

View File

@ -1355,23 +1355,24 @@ void Att_RecFormAttEvent (void)
void Att_CreateAttEvent (struct AttendanceEvent *Att,const char *Txt) void Att_CreateAttEvent (struct AttendanceEvent *Att,const char *Txt)
{ {
/***** Create a new attendance event *****/ /***** Create a new attendance event *****/
DB_BuildQuery ("INSERT INTO att_events" Att->AttCod =
" (CrsCod,Hidden,UsrCod," DB_QueryINSERTandReturnCode ("can not create new attendance event",
"StartTime,EndTime,CommentTchVisible,Title,Txt)" "INSERT INTO att_events"
" VALUES" " (CrsCod,Hidden,UsrCod,"
" (%ld,'%c',%ld," "StartTime,EndTime,CommentTchVisible,Title,Txt)"
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),'%c','%s','%s')", " VALUES"
Gbl.CurrentCrs.Crs.CrsCod, " (%ld,'%c',%ld,"
Att->Hidden ? 'Y' : "FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),'%c','%s','%s')",
'N', Gbl.CurrentCrs.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod, Att->Hidden ? 'Y' :
Att->TimeUTC[Att_START_TIME], 'N',
Att->TimeUTC[Att_END_TIME ], Gbl.Usrs.Me.UsrDat.UsrCod,
Att->CommentTchVisible ? 'Y' : Att->TimeUTC[Att_START_TIME],
'N', Att->TimeUTC[Att_END_TIME ],
Att->Title, Att->CommentTchVisible ? 'Y' :
Txt); 'N',
Att->AttCod = DB_QueryINSERTandReturnCode_new ("can not create new attendance event"); Att->Title,
Txt);
/***** Create groups *****/ /***** Create groups *****/
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps) if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)

View File

@ -2816,20 +2816,21 @@ static void Ctr_CreateCentre (unsigned Status)
extern const char *Txt_Created_new_centre_X; extern const char *Txt_Created_new_centre_X;
/***** Create a new centre *****/ /***** Create a new centre *****/
DB_BuildQuery ("INSERT INTO centres" Gbl.Ctrs.EditingCtr.CtrCod =
" (InsCod,PlcCod,Status,RequesterUsrCod," DB_QueryINSERTandReturnCode ("can not create a new centre",
"ShortName,FullName,WWW,PhotoAttribution)" "INSERT INTO centres"
" VALUES" " (InsCod,PlcCod,Status,RequesterUsrCod,"
" (%ld,%ld,%u,%ld," "ShortName,FullName,WWW,PhotoAttribution)"
"'%s','%s','%s','')", " VALUES"
Gbl.Ctrs.EditingCtr.InsCod, " (%ld,%ld,%u,%ld,"
Gbl.Ctrs.EditingCtr.PlcCod, "'%s','%s','%s','')",
Status, Gbl.Ctrs.EditingCtr.InsCod,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Ctrs.EditingCtr.PlcCod,
Gbl.Ctrs.EditingCtr.ShrtName, Status,
Gbl.Ctrs.EditingCtr.FullName, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Ctrs.EditingCtr.WWW); Gbl.Ctrs.EditingCtr.ShrtName,
Gbl.Ctrs.EditingCtr.CtrCod = DB_QueryINSERTandReturnCode_new ("can not create a new centre"); Gbl.Ctrs.EditingCtr.FullName,
Gbl.Ctrs.EditingCtr.WWW);
/***** Write message to show the change made /***** Write message to show the change made
and put button to go to centre created *****/ and put button to go to centre created *****/

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf 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 CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js" #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.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.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) 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; extern const char *Txt_Created_new_course_X;
/***** Insert new course into pending requests *****/ /***** Insert new course into pending requests *****/
DB_BuildQuery ("INSERT INTO courses" Gbl.Degs.EditingCrs.CrsCod =
" (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,ShortName,FullName)" DB_QueryINSERTandReturnCode ("can not create a new course",
" VALUES" "INSERT INTO courses"
" (%ld,%u,'%s',%u,%ld,'%s','%s')", " (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,"
Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year, "ShortName,FullName)"
Gbl.Degs.EditingCrs.InstitutionalCrsCod, " VALUES"
Status, " (%ld,%u,'%s',%u,%ld,"
Gbl.Usrs.Me.UsrDat.UsrCod, "'%s','%s')",
Gbl.Degs.EditingCrs.ShrtName,Gbl.Degs.EditingCrs.FullName); Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year,
Gbl.Degs.EditingCrs.CrsCod = DB_QueryINSERTandReturnCode_new ("can not create a new course"); Gbl.Degs.EditingCrs.InstitutionalCrsCod,
Status,
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Degs.EditingCrs.ShrtName,
Gbl.Degs.EditingCrs.FullName);
/***** Create success message *****/ /***** Create success message *****/
Gbl.Alert.Type = Ale_SUCCESS; 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 ***/ /** 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; 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 /***** Check that query string pointer
does point to an allocated string *****/ does point to an allocated string *****/
if (Gbl.DB.QueryPtr == NULL) if (Query == NULL)
Lay_ShowErrorAndExit ("Wrong query string."); Lay_ShowErrorAndExit ("Wrong query string.");
/***** Query database and free query string pointer *****/ /***** Query database and free query string pointer *****/
Result = mysql_query (&Gbl.mysql,Gbl.DB.QueryPtr); // Returns 0 on success Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Gbl.DB.QueryPtr); free ((void *) Query);
Gbl.DB.QueryPtr = NULL; Query = NULL;
if (Result) if (Result)
DB_ExitOnMySQLError (MsgError); 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 (const char *MsgError,const char *fmt,...);
void DB_QueryINSERT_old (char **Query,const char *MsgError); 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,...); void DB_QueryREPLACE (const char *MsgError,const char *fmt,...);

View File

@ -1144,17 +1144,18 @@ static void Deg_CreateDegree (unsigned Status)
extern const char *Txt_Created_new_degree_X; extern const char *Txt_Created_new_degree_X;
/***** Create a new degree *****/ /***** Create a new degree *****/
DB_BuildQuery ("INSERT INTO degrees (CtrCod,DegTypCod,Status," Gbl.Degs.EditingDeg.DegCod =
"RequesterUsrCod,ShortName,FullName,WWW)" DB_QueryINSERTandReturnCode ("can not create a new degree",
" VALUES (%ld,%ld,%u,%ld,'%s','%s','%s')", "INSERT INTO degrees (CtrCod,DegTypCod,Status,"
Gbl.Degs.EditingDeg.CtrCod, "RequesterUsrCod,ShortName,FullName,WWW)"
Gbl.Degs.EditingDeg.DegTypCod, " VALUES (%ld,%ld,%u,%ld,'%s','%s','%s')",
Status, Gbl.Degs.EditingDeg.CtrCod,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.Degs.EditingDeg.DegTypCod,
Gbl.Degs.EditingDeg.ShrtName, Status,
Gbl.Degs.EditingDeg.FullName, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Degs.EditingDeg.WWW); Gbl.Degs.EditingDeg.ShrtName,
Gbl.Degs.EditingDeg.DegCod = DB_QueryINSERTandReturnCode_new ("can not create a new degree"); Gbl.Degs.EditingDeg.FullName,
Gbl.Degs.EditingDeg.WWW);
/***** Write message to show the change made /***** Write message to show the change made
and put button to go to degree created *****/ 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"); DB_QueryUPDATE_new ("can not update enrolment request");
} }
else // No request in database for this user in this course else // No request in database for this user in this course
{ ReqCod =
DB_BuildQuery ("INSERT INTO crs_usr_requests" DB_QueryINSERTandReturnCode ("can not save enrolment request",
" (CrsCod,UsrCod,Role,RequestTime)" "INSERT INTO crs_usr_requests"
" VALUES" " (CrsCod,UsrCod,Role,RequestTime)"
" (%ld,%ld,%u,NOW())", " VALUES"
Gbl.CurrentCrs.Crs.CrsCod, " (%ld,%ld,%u,NOW())",
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.CurrentCrs.Crs.CrsCod,
(unsigned) RoleFromForm); Gbl.Usrs.Me.UsrDat.UsrCod,
ReqCod = DB_QueryINSERTandReturnCode_new ("can not save enrolment request"); (unsigned) RoleFromForm);
}
/***** Show confirmation message *****/ /***** Show confirmation message *****/
snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt), snprintf (Gbl.Alert.Txt,sizeof (Gbl.Alert.Txt),

View File

@ -734,34 +734,35 @@ static long Exa_AddExamAnnouncementToDB (void)
long ExaCod; long ExaCod;
/***** Add exam announcement *****/ /***** Add exam announcement *****/
DB_BuildQuery ("INSERT INTO exam_announcements " ExaCod =
"(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession," DB_QueryINSERTandReturnCode ("can not create a new exam announcement",
"CallDate,ExamDate,Duration," "INSERT INTO exam_announcements "
"Place,ExamMode,Structure,DocRequired,MatRequired,MatAllowed,OtherInfo)" "(CrsCod,Status,NumNotif,CrsFullName,Year,ExamSession,"
" VALUES " "CallDate,ExamDate,Duration,"
"(%ld,%u,0,'%s',%u,'%s'," "Place,ExamMode,Structure,DocRequired,MatRequired,MatAllowed,OtherInfo)"
"NOW(),'%04u-%02u-%02u %02u:%02u:00','%02u:%02u:00','%s'," " VALUES "
"'%s','%s','%s','%s','%s','%s')", "(%ld,%u,0,'%s',%u,'%s',"
Gbl.CurrentCrs.Crs.CrsCod, "NOW(),'%04u-%02u-%02u %02u:%02u:00','%02u:%02u:00','%s',"
(unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT, "'%s','%s','%s','%s','%s','%s')",
Gbl.ExamAnns.ExaDat.CrsFullName, Gbl.CurrentCrs.Crs.CrsCod,
Gbl.ExamAnns.ExaDat.Year, (unsigned) Exa_VISIBLE_EXAM_ANNOUNCEMENT,
Gbl.ExamAnns.ExaDat.Session, Gbl.ExamAnns.ExaDat.CrsFullName,
Gbl.ExamAnns.ExaDat.ExamDate.Year, Gbl.ExamAnns.ExaDat.Year,
Gbl.ExamAnns.ExaDat.ExamDate.Month, Gbl.ExamAnns.ExaDat.Session,
Gbl.ExamAnns.ExaDat.ExamDate.Day, Gbl.ExamAnns.ExaDat.ExamDate.Year,
Gbl.ExamAnns.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.ExamDate.Month,
Gbl.ExamAnns.ExaDat.StartTime.Minute, Gbl.ExamAnns.ExaDat.ExamDate.Day,
Gbl.ExamAnns.ExaDat.Duration.Hour, Gbl.ExamAnns.ExaDat.StartTime.Hour,
Gbl.ExamAnns.ExaDat.Duration.Minute, Gbl.ExamAnns.ExaDat.StartTime.Minute,
Gbl.ExamAnns.ExaDat.Place, Gbl.ExamAnns.ExaDat.Duration.Hour,
Gbl.ExamAnns.ExaDat.Mode, Gbl.ExamAnns.ExaDat.Duration.Minute,
Gbl.ExamAnns.ExaDat.Structure, Gbl.ExamAnns.ExaDat.Place,
Gbl.ExamAnns.ExaDat.DocRequired, Gbl.ExamAnns.ExaDat.Mode,
Gbl.ExamAnns.ExaDat.MatRequired, Gbl.ExamAnns.ExaDat.Structure,
Gbl.ExamAnns.ExaDat.MatAllowed, Gbl.ExamAnns.ExaDat.DocRequired,
Gbl.ExamAnns.ExaDat.OtherInfo); Gbl.ExamAnns.ExaDat.MatRequired,
ExaCod = DB_QueryINSERTandReturnCode_new ("can not create a new exam announcement"); Gbl.ExamAnns.ExaDat.MatAllowed,
Gbl.ExamAnns.ExaDat.OtherInfo);
return ExaCod; return ExaCod;
} }

View File

@ -11831,21 +11831,22 @@ long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType,
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
/***** Add path to the database *****/ /***** Add path to the database *****/
DB_BuildQuery ("INSERT INTO files" return
" (FileBrowser,Cod,ZoneUsrCod," DB_QueryINSERTandReturnCode ("can not add path to database",
"PublisherUsrCod,FileType,Path,Hidden,Public,License)" "INSERT INTO files"
" VALUES" " (FileBrowser,Cod,ZoneUsrCod,"
" (%u,%ld,%ld," "PublisherUsrCod,FileType,Path,Hidden,Public,License)"
"%ld,%u,'%s','N','%c',%u)", " VALUES"
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type], " (%u,%ld,%ld,"
Cod,ZoneUsrCod, "%ld,%u,'%s','N','%c',%u)",
PublisherUsrCod, (unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
(unsigned) FileType, Cod,ZoneUsrCod,
FullPathInTree, PublisherUsrCod,
IsPublic ? 'Y' : (unsigned) FileType,
'N', FullPathInTree,
(unsigned) License); IsPublic ? 'Y' :
return DB_QueryINSERTandReturnCode_new ("can not add path to database"); 'N',
(unsigned) License);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -3314,30 +3314,31 @@ static void Prj_CreateProject (struct Project *Prj)
Prj->ModifTime = Gbl.StartExecutionTimeUTC; Prj->ModifTime = Gbl.StartExecutionTimeUTC;
/***** Create a new project *****/ /***** Create a new project *****/
DB_BuildQuery ("INSERT INTO projects" Prj->PrjCod =
" (CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal," DB_QueryINSERTandReturnCode ("can not create new project",
"CreatTime,ModifTime," "INSERT INTO projects"
"Title,Description,Knowledge,Materials,URL)" " (CrsCod,DptCod,Hidden,Preassigned,NumStds,Proposal,"
" VALUES" "CreatTime,ModifTime,"
" (%ld,%ld,'%c','%c',%u,'%s'," "Title,Description,Knowledge,Materials,URL)"
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld)," " VALUES"
"'%s','%s','%s','%s','%s')", " (%ld,%ld,'%c','%c',%u,'%s',"
Gbl.CurrentCrs.Crs.CrsCod, "FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
Prj->DptCod, "'%s','%s','%s','%s','%s')",
Prj->Hidden == Prj_HIDDEN ? 'Y' : Gbl.CurrentCrs.Crs.CrsCod,
'N', Prj->DptCod,
Prj->Preassigned == Prj_PREASSIGNED ? 'Y' : Prj->Hidden == Prj_HIDDEN ? 'Y' :
'N', 'N',
Prj->NumStds, Prj->Preassigned == Prj_PREASSIGNED ? 'Y' :
Prj_Proposal_DB[Prj->Proposal], 'N',
Prj->CreatTime, Prj->NumStds,
Prj->ModifTime, Prj_Proposal_DB[Prj->Proposal],
Prj->Title, Prj->CreatTime,
Prj->Description, Prj->ModifTime,
Prj->Knowledge, Prj->Title,
Prj->Materials, Prj->Description,
Prj->URL); Prj->Knowledge,
Prj->PrjCod = DB_QueryINSERTandReturnCode_new ("can not create new project"); Prj->Materials,
Prj->URL);
/***** Insert creator as first tutor *****/ /***** Insert creator as first tutor *****/
DB_QueryINSERT ("can not add 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 *****/ /***** Store social note *****/
DB_BuildQuery ("INSERT INTO social_notes" SocPub->NotCod =
" (NoteType,Cod,UsrCod,HieCod,Unavailable,TimeNote)" DB_QueryINSERTandReturnCode ("can not create new social note",
" VALUES" "INSERT INTO social_notes"
" (%u,%ld,%ld,%ld,'N',NOW())", " (NoteType,Cod,UsrCod,HieCod,Unavailable,TimeNote)"
(unsigned) NoteType,Cod,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod); " VALUES"
SocPub->NotCod = DB_QueryINSERTandReturnCode_new ("can not create new social note"); " (%u,%ld,%ld,%ld,'N',NOW())",
(unsigned) NoteType,
Cod,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod);
/***** Publish social note in timeline *****/ /***** Publish social note in timeline *****/
SocPub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; SocPub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod;
@ -2122,14 +2124,15 @@ void Soc_MarkSocialNotesChildrenOfFolderAsUnavailable (const char *Path)
static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub) static void Soc_PublishSocialNoteInTimeline (struct SocialPublishing *SocPub)
{ {
/***** Publish social note in timeline *****/ /***** Publish social note in timeline *****/
DB_BuildQuery ("INSERT INTO social_pubs" SocPub->PubCod =
" (NotCod,PublisherCod,PubType,TimePublish)" DB_QueryINSERTandReturnCode ("can not publish social note",
" VALUES" "INSERT INTO social_pubs"
" (%ld,%ld,%u,NOW())", " (NotCod,PublisherCod,PubType,TimePublish)"
SocPub->NotCod, " VALUES"
SocPub->PublisherCod, " (%ld,%ld,%u,NOW())",
(unsigned) SocPub->PubType); SocPub->NotCod,
SocPub->PubCod = DB_QueryINSERTandReturnCode_new ("can not publish social note"); SocPub->PublisherCod,
(unsigned) SocPub->PubType);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -2300,17 +2303,18 @@ static long Soc_ReceiveSocialPost (void)
/***** Publish *****/ /***** Publish *****/
/* Insert post content in the database */ /* Insert post content in the database */
DB_BuildQuery ("INSERT INTO social_posts" PstCod =
" (Content,ImageName,ImageTitle,ImageURL)" DB_QueryINSERTandReturnCode ("can not create post",
" VALUES" "INSERT INTO social_posts"
" ('%s','%s','%s','%s')", " (Content,ImageName,ImageTitle,ImageURL)"
Content, " VALUES"
Image.Name, " ('%s','%s','%s','%s')",
(Image.Name[0] && // Save image title only if image attached Content,
Image.Title) ? Image.Title : "", Image.Name,
(Image.Name[0] && // Save image URL only if image attached (Image.Name[0] && // Save image title only if image attached
Image.URL ) ? Image.URL : ""); Image.Title) ? Image.Title : "",
PstCod = DB_QueryINSERTandReturnCode_new ("can not create post"); (Image.Name[0] && // Save image URL only if image attached
Image.URL ) ? Image.URL : "");
/* Insert post in social notes */ /* Insert post in social notes */
Soc_StoreAndPublishSocialNote (Soc_NOTE_SOCIAL_POST,PstCod,&SocPub); Soc_StoreAndPublishSocialNote (Soc_NOTE_SOCIAL_POST,PstCod,&SocPub);

View File

@ -293,24 +293,25 @@ void Sta_LogAccess (const char *Comments)
/***** Insert access into database *****/ /***** Insert access into database *****/
/* Log access in historical log (log_full) */ /* Log access in historical log (log_full) */
DB_BuildQuery ("INSERT INTO log_full " LogCod =
"(ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod," DB_QueryINSERTandReturnCode ("can not log access (full)",
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)" "INSERT INTO log_full "
" VALUES " "(ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"(%ld,%ld,%ld,%ld,%ld,%ld,%ld," "Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
"%u,NOW(),%ld,%ld,'%s')", " VALUES "
ActCod, "(%ld,%ld,%ld,%ld,%ld,%ld,%ld,"
Gbl.CurrentCty.Cty.CtyCod, "%u,NOW(),%ld,%ld,'%s')",
Gbl.CurrentIns.Ins.InsCod, ActCod,
Gbl.CurrentCtr.Ctr.CtrCod, Gbl.CurrentCty.Cty.CtyCod,
Gbl.CurrentDeg.Deg.DegCod, Gbl.CurrentIns.Ins.InsCod,
Gbl.CurrentCrs.Crs.CrsCod, Gbl.CurrentCtr.Ctr.CtrCod,
Gbl.Usrs.Me.UsrDat.UsrCod, Gbl.CurrentDeg.Deg.DegCod,
(unsigned) RoleToStore, Gbl.CurrentCrs.Crs.CrsCod,
Gbl.TimeGenerationInMicroseconds, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.TimeSendInMicroseconds, (unsigned) RoleToStore,
Gbl.IP); Gbl.TimeGenerationInMicroseconds,
LogCod = DB_QueryINSERTandReturnCode_new ("can not log access (full)"); Gbl.TimeSendInMicroseconds,
Gbl.IP);
/* Log access in recent log (log_recent) */ /* Log access in recent log (log_recent) */
DB_QueryINSERT ("can not log access (recent)", DB_QueryINSERT ("can not log access (recent)",

View File

@ -2253,20 +2253,21 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
extern const char *Txt_Created_new_survey_X; extern const char *Txt_Created_new_survey_X;
/***** Create a new survey *****/ /***** Create a new survey *****/
DB_BuildQuery ("INSERT INTO surveys" Svy->SvyCod =
" (Scope,Cod,Hidden,Roles,UsrCod,StartTime,EndTime,Title,Txt)" DB_QueryINSERTandReturnCode ("can not create new survey",
" VALUES" "INSERT INTO surveys"
" ('%s',%ld,'N',%u,%ld," " (Scope,Cod,Hidden,Roles,UsrCod,StartTime,EndTime,Title,Txt)"
"FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld)," " VALUES"
"'%s','%s')", " ('%s',%ld,'N',%u,%ld,"
Sco_ScopeDB[Svy->Scope],Svy->Cod, "FROM_UNIXTIME(%ld),FROM_UNIXTIME(%ld),"
Svy->Roles, "'%s','%s')",
Gbl.Usrs.Me.UsrDat.UsrCod, Sco_ScopeDB[Svy->Scope],Svy->Cod,
Svy->TimeUTC[Svy_START_TIME], Svy->Roles,
Svy->TimeUTC[Svy_END_TIME ], Gbl.Usrs.Me.UsrDat.UsrCod,
Svy->Title, Svy->TimeUTC[Svy_START_TIME],
Txt); Svy->TimeUTC[Svy_END_TIME ],
Svy->SvyCod = DB_QueryINSERTandReturnCode_new ("can not create new survey"); Svy->Title,
Txt);
/***** Create groups *****/ /***** Create groups *****/
if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps) if (Gbl.CurrentCrs.Grps.LstGrpsSel.NumGrps)
@ -3022,13 +3023,14 @@ void Svy_ReceiveQst (void)
SvyQst.QstInd = Svy_GetNextQuestionIndexInSvy (SvyCod); SvyQst.QstInd = Svy_GetNextQuestionIndexInSvy (SvyCod);
/* Insert question in the table of questions */ /* Insert question in the table of questions */
DB_BuildQuery ("INSERT INTO svy_questions" SvyQst.QstCod =
" (SvyCod,QstInd,AnsType,Stem)" DB_QueryINSERTandReturnCode ("can not create question",
" VALUES" "INSERT INTO svy_questions"
" (%ld,%u,'%s','%s')", " (SvyCod,QstInd,AnsType,Stem)"
SvyCod,SvyQst.QstInd, " VALUES"
Svy_StrAnswerTypesDB[SvyQst.AnswerType],Txt); " (%ld,%u,'%s','%s')",
SvyQst.QstCod = DB_QueryINSERTandReturnCode_new ("can not create question"); SvyCod,SvyQst.QstInd,
Svy_StrAnswerTypesDB[SvyQst.AnswerType],Txt);
} }
else // It's an existing 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) static long Tst_CreateNewTag (long CrsCod,const char *TagTxt)
{ {
/***** Insert new tag into tst_tags table *****/ /***** Insert new tag into tst_tags table *****/
DB_BuildQuery ("INSERT INTO tst_tags" return
" (CrsCod,ChangeTime,TagTxt,TagHidden)" DB_QueryINSERTandReturnCode ("can not create new tag",
" VALUES" "INSERT INTO tst_tags"
" (%ld,NOW(),'%s','N')", " (CrsCod,ChangeTime,TagTxt,TagHidden)"
CrsCod,TagTxt); " VALUES"
return DB_QueryINSERTandReturnCode_new ("can not create new tag"); " (%ld,NOW(),'%s','N')",
CrsCod,TagTxt);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -6541,24 +6542,25 @@ static void Tst_InsertOrUpdateQstIntoDB (void)
if (Gbl.Test.QstCod < 0) // It's a new question if (Gbl.Test.QstCod < 0) // It's a new question
{ {
/***** Insert question in the table of questions *****/ /***** Insert question in the table of questions *****/
DB_BuildQuery ("INSERT INTO tst_questions" Gbl.Test.QstCod =
" (CrsCod,EditTime,AnsType,Shuffle," DB_QueryINSERTandReturnCode ("can not create question",
"Stem,Feedback,ImageName,ImageTitle,ImageURL," "INSERT INTO tst_questions"
"NumHits,Score)" " (CrsCod,EditTime,AnsType,Shuffle,"
" VALUES" "Stem,Feedback,ImageName,ImageTitle,ImageURL,"
" (%ld,NOW(),'%s','%c'," "NumHits,Score)"
"'%s','%s','%s','%s','%s'," " VALUES"
"0,0)", " (%ld,NOW(),'%s','%c',"
Gbl.CurrentCrs.Crs.CrsCod, "'%s','%s','%s','%s','%s',"
Tst_StrAnswerTypesDB[Gbl.Test.AnswerType], "0,0)",
Gbl.Test.Shuffle ? 'Y' : Gbl.CurrentCrs.Crs.CrsCod,
'N', Tst_StrAnswerTypesDB[Gbl.Test.AnswerType],
Gbl.Test.Stem.Text, Gbl.Test.Shuffle ? 'Y' :
Gbl.Test.Feedback.Text ? Gbl.Test.Feedback.Text : "", 'N',
Gbl.Test.Image.Name, Gbl.Test.Stem.Text,
Gbl.Test.Image.Title ? Gbl.Test.Image.Title : "", Gbl.Test.Feedback.Text ? Gbl.Test.Feedback.Text : "",
Gbl.Test.Image.URL ? Gbl.Test.Image.URL : ""); Gbl.Test.Image.Name,
Gbl.Test.QstCod = DB_QueryINSERTandReturnCode_new ("can not create question"); Gbl.Test.Image.Title ? Gbl.Test.Image.Title : "",
Gbl.Test.Image.URL ? Gbl.Test.Image.URL : "");
/* Update image status */ /* Update image status */
if (Gbl.Test.Image.Name[0]) if (Gbl.Test.Image.Name[0])
@ -7593,16 +7595,17 @@ void Tst_SelDatesToSeeMyTestResults (void)
static long Tst_CreateTestResultInDB (void) static long Tst_CreateTestResultInDB (void)
{ {
/***** Insert new test result into table *****/ /***** Insert new test result into table *****/
DB_BuildQuery ("INSERT INTO tst_exams" return
" (CrsCod,UsrCod,AllowTeachers,TstTime,NumQsts)" DB_QueryINSERTandReturnCode ("can not create new test result",
" VALUES" "INSERT INTO tst_exams"
" (%ld,%ld,'%c',NOW(),%u)", " (CrsCod,UsrCod,AllowTeachers,TstTime,NumQsts)"
Gbl.CurrentCrs.Crs.CrsCod, " VALUES"
Gbl.Usrs.Me.UsrDat.UsrCod, " (%ld,%ld,'%c',NOW(),%u)",
Gbl.Test.AllowTeachers ? 'Y' : Gbl.CurrentCrs.Crs.CrsCod,
'N', Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Test.NumQsts); Gbl.Test.AllowTeachers ? 'Y' :
return DB_QueryINSERTandReturnCode_new ("can not create new test result"); 'N',
Gbl.Test.NumQsts);
} }
/*****************************************************************************/ /*****************************************************************************/

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 if (!MsgAlreadyInserted) // The message is inserted only once in the table of messages sent
{ {
/***** Insert message subject and body in the database *****/ /***** Insert message subject and body in the database *****/
/* Build query */
DB_BuildQuery ("INSERT INTO msg_content"
" (Subject,Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
" ('%s','%s','','','')",
Subject,Content);
/* Get the code of the inserted item */ /* Get the code of the inserted item */
NewMsgCod = DB_QueryINSERTandReturnCode_new ("can not create message"); NewMsgCod =
DB_QueryINSERTandReturnCode ("can not create message",
"INSERT INTO msg_content"
" (Subject,Content,ImageName,ImageTitle,ImageURL)"
" VALUES"
" ('%s','%s','','','')",
Subject,Content);
/***** Insert message in sent messages *****/ /* Insert message in sent messages */
DB_QueryINSERT ("can not create message", DB_QueryINSERT ("can not create message",
"INSERT INTO msg_snt" "INSERT INTO msg_snt"
" (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)" " (MsgCod,CrsCod,UsrCod,Expanded,CreatTime)"
@ -3528,16 +3528,15 @@ int swad__sendNotice (struct soap *soap,
"Requester must be a teacher"); "Requester must be a teacher");
/***** Insert notice in the database *****/ /***** Insert notice in the database *****/
/* Build query */
DB_BuildQuery ("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 */ /* Get the code of the inserted item */
NotCod = DB_QueryINSERTandReturnCode_new ("can not create message"); 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);
/***** Create notifications *****/ /***** Create notifications *****/
// TODO: create notifications // TODO: create notifications