mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
MDL-62599 mod_lti: Revert service configuration parameters
Code to add configuration settings for LTI services reverted to current release code which injects them directly into the edit form. This has the risk of name clashes and changes being made to elements not created by the service.
This commit is contained in:
parent
d930ef0491
commit
a464331db2
@ -221,12 +221,9 @@ abstract class service_base {
|
||||
* Returns the configuration options for this service.
|
||||
*
|
||||
* @param \MoodleQuickForm $mform Moodle quickform object definition
|
||||
* @deprecated since Moodle 3.7 MDL-62599 - please do not use this function any more.
|
||||
* @see service_base::get_configuration_elements()
|
||||
*/
|
||||
public function get_configuration_options(&$mform) {
|
||||
debugging('get_configuration_options() has been deprecated, ' .
|
||||
'please use service_base::get_configuration_elements() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -235,17 +232,7 @@ abstract class service_base {
|
||||
* @return array Names list of the parameters that the service will be saving in the configuration
|
||||
*/
|
||||
public function get_configuration_parameter_names() {
|
||||
debugging('get_configuration_options() has been deprecated, ' .
|
||||
'please use service_base::get_configuration_elements() instead.', DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create form element for gradebook sync add/edit page.
|
||||
*
|
||||
* @return array of \HTML_QuickForm_element Form elements
|
||||
*/
|
||||
public function get_configuration_elements() {
|
||||
debugging('get_configuration_parameter_names() has been deprecated.', DEBUG_DEVELOPER);
|
||||
return array();
|
||||
}
|
||||
|
||||
|
@ -206,14 +206,6 @@ function xmldb_lti_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2019031302) {
|
||||
$DB->set_field('lti_types_config', 'name', 'ltiservice_memberships', array('name' => 'memberships'));
|
||||
$DB->set_field('lti_types_config', 'name', 'ltiservice_gradebookservices', array('name' => 'gradesynchronization'));
|
||||
|
||||
// Lti savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2019031302, 'lti');
|
||||
}
|
||||
|
||||
if ($oldversion < 2019031303) {
|
||||
// Define field typeid to be added to lti_tool_settings.
|
||||
$table = new xmldb_table('lti_tool_settings');
|
||||
$field = new xmldb_field('typeid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'toolproxyid');
|
||||
@ -231,7 +223,7 @@ function xmldb_lti_upgrade($oldversion) {
|
||||
$dbman->add_key($table, $key);
|
||||
|
||||
// Lti savepoint reached.
|
||||
upgrade_mod_savepoint(true, 2019031303, 'lti');
|
||||
upgrade_mod_savepoint(true, 2019031302, 'lti');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -227,7 +227,8 @@ class mod_lti_edit_types_form extends moodleform {
|
||||
$mform->addHelpButton('lti_secureicon', 'secure_icon_url', 'lti');
|
||||
|
||||
if (!$istool) {
|
||||
$this->get_lti_services($mform);
|
||||
// Display the lti advantage services.
|
||||
$this->get_lti_advantage_services($mform);
|
||||
}
|
||||
|
||||
if (!$istool) {
|
||||
@ -328,12 +329,8 @@ class mod_lti_edit_types_form extends moodleform {
|
||||
* Generates the lti advantage extra configuration adding it to the mform
|
||||
*
|
||||
* @param MoodleQuickForm $mform
|
||||
* @deprecated since Moodle 3.7 MDL-62599 - please do not use this function any more.
|
||||
* @see mod_lti_edit_types_form::get_lti_services()
|
||||
*/
|
||||
public function get_lti_advantage_services(&$mform) {
|
||||
debugging('get_lti_advantage_services() has been deprecated, ' .
|
||||
'please use mod_lti_edit_types_form::get_lti_services() instead.', DEBUG_DEVELOPER);
|
||||
// For each service add the label and get the array of configuration.
|
||||
$services = lti_get_services();
|
||||
$mform->addElement('header', 'services', get_string('services', 'lti'));
|
||||
@ -342,38 +339,4 @@ class mod_lti_edit_types_form extends moodleform {
|
||||
$service->get_configuration_options($mform);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the lti services extra configuration adding it to the mform
|
||||
*
|
||||
* @param MoodleQuickForm $mform
|
||||
*/
|
||||
public function get_lti_services(&$mform) {
|
||||
$services = lti_get_services();
|
||||
$mform->addElement('header', 'services', get_string('services', 'lti'));
|
||||
foreach ($services as $service) {
|
||||
$elements = $service->get_configuration_elements();
|
||||
if (!empty($elements)) {
|
||||
foreach ($elements as $name => $element) {
|
||||
$id = $service->get_component_id();
|
||||
if (!empty($name)) {
|
||||
$id = "{$id}_{$name}";
|
||||
}
|
||||
$element->setName($id);
|
||||
$mform->addelement($element);
|
||||
$type = PARAM_TEXT;
|
||||
if ($element instanceof \MoodleQuickForm_select) {
|
||||
if (is_int($element->_options[0]['attr']['value'])) {
|
||||
$type = PARAM_INT;
|
||||
}
|
||||
}
|
||||
$mform->setType($id, $type);
|
||||
$mform->setDefault($id, 0);
|
||||
if (empty($name)) {
|
||||
$mform->addHelpButton($id, $id, $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2522,10 +2522,8 @@ function lti_get_type_type_config($id) {
|
||||
}
|
||||
|
||||
// Get the parameters from the LTI services.
|
||||
$services = lti_get_services();
|
||||
foreach ($services as $service) {
|
||||
$name = $service->get_component_id();
|
||||
if (isset($config[$name])) {
|
||||
foreach ($config as $name => $value) {
|
||||
if (strpos($name, 'ltiservice_') === 0) {
|
||||
$type->{$name} = $config[$name];
|
||||
}
|
||||
}
|
||||
|
@ -81,34 +81,4 @@ class basicoutcomes extends \mod_lti\local\ltiservice\service_base {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of key/values to add to the launch parameters.
|
||||
*
|
||||
* @param string $messagetype 'basic-lti-launch-request' or 'ContentItemSelectionRequest'.
|
||||
* @param string $courseid The course id.
|
||||
* @param string $user The user id.
|
||||
* @param string $typeid The tool lti type id.
|
||||
* @param string $modlti The id of the lti activity.
|
||||
*
|
||||
* The type is passed to check the configuration
|
||||
* and not return parameters for services not used.
|
||||
*
|
||||
* @return array of key/value pairs to add as launch parameters.
|
||||
*/
|
||||
public function get_launch_parameters($messagetype, $courseid, $user, $typeid, $modlti = null) {
|
||||
global $COURSE;
|
||||
|
||||
$launchparameters = array();
|
||||
$tool = lti_get_type_type_config($typeid);
|
||||
if (isset($tool->{$this->get_component_id()})) {
|
||||
if ($tool->{$this->get_component_id()} == parent::SERVICE_ENABLED) {
|
||||
if ($messagetype === 'basic-lti-launch-request') {
|
||||
$launchparameters['lis_outcome_service_url'] = '$BasicOutcome.url';
|
||||
$launchparameters['lis_result_sourcedid'] = '$BasicOutcome.sourcedId';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $launchparameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -116,41 +116,21 @@ class gradebookservices extends service_base {
|
||||
* Adds form elements for gradebook sync add/edit page.
|
||||
*
|
||||
* @param \MoodleQuickForm $mform Moodle quickform object definition
|
||||
* @deprecated since Moodle 3.7 MDL-62599 - please do not use this function any more.
|
||||
* @see gradebookservices::get_configuration_elements()
|
||||
*/
|
||||
public function get_configuration_options(&$mform) {
|
||||
debugging('get_configuration_options() has been deprecated, ' .
|
||||
'please use service_base::get_configuration_elements() instead.', DEBUG_DEVELOPER);
|
||||
|
||||
$selectelementname = 'ltiservice_gradesynchronization';
|
||||
$identifier = 'grade_synchronization';
|
||||
$options = [
|
||||
$this->get_string('nevergs'),
|
||||
$this->get_string('partialgs'),
|
||||
$this->get_string('alwaysgs')
|
||||
];
|
||||
$mform->addElement('select', $selectelementname, $this->get_string($identifier), $options);
|
||||
$mform->setType($selectelementname, 'int');
|
||||
$mform->setDefault($selectelementname, 0);
|
||||
$mform->addHelpButton($selectelementname, $identifier, self::SERVICE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create form element for gradebook sync add/edit page.
|
||||
*
|
||||
* @return array of \HTML_QuickForm_element Form elements
|
||||
*/
|
||||
public function get_configuration_elements() {
|
||||
$elements = array();
|
||||
$options = [
|
||||
get_string('nevergs', $this->get_component_id()),
|
||||
get_string('partialgs', $this->get_component_id()),
|
||||
get_string('alwaysgs', $this->get_component_id())
|
||||
];
|
||||
$elements[''] = new \MoodleQuickForm_select($this->get_component_id(), get_string($this->get_component_id(),
|
||||
$this->get_component_id()), $options);
|
||||
|
||||
return $elements;
|
||||
$mform->addElement('select', $selectelementname, get_string($identifier, $this->get_component_id()), $options);
|
||||
$mform->setType($selectelementname, 'int');
|
||||
$mform->setDefault($selectelementname, 0);
|
||||
$mform->addHelpButton($selectelementname, $identifier, $this->get_component_id());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,9 +153,9 @@ class gradebookservices extends service_base {
|
||||
$this->set_type(lti_get_type($typeid));
|
||||
$this->set_typeconfig(lti_get_type_config($typeid));
|
||||
// Only inject parameters if the service is enabled for this tool.
|
||||
if (isset($this->get_typeconfig()[$this->get_component_id()])) {
|
||||
if ($this->get_typeconfig()[$this->get_component_id()] == self::GRADEBOOKSERVICES_READ ||
|
||||
$this->get_typeconfig()[$this->get_component_id()] == self::GRADEBOOKSERVICES_FULL) {
|
||||
if (isset($this->get_typeconfig()['ltiservice_gradesynchronization'])) {
|
||||
if ($this->get_typeconfig()['ltiservice_gradesynchronization'] == self::GRADEBOOKSERVICES_READ ||
|
||||
$this->get_typeconfig()['ltiservice_gradesynchronization'] == self::GRADEBOOKSERVICES_FULL) {
|
||||
// Check for used in context is only needed because there is no explicit site tool - course relation.
|
||||
if ($this->is_allowed_in_context($typeid, $courseid)) {
|
||||
if (is_null($modlti)) {
|
||||
|
@ -24,8 +24,8 @@
|
||||
*/
|
||||
|
||||
$string['alwaysgs'] = 'Use this service for grade sync and column management ';
|
||||
$string['ltiservice_gradebookservices'] = 'IMS LTI Assignment and Grade Services';
|
||||
$string['ltiservice_gradebookservices_help'] = 'Whether to use the IMS LTI Assignment and Grade Services to synchronise grades instead of the Basic Outcomes service.
|
||||
$string['grade_synchronization'] = 'IMS LTI Assignment and Grade Services';
|
||||
$string['grade_synchronization_help'] = 'Whether to use the IMS LTI Assignment and Grade Services to synchronise grades instead of the Basic Outcomes service.
|
||||
|
||||
* **Do not use this service** - Basic Outcomes features and configuration will be used
|
||||
* **Use this service for grade sync only** - The service will populate the grades in an already existing gradebook column, but it will not be able to create new columns
|
||||
|
@ -493,20 +493,21 @@ class memberships extends \mod_lti\local\ltiservice\service_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create form element for membership add/edit page.
|
||||
* Adds form elements for membership add/edit page.
|
||||
*
|
||||
* @return array of \HTML_QuickForm_element Form elements
|
||||
* @param \MoodleQuickForm $mform
|
||||
*/
|
||||
public function get_configuration_elements() {
|
||||
$elements = array();
|
||||
public function get_configuration_options(&$mform) {
|
||||
$elementname = $this->get_component_id();
|
||||
$options = [
|
||||
get_string('notallow', $this->get_component_id()),
|
||||
get_string('allow', $this->get_component_id())
|
||||
];
|
||||
$elements[''] = new \MoodleQuickForm_select($this->get_component_id(), get_string($this->get_component_id(),
|
||||
$this->get_component_id()), $options);
|
||||
|
||||
return $elements;
|
||||
$mform->addElement('select', $elementname, get_string($elementname, $this->get_component_id()), $options);
|
||||
$mform->setType($elementname, 'int');
|
||||
$mform->setDefault($elementname, 0);
|
||||
$mform->addHelpButton($elementname, $elementname, $this->get_component_id());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -156,20 +156,21 @@ class toolsettings extends \mod_lti\local\ltiservice\service_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create form element for membership add/edit page.
|
||||
* Adds form elements for membership add/edit page.
|
||||
*
|
||||
* @return array of \HTML_QuickForm_element Form elements
|
||||
* @param \MoodleQuickForm $mform
|
||||
*/
|
||||
public function get_configuration_elements() {
|
||||
$elements = array();
|
||||
public function get_configuration_options(&$mform) {
|
||||
$elementname = $this->get_component_id();
|
||||
$options = [
|
||||
get_string('notallow', $this->get_component_id()),
|
||||
get_string('allow', $this->get_component_id())
|
||||
];
|
||||
$elements[''] = new \MoodleQuickForm_select($this->get_component_id(), get_string($this->get_component_id(),
|
||||
$this->get_component_id()), $options);
|
||||
|
||||
return $elements;
|
||||
$mform->addElement('select', $elementname, get_string($elementname, $this->get_component_id()), $options);
|
||||
$mform->setType($elementname, 'int');
|
||||
$mform->setDefault($elementname, 0);
|
||||
$mform->addHelpButton($elementname, $elementname, $this->get_component_id());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user