From f90760fd5e6efe5f2f89b377dbd27422c064f9e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 1 Apr 2016 14:44:55 +0200 Subject: [PATCH] Version 15.173 --- css/{swad15.165.5.css => swad15.173.css} | 15 ++++++- swad_changelog.h | 7 ++-- swad_file_browser.c | 12 +++--- swad_file_browser.h | 3 ++ swad_test.c | 51 ++++++++++++++++++------ 5 files changed, 66 insertions(+), 22 deletions(-) rename css/{swad15.165.5.css => swad15.173.css} (99%) diff --git a/css/swad15.165.5.css b/css/swad15.173.css similarity index 99% rename from css/swad15.165.5.css rename to css/swad15.173.css index 0372d824b..7b6695d8f 100644 --- a/css/swad15.165.5.css +++ b/css/swad15.173.css @@ -1432,7 +1432,7 @@ a:hover img.CENTRE_PHOTO_SHOW border:solid 1px #EEE; box-shadow:1px 1px 6px #999; } - + /**************** Attribution (author and license) of images *****************/ #AttributionArea { @@ -1732,6 +1732,19 @@ a:hover img.CENTRE_PHOTO_SHOW .TEST_EXA_LIGHT {color:#A0A0A0; font-size:12pt;} .TEST_EDI {color:#404040; font-size:12pt;} .TEST_EDI_LIGHT {color:#A0A0A0; font-size:12pt;} +.TEST_IMG_SHOW + { + width:600px; + margin:10px 0; + } +.TEST_IMG_EDIT_LIST + { + width:256px; + } +.TEST_IMG_EDIT_ONE + { + width:600px; + } /******************************* Time table **********************************/ #timetable diff --git a/swad_changelog.h b/swad_changelog.h index 2bf92afb8..ec2197237 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -138,14 +138,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.172.1 (2016-04-01)" -#define CSS_FILE "swad15.165.5.css" +#define Log_PLATFORM_VERSION "SWAD 15.173 (2016-04-01)" +#define CSS_FILE "swad15.173.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.172.1: Apr 01, 2016 Reception of test image. Not finished. (197398 lines) + Version 15.173: Apr 01, 2016 Show image in test question, if present. (197435 lines) + Version 15.172.1: Apr 01, 2016 Reception of test image. (197398 lines) Version 15.172: Apr 01, 2016 Reception of test image. Not finished. (197339 lines) Version 15.171.2: Apr 01, 2016 Change in message related to user photo. (197272 lines) Version 15.171.1: Apr 01, 2016 Code refactoring in functions to get a parameter and to receive file. (197271 lines) diff --git a/swad_file_browser.c b/swad_file_browser.c index ded362ca2..64ef65b4f 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -1444,7 +1444,6 @@ static void Brw_WriteFileName (unsigned Level,bool IsPublic,Brw_FileType_t FileT static void Brw_GetFileNameToShow (Brw_FileBrowser_t FileBrowser,unsigned Level,Brw_FileType_t FileType, const char *FileName,char *FileNameToShow); static void Brw_LimitLengthFileNameToShow (Brw_FileType_t FileType,const char *FileName,char *FileNameToShow); -static void Brw_CreateTmpLinkToDownloadFileBrowser (const char *FullPathIncludingFile,const char *FileName); static void Brw_WriteDatesAssignment (void); static void Brw_WriteFileSizeAndDate (Brw_FileType_t FileType,struct FileMetadata *FileMetadata); static void Brw_WriteFileOrFolderPublisher (unsigned Level,unsigned long UsrCod); @@ -5864,19 +5863,20 @@ static void Brw_LimitLengthFileNameToShow (Brw_FileType_t FileType,const char *F } /*****************************************************************************/ -/****** Create a link in public temporary directory to download a file *******/ +/****** Create a link in public temporary directory to a private file ********/ /*****************************************************************************/ -static void Brw_CreateTmpLinkToDownloadFileBrowser (const char *FullPathIncludingFile,const char *FileName) +void Brw_CreateTmpPublicLinkToPrivateFile (const char *FullPathIncludingFile, + const char *FileName) { char Link[PATH_MAX+1]; - /***** Create, into temporary download directory, a symbolic link to file *****/ + /***** Create, into temporary public directory, a symbolic link to file *****/ sprintf (Link,"%s/%s/%s/%s", Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_FILE_BROWSER_TMP, Gbl.FileBrowser.TmpPubDir,FileName); if (symlink (FullPathIncludingFile,Link) != 0) - Lay_ShowErrorAndExit ("Can not create temporary link for download."); + Lay_ShowErrorAndExit ("Can not create temporary link."); } /*****************************************************************************/ @@ -9681,7 +9681,7 @@ void Brw_GetLinkToDownloadFile (const char *PathInTree,const char *FileName,char Brw_CreateDirDownloadTmp (); /***** Create symbolic link from temporary public directory to private file in order to gain access to it for downloading *****/ - Brw_CreateTmpLinkToDownloadFileBrowser (FullPathIncludingFile,FileName); + Brw_CreateTmpPublicLinkToPrivateFile (FullPathIncludingFile,FileName); /***** Create URL pointing to symbolic link *****/ sprintf (URLWithSpaces,"%s/%s/%s/%s", diff --git a/swad_file_browser.h b/swad_file_browser.h index 654a0abed..79eb874e7 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -214,6 +214,9 @@ void Brw_CalcSizeOfDir (char *Path); void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char *FilFolLnkName); +void Brw_CreateTmpPublicLinkToPrivateFile (const char *FullPathIncludingFile, + const char *FileName); + void Brw_ParamListFiles (Brw_FileType_t FileType,const char *PathInTree,const char *FileName); void Brw_RemoveZonesOfGroupsOfType (long GrpTypCod); diff --git a/swad_test.c b/swad_test.c index ecc4b200d..bf62ade52 100644 --- a/swad_test.c +++ b/swad_test.c @@ -154,7 +154,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_WriteQstImage (const char *Image); +static void Tst_WriteQstImage (const char *Image,const char *ClassImg); static void Tst_PutFormToUploadNewQstImage (void); static void Tst_UpdateScoreQst (long QstCod,float ScoreThisQst,bool AnswerIsNotBlank); static void Tst_UpdateMyNumAccessTst (unsigned NumAccessesTst); @@ -978,7 +978,7 @@ static void Tst_WriteQstAndAnsExam (unsigned NumQst,long QstCod,MYSQL_ROW row, fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); Tst_WriteQstStem (row[4],"TEST_EXA"); - Tst_WriteQstImage (row[5]); + Tst_WriteQstImage (row[5],"TEST_IMG_SHOW"); if (Gbl.Action.Act == ActSeeTst) Tst_WriteAnswersOfAQstSeeExam (NumQst,QstCod,(Str_ConvertToUpperLetter (row[3][0]) == 'Y')); else // Assessing exam / Viewing old exam @@ -1023,15 +1023,42 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem) /******************** Write the image of a test question *********************/ /*****************************************************************************/ -static void Tst_WriteQstImage (const char *Image) +static void Tst_WriteQstImage (const char *Image,const char *ClassImg) { - if (Image) - if (Image[0]) - /***** Write the image *****/ - fprintf (Gbl.F.Out,"
" - "%s" - "
", - Image); + char FileNameImgPriv[PATH_MAX+1]; + char FullPathImgPriv[PATH_MAX+1]; + char URL[PATH_MAX+1]; + + if (!Image) + return; + if (!Image[0]) + return; + + /***** Create a temporary public directory + used to download the zip file *****/ + Brw_CreateDirDownloadTmp (); + + /***** Create symbolic link from temporary public directory to private file in order to gain access to it for downloading *****/ + /* Private path to image */ + sprintf (FileNameImgPriv,"%s.jpg", + Image); + sprintf (FullPathImgPriv,"%s/%s/%c%c/%s", + Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG, + Image[0], + Image[1], + FileNameImgPriv); + Brw_CreateTmpPublicLinkToPrivateFile (FullPathImgPriv,FileNameImgPriv); + + /***** Create URL pointing to symbolic link *****/ + sprintf (URL,"%s/%s/%s/%s", + Cfg_HTTPS_URL_SWAD_PUBLIC,Cfg_FOLDER_FILE_BROWSER_TMP, + Gbl.FileBrowser.TmpPubDir, + FileNameImgPriv); + + /***** Show image *****/ + fprintf (Gbl.F.Out,"\"\"" + "
", + URL,ClassImg); } /*****************************************************************************/ @@ -2683,7 +2710,7 @@ static void Tst_ListOneOrMoreQuestionsToEdit (unsigned long NumRows,MYSQL_RES *m fprintf (Gbl.F.Out,"", Gbl.RowEvenOdd); Tst_WriteQstStem (row[4],"TEST_EDI"); - Tst_WriteQstImage (row[5]); + Tst_WriteQstImage (row[5],"TEST_IMG_EDIT_LIST"); Tst_WriteQstFeedback (row[6],"TEST_EDI_LIGHT"); Tst_WriteAnswersOfAQstEdit (QstCod); fprintf (Gbl.F.Out,""); @@ -4414,7 +4441,7 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback) "", The_ClassForm[Gbl.Prefs.Theme], Txt_Image); - Tst_WriteQstImage (Gbl.Test.Image); + Tst_WriteQstImage (Gbl.Test.Image,"TEST_IMG_EDIT_ONE"); Tst_PutFormToUploadNewQstImage (); fprintf (Gbl.F.Out,"" "");