Esempio n. 1
0
/**
 * Serve question files when they are displayed in this export format.
 *
 * @param context $previewcontext the quiz context
 * @param int $questionid the question id.
 * @param context $filecontext the file (question) context
 * @param string $filecomponent the component the file belongs to.
 * @param string $filearea the file area.
 * @param array $args remaining file args.
 * @param bool $forcedownload.
 * @param array $options additional options affecting the file serving.
 */
function qformat_xhtml_questiontext_preview_pluginfile($context, $questionid,
        $args, $forcedownload, array $options = array()) {
    global $CFG;

    list($context, $course, $cm) = get_context_info_array($context->id);
    require_login($course, false, $cm);

    question_require_capability_on($questionid, 'view');

    question_send_questiontext_file($questionid, $args, $forcedownload, $options);
}
Esempio n. 2
0
/**
 * Serve questiontext files in the question text when they are displayed in this report.
 *
 * @package  mod_offlinequiz
 * @category files
 * @param stdClass $context the context
 * @param int $questionid the question id
 * @param array $args remaining file args
 * @param bool $forcedownload
 * @param array $options additional options affecting the file serving
 */
function offlinequiz_statistics_questiontext_preview_pluginfile($context, $questionid, $args, $forcedownload, array $options = array())
{
    global $CFG;
    require_once $CFG->dirroot . '/mod/offlinequiz/locallib.php';
    list($context, $course, $cm) = get_context_info_array($context->id);
    require_login($course, false, $cm);
    // Assume only trusted people can see this report. There is no real way to
    // validate questionid, becuase of the complexity of random quetsions.
    require_capability('offlinequiz/statistics:view', $context);
    question_send_questiontext_file($questionid, $args, $forcedownload, $options);
}
Esempio n. 3
0
/**
 * Serve questiontext files in the question text when they are displayed in this report.
 *
 * @package  core_files
 * @category files
 * @param stdClass $context the context
 * @param int $questionid the question id
 * @param array $args remaining file args
 * @param bool $forcedownload
 */
function core_question_questiontext_preview_pluginfile($context, $questionid, $args, $forcedownload)
{
    global $DB;
    // Verify that contextid matches the question.
    $question = $DB->get_record_sql('
            SELECT q.*, qc.contextid
              FROM {question} q
              JOIN {question_categories} qc ON qc.id = q.category
             WHERE q.id = :id AND qc.contextid = :contextid', array('id' => $questionid, 'contextid' => $context->id), MUST_EXIST);
    // Check the capability.
    list($context, $course, $cm) = get_context_info_array($context->id);
    require_login($course, false, $cm);
    question_require_capability_on($question, 'use');
    question_send_questiontext_file($questionid, $args, $forcedownload);
}