mirror of https://github.com/acanas/swad-core.git
Version 15.195
This commit is contained in:
parent
65671ee700
commit
4055391928
|
@ -137,13 +137,14 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.194.2 (2016-04-14)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.195 (2016-04-14)"
|
||||
#define CSS_FILE "swad15.193.css"
|
||||
#define JS_FILE "swad15.193.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.195: Apr 14, 2016 Code refactoring related to uploading images. (199355 lines)
|
||||
Version 15.194.2: Apr 14, 2016 Code refactoring related to uploading images. (199384 lines)
|
||||
Version 15.194.1: Apr 14, 2016 Code refactoring related to uploading images. (199391 lines)
|
||||
Version 15.194: Apr 14, 2016 Code refactoring related to uploading images. (199391 lines)
|
||||
|
|
12
swad_forum.c
12
swad_forum.c
|
@ -3779,7 +3779,6 @@ static void For_WriteFormForumPst (bool IsReply,long ThrCod,const char *Subject)
|
|||
extern const char *Txt_MSG_Subject;
|
||||
extern const char *Txt_MSG_Message;
|
||||
extern const char *Txt_Send_message;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
||||
/***** Start frame *****/
|
||||
Lay_StartRoundFrame (NULL,
|
||||
|
@ -3836,10 +3835,7 @@ static void For_WriteFormForumPst (bool IsReply,long ThrCod,const char *Subject)
|
|||
Lay_HelpPlainEditor ();
|
||||
|
||||
/***** Attached image (optional) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Img_PutImageUploader ("FOR_IMG_TIT",&ParamUploadImg);
|
||||
Img_PutImageUploader (-1,"FOR_IMG_TIT");
|
||||
|
||||
/***** Send button *****/
|
||||
Lay_PutCreateButton (Txt_Send_message);
|
||||
|
@ -3866,7 +3862,6 @@ void For_RecForumPst (void)
|
|||
struct SocialPublishing SocPub;
|
||||
char Content[Cns_MAX_BYTES_LONG_TEXT+1];
|
||||
struct Image Image;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
||||
/***** Get order type, degree and course of the forum *****/
|
||||
For_GetParamsForum ();
|
||||
|
@ -3902,13 +3897,10 @@ void For_RecForumPst (void)
|
|||
Img_ImageConstructor (&Image);
|
||||
|
||||
/***** Get attached image (action, file and title) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Image.Width = For_IMAGE_SAVED_MAX_WIDTH;
|
||||
Image.Height = For_IMAGE_SAVED_MAX_HEIGHT;
|
||||
Image.Quality = For_IMAGE_SAVED_QUALITY;
|
||||
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||
Img_GetImageFromForm (-1,&Image,NULL);
|
||||
|
||||
/***** Create a new message *****/
|
||||
if (PstIsAReply) // This post is a reply to another posts in the thread
|
||||
|
|
54
swad_image.c
54
swad_image.c
|
@ -155,14 +155,17 @@ void Img_GetImageNameAndTitleFromRow (const char *Name,const char *Title,
|
|||
/************ Draw input fields to upload an image inside a form *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Img_PutImageUploader (const char *ClassImgTit,
|
||||
struct ParamUploadImg *ParamUploadImg)
|
||||
void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTit)
|
||||
{
|
||||
extern const char *Txt_Image;
|
||||
extern const char *Txt_optional;
|
||||
extern const char *Txt_Image_title_attribution;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
char Id[Act_MAX_LENGTH_ID];
|
||||
|
||||
/***** Set names of parameters depending on number of image in form *****/
|
||||
Img_SetParamNames (&ParamUploadImg,NumImgInForm);
|
||||
|
||||
/***** Create unique id for this image uploader *****/
|
||||
Act_SetUniqueId (Id);
|
||||
|
||||
|
@ -170,7 +173,7 @@ void Img_PutImageUploader (const char *ClassImgTit,
|
|||
fprintf (Gbl.F.Out,"<div class=\"IMG_UPLOAD_CONTAINER\">");
|
||||
|
||||
/***** Action to perform on image *****/
|
||||
Par_PutHiddenParamUnsigned (ParamUploadImg->Action,(unsigned) Img_ACTION_NEW_IMAGE);
|
||||
Par_PutHiddenParamUnsigned (ParamUploadImg.Action,(unsigned) Img_ACTION_NEW_IMAGE);
|
||||
|
||||
/***** Image file *****/
|
||||
fprintf (Gbl.F.Out,"<label class=\"IMG_UPLOAD_BUTTON\">"
|
||||
|
@ -186,7 +189,7 @@ void Img_PutImageUploader (const char *ClassImgTit,
|
|||
"<br />",
|
||||
Gbl.Prefs.IconsURL,
|
||||
Txt_Image,Txt_Image,Txt_optional,
|
||||
ParamUploadImg->File,
|
||||
ParamUploadImg.File,
|
||||
Id,Id);
|
||||
|
||||
/***** Image title/attribution *****/
|
||||
|
@ -194,7 +197,7 @@ void Img_PutImageUploader (const char *ClassImgTit,
|
|||
" placeholder=\"%s (%s)…\""
|
||||
" class=\"%s\" maxlength=\"%u\" value=\"\""
|
||||
" style=\"display:none;\" />",
|
||||
Id,ParamUploadImg->Title,
|
||||
Id,ParamUploadImg.Title,
|
||||
Txt_Image_title_attribution,Txt_optional,
|
||||
ClassImgTit,Img_MAX_BYTES_TITLE);
|
||||
|
||||
|
@ -206,16 +209,19 @@ void Img_PutImageUploader (const char *ClassImgTit,
|
|||
/***************************** Get image from form ***************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
||||
void (*GetImageFromDB) (int NumOpt,struct Image *Image),
|
||||
struct ParamUploadImg *ParamUploadImg)
|
||||
void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
|
||||
void (*GetImageFromDB) (int NumImgInForm,struct Image *Image))
|
||||
{
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
char Title[Img_MAX_BYTES_TITLE+1];
|
||||
size_t Length;
|
||||
|
||||
/***** Set names of parameters depending on number of image in form *****/
|
||||
Img_SetParamNames (&ParamUploadImg,NumImgInForm);
|
||||
|
||||
/***** First, get action and initialize image
|
||||
(except title, that will be get after the image file) *****/
|
||||
Image->Action = Img_GetImageActionFromForm (ParamUploadImg->Action);
|
||||
Image->Action = Img_GetImageActionFromForm (ParamUploadImg.Action);
|
||||
Image->Status = Img_FILE_NONE;
|
||||
Image->Name[0] = '\0';
|
||||
|
||||
|
@ -224,7 +230,7 @@ void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
|||
{
|
||||
case Img_ACTION_NEW_IMAGE: // Upload new image
|
||||
/***** Get new image (if present ==> process and create temporary file) *****/
|
||||
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg->File);
|
||||
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg.File);
|
||||
if (Image->Status != Img_FILE_PROCESSED) // No new image received-processed successfully
|
||||
{
|
||||
/* Reset image name */
|
||||
|
@ -235,22 +241,22 @@ void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
|||
case Img_ACTION_KEEP_IMAGE: // Keep current image unchanged
|
||||
/***** Get image name *****/
|
||||
if (GetImageFromDB != NULL)
|
||||
GetImageFromDB (NumOpt,Image);
|
||||
GetImageFromDB (NumImgInForm,Image);
|
||||
break;
|
||||
case Img_ACTION_CHANGE_IMAGE: // Replace old image by new image
|
||||
/***** Get new image (if present ==> process and create temporary file) *****/
|
||||
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg->File);
|
||||
Img_GetAndProcessImageFileFromForm (Image,ParamUploadImg.File);
|
||||
if (Image->Status != Img_FILE_PROCESSED && // No new image received-processed successfully
|
||||
GetImageFromDB != NULL)
|
||||
/* Get image name */
|
||||
GetImageFromDB (NumOpt,Image);
|
||||
GetImageFromDB (NumImgInForm,Image);
|
||||
break;
|
||||
case Img_ACTION_NO_IMAGE: // Do not use image (remove current image if exists)
|
||||
break;
|
||||
}
|
||||
|
||||
/***** By last, get image title from form *****/
|
||||
Par_GetParToText (ParamUploadImg->Title,Title,Img_MAX_BYTES_TITLE);
|
||||
Par_GetParToText (ParamUploadImg.Title,Title,Img_MAX_BYTES_TITLE);
|
||||
/* If the title coming from the form is empty, keep current image title unchanged
|
||||
If not empty, copy it to current image title */
|
||||
if ((Length = strlen (Title)) > 0)
|
||||
|
@ -265,6 +271,26 @@ void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Set parameters names depending on number of image in form *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm)
|
||||
{
|
||||
if (NumImgInForm < 0) // One unique image in form ==> no suffix needed
|
||||
{
|
||||
strcpy (ParamUploadImg->Action,"ImgAct");
|
||||
strcpy (ParamUploadImg->File ,"ImgFil");
|
||||
strcpy (ParamUploadImg->Title ,"ImgTit");
|
||||
}
|
||||
else // Several images in form ==> add suffix
|
||||
{
|
||||
sprintf (ParamUploadImg->Action,"ImgAct%u",NumImgInForm);
|
||||
sprintf (ParamUploadImg->File ,"ImgFil%u",NumImgInForm);
|
||||
sprintf (ParamUploadImg->Title ,"ImgTit%u",NumImgInForm);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************* Get image action from form ************************/
|
||||
/*****************************************************************************/
|
||||
|
|
16
swad_image.h
16
swad_image.h
|
@ -94,11 +94,12 @@ struct Image
|
|||
unsigned Quality;
|
||||
};
|
||||
|
||||
/***** Parameters used in a form to upload an image *****/
|
||||
struct ParamUploadImg
|
||||
{
|
||||
char *Action;
|
||||
char *File;
|
||||
char *Title;
|
||||
char Action[16];
|
||||
char File[16];
|
||||
char Title[16];
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -113,11 +114,10 @@ void Img_FreeImageTitle (struct Image *Image);
|
|||
void Img_GetImageNameAndTitleFromRow (const char *Name,const char *Title,
|
||||
struct Image *Image);
|
||||
|
||||
void Img_PutImageUploader (const char *ClassImgTit,
|
||||
struct ParamUploadImg *ParamUploadImg);
|
||||
void Img_GetImageFromForm (int NumOpt,struct Image *Image,
|
||||
void (*GetImageFromDB) (int NumOpt,struct Image *Image),
|
||||
struct ParamUploadImg *ParamUploadImg);
|
||||
void Img_PutImageUploader (int NumImgInForm,const char *ClassImgTit);
|
||||
void Img_GetImageFromForm (int NumImgInForm,struct Image *Image,
|
||||
void (*GetImageFromDB) (int NumImgInForm,struct Image *Image));
|
||||
void Img_SetParamNames (struct ParamUploadImg *ParamUploadImg,int NumImgInForm);
|
||||
Img_Action_t Img_GetImageActionFromForm (const char *ParamAction);
|
||||
void Img_GetAndProcessImageFileFromForm (struct Image *Image,const char *ParamFile);
|
||||
|
||||
|
|
|
@ -285,7 +285,6 @@ static void Msg_PutFormMsgUsrs (const char *Content)
|
|||
extern const char *Txt_New_message;
|
||||
extern const char *Txt_MSG_To;
|
||||
extern const char *Txt_Send_message;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
char YN[1+1];
|
||||
|
||||
Gbl.Usrs.LstTchs.NumUsrs =
|
||||
|
@ -419,10 +418,7 @@ static void Msg_PutFormMsgUsrs (const char *Content)
|
|||
Lay_HelpPlainEditor ();
|
||||
|
||||
/***** Attached image (optional) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Img_PutImageUploader ("MSG_IMG_TIT",&ParamUploadImg);
|
||||
Img_PutImageUploader (-1,"MSG_IMG_TIT");
|
||||
|
||||
/***** Send button *****/
|
||||
Lay_PutCreateButton (Txt_Send_message);
|
||||
|
@ -710,7 +706,6 @@ void Msg_RecMsgFromUsr (void)
|
|||
bool NotifyByEmail;
|
||||
char Content[Cns_MAX_BYTES_LONG_TEXT+1];
|
||||
struct Image Image;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
bool Error = false;
|
||||
|
||||
/***** Get data from form *****/
|
||||
|
@ -777,13 +772,10 @@ void Msg_RecMsgFromUsr (void)
|
|||
Img_ImageConstructor (&Image);
|
||||
|
||||
/***** Get attached image (action, file and title) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Image.Width = Msg_IMAGE_SAVED_MAX_WIDTH;
|
||||
Image.Height = Msg_IMAGE_SAVED_MAX_HEIGHT;
|
||||
Image.Quality = Msg_IMAGE_SAVED_QUALITY;
|
||||
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||
Img_GetImageFromForm (-1,&Image,NULL);
|
||||
|
||||
/***** Loop over the list Gbl.Usrs.Select.All, that holds the list of the
|
||||
recipients, creating a received message for each recipient *****/
|
||||
|
|
|
@ -1997,7 +1997,6 @@ static void Soc_PutTextarea (const char *Placeholder,
|
|||
const char *ClassTextArea,const char *ClassImgTit)
|
||||
{
|
||||
extern const char *Txt_Post;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
char IdDivImgButton[Act_MAX_LENGTH_ID];
|
||||
|
||||
/***** Set unique id for the hidden div *****/
|
||||
|
@ -2021,10 +2020,7 @@ static void Soc_PutTextarea (const char *Placeholder,
|
|||
Lay_HelpPlainEditor ();
|
||||
|
||||
/***** Attached image (optional) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Img_PutImageUploader (ClassImgTit,&ParamUploadImg);
|
||||
Img_PutImageUploader (-1,ClassImgTit);
|
||||
|
||||
/***** Submit button *****/
|
||||
fprintf (Gbl.F.Out,"<button type=\"submit\""
|
||||
|
@ -2083,7 +2079,6 @@ static long Soc_ReceiveSocialPost (void)
|
|||
char *Query;
|
||||
long PstCod;
|
||||
struct SocialPublishing SocPub;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
||||
/***** Get the content of the new post *****/
|
||||
Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT,
|
||||
|
@ -2093,13 +2088,10 @@ static long Soc_ReceiveSocialPost (void)
|
|||
Img_ImageConstructor (&Image);
|
||||
|
||||
/***** Get attached image (action, file and title) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Image.Width = Soc_IMAGE_SAVED_MAX_WIDTH;
|
||||
Image.Height = Soc_IMAGE_SAVED_MAX_HEIGHT;
|
||||
Image.Quality = Soc_IMAGE_SAVED_QUALITY;
|
||||
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||
Img_GetImageFromForm (-1,&Image,NULL);
|
||||
|
||||
if (Content[0] || // Text not empty
|
||||
Image.Name[0]) // An image is attached
|
||||
|
@ -2836,7 +2828,6 @@ static long Soc_ReceiveComment (void)
|
|||
char *Query;
|
||||
struct SocialNote SocNot;
|
||||
struct SocialPublishing SocPub;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
||||
/***** Get data of social note *****/
|
||||
SocNot.NotCod = Soc_GetParamNotCod ();
|
||||
|
@ -2852,13 +2843,10 @@ static long Soc_ReceiveComment (void)
|
|||
Img_ImageConstructor (&Image);
|
||||
|
||||
/***** Get attached image (action, file and title) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Image.Width = Soc_IMAGE_SAVED_MAX_WIDTH;
|
||||
Image.Height = Soc_IMAGE_SAVED_MAX_HEIGHT;
|
||||
Image.Quality = Soc_IMAGE_SAVED_QUALITY;
|
||||
Img_GetImageFromForm (-1,&Image,NULL,&ParamUploadImg);
|
||||
Img_GetImageFromForm (-1,&Image,NULL);
|
||||
|
||||
if (Content[0] || // Text not empty
|
||||
Image.Name[0]) // An image is attached
|
||||
|
|
59
swad_test.c
59
swad_test.c
|
@ -154,10 +154,9 @@ 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_PutFormToEditQstImage (struct Image *Image,
|
||||
static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm,
|
||||
const char *ClassImg,
|
||||
const char *ClassImgTit,
|
||||
struct ParamUploadImg *ParamUploadImg,
|
||||
bool OptionsDisabled);
|
||||
static void Tst_UpdateScoreQst (long QstCod,float ScoreThisQst,bool AnswerIsNotBlank);
|
||||
static void Tst_UpdateMyNumAccessTst (unsigned NumAccessesTst);
|
||||
|
@ -1053,10 +1052,9 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem)
|
|||
/************* Put form to upload a new image for a test question ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Tst_PutFormToEditQstImage (struct Image *Image,
|
||||
static void Tst_PutFormToEditQstImage (struct Image *Image,int NumImgInForm,
|
||||
const char *ClassImg,
|
||||
const char *ClassImgTit,
|
||||
struct ParamUploadImg *ParamUploadImg,
|
||||
bool OptionsDisabled)
|
||||
{
|
||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||
|
@ -1066,15 +1064,19 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,
|
|||
extern const char *Txt_Image_title_attribution;
|
||||
extern const char *Txt_optional;
|
||||
static unsigned UniqueId = 0;
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
||||
if (Image->Name[0])
|
||||
{
|
||||
/***** Set names of parameters depending on number of image in form *****/
|
||||
Img_SetParamNames (&ParamUploadImg,NumImgInForm);
|
||||
|
||||
/***** Start container *****/
|
||||
fprintf (Gbl.F.Out,"<div class=\"TEST_IMG_EDIT_ONE_CONTAINER\">");
|
||||
|
||||
/***** Choice 1: No image *****/
|
||||
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"%s\" value=\"%u\"",
|
||||
ParamUploadImg->Action,Img_ACTION_NO_IMAGE);
|
||||
ParamUploadImg.Action,Img_ACTION_NO_IMAGE);
|
||||
if (OptionsDisabled)
|
||||
fprintf (Gbl.F.Out," disabled=\"disabled\"");
|
||||
fprintf (Gbl.F.Out," />"
|
||||
|
@ -1087,7 +1089,7 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,
|
|||
|
||||
/***** Choice 2: Current image *****/
|
||||
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"%s\" value=\"%u\" checked=\"checked\"",
|
||||
ParamUploadImg->Action,Img_ACTION_KEEP_IMAGE);
|
||||
ParamUploadImg.Action,Img_ACTION_KEEP_IMAGE);
|
||||
if (OptionsDisabled)
|
||||
fprintf (Gbl.F.Out," disabled=\"disabled\"");
|
||||
fprintf (Gbl.F.Out," />"
|
||||
|
@ -1102,7 +1104,7 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,
|
|||
UniqueId++;
|
||||
fprintf (Gbl.F.Out,"<input type=\"radio\" id=\"chg_img_%u\" name=\"%s\""
|
||||
" value=\"%u\"",
|
||||
UniqueId,ParamUploadImg->Action,Img_ACTION_CHANGE_IMAGE); // Replace existing image by new image
|
||||
UniqueId,ParamUploadImg.Action,Img_ACTION_CHANGE_IMAGE); // Replace existing image by new image
|
||||
if (OptionsDisabled)
|
||||
fprintf (Gbl.F.Out," disabled=\"disabled\"");
|
||||
fprintf (Gbl.F.Out," />"
|
||||
|
@ -1111,7 +1113,7 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,
|
|||
"</label>"
|
||||
"<input type=\"file\" name=\"%s\" accept=\"image/*\"",
|
||||
The_ClassForm[Gbl.Prefs.Theme],Txt_Change_image,
|
||||
ParamUploadImg->File);
|
||||
ParamUploadImg.File);
|
||||
if (OptionsDisabled)
|
||||
fprintf (Gbl.F.Out," disabled=\"disabled\"");
|
||||
fprintf (Gbl.F.Out," onchange=\"document.getElementById('chg_img_%u').checked = true;\" />",
|
||||
|
@ -1122,7 +1124,7 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,
|
|||
"<input type=\"text\" name=\"%s\""
|
||||
" placeholder=\"%s (%s)…\""
|
||||
" class=\"%s\" maxlength=\"%u\" value=\"%s\">",
|
||||
ParamUploadImg->Title,Txt_Image_title_attribution,Txt_optional,
|
||||
ParamUploadImg.Title,Txt_Image_title_attribution,Txt_optional,
|
||||
ClassImgTit,Img_MAX_BYTES_TITLE,Image->Title ? Image->Title : "");
|
||||
|
||||
/***** End container *****/
|
||||
|
@ -1130,7 +1132,7 @@ static void Tst_PutFormToEditQstImage (struct Image *Image,
|
|||
}
|
||||
else // No current image
|
||||
/***** Attached image (optional) *****/
|
||||
Img_PutImageUploader (ClassImgTit,ParamUploadImg);
|
||||
Img_PutImageUploader (NumImgInForm,ClassImgTit);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4361,10 +4363,6 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
|
|||
bool OptionsDisabled;
|
||||
bool AnswerHasContent;
|
||||
bool DisplayRightColumn;
|
||||
char ParamAction[32];
|
||||
char ParamFile[32];
|
||||
char ParamTitle[32];
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
||||
/***** Start frame *****/
|
||||
if (Gbl.Test.QstCod > 0) // The question already has assigned a code
|
||||
|
@ -4471,12 +4469,10 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
|
|||
The_ClassForm[Gbl.Prefs.Theme],
|
||||
Txt_Stem,
|
||||
Stem);
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Tst_PutFormToEditQstImage (&Gbl.Test.Image,"TEST_IMG_EDIT_ONE_STEM",
|
||||
Tst_PutFormToEditQstImage (&Gbl.Test.Image,-1,
|
||||
"TEST_IMG_EDIT_ONE_STEM",
|
||||
"STEM", // Title / attribution
|
||||
&ParamUploadImg,false);
|
||||
false);
|
||||
|
||||
/***** Feedback *****/
|
||||
fprintf (Gbl.F.Out,"<label class=\"%s\">"
|
||||
|
@ -4692,16 +4688,10 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback)
|
|||
fprintf (Gbl.F.Out,"</textarea>");
|
||||
|
||||
/* Image */
|
||||
sprintf (ParamAction,"ImgAct%u",NumOpt);
|
||||
sprintf (ParamFile ,"ImgFil%u",NumOpt);
|
||||
sprintf (ParamTitle ,"ImgTit%u",NumOpt);
|
||||
ParamUploadImg.Action = ParamAction;
|
||||
ParamUploadImg.File = ParamFile;
|
||||
ParamUploadImg.Title = ParamTitle;
|
||||
Tst_PutFormToEditQstImage (&Gbl.Test.Answer.Options[NumOpt].Image,
|
||||
(int) NumOpt,
|
||||
"TEST_IMG_EDIT_ONE_ANS",
|
||||
"ANS_STR", // Title / attribution
|
||||
&ParamUploadImg,
|
||||
OptionsDisabled);
|
||||
|
||||
/* Feedback */
|
||||
|
@ -5143,10 +5133,6 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
|
|||
char StrMultiAns[Tst_MAX_SIZE_ANSWERS_ONE_QST+1];
|
||||
const char *Ptr;
|
||||
unsigned NumCorrectAns;
|
||||
char ParamAction[32];
|
||||
char ParamFile[32];
|
||||
char ParamTitle[32];
|
||||
struct ParamUploadImg ParamUploadImg;
|
||||
|
||||
/***** Get question code *****/
|
||||
Gbl.Test.QstCod = Tst_GetQstCod ();
|
||||
|
@ -5186,13 +5172,10 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
|
|||
Par_GetParToHTML ("Feedback",Feedback,Cns_MAX_BYTES_TEXT);
|
||||
|
||||
/***** Get image associated to the stem (action, file and title) *****/
|
||||
ParamUploadImg.Action = "ImgAct";
|
||||
ParamUploadImg.File = "ImgFil";
|
||||
ParamUploadImg.Title = "ImgTit";
|
||||
Gbl.Test.Image.Width = Tst_IMAGE_SAVED_MAX_WIDTH;
|
||||
Gbl.Test.Image.Height = Tst_IMAGE_SAVED_MAX_HEIGHT;
|
||||
Gbl.Test.Image.Quality = Tst_IMAGE_SAVED_QUALITY;
|
||||
Img_GetImageFromForm (-1,&Gbl.Test.Image,Tst_GetImageFromDB,&ParamUploadImg);
|
||||
Img_GetImageFromForm (-1,&Gbl.Test.Image,Tst_GetImageFromDB);
|
||||
|
||||
/***** Get answers *****/
|
||||
Gbl.Test.Shuffle = false;
|
||||
|
@ -5245,17 +5228,11 @@ static void Tst_GetQstFromForm (char *Stem,char *Feedback)
|
|||
if (Gbl.Test.AnswerType == Tst_ANS_UNIQUE_CHOICE ||
|
||||
Gbl.Test.AnswerType == Tst_ANS_MULTIPLE_CHOICE)
|
||||
{
|
||||
sprintf (ParamAction,"ImgAct%u",NumOpt);
|
||||
sprintf (ParamFile ,"ImgFil%u",NumOpt);
|
||||
sprintf (ParamTitle ,"ImgTit%u",NumOpt);
|
||||
ParamUploadImg.Action = ParamAction;
|
||||
ParamUploadImg.File = ParamFile;
|
||||
ParamUploadImg.Title = ParamTitle;
|
||||
Gbl.Test.Answer.Options[NumOpt].Image.Width = Tst_IMAGE_SAVED_MAX_WIDTH;
|
||||
Gbl.Test.Answer.Options[NumOpt].Image.Height = Tst_IMAGE_SAVED_MAX_HEIGHT;
|
||||
Gbl.Test.Answer.Options[NumOpt].Image.Quality = Tst_IMAGE_SAVED_QUALITY;
|
||||
Img_GetImageFromForm ((int) NumOpt,&Gbl.Test.Answer.Options[NumOpt].Image,
|
||||
Tst_GetImageFromDB,&ParamUploadImg);
|
||||
Tst_GetImageFromDB);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue