Skip to content

Commit

Permalink
Merge branch 'MDL-63844-master' of git://github.com/aanabit/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
abgreeve committed Dec 18, 2018
2 parents 648afe7 + 26b34c3 commit c6f2f4a
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion user/amd/build/status_field.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion user/amd/src/status_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ define(['core/templates',
"status": parentContainer.data('status'),
"statusclass": parentContainer.find('span').attr('class'),
"timestart": parentContainer.data('timestart'),
"timeend": parentContainer.data('timeend')
"timeend": parentContainer.data('timeend'),
"timeenrolled": parentContainer.data('timeenrolled')
};

// Get default string for the modal and modal type.
Expand Down
10 changes: 9 additions & 1 deletion user/classes/output/status_field.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class status_field implements renderable, templatable {
/** @var int $timeend The timestamp when the user's enrolment ends. */
protected $timeend;

/** @var int $timeenrolled The timestamp when the user was enrolled. */
protected $timeenrolled;

/** @var user_enrolment_action[] $enrolactions Array of enrol action objects for the given enrolment method. */
protected $enrolactions;

Expand All @@ -90,16 +93,18 @@ class status_field implements renderable, templatable {
* @param int|null $timestart The timestamp when the user's enrolment starts.
* @param int|null $timeend The timestamp when the user's enrolment ends.
* @param user_enrolment_action[] $enrolactions Array of enrol action objects for the given enrolment method.
* @param int|null $timeenrolled The timestamp when the user was enrolled.
*/
public function __construct($enrolinstancename, $coursename, $fullname, $status, $timestart = null, $timeend = null,
$enrolactions = []) {
$enrolactions = [], $timeenrolled = null) {
$this->enrolinstancename = $enrolinstancename;
$this->coursename = $coursename;
$this->fullname = $fullname;
$this->status = $status;
$this->timestart = $timestart;
$this->timeend = $timeend;
$this->enrolactions = $enrolactions;
$this->timeenrolled = $timeenrolled;
}

/**
Expand Down Expand Up @@ -127,6 +132,9 @@ public function export_for_template(renderer_base $output) {
if ($this->timeend) {
$data->timeend = userdate($this->timeend);
}
if ($this->timeenrolled) {
$data->timeenrolled = userdate($this->timeenrolled);
}
$data->enrolactions = [];

foreach ($this->enrolactions as $enrolaction) {
Expand Down
4 changes: 3 additions & 1 deletion user/classes/participants_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ public function col_status($data) {
foreach ($userenrolments as $ue) {
$timestart = $ue->timestart;
$timeend = $ue->timeend;
$timeenrolled = $ue->timecreated;
$actions = $ue->enrolmentplugin->get_user_enrolment_actions($manager, $ue);
$instancename = $ue->enrolmentinstancename;

Expand All @@ -399,7 +400,8 @@ public function col_status($data) {
break;
}

$statusfield = new status_field($instancename, $coursename, $fullname, $status, $timestart, $timeend, $actions);
$statusfield = new status_field($instancename, $coursename, $fullname, $status, $timestart, $timeend,
$actions, $timeenrolled);
$statusfielddata = $statusfield->set_status($statusval)->export_for_template($OUTPUT);
$enrolstatusoutput .= $OUTPUT->render_from_template('core_user/status_field', $statusfielddata);
}
Expand Down
14 changes: 13 additions & 1 deletion user/templates/status_details.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* statusclass string - The CSS class for the enrolment status.
* timestart string - Optional. The enrolment time start.
* timeend string - Optional. The enrolment time end.
* timeenrolled string - Optional. The time when the user was enrolled.
Example context (json):
{
Expand All @@ -36,7 +37,8 @@
"status": "Active",
"statusclass": "label label-success",
"timestart": "1 January 2017",
"timeend": "31 January 2018"
"timeend": "31 January 2018",
"timeenrolled": "31 December 2016"
}
}}
<table class="table user-enrol-details">
Expand Down Expand Up @@ -94,4 +96,14 @@
</td>
</tr>
{{/timeend}}
{{#timeenrolled}}
<tr>
<th>
{{#str}}enroltimecreated, enrol{{/str}}
</th>
<td class="user-enrol-timeenrolled">
{{timeenrolled}}
</td>
</tr>
{{/timeenrolled}}
</table>
4 changes: 3 additions & 1 deletion user/templates/status_field.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* notcurrent boolean - Flag to indicate whether the user's enrolment is active, but not current.
* timestart string - Optional. The enrolment time start.
* timeend string - Optional. The enrolment time end.
* timeenrolled string - Optional. The time when the user was enrolled.
* enrolactions array - Optional. Array of enrol actions consisting of:
* url string - The URL of the enrol action link.
* attributes array - The array of attributes for the enrol action link.
Expand All @@ -43,6 +44,7 @@
"active": true,
"timestart": "1 January 2017",
"timeend": "31 January 2018",
"timeenrolled": "31 December 2016",
"enrolactions": [
{
"url": "#",
Expand All @@ -58,7 +60,7 @@
}
}}
<div data-fullname="{{fullname}}" data-coursename="{{coursename}}" data-enrolinstancename="{{enrolinstancename}}"
data-status="{{status}}" data-timestart="{{timestart}}" data-timeend="{{timeend}}">
data-status="{{status}}" data-timestart="{{timestart}}" data-timeend="{{timeend}}" data-timeenrolled="{{timeenrolled}}">
<span class="label {{#active}}label-success{{/active}}{{#suspended}}label-warning{{/suspended}}{{#notcurrent}}label-default{{/notcurrent}}">{{status}}</span>
<a data-action="showdetails" href="#" role="button" tabindex="0">{{!
}}{{#pix}}docs, core, {{enrolinstancename}}{{/pix}}{{!
Expand Down
2 changes: 2 additions & 0 deletions user/tests/behat/edit_user_enrolment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ Feature: Edit user enrolment
And I should see "Student 1" in the "Full name" "table_row"
And I should see "Active" in the "//td[@class='user-enrol-status']" "xpath_element"
And I should see "Manual enrolments" in the "Enrolment method" "table_row"
And I should see "Enrolment created"
And I click on "Cancel" "button" in the "Enrolment details" "dialogue"
And I click on "Manual enrolments" "icon" in the "student2" "table_row"
And I should see "Enrolment details"
And I should see "Student 2" in the "Full name" "table_row"
And I should see "Suspended" in the "//td[@class='user-enrol-status']" "xpath_element"
And I should see "Manual enrolments" in the "Enrolment method" "table_row"
And I should see "Enrolment created"
And "Edit enrolment" "icon" should exist in the "Enrolment method" "table_row"

@javascript
Expand Down

0 comments on commit c6f2f4a

Please sign in to comment.