Version 15.175.5

This commit is contained in:
Antonio Cañas Vargas 2016-04-03 17:49:09 +02:00
parent 77f1f65c62
commit 81b92b9d4a
4 changed files with 55 additions and 15 deletions

View File

@ -140,13 +140,15 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.175.4 (2016-04-03)"
#define Log_PLATFORM_VERSION "SWAD 15.175.5 (2016-04-03)"
#define CSS_FILE "swad15.173.1.css"
#define JS_FILE "swad15.131.3.js"
// 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
/*
Version 15.175.6: Apr 03, 2016 Remove image associated to a test question. (? 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.3: Apr 03, 2016 Change in edition of test question. (197804 lines)
Version 15.175.2: Apr 03, 2016 Code refactoring related to deleting image file. (197773 lines)

View File

@ -68,7 +68,24 @@ static void Img_ProcessImage (const char *FileNameImgOriginal,
unsigned Width,unsigned Height,unsigned Quality);
/*****************************************************************************/
/****************** Get image of a test question from form *******************/
/************************* Get image action from form ************************/
/*****************************************************************************/
Img_Action_t Img_GetImageActionFromForm (void)
{
char UnsignedStr[10+1];
unsigned UnsignedNum;
Par_GetParToText ("ImgAct",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1)
Lay_ShowErrorAndExit ("Wrong action to perform on image.");
if (UnsignedNum >= Img_NUM_ACTIONS)
Lay_ShowErrorAndExit ("Wrong action to perform on image.");
return (Img_Action_t) UnsignedNum;
}
/*****************************************************************************/
/**************************** Get image from form ****************************/
/*****************************************************************************/
// Return true if image is created

View File

@ -68,6 +68,7 @@ typedef enum
} Img_Status_t;
/***** Action to perform when editing a form with an image *****/
#define Img_NUM_ACTIONS 3
typedef enum
{
Img_ACTION_NONE, // Do not use image (remove current image if exists)
@ -79,7 +80,9 @@ typedef enum
/***************************** Public prototypes *****************************/
/*****************************************************************************/
Img_Action_t Img_GetImageActionFromForm (void);
void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality);
void Img_MoveImageToDefinitiveDirectory (void);
void Img_ShowImage (const char *Image,const char *ClassImg);
void Img_RemoveImageFile (const char *ImageName);

View File

@ -1036,7 +1036,7 @@ static void Tst_PutFormToEditQstImage (void)
extern const char *Txt_New_image;
/***** No image *****/
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"Image\" value=\"%u\"",
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"ImgAct\" value=\"%u\"",
Img_ACTION_NONE);
if (!Gbl.Test.Image[0])
fprintf (Gbl.F.Out," checked=\"checked\"");
@ -1050,7 +1050,7 @@ static void Tst_PutFormToEditQstImage (void)
/***** Current image *****/
if (Gbl.Test.Image[0])
{
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"Image\" value=\"%u\" checked=\"checked\" />"
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"ImgAct\" value=\"%u\" checked=\"checked\" />"
"<label class=\"%s\">"
"%s"
"</label><br />",
@ -1061,7 +1061,7 @@ static void Tst_PutFormToEditQstImage (void)
}
/***** New image *****/
fprintf (Gbl.F.Out,"<input id=\"change_image\" type=\"radio\" name=\"Image\" value=\"%u\">",
fprintf (Gbl.F.Out,"<input id=\"change_image\" type=\"radio\" name=\"ImgAct\" value=\"%u\">",
Img_ACTION_CHANGE);
fprintf (Gbl.F.Out,"<label class=\"%s\">"
"%s: "
@ -4830,6 +4830,7 @@ void Tst_ReceiveQst (void)
static void Tst_GetQstFromForm (char *Stem,char *Feedback)
{
char UnsignedStr[10+1];
Img_Action_t ImageAction;
char YN[1+1];
unsigned NumTag;
unsigned NumTagRead;
@ -4878,17 +4879,34 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
/***** Get question feedback *****/
Par_GetParToHTML ("Feedback",Feedback,Cns_MAX_BYTES_TEXT);
/***** Get new image (if present ==> create file) *****/
Img_GetImageFromForm (Tst_PHOTO_SAVED_MAX_WIDTH,
Tst_PHOTO_SAVED_MAX_HEIGHT,
Tst_PHOTO_SAVED_QUALITY);
if (Gbl.Image.Status != Img_FILE_PROCESSED && // No new image received-processed successfully
Gbl.Test.QstCod > 0) // Question exists
/***** Get type of image *****/
ImageAction = Img_GetImageActionFromForm ();
switch (ImageAction)
{
/***** Get possible image from database *****/
Tst_GetImageNameFromDB ();
Gbl.Image.Status = (Gbl.Test.Image[0] ? Img_NAME_STORED_IN_DB :
Img_NONE);
case Img_ACTION_NONE: // Do not use image (remove current image if exists)
// TODO: Remove image
case Img_ACTION_KEEP: // Keep current image unchanged
/***** Get image from database *****/
Tst_GetImageNameFromDB ();
Gbl.Image.Status = (Gbl.Test.Image[0] ? Img_NAME_STORED_IN_DB :
Img_NONE);
break;
case Img_ACTION_CHANGE: // Upload new image (remove current image if exists)
/***** Get new image (if present ==> create file) *****/
Img_GetImageFromForm (Tst_PHOTO_SAVED_MAX_WIDTH,
Tst_PHOTO_SAVED_MAX_HEIGHT,
Tst_PHOTO_SAVED_QUALITY);
if (Gbl.Image.Status != Img_FILE_PROCESSED && // No new image received-processed successfully
Gbl.Test.QstCod > 0) // Question exists
{
/* Get possible image from database */
Tst_GetImageNameFromDB ();
Gbl.Image.Status = (Gbl.Test.Image[0] ? Img_NAME_STORED_IN_DB :
Img_NONE);
}
break;
}
/***** Get answers *****/