Skip to content

Commit

Permalink
#232 Backport bugfixes from v0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastsg committed Oct 10, 2024
1 parent bc66482 commit c91888b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org).

## [Unreleased]

## [0.7.0] - planned 2023-04-28
## [0.7.1] - 2024-10-10

- Fixed bug with uploaded images in questions not being displayed
- Fixed edit/preview action links in question list

## [0.7.0] - 2023-04-28

+ Upgraded to work with Moodle 4.0

Expand Down
6 changes: 3 additions & 3 deletions classes/output/question_attempt_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function render() : string {
if ($attempt->is_answered()) {
return $this->render_review($attempt);
} else if ($attempt->is_pending()) {
return $this->render_attempt($attempt, $this->attempt_display_options());
return $this->render_attempt($attempt, self::attempt_display_options($this->capquiz->context()));
}
}
return get_string('you_finished_capquiz', 'capquiz');
Expand Down Expand Up @@ -272,9 +272,9 @@ private function review_display_options() : \question_display_options {
*
* @return \question_display_options
*/
private function attempt_display_options() : \question_display_options {
public static function attempt_display_options($context) : \question_display_options {
$options = new \question_display_options();
$options->context = $this->capquiz->context();
$options->context = $context;
$options->flags = \question_display_options::HIDDEN;
$options->marks = \question_display_options::HIDDEN;
$options->rightanswer = \question_display_options::HIDDEN;
Expand Down
4 changes: 2 additions & 2 deletions classes/output/question_list_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ private function render_questions(capquiz_question_list $qlist) {
for ($i = 0; $i < $qlist->question_count(); $i++) {
$question = $questions[$i];
$courseid = $question->course_id();
$editurl = new \moodle_url($CFG->wwwroot . '/question/question.php', [
$editurl = new \moodle_url('/question/bank/editquestion/question.php', [
'courseid' => $courseid,
'id' => $question->question_id()
]);
$previewurl = new \moodle_url($CFG->wwwroot . '/question/preview.php', [
$previewurl = new \moodle_url('/question/bank/previewquestion/preview.php', [
'courseid' => $courseid,
'id' => $question->question_id()
]);
Expand Down
36 changes: 36 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

use mod_capquiz\capquiz;
use mod_capquiz\output\question_attempt_renderer;

defined('MOODLE_INTERNAL') || die();

Expand Down Expand Up @@ -238,6 +239,41 @@ function capquiz_reset_gradebook($courseid, $type = '') {
}
}

/**
* Serve question files.
*
* @param stdClass $course
* @param stdClass $context
* @param string $component
* @param string $filearea
* @param int $qubaid
* @param int $slot
* @param array $args
* @param bool $forcedownload
* @param array $options
* @see quiz_question_pluginfile
*/
function capquiz_question_pluginfile(stdClass $course, stdClass $context, string $component, string $filearea,
int $qubaid, int $slot, array $args, bool $forcedownload, array $options = []): void {
global $DB;
$user = $DB->get_record('capquiz_user', ['question_usage_id' => $qubaid]);
$cm = get_coursemodule_from_instance('capquiz', $user->capquiz_id, $course->id, false, MUST_EXIST);
require_login($course, false, $cm);
$quba = question_engine::load_questions_usage_by_activity($qubaid);
$displayoptions = question_attempt_renderer::attempt_display_options(context_module::instance($cm->id));
if (!$quba->check_file_access($slot, $displayoptions, $component, $filearea, $args, $forcedownload)) {
send_file_not_found();
}
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/$context->id/$component/$filearea/$relativepath";
$file = $fs->get_file_by_hash(sha1($fullpath));
if (!$file || $file->is_directory()) {
send_file_not_found();
}
send_stored_file($file, 0, 0, $forcedownload, $options);
}

/**
* Checks if $feature is supported
*
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2023043001 ;
$plugin->version = 2023043002 ;
$plugin->requires = 2022041901 ; // 4.0
$plugin->cron = 0;
$plugin->component = 'mod_capquiz';
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '0.7.0';
$plugin->release = '0.7.1';

0 comments on commit c91888b

Please sign in to comment.