See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * List the tool provided in a course 19 * 20 * @package enrol_lti 21 * @copyright 2016 Mark Nelson <markn@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 use enrol_lti\local\ltiadvantage\table\published_resources_table; 26 27 require_once(__DIR__ . '/../../config.php'); 28 require_once($CFG->dirroot.'/enrol/lti/lib.php'); 29 30 $courseid = required_param('courseid', PARAM_INT); 31 $action = optional_param('action', '', PARAM_ALPHA); 32 $legacy = optional_param('legacy', false, PARAM_BOOL); 33 if ($action) { 34 require_sesskey(); 35 $instanceid = required_param('instanceid', PARAM_INT); 36 $instance = $DB->get_record('enrol', array('id' => $instanceid), '*', MUST_EXIST); 37 } 38 $confirm = optional_param('confirm', 0, PARAM_INT); 39 40 $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); 41 42 $context = context_course::instance($course->id); 43 44 require_login($course); 45 require_capability('moodle/course:enrolreview', $context); 46 47 $ltiplugin = enrol_get_plugin('lti'); 48 $canconfig = has_capability('moodle/course:enrolconfig', $context); 49 $pageurl = new moodle_url('/enrol/lti/index.php', array('courseid' => $courseid, 'legacy' => $legacy)); 50 51 $PAGE->set_url($pageurl); 52 $PAGE->set_title(get_string('course') . ': ' . $course->fullname); 53 $PAGE->set_pagelayout('admin'); 54 55 // Check if we want to perform any actions. 56 if ($action) { 57 if ($action === 'delete') { 58 if ($ltiplugin->can_delete_instance($instance)) { 59 if ($confirm) { 60 $ltiplugin->delete_instance($instance); 61 redirect($PAGE->url); 62 } 63 64 $yesurl = new moodle_url('/enrol/lti/index.php', 65 array('courseid' => $course->id, 66 'action' => 'delete', 67 'instanceid' => $instance->id, 68 'confirm' => 1, 69 'sesskey' => sesskey()) 70 ); 71 $displayname = $ltiplugin->get_instance_name($instance); 72 $users = $DB->count_records('user_enrolments', array('enrolid' => $instance->id)); 73 if ($users) { 74 $message = markdown_to_html(get_string('deleteinstanceconfirm', 'enrol', 75 array('name' => $displayname, 76 'users' => $users))); 77 } else { 78 $message = markdown_to_html(get_string('deleteinstancenousersconfirm', 'enrol', 79 array('name' => $displayname))); 80 } 81 echo $OUTPUT->header(); 82 echo $OUTPUT->confirm($message, $yesurl, $PAGE->url); 83 echo $OUTPUT->footer(); 84 die(); 85 } 86 } else if ($action === 'disable') { 87 if ($ltiplugin->can_hide_show_instance($instance)) { 88 if ($instance->status != ENROL_INSTANCE_DISABLED) { 89 $ltiplugin->update_status($instance, ENROL_INSTANCE_DISABLED); 90 redirect($PAGE->url); 91 } 92 } 93 } else if ($action === 'enable') { 94 if ($ltiplugin->can_hide_show_instance($instance)) { 95 if ($instance->status != ENROL_INSTANCE_ENABLED) { 96 $ltiplugin->update_status($instance, ENROL_INSTANCE_ENABLED); 97 redirect($PAGE->url); 98 } 99 } 100 } 101 } 102 103 echo $OUTPUT->header(); 104 if ($legacy) { 105 echo $OUTPUT->heading(get_string('toolsprovided', 'enrol_lti')); 106 echo html_writer::tag('p', get_string('toolsprovided_help', 'enrol_lti')); 107 } else { 108 echo $OUTPUT->heading(get_string('publishedcontent', 'enrol_lti')); 109 echo html_writer::tag('p', get_string('publishedcontent_help', 'enrol_lti')); 110 } 111 echo html_writer::tag('p', $OUTPUT->doc_link('enrol/lti/index', get_string('morehelp')), ['class' => 'helplink']); 112 113 114 // Distinguish between legacy published tools and LTI-Advantage published resources. 115 $tabs = [ 116 0 => [ 117 new tabobject('0', new moodle_url('/enrol/lti/index.php', ['courseid' => $courseid]), 118 get_string('lti13', 'enrol_lti')), 119 new tabobject('1', new moodle_url('/enrol/lti/index.php', ['legacy' => 1, 'courseid' => $courseid]), 120 get_string('ltilegacy', 'enrol_lti')), 121 ] 122 ]; 123 $selected = $legacy ? '1' : '0'; 124 echo html_writer::div(print_tabs($tabs, $selected, null, null, true), 'lti-resource-publication'); 125 126 if ($legacy) { 127 $notify = new \core\output\notification(get_string('ltilegacydeprecatednotice', 'enrol_lti'), 128 \core\output\notification::NOTIFY_WARNING); 129 echo $OUTPUT->render($notify); 130 131 if (\enrol_lti\helper::count_lti_tools(array('courseid' => $courseid, 'ltiversion' => 'LTI-1p0/LTI-2p0')) > 0) { 132 133 $table = new \enrol_lti\manage_table($courseid); 134 $table->define_baseurl($pageurl); 135 $table->out(50, false); 136 } else { 137 $notify = new \core\output\notification(get_string('notoolsprovided', 'enrol_lti'), 138 \core\output\notification::NOTIFY_INFO); 139 echo $OUTPUT->render($notify); 140 } 141 } else { 142 if (\enrol_lti\helper::count_lti_tools(array('courseid' => $courseid, 'ltiversion' => 'LTI-1p3')) > 0) { 143 $table = new published_resources_table($courseid); 144 $table->define_baseurl($pageurl); 145 $table->out(50, false); 146 } else { 147 $notify = new \core\output\notification(get_string('nopublishedcontent', 'enrol_lti'), 148 \core\output\notification::NOTIFY_INFO); 149 echo $OUTPUT->render($notify); 150 } 151 } 152 153 if ($ltiplugin->can_add_instance($course->id)) { 154 echo $OUTPUT->single_button(new moodle_url('/enrol/editinstance.php', 155 array( 156 'legacy' => $legacy, 157 'type' => 'lti', 158 'courseid' => $course->id, 159 'returnurl' => new moodle_url('/enrol/lti/index.php', ['courseid' => $course->id, 'legacy' => $legacy])) 160 ), 161 get_string('add')); 162 } 163 164 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body