MDL-55472 assign: Show userlist on extension form error page

This commit is contained in:
Ilya Tregubov 2016-08-17 15:40:19 +10:00 committed by Ilya Tregubov
parent 26162efe4a
commit ffcfffbe64
3 changed files with 106 additions and 63 deletions

View file

@ -2226,7 +2226,7 @@ class assign {
* @return string
*/
protected function view_grant_extension($mform) {
global $DB, $CFG;
global $CFG;
require_once($CFG->dirroot . '/mod/assign/extensionform.php');
$o = '';
@ -2235,64 +2235,24 @@ class assign {
$data->id = $this->get_course_module()->id;
$formparams = array(
'instance' => $this->get_instance()
'instance' => $this->get_instance(),
'assign' => $this
);
$extrauserfields = get_extra_user_fields($this->get_context());
if ($mform) {
$submitteddata = $mform->get_data();
$users = $submitteddata->selectedusers;
$userlist = explode(',', $users);
$data->selectedusers = $users;
$data->userid = 0;
$usershtml = '';
$usercount = 0;
foreach ($userlist as $userid) {
if ($usercount >= 5) {
$usershtml .= get_string('moreusers', 'assign', count($userlist) - 5);
break;
}
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$usershtml .= $this->get_renderer()->render(new assign_user_summary($user,
$this->get_course()->id,
has_capability('moodle/site:viewfullnames',
$this->get_course_context()),
$this->is_blind_marking(),
$this->get_uniqueid_for_user($user->id),
$extrauserfields,
!$this->is_active_user($userid)));
$usercount += 1;
}
$formparams['userscount'] = count($userlist);
$formparams['usershtml'] = $usershtml;
} else {
$userid = required_param('userid', PARAM_INT);
$user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
$flags = $this->get_user_flags($userid, false);
$data->userid = $user->id;
if ($flags) {
$data->extensionduedate = $flags->extensionduedate;
}
$usershtml = $this->get_renderer()->render(new assign_user_summary($user,
$this->get_course()->id,
has_capability('moodle/site:viewfullnames',
$this->get_course_context()),
$this->is_blind_marking(),
$this->get_uniqueid_for_user($user->id),
$extrauserfields,
!$this->is_active_user($userid)));
$formparams['usershtml'] = $usershtml;
$users = optional_param('userid', 0, PARAM_INT);
if (!$users) {
$users = required_param('selectedusers', PARAM_SEQUENCE);
}
$userlist = explode(',', $users);
$mform = new mod_assign_extension_form(null, $formparams);
$formparams['userlist'] = $userlist;
$data->selectedusers = $users;
$data->userid = 0;
if (empty($mform)) {
$mform = new mod_assign_extension_form(null, $formparams);
}
$mform->set_data($data);
$header = new assign_header($this->get_instance(),
$this->get_context(),
@ -4176,6 +4136,7 @@ class assign {
if ($data->operation == 'grantextension') {
// Reset the form so the grant extension page will create the extension form.
$mform = null;
return 'grantextension';
} else if ($data->operation == 'setmarkingworkflowstate') {
return 'viewbatchsetmarkingworkflowstate';
@ -5832,10 +5793,16 @@ class assign {
require_once($CFG->dirroot . '/mod/assign/extensionform.php');
require_sesskey();
$users = optional_param('userid', 0, PARAM_INT);
if (!$users) {
$users = required_param('selectedusers', PARAM_SEQUENCE);
}
$userlist = explode(',', $users);
$formparams = array(
'instance' => $this->get_instance(),
'userscount' => 0,
'usershtml' => '',
'assign' => $this,
'userlist' => $userlist
);
$mform = new mod_assign_extension_form(null, $formparams);