Updating LTI backup / restore
[moodle.git] / mod / lti / launch.php
CommitLineData
b7e436b0
CS
1<?php\r
2// This file is part of BasicLTI4Moodle\r
3//\r
4// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)\r
5// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web\r
6// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI\r
7// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS\r
8// are already supporting or going to support BasicLTI. This project Implements the consumer\r
9// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.\r
10// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem\r
11// at the GESSI research group at UPC.\r
12// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI\r
13// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a\r
14// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.\r
15//\r
16// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis\r
17// of the Universitat Politecnica de Catalunya http://www.upc.edu\r
18// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu\r
19//\r
20// Moodle is free software: you can redistribute it and/or modify\r
21// it under the terms of the GNU General Public License as published by\r
22// the Free Software Foundation, either version 3 of the License, or\r
23// (at your option) any later version.\r
24//\r
25// Moodle is distributed in the hope that it will be useful,\r
26// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
27// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
28// GNU General Public License for more details.\r
29//\r
30// You should have received a copy of the GNU General Public License\r
31// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\r
32\r
33/**\r
34 * This file contains all necessary code to view a basiclti activity instance\r
35 *\r
73300339 36 * @package lti\r
b7e436b0
CS
37 * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis\r
38 * marc.alier@upc.edu\r
39 * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu\r
40 *\r
41 * @author Marc Alier\r
42 * @author Jordi Piguillem\r
43 * @author Nikolas Galanis\r
44 *\r
45 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\r
46 */\r
47\r
48require_once("../../config.php");\r
73300339
CS
49require_once($CFG->dirroot.'/mod/lti/lib.php');\r
50require_once($CFG->dirroot.'/mod/lti/locallib.php');\r
b7e436b0
CS
51\r
52$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or\r
53 $object = optional_param('withobject', false, PARAM_BOOL); // Launch BasicLTI in an object\r
54\r
55if ($id) {\r
56 if (! $cm = $DB->get_record("course_modules", array("id" => $id))) {\r
57 throw new moodle_exception('generalexceptionmessage', 'error', '', 'Course Module ID was incorrect');\r
58 }\r
59\r
60 if (! $course = $DB->get_record("course", array("id" => $cm->course))) {\r
61 throw new moodle_exception('generalexceptionmessage', 'error', '', 'Course is misconfigured');\r
62 }\r
63\r
73300339 64 if (! $basiclti = $DB->get_record("lti", array("id" => $cm->instance))) {\r
b7e436b0
CS
65 throw new moodle_exception('generalexceptionmessage', 'error', '', 'Course module is incorrect');\r
66 }\r
67\r
68} else {\r
73300339 69 if (! $basiclti = $DB->get_record("lti", array("id" => $a))) {\r
b7e436b0
CS
70 throw new moodle_exception('generalexceptionmessage', 'error', '', 'Course module is incorrect');\r
71 }\r
72 if (! $course = $DB->get_record("course", array("id" => $basiclti->course))) {\r
73 throw new moodle_exception('generalexceptionmessage', 'error', '', 'Course is misconfigured');\r
74 }\r
73300339 75 if (! $cm = get_coursemodule_from_instance("lti", $basiclti->id, $course->id)) {\r
b7e436b0
CS
76 throw new moodle_exception('generalexceptionmessage', 'error', '', 'Course Module ID was incorrect');\r
77 }\r
78}\r
79\r
80require_login($course);\r
81\r
73300339 82add_to_log($course->id, "lti", "launch", "launch.php?id=$cm->id", "$basiclti->id");\r
b7e436b0 83\r
73300339 84lti_view($basiclti, $object);\r
b7e436b0 85\r