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


PHP move_section_to函数代码示例

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


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

示例1: create_section

 /**
  * Create a section.
  */
 private function create_section($course, $section, $prepend = false)
 {
     global $DB;
     $maxid = $DB->get_field('course_sections', 'MAX(section)', array('course' => $course->id));
     $section->section = $maxid + 1;
     \cattarget_section\section::create_section($course, $section);
     if ($prepend) {
         move_section_to($course, $section->section, 1);
     }
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:13,代码来源:course.php

示例2: testMoveSection

 function testMoveSection()
 {
     global $DB;
     $course = new stdClass();
     $course->numsections = 10;
     $course->id = 1;
     $sections = array(20 => 0, 21 => 1, 22 => 2, 23 => 3, 24 => 4, 25 => 5);
     $DB->setReturnValueAt(0, 'get_records_menu', $sections);
     $DB->expectAt(0, 'set_field', array('course_sections', 'section', 0, array('id' => 20)));
     $DB->expectAt(1, 'set_field', array('course_sections', 'section', 1, array('id' => 21)));
     $DB->expectAt(2, 'set_field', array('course_sections', 'section', 2, array('id' => 23)));
     $DB->expectAt(3, 'set_field', array('course_sections', 'section', 3, array('id' => 24)));
     $DB->expectAt(4, 'set_field', array('course_sections', 'section', 4, array('id' => 22)));
     $DB->expectAt(5, 'set_field', array('course_sections', 'section', 5, array('id' => 25)));
     move_section_to($course, 2, 4);
     $DB->setReturnValueAt(1, 'get_records_menu', $sections);
     $DB->expectAt(6, 'set_field', array('course_sections', 'section', 0, array('id' => 20)));
     $DB->expectAt(7, 'set_field', array('course_sections', 'section', 1, array('id' => 24)));
     $DB->expectAt(8, 'set_field', array('course_sections', 'section', 2, array('id' => 21)));
     $DB->expectAt(9, 'set_field', array('course_sections', 'section', 3, array('id' => 22)));
     $DB->expectAt(10, 'set_field', array('course_sections', 'section', 4, array('id' => 23)));
     $DB->expectAt(11, 'set_field', array('course_sections', 'section', 5, array('id' => 25)));
     move_section_to($course, 4, 0);
 }
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:24,代码来源:testcourselib.php

示例3: delete_section

 /**
  * Deletes a section
  *
  * Do not call this function directly, instead call {@link course_delete_section()}
  *
  * @param int|stdClass|section_info $section
  * @param bool $forcedeleteifnotempty if set to false section will not be deleted if it has modules in it.
  * @return bool whether section was deleted
  */
 public function delete_section($section, $forcedeleteifnotempty = false)
 {
     global $DB;
     if (!$this->uses_sections()) {
         // Not possible to delete section if sections are not used.
         return false;
     }
     if (!is_object($section)) {
         $section = $DB->get_record('course_sections', array('course' => $this->get_courseid(), 'section' => $section), 'id,section,sequence,summary');
     }
     if (!$section || !$section->section) {
         // Not possible to delete 0-section.
         return false;
     }
     if (!$forcedeleteifnotempty && (!empty($section->sequence) || !empty($section->summary))) {
         return false;
     }
     $course = $this->get_course();
     // Remove the marker if it points to this section.
     if ($section->section == $course->marker) {
         course_set_marker($course->id, 0);
     }
     $lastsection = $DB->get_field_sql('SELECT max(section) from {course_sections}
                         WHERE course = ?', array($course->id));
     // Find out if we need to descrease the 'numsections' property later.
     $courseformathasnumsections = array_key_exists('numsections', $this->get_format_options());
     $decreasenumsections = $courseformathasnumsections && $section->section <= $course->numsections;
     // Move the section to the end.
     move_section_to($course, $section->section, $lastsection, true);
     // Delete all modules from the section.
     foreach (preg_split('/,/', $section->sequence, -1, PREG_SPLIT_NO_EMPTY) as $cmid) {
         course_delete_module($cmid);
     }
     // Delete section and it's format options.
     $DB->delete_records('course_format_options', array('sectionid' => $section->id));
     $DB->delete_records('course_sections', array('id' => $section->id));
     rebuild_course_cache($course->id, true);
     // Descrease 'numsections' if needed.
     if ($decreasenumsections) {
         $this->update_course_format_options(array('numsections' => $course->numsections - 1));
     }
     return true;
 }
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:52,代码来源:lib.php

示例4: switch

switch ($requestmethod) {
    case 'POST':
        switch ($class) {
            case 'section':
                if (!$DB->record_exists('course_sections', array('course' => $course->id, 'section' => $id))) {
                    throw new moodle_exception('AJAX commands.php: Bad Section ID ' . $id);
                }
                switch ($field) {
                    case 'visible':
                        require_capability('moodle/course:sectionvisibility', $coursecontext);
                        $resourcestotoggle = set_section_visible($course->id, $id, $value);
                        echo json_encode(array('resourcestotoggle' => $resourcestotoggle));
                        break;
                    case 'move':
                        require_capability('moodle/course:movesections', $coursecontext);
                        move_section_to($course, $id, $value);
                        // See if format wants to do something about it
                        $response = course_get_format($course)->ajax_section_move();
                        if ($response !== null) {
                            echo json_encode($response);
                        }
                        break;
                }
                break;
            case 'resource':
                switch ($field) {
                    case 'visible':
                        require_capability('moodle/course:activityvisibility', $modcontext);
                        set_coursemodule_visible($cm->id, $value);
                        \core\event\course_module_updated::create_from_cm($cm, $modcontext)->trigger();
                        break;
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:31,代码来源:rest.php

示例5: set_user_preference

            set_user_preference('usemodchooser', $modchooser);
        }
    }
    if (has_capability('moodle/course:sectionvisibility', $context)) {
        if ($hide && confirm_sesskey()) {
            set_section_visible($course->id, $hide, '0');
            redirect($PAGE->url);
        }
        if ($show && confirm_sesskey()) {
            set_section_visible($course->id, $show, '1');
            redirect($PAGE->url);
        }
    }
    if (!empty($section) && !empty($move) && has_capability('moodle/course:movesections', $context) && confirm_sesskey()) {
        $destsection = $section + $move;
        if (move_section_to($course, $section, $destsection)) {
            if ($course->id == SITEID) {
                redirect($CFG->wwwroot . '/?redirect=0');
            } else {
                redirect(course_get_url($course));
            }
        } else {
            echo $OUTPUT->notification('An error occurred while moving a section');
        }
    }
} else {
    $USER->editing = 0;
    /**
     * Hide blocks
     * @author André Rodrigues <Math>
     * @date 2015/12/19
开发者ID:dibarbado,项目名称:moodle,代码行数:31,代码来源:view.php

示例6: test_move_section_marker

 public function test_move_section_marker()
 {
     global $DB;
     $this->resetAfterTest(true);
     $this->getDataGenerator()->create_course(array('numsections' => 5), array('createsections' => true));
     $course = $this->getDataGenerator()->create_course(array('numsections' => 10), array('createsections' => true));
     // Set course marker to the section we are going to move..
     course_set_marker($course->id, 2);
     // Verify that the course marker is set correctly.
     $course = $DB->get_record('course', array('id' => $course->id));
     $this->assertEquals(2, $course->marker);
     // Test move the marked section down..
     move_section_to($course, 2, 4);
     // Verify that the coruse marker has been moved along with the section..
     $course = $DB->get_record('course', array('id' => $course->id));
     $this->assertEquals(4, $course->marker);
     // Test move the marked section up..
     move_section_to($course, 4, 3);
     // Verify that the course marker has been moved along with the section..
     $course = $DB->get_record('course', array('id' => $course->id));
     $this->assertEquals(3, $course->marker);
     // Test moving a non-marked section above the marked section..
     move_section_to($course, 4, 2);
     // Verify that the course marker has been moved down to accomodate..
     $course = $DB->get_record('course', array('id' => $course->id));
     $this->assertEquals(4, $course->marker);
     // Test moving a non-marked section below the marked section..
     move_section_to($course, 3, 6);
     // Verify that the course marker has been up to accomodate..
     $course = $DB->get_record('course', array('id' => $course->id));
     $this->assertEquals(3, $course->marker);
 }
开发者ID:uniedpa,项目名称:moodle,代码行数:32,代码来源:courselib_test.php

示例7: move_section

/**
 * Moves a section up or down by 1. CANNOT BE USED DIRECTLY BY AJAX!
 *
 * @param object $course course object
 * @param int $section Section number (not id!!!)
 * @param int $move (-1 or 1)
 * @return boolean true if section moved successfully
 * @todo MDL-33379 remove this function in 2.5
 */
function move_section($course, $section, $move)
{
    debugging('This function will be removed before 2.5 is released please use move_section_to', DEBUG_DEVELOPER);
    /// Moves a whole course section up and down within the course
    global $USER;
    if (!$move) {
        return true;
    }
    $sectiondest = $section + $move;
    // compartibility with course formats using field 'numsections'
    $courseformatoptions = course_get_format($course)->get_format_options();
    if (array_key_exists('numsections', $courseformatoptions) && $sectiondest > $courseformatoptions['numsections'] or $sectiondest < 1) {
        return false;
    }
    $retval = move_section_to($course, $section, $sectiondest);
    return $retval;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:26,代码来源:lib.php

示例8: move_section

/**
 * Moves a section up or down by 1. CANNOT BE USED DIRECTLY BY AJAX!
 *
 * @param object $course course object
 * @param int $section Section number (not id!!!)
 * @param int $move (-1 or 1)
 * @return boolean true if section moved successfully
 * @todo MDL-33379 remove this function in 2.5
 */
function move_section($course, $section, $move) {
    debugging('This function will be removed before 2.5 is released please use move_section_to', DEBUG_DEVELOPER);

/// Moves a whole course section up and down within the course
    global $USER, $DB;

    if (!$move) {
        return true;
    }

    $sectiondest = $section + $move;

    if ($sectiondest > $course->numsections or $sectiondest < 1) {
        return false;
    }

    $retval = move_section_to($course, $section, $sectiondest);
    // If section moved, then rebuild course cache.
    if ($retval) {
        rebuild_course_cache($course->id, true);
    }
    return $retval;
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:32,代码来源:lib.php

示例9: print_error

     print_error('cantcreatesection', 'error', null, $course->fullname);
     return;
 }
 $pbar->update_full(5, get_string('creating_section', 'format_onetopic'));
 //Assign same section info
 $data = new stdClass();
 $data->course = $sectioninfo->course;
 $data->section = $num_newsection;
 //The name is not duplicated
 //$data->name = $sectioninfo->name;
 $data->summary = $sectioninfo->summary;
 $data->summaryformat = $sectioninfo->summaryformat;
 $data->visible = $sectioninfo->visible;
 $data->availability = $sectioninfo->availability;
 $new_section_id = $DB->insert_record('course_sections', $data, true);
 $moved = move_section_to($course, $num_newsection, $section + 1);
 if ($moved) {
     $num_newsection = $section + 1;
 }
 $format_options = $course_format->get_format_options($section);
 if (is_array($format_options) && count($format_options) > 0) {
     $format_options['id'] = $new_section_id;
     $course_format->update_section_format_options($format_options);
 }
 // Trigger an event for course section update.
 $event = \core\event\course_section_updated::create(array('objectid' => $new_section_id, 'courseid' => $course->id, 'context' => $context, 'other' => array('sectionnum' => $num_newsection)));
 $event->trigger();
 $pbar->update_full(10, get_string('rebuild_course_cache', 'format_onetopic'));
 //rebuild_course_cache($course->id, true);
 $new_sectioninfo = $modinfo->get_section_info($num_newsection);
 $modules = array();
开发者ID:dibarbado,项目名称:moodle,代码行数:31,代码来源:duplicate.php

示例10: delete

 /**
  * Delete a section.
  */
 public function delete($courses)
 {
     global $DB;
     // Get the section identifier.
     $sectionident = $this->get_identifier();
     if ($sectionident == 0) {
         throw new \moodle_exception("Cannot delete section 0.");
     }
     // We have a section number, delete that section.
     foreach ($courses as $course) {
         // Get the last section id.
         $lastid = $DB->get_field('course_sections', 'MAX(section)', array('course' => $course->id));
         // Move this to be the last section.
         move_section_to($course, $sectionident, $lastid + 1, true);
         // Get section info, the number of sections won't have changed so we are now $lastid.
         $modinfo = get_fast_modinfo($course);
         $section = $modinfo->get_section_info($lastid);
         // Delete it.
         course_delete_section($course, $section);
     }
 }
开发者ID:unikent,项目名称:moodle-tool_cat,代码行数:24,代码来源:section.php


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