コード例 #1
0
 /**
  * A collection of actions for a course.
  *
  * @param course_in_list $course The course to display actions for.
  * @return string
  */
 public function course_detail_actions(course_in_list $course)
 {
     $actions = \core_course\management\helper::get_course_detail_actions($course);
     if (empty($actions)) {
         return '';
     }
     $options = array();
     foreach ($actions as $action) {
         $options[] = $this->action_link($action['url'], $action['string']);
     }
     return html_writer::div(join(' | ', $options), 'listing-actions course-detail-listing-actions');
 }
コード例 #2
0
 /**
  * Tests fetching the course actions.
  */
 public function test_get_course_detail_actions()
 {
     $this->resetAfterTest(true);
     $generator = $this->getDataGenerator();
     $category = $generator->create_category();
     $course = $generator->create_course();
     $context = context_system::instance();
     list($user, $roleid) = $this->get_user_objects($generator, $context->id);
     $generator->enrol_user($user->id, $course->id, $roleid);
     course_capability_assignment::allow(array(self::COURSE_VIEW, self::COURSE_VIEWHIDDEN, 'moodle/course:update', 'moodle/course:enrolreview', 'moodle/course:delete', 'moodle/backup:backupcourse', 'moodle/restore:restorecourse'), $roleid, $context->id);
     $actions = \core_course\management\helper::get_course_detail_actions(new course_in_list($course));
     $this->assertInternalType('array', $actions);
     $this->assertArrayHasKey('view', $actions);
     $this->assertArrayHasKey('edit', $actions);
     $this->assertArrayHasKey('enrolledusers', $actions);
     $this->assertArrayHasKey('delete', $actions);
     $this->assertArrayHasKey('hide', $actions);
     $this->assertArrayHasKey('backup', $actions);
     $this->assertArrayHasKey('restore', $actions);
 }