From 774ff78ca6fb0b70db34f9b318abc5baf5455fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 17 Mar 2019 01:38:10 +0100 Subject: [PATCH] Version18.77.5 --- css/swad18.77.css | 38 +++++++++--- swad_changelog.h | 10 +++- swad_media.c | 150 +++++++++++++++++++++++++--------------------- swad_media.h | 1 + swad_test.c | 100 ++++++++++++------------------- swad_text.c | 6 +- 6 files changed, 161 insertions(+), 144 deletions(-) diff --git a/css/swad18.77.css b/css/swad18.77.css index b4e3b4353..b65d4b220 100644 --- a/css/swad18.77.css +++ b/css/swad18.77.css @@ -2409,12 +2409,30 @@ a:hover img.CENTRE_PHOTO_SHOW /********************************** Tests ************************************/ .TAG_SEL {box-sizing:border-box; width:346px;} .TAG_TXT {box-sizing:border-box; width:346px;} -.STEM {box-sizing:border-box; width:700px;} +.STEM + { + box-sizing:border-box; + margin:0 auto; + width:700px; + } +.STEM_TEXTAREA + { + width:696px; + } +.ANSWER + { + box-sizing:border-box; + margin:0 auto; + width:600px; + } +.ANSWER_TEXTAREA + { + width:596px; + } .ANS_TXT {color:#202020; font-size:12pt;} .ANS_0 {color:#202020; font-size:12pt; font-weight:bold;} .ANS_OK {color:#008000; font-size:12pt; font-weight:bold;} .ANS_BAD {color:red; font-size:12pt; font-weight:bold;} -.ANS_STR {box-sizing:border-box; width:600px;} .TEST_SUBTITLE { margin:10px; @@ -2483,7 +2501,7 @@ a:hover img.CENTRE_PHOTO_SHOW border-radius:2px; } -.TEST_FORM_EDIT_IMG +.TEST_FORM_EDIT_MED { box-sizing:border-box; margin:15px 0; @@ -2517,21 +2535,21 @@ a:hover img.CENTRE_PHOTO_SHOW .TEST_EDI_ANS_LEFT_COL { box-sizing:border-box; - width:50px; + width:48px; text-align:left; vertical-align:top; } .TEST_EDI_ANS_CENTER_COL { box-sizing:border-box; - width:50px; + width:48px; text-align:right; vertical-align:top; } .TEST_EDI_ANS_RIGHT_COL { box-sizing:border-box; - width:604px; + width:600px; text-align:left; vertical-align:top; } @@ -2675,7 +2693,7 @@ a:hover img.CENTRE_PHOTO_SHOW { display:table-cell; box-sizing:border-box; - padding:6px; + padding:6px; text-align:center; vertical-align:middle; border:solid 1px; @@ -2717,8 +2735,7 @@ a:hover img.CENTRE_PHOTO_SHOW .MED_UPL_CON /* Upload container */ { text-align:center; - vertical-align:top; - margin-bottom:10px; + margin-bottom:6px; } .MED_PLAY @@ -2964,6 +2981,7 @@ a:hover img.CENTRE_PHOTO_SHOW .TL_POST_MED_INPUT { box-sizing:border-box; + margin:0 auto; } .TL_POST_IMG_CONTAINER { @@ -3132,6 +3150,7 @@ a:hover img.CENTRE_PHOTO_SHOW .FOR_MED_INPUT { box-sizing:border-box; + margin:0 auto; width:480px; } @@ -3158,6 +3177,7 @@ a:hover img.CENTRE_PHOTO_SHOW .MSG_MED_INPUT { box-sizing:border-box; + margin:0 auto; width:480px; } .MSG_TXT diff --git a/swad_changelog.h b/swad_changelog.h index 1f85b16f8..b762b82cd 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -413,6 +413,11 @@ Lo de mutear anuncios, en principio prefiero hacer una opci // TODO: Chequear todos los iconos .gif y .png que restan, concretamente los de file_browser +// TODO: Víctor González Argudo: Como sugerencia, estaría bien que cuando te dieran like +// mas de 5 personas se pudiera saber quienes son +// por ejemplo dejando encima el cursor de los 3 puntos +// y que saliera una lista con los nombres + // TODO: Pedro Villar Castro: // Al asignar un TFG a alumnos, no escribir el DNI del alumno, sino escogerlo de una lista de entre los alumnos inscritos en la asignatura. @@ -452,7 +457,7 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.77.1 (2019-03-15)" +#define Log_PLATFORM_VERSION "SWAD 18.77.5 (2019-03-17)" #define CSS_FILE "swad18.77.css" #define JS_FILE "swad18.77.js" /* @@ -468,8 +473,7 @@ Si el usuario acepta, a partir de ese momento se le mostrar Ese bloqueo o aceptación sería una opción en Perfil > Ajustes que el usuario podría cambiar en cualquier momento. -TODO: Fix edition of media in test edition - + Version 18.77.5: Mar 16, 2019 Fixed bugs in forms to upload media. (240272 lines) Version 18.77.4: Mar 16, 2019 Changes in form to upload media. (240256 lines) Version 18.77.3: Mar 16, 2019 Embedded YouTube videos. Not finished. (240252 lines) Version 18.77.2: Mar 14, 2019 Embedded YouTube videos. Not finished. (240267 lines) diff --git a/swad_media.c b/swad_media.c index d198b9795..58812a8e0 100644 --- a/swad_media.c +++ b/swad_media.c @@ -104,7 +104,7 @@ extern struct Globals Gbl; /*****************************************************************************/ static Med_Action_t Med_GetMediaActionFromForm (const char *ParamAction); -static Med_FormType_t Usr_GetFormTypeFromForm (void); +static Med_FormType_t Usr_GetFormTypeFromForm (struct ParamUploadMedia *ParamUploadMedia); static void Usr_GetURLFromForm (const char *ParamName,struct Media *Media); static void Usr_GetTitleFromForm (const char *ParamName,struct Media *Media); static void Med_GetAndProcessFileFromForm (const char *ParamFile, @@ -307,7 +307,7 @@ void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput) " class=\"PREF_OFF\">" "\"%s\"" "", // _ico_upl Id, @@ -318,9 +318,9 @@ void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput) /***** Form type *****/ fprintf (Gbl.F.Out,"_par_upl - " name=\"FormType\" value=\"%u\"" + " name=\"%s\" value=\"%u\"" " disabled=\"disabled\" />", - Id, + Id,ParamUploadMedia.FormType, (unsigned) Med_FORM_FILE); /***** Embed icon *****/ @@ -328,7 +328,7 @@ void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput) " class=\"PREF_OFF\">" "\"%s\"" "", // _ico_emb Id, @@ -347,9 +347,9 @@ void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput) /***** Form type *****/ fprintf (Gbl.F.Out,"_par_emb - " name=\"FormType\" value=\"%u\"" + " name=\"%s\" value=\"%u\"" " disabled=\"disabled\" />", - Id, + Id,ParamUploadMedia.FormType, (unsigned) Med_FORM_EMBED); /***** Media file *****/ @@ -400,28 +400,34 @@ void Med_GetMediaFromForm (int NumMediaInForm,struct Media *Media, struct ParamUploadMedia ParamUploadMedia; Med_FormType_t FormType; + /***** Initialize media *****/ + Media->Action = Med_ACTION_NO_MEDIA; + Media->Status = Med_STATUS_NONE; + Media->Name[0] = '\0'; + Media->Type = Med_TYPE_NONE; + Media->Title = NULL; + Media->URL = NULL; + /***** Set names of parameters depending on number of media in form *****/ Med_SetParamNames (&ParamUploadMedia,NumMediaInForm); /***** Get action and initialize media (image/video) (except title, that will be get after the media file) *****/ Media->Action = Med_GetMediaActionFromForm (ParamUploadMedia.Action); - Media->Status = Med_STATUS_NONE; - Media->Name[0] = '\0'; - Media->Type = Med_TYPE_NONE; - - /***** Get form type *****/ - FormType = Usr_GetFormTypeFromForm (); /***** Get the media (image/video) name and the file *****/ switch (Media->Action) { case Med_ACTION_NEW_MEDIA: // Upload new image/video + /***** Get form type *****/ + FormType = Usr_GetFormTypeFromForm (&ParamUploadMedia); + /***** Get new media *****/ switch (FormType) { case Med_FORM_FILE: - /***** Get image/video (if present ==> process and create temporary file) *****/ + /* Get image/video (if present ==> + process and create temporary file) */ Med_GetAndProcessFileFromForm (ParamUploadMedia.File,Media); switch (Media->Status) { @@ -444,7 +450,7 @@ void Med_GetMediaFromForm (int NumMediaInForm,struct Media *Media, } break; case Med_FORM_EMBED: - /***** Get and process embed URL from form *****/ + /* Get and process embed URL from form */ Med_GetAndProcessEmbedFromForm (ParamUploadMedia.URL,Media); break; default: @@ -457,10 +463,15 @@ void Med_GetMediaFromForm (int NumMediaInForm,struct Media *Media, GetMediaFromDB (NumMediaInForm,Media); break; case Med_ACTION_CHANGE_MEDIA: // Replace old image/video by new one + /***** Get form type *****/ + FormType = Usr_GetFormTypeFromForm (&ParamUploadMedia); + + /***** Get new media *****/ switch (FormType) { case Med_FORM_FILE: - /***** Get image/video (if present ==> process and create temporary file) *****/ + /* Get image/video (if present ==> + process and create temporary file) */ Med_GetAndProcessFileFromForm (ParamUploadMedia.File,Media); switch (Media->Status) { @@ -473,7 +484,7 @@ void Med_GetMediaFromForm (int NumMediaInForm,struct Media *Media, } break; case Med_FORM_EMBED: - /***** Get and process embed URL from form *****/ + /* Get and process embed URL from form */ Med_GetAndProcessEmbedFromForm (ParamUploadMedia.URL,Media); break; default: @@ -484,7 +495,7 @@ void Med_GetMediaFromForm (int NumMediaInForm,struct Media *Media, /* Get media (image/video) name */ GetMediaFromDB (NumMediaInForm,Media); break; - case Med_ACTION_NO_MEDIA: // Do not use image/video (remove current image/video if exists) + default: break; } } @@ -499,27 +510,32 @@ void Med_SetParamNames (struct ParamUploadMedia *ParamUploadMedia,int NumMediaIn { if (NumMediaInForm < 0) // One unique media in form ==> no suffix needed { - Str_Copy (ParamUploadMedia->Action,"MedAct", + Str_Copy (ParamUploadMedia->Action ,"MedAct", Med_MAX_BYTES_PARAM_UPLOAD_MEDIA); - Str_Copy (ParamUploadMedia->File ,"MedFil", + Str_Copy (ParamUploadMedia->FormType,"MedFrm", Med_MAX_BYTES_PARAM_UPLOAD_MEDIA); - Str_Copy (ParamUploadMedia->Title ,"MedTit", + Str_Copy (ParamUploadMedia->File ,"MedFil", Med_MAX_BYTES_PARAM_UPLOAD_MEDIA); - Str_Copy (ParamUploadMedia->URL ,"MedURL", + Str_Copy (ParamUploadMedia->Title ,"MedTit", + Med_MAX_BYTES_PARAM_UPLOAD_MEDIA); + Str_Copy (ParamUploadMedia->URL ,"MedURL", Med_MAX_BYTES_PARAM_UPLOAD_MEDIA); } else // Several video/images in form ==> add suffix { - snprintf (ParamUploadMedia->Action,sizeof (ParamUploadMedia->Action), + snprintf (ParamUploadMedia->Action ,sizeof (ParamUploadMedia->Action), "MedAct%u", NumMediaInForm); - snprintf (ParamUploadMedia->File ,sizeof (ParamUploadMedia->File), + snprintf (ParamUploadMedia->FormType,sizeof (ParamUploadMedia->Action), + "MedFrm%u", + NumMediaInForm); + snprintf (ParamUploadMedia->File ,sizeof (ParamUploadMedia->File), "MedFil%u", NumMediaInForm); - snprintf (ParamUploadMedia->Title ,sizeof (ParamUploadMedia->Title), + snprintf (ParamUploadMedia->Title ,sizeof (ParamUploadMedia->Title), "MedTit%u", NumMediaInForm); - snprintf (ParamUploadMedia->URL ,sizeof (ParamUploadMedia->URL), + snprintf (ParamUploadMedia->URL ,sizeof (ParamUploadMedia->URL), "MedURL%u", NumMediaInForm); } @@ -543,9 +559,9 @@ static Med_Action_t Med_GetMediaActionFromForm (const char *ParamAction) /********************* Get from form the type of form ************************/ /*****************************************************************************/ -static Med_FormType_t Usr_GetFormTypeFromForm (void) +static Med_FormType_t Usr_GetFormTypeFromForm (struct ParamUploadMedia *ParamUploadMedia) { - return (Med_FormType_t) Par_GetParToUnsignedLong ("FormType", + return (Med_FormType_t) Par_GetParToUnsignedLong (ParamUploadMedia->FormType, 0, Med_NUM_FORM_TYPES - 1, (unsigned long) Med_FORM_UNKNOWN); @@ -1118,7 +1134,7 @@ void Med_MoveMediaToDefinitiveDir (struct Media *Media) /***** Check trivial cases *****/ if (Media->Type == Med_TYPE_NONE) - Lay_ShowErrorAndExit ("Wrong media type."); + Lay_ShowErrorAndExit ("Med_MoveMediaToDefinitiveDir: Wrong media type."); if (Media->Type == Med_YOUTUBE) return; // Nothing to do with files @@ -1546,8 +1562,10 @@ void Med_RemoveMediaFiles (const char *Name,Med_Type_t Type) char FullPathMediaPriv[PATH_MAX + 1]; /***** Trivial cases *****/ - if (Type == Med_TYPE_NONE) - Lay_ShowErrorAndExit ("Wrong media type."); + if (Name == NULL) + return; + if (!Name[0]) + return; if (Type == Med_YOUTUBE) return; @@ -1558,48 +1576,46 @@ void Med_RemoveMediaFiles (const char *Name,Med_Type_t Type) Name[0], Name[1]); - if (Name[0]) + /***** Remove files *****/ + switch (Type) { - switch (Type) - { - case Med_JPG: - /***** Remove private JPG file *****/ - snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), - "%s/%s.%s", - PathMedPriv,Name,Med_Extensions[Med_JPG]); - unlink (FullPathMediaPriv); + case Med_JPG: + /***** Remove private JPG file *****/ + snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), + "%s/%s.%s", + PathMedPriv,Name,Med_Extensions[Med_JPG]); + unlink (FullPathMediaPriv); - break; - case Med_GIF: - /***** Remove private GIF file *****/ - snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), - "%s/%s.%s", - PathMedPriv,Name,Med_Extensions[Med_GIF]); - unlink (FullPathMediaPriv); + break; + case Med_GIF: + /***** Remove private GIF file *****/ + snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), + "%s/%s.%s", + PathMedPriv,Name,Med_Extensions[Med_GIF]); + unlink (FullPathMediaPriv); - /***** Remove private PNG file *****/ - snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), - "%s/%s.png", - PathMedPriv,Name); - unlink (FullPathMediaPriv); + /***** Remove private PNG file *****/ + snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), + "%s/%s.png", + PathMedPriv,Name); + unlink (FullPathMediaPriv); - break; - case Med_MP4: - case Med_WEBM: - case Med_OGG: - /***** Remove private video file *****/ - snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), - "%s/%s.%s", - PathMedPriv,Name,Med_Extensions[Type]); - unlink (FullPathMediaPriv); + break; + case Med_MP4: + case Med_WEBM: + case Med_OGG: + /***** Remove private video file *****/ + snprintf (FullPathMediaPriv,sizeof (FullPathMediaPriv), + "%s/%s.%s", + PathMedPriv,Name,Med_Extensions[Type]); + unlink (FullPathMediaPriv); - break; - default: - break; - } - - // Public links are removed automatically after a period + break; + default: + break; } + + // Public links are removed automatically after a period } /*****************************************************************************/ diff --git a/swad_media.h b/swad_media.h index 9ff4df422..65d36e3f8 100644 --- a/swad_media.h +++ b/swad_media.h @@ -122,6 +122,7 @@ struct Media struct ParamUploadMedia { char Action [Med_MAX_BYTES_PARAM_UPLOAD_MEDIA + 1]; + char FormType[Med_MAX_BYTES_PARAM_UPLOAD_MEDIA + 1]; char File [Med_MAX_BYTES_PARAM_UPLOAD_MEDIA + 1]; char Title [Med_MAX_BYTES_PARAM_UPLOAD_MEDIA + 1]; char URL [Med_MAX_BYTES_PARAM_UPLOAD_MEDIA + 1]; diff --git a/swad_test.c b/swad_test.c index 8588b8204..2c8abc3c1 100644 --- a/swad_test.c +++ b/swad_test.c @@ -276,11 +276,11 @@ static void Tst_RemAnsFromQst (void); static void Tst_RemTagsFromQst (void); static void Tst_RemoveUnusedTagsFromCurrentCrs (void); -static void Tst_RemoveImgFileFromStemOfQst (long CrsCod,long QstCod); -static void Tst_RemoveAllImgFilesFromStemOfAllQstsInCrs (long CrsCod); -static void Tst_RemoveImgFileFromAnsOfQst (long CrsCod,long QstCod,unsigned AnsInd); -static void Tst_RemoveAllImgFilesFromAnsOfQst (long CrsCod,long QstCod); -static void Tst_RemoveAllImgFilesFromAnsOfAllQstsInCrs (long CrsCod); +static void Tst_RemoveMedFileFromStemOfQst (long CrsCod,long QstCod); +static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod); +static void Tst_RemoveMedFileFromAnsOfQst (long CrsCod,long QstCod,unsigned AnsInd); +static void Tst_RemoveAllMedFilesFromAnsOfQst (long CrsCod,long QstCod); +static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod); static unsigned Tst_GetNumTstQuestions (Sco_Scope_t Scope,Tst_AnswerType_t AnsType,struct Tst_Stats *Stats); static unsigned Tst_GetNumCoursesWithTstQuestions (Sco_Scope_t Scope,Tst_AnswerType_t AnsType); @@ -1115,12 +1115,9 @@ static void Tst_PutFormToEditQstMedia (struct Media *Media,int NumMediaInForm, bool OptionsDisabled) { extern const char *The_ClassFormInBox[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_Title_attribution; - extern const char *Txt_Link; - extern const char *Txt_optional; + extern const char *Txt_No_image_video; + extern const char *Txt_Current_image_video; + extern const char *Txt_Change_image_video; static unsigned UniqueId = 0; struct ParamUploadMedia ParamUploadMedia; @@ -1130,9 +1127,9 @@ static void Tst_PutFormToEditQstMedia (struct Media *Media,int NumMediaInForm, Med_SetParamNames (&ParamUploadMedia,NumMediaInForm); /***** Start container *****/ - fprintf (Gbl.F.Out,"
"); + fprintf (Gbl.F.Out,"
"); - /***** Choice 1: No image *****/ + /***** Choice 1: No media *****/ fprintf (Gbl.F.Out,"
", - Txt_No_image); + Txt_No_image_video); - /***** Choice 2: Current image *****/ + /***** Choice 2: Current media *****/ fprintf (Gbl.F.Out,"", - Txt_Current_image); + Txt_Current_image_video); Med_ShowMedia (Media,ClassContainer,ClassMedia); - /***** Choice 3: Change/new image *****/ + /***** Choice 3: Change media *****/ UniqueId++; fprintf (Gbl.F.Out,"" - "", - UniqueId); - - /***** Media title/attribution *****/ - fprintf (Gbl.F.Out,"
" - "", - ParamUploadMedia.Title,Txt_Title_attribution,Txt_optional, - ClassMediaInput,Med_MAX_CHARS_TITLE, - Media->Title ? Media->Title : - ""); - - /***** Media URL *****/ - fprintf (Gbl.F.Out,"
" - "", - ParamUploadMedia.URL,Txt_Link,Txt_optional, - ClassMediaInput,Cns_MAX_CHARS_WWW, - Media->URL ? Media->URL : - ""); + "", + Txt_Change_image_video); + Med_PutMediaUploader (NumMediaInForm,ClassMediaInput); /***** End container *****/ fprintf (Gbl.F.Out,"
"); } else // No current image - /***** Attached image (optional) *****/ + /***** Attached media *****/ Med_PutMediaUploader (NumMediaInForm,ClassMediaInput); } @@ -5081,7 +5053,7 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1], "" "" "
", The_ClassFormInBox[Gbl.Prefs.Theme], @@ -5096,7 +5068,8 @@ static void Tst_PutFormEditOneQst (char Stem[Cns_MAX_BYTES_TEXT + 1], /***** Feedback *****/ fprintf (Gbl.F.Out,"