Skip to content

Commit

Permalink
MDL-37337 Assignment: Restructure assignment settings screen to make …
Browse files Browse the repository at this point in the history
…it "wieldy"
  • Loading branch information
Damyon Wiese committed Feb 15, 2013
1 parent 9e7e1b1 commit b0da618
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 41 deletions.
2 changes: 1 addition & 1 deletion mod/assign/externallib.php
Expand Up @@ -185,7 +185,7 @@ public static function get_grades_returns() {
array(
'assignments' => new external_multiple_structure(self::assign_grades(), 'list of assignment grade information'),
'warnings' => new external_warnings('item is always \'assignment\'',
'when errorcode is 3 then itemid is an assignment id. When errorcode is 1, itemid is a course module instance id',
'when errorcode is 3 then itemid is an assignment id. When errorcode is 1, itemid is a course module id',
'errorcode can be 3 (no grades found) or 1 (no permission to get grades)')
)
);
Expand Down
3 changes: 3 additions & 0 deletions mod/assign/lang/en/assign.php
Expand Up @@ -324,4 +324,7 @@
$string['viewsummary'] = 'View summary';
$string['viewsubmissiongradingtable'] = 'View submission grading table.';
$string['viewrevealidentitiesconfirm'] = 'View reveal student identities confirmation page.';
$string['submissiontypes'] = 'Submission types';
$string['feedbacktypes'] = 'Feedback types';
$string['groupsubmissionsettings'] = 'Group submission settings';

35 changes: 21 additions & 14 deletions mod/assign/locallib.php
Expand Up @@ -657,7 +657,7 @@ public function reset_userdata($data) {
protected function update_plugin_instance(assign_plugin $plugin, stdClass $formdata) {
if ($plugin->is_visible()) {
$enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
if ($formdata->$enabledname) {
if (!empty($formdata->$enabledname)) {
$plugin->enable();
if (!$plugin->save_settings($formdata)) {
print_error($plugin->get_error());
Expand Down Expand Up @@ -843,17 +843,18 @@ protected function add_plugin_grade_elements($grade, MoodleQuickForm $mform, std
* @param assign_plugin $plugin The plugin to add the settings from
* @param MoodleQuickForm $mform The form to add the configuration settings to.
* This form is modified directly (not returned).
* @param array $pluginsenabled A list of form elements to be added to a group.
* The new element is added to this array by this function.
* @return void
*/
protected function add_plugin_settings(assign_plugin $plugin, MoodleQuickForm $mform) {
protected function add_plugin_settings(assign_plugin $plugin, MoodleQuickForm $mform, & $pluginsenabled) {
global $CFG;
if ($plugin->is_visible()) {
$mform->addElement('selectyesno',
$plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled',
$plugin->get_name());
$mform->addHelpButton($plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled',
'enabled',
$plugin->get_subtype() . '_' . $plugin->get_type());

$name = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled';
$label = $plugin->get_name();
$label .= ' ' . $this->get_renderer()->help_icon('enabled', $plugin->get_subtype() . '_' . $plugin->get_type());
$pluginsenabled[] = $mform->createElement('checkbox', $name, '', $label);

$default = get_config($plugin->get_subtype() . '_' . $plugin->get_type(), 'default');
if ($plugin->get_config('enabled') !== false) {
Expand All @@ -874,16 +875,23 @@ protected function add_plugin_settings(assign_plugin $plugin, MoodleQuickForm $m
* @return void
*/
public function add_all_plugin_settings(MoodleQuickForm $mform) {
$mform->addElement('header', 'general', get_string('submissionsettings', 'assign'));
$mform->addElement('header', 'submissiontypes', get_string('submissionsettings', 'assign'));

$submissionpluginsenabled = array();
$group = $mform->addGroup(array(), 'submissionplugins', get_string('submissiontypes', 'assign'), array(' '), false);
foreach ($this->submissionplugins as $plugin) {
$this->add_plugin_settings($plugin, $mform);

$this->add_plugin_settings($plugin, $mform, $submissionpluginsenabled);
}
$mform->addElement('header', 'general', get_string('feedbacksettings', 'assign'));
$group->setElements($submissionpluginsenabled);

$mform->addElement('header', 'feedbacktypes', get_string('feedbacksettings', 'assign'));
$feedbackpluginsenabled = array();
$group = $mform->addGroup(array(), 'feedbackplugins', get_string('feedbacktypes', 'assign'), array(' '), false);
foreach ($this->feedbackplugins as $plugin) {
$this->add_plugin_settings($plugin, $mform);
$this->add_plugin_settings($plugin, $mform, $feedbackpluginsenabled);
}
$group->setElements($feedbackpluginsenabled);
$mform->setExpanded('submissiontypes');
}

/**
Expand Down Expand Up @@ -3112,7 +3120,6 @@ public function view_student_summary($user, $showlinks) {
}
}


$feedbackstatus = new assign_feedback_status($gradefordisplay,
$gradeddate,
$grader,
Expand Down
48 changes: 28 additions & 20 deletions mod/assign/mod_form.php
Expand Up @@ -73,7 +73,9 @@ public function definition() {

$config = get_config('assign');

$mform->addElement('header', 'general', get_string('settings', 'assign'));
$assignment->add_all_plugin_settings($mform);

$mform->addElement('header', 'availability', get_string('availability', 'assign'));

$name = get_string('allowsubmissionsfromdate', 'assign');
$options = array('optional'=>true);
Expand All @@ -92,10 +94,12 @@ public function definition() {
$mform->setDefault('cutoffdate', time()+7*24*3600);

$name = get_string('alwaysshowdescription', 'assign');
$mform->addElement('selectyesno', 'alwaysshowdescription', $name);
$mform->addElement('checkbox', 'alwaysshowdescription', $name);
$mform->addHelpButton('alwaysshowdescription', 'alwaysshowdescription', 'assign');
$mform->setDefault('alwaysshowdescription', 1);

$mform->addElement('header', 'submissionsettings', get_string('submissionsettings', 'assign'));

$name = get_string('submissiondrafts', 'assign');
$mform->addElement('selectyesno', 'submissiondrafts', $name);
$mform->addHelpButton('submissiondrafts', 'submissiondrafts', 'assign');
Expand All @@ -114,16 +118,7 @@ public function definition() {
$mform->addElement('hidden', 'requiresubmissionstatement', 1);
}

$name = get_string('sendnotifications', 'assign');
$mform->addElement('selectyesno', 'sendnotifications', $name);
$mform->addHelpButton('sendnotifications', 'sendnotifications', 'assign');
$mform->setDefault('sendnotifications', 1);

$name = get_string('sendlatenotifications', 'assign');
$mform->addElement('selectyesno', 'sendlatenotifications', $name);
$mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'assign');
$mform->setDefault('sendlatenotifications', 1);
$mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1);
$mform->addElement('header', 'groupsubmissionsettings', get_string('groupsubmissionsettings', 'assign'));

$name = get_string('teamsubmission', 'assign');
$mform->addElement('selectyesno', 'teamsubmission', $name);
Expand All @@ -150,22 +145,34 @@ public function definition() {
$mform->setDefault('teamsubmissiongroupingid', 0);
$mform->disabledIf('teamsubmissiongroupingid', 'teamsubmission', 'eq', 0);

$name = get_string('blindmarking', 'assign');
$mform->addElement('selectyesno', 'blindmarking', $name);
$mform->addHelpButton('blindmarking', 'blindmarking', 'assign');
$mform->setDefault('blindmarking', 0);
if ($assignment->has_submissions_or_grades() ) {
$mform->freeze('blindmarking');
}
$mform->addElement('header', 'notifications', get_string('notifications', 'assign'));

$name = get_string('sendnotifications', 'assign');
$mform->addElement('selectyesno', 'sendnotifications', $name);
$mform->addHelpButton('sendnotifications', 'sendnotifications', 'assign');
$mform->setDefault('sendnotifications', 1);

$name = get_string('sendlatenotifications', 'assign');
$mform->addElement('selectyesno', 'sendlatenotifications', $name);
$mform->addHelpButton('sendlatenotifications', 'sendlatenotifications', 'assign');
$mform->setDefault('sendlatenotifications', 1);
$mform->disabledIf('sendlatenotifications', 'sendnotifications', 'eq', 1);

// Plagiarism enabling form.
if (!empty($CFG->enableplagiarism)) {
require_once($CFG->libdir . '/plagiarismlib.php');
plagiarism_get_form_elements_module($mform, $ctx->get_course_context(), 'mod_assign');
}

$assignment->add_all_plugin_settings($mform);
$this->standard_grading_coursemodule_elements();
$name = get_string('blindmarking', 'assign');
$mform->addElement('selectyesno', 'blindmarking', $name);
$mform->addHelpButton('blindmarking', 'blindmarking', 'assign');
$mform->setDefault('blindmarking', 0);
if ($assignment->has_submissions_or_grades() ) {
$mform->freeze('blindmarking');
}

$this->standard_coursemodule_elements();

$this->add_action_buttons();
Expand All @@ -177,6 +184,7 @@ public function definition() {
'assignment = ? AND grade <> -1',
array($this->_instance));
}

if ($mform->elementExists('grade') && $hasgrade) {
$module = array(
'name' => 'mod_assign',
Expand Down
4 changes: 2 additions & 2 deletions mod/assign/submission/file/locallib.php
Expand Up @@ -85,7 +85,7 @@ public function get_settings(MoodleQuickForm $mform) {
'maxfilessubmission',
'assignsubmission_file');
$mform->setDefault('assignsubmission_file_maxfiles', $defaultmaxfilesubmissions);
$mform->disabledIf('assignsubmission_file_maxfiles', 'assignsubmission_file_enabled', 'eq', 0);
$mform->disabledIf('assignsubmission_file_maxfiles', 'assignsubmission_file_enabled', 'notchecked');

$choices = get_max_upload_sizes($CFG->maxbytes,
$COURSE->maxbytes,
Expand All @@ -105,7 +105,7 @@ public function get_settings(MoodleQuickForm $mform) {
$mform->setDefault('assignsubmission_file_maxsizebytes', $defaultmaxsubmissionsizebytes);
$mform->disabledIf('assignsubmission_file_maxsizebytes',
'assignsubmission_file_enabled',
'eq', 0);
'notchecked');
}

/**
Expand Down
1 change: 0 additions & 1 deletion mod/assign/tests/lib_test.php
Expand Up @@ -181,7 +181,6 @@ public function test_assign_user_complete() {

$submission = $assign->get_user_submission($this->students[0]->id, true);


$this->expectOutputRegex('/Draft/');
assign_user_complete($this->course, $this->students[0], $assign->get_course_module(), $assign->get_instance());

Expand Down
6 changes: 3 additions & 3 deletions mod/assign/tests/locallib_test.php
Expand Up @@ -674,7 +674,7 @@ public function test_show_student_summary() {
$data->grade = '50.0';
$assign->testable_apply_grade_to_user($data, $this->students[0]->id);

// Now we should see the feedback
// Now we should see the feedback.
$this->setUser($this->students[0]);
$output = $assign->view_student_summary($this->students[0], true);
$this->assertNotEquals(false, strpos($output, 'Feedback'), 'Show feedback if there is a grade');
Expand All @@ -695,7 +695,7 @@ public function test_show_student_summary() {
$output = $assign->view_student_summary($this->students[0], true);
$this->assertEquals(false, strpos($output, 'Feedback'), 'Do not show feedback if the grade is hidden in the gradebook');

// Do the same but add feedback
// Do the same but add feedback.
$assign = $this->create_instance(array('assignfeedback_comments_enabled' => 1));

$this->setUser($this->teachers[0]);
Expand All @@ -706,7 +706,7 @@ public function test_show_student_summary() {
$plugin = $assign->get_feedback_plugin_by_type('comments');
$plugin->save($grade, $data);

// Should have feedback but no grade
// Should have feedback but no grade.
$this->setUser($this->students[0]);
$output = $assign->view_student_summary($this->students[0], true);
$this->assertNotEquals(false, strpos($output, 'Tomato sauce'), 'Show feedback even if there is no grade');
Expand Down

0 comments on commit b0da618

Please sign in to comment.