Display submitted images instead of titles of Images on the review page for the quiz.

Re: Display submitted images instead of titles of Images on the review page for the quiz.

by Liberty IT -
Number of replies: 0
On specific page



  public function files_read_only(question_attempt $qa, question_display_options $options) {

        $files = $qa->get_last_qt_files('attachments', $options->context->id);

        $output = array();


$url = $_SERVER["REQUEST_URI"]; 
$pos = strrpos($url, "review.php"); 

      if($pos != false) { foreach ($files as $file) {

            $output[] = html_writer::tag('p', html_writer::link($qa->get_response_file_url($file),

                    $this->output->pix_icon(file_file_icon($file), get_mimetype_description($file),

                    'moodle', array('class' => 'icon')) . ' ' . s($file->get_filename())));

        }
          
      }
          else { foreach ($files as $file) {
           
         $type=get_mimetype_description($file);   
         $extensions=array('Image (JPEG)','Image (PNG)','Image (BMP)','Image (GIF)','Image (PICT)','Image (SVG+XML)','Image (TIFF)');
   
    if(in_array($type, $extensions)){
                $output[] = html_writer::link($qa->get_response_file_url($file),
                    '<img src="'.$qa->get_response_file_url($file).'/>');
    }
                   $output[] = html_writer::tag('p', html_writer::link($qa->get_response_file_url($file),
                    $this->output->pix_icon(file_file_icon($file), get_mimetype_description($file),
                    'moodle', array('class' => 'icon')) . ' ' . s($file->get_filename())));
            
        }
          }

        return implode($output);

    }