Version 16.155.25

This commit is contained in:
Antonio Cañas Vargas 2017-03-13 14:45:05 +01:00
parent e524c33078
commit 08b4a8e03d
4 changed files with 78 additions and 70 deletions

View File

@ -1017,7 +1017,7 @@ CREATE TABLE IF NOT EXISTS surveys (
UsrCod INT NOT NULL, UsrCod INT NOT NULL,
StartTime DATETIME NOT NULL, StartTime DATETIME NOT NULL,
EndTime DATETIME NOT NULL, EndTime DATETIME NOT NULL,
Title VARCHAR(255) NOT NULL, Title VARCHAR(2047) NOT NULL,
Txt TEXT NOT NULL, Txt TEXT NOT NULL,
UNIQUE INDEX(SvyCod), UNIQUE INDEX(SvyCod),
INDEX(Scope,Cod)); INDEX(Scope,Cod));

View File

@ -209,13 +209,17 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.155.24 (2017-03-13)" #define Log_PLATFORM_VERSION "SWAD 16.155.25 (2017-03-13)"
#define CSS_FILE "swad16.147.css" #define CSS_FILE "swad16.147.css"
#define JS_FILE "swad16.144.js" #define JS_FILE "swad16.144.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.155.25:Mar 13, 2017 Adjusting size of database fields. (216995 lines)
1 change necessary in database.
ALTER TABLE surveys CHANGE COLUMN Title Title VARCHAR(2047) NOT NULL;
Version 16.155.24:Mar 13, 2017 Adjusting size of database fields. (216988 lines) Version 16.155.24:Mar 13, 2017 Adjusting size of database fields. (216988 lines)
2 changes necessary in database: 2 changes necessary in database:
ALTER TABLE social_comments CHANGE COLUMN ImageTitle ImageTitle VARCHAR(2047) NOT NULL; ALTER TABLE social_comments CHANGE COLUMN ImageTitle ImageTitle VARCHAR(2047) NOT NULL;

View File

@ -202,7 +202,7 @@ mysql> DESCRIBE agendas;
"EndTime DATETIME NOT NULL," "EndTime DATETIME NOT NULL,"
"Event VARCHAR(2047) NOT NULL," // Agd_MAX_BYTES_EVENT "Event VARCHAR(2047) NOT NULL," // Agd_MAX_BYTES_EVENT
"Location VARCHAR(2047) NOT NULL," // Agd_MAX_BYTES_LOCATION "Location VARCHAR(2047) NOT NULL," // Agd_MAX_BYTES_LOCATION
"Txt TEXT NOT NULL," "Txt TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(AgdCod)," "UNIQUE INDEX(AgdCod),"
"INDEX(UsrCod,Public,Hidden))"); "INDEX(UsrCod,Public,Hidden))");
@ -2147,7 +2147,7 @@ mysql> DESCRIBE surveys;
| UsrCod | int(11) | NO | | NULL | | | UsrCod | int(11) | NO | | NULL | |
| StartTime | datetime | NO | | NULL | | | StartTime | datetime | NO | | NULL | |
| EndTime | datetime | NO | | NULL | | | EndTime | datetime | NO | | NULL | |
| Title | varchar(255) | NO | | NULL | | | Title | varchar(2047) | NO | | NULL | |
| Txt | text | NO | | NULL | | | Txt | text | NO | | NULL | |
+-----------+-------------------------------------------+------+-----+---------+----------------+ +-----------+-------------------------------------------+------+-----+---------+----------------+
13 rows in set (0,00 sec) 13 rows in set (0,00 sec)
@ -2162,8 +2162,8 @@ mysql> DESCRIBE surveys;
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
"StartTime DATETIME NOT NULL," "StartTime DATETIME NOT NULL,"
"EndTime DATETIME NOT NULL," "EndTime DATETIME NOT NULL,"
"Title VARCHAR(255) NOT NULL," "Title VARCHAR(2047) NOT NULL," // Svy_MAX_BYTES_SURVEY_TITLE
"Txt TEXT NOT NULL," "Txt TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(SvyCod)," "UNIQUE INDEX(SvyCod),"
"INDEX(Scope,Cod))"); "INDEX(Scope,Cod))");

View File

@ -1369,7 +1369,7 @@ void Svy_FreeListSurveys (void)
static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{ {
char Query[512]; char Query[128];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
@ -1405,7 +1405,7 @@ void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
char **ContentStr, char **ContentStr,
long SvyCod,bool GetContent) long SvyCod,bool GetContent)
{ {
char Query[512]; char Query[128];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
size_t Length; size_t Length;
@ -1544,7 +1544,8 @@ void Svy_RemoveSurvey (void)
Svy_RemoveAllTheGrpsAssociatedToAndSurvey (Svy.SvyCod); Svy_RemoveAllTheGrpsAssociatedToAndSurvey (Svy.SvyCod);
/***** Remove survey *****/ /***** Remove survey *****/
sprintf (Query,"DELETE FROM surveys WHERE SvyCod='%ld'",Svy.SvyCod); sprintf (Query,"DELETE FROM surveys WHERE SvyCod='%ld'",
Svy.SvyCod);
DB_QueryDELETE (Query,"can not remove survey"); DB_QueryDELETE (Query,"can not remove survey");
/***** Mark possible notifications as removed *****/ /***** Mark possible notifications as removed *****/
@ -1658,7 +1659,7 @@ void Svy_ResetSurvey (void)
void Svy_HideSurvey (void) void Svy_HideSurvey (void)
{ {
extern const char *Txt_Survey_X_is_now_hidden; extern const char *Txt_Survey_X_is_now_hidden;
char Query[512]; char Query[128];
struct Survey Svy; struct Survey Svy;
struct SurveyQuestion SvyQst; struct SurveyQuestion SvyQst;
@ -1692,7 +1693,7 @@ void Svy_HideSurvey (void)
void Svy_UnhideSurvey (void) void Svy_UnhideSurvey (void)
{ {
extern const char *Txt_Survey_X_is_now_visible; extern const char *Txt_Survey_X_is_now_visible;
char Query[512]; char Query[128];
struct Survey Svy; struct Survey Svy;
struct SurveyQuestion SvyQst; struct SurveyQuestion SvyQst;
@ -1726,7 +1727,7 @@ void Svy_UnhideSurvey (void)
static bool Svy_CheckIfSimilarSurveyExists (struct Survey *Svy) static bool Svy_CheckIfSimilarSurveyExists (struct Survey *Svy)
{ {
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
char Query[512]; char Query[512 + Svy_MAX_BYTES_SURVEY_TITLE];
/***** Get number of surveys with a field value from database *****/ /***** Get number of surveys with a field value from database *****/
sprintf (Query,"SELECT COUNT(*) FROM surveys" sprintf (Query,"SELECT COUNT(*) FROM surveys"
@ -2197,7 +2198,7 @@ void Svy_RecFormSurvey (void)
static void Svy_UpdateNumUsrsNotifiedByEMailAboutSurvey (long SvyCod, static void Svy_UpdateNumUsrsNotifiedByEMailAboutSurvey (long SvyCod,
unsigned NumUsrsToBeNotifiedByEMail) unsigned NumUsrsToBeNotifiedByEMail)
{ {
char Query[512]; char Query[256];
/***** Update number of users notified *****/ /***** Update number of users notified *****/
sprintf (Query,"UPDATE surveys SET NumNotif=NumNotif+'%u'" sprintf (Query,"UPDATE surveys SET NumNotif=NumNotif+'%u'"
@ -2214,7 +2215,9 @@ static void Svy_CreateSurvey (struct Survey *Svy,const char *Txt)
{ {
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
extern const char *Txt_Created_new_survey_X; extern const char *Txt_Created_new_survey_X;
char Query[1024 + Cns_MAX_BYTES_TEXT]; char Query[1024 +
Svy_MAX_BYTES_SURVEY_TITLE +
Cns_MAX_BYTES_TEXT];
/***** Create a new survey *****/ /***** Create a new survey *****/
sprintf (Query,"INSERT INTO surveys" sprintf (Query,"INSERT INTO surveys"
@ -2250,7 +2253,9 @@ static void Svy_UpdateSurvey (struct Survey *Svy,const char *Txt)
{ {
extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; extern const char *Sco_ScopeDB[Sco_NUM_SCOPES];
extern const char *Txt_The_survey_has_been_modified; extern const char *Txt_The_survey_has_been_modified;
char Query[1024 + Cns_MAX_BYTES_TEXT]; char Query[1024 +
Svy_MAX_BYTES_SURVEY_TITLE +
Cns_MAX_BYTES_TEXT];
/***** Update the data of the survey *****/ /***** Update the data of the survey *****/
sprintf (Query,"UPDATE surveys" sprintf (Query,"UPDATE surveys"
@ -2286,7 +2291,7 @@ static void Svy_UpdateSurvey (struct Survey *Svy,const char *Txt)
static bool Svy_CheckIfSvyIsAssociatedToGrps (long SvyCod) static bool Svy_CheckIfSvyIsAssociatedToGrps (long SvyCod)
{ {
char Query[256]; char Query[128];
/***** Get if a survey is associated to a group from database *****/ /***** Get if a survey is associated to a group from database *****/
sprintf (Query,"SELECT COUNT(*) FROM svy_grp WHERE SvyCod='%ld'", sprintf (Query,"SELECT COUNT(*) FROM svy_grp WHERE SvyCod='%ld'",
@ -2300,10 +2305,11 @@ static bool Svy_CheckIfSvyIsAssociatedToGrps (long SvyCod)
bool Svy_CheckIfSvyIsAssociatedToGrp (long SvyCod,long GrpCod) bool Svy_CheckIfSvyIsAssociatedToGrp (long SvyCod,long GrpCod)
{ {
char Query[512]; char Query[256];
/***** Get if a survey is associated to a group from database *****/ /***** Get if a survey is associated to a group from database *****/
sprintf (Query,"SELECT COUNT(*) FROM svy_grp WHERE SvyCod='%ld' AND GrpCod='%ld'", sprintf (Query,"SELECT COUNT(*) FROM svy_grp"
" WHERE SvyCod='%ld' AND GrpCod='%ld'",
SvyCod,GrpCod); SvyCod,GrpCod);
return (DB_QueryCOUNT (Query,"can not check if a survey is associated to a group") != 0); return (DB_QueryCOUNT (Query,"can not check if a survey is associated to a group") != 0);
} }
@ -2314,10 +2320,11 @@ bool Svy_CheckIfSvyIsAssociatedToGrp (long SvyCod,long GrpCod)
static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod) static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod)
{ {
char Query[256]; char Query[128];
/***** Remove groups of the survey *****/ /***** Remove groups of the survey *****/
sprintf (Query,"DELETE FROM svy_grp WHERE SvyCod='%ld'",SvyCod); sprintf (Query,"DELETE FROM svy_grp WHERE SvyCod='%ld'",
SvyCod);
DB_QueryDELETE (Query,"can not remove the groups associated to a survey"); DB_QueryDELETE (Query,"can not remove the groups associated to a survey");
} }
@ -2327,11 +2334,10 @@ static void Svy_RemoveAllTheGrpsAssociatedToAndSurvey (long SvyCod)
void Svy_RemoveGroup (long GrpCod) void Svy_RemoveGroup (long GrpCod)
{ {
char Query[256]; char Query[128];
/***** Remove group from all the surveys *****/ /***** Remove group from all the surveys *****/
sprintf (Query,"DELETE FROM svy_grp" sprintf (Query,"DELETE FROM svy_grp WHERE GrpCod='%ld'",
" WHERE GrpCod='%ld'",
GrpCod); GrpCod);
DB_QueryDELETE (Query,"can not remove group" DB_QueryDELETE (Query,"can not remove group"
" from the associations between surveys and groups"); " from the associations between surveys and groups");
@ -2522,7 +2528,7 @@ static bool Svy_CheckIfICanDoThisSurveyBasedOnGrps (long SvyCod)
static unsigned Svy_GetNumQstsSvy (long SvyCod) static unsigned Svy_GetNumQstsSvy (long SvyCod)
{ {
char Query[512]; char Query[128];
/***** Get data of questions from database *****/ /***** Get data of questions from database *****/
sprintf (Query,"SELECT COUNT(*) FROM svy_questions WHERE SvyCod='%ld'", sprintf (Query,"SELECT COUNT(*) FROM svy_questions WHERE SvyCod='%ld'",
@ -2579,7 +2585,7 @@ static void Svy_ShowFormEditOneQst (long SvyCod,struct SurveyQuestion *SvyQst,
extern const char *Txt_SURVEY_STR_ANSWER_TYPES[Svy_NUM_ANS_TYPES]; extern const char *Txt_SURVEY_STR_ANSWER_TYPES[Svy_NUM_ANS_TYPES];
extern const char *Txt_Save; extern const char *Txt_Save;
extern const char *Txt_Create_question; extern const char *Txt_Create_question;
char Query[512]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumAns; unsigned NumAns;
@ -2794,10 +2800,11 @@ static long Svy_GetParamQstCod (void)
static void Svy_RemAnswersOfAQuestion (long QstCod) static void Svy_RemAnswersOfAQuestion (long QstCod)
{ {
char Query[512]; char Query[128];
/***** Remove answers *****/ /***** Remove answers *****/
sprintf (Query,"DELETE FROM svy_answers WHERE QstCod='%ld'",QstCod); sprintf (Query,"DELETE FROM svy_answers WHERE QstCod='%ld'",
QstCod);
DB_QueryDELETE (Query,"can not remove the answers of a question"); DB_QueryDELETE (Query,"can not remove the answers of a question");
} }
@ -2824,7 +2831,7 @@ static Svy_AnswerType_t Svy_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTy
static bool Svy_CheckIfAnswerExists (long QstCod,unsigned AnsInd) static bool Svy_CheckIfAnswerExists (long QstCod,unsigned AnsInd)
{ {
char Query[512]; char Query[256];
/***** Get answers of a question from database *****/ /***** Get answers of a question from database *****/
sprintf (Query,"SELECT COUNT(*) FROM svy_answers" sprintf (Query,"SELECT COUNT(*) FROM svy_answers"
@ -2839,7 +2846,7 @@ static bool Svy_CheckIfAnswerExists (long QstCod,unsigned AnsInd)
static unsigned Svy_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res) static unsigned Svy_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res)
{ {
char Query[512]; char Query[256];
unsigned long NumRows; unsigned long NumRows;
/***** Get answers of a question from database *****/ /***** Get answers of a question from database *****/
@ -2909,7 +2916,7 @@ void Svy_ReceiveQst (void)
extern const char *Txt_You_must_type_at_least_the_first_two_answers; extern const char *Txt_You_must_type_at_least_the_first_two_answers;
extern const char *Txt_The_survey_has_been_modified; extern const char *Txt_The_survey_has_been_modified;
char Txt[Cns_MAX_BYTES_TEXT + 1]; char Txt[Cns_MAX_BYTES_TEXT + 1];
char Query[512 + Cns_MAX_BYTES_TEXT + 1]; char Query[512 + Cns_MAX_BYTES_TEXT];
long SvyCod; long SvyCod;
struct SurveyQuestion SvyQst; struct SurveyQuestion SvyQst;
unsigned NumAns; unsigned NumAns;
@ -3012,7 +3019,8 @@ void Svy_ReceiveQst (void)
/* Update question */ /* Update question */
sprintf (Query,"UPDATE svy_questions SET Stem='%s',AnsType='%s'" sprintf (Query,"UPDATE svy_questions SET Stem='%s',AnsType='%s'"
" WHERE QstCod='%ld' AND SvyCod='%ld'", " WHERE QstCod='%ld' AND SvyCod='%ld'",
Txt,Svy_StrAnswerTypesDB[SvyQst.AnswerType],SvyQst.QstCod,SvyCod); Txt,Svy_StrAnswerTypesDB[SvyQst.AnswerType],
SvyQst.QstCod,SvyCod);
DB_QueryUPDATE (Query,"can not update question"); DB_QueryUPDATE (Query,"can not update question");
} }
@ -3070,15 +3078,14 @@ void Svy_ReceiveQst (void)
static unsigned Svy_GetQstIndFromQstCod (long QstCod) static unsigned Svy_GetQstIndFromQstCod (long QstCod)
{ {
char Query[512]; char Query[128];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
unsigned QstInd = 0; unsigned QstInd = 0;
/***** Get number of surveys with a field value from database *****/ /***** Get number of surveys with a field value from database *****/
sprintf (Query,"SELECT QstInd FROM svy_questions" sprintf (Query,"SELECT QstInd FROM svy_questions WHERE QstCod='%ld'",
" WHERE QstCod='%ld'",
QstCod); QstCod);
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get question index"); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get question index");
@ -3110,8 +3117,7 @@ static unsigned Svy_GetNextQuestionIndexInSvy (long SvyCod)
unsigned QstInd = 0; unsigned QstInd = 0;
/***** Get number of surveys with a field value from database *****/ /***** Get number of surveys with a field value from database *****/
sprintf (Query,"SELECT MAX(QstInd) FROM svy_questions" sprintf (Query,"SELECT MAX(QstInd) FROM svy_questions WHERE SvyCod='%ld'",
" WHERE SvyCod='%ld'",
SvyCod); SvyCod);
DB_QuerySELECT (Query,&mysql_res,"can not get last question index"); DB_QuerySELECT (Query,&mysql_res,"can not get last question index");
@ -3145,7 +3151,7 @@ static void Svy_ListSvyQuestions (struct Survey *Svy,struct SurveyQuestion *SvyQ
extern const char *Txt_This_survey_has_no_questions; extern const char *Txt_This_survey_has_no_questions;
extern const char *Txt_Done; extern const char *Txt_Done;
extern const char *Txt_Edit_question; extern const char *Txt_Edit_question;
char Query[512]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumQsts; unsigned NumQsts;
@ -3571,8 +3577,7 @@ void Svy_RemoveQst (void)
Svy_RemAnswersOfAQuestion (SvyQst.QstCod); Svy_RemAnswersOfAQuestion (SvyQst.QstCod);
/* Remove the question itself */ /* Remove the question itself */
sprintf (Query,"DELETE FROM svy_questions" sprintf (Query,"DELETE FROM svy_questions WHERE QstCod='%ld'",
" WHERE QstCod='%ld'",
SvyQst.QstCod); SvyQst.QstCod);
DB_QueryDELETE (Query,"can not remove a question"); DB_QueryDELETE (Query,"can not remove a question");
if (!mysql_affected_rows (&Gbl.mysql)) if (!mysql_affected_rows (&Gbl.mysql))
@ -3630,7 +3635,7 @@ void Svy_ReceiveSurveyAnswers (void)
static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod) static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
{ {
char Query[512]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
unsigned NumQst; unsigned NumQst;
@ -3693,7 +3698,7 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
static void Svy_IncreaseAnswerInDB (long QstCod,unsigned AnsInd) static void Svy_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
{ {
char Query[512]; char Query[256];
/***** Increase number of users who have selected the answer AnsInd in the question QstCod *****/ /***** Increase number of users who have selected the answer AnsInd in the question QstCod *****/
sprintf (Query,"UPDATE svy_answers SET NumUsrs=NumUsrs+1" sprintf (Query,"UPDATE svy_answers SET NumUsrs=NumUsrs+1"
@ -3708,7 +3713,7 @@ static void Svy_IncreaseAnswerInDB (long QstCod,unsigned AnsInd)
static void Svy_RegisterIHaveAnsweredSvy (long SvyCod) static void Svy_RegisterIHaveAnsweredSvy (long SvyCod)
{ {
char Query[512]; char Query[256];
sprintf (Query,"INSERT INTO svy_users" sprintf (Query,"INSERT INTO svy_users"
" (SvyCod,UsrCod)" " (SvyCod,UsrCod)"
@ -3724,7 +3729,7 @@ static void Svy_RegisterIHaveAnsweredSvy (long SvyCod)
static bool Svy_CheckIfIHaveAnsweredSvy (long SvyCod) static bool Svy_CheckIfIHaveAnsweredSvy (long SvyCod)
{ {
char Query[512]; char Query[256];
/***** Get number of surveys with a field value from database *****/ /***** Get number of surveys with a field value from database *****/
sprintf (Query,"SELECT COUNT(*) FROM svy_users" sprintf (Query,"SELECT COUNT(*) FROM svy_users"
@ -3739,11 +3744,10 @@ static bool Svy_CheckIfIHaveAnsweredSvy (long SvyCod)
static unsigned Svy_GetNumUsrsWhoHaveAnsweredSvy (long SvyCod) static unsigned Svy_GetNumUsrsWhoHaveAnsweredSvy (long SvyCod)
{ {
char Query[512]; char Query[128];
/***** Get number of surveys with a field value from database *****/ /***** Get number of surveys with a field value from database *****/
sprintf (Query,"SELECT COUNT(*) FROM svy_users" sprintf (Query,"SELECT COUNT(*) FROM svy_users WHERE SvyCod='%ld'",
" WHERE SvyCod='%ld'",
SvyCod); SvyCod);
return (unsigned) DB_QueryCOUNT (Query,"can not get number of users who have answered a survey"); return (unsigned) DB_QueryCOUNT (Query,"can not get number of users who have answered a survey");
} }