|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00028 require_once(dirname(__FILE__) . "/../../config.php"); 00029 require_once($CFG->dirroot . '/mod/lti/locallib.php'); 00030 00031 $courseid = required_param('course', PARAM_INT); 00032 00033 require_login($courseid, false); 00034 00035 $action = required_param('action', PARAM_TEXT); 00036 00037 $response = new stdClass(); 00038 00039 switch ($action) { 00040 case 'find_tool_config': 00041 $toolurl = required_param('toolurl', PARAM_RAW); 00042 $toolid = optional_param('toolid', 0, PARAM_INT); 00043 00044 if(empty($toolid) && !empty($toolurl)){ 00045 $tool = lti_get_tool_by_url_match($toolurl, $courseid); 00046 00047 if(!empty($tool)){ 00048 $toolid = $tool->id; 00049 00050 $response->toolid = $tool->id; 00051 $response->toolname = htmlspecialchars($tool->name); 00052 $response->tooldomain = htmlspecialchars($tool->tooldomain); 00053 } 00054 } else { 00055 $response->toolid = $toolid; 00056 } 00057 00058 if (!empty($toolid)) { 00059 // Look up privacy settings 00060 $query = ' 00061 SELECT name, value 00062 FROM {lti_types_config} 00063 WHERE 00064 typeid = :typeid 00065 AND name IN (\'sendname\', \'sendemailaddr\', \'acceptgrades\') 00066 '; 00067 00068 $privacyconfigs = $DB->get_records_sql($query, array('typeid' => $toolid)); 00069 foreach($privacyconfigs as $config){ 00070 $configname = $config->name; 00071 $response->$configname = $config->value; 00072 } 00073 } 00074 break; 00075 } 00076 00077 echo json_encode($response); 00078 00079 die;