MDL-73354 mod_assign: Fixed broken timed assignment feature.
This commit is contained in:
committed by
Adrian Greeve
parent
c565ec4535
commit
ac32195022
@@ -245,9 +245,11 @@ class renderer extends \plugin_renderer_base {
|
||||
$this->page->set_heading($this->page->course->fullname);
|
||||
|
||||
$description = $header->preface;
|
||||
if ($header->showintro) {
|
||||
if ($header->showintro || $header->activity) {
|
||||
$description = $this->output->box_start('generalbox boxaligncenter', 'intro');
|
||||
$description .= format_module_intro('assign', $header->assign, $header->coursemoduleid);
|
||||
if ($header->showintro) {
|
||||
$description .= format_module_intro('assign', $header->assign, $header->coursemoduleid);
|
||||
}
|
||||
if ($header->activity) {
|
||||
$description .= $this->format_activity_text($header->assign, $header->coursemoduleid);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ class user_submission_actionmenu implements templatable, renderable {
|
||||
protected $submission;
|
||||
/** @var stdClass A team submission for this activity. */
|
||||
protected $teamsubmission;
|
||||
/** @var int The time limit for the submission. 0 = no time limit. */
|
||||
protected $timelimit;
|
||||
|
||||
/**
|
||||
* Constructor for this object.
|
||||
@@ -59,15 +61,17 @@ class user_submission_actionmenu implements templatable, renderable {
|
||||
* @param bool $showedit Whether to show the edit button.
|
||||
* @param stdClass|null $submission A submission for this activity.
|
||||
* @param stdClass|null $teamsubmission A team submission for this activity.
|
||||
* @param int|null $timelimit The time limit for completing this activity.
|
||||
*/
|
||||
public function __construct(int $cmid, bool $showsubmit, bool $showedit, stdClass $submission = null,
|
||||
stdClass $teamsubmission = null) {
|
||||
stdClass $teamsubmission = null, $timelimit = 0) {
|
||||
|
||||
$this->cmid = $cmid;
|
||||
$this->showsubmit = $showsubmit;
|
||||
$this->showedit = $showedit;
|
||||
$this->submission = $submission;
|
||||
$this->teamsubmission = $teamsubmission;
|
||||
$this->timelimit = $timelimit;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,9 +125,28 @@ class user_submission_actionmenu implements templatable, renderable {
|
||||
$data['edit']['help'] = $newattempthelp->export_for_template($output);
|
||||
}
|
||||
if ($status === ASSIGN_SUBMISSION_STATUS_NEW) {
|
||||
$newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get', true);
|
||||
$data['edit']['button'] = $newattemptbutton->export_for_template($output);
|
||||
$data['edit']['help'] = '';
|
||||
|
||||
if ($this->timelimit && empty($this->submission->timestarted)) {
|
||||
$confirmation = new \confirm_action(
|
||||
get_string('confirmstart', 'assign', format_time($this->timelimit)),
|
||||
null,
|
||||
get_string('beginassignment', 'assign')
|
||||
);
|
||||
$urlparams = array('id' => $this->cmid, 'action' => 'editsubmission');
|
||||
$beginbutton = new \action_link(
|
||||
new moodle_url('/mod/assign/view.php', $urlparams),
|
||||
get_string('beginassignment', 'assign'),
|
||||
$confirmation,
|
||||
['class' => 'btn btn-primary']
|
||||
);
|
||||
$data['edit']['button'] = $beginbutton->export_for_template($output);
|
||||
$data['edit']['begin'] = true;
|
||||
$data['edit']['help'] = '';
|
||||
} else {
|
||||
$newattemptbutton = new single_button($url, get_string('addsubmission', 'mod_assign'), 'get', true);
|
||||
$data['edit']['button'] = $newattemptbutton->export_for_template($output);
|
||||
$data['edit']['help'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->showsubmit) {
|
||||
|
||||
@@ -4929,12 +4929,13 @@ class assign {
|
||||
$bc->content = $navbc;
|
||||
$PAGE->blocks->add_fake_block($bc, reset($regions));
|
||||
}
|
||||
$PAGE->activityheader->disable();
|
||||
|
||||
$PAGE->activityheader->set_hidecompletion(true);
|
||||
|
||||
$o .= $this->get_renderer()->render(
|
||||
new assign_header($this->get_instance(),
|
||||
$this->get_context(),
|
||||
$this->show_intro(),
|
||||
false,
|
||||
$this->get_course_module()->id,
|
||||
$title,
|
||||
'',
|
||||
@@ -5979,7 +5980,8 @@ class assign {
|
||||
$showsubmit,
|
||||
$showedit,
|
||||
$submission,
|
||||
$teamsubmission
|
||||
$teamsubmission,
|
||||
$instance->timelimit
|
||||
);
|
||||
|
||||
return $this->get_renderer()->render($actionbuttons);
|
||||
|
||||
@@ -166,12 +166,19 @@
|
||||
{{/previoussubmission}}
|
||||
{{#edit}}
|
||||
<div class="col-xs-6 mr-3">
|
||||
{{#button}}
|
||||
{{>core/single_button}}
|
||||
{{/button}}
|
||||
{{#help}}
|
||||
{{>core/help_icon}}
|
||||
{{/help}}
|
||||
{{#begin}}
|
||||
{{#button}}
|
||||
{{>core/action_link}}
|
||||
{{/button}}
|
||||
{{/begin}}
|
||||
{{^begin}}
|
||||
{{#button}}
|
||||
{{>core/single_button}}
|
||||
{{/button}}
|
||||
{{#help}}
|
||||
{{>core/help_icon}}
|
||||
{{/help}}
|
||||
{{/begin}}
|
||||
</div>
|
||||
{{/edit}}
|
||||
{{#remove}}
|
||||
|
||||
Reference in New Issue
Block a user