Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Images shown in response export.

  • moodleboy
  • moodleboy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 days 11 hours ago #268828 by moodleboy
Images shown in response export. was created by moodleboy
Hello,

I am using the LimeSurvey Community Edition Version 6.9.0+241218 and I have a question regarding exported responses.

We would like to use limesurvey to collect information regarding our campers and part of it requires submitting a few image files.  At the start of camp, we need to print all the records for legal compliance, and this requires the image to be printed as well.  Currently, when running an export, the images are not exported; only the filenames and other metadata are exported (see attached screenshot)

We have well over 300 campers, so the available process (which is to download the submitted files for each submission individually and then unzipping each file) is too cumbersome and impractical. Even the alternative option, which is to download all files, is even more impractical, since we would have to parse the submission numbers for over 1000 images to match with the 300 or so forms the campers' families submit.

I've searched the forums for a solution to this but I haven't found one.  There are a bunch of posts, but none seem to have a solution.  I have installed the "pdfReport" plugin, but it does not seem to do what I want it to do.  I believe it is for the person submitting the form to be able to print it for themselves.

Is there a way to accomplish this, so that the attached image files in a survey can be included, as images, in the resulting export? The export can either be in pdf or html format.

Thank you,
Paul
 

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 days 10 hours ago #268829 by DenisChenu
Replied by DenisChenu on topic Images shown in response export.

I've searched the forums for a solution to this but I haven't found one.  There are a bunch of posts, but none seem to have a solution.  I have installed the "pdfReport" plugin, but it does not seem to do what I want it to do.  I believe it is for the person submitting the form to be able to print it for themselves.
 
You can send the report to any email, but currently there are no way to include the image link./source to the PDF.

I think we can add an Expression Manager function : imgSrc(Qcode[index=0]) in a new plugin.

Else a plugin can create any PDF file using any PHP script Export plugin : www.limesurvey.org/manual/Export_plugin_development#newExport but more time consuming.
 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 days 9 hours ago #268836 by Joffm
Replied by Joffm on topic Images shown in response export.
Hi, unfortunately you did not answer the question at the beginning about your hosting.

There is a way to achieve this if you have access to the server..
When you have a look at the content of the uploaded question {QUpload} you see something like this.
 
 
And on your sever there you find this
 
The files are stored under their "tmp filename" without extension.

Now you may do an ajax-call to rename the files on the server.
Extract the filename and the extension by some stringfunctions (ExpressionScript) and run the ajax call in a question of type "short text" where you store the result of the call (the new name of the file)
Like this
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
    $.post('https://www.myServer/renameFile.php' , { sid: "{SID}", fname: "{eqFname}", ext: "{eqExt}" },function(data) {
        $('#question{QID} input[type="text"]').val(data)
    });
  });
</script>
You see there is a php script called "renameFile.php" that you have to create (up to your needs)

Now the file is renamed and you can use it e.g. in your pdfReport
 

It is possible though I see it as a "l'art pour l'art" solution.

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 days 9 hours ago #268838 by DenisChenu
Replied by DenisChenu on topic Images shown in response export.

It is possible though I see it as a "l'art pour l'art" solution.
 
Maybe you can do it too with some LibreOffice Calc calculation to transform the JSON data to
Code:
wget http://example.org/up)load/surveys/files/fu_jqsdbhqsdbhazbde -O file-{SRID}-{Original file name}.jpg

 

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.

Please Log in to join the conversation.

  • moodleboy
  • moodleboy's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 days 11 hours ago - 3 days 9 hours ago #268876 by moodleboy
Replied by moodleboy on topic Images shown in response export.
Hello, and thank you all for your quick responses.  Please allow me to address them, the best I can, in the order of your replies.

You can send the report to any email, but currently there are no way to include the image link./source to the PDF.

I think we can add an Expression Manager function : imgSrc(Qcode[index=0]) in a new plugin.

Else a plugin can create any PDF file using any PHP script Export plugin : www.limesurvey.org/manual/Export_plugin_development#newExport but more time consuming.

I followed the link in the above reply, but the page only had five items on it with no details.  Is there another page with additional details and/or instructions?

Hi, unfortunately you did not answer the question at the beginning about your hosting.

My apologies. I didn't see this.  I am on a dedicated server, so I have access to all files.

Now you may do an ajax-call to rename the files on the server.
Extract the filename and the extension by some stringfunctions (ExpressionScript) and run the ajax call in a question of type "short text" where you store the result of the call (the new name of the file)
Like this

I have a little experience with php and Java, but not much with AJAX.  Exactly where should this code go?

You see there is a php script called "renameFile.php" that you have to create (up to your needs)

My apologies, but this is a bit vague for me.  My needs are pretty specific, to include the actual images in the output.  What should go in this file?

As a temporary measure, I hacked part of the code in /application/helpers/admin/export/HtmlWriter.php as follows.  FULL DISCLAIMER: This is a terrible hack, and I am using this on a non-production site only for testing. I have extremely limited experience with the file structure and programming logic of limesurvey so I was just trying to see if I could access the files.  It works, but it leaves the images in a publicly available folder which is not good for security.  Please don't judge me on this code :-) /**
* Renders a question and recurses into subquestions.
* @param Question $question
* @param string $value
*/
protected function renderQuestion($question, $value, $header)
{
if (isset($value) && strlen($value) > 0) {
$this->openTag('tr', array(
'data-qid' => $question,
'class' => 'question'
));

$this->tag('td', $header);
$this->tag('td', $value);
if(substr($value,0,2) == "[{") {
$tempvalue = str_replace("&quot;","",$value);

$tempvalue = str_replace("[{","",$tempvalue);
$tempvalue = str_replace("}];","",$tempvalue);
$filenamearray = array();
foreach(explode(',',$tempvalue) as $filenameitems) {
$filenameitem = explode(':',$filenameitems);
$filenamearray[$filenameitem[0]] = $filenameitem[1];
}
$original_filename = $filenamearray;
$new_filename = $filenamearray;
$new_url = "https://myserver/upload/surveys/surveynumber/files/temp/" . $new_filename;

$temp_directory = '/myserverpath/upload/surveys/surveynumber/files/temp/';
$main_directory = '/myserverpath/upload/surveys/surveynumber/files/';

$original_file = $main_directory . $original_filename;
$new_file = $temp_directory . $new_filename;

copy($original_file,$new_file);

echo "<img src=\"$new_url\" width=\"200\"><br>";



}
$this->closeTag();
}
}


Thank you again for all your help.
 



 
Last edit: 3 days 9 hours ago by moodleboy.

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose