Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lti/mod_form.php
Go to the documentation of this file.
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 //
00017 // This file is part of BasicLTI4Moodle
00018 //
00019 // BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
00020 // consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
00021 // based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
00022 // specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
00023 // are already supporting or going to support BasicLTI. This project Implements the consumer
00024 // for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
00025 // BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
00026 // at the GESSI research group at UPC.
00027 // SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
00028 // by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
00029 // Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
00030 //
00031 // BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
00032 // of the Universitat Politecnica de Catalunya http://www.upc.edu
00033 // Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
00034 
00050 defined('MOODLE_INTERNAL') || die;
00051 
00052 require_once($CFG->dirroot.'/course/moodleform_mod.php');
00053 require_once($CFG->dirroot.'/mod/lti/locallib.php');
00054 
00055 class mod_lti_mod_form extends moodleform_mod {
00056 
00057     public function definition() {
00058         global $DB, $PAGE, $OUTPUT, $USER, $COURSE;
00059 
00060         $this->typeid = 0;
00061 
00062         $mform =& $this->_form;
00063         //-------------------------------------------------------------------------------
00064         // Adding the "general" fieldset, where all the common settings are shown
00065         $mform->addElement('header', 'general', get_string('general', 'form'));
00066         // Adding the standard "name" field
00067         $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64'));
00068         $mform->setType('name', PARAM_TEXT);
00069         $mform->addRule('name', null, 'required', null, 'client');
00070         // Adding the optional "intro" and "introformat" pair of fields
00071         $this->add_intro_editor(false, get_string('basicltiintro', 'lti'));
00072         $mform->setAdvanced('introeditor');
00073 
00074         // Display the label to the right of the checkbox so it looks better & matches rest of the form
00075         $coursedesc = $mform->getElement('showdescription');
00076         if(!empty($coursedesc)){
00077             $coursedesc->setText(' ' . $coursedesc->getLabel());
00078             $coursedesc->setLabel('&nbsp');
00079         }
00080 
00081         $mform->setAdvanced('showdescription');
00082 
00083         $mform->addElement('checkbox', 'showtitlelaunch', '&nbsp;', ' ' . get_string('display_name', 'lti'));
00084         $mform->setAdvanced('showtitlelaunch');
00085         $mform->addHelpButton('showtitlelaunch', 'display_name', 'lti');
00086 
00087         $mform->addElement('checkbox', 'showdescriptionlaunch', '&nbsp;', ' ' . get_string('display_description', 'lti'));
00088         $mform->setAdvanced('showdescriptionlaunch');
00089         $mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti');
00090 
00091         // Tool settings
00092         $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array());
00093         $mform->addHelpButton('typeid', 'external_tool_type', 'lti');
00094 
00095         foreach (lti_get_types_for_add_instance() as $id => $type) {
00096             if ($type->course == $COURSE->id) {
00097                 $attributes = array( 'editable' => 1, 'courseTool' => 1, 'domain' => $type->tooldomain );
00098             } else if ($id != 0) {
00099                 $attributes = array( 'globalTool' => 1, 'domain' => $type->tooldomain);
00100             } else {
00101                 $attributes = array();
00102             }
00103 
00104             $tooltypes->addOption($type->name, $id, $attributes);
00105         }
00106 
00107         $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size'=>'64'));
00108         $mform->setType('toolurl', PARAM_TEXT);
00109         $mform->addHelpButton('toolurl', 'launch_url', 'lti');
00110 
00111         $mform->addElement('text', 'securetoolurl', get_string('secure_launch_url', 'lti'), array('size'=>'64'));
00112         $mform->setType('securetoolurl', PARAM_TEXT);
00113         $mform->setAdvanced('securetoolurl');
00114         $mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti');
00115 
00116         $launchoptions=array();
00117         $launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti');
00118         $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti');
00119         $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti');
00120         $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti');
00121 
00122         $mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions);
00123         $mform->setDefault('launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT);
00124         $mform->addHelpButton('launchcontainer', 'launchinpopup', 'lti');
00125 
00126         $mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti'));
00127         $mform->setType('resourcekey', PARAM_TEXT);
00128         $mform->setAdvanced('resourcekey');
00129         $mform->addHelpButton('resourcekey', 'resourcekey', 'lti');
00130 
00131         $mform->addElement('passwordunmask', 'password', get_string('password', 'lti'));
00132         $mform->setType('password', PARAM_TEXT);
00133         $mform->setAdvanced('password');
00134         $mform->addHelpButton('password', 'password', 'lti');
00135 
00136         $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60));
00137         $mform->setType('instructorcustomparameters', PARAM_TEXT);
00138         $mform->setAdvanced('instructorcustomparameters');
00139         $mform->addHelpButton('instructorcustomparameters', 'custom', 'lti');
00140 
00141         $mform->addElement('text', 'icon', get_string('icon_url', 'lti'), array('size'=>'64'));
00142         $mform->setType('icon', PARAM_TEXT);
00143         $mform->setAdvanced('icon');
00144         $mform->addHelpButton('icon', 'icon_url', 'lti');
00145 
00146         $mform->addElement('text', 'secureicon', get_string('secure_icon_url', 'lti'), array('size'=>'64'));
00147         $mform->setType('secureicon', PARAM_TEXT);
00148         $mform->setAdvanced('secureicon');
00149         $mform->addHelpButton('secureicon', 'secure_icon_url', 'lti');
00150 
00151         //-------------------------------------------------------------------------------
00152         // Add privacy preferences fieldset where users choose whether to send their data
00153         $mform->addElement('header', 'privacy', get_string('privacy', 'lti'));
00154 
00155         $mform->addElement('checkbox', 'instructorchoicesendname', '&nbsp;', ' ' . get_string('share_name', 'lti'));
00156         $mform->setDefault('instructorchoicesendname', '1');
00157         $mform->addHelpButton('instructorchoicesendname', 'share_name', 'lti');
00158 
00159         $mform->addElement('checkbox', 'instructorchoicesendemailaddr', '&nbsp;', ' ' . get_string('share_email', 'lti'));
00160         $mform->setDefault('instructorchoicesendemailaddr', '1');
00161         $mform->addHelpButton('instructorchoicesendemailaddr', 'share_email', 'lti');
00162 
00163         $mform->addElement('checkbox', 'instructorchoiceacceptgrades', '&nbsp;', ' ' . get_string('accept_grades', 'lti'));
00164         $mform->setDefault('instructorchoiceacceptgrades', '1');
00165         $mform->addHelpButton('instructorchoiceacceptgrades', 'accept_grades', 'lti');
00166 
00167         //$mform->addElement('checkbox', 'instructorchoiceallowroster', '&nbsp;', ' ' . get_string('share_roster', 'lti'));
00168         //$mform->setDefault('instructorchoiceallowroster', '1');
00169         //$mform->addHelpButton('instructorchoiceallowroster', 'share_roster', 'lti');
00170 
00171         //-------------------------------------------------------------------------------
00172 
00189         //-------------------------------------------------------------------------------
00190         // add standard elements, common to all modules
00191         $this->standard_coursemodule_elements();
00192         $mform->setAdvanced('cmidnumber');
00193         //-------------------------------------------------------------------------------
00194         // add standard buttons, common to all modules
00195         $this->add_action_buttons();
00196 
00197         $editurl = new moodle_url("/mod/lti/instructor_edit_tool_type.php?sesskey={$USER->sesskey}&course={$COURSE->id}");
00198         $ajaxurl = new moodle_url('/mod/lti/ajax.php');
00199 
00200         $jsinfo = (object)array(
00201                         'edit_icon_url' => (string)$OUTPUT->pix_url('t/edit'),
00202                         'add_icon_url' => (string)$OUTPUT->pix_url('t/add'),
00203                         'delete_icon_url' => (string)$OUTPUT->pix_url('t/delete'),
00204                         'green_check_icon_url' => (string)$OUTPUT->pix_url('i/tick_green_small'),
00205                         'warning_icon_url' => (string)$OUTPUT->pix_url('warning', 'lti'),
00206                         'instructor_tool_type_edit_url' => $editurl->out(false),
00207                         'ajax_url' => $ajaxurl->out(true),
00208                         'courseId' => $COURSE->id
00209                   );
00210 
00211         $module = array(
00212             'name'      => 'mod_lti_edit',
00213             'fullpath'  => '/mod/lti/mod_form.js',
00214             'requires'  => array('base', 'io', 'querystring-stringify-simple', 'node', 'event', 'json-parse'),
00215             'strings'   => array(
00216                 array('addtype', 'lti'),
00217                 array('edittype', 'lti'),
00218                 array('deletetype', 'lti'),
00219                 array('delete_confirmation', 'lti'),
00220                 array('cannot_edit', 'lti'),
00221                 array('cannot_delete', 'lti'),
00222                 array('global_tool_types', 'lti'),
00223                 array('course_tool_types', 'lti'),
00224                 array('using_tool_configuration', 'lti'),
00225                 array('domain_mismatch', 'lti'),
00226                 array('custom_config', 'lti'),
00227                 array('tool_config_not_found', 'lti'),
00228                 array('forced_help', 'lti')
00229             ),
00230         );
00231 
00232         $PAGE->requires->js_init_call('M.mod_lti.editor.init', array(json_encode($jsinfo)), true, $module);
00233     }
00234 
00239     public function definition_after_data() {
00240         parent::definition_after_data();
00241 
00242         //$mform =& $this->_form;
00243     }
00244 
00251     public function data_preprocessing(&$default_values) {
00252 
00253     }
00254 }
00255 
 All Data Structures Namespaces Files Functions Variables Enumerations