Version 15.175.7

This commit is contained in:
Antonio Cañas Vargas 2016-04-04 01:02:41 +02:00
parent ee6164e39c
commit 42b7ba6655
4 changed files with 24 additions and 30 deletions

View File

@ -140,13 +140,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.175.6 (2016-04-03)" #define Log_PLATFORM_VERSION "SWAD 15.175.7 (2016-04-04)"
#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.7: Apr 03, 2016 Code refactoring related to 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.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)

View File

@ -721,6 +721,7 @@ struct Globals
} Stat; } Stat;
struct struct
{ {
Img_Action_t Action;
Img_Status_t Status; Img_Status_t Status;
} Image; } Image;
}; };

View File

@ -70,9 +70,9 @@ typedef enum
#define Img_NUM_ACTIONS 3 #define Img_NUM_ACTIONS 3
typedef enum typedef enum
{ {
Img_ACTION_NONE, // Do not use image (remove current image if exists) Img_ACTION_NO_IMAGE, // Do not use image (remove current image if exists)
Img_ACTION_KEEP, // Keep current image unchanged Img_ACTION_KEEP_IMAGE, // Keep current image unchanged
Img_ACTION_CHANGE, // Upload new image (remove current image if exists) Img_ACTION_CHANGE_IMAGE, // Upload new image (remove current image if exists)
} Img_Action_t; } Img_Action_t;
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1037,7 +1037,7 @@ static void Tst_PutFormToEditQstImage (void)
/***** No image *****/ /***** No image *****/
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"ImgAct\" value=\"%u\"", fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"ImgAct\" value=\"%u\"",
Img_ACTION_NONE); Img_ACTION_NO_IMAGE);
if (!Gbl.Test.Image[0]) if (!Gbl.Test.Image[0])
fprintf (Gbl.F.Out," checked=\"checked\""); fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," />" fprintf (Gbl.F.Out," />"
@ -1054,7 +1054,7 @@ static void Tst_PutFormToEditQstImage (void)
"<label class=\"%s\">" "<label class=\"%s\">"
"%s" "%s"
"</label><br />", "</label><br />",
Img_ACTION_KEEP, Img_ACTION_KEEP_IMAGE,
The_ClassForm[Gbl.Prefs.Theme], The_ClassForm[Gbl.Prefs.Theme],
Txt_Current_image); Txt_Current_image);
Img_ShowImage (Gbl.Test.Image,"TEST_IMG_EDIT_ONE"); Img_ShowImage (Gbl.Test.Image,"TEST_IMG_EDIT_ONE");
@ -1062,7 +1062,7 @@ static void Tst_PutFormToEditQstImage (void)
/***** New image *****/ /***** New image *****/
fprintf (Gbl.F.Out,"<input id=\"change_image\" type=\"radio\" name=\"ImgAct\" value=\"%u\">", fprintf (Gbl.F.Out,"<input id=\"change_image\" type=\"radio\" name=\"ImgAct\" value=\"%u\">",
Img_ACTION_CHANGE); Img_ACTION_CHANGE_IMAGE);
fprintf (Gbl.F.Out,"<label class=\"%s\">" fprintf (Gbl.F.Out,"<label class=\"%s\">"
"%s: " "%s: "
"</label>", "</label>",
@ -4804,25 +4804,18 @@ 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 ())
{ {
switch (Gbl.Image.Status) if (Gbl.Image.Action != Img_ACTION_KEEP_IMAGE) // Don't keep the current image
{ /* Remove possible file with the old image
case Img_NONE: (the new image file is already processed
case Img_FILE_PROCESSED: and moved to the definitive directory) */
case Img_FILE_MOVED: Tst_RemoveImageFilesFromQstsInCrs (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod);
/* 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 if (Gbl.Image.Action == Img_ACTION_CHANGE_IMAGE && // Upload new image (remove current image if exists)
/* Move processed image to definitive directory */ Gbl.Image.Status == Img_FILE_PROCESSED) // The new image received has been processed
Img_MoveImageToDefinitiveDirectory (); /* Move processed image to definitive directory */
break; Img_MoveImageToDefinitiveDirectory ();
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 ();
/***** Show the question just inserted in the database *****/ /***** Show the question just inserted in the database *****/
@ -4843,7 +4836,6 @@ void Tst_ReceiveQst (void)
static void Tst_GetQstFromForm (char *Stem,char *Feedback) static void Tst_GetQstFromForm (char *Stem,char *Feedback)
{ {
char UnsignedStr[10+1]; char UnsignedStr[10+1];
Img_Action_t ImageAction;
char YN[1+1]; char YN[1+1];
unsigned NumTag; unsigned NumTag;
unsigned NumTagRead; unsigned NumTagRead;
@ -4893,21 +4885,21 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
Par_GetParToHTML ("Feedback",Feedback,Cns_MAX_BYTES_TEXT); Par_GetParToHTML ("Feedback",Feedback,Cns_MAX_BYTES_TEXT);
/***** Get type of image *****/ /***** Get type of image *****/
ImageAction = Img_GetImageActionFromForm (); Gbl.Image.Action = Img_GetImageActionFromForm ();
switch (ImageAction) switch (Gbl.Image.Action)
{ {
case Img_ACTION_NONE: // Do not use image (remove current image if exists) case Img_ACTION_NO_IMAGE: // Do not use image (remove current image if exists)
/***** Reset image name *****/ /***** Reset image name *****/
Gbl.Test.Image[0] = '\0'; Gbl.Test.Image[0] = '\0';
Gbl.Image.Status = Img_NONE; Gbl.Image.Status = Img_NONE;
break; break;
case Img_ACTION_KEEP: // Keep current image unchanged case Img_ACTION_KEEP_IMAGE: // Keep current image unchanged
/***** Get image from database *****/ /***** Get image from database *****/
Tst_GetImageNameFromDB (); Tst_GetImageNameFromDB ();
Gbl.Image.Status = (Gbl.Test.Image[0] ? Img_NAME_STORED_IN_DB : Gbl.Image.Status = (Gbl.Test.Image[0] ? Img_NAME_STORED_IN_DB :
Img_NONE); Img_NONE);
break; break;
case Img_ACTION_CHANGE: // Upload new image (remove current image if exists) case Img_ACTION_CHANGE_IMAGE: // Upload new image (remove current image if exists)
/***** Get new image (if present ==> process and create temporary 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,