mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
MDL-82684 mod_assign: Move the downloadasfolders checkbox to action bar
This commit is contained in:
parent
2e35d1bd30
commit
5fe8064557
7 changed files with 51 additions and 21 deletions
|
@ -64,7 +64,7 @@ class downloader {
|
||||||
* Class constructor.
|
* Class constructor.
|
||||||
*
|
*
|
||||||
* @param assign $manager the instance manager
|
* @param assign $manager the instance manager
|
||||||
* @param array|null $userids the user ids to download.
|
* @param int[]|null $userids the user ids to download.
|
||||||
*/
|
*/
|
||||||
public function __construct(assign $manager, ?array $userids = null) {
|
public function __construct(assign $manager, ?array $userids = null) {
|
||||||
$this->manager = $manager;
|
$this->manager = $manager;
|
||||||
|
|
|
@ -75,13 +75,6 @@ class grading_options_temp_form extends \moodleform {
|
||||||
$mform->setDefault('showonlyactiveenrol', $instance['showonlyactiveenrol']);
|
$mform->setDefault('showonlyactiveenrol', $instance['showonlyactiveenrol']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place student downloads in seperate folders.
|
|
||||||
if ($instance['submissionsenabled']) {
|
|
||||||
$mform->addElement('checkbox', 'downloadasfolders', get_string('downloadasfolders', 'assign'));
|
|
||||||
$mform->addHelpButton('downloadasfolders', 'downloadasfolders', 'assign');
|
|
||||||
$mform->setDefault('downloadasfolders', $instance['downloadasfolders']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hidden params.
|
// Hidden params.
|
||||||
$mform->addElement('hidden', 'contextid', $instance['contextid']);
|
$mform->addElement('hidden', 'contextid', $instance['contextid']);
|
||||||
$mform->setType('contextid', PARAM_INT);
|
$mform->setType('contextid', PARAM_INT);
|
||||||
|
|
|
@ -48,6 +48,8 @@ class grading_actionmenu implements templatable, renderable {
|
||||||
protected int $submissioncount;
|
protected int $submissioncount;
|
||||||
/** @var assign The assign instance. */
|
/** @var assign The assign instance. */
|
||||||
protected assign $assign;
|
protected assign $assign;
|
||||||
|
/** @var bool If there are submissions to download. */
|
||||||
|
protected bool $showdownload;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for this object.
|
* Constructor for this object.
|
||||||
|
@ -69,6 +71,7 @@ class grading_actionmenu implements templatable, renderable {
|
||||||
$assign = new assign($context, null, null);
|
$assign = new assign($context, null, null);
|
||||||
}
|
}
|
||||||
$this->assign = $assign;
|
$this->assign = $assign;
|
||||||
|
$this->showdownload = $this->assign->is_any_submission_plugin_enabled() && $this->assign->count_submissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -162,6 +165,23 @@ class grading_actionmenu implements templatable, renderable {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->showdownload) {
|
||||||
|
$downloadasfoldersbaseurl = new moodle_url('/mod/assign/view.php', [
|
||||||
|
'id' => $this->assign->get_course_module()->id,
|
||||||
|
'action' => 'grading',
|
||||||
|
]);
|
||||||
|
if ($userid) {
|
||||||
|
$downloadasfoldersbaseurl->param('userid', $userid);
|
||||||
|
} else if ($usersearch) {
|
||||||
|
$downloadasfoldersbaseurl->param('search', $usersearch);
|
||||||
|
}
|
||||||
|
$downloadasfolders = get_user_preferences('assign_downloadasfolders', 1);
|
||||||
|
$data['downloadasfolders'] = [
|
||||||
|
'baseurl' => $downloadasfoldersbaseurl->out(false),
|
||||||
|
'enabled' => $downloadasfolders,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$actions = $this->get_actions();
|
$actions = $this->get_actions();
|
||||||
if ($actions) {
|
if ($actions) {
|
||||||
$menu = new \action_menu();
|
$menu = new \action_menu();
|
||||||
|
@ -219,7 +239,7 @@ class grading_actionmenu implements templatable, renderable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->assign->is_any_submission_plugin_enabled() && $this->assign->count_submissions()) {
|
if ($this->showdownload) {
|
||||||
$url = new moodle_url('/mod/assign/view.php', [
|
$url = new moodle_url('/mod/assign/view.php', [
|
||||||
'id' => $this->assign->get_course_module()->id,
|
'id' => $this->assign->get_course_module()->id,
|
||||||
'action' => 'downloadall',
|
'action' => 'downloadall',
|
||||||
|
|
|
@ -190,7 +190,6 @@ $string['disabled'] = 'Disabled';
|
||||||
$string['downloadall'] = 'Download all submissions';
|
$string['downloadall'] = 'Download all submissions';
|
||||||
$string['download all submissions'] = 'Download all submissions in a zip file.';
|
$string['download all submissions'] = 'Download all submissions in a zip file.';
|
||||||
$string['downloadasfolders'] = 'Download submissions in folders';
|
$string['downloadasfolders'] = 'Download submissions in folders';
|
||||||
$string['downloadasfolders_help'] = 'Assignment submissions may be downloaded in folders. Each submission is then put in a separate folder, with the folder structure kept for any subfolders, and files are not renamed.';
|
|
||||||
$string['downloadselectedsubmissions'] = 'Download selected submissions';
|
$string['downloadselectedsubmissions'] = 'Download selected submissions';
|
||||||
$string['duedate'] = 'Due date';
|
$string['duedate'] = 'Due date';
|
||||||
$string['duedatecolon'] = 'Due date: {$a}';
|
$string['duedatecolon'] = 'Due date: {$a}';
|
||||||
|
@ -703,6 +702,7 @@ $string['xofy'] = '{$a->x} of {$a->y}';
|
||||||
// Deprecated since Moodle 4.5.
|
// Deprecated since Moodle 4.5.
|
||||||
$string['attemptreopenmethod_none'] = 'Never';
|
$string['attemptreopenmethod_none'] = 'Never';
|
||||||
$string['choosegradingaction'] = 'Grading action';
|
$string['choosegradingaction'] = 'Grading action';
|
||||||
|
$string['downloadasfolders_help'] = 'Assignment submissions may be downloaded in folders. Each submission is then put in a separate folder, with the folder structure kept for any subfolders, and files are not renamed.';
|
||||||
$string['groupoverridesdeleted'] = 'Group overrides deleted';
|
$string['groupoverridesdeleted'] = 'Group overrides deleted';
|
||||||
$string['updategrade'] = 'Update grade';
|
$string['updategrade'] = 'Update grade';
|
||||||
$string['useroverridesdeleted'] = 'User overrides deleted';
|
$string['useroverridesdeleted'] = 'User overrides deleted';
|
||||||
|
|
|
@ -3,3 +3,4 @@ groupoverridesdeleted,mod_assign
|
||||||
useroverridesdeleted,mod_assign
|
useroverridesdeleted,mod_assign
|
||||||
choosegradingaction,mod_assign
|
choosegradingaction,mod_assign
|
||||||
updategrade,mod_assign
|
updategrade,mod_assign
|
||||||
|
downloadasfolders_help,mod_assign
|
||||||
|
|
|
@ -3740,7 +3740,7 @@ class assign {
|
||||||
/**
|
/**
|
||||||
* Download a zip file of all assignment submissions.
|
* Download a zip file of all assignment submissions.
|
||||||
*
|
*
|
||||||
* @param array|null $userids Array of user ids to download assignment submissions in a zip file
|
* @param int[]|null $userids Array of user ids to download assignment submissions in a zip file
|
||||||
* @return string - If an error occurs, this will contain the error page.
|
* @return string - If an error occurs, this will contain the error page.
|
||||||
*/
|
*/
|
||||||
protected function download_submissions($userids = null) {
|
protected function download_submissions($userids = null) {
|
||||||
|
@ -4499,6 +4499,11 @@ class assign {
|
||||||
set_user_preference('assign_quickgrading', $submittedquickgrading);
|
set_user_preference('assign_quickgrading', $submittedquickgrading);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$submitteddownloadasfolders = optional_param('downloadasfolders', null, PARAM_BOOL);
|
||||||
|
if (isset($submitteddownloadasfolders)) {
|
||||||
|
set_user_preference('assign_downloadasfolders', $submitteddownloadasfolders);
|
||||||
|
}
|
||||||
|
|
||||||
$o = '';
|
$o = '';
|
||||||
$cmid = $this->get_course_module()->id;
|
$cmid = $this->get_course_module()->id;
|
||||||
|
|
||||||
|
@ -4520,7 +4525,6 @@ class assign {
|
||||||
$showquickgrading = empty($controller) && $this->can_grade();
|
$showquickgrading = empty($controller) && $this->can_grade();
|
||||||
$quickgrading = get_user_preferences('assign_quickgrading', false);
|
$quickgrading = get_user_preferences('assign_quickgrading', false);
|
||||||
$showonlyactiveenrolopt = has_capability('moodle/course:viewsuspendedusers', $this->context);
|
$showonlyactiveenrolopt = has_capability('moodle/course:viewsuspendedusers', $this->context);
|
||||||
$downloadasfolders = get_user_preferences('assign_downloadasfolders', 1);
|
|
||||||
|
|
||||||
$markingallocation = $this->get_instance()->markingworkflow &&
|
$markingallocation = $this->get_instance()->markingworkflow &&
|
||||||
$this->get_instance()->markingallocation &&
|
$this->get_instance()->markingallocation &&
|
||||||
|
@ -4548,12 +4552,10 @@ class assign {
|
||||||
'cm' => $cmid,
|
'cm' => $cmid,
|
||||||
'contextid' => $this->context->id,
|
'contextid' => $this->context->id,
|
||||||
'userid' => $USER->id,
|
'userid' => $USER->id,
|
||||||
'submissionsenabled' => $this->is_any_submission_plugin_enabled(),
|
|
||||||
'markingworkflowopt' => $markingworkflowoptions,
|
'markingworkflowopt' => $markingworkflowoptions,
|
||||||
'markingallocationopt' => $markingallocationoptions,
|
'markingallocationopt' => $markingallocationoptions,
|
||||||
'showonlyactiveenrolopt' => $showonlyactiveenrolopt,
|
'showonlyactiveenrolopt' => $showonlyactiveenrolopt,
|
||||||
'showonlyactiveenrol' => $this->show_only_active_users(),
|
'showonlyactiveenrol' => $this->show_only_active_users(),
|
||||||
'downloadasfolders' => $downloadasfolders,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$classoptions = array('class'=>'gradingoptionsform');
|
$classoptions = array('class'=>'gradingoptionsform');
|
||||||
|
@ -7416,12 +7418,10 @@ class assign {
|
||||||
'cm' => $this->get_course_module()->id,
|
'cm' => $this->get_course_module()->id,
|
||||||
'contextid' => $this->context->id,
|
'contextid' => $this->context->id,
|
||||||
'userid' => $USER->id,
|
'userid' => $USER->id,
|
||||||
'submissionsenabled' => $this->is_any_submission_plugin_enabled(),
|
|
||||||
'markingworkflowopt' => $markingworkflowoptions,
|
'markingworkflowopt' => $markingworkflowoptions,
|
||||||
'markingallocationopt' => $markingallocationoptions,
|
'markingallocationopt' => $markingallocationoptions,
|
||||||
'showonlyactiveenrolopt' => $showonlyactiveenrolopt,
|
'showonlyactiveenrolopt' => $showonlyactiveenrolopt,
|
||||||
'showonlyactiveenrol' => $this->show_only_active_users(),
|
'showonlyactiveenrol' => $this->show_only_active_users(),
|
||||||
'downloadasfolders' => get_user_preferences('assign_downloadasfolders', 1),
|
|
||||||
];
|
];
|
||||||
$mform = new mod_assign\form\grading_options_temp_form(null, $gradingoptionsparams);
|
$mform = new mod_assign\form\grading_options_temp_form(null, $gradingoptionsparams);
|
||||||
if ($formdata = $mform->get_data()) {
|
if ($formdata = $mform->get_data()) {
|
||||||
|
@ -7429,11 +7429,6 @@ class assign {
|
||||||
if (isset($formdata->markerfilter)) {
|
if (isset($formdata->markerfilter)) {
|
||||||
set_user_preference('assign_markerfilter', $formdata->markerfilter);
|
set_user_preference('assign_markerfilter', $formdata->markerfilter);
|
||||||
}
|
}
|
||||||
if (isset($formdata->downloadasfolders)) {
|
|
||||||
set_user_preference('assign_downloadasfolders', 1); // Enabled.
|
|
||||||
} else {
|
|
||||||
set_user_preference('assign_downloadasfolders', 0); // Disabled.
|
|
||||||
}
|
|
||||||
if (!empty($showonlyactiveenrolopt)) {
|
if (!empty($showonlyactiveenrolopt)) {
|
||||||
$showonlyactiveenrol = isset($formdata->showonlyactiveenrol);
|
$showonlyactiveenrol = isset($formdata->showonlyactiveenrol);
|
||||||
set_user_preference('grade_report_showonlyactiveenrol', $showonlyactiveenrol);
|
set_user_preference('grade_report_showonlyactiveenrol', $showonlyactiveenrol);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
* pagereset - (optional) URL to reset the page
|
* pagereset - (optional) URL to reset the page
|
||||||
* graderurl - (optional) URL to the grader page
|
* graderurl - (optional) URL to the grader page
|
||||||
* quickgrading - (optional) Includes the baseurl and enabled properties for the quick grading checkbox
|
* quickgrading - (optional) Includes the baseurl and enabled properties for the quick grading checkbox
|
||||||
|
* downloadasfolders - (optional) Includes the baseurl and enabled properties for the download as folders checkbox
|
||||||
* actions - (optional) HTML that outputs the bulk action menu
|
* actions - (optional) HTML that outputs the bulk action menu
|
||||||
|
|
||||||
Example context (json):
|
Example context (json):
|
||||||
|
@ -57,6 +58,10 @@
|
||||||
"baseurl": "http://moodle.local/mod/assign/view.php?id=2&action=grading",
|
"baseurl": "http://moodle.local/mod/assign/view.php?id=2&action=grading",
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
"downloadasfolders": {
|
||||||
|
"baseurl": "http://moodle.local/mod/assign/view.php?id=2&action=grading",
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
"actions": "<div class='action-menu'></div>"
|
"actions": "<div class='action-menu'></div>"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +132,22 @@
|
||||||
});
|
});
|
||||||
{{/js}}
|
{{/js}}
|
||||||
{{/quickgrading}}
|
{{/quickgrading}}
|
||||||
|
{{#downloadasfolders}}
|
||||||
|
<div class="navitem m-0">
|
||||||
|
<div class="form-check align-self-center">
|
||||||
|
<input class="form-check-input" type="checkbox" id="downloadasfolders-{{uniqid}}" {{#enabled}}checked{{/enabled}}/>
|
||||||
|
<label class="form-check-label" for="downloadasfolders-{{uniqid}}">{{#str}}downloadasfolders, mod_assign{{/str}}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="navitem-divider m-0"></div>
|
||||||
|
{{#js}}
|
||||||
|
document.querySelector('#downloadasfolders-{{uniqid}}').addEventListener('change', function(e) {
|
||||||
|
var url = new URL('{{{baseurl}}}');
|
||||||
|
url.searchParams.set('downloadasfolders', e.target.checked ? 1 : 0);
|
||||||
|
window.location.href = url;
|
||||||
|
});
|
||||||
|
{{/js}}
|
||||||
|
{{/downloadasfolders}}
|
||||||
{{#actions}}
|
{{#actions}}
|
||||||
<div class="navitem m-0">{{{actions}}}</div>
|
<div class="navitem m-0">{{{actions}}}</div>
|
||||||
{{/actions}}
|
{{/actions}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue