public function definition() { global $CFG, $DB, $PAGE, $OUTPUT, $USER, $COURSE; require_once $CFG->dirroot . '/blocks/pearson/locallib.php'; // check capabilities and throw error if needed has_capability('mod/pearson:addinstance', context_course::instance($COURSE->id)); $this->typeid = 0; $mform =& $this->_form; if (pearsondirect_is_global_configured()) { if (pearsondirect_course_has_config($COURSE->id)) { $data = $this->current; $mform->addElement('hidden', 'pdcourseid', $data->course); $mform->addElement('hidden', 'pdsection', $data->section); $mform->addElement('header', 'product', get_string('addlinkheader', 'mod_pearson')); $availablelinks = array(); foreach (lti_get_types_for_add_instance() as $id => $type) { if ($type->course == $COURSE->id) { $idnumber = $type->tooldomain; if (!strncmp($idnumber, 'pearson:', strlen('pearson:'))) { $availablelinks[$type->id] = $type->name; } } } $mform->addElement('select', 'selectedlink', get_string('selectedlink', 'mod_pearson'), $availablelinks); $mform->addHelpButton('selectedlink', 'selectedlink', 'mod_pearson'); $mform->setType('selectedlink', PARAM_TEXT); $mform->addRule('selectedlink', null, 'required', null, 'client'); $mform->addElement('text', 'linktitle', get_string('linktitle', 'mod_pearson'), ''); $mform->addHelpButton('linktitle', 'linktitle', 'mod_pearson'); $mform->addElement('text', 'customparams', get_string('customparams', 'mod_pearson'), array('size' => '64')); $mform->addHelpButton('customparams', 'customparams', 'mod_pearson'); $mform->addElement('header', 'media', get_string('addmediaheader', 'mod_pearson')); $mform->addElement('text', 'mediaurl', get_string('mediaurl', 'mod_pearson'), array('size' => '64')); $mform->addHelpButton('mediaurl', 'mediaurl', 'mod_pearson'); $mform->addElement('text', 'mediaurltitle', get_string('mediaurltitle', 'mod_pearson'), ''); $mform->addHelpButton('mediaurltitle', 'mediaurltitle', 'mod_pearson'); $mform->addElement('header', 'lauchpresentation', get_string('lauchpresentationheader', 'mod_pearson')); $mform->addElement('checkbox', 'inframe', get_string('inframe', 'mod_pearson')); $mform->addHelpButton('inframe', 'inframe', 'mod_pearson'); // add standard elements, common to all modules $this->standard_coursemodule_elements(); // add standard buttons, common to all modules $this->add_action_buttons(); } else { $mform->addElement('header', 'moduleheader', 'Module settings'); $mform->addElement('static', 'info', '', get_string('pearson_blocknotconfigured', 'block_pearson')); // add standard elements, common to all modules $this->standard_coursemodule_elements(); // add standard buttons, common to all modules $this->add_action_buttons(true, false, false); } } else { $mform->addElement('header', 'moduleheader', 'Module settings'); $mform->addElement('static', 'info', '', get_string('pearson_notconfigured', 'block_pearson')); // add standard elements, common to all modules $this->standard_coursemodule_elements(); // add standard buttons, common to all modules $this->add_action_buttons(true, false, false); } }
public function definition() { global $DB, $PAGE, $OUTPUT, $USER, $COURSE; $this->typeid = 0; $mform =& $this->_form; //------------------------------------------------------------------------------- // Adding the "general" fieldset, where all the common settings are shown $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size'=>'64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); // Adding the optional "intro" and "introformat" pair of fields $this->add_intro_editor(false, get_string('basicltiintro', 'lti')); $mform->setAdvanced('introeditor'); // Display the label to the right of the checkbox so it looks better & matches rest of the form $coursedesc = $mform->getElement('showdescription'); if(!empty($coursedesc)){ $coursedesc->setText(' ' . $coursedesc->getLabel()); $coursedesc->setLabel(' '); } $mform->setAdvanced('showdescription'); $mform->addElement('checkbox', 'showtitlelaunch', ' ', ' ' . get_string('display_name', 'lti')); $mform->setAdvanced('showtitlelaunch'); $mform->addHelpButton('showtitlelaunch', 'display_name', 'lti'); $mform->addElement('checkbox', 'showdescriptionlaunch', ' ', ' ' . get_string('display_description', 'lti')); $mform->setAdvanced('showdescriptionlaunch'); $mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti'); // Tool settings $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array()); $mform->addHelpButton('typeid', 'external_tool_type', 'lti'); foreach (lti_get_types_for_add_instance() as $id => $type) { if ($type->course == $COURSE->id) { $attributes = array( 'editable' => 1, 'courseTool' => 1, 'domain' => $type->tooldomain ); } else if ($id != 0) { $attributes = array( 'globalTool' => 1, 'domain' => $type->tooldomain); } else { $attributes = array(); } $tooltypes->addOption($type->name, $id, $attributes); } $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size'=>'64')); $mform->setType('toolurl', PARAM_TEXT); $mform->addHelpButton('toolurl', 'launch_url', 'lti'); $mform->addElement('text', 'securetoolurl', get_string('secure_launch_url', 'lti'), array('size'=>'64')); $mform->setType('securetoolurl', PARAM_TEXT); $mform->setAdvanced('securetoolurl'); $mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti'); $launchoptions=array(); $launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti'); $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti'); $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti'); $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti'); $mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions); $mform->setDefault('launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT); $mform->addHelpButton('launchcontainer', 'launchinpopup', 'lti'); $mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti')); $mform->setType('resourcekey', PARAM_TEXT); $mform->setAdvanced('resourcekey'); $mform->addHelpButton('resourcekey', 'resourcekey', 'lti'); $mform->addElement('passwordunmask', 'password', get_string('password', 'lti')); $mform->setType('password', PARAM_TEXT); $mform->setAdvanced('password'); $mform->addHelpButton('password', 'password', 'lti'); $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows'=>4, 'cols'=>60)); $mform->setType('instructorcustomparameters', PARAM_TEXT); $mform->setAdvanced('instructorcustomparameters'); $mform->addHelpButton('instructorcustomparameters', 'custom', 'lti'); $mform->addElement('text', 'icon', get_string('icon_url', 'lti'), array('size'=>'64')); $mform->setType('icon', PARAM_TEXT); $mform->setAdvanced('icon'); $mform->addHelpButton('icon', 'icon_url', 'lti'); $mform->addElement('text', 'secureicon', get_string('secure_icon_url', 'lti'), array('size'=>'64')); $mform->setType('secureicon', PARAM_TEXT); $mform->setAdvanced('secureicon'); $mform->addHelpButton('secureicon', 'secure_icon_url', 'lti'); //------------------------------------------------------------------------------- // Add privacy preferences fieldset where users choose whether to send their data $mform->addElement('header', 'privacy', get_string('privacy', 'lti')); $mform->addElement('checkbox', 'instructorchoicesendname', ' ', ' ' . get_string('share_name', 'lti')); $mform->setDefault('instructorchoicesendname', '1'); $mform->addHelpButton('instructorchoicesendname', 'share_name', 'lti'); $mform->addElement('checkbox', 'instructorchoicesendemailaddr', ' ', ' ' . get_string('share_email', 'lti')); $mform->setDefault('instructorchoicesendemailaddr', '1'); $mform->addHelpButton('instructorchoicesendemailaddr', 'share_email', 'lti'); $mform->addElement('checkbox', 'instructorchoiceacceptgrades', ' ', ' ' . get_string('accept_grades', 'lti')); $mform->setDefault('instructorchoiceacceptgrades', '1'); $mform->addHelpButton('instructorchoiceacceptgrades', 'accept_grades', 'lti'); //$mform->addElement('checkbox', 'instructorchoiceallowroster', ' ', ' ' . get_string('share_roster', 'lti')); //$mform->setDefault('instructorchoiceallowroster', '1'); //$mform->addHelpButton('instructorchoiceallowroster', 'share_roster', 'lti'); //------------------------------------------------------------------------------- /** $debugoptions=array(); $debugoptions[0] = get_string('debuglaunchoff', 'lti'); $debugoptions[1] = get_string('debuglaunchon', 'lti'); $mform->addElement('select', 'debuglaunch', get_string('debuglaunch', 'lti'), $debugoptions); if (isset($this->typeconfig['debuglaunch'])) { if ($this->typeconfig['debuglaunch'] == 0) { $mform->setDefault('debuglaunch', '0'); } else if ($this->typeconfig['debuglaunch'] == 1) { $mform->setDefault('debuglaunch', '1'); } } */ //------------------------------------------------------------------------------- // add standard elements, common to all modules $this->standard_coursemodule_elements(); $mform->setAdvanced('cmidnumber'); //------------------------------------------------------------------------------- // add standard buttons, common to all modules $this->add_action_buttons(); $editurl = new moodle_url("/mod/lti/instructor_edit_tool_type.php?sesskey={$USER->sesskey}&course={$COURSE->id}"); $ajaxurl = new moodle_url('/mod/lti/ajax.php'); $jsinfo = (object)array( 'edit_icon_url' => (string)$OUTPUT->pix_url('t/edit'), 'add_icon_url' => (string)$OUTPUT->pix_url('t/add'), 'delete_icon_url' => (string)$OUTPUT->pix_url('t/delete'), 'green_check_icon_url' => (string)$OUTPUT->pix_url('i/valid'), 'warning_icon_url' => (string)$OUTPUT->pix_url('warning', 'lti'), 'instructor_tool_type_edit_url' => $editurl->out(false), 'ajax_url' => $ajaxurl->out(true), 'courseId' => $COURSE->id ); $module = array( 'name' => 'mod_lti_edit', 'fullpath' => '/mod/lti/mod_form.js', 'requires' => array('base', 'io', 'querystring-stringify-simple', 'node', 'event', 'json-parse'), 'strings' => array( array('addtype', 'lti'), array('edittype', 'lti'), array('deletetype', 'lti'), array('delete_confirmation', 'lti'), array('cannot_edit', 'lti'), array('cannot_delete', 'lti'), array('global_tool_types', 'lti'), array('course_tool_types', 'lti'), array('using_tool_configuration', 'lti'), array('domain_mismatch', 'lti'), array('custom_config', 'lti'), array('tool_config_not_found', 'lti'), array('forced_help', 'lti') ), ); $PAGE->requires->js_init_call('M.mod_lti.editor.init', array(json_encode($jsinfo)), true, $module); }
public function definition() { global $PAGE, $OUTPUT, $COURSE; if ($type = optional_param('type', false, PARAM_ALPHA)) { component_callback("ltisource_{$type}", 'add_instance_hook'); } $this->typeid = 0; $mform =& $this->_form; // Adding the "general" fieldset, where all the common settings are shown. $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field. $mform->addElement('text', 'name', get_string('basicltiname', 'lti'), array('size' => '64')); $mform->setType('name', PARAM_TEXT); $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); // Adding the optional "intro" and "introformat" pair of fields. $this->standard_intro_elements(get_string('basicltiintro', 'lti')); $mform->setAdvanced('introeditor'); // Display the label to the right of the checkbox so it looks better & matches rest of the form. if ($mform->elementExists('showdescription')) { $coursedesc = $mform->getElement('showdescription'); if (!empty($coursedesc)) { $coursedesc->setText(' ' . $coursedesc->getLabel()); $coursedesc->setLabel(' '); } } $mform->setAdvanced('showdescription'); $mform->addElement('checkbox', 'showtitlelaunch', ' ', ' ' . get_string('display_name', 'lti')); $mform->setAdvanced('showtitlelaunch'); $mform->setDefault('showtitlelaunch', true); $mform->addHelpButton('showtitlelaunch', 'display_name', 'lti'); $mform->addElement('checkbox', 'showdescriptionlaunch', ' ', ' ' . get_string('display_description', 'lti')); $mform->setAdvanced('showdescriptionlaunch'); $mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti'); // Tool settings. $attributes = array(); if ($update = optional_param('update', false, PARAM_INT)) { $attributes['disabled'] = 'disabled'; } $attributes['class'] = 'lti_contentitem'; $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array(), $attributes); $typeid = optional_param('typeid', false, PARAM_INT); $mform->getElement('typeid')->setValue($typeid); $mform->addHelpButton('typeid', 'external_tool_type', 'lti'); $toolproxy = array(); // Array of tool type IDs that don't support ContentItemSelectionRequest. $noncontentitemtypes = []; foreach (lti_get_types_for_add_instance() as $id => $type) { if (!empty($type->toolproxyid)) { $toolproxy[] = $type->id; $attributes = array('globalTool' => 1, 'toolproxy' => 1); $enabledcapabilities = explode("\n", $type->enabledcapability); if (!in_array('Result.autocreate', $enabledcapabilities)) { $attributes['nogrades'] = 1; } if (!in_array('Person.name.full', $enabledcapabilities) && !in_array('Person.name.family', $enabledcapabilities) && !in_array('Person.name.given', $enabledcapabilities)) { $attributes['noname'] = 1; } if (!in_array('Person.email.primary', $enabledcapabilities)) { $attributes['noemail'] = 1; } } else { if ($type->course == $COURSE->id) { $attributes = array('editable' => 1, 'courseTool' => 1, 'domain' => $type->tooldomain); } else { if ($id != 0) { $attributes = array('globalTool' => 1, 'domain' => $type->tooldomain); } else { $attributes = array(); } } } if (!$update && $id) { $config = lti_get_type_config($id); if (!empty($config['contentitem'])) { $attributes['data-contentitem'] = 1; $attributes['data-id'] = $id; } else { $noncontentitemtypes[] = $id; } } $tooltypes->addOption($type->name, $id, $attributes); } // Add button that launches the content-item selection dialogue. // Set contentitem URL. $contentitemurl = new moodle_url('/mod/lti/contentitem.php'); $contentbuttonattributes['data-contentitemurl'] = $contentitemurl->out(false); $mform->addElement('button', 'selectcontent', get_string('selectcontent', 'lti'), $contentbuttonattributes); if ($update) { $mform->disabledIf('selectcontent', 'typeid', 'neq', 0); } else { // Disable select content button if the selected tool doesn't support content item or it's set to Automatic. $allnoncontentitemtypes = $noncontentitemtypes; $allnoncontentitemtypes[] = '0'; // Add option value for "Automatic, based on launch URL". $mform->disabledIf('selectcontent', 'typeid', 'in', $allnoncontentitemtypes); } $mform->addElement('text', 'toolurl', get_string('launch_url', 'lti'), array('size' => '64')); $mform->setType('toolurl', PARAM_URL); $mform->addHelpButton('toolurl', 'launch_url', 'lti'); if ($update) { $mform->disabledIf('toolurl', 'typeid', 'neq', 0); } else { $mform->disabledIf('toolurl', 'typeid', 'in', $noncontentitemtypes); } $mform->addElement('text', 'securetoolurl', get_string('secure_launch_url', 'lti'), array('size' => '64')); $mform->setType('securetoolurl', PARAM_URL); $mform->setAdvanced('securetoolurl'); $mform->addHelpButton('securetoolurl', 'secure_launch_url', 'lti'); if ($update) { $mform->disabledIf('securetoolurl', 'typeid', 'neq', 0); } else { $mform->disabledIf('securetoolurl', 'typeid', 'in', $noncontentitemtypes); } $mform->addElement('hidden', 'urlmatchedtypeid', '', array('id' => 'id_urlmatchedtypeid')); $mform->setType('urlmatchedtypeid', PARAM_INT); $launchoptions = array(); $launchoptions[LTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'lti'); $launchoptions[LTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'lti'); $launchoptions[LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'lti'); $launchoptions[LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW] = get_string('existing_window', 'lti'); $launchoptions[LTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'lti'); $mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'lti'), $launchoptions); $mform->setDefault('launchcontainer', LTI_LAUNCH_CONTAINER_DEFAULT); $mform->addHelpButton('launchcontainer', 'launchinpopup', 'lti'); $mform->setAdvanced('launchcontainer'); $mform->addElement('text', 'resourcekey', get_string('resourcekey', 'lti')); $mform->setType('resourcekey', PARAM_TEXT); $mform->setAdvanced('resourcekey'); $mform->addHelpButton('resourcekey', 'resourcekey', 'lti'); if ($update) { $mform->disabledIf('resourcekey', 'typeid', 'neq', 0); } else { $mform->disabledIf('resourcekey', 'typeid', 'in', $noncontentitemtypes); } $mform->setForceLtr('resourcekey'); $mform->addElement('passwordunmask', 'password', get_string('password', 'lti')); $mform->setType('password', PARAM_TEXT); $mform->setAdvanced('password'); $mform->addHelpButton('password', 'password', 'lti'); if ($update) { $mform->disabledIf('password', 'typeid', 'neq', 0); } else { $mform->disabledIf('password', 'typeid', 'in', $noncontentitemtypes); } $mform->addElement('textarea', 'instructorcustomparameters', get_string('custom', 'lti'), array('rows' => 4, 'cols' => 60)); $mform->setType('instructorcustomparameters', PARAM_TEXT); $mform->setAdvanced('instructorcustomparameters'); $mform->addHelpButton('instructorcustomparameters', 'custom', 'lti'); $mform->setForceLtr('instructorcustomparameters'); $mform->addElement('text', 'icon', get_string('icon_url', 'lti'), array('size' => '64')); $mform->setType('icon', PARAM_URL); $mform->setAdvanced('icon'); $mform->addHelpButton('icon', 'icon_url', 'lti'); if ($update) { $mform->disabledIf('icon', 'typeid', 'neq', 0); } else { $mform->disabledIf('icon', 'typeid', 'in', $noncontentitemtypes); } $mform->addElement('text', 'secureicon', get_string('secure_icon_url', 'lti'), array('size' => '64')); $mform->setType('secureicon', PARAM_URL); $mform->setAdvanced('secureicon'); $mform->addHelpButton('secureicon', 'secure_icon_url', 'lti'); if ($update) { $mform->disabledIf('secureicon', 'typeid', 'neq', 0); } else { $mform->disabledIf('secureicon', 'typeid', 'in', $noncontentitemtypes); } // Add privacy preferences fieldset where users choose whether to send their data. $mform->addElement('header', 'privacy', get_string('privacy', 'lti')); $mform->addElement('advcheckbox', 'instructorchoicesendname', ' ', ' ' . get_string('share_name', 'lti')); $mform->setDefault('instructorchoicesendname', '1'); $mform->addHelpButton('instructorchoicesendname', 'share_name', 'lti'); $mform->disabledIf('instructorchoicesendname', 'typeid', 'in', $toolproxy); $mform->addElement('advcheckbox', 'instructorchoicesendemailaddr', ' ', ' ' . get_string('share_email', 'lti')); $mform->setDefault('instructorchoicesendemailaddr', '1'); $mform->addHelpButton('instructorchoicesendemailaddr', 'share_email', 'lti'); $mform->disabledIf('instructorchoicesendemailaddr', 'typeid', 'in', $toolproxy); $mform->addElement('advcheckbox', 'instructorchoiceacceptgrades', ' ', ' ' . get_string('accept_grades', 'lti')); $mform->setDefault('instructorchoiceacceptgrades', '1'); $mform->addHelpButton('instructorchoiceacceptgrades', 'accept_grades', 'lti'); $mform->disabledIf('instructorchoiceacceptgrades', 'typeid', 'in', $toolproxy); // Add standard course module grading elements. $this->standard_grading_coursemodule_elements(); // Add standard elements, common to all modules. $this->standard_coursemodule_elements(); $mform->setAdvanced('cmidnumber'); // Add standard buttons, common to all modules. $this->add_action_buttons(); $editurl = new moodle_url('/mod/lti/instructor_edit_tool_type.php', array('sesskey' => sesskey(), 'course' => $COURSE->id)); $ajaxurl = new moodle_url('/mod/lti/ajax.php'); $jsinfo = (object) array('edit_icon_url' => (string) $OUTPUT->pix_url('t/edit'), 'add_icon_url' => (string) $OUTPUT->pix_url('t/add'), 'delete_icon_url' => (string) $OUTPUT->pix_url('t/delete'), 'green_check_icon_url' => (string) $OUTPUT->pix_url('i/valid'), 'warning_icon_url' => (string) $OUTPUT->pix_url('warning', 'lti'), 'instructor_tool_type_edit_url' => $editurl->out(false), 'ajax_url' => $ajaxurl->out(true), 'courseId' => $COURSE->id); $module = array('name' => 'mod_lti_edit', 'fullpath' => '/mod/lti/mod_form.js', 'requires' => array('base', 'io', 'querystring-stringify-simple', 'node', 'event', 'json-parse'), 'strings' => array(array('addtype', 'lti'), array('edittype', 'lti'), array('deletetype', 'lti'), array('delete_confirmation', 'lti'), array('cannot_edit', 'lti'), array('cannot_delete', 'lti'), array('global_tool_types', 'lti'), array('course_tool_types', 'lti'), array('using_tool_configuration', 'lti'), array('using_tool_cartridge', 'lti'), array('domain_mismatch', 'lti'), array('custom_config', 'lti'), array('tool_config_not_found', 'lti'), array('tooltypeadded', 'lti'), array('tooltypedeleted', 'lti'), array('tooltypenotdeleted', 'lti'), array('tooltypeupdated', 'lti'), array('forced_help', 'lti'))); if (!empty($typeid)) { $mform->setAdvanced('typeid'); $mform->setAdvanced('toolurl'); } $PAGE->requires->js_init_call('M.mod_lti.editor.init', array(json_encode($jsinfo)), true, $module); }