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


PHP grade_tree::locate_element方法代码示例

本文整理汇总了PHP中grade_tree::locate_element方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_tree::locate_element方法的具体用法?PHP grade_tree::locate_element怎么用?PHP grade_tree::locate_element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在grade_tree的用法示例。


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

示例1: array

 /**
  * Given the grade tree and an array of element ids (e.g. c15, i42), and expecting the 'moveafter' URL param,
  * moves the selected items to the requested location. Then redirects the user to the given $returnurl
  *
  * @param object $gtree The grade tree (a recursive representation of the grade categories and grade items)
  * @param array $eids
  * @param string $returnurl
  */
 function move_elements($eids, $returnurl)
 {
     $moveafter = required_param('moveafter', PARAM_INT);
     if (!is_array($eids)) {
         $eids = array($eids);
     }
     if (!($after_el = $this->gtree->locate_element("cg{$moveafter}"))) {
         print_error('invalidelementid', '', $returnurl);
     }
     $after = $after_el['object'];
     $parent = $after;
     $sortorder = $after->get_sortorder();
     foreach ($eids as $eid) {
         if (!($element = $this->gtree->locate_element($eid))) {
             print_error('invalidelementid', '', $returnurl);
         }
         $object = $element['object'];
         $object->set_parent($parent->id);
         $object->move_after_sortorder($sortorder);
         $sortorder++;
     }
     redirect($returnurl, '', 0);
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:31,代码来源:lib.php

示例2:

//first make sure we have proper final grades - we need it for locking changes
$normalisationmessage = null;
$originalweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
grade_regrade_final_grades($courseid);
$alteredweights = grade_helper::fetch_all_natural_weights_for_course($courseid);
if (array_diff($originalweights, $alteredweights)) {
    $normalisationmessage = get_string('weightsadjusted', 'grades');
}
// get the grading tree object
// note: total must be first for moving to work correctly, if you want it last moving code must be rewritten!
$gtree = new grade_tree($courseid, false, false);
if (empty($eid)) {
    $element = null;
    $object = null;
} else {
    if (!($element = $gtree->locate_element($eid))) {
        print_error('invalidelementid', '', $returnurl);
    }
    $object = $element['object'];
}
$switch = grade_get_setting($course->id, 'aggregationposition', $CFG->grade_aggregationposition);
$strgrades = get_string('grades');
$strgraderreport = get_string('graderreport', 'grades');
$moving = false;
$movingeid = false;
if ($action == 'moveselect') {
    if ($eid and confirm_sesskey()) {
        $movingeid = $eid;
        $moving = true;
    }
}
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:31,代码来源:index.php

示例3: array

$action = required_param('action', PARAM_ALPHA);
$eid = required_param('eid', PARAM_ALPHANUM);
$PAGE->set_url('/grade/edit/tree/action.php', array('id' => $courseid, 'action' => $action, 'eid' => $eid));
/// Make sure they can even access this course
if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
    print_error('nocourseid');
}
require_login($course);
$context = context_course::instance($course->id);
// default return url
$gpr = new grade_plugin_return();
$returnurl = $gpr->get_return_url($CFG->wwwroot . '/grade/edit/tree/index.php?id=' . $course->id);
// get the grading tree object
$gtree = new grade_tree($courseid, false, false);
// what are we working with?
if (!($element = $gtree->locate_element($eid))) {
    print_error('invalidelementid', '', $returnurl);
}
$object = $element['object'];
$type = $element['type'];
switch ($action) {
    case 'hide':
        if ($eid and confirm_sesskey()) {
            if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) {
                print_error('nopermissiontohide', '', $returnurl);
            }
            if ($type == 'grade' and empty($object->id)) {
                $object->insert();
            }
            if (!$object->can_control_visibility()) {
                print_error('componentcontrolsvisibility', 'grades', $returnurl);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:action.php

示例4: sort_gradebook

/**
 * Re-sorts the gradebook to put all MTG grade items first.
 *
 * Gets all of the grade items for the specifed course. Iterates over the array
 * of items and moves the MTG items to the front of the array. Then does a
 * second pass to renumber all the sortorders to make the items sequential from
 * 2 upwards (1 will be the course item).
 *
 * @param object $course Database record for course, containing the id.
 */
function sort_gradebook($course)
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/grade/lib.php';
    require_once $CFG->dirroot . '/grade/edit/tree/lib.php';
    $gtree = new \grade_tree($course->id, false, false);
    $fields = array('alis_avgcse', 'alis_alisnum', 'alis_alis', 'alis_mtg', 'alis_cpg');
    $params = array($course->id);
    list($in_sql, $in_params) = $DB->get_in_or_equal($params);
    $params = \array_merge($params, $in_params);
    $where = 'courseid = ? AND idnumber ' . $in_sql;
    $gradeitems = $DB->get_records_select('grade_items', $where, $params, 'itemnumber DESC');
    $courseitem = $DB->get_record('grade_items', array('courseid' => $course->id, 'itemtype' => 'course'));
    //$mtgitems = count_records_select('grade_items', $where);
    // First, move the MTG grade items to the front
    $offset = 0;
    foreach ($gradeitems as $item) {
        if (!($element = $gtree->locate_element('i' . $item->id))) {
            \print_error('invalidelementid');
        }
        $object = $element['object'];
        $moveafter = 'c' . $courseitem->iteminstance;
        $first = 1;
        // If First is set to 1, it means the target is the first child of the category $moveafter
        if (!($after_el = $gtree->locate_element($moveafter))) {
            \print_error('invalidelementid');
        }
        $after = $after_el['object'];
        $sortorder = $after->get_sortorder();
        if (!$first) {
            $parent = $after->get_parent_category();
            $object->set_parent($parent->id);
        } else {
            $object->set_parent($after->id);
        }
        $object->move_after_sortorder($sortorder);
    }
}
开发者ID:rtsfc,项目名称:moodle-report_targetgrades,代码行数:48,代码来源:lib.php


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