diff --git a/swad_changelog.h b/swad_changelog.h
index e797dff0a..8dd8cc345 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -140,14 +140,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 15.175.3 (2016-04-03)"
+#define Log_PLATFORM_VERSION "SWAD 15.175.4 (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.4: Apr 03, 2016 Check button to remove image when editing one test question. (? 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)
Version 15.175.1: Apr 03, 2016 Code refactoring related to deleting tests of a course. (197763 lines)
diff --git a/swad_image.h b/swad_image.h
index 05fa23b2f..e016a01cd 100644
--- a/swad_image.h
+++ b/swad_image.h
@@ -67,6 +67,14 @@ typedef enum
Img_NAME_STORED_IN_DB,
} Img_Status_t;
+/***** Action to perform when editing a form with an image *****/
+typedef enum
+ {
+ Img_ACTION_NONE, // Do not use image (remove current image if exists)
+ Img_ACTION_KEEP, // Keep current image unchanged
+ Img_ACTION_CHANGE, // Upload new image (remove current image if exists)
+ } Img_Action_t;
+
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
diff --git a/swad_test.c b/swad_test.c
index 72da122fb..77fa114b7 100644
--- a/swad_test.c
+++ b/swad_test.c
@@ -155,7 +155,7 @@ static void Tst_ShowTestQuestionsWhenSeeing (MYSQL_RES *mysql_res);
static void Tst_ShowTstResultAfterAssess (long TstCod,unsigned *NumQstsNotBlank,double *TotalScore);
static void Tst_WriteQstAndAnsExam (unsigned NumQst,long QstCod,MYSQL_ROW row,
double *ScoreThisQst,bool *AnswerIsNotBlank);
-static void Tst_PutFormToUploadNewQstImage (void);
+static void Tst_PutFormToEditQstImage (void);
static void Tst_UpdateScoreQst (long QstCod,float ScoreThisQst,bool AnswerIsNotBlank);
static void Tst_UpdateMyNumAccessTst (unsigned NumAccessesTst);
static void Tst_UpdateLastAccTst (void);
@@ -1027,21 +1027,51 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem)
/************* Put form to upload a new image for a test question ************/
/*****************************************************************************/
-static void Tst_PutFormToUploadNewQstImage (void)
+static void Tst_PutFormToEditQstImage (void)
{
extern const char *The_ClassForm[The_NUM_THEMES];
+ extern const char *Txt_No_image;
+ extern const char *Txt_Current_image;
extern const char *Txt_Change_image;
+ extern const char *Txt_New_image;
- /***** If an image exists, put label *****/
+ /***** No image *****/
+ fprintf (Gbl.F.Out,""
+ "
",
+ The_ClassForm[Gbl.Prefs.Theme],
+ Txt_No_image);
+
+ /***** Current image *****/
if (Gbl.Test.Image[0])
- fprintf (Gbl.F.Out,"",
- The_ClassForm[Gbl.Prefs.Theme],Txt_Change_image);
+ {
+ fprintf (Gbl.F.Out,""
+ "
",
+ Img_ACTION_KEEP,
+ The_ClassForm[Gbl.Prefs.Theme],
+ Txt_Current_image);
+ Img_ShowImage (Gbl.Test.Image,"TEST_IMG_EDIT_ONE");
+ }
- /****** Form field to upload a new image *****/
+ /***** New image *****/
+ fprintf (Gbl.F.Out,"",
+ Img_ACTION_CHANGE);
+ fprintf (Gbl.F.Out,"",
+ The_ClassForm[Gbl.Prefs.Theme],
+ Gbl.Test.Image[0] ? Txt_Change_image :
+ Txt_New_image);
fprintf (Gbl.F.Out,"",
+ " size=\"40\" maxlength=\"100\" value=\"\""
+ " onchange=\"document.getElementById('change_image').checked = true;\" />",
Fil_NAME_OF_PARAM_FILENAME_ORG);
}
@@ -4316,11 +4346,7 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
"