You are here

function quiz_file_markup in Quiz File Upload 7.5

Same name and namespace in other branches
  1. 7 quizfileupload.classes.inc \quiz_file_markup()
  2. 7.4 quizfileupload.classes.inc \quiz_file_markup()

Markup function to show the file on the result screen.

1 call to quiz_file_markup()
QuizfileuploadResponse::getFeedbackValues in ./quizfileupload.classes.inc
Implements getFeedbackValues().

File

./quizfileupload.module, line 161
Quizfileupload question type for the Quiz module.

Code

function quiz_file_markup($fid) {
  if (!empty($fid) && is_numeric($fid)) {
    if ($file = file_load($fid)) {

      // Check if file is an image.
      $errors = file_validate_is_image($file);

      // When the file is not an image, we show a link.
      if (count($errors)) {
        return l($file->filename, file_create_url($file->uri));
      }
      else {
        $variables['item'] = array(
          'uri' => $file->uri,
          'alt' => '',
          'title' => $file->filename,
        );
        $variables['path'] = array(
          'path' => file_create_url($file->uri),
          'options' => array(
            'html' => TRUE,
          ),
        );
        $variables['image_style'] = 'large';
        return theme('image_formatter', $variables);
      }
    }
    else {
      return t('File not found.');
    }
  }

  // When the fid is empty we can assume no file was uploaded.
  return t('n/a');
}