Version 15.175.6

This commit is contained in:
Antonio Cañas Vargas 2016-04-03 18:51:48 +02:00
parent 81b92b9d4a
commit ee6164e39c
4 changed files with 40 additions and 48 deletions

View File

@ -140,14 +140,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.175.5 (2016-04-03)" #define Log_PLATFORM_VERSION "SWAD 15.175.6 (2016-04-03)"
#define CSS_FILE "swad15.173.1.css" #define CSS_FILE "swad15.173.1.css"
#define JS_FILE "swad15.131.3.js" #define JS_FILE "swad15.131.3.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 15.175.6: Apr 03, 2016 Remove image associated to a test question. (? lines) Version 15.175.6: Apr 03, 2016 Remove image associated to a test question. (197926 lines)
Version 15.175.5: Apr 03, 2016 Changes in reception of form to edit one test question. (197930 lines) Version 15.175.5: Apr 03, 2016 Changes in reception of form to edit one test question. (197930 lines)
Version 15.175.4: Apr 03, 2016 Changes in form to edit one test question. (197897 lines) Version 15.175.4: Apr 03, 2016 Changes in form to edit one test question. (197897 lines)
Version 15.175.3: Apr 03, 2016 Change in edition of test question. (197804 lines) Version 15.175.3: Apr 03, 2016 Change in edition of test question. (197804 lines)

View File

@ -154,8 +154,6 @@ void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality)
Gbl.Test.Image,PtrExtension); Gbl.Test.Image,PtrExtension);
if (Fil_EndReceptionOfFile (FileNameImgOrig,Param)) // Success if (Fil_EndReceptionOfFile (FileNameImgOrig,Param)) // Success
{ {
Gbl.Image.Status = Img_FILE_RECEIVED;
/***** Convert original image to temporary JPEG processed file *****/ /***** Convert original image to temporary JPEG processed file *****/
sprintf (FileNameImgTmp,"%s/%s/%s/%s.jpg", sprintf (FileNameImgTmp,"%s/%s/%s/%s.jpg",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP, Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,

View File

@ -38,7 +38,7 @@
No image Original file Temporary Definitive Name of the image No image Original file Temporary Definitive Name of the image
uploaded uploaded by user processed image processed image stored in database uploaded uploaded by user processed image processed image stored in database
--------- --------------------------- ------------------ ------------------ --------------------- --------- --------------------------- ------------------ ------------------ ---------------------
Img_NONE Img_FILE_RECEIVED Img_FILE_PROCESSED Img_FILE_MOVED Img_NAME_STORED_IN_DB Img_NONE Img_NONE Img_FILE_PROCESSED Img_FILE_MOVED Img_NAME_STORED_IN_DB
--------- --------------------------- ------------------ ------------------ --------------------- --------- --------------------------- ------------------ ------------------ ---------------------
-> upload-file -> -> process-file -> b -> move-file -> -> insert-name -> -> upload-file -> -> process-file -> b -> move-file -> -> insert-name ->
--------- --------------------------- ------------------ ------------------ --------------------- --------- --------------------------- ------------------ ------------------ ---------------------
@ -61,7 +61,6 @@ xx-unique-name: a unique name encrypted starting by two random chars xx
typedef enum typedef enum
{ {
Img_NONE, Img_NONE,
Img_FILE_RECEIVED,
Img_FILE_PROCESSED, Img_FILE_PROCESSED,
Img_FILE_MOVED, Img_FILE_MOVED,
Img_NAME_STORED_IN_DB, Img_NAME_STORED_IN_DB,

View File

@ -4804,10 +4804,23 @@ void Tst_ReceiveQst (void)
/***** Make sure that tags, text and answer are not empty *****/ /***** Make sure that tags, text and answer are not empty *****/
if (Tst_CheckIfQstFormatIsCorrectAndCountNumOptions ()) if (Tst_CheckIfQstFormatIsCorrectAndCountNumOptions ())
{ {
/***** Form is received OK ==> insert or update question and answer in the database *****/ switch (Gbl.Image.Status)
if (Gbl.Image.Status == Img_FILE_PROCESSED) {
/* Move processed image to definitive directory */ case Img_NONE:
Img_MoveImageToDefinitiveDirectory (); case Img_FILE_PROCESSED:
case Img_FILE_MOVED:
/* Remove possible file with the old image
(the new image file is already processed
and moved to the definitive directory) */
Tst_RemoveImageFilesFromQstsInCrs (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod);
if (Gbl.Image.Status == Img_FILE_PROCESSED) // A new image has been received and processed
/* Move processed image to definitive directory */
Img_MoveImageToDefinitiveDirectory ();
break;
case Img_NAME_STORED_IN_DB: // Keep image unchanged
break;
}
/* Insert or update question, tags and answer in the database */ /* Insert or update question, tags and answer in the database */
Tst_InsertOrUpdateQstTagsAnsIntoDB (); Tst_InsertOrUpdateQstTagsAnsIntoDB ();
@ -4884,9 +4897,10 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
switch (ImageAction) switch (ImageAction)
{ {
case Img_ACTION_NONE: // Do not use image (remove current image if exists) case Img_ACTION_NONE: // Do not use image (remove current image if exists)
/***** Reset image name *****/
// TODO: Remove image Gbl.Test.Image[0] = '\0';
Gbl.Image.Status = Img_NONE;
break;
case Img_ACTION_KEEP: // Keep current image unchanged case Img_ACTION_KEEP: // Keep current image unchanged
/***** Get image from database *****/ /***** Get image from database *****/
Tst_GetImageNameFromDB (); Tst_GetImageNameFromDB ();
@ -4894,7 +4908,7 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
Img_NONE); Img_NONE);
break; break;
case Img_ACTION_CHANGE: // Upload new image (remove current image if exists) case Img_ACTION_CHANGE: // Upload new image (remove current image if exists)
/***** Get new image (if present ==> create file) *****/ /***** Get new image (if present ==> process and create temporary file) *****/
Img_GetImageFromForm (Tst_PHOTO_SAVED_MAX_WIDTH, Img_GetImageFromForm (Tst_PHOTO_SAVED_MAX_WIDTH,
Tst_PHOTO_SAVED_MAX_HEIGHT, Tst_PHOTO_SAVED_MAX_HEIGHT,
Tst_PHOTO_SAVED_QUALITY); Tst_PHOTO_SAVED_QUALITY);
@ -5474,41 +5488,22 @@ static void Tst_InsertOrUpdateQstIntoDB (void)
else // It's an existing question else // It's an existing question
{ {
/***** Update existing question *****/ /***** Update existing question *****/
if (Gbl.Image.Status == Img_FILE_MOVED) /* Update question in database */
{ sprintf (Query,"UPDATE tst_questions"
/* Remove possible file with the old image " SET EditTime=NOW(),AnsType='%s',Shuffle='%c',"
(the new image file is already processed "Stem='%s',Image='%s',Feedback='%s'"
and moved to the definitive directory) */ " WHERE QstCod='%ld' AND CrsCod='%ld'",
Tst_RemoveImageFilesFromQstsInCrs (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod); Tst_StrAnswerTypesDB[Gbl.Test.AnswerType],
Gbl.Test.Shuffle ? 'Y' :
'N',
Gbl.Test.Stem.Text,
Gbl.Test.Image,
Gbl.Test.Feedback.Text ? Gbl.Test.Feedback.Text : "",
Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod);
/* Update question in database */ /* Update image status */
sprintf (Query,"UPDATE tst_questions" if (Gbl.Test.Image[0])
" SET EditTime=NOW(),AnsType='%s',Shuffle='%c'," Gbl.Image.Status = Img_NAME_STORED_IN_DB;
"Stem='%s',Image='%s',Feedback='%s'"
" WHERE QstCod='%ld' AND CrsCod='%ld'",
Tst_StrAnswerTypesDB[Gbl.Test.AnswerType],
Gbl.Test.Shuffle ? 'Y' :
'N',
Gbl.Test.Stem.Text,
Gbl.Test.Image,
Gbl.Test.Feedback.Text ? Gbl.Test.Feedback.Text : "",
Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod);
/* Update image status */
if (Gbl.Test.Image[0])
Gbl.Image.Status = Img_NAME_STORED_IN_DB;
}
else // Do not change image
sprintf (Query,"UPDATE tst_questions"
" SET EditTime=NOW(),AnsType='%s',Shuffle='%c',"
"Stem='%s',Feedback='%s'"
" WHERE QstCod='%ld' AND CrsCod='%ld'",
Tst_StrAnswerTypesDB[Gbl.Test.AnswerType],
Gbl.Test.Shuffle ? 'Y' :
'N',
Gbl.Test.Stem.Text,
Gbl.Test.Feedback.Text ? Gbl.Test.Feedback.Text : "",
Gbl.Test.QstCod,Gbl.CurrentCrs.Crs.CrsCod);
DB_QueryUPDATE (Query,"can not update question"); DB_QueryUPDATE (Query,"can not update question");
/* Remove answers and tags from this test question */ /* Remove answers and tags from this test question */