Merge branch 'MDL-63844-master' of git://github.com/aanabit/moodle
authorAdrian Greeve <abgreeve@gmail.com>
Tue, 18 Dec 2018 17:11:38 +0000 (18:11 +0100)
committerAdrian Greeve <abgreeve@gmail.com>
Tue, 18 Dec 2018 17:11:38 +0000 (18:11 +0100)
user/amd/build/status_field.min.js
user/amd/src/status_field.js
user/classes/output/status_field.php
user/classes/participants_table.php
user/templates/status_details.mustache
user/templates/status_field.mustache
user/tests/behat/edit_user_enrolment.feature

index 2079e47..a26e99f 100644 (file)
Binary files a/user/amd/build/status_field.min.js and b/user/amd/build/status_field.min.js differ
index 23f5b7f..865f33c 100644 (file)
@@ -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.
index 18d36ba..a1953b1 100644 (file)
@@ -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;
 
@@ -90,9 +93,10 @@ 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;
@@ -100,6 +104,7 @@ class status_field implements renderable, templatable {
         $this->timestart = $timestart;
         $this->timeend = $timeend;
         $this->enrolactions = $enrolactions;
+        $this->timeenrolled = $timeenrolled;
     }
 
     /**
@@ -127,6 +132,9 @@ class status_field implements renderable, templatable {
         if ($this->timeend) {
             $data->timeend = userdate($this->timeend);
         }
+        if ($this->timeenrolled) {
+            $data->timeenrolled = userdate($this->timeenrolled);
+        }
         $data->enrolactions = [];
 
         foreach ($this->enrolactions as $enrolaction) {
index d686118..095ba8a 100644 (file)
@@ -375,6 +375,7 @@ class participants_table extends \table_sql {
             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;
 
@@ -399,7 +400,8 @@ class participants_table extends \table_sql {
                         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);
             }
index 120e44e..571798e 100644 (file)
@@ -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):
     {
@@ -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">
         </td>
     </tr>
     {{/timeend}}
+    {{#timeenrolled}}
+    <tr>
+        <th>
+            {{#str}}enroltimecreated, enrol{{/str}}
+        </th>
+        <td class="user-enrol-timeenrolled">
+            {{timeenrolled}}
+        </td>
+    </tr>
+    {{/timeenrolled}}
 </table>
index 0a59428..4235fc5 100644 (file)
@@ -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.
@@ -43,6 +44,7 @@
         "active": true,
         "timestart": "1 January 2017",
         "timeend": "31 January 2018",
+        "timeenrolled": "31 December 2016",
         "enrolactions": [
             {
                 "url": "#",
@@ -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}}{{!
index db3139d..a8f9733 100644 (file)
@@ -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