Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
// This file is part of BasicLTI4Moodle
18
//
19
// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
20
// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
21
// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
22
// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
23
// are already supporting or going to support BasicLTI. This project Implements the consumer
24
// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
25
// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
26
// at the GESSI research group at UPC.
27
// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
28
// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
29
// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
30
//
31
// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
32
// of the Universitat Politecnica de Catalunya http://www.upc.edu
33
// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu.
34
 
35
/**
36
 * This file contains the script used to clone Moodle admin setting page.
37
 *
38
 * It is used to create a new form used to pre-configure lti activities
39
 *
40
 * @package mod_lti
41
 * @copyright  2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
42
 *  marc.alier@upc.edu
43
 * @copyright  2009 Universitat Politecnica de Catalunya http://www.upc.edu
44
 * @author     Marc Alier
45
 * @author     Jordi Piguillem
46
 * @author     Nikolas Galanis
47
 * @author     Chris Scribner
48
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
49
 */
50
 
51
require_once('../../config.php');
52
require_once($CFG->libdir.'/adminlib.php');
53
require_once($CFG->dirroot.'/mod/lti/edit_form.php');
54
require_once($CFG->dirroot.'/mod/lti/locallib.php');
55
 
56
$action       = optional_param('action', null, PARAM_ALPHANUMEXT);
57
$id           = optional_param('id', null, PARAM_INT);
58
$tab          = optional_param('tab', '', PARAM_ALPHAEXT);
59
$returnto     = optional_param('returnto', '', PARAM_ALPHA);
60
 
61
if ($returnto == 'toolconfigure') {
62
    $returnurl = new moodle_url($CFG->wwwroot . '/mod/lti/toolconfigure.php');
63
}
64
 
65
// No guest autologin.
66
require_login(0, false);
67
 
68
require_sesskey();
69
 
70
// Check this is not for a tool created from a tool proxy.
71
if (!empty($id)) {
72
    $type = lti_get_type_type_config($id);
73
    if (!empty($type->toolproxyid)) {
74
        $sesskey = required_param('sesskey', PARAM_RAW);
75
        $params = array('action' => $action, 'id' => $id, 'sesskey' => $sesskey, 'tab' => $tab);
76
        if (!empty($returnto)) {
77
            $params['returnto'] = $returnto;
78
        }
79
        $redirect = new moodle_url('/mod/lti/toolssettings.php', $params);
80
        redirect($redirect);
81
    }
82
    $type->lti_coursecategories = '';
83
    if ($records = $DB->get_fieldset_select('lti_types_categories', 'categoryid', 'typeid = :typeid',
84
            ['typeid' => $id])) {
85
        $type->lti_coursecategories = implode(',', $records);
86
    }
87
} else {
88
    $type = new stdClass();
89
    // Assign a default empty value for the lti_icon.
90
    $type->lti_icon = '';
91
    $type->lti_secureicon = '';
92
 
93
    $type->lti_clientid = null;
94
    $type->lti_coursecategories = '';
95
}
96
 
97
$pageurl = new moodle_url('/mod/lti/typessettings.php');
98
if (!empty($id)) {
99
    $pageurl->param('id', $id);
100
}
101
if (!empty($returnto)) {
102
    $pageurl->param('returnto', $returnto);
103
}
104
$PAGE->set_url($pageurl);
105
 
106
admin_externalpage_setup('managemodules'); // Hacky solution for printing the admin page.
107
 
108
$redirect = "$CFG->wwwroot/$CFG->admin/settings.php?section=modsettinglti&tab={$tab}";
109
if (!empty($returnurl)) {
110
    $redirect = $returnurl;
111
}
112
 
113
if ($action == 'accept') {
114
    lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);
115
    redirect($redirect);
116
} else if ($action == 'reject') {
117
    lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);
118
    redirect($redirect);
119
} else if ($action == 'delete') {
120
    lti_delete_type($id);
121
    redirect($redirect);
122
}
123
 
124
if (lti_request_is_using_ssl() && !empty($type->lti_secureicon)) {
125
    $type->oldicon = $type->lti_secureicon;
126
} else {
127
    $type->oldicon = $type->lti_icon;
128
}
129
 
130
$form = new mod_lti_edit_types_form(
131
    $pageurl,
132
    (object) [
133
        'isadmin' => true,
134
        'istool' => false,
135
        'id' => $id,
136
        'clientid' => $type->lti_clientid,
137
        'coursecategories' => $type->lti_coursecategories,
138
        'iscoursetool' => !empty($id) && $type->course !== get_site()->id
139
    ]
140
);
141
 
142
if ($data = $form->get_data()) {
143
    $type = new stdClass();
144
    if (!empty($id)) {
145
        $type->id = $id;
146
        lti_load_type_if_cartridge($data);
147
        lti_update_type($type, $data);
148
 
149
        redirect($redirect);
150
    } else {
151
        $type->state = LTI_TOOL_STATE_CONFIGURED;
152
        lti_load_type_if_cartridge($data);
153
        lti_add_type($type, $data);
154
 
155
        redirect($redirect);
156
    }
157
} else if ($form->is_cancelled()) {
158
    redirect($redirect);
159
}
160
 
161
$PAGE->set_title(get_string('toolsetup', 'lti'));
162
$PAGE->set_primary_active_tab('siteadminnode');
163
$PAGE->set_secondary_active_tab('ltitoolconfigure');
164
$PAGE->navbar->add(get_string('manage_external_tools', 'lti'), new moodle_url('/mod/lti/toolconfigure.php'));
165
$PAGE->navbar->add(get_string('toolsetup', 'lti'), $PAGE->url);
166
$PAGE->requires->js_call_amd('mod_lti/coursecategory', 'init', [$type->lti_coursecategories]);
167
 
168
echo $OUTPUT->header();
169
echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
170
echo $OUTPUT->box_start('generalbox');
171
 
172
if ($action == 'update') {
173
    $form->set_data($type);
174
}
175
 
176
$form->display();
177
echo $OUTPUT->box_end();
178
echo $OUTPUT->footer();