Version 15.175.9

This commit is contained in:
Antonio Cañas Vargas 2016-04-04 03:00:12 +02:00
parent f00686f2cf
commit b157943f4e
7 changed files with 60 additions and 24 deletions

View File

@ -139,14 +139,16 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.175.7 (2016-04-04)"
#define Log_PLATFORM_VERSION "SWAD 15.175.9 (2016-04-04)"
#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.7: Apr 03, 2016 Code refactoring related to image associated to a test question.
Version 15.175.9: Apr 04, 2016 Fixed bug in edition of a test question. (197953 lines)
Version 15.175.8: Apr 04, 2016 Code refactoring related to receiving and processing image file. (197945 lines)
Version 15.175.7: Apr 04, 2016 Code refactoring related to image associated to a test question.
Fixed bug while exporting test questions. (197923 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)

View File

@ -432,7 +432,7 @@ void Gbl_InitializeGlobals (void)
/* Related to images uploaded in a form */
Gbl.Image.Action = Img_ACTION_NO_IMAGE;
Gbl.Image.Status = Img_NONE;
Gbl.Image.Status = Img_FILE_NONE;
Gbl.WebService.Function = Svc_unknown;
}

View File

@ -722,7 +722,7 @@ struct Globals
struct
{
Img_Action_t Action;
Img_Status_t Status;
Img_FileStatus_t Status;
} Image;
};

View File

@ -89,7 +89,7 @@ Img_Action_t Img_GetImageActionFromForm (void)
/*****************************************************************************/
// Return true if image is created
void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality)
void Img_GetAndProcessImageFromForm (unsigned Width,unsigned Height,unsigned Quality)
{
struct Param *Param;
char FileNameImgSrc[PATH_MAX+1];
@ -102,7 +102,7 @@ void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality)
bool WrongType = false;
/***** Reset image status *****/
Gbl.Image.Status = Img_NONE;
Gbl.Image.Status = Img_FILE_NONE;
/***** Get filename and MIME type *****/
Param = Fil_StartReceptionOfFile (FileNameImgSrc,MIMEType);
@ -111,16 +111,13 @@ void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality)
/* Get filename extension */
if ((PtrExtension = strrchr (FileNameImgSrc,(int) '.')) == NULL)
{
Lay_ShowAlert (Lay_WARNING,"El tipo de archivo no es correcto."); // TODO: Need translation!!!!
return;
} LengthExtension = strlen (PtrExtension);
LengthExtension = strlen (PtrExtension);
if (LengthExtension < Fil_MIN_LENGTH_FILE_EXTENSION ||
LengthExtension > Fil_MAX_LENGTH_FILE_EXTENSION)
{
Lay_ShowAlert (Lay_WARNING,"El tipo de archivo no es correcto."); // TODO: Need translation!!!!
return;
}
/* Check if the file type is image/ or application/octet-stream */
if (strncmp (MIMEType,"image/",strlen ("image/")))
if (strcmp (MIMEType,"application/octet-stream"))
@ -128,10 +125,7 @@ void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality)
if (strcmp (MIMEType,"application/octet"))
WrongType = true;
if (WrongType)
{
Lay_ShowAlert (Lay_WARNING,"El tipo de archivo no es correcto."); // TODO: Need translation!!!!
return;
}
/***** Assign a unique name for the image *****/
strcpy (Gbl.Test.Image,Gbl.UniqueNameEncrypted);
@ -154,6 +148,8 @@ void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality)
Gbl.Test.Image,PtrExtension);
if (Fil_EndReceptionOfFile (FileNameImgOrig,Param)) // Success
{
Gbl.Image.Status = Img_FILE_RECEIVED;
/***** Convert original image to temporary JPEG processed file *****/
sprintf (FileNameImgTmp,"%s/%s/%s/%s.jpg",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG,Cfg_FOLDER_IMG_TMP,

View File

@ -60,11 +60,12 @@ xx-unique-name: a unique name encrypted starting by two random chars xx
*/
typedef enum
{
Img_NONE,
Img_FILE_NONE,
Img_FILE_RECEIVED,
Img_FILE_PROCESSED,
Img_FILE_MOVED,
Img_NAME_STORED_IN_DB,
} Img_Status_t;
} Img_FileStatus_t;
/***** Action to perform when editing a form with an image *****/
#define Img_NUM_ACTIONS 3
@ -80,7 +81,7 @@ typedef enum
/*****************************************************************************/
Img_Action_t Img_GetImageActionFromForm (void);
void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality);
void Img_GetAndProcessImageFromForm (unsigned Width,unsigned Height,unsigned Quality);
void Img_MoveImageToDefinitiveDirectory (void);
void Img_ShowImage (const char *Image,const char *ClassImg);

View File

@ -4639,7 +4639,7 @@ static void Tst_GetQstDataFromDB (char *Stem,char *Feedback)
Gbl.Test.Image[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64] = '\0';
}
else
Gbl.Image.Status = Img_NONE;
Gbl.Image.Status = Img_FILE_NONE;
/* Get the feedback of the question from the database (row[4]) */
Feedback[0] = '\0';
@ -4745,7 +4745,7 @@ static void Tst_GetImageNameFromDB (void)
Gbl.Test.Image[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64] = '\0';
}
else // No image in this question
Gbl.Image.Status = Img_NONE;
Gbl.Image.Status = Img_FILE_NONE;
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
@ -4822,8 +4822,16 @@ void Tst_ReceiveQst (void)
Tst_ListOneQstToEdit ();
}
else // Question is wrong
{
/***** Whether an image has been received or not,
reset status and image *****/
Gbl.Image.Action = Img_ACTION_NO_IMAGE;
Gbl.Image.Status = Img_FILE_NONE;
Gbl.Test.Image[0] = '\0';
/***** Put form to edit question again *****/
Tst_PutFormEditOneQst (Stem,Feedback);
}
/***** Free answers *****/
Tst_FreeTextChoiceAnswers ();
@ -4891,17 +4899,17 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
case Img_ACTION_NO_IMAGE: // Do not use image (remove current image if exists)
/***** Reset image name *****/
Gbl.Test.Image[0] = '\0';
Gbl.Image.Status = Img_NONE;
Gbl.Image.Status = Img_FILE_NONE;
break;
case Img_ACTION_KEEP_IMAGE: // Keep current image unchanged
/***** Get image from database *****/
Tst_GetImageNameFromDB ();
Gbl.Image.Status = (Gbl.Test.Image[0] ? Img_NAME_STORED_IN_DB :
Img_NONE);
Img_FILE_NONE);
break;
case Img_ACTION_CHANGE_IMAGE: // Upload new image (remove current image if exists)
/***** Get new image (if present ==> process and create temporary file) *****/
Img_GetImageFromForm (Tst_PHOTO_SAVED_MAX_WIDTH,
Img_GetAndProcessImageFromForm (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
@ -4910,7 +4918,7 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
/* Get possible image from database */
Tst_GetImageNameFromDB ();
Gbl.Image.Status = (Gbl.Test.Image[0] ? Img_NAME_STORED_IN_DB :
Img_NONE);
Img_FILE_NONE);
}
break;
}
@ -5022,6 +5030,7 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (void)
{
extern const char *Txt_Error_receiving_or_processing_image;
extern const char *Txt_You_must_type_at_least_one_tag_for_the_question;
extern const char *Txt_You_must_type_the_stem_of_the_question;
extern const char *Txt_You_must_select_a_T_F_answer;
@ -5037,6 +5046,13 @@ bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (void)
bool ThereIsEndOfAnswers;
unsigned i;
if (Gbl.Image.Action == Img_ACTION_CHANGE_IMAGE &&
Gbl.Image.Status != Img_FILE_PROCESSED)
{
Lay_ShowAlert (Lay_WARNING,Txt_Error_receiving_or_processing_image);
return false;
}
/***** This function also counts the number of options. Initialize this number to 0. *****/
Gbl.Test.Answer.NumOptions = 0;

View File

@ -10376,6 +10376,27 @@ const char *Txt_Error_getting_data_from_a_recipient =
"Error getting data from a recipient."; // Necessita de tradução
#endif
const char *Txt_Error_receiving_or_processing_image =
#if L==1
"Error rebent o processant imatge.";
#elif L==2
"Fehler beim Empfangen oder Verarbeiten von Abbild.";
#elif L==3
"Error receiving or processing image.";
#elif L==4
"Error recibiendo o procesando imagen.";
#elif L==5
"Erreur de r&eacute;ception ou de traitement d'image.";
#elif L==6
"Error recibiendo o procesando imagen."; // Okoteve traducción
#elif L==7
"Errore durante la ricezione o la elaborazione delle immagini.";
#elif L==8
"B&lstrok;&aogon;d odbioru lub przetwarzania obrazu.";
#elif L==9
"Erro no recebimento ou processamento de imagem.";
#endif
const char *Txt_Event =
#if L==1
"Esdeveniment";