Skip to content

Commit

Permalink
Merge branch 'MDL-55129-master' of git://github.com/jleyva/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Oct 5, 2016
2 parents 77371e2 + 30cdddb commit e43bab7
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 15 deletions.
11 changes: 11 additions & 0 deletions mod/assign/assignmentplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,4 +677,15 @@ public function get_external_parameters() {
public function is_configurable() {
return true;
}

/**
* Return the plugin configs for external functions,
* in some cases the configs will need formatting or be returned only if the current user has some capabilities enabled.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
return array();
}
}
36 changes: 21 additions & 15 deletions mod/assign/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,19 +401,27 @@ public static function get_assignments($courseids = array(), $capabilities = arr
);
continue;
}
$configrecords = $DB->get_recordset('assign_plugin_config', array('assignment' => $module->assignmentid));

$assign = new assign($context, null, null);

// Get configurations for only enabled plugins.
$plugins = $assign->get_submission_plugins();
$plugins = array_merge($plugins, $assign->get_feedback_plugins());

$configarray = array();
foreach ($configrecords as $configrecord) {
$configarray[] = array(
'id' => $configrecord->id,
'assignment' => $configrecord->assignment,
'plugin' => $configrecord->plugin,
'subtype' => $configrecord->subtype,
'name' => $configrecord->name,
'value' => $configrecord->value
);
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$configrecords = $plugin->get_config_for_external();
foreach ($configrecords as $name => $value) {
$configarray[] = array(
'plugin' => $plugin->get_type(),
'subtype' => $plugin->get_subtype(),
'name' => $name,
'value' => $value
);
}
}
}
$configrecords->close();

$assignment = array(
'id' => $module->assignmentid,
Expand Down Expand Up @@ -446,8 +454,6 @@ public static function get_assignments($courseids = array(), $capabilities = arr
);

// Return or not intro and file attachments depending on the plugin settings.
$assign = new assign($context, null, null);

if ($assign->show_intro()) {

list($assignment['intro'], $assignment['introformat']) = external_format_text($module->intro,
Expand Down Expand Up @@ -540,8 +546,8 @@ private static function get_assignments_assignment_structure() {
private static function get_assignments_config_structure() {
return new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'assign_plugin_config id'),
'assignment' => new external_value(PARAM_INT, 'assignment id'),
'id' => new external_value(PARAM_INT, 'assign_plugin_config id', VALUE_OPTIONAL),
'assignment' => new external_value(PARAM_INT, 'assignment id', VALUE_OPTIONAL),
'plugin' => new external_value(PARAM_TEXT, 'plugin'),
'subtype' => new external_value(PARAM_TEXT, 'subtype'),
'name' => new external_value(PARAM_TEXT, 'name'),
Expand Down
9 changes: 9 additions & 0 deletions mod/assign/feedback/comments/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,4 +517,13 @@ public function get_external_parameters() {
return array('assignfeedbackcomments_editor' => $editorstructure);
}

/**
* Return the plugin configs for external functions.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
return (array) $this->get_config();
}
}
10 changes: 10 additions & 0 deletions mod/assign/feedback/editpdf/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,14 @@ public function get_file_areas() {
public function supports_review_panel() {
return true;
}

/**
* Return the plugin configs for external functions.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
return (array) $this->get_config();
}
}
9 changes: 9 additions & 0 deletions mod/assign/feedback/file/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,4 +688,13 @@ public function get_external_parameters() {
);
}

/**
* Return the plugin configs for external functions.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
return (array) $this->get_config();
}
}
9 changes: 9 additions & 0 deletions mod/assign/feedback/offline/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,13 @@ public function has_user_summary() {
return false;
}

/**
* Return the plugin configs for external functions.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
return (array) $this->get_config();
}
}
10 changes: 10 additions & 0 deletions mod/assign/submission/comments/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,14 @@ public function is_enabled() {
public function is_configurable() {
return false;
}

/**
* Return the plugin configs for external functions.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
return (array) $this->get_config();
}
}
19 changes: 19 additions & 0 deletions mod/assign/submission/file/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,4 +547,23 @@ public function get_external_parameters() {
)
);
}

/**
* Return the plugin configs for external functions.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
global $CFG;

$configs = $this->get_config();

// Get a size in bytes.
if ($configs->maxsubmissionsizebytes == 0) {
$configs->maxsubmissionsizebytes = get_max_upload_file_size($CFG->maxbytes, $this->assignment->get_course()->maxbytes,
get_config('assignsubmission_file', 'maxbytes'));
}
return (array) $configs;
}
}
9 changes: 9 additions & 0 deletions mod/assign/submission/onlinetext/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,15 @@ public function check_word_count($submissiontext) {
}
}

/**
* Return the plugin configs for external functions.
*
* @return array the list of settings
* @since Moodle 3.2
*/
public function get_config_for_external() {
return (array) $this->get_config();
}
}


1 change: 1 addition & 0 deletions mod/assign/tests/externallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public function test_get_assignments() {
$this->assertEquals($course1->id, $assignment['course']);
$this->assertEquals('lightwork assignment', $assignment['name']);
$this->assertContains('the assignment intro text here', $assignment['intro']);
$this->assertNotEmpty($assignment['configs']);
// Check the url of the file attatched.
$this->assertRegExp('@"' . $CFG->wwwroot . '/webservice/pluginfile.php/\d+/mod_assign/intro/intro\.txt"@', $assignment['intro']);
$this->assertEquals(1, $assignment['markingworkflow']);
Expand Down
2 changes: 2 additions & 0 deletions mod/assign/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ This files describes API changes in the assign code.
Please, note that previously the filename was part of the filepath field, now they are separated.
* Submission and feedback plugins can now specify file areas related to their configuration data,
which will then be included in backup and restore; see assign_plugin::get_config_file_areas().
* Submission and feedback plugins must now return the specific list of configs available for external functions,
this can be done implementing the new assign plugin method get_config_for_external()

=== 3.1 ===
* The feedback plugins now need to implement the is_feedback_modified() method. The default is to return true
Expand Down

0 comments on commit e43bab7

Please sign in to comment.