当前位置: 首页>>代码示例>>PHP>>正文


PHP course_change_sortorder_after_course函数代码示例

本文整理汇总了PHP中course_change_sortorder_after_course函数的典型用法代码示例。如果您正苦于以下问题:PHP course_change_sortorder_after_course函数的具体用法?PHP course_change_sortorder_after_course怎么用?PHP course_change_sortorder_after_course使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了course_change_sortorder_after_course函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_course_change_sortorder_after_course

 /**
  * Test course move after course.
  */
 public function test_course_change_sortorder_after_course()
 {
     global $DB;
     $this->resetAfterTest(true);
     $generator = $this->getDataGenerator();
     $category = $generator->create_category();
     $course3 = $generator->create_course(array('category' => $category->id));
     $course2 = $generator->create_course(array('category' => $category->id));
     $course1 = $generator->create_course(array('category' => $category->id));
     $context = $category->get_context();
     list($user, $roleid) = $this->get_user_objects($generator, $context->id);
     $caps = course_capability_assignment::allow('moodle/category:manage', $roleid, $context->id);
     $courses = $category->get_courses();
     $this->assertInternalType('array', $courses);
     $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses));
     $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id');
     $this->assertEquals(array_keys($dbcourses), array_keys($courses));
     // Test moving down.
     $this->assertTrue(course_change_sortorder_after_course($course1->id, $course3->id));
     $courses = $category->get_courses();
     $this->assertInternalType('array', $courses);
     $this->assertEquals(array($course2->id, $course3->id, $course1->id), array_keys($courses));
     $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id');
     $this->assertEquals(array_keys($dbcourses), array_keys($courses));
     // Test moving up.
     $this->assertTrue(course_change_sortorder_after_course($course1->id, $course2->id));
     $courses = $category->get_courses();
     $this->assertInternalType('array', $courses);
     $this->assertEquals(array($course2->id, $course1->id, $course3->id), array_keys($courses));
     $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id');
     $this->assertEquals(array_keys($dbcourses), array_keys($courses));
     // Test moving to the top.
     $this->assertTrue(course_change_sortorder_after_course($course1->id, 0));
     $courses = $category->get_courses();
     $this->assertInternalType('array', $courses);
     $this->assertEquals(array($course1->id, $course2->id, $course3->id), array_keys($courses));
     $dbcourses = $DB->get_records('course', array('category' => $category->id), 'sortorder', 'id');
     $this->assertEquals(array_keys($dbcourses), array_keys($courses));
 }
开发者ID:uniedpa,项目名称:moodle,代码行数:42,代码来源:courselib_test.php

示例2: action_course_change_sortorder_after_course

 /**
  * Changes the sort order so that the first course appears after the second course.
  *
  * @param int|\stdClass $courserecordorid
  * @param int $moveaftercourseid
  * @return bool
  * @throws \moodle_exception
  */
 public static function action_course_change_sortorder_after_course($courserecordorid, $moveaftercourseid)
 {
     $course = \get_course($courserecordorid);
     $category = \coursecat::get($course->category);
     if (!$category->can_resort_courses()) {
         $url = '/course/management.php?categoryid=' . $course->category;
         throw new \moodle_exception('nopermissions', 'error', $url, \get_string('resortcourses', 'moodle'));
     }
     return \course_change_sortorder_after_course($course, $moveaftercourseid);
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:18,代码来源:helper.php


注:本文中的course_change_sortorder_after_course函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。