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


PHP course_change_visibility函数代码示例

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


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

示例1: test_course_change_visibility

 /**
  * Tests changing the visibility of a course.
  */
 public function test_course_change_visibility()
 {
     global $DB;
     $this->resetAfterTest(true);
     $generator = $this->getDataGenerator();
     $category = $generator->create_category();
     $course = $generator->create_course(array('category' => $category->id));
     $this->assertEquals('1', $course->visible);
     $this->assertEquals('1', $course->visibleold);
     $this->assertTrue(course_change_visibility($course->id, false));
     $course = $DB->get_record('course', array('id' => $course->id));
     $this->assertEquals('0', $course->visible);
     $this->assertEquals('0', $course->visibleold);
     $this->assertTrue(course_change_visibility($course->id, true));
     $course = $DB->get_record('course', array('id' => $course->id));
     $this->assertEquals('1', $course->visible);
     $this->assertEquals('1', $course->visibleold);
 }
开发者ID:uniedpa,项目名称:moodle,代码行数:21,代码来源:courselib_test.php

示例2: action_course_hide

 /**
  * Makes a course hidden given a \course_in_list object.
  *
  * @param \course_in_list $course
  * @return bool
  * @throws \moodle_exception
  */
 public static function action_course_hide(\course_in_list $course)
 {
     if (!$course->can_change_visibility()) {
         throw new \moodle_exception('permissiondenied', 'error', '', null, 'course_in_list::can_change_visbility');
     }
     return course_change_visibility($course->id, false);
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:14,代码来源:helper.php

示例3: test_can_access_course

 /**
  * Test to confirm that subscriptions for users who fail can_access_course(), are deactivated.
  */
 public function test_can_access_course()
 {
     // Enrol the user as a teacher. This role should have the required capability.
     $this->getDataGenerator()->enrol_user($this->user->id, $this->course->id, $this->teacherrole->id);
     // Strip the ability to see hidden courses, so we'll fail the check_subscriptions->user_can_access_course call.
     $context = \context_course::instance($this->course->id);
     assign_capability('moodle/course:viewhiddencourses', CAP_PROHIBIT, $this->teacherrole->id, $context);
     // Subscription should be active to start with.
     $this->assertEquals(true, \tool_monitor\subscription_manager::subscription_is_active($this->subscription));
     // Hide the course.
     course_change_visibility($this->course->id, false);
     // Run the task.
     $task = new \tool_monitor\task\check_subscriptions();
     $task->execute();
     // The subscription should be inactive. Pass in the id only to refetch the data.
     $this->reload_subscription();
     $this->assertEquals(false, \tool_monitor\subscription_manager::subscription_is_active($this->subscription));
 }
开发者ID:sirromas,项目名称:lms,代码行数:21,代码来源:task_check_subscriptions_test.php

示例4: process_group_tag


//.........这里部分代码省略.........
         }
     }
     $recstatus = $this->get_recstatus($tagcontents, 'group');
     if (empty($group->coursecode)) {
         $this->log_line('Error: Unable to find course code in \'group\' element.');
     } else {
         // First, truncate the course code if desired.
         if (intval($truncatecoursecodes) > 0) {
             $group->coursecode = $truncatecoursecodes > 0 ? substr($group->coursecode, 0, intval($truncatecoursecodes)) : $group->coursecode;
         }
         // For compatibility with the (currently inactive) course aliasing, we need this to be an array.
         $group->coursecode = array($group->coursecode);
         // Third, check if the course(s) exist.
         foreach ($group->coursecode as $coursecode) {
             $coursecode = trim($coursecode);
             $dbcourse = $DB->get_record('course', array('idnumber' => $coursecode));
             if (!$dbcourse) {
                 if (!$createnewcourses) {
                     $this->log_line("Course {$coursecode} not found in Moodle's course idnumbers.");
                 } else {
                     // Create the (hidden) course(s) if not found.
                     $courseconfig = get_config('moodlecourse');
                     // Load Moodle Course shell defaults.
                     // New course.
                     $course = new stdClass();
                     foreach ($this->coursemappings as $courseattr => $imsname) {
                         if ($imsname == 'ignore') {
                             continue;
                         }
                         // Check if the IMS file contains the mapped tag, otherwise fallback on coursecode.
                         if ($imsname == 'coursecode') {
                             $course->{$courseattr} = $coursecode;
                         } else {
                             if (!empty($group->{$imsname})) {
                                 $course->{$courseattr} = $group->{$imsname};
                             } else {
                                 $this->log_line('No ' . $imsname . ' description tag found for ' . $coursecode . ' coursecode, using ' . $coursecode . ' instead');
                                 $course->{$courseattr} = $coursecode;
                             }
                         }
                     }
                     $course->idnumber = $coursecode;
                     $course->format = $courseconfig->format;
                     $course->visible = $courseconfig->visible;
                     $course->newsitems = $courseconfig->newsitems;
                     $course->showgrades = $courseconfig->showgrades;
                     $course->showreports = $courseconfig->showreports;
                     $course->maxbytes = $courseconfig->maxbytes;
                     $course->groupmode = $courseconfig->groupmode;
                     $course->groupmodeforce = $courseconfig->groupmodeforce;
                     $course->enablecompletion = $courseconfig->enablecompletion;
                     // Insert default names for teachers/students, from the current language.
                     // Handle course categorisation (taken from the group.org.orgunit or group.org.id fields if present).
                     $course->category = $this->get_category_from_group($group->categories);
                     $course->startdate = time();
                     // Choose a sort order that puts us at the start of the list!
                     $course->sortorder = 0;
                     $course = create_course($course);
                     $this->log_line("Created course {$coursecode} in Moodle (Moodle ID is {$course->id})");
                 }
             } else {
                 if ($recstatus == self::IMSENTERPRISE_UPDATE && $dbcourse) {
                     if ($updatecourses) {
                         // Update course. Allowed fields to be updated are:
                         // Short Name, and Full Name.
                         $hasupdates = false;
                         if (!empty($group->short)) {
                             if ($group->short != $dbcourse->shortname) {
                                 $dbcourse->shortname = $group->short;
                                 $hasupdates = true;
                             }
                         }
                         if (!empty($group->full)) {
                             if ($group->full != $dbcourse->fullname) {
                                 $dbcourse->fullname = $group->full;
                                 $hasupdates = true;
                             }
                         }
                         if ($hasupdates) {
                             update_course($dbcourse);
                             $courseid = $dbcourse->id;
                             $this->log_line("Updated course {$coursecode} in Moodle (Moodle ID is {$courseid})");
                         }
                     } else {
                         // Update courses option is not enabled. Ignore.
                         $this->log_line("Ignoring update to course {$coursecode}");
                     }
                 } else {
                     if ($recstatus == self::IMSENTERPRISE_DELETE && $dbcourse) {
                         // If course does exist, but recstatus==3 (delete), then set the course as hidden.
                         $courseid = $dbcourse->id;
                         $show = false;
                         course_change_visibility($courseid, $show);
                         $this->log_line("Updated (set to hidden) course {$coursecode} in Moodle (Moodle ID is {$courseid})");
                     }
                 }
             }
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:lib.php


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