MDL-59393 calendar: fix CiBoT complaints
authorRyan Wyllie <ryan@moodle.com>
Wed, 23 Aug 2017 02:07:50 +0000 (02:07 +0000)
committerRyan Wyllie <ryan@moodle.com>
Wed, 23 Aug 2017 02:09:43 +0000 (02:09 +0000)
calendar/amd/build/repository.min.js
calendar/amd/src/drag_drop.js
calendar/amd/src/repository.js
calendar/classes/local/api.php
calendar/externallib.php
calendar/tests/externallib_test.php
calendar/tests/local_api_test.php

index a7c085d..a33feed 100644 (file)
Binary files a/calendar/amd/build/repository.min.js and b/calendar/amd/build/repository.min.js differ
index f2b17e6..de085f0 100644 (file)
@@ -188,6 +188,8 @@ define([
     return {
         /**
          * Initialise the event handlers for the drag events.
+         *
+         * @param {object} root The root calendar element that containers the drag drop elements
          */
         init: function(root) {
             root = $(root);
index a8aa489..55c9db9 100644 (file)
@@ -116,8 +116,8 @@ define(['jquery', 'core/ajax'], function($, Ajax) {
         var request = {
             methodname: 'core_calendar_update_event_start_day',
             args: {
-                eventId: eventId,
-                dayTimestamp: dayTimestamp
+                eventid: eventId,
+                daytimestamp: dayTimestamp
             }
         };
 
index 9f80509..5c5d7d6 100644 (file)
@@ -222,19 +222,19 @@ class api {
      * modified, the time of day for the event will be left as is.
      *
      * @param event_interface $event The existing event to modify
-     * @param DateTimeInterface $startDate The new date to use for the start day
+     * @param DateTimeInterface $startdate The new date to use for the start day
      * @return event_interface The new event with updated start date
      */
     public static function update_event_start_day(
         event_interface $event,
-        \DateTimeInterface $startDate
+        \DateTimeInterface $startdate
     ) {
         $mapper = container::get_event_mapper();
         $legacyevent = $mapper->from_event_to_legacy_event($event);
         $starttime = $event->get_times()->get_start_time()->setDate(
-            $startDate->format('Y'),
-            $startDate->format('n'),
-            $startDate->format('j')
+            $startdate->format('Y'),
+            $startdate->format('n'),
+            $startdate->format('j')
         );
 
         // This function does our capability checks.
index ba62951..6000a25 100644 (file)
@@ -919,8 +919,8 @@ class core_calendar_external extends external_api {
     public static function update_event_start_day_parameters() {
         return new external_function_parameters(
             [
-                'eventId' => new external_value(PARAM_INT, 'Id of event to be updated', VALUE_REQUIRED),
-                'dayTimestamp' => new external_value(PARAM_INT, 'Timestamp for the new start day', VALUE_REQUIRED),
+                'eventid' => new external_value(PARAM_INT, 'Id of event to be updated', VALUE_REQUIRED),
+                'daytimestamp' => new external_value(PARAM_INT, 'Timestamp for the new start day', VALUE_REQUIRED),
             ]
         );
     }
@@ -934,25 +934,25 @@ class core_calendar_external extends external_api {
      *
      * The event's original time of day is maintained, only the date is shifted.
      *
-     * @param int $eventId Id of event to be updated
-     * @param int $dayTimestamp Timestamp for the new start day
+     * @param int $eventid Id of event to be updated
+     * @param int $daytimestamp Timestamp for the new start day
      * @return  array
      */
-    public static function update_event_start_day($eventId, $dayTimestamp) {
+    public static function update_event_start_day($eventid, $daytimestamp) {
         global $USER, $PAGE;
 
         // Parameter validation.
         $params = self::validate_parameters(self::update_event_start_day_parameters(), [
-            'eventId' => $eventId,
-            'dayTimestamp' => $dayTimestamp,
+            'eventid' => $eventid,
+            'daytimestamp' => $daytimestamp,
         ]);
 
         $vault = event_container::get_event_vault();
         $mapper = event_container::get_event_mapper();
-        $event = $vault->get_event_by_id($eventId);
+        $event = $vault->get_event_by_id($eventid);
 
         if (!$event) {
-            throw new \moodle_exception('Unable to find event with id ' . $eventId);
+            throw new \moodle_exception('Unable to find event with id ' . $eventid);
         }
 
         $legacyevent = $mapper->from_event_to_legacy_event($event);
@@ -963,7 +963,7 @@ class core_calendar_external extends external_api {
 
         self::validate_context($legacyevent->context);
 
-        $newdate = usergetdate($dayTimestamp);
+        $newdate = usergetdate($daytimestamp);
         $startdatestring = implode('-', [$newdate['year'], $newdate['mon'], $newdate['mday']]);
         $startdate = new DateTimeImmutable($startdatestring);
         $event = local_api::update_event_start_day($event, $startdate);
index bbf9f37..8098f72 100644 (file)
@@ -1300,8 +1300,8 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
         $user = $generator->create_user();
         $roleid = $generator->create_role();
         $context = \context_system::instance();
-        $originalStartTime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
-        $newStartDate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
+        $originalstarttime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
+        $newstartdate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
         $expected = new DateTimeImmutable('2018-02-2T15:00:00+08:00');
 
         $generator->role_assign($roleid, $user->id, $context->id);
@@ -1318,11 +1318,11 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
             null,
             [
                 'courseid' => 0,
-                'timestart' => $originalStartTime->getTimestamp()
+                'timestart' => $originalstarttime->getTimestamp()
             ]
         );
 
-        $result = core_calendar_external::update_event_start_day($event->id, $newStartDate->getTimestamp());
+        $result = core_calendar_external::update_event_start_day($event->id, $newstartdate->getTimestamp());
         $result = external_api::clean_returnvalue(
             core_calendar_external::update_event_start_day_returns(),
             $result
@@ -1340,8 +1340,8 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
         $user = $generator->create_user();
         $roleid = $generator->create_role();
         $context = \context_system::instance();
-        $originalStartTime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
-        $newStartDate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
+        $originalstarttime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
+        $newstartdate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
         $expected = new DateTimeImmutable('2018-02-2T15:00:00+08:00');
 
         $generator->role_assign($roleid, $user->id, $context->id);
@@ -1358,13 +1358,13 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
             null,
             [
                 'courseid' => 0,
-                'timestart' => $originalStartTime->getTimestamp()
+                'timestart' => $originalstarttime->getTimestamp()
             ]
         );
 
         assign_capability('moodle/calendar:manageownentries', CAP_PROHIBIT, $roleid, $context, true);
         $this->expectException('moodle_exception');
-        $result = core_calendar_external::update_event_start_day($event->id, $newStartDate->getTimestamp());
+        $result = core_calendar_external::update_event_start_day($event->id, $newstartdate->getTimestamp());
         $result = external_api::clean_returnvalue(
             core_calendar_external::update_event_start_day_returns(),
             $result
@@ -1378,12 +1378,12 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
         $generator = $this->getDataGenerator();
         $user = $generator->create_user();
         $course = $generator->create_course();
-        $moduleinstance = $generator->get_plugin_generator('mod_assign')
-                                    ->create_instance(['course' => $course->id]);
+        $plugingenerator = $generator->get_plugin_generator('mod_assign');
+        $moduleinstance = $plugingenerator->create_instance(['course' => $course->id]);
         $roleid = $generator->create_role();
         $context = \context_course::instance($course->id);
-        $originalStartTime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
-        $newStartDate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
+        $originalstarttime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
+        $newstartdate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
         $expected = new DateTimeImmutable('2018-02-2T15:00:00+08:00');
 
         $generator->role_assign($roleid, $user->id, $context->id);
@@ -1402,13 +1402,13 @@ class core_calendar_externallib_testcase extends externallib_advanced_testcase {
                 'modulename' => 'assign',
                 'instance' => $moduleinstance->id,
                 'courseid' => $course->id,
-                'timestart' => $originalStartTime->getTimestamp()
+                'timestart' => $originalstarttime->getTimestamp()
             ]
         );
 
         assign_capability('moodle/calendar:manageentries', CAP_ALLOW, $roleid, $context, true);
         $this->expectException('moodle_exception');
-        $result = core_calendar_external::update_event_start_day($event->id, $newStartDate->getTimestamp());
+        $result = core_calendar_external::update_event_start_day($event->id, $newstartdate->getTimestamp());
         $result = external_api::clean_returnvalue(
             core_calendar_external::update_event_start_day_returns(),
             $result
index 8e8ad27..7f17a28 100644 (file)
@@ -870,8 +870,8 @@ class core_calendar_local_api_testcase extends advanced_testcase {
         $user = $generator->create_user();
         $roleid = $generator->create_role();
         $context = \context_system::instance();
-        $originalStartTime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
-        $newStartDate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
+        $originalstarttime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
+        $newstartdate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
         $expected = new DateTimeImmutable('2018-02-2T15:00:00+08:00');
         $mapper = container::get_event_mapper();
 
@@ -886,11 +886,11 @@ class core_calendar_local_api_testcase extends advanced_testcase {
             'userid' => $user->id,
             'eventtype' => 'user',
             'repeats' => 0,
-            'timestart' => $originalStartTime->getTimestamp(),
+            'timestart' => $originalstarttime->getTimestamp(),
         ]);
         $event = $mapper->from_legacy_event_to_event($event);
 
-        $newEvent = \core_calendar\local\api::update_event_start_day($event, $newStartDate);
+        $newEvent = \core_calendar\local\api::update_event_start_day($event, $newstartdate);
         $actual = $newEvent->get_times()->get_start_time();
 
         $this->assertEquals($expected->getTimestamp(), $actual->getTimestamp());
@@ -905,8 +905,8 @@ class core_calendar_local_api_testcase extends advanced_testcase {
         $user = $generator->create_user();
         $roleid = $generator->create_role();
         $context = \context_system::instance();
-        $originalStartTime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
-        $newStartDate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
+        $originalstarttime = new DateTimeImmutable('2017-01-1T15:00:00+08:00');
+        $newstartdate = new DateTimeImmutable('2018-02-2T10:00:00+08:00');
         $expected = new DateTimeImmutable('2018-02-2T15:00:00+08:00');
         $mapper = container::get_event_mapper();
 
@@ -920,12 +920,12 @@ class core_calendar_local_api_testcase extends advanced_testcase {
             'userid' => $user->id,
             'eventtype' => 'user',
             'repeats' => 0,
-            'timestart' => $originalStartTime->getTimestamp(),
+            'timestart' => $originalstarttime->getTimestamp(),
         ]);
         $event = $mapper->from_legacy_event_to_event($event);
 
         assign_capability('moodle/calendar:manageownentries', CAP_PROHIBIT, $roleid, $context, true);
         $this->expectException('moodle_exception');
-        $newEvent = \core_calendar\local\api::update_event_start_day($event, $newStartDate);
+        $newEvent = \core_calendar\local\api::update_event_start_day($event, $newstartdate);
     }
 }