MDL-71913 mod_h5pactivity: Add attempts report setting node

This commit is contained in:
Mihail Geshoski 2021-06-22 16:43:26 +08:00
parent 77e9f45157
commit 3e97273b21
4 changed files with 33 additions and 16 deletions

View File

@ -124,8 +124,6 @@ class participants extends table_sql implements report {
$this->define_baseurl($PAGE->url);
echo $OUTPUT->heading(get_string('attempts_report', 'mod_h5pactivity'));
$this->out($this->get_page_size(), true);
}

View File

@ -823,3 +823,31 @@ function h5pactivity_fetch_recent_activity(array $submissions, int $courseid) :
return $recentactivity;
}
/**
* Extends the settings navigation with the H5P activity settings
* This function is called when the context for the page is an H5P activity. This is not called by AJAX
* so it is safe to rely on the $PAGE.
*
* @param settings_navigation $settingsnav The settings navigation object
* @param navigation_node $h5pactivitynode The node to add module settings to
*/
function h5pactivity_extend_settings_navigation(settings_navigation $settingsnav,
navigation_node $h5pactivitynode = null) {
global $PAGE, $USER;
$manager = manager::create_from_coursemodule($PAGE->cm);
// Attempts report.
if ($manager->can_view_all_attempts()) {
$attemptsreporturl = new moodle_url('/mod/h5pactivity/report.php', ['a' => $PAGE->cm->instance]);
$h5pactivitynode->add(get_string('attempts_report', 'h5pactivity'), $attemptsreporturl,
settings_navigation::TYPE_SETTING, '', 'attemptsreport');
} else if ($manager->can_view_own_attempts() && $manager->count_attempts($USER->id)) {
$attemptsreporturl = new moodle_url('/mod/h5pactivity/report.php',
['a' => $PAGE->cm->instance, 'userid' => $USER->id]);
$h5pactivitynode->add(get_string('attempts_report', 'h5pactivity'), $attemptsreporturl,
settings_navigation::TYPE_SETTING, '', 'attemptsreport');
}
}

View File

@ -125,6 +125,8 @@ $PAGE->set_context($context);
echo $OUTPUT->header();
echo html_writer::start_div('mt-4');
echo $report->print();
echo html_writer::end_div();
echo $OUTPUT->footer();

View File

@ -68,7 +68,9 @@ $PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($moduleinstance->name));
if (!$PAGE->has_secondary_navigation()) {
echo $OUTPUT->heading(format_string($moduleinstance->name));
}
// Render the activity information.
$completiondetails = \core_completion\cm_completion_details::get_instance($cm, $USER->id);
@ -80,19 +82,6 @@ if (!empty($instance->intro)) {
echo $OUTPUT->box(format_module_intro('h5pactivity', $instance, $cm->id), 'generalbox', 'intro');
}
// Attempts review.
if ($manager->can_view_all_attempts()) {
$reviewurl = new moodle_url('report.php', ['a' => $cm->instance]);
$reviewmessage = get_string('review_all_attempts', 'mod_h5pactivity', $manager->count_attempts());
} else if ($manager->can_view_own_attempts() && $manager->count_attempts($USER->id)) {
$reviewurl = new moodle_url('report.php', ['a' => $cm->instance, 'userid' => $USER->id]);
$reviewmessage = get_string('review_my_attempts', 'mod_h5pactivity');
}
if (isset($reviewurl)) {
$widget = new mod_h5pactivity\output\reportlink($reviewurl, $reviewmessage);
echo $OUTPUT->render($widget);
}
if (!$manager->is_tracking_enabled()) {
$message = get_string('previewmode', 'mod_h5pactivity');
echo $OUTPUT->notification($message, \core\output\notification::NOTIFY_WARNING);