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


PHP grade_category::load_grade_item方法代码示例

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


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

示例1: sub_test_grade_category_generate_grades_aggregationweight

 /**
  * Tests the setting of the grade_grades aggregationweight column.
  * Currently, this is only a regression test for MDL-51715.
  * This must be run before sub_test_grade_category_set_parent(), which alters
  * the fixture.
  */
 protected function sub_test_grade_category_generate_grades_aggregationweight()
 {
     global $DB;
     // Start of regression test for MDL-51715.
     // grade_categories [1] and [2] are child categories of [0]
     // Ensure that grades have been generated with fixture data.
     $childcat1 = new grade_category($this->grade_categories[1]);
     $childcat1itemid = $childcat1->load_grade_item()->id;
     $childcat1->generate_grades();
     $childcat2 = new grade_category($this->grade_categories[2]);
     $childcat2itemid = $childcat2->load_grade_item()->id;
     $childcat2->generate_grades();
     $parentcat = new grade_category($this->grade_categories[0]);
     $parentcat->generate_grades();
     // Drop low and and re-generate to produce 'dropped' aggregation status.
     $parentcat->droplow = 1;
     $parentcat->generate_grades();
     $this->assertTrue($DB->record_exists_select('grade_grades', "aggregationstatus='dropped' and itemid in (?,?)", array($childcat1itemid, $childcat2itemid)));
     $this->assertFalse($DB->record_exists_select('grade_grades', "aggregationstatus='dropped' and aggregationweight > 0.00"), "aggregationweight should be 0.00 if aggregationstatus=='dropped'");
     // Reset grade data to be consistent with fixture data.
     $parentcat->droplow = 0;
     $parentcat->generate_grades();
     // Blank out the final grade for one of the child categories and re-generate
     // to produce 'novalue' aggregationstatus.  Direct DB update is testing shortcut.
     $DB->set_field('grade_grades', 'finalgrade', null, array('itemid' => $childcat1itemid));
     $parentcat->generate_grades();
     $this->assertTrue($DB->record_exists_select('grade_grades', "aggregationstatus='novalue' and itemid = ?", array($childcat1itemid)));
     $this->assertFalse($DB->record_exists_select('grade_grades', "aggregationstatus='novalue' and aggregationweight > 0.00"), "aggregationweight should be 0.00 if aggregationstatus=='novalue'");
     // Re-generate to be consistent with fixture data.
     $childcat1->generate_grades();
     $parentcat->generate_grades();
     // End of regression test for MDL-51715.
 }
开发者ID:rushi963,项目名称:moodle,代码行数:39,代码来源:grade_category_test.php

示例2: restore_migrate_old_gradebook

/**
 * This function migrades all the pre 1.9 gradebook data from xml
 */
function restore_migrate_old_gradebook($restore, $xml_file)
{
    global $CFG;
    $status = true;
    //Check it exists
    if (!file_exists($xml_file)) {
        return false;
    }
    // Get info from xml
    // info will contain the number of record to process
    $info = restore_read_xml_gradebook($restore, $xml_file);
    // If we have info, then process
    if (empty($info)) {
        return $status;
    }
    // make sure top course category exists
    $course_category = grade_category::fetch_course_category($restore->course_id);
    $course_category->load_grade_item();
    // we need to know if all grade items that were backed up are being restored
    // if that is not the case, we do not restore grade categories nor gradeitems of category type or course type
    // i.e. the aggregated grades of that category
    $restoreall = true;
    // set to false if any grade_item is not selected/restored
    $importing = !empty($SESSION->restore->importing);
    // there should not be a way to import old backups, but anyway ;-)
    if ($importing) {
        $restoreall = false;
    } else {
        $prev_grade_items = grade_item::fetch_all(array('courseid' => $restore->course_id));
        $prev_grade_cats = grade_category::fetch_all(array('courseid' => $restore->course_id));
        // if any categories already present, skip restore of categories from backup
        if (count($prev_grade_items) > 1 or count($prev_grade_cats) > 1) {
            $restoreall = false;
        }
        unset($prev_grade_items);
        unset($prev_grade_cats);
    }
    // force creation of all grade_items - the course_modules already exist
    grade_force_full_regrading($restore->course_id);
    grade_grab_course_grades($restore->course_id);
    // Start ul
    if (!defined('RESTORE_SILENTLY')) {
        echo '<ul>';
    }
    /// Process letters
    $context = get_context_instance(CONTEXT_COURSE, $restore->course_id);
    // respect current grade letters if defined
    if ($status and $restoreall and !record_exists('grade_letters', 'contextid', $context->id)) {
        if (!defined('RESTORE_SILENTLY')) {
            echo '<li>' . get_string('gradeletters', 'grades') . '</li>';
        }
        // Fetch recordset_size records in each iteration
        $recs = get_records_select("backup_ids", "table_name = 'grade_letter' AND backup_code = {$restore->backup_unique_code}", "", "old_id");
        if ($recs) {
            foreach ($recs as $rec) {
                // Get the full record from backup_ids
                $data = backup_getid($restore->backup_unique_code, 'grade_letter', $rec->old_id);
                if ($data) {
                    $info = $data->info;
                    $dbrec = new object();
                    $dbrec->contextid = $context->id;
                    $dbrec->lowerboundary = backup_todb($info['GRADE_LETTER']['#']['GRADE_LOW']['0']['#']);
                    $dbrec->letter = backup_todb($info['GRADE_LETTER']['#']['LETTER']['0']['#']);
                    insert_record('grade_letters', $dbrec);
                }
            }
        }
    }
    if (!defined('RESTORE_SILENTLY')) {
        echo '<li>' . get_string('categories', 'grades') . '</li>';
    }
    //Fetch recordset_size records in each iteration
    $recs = get_records_select("backup_ids", "table_name = 'grade_category' AND backup_code = {$restore->backup_unique_code}", "old_id", "old_id");
    $cat_count = count($recs);
    if ($recs) {
        foreach ($recs as $rec) {
            //Get the full record from backup_ids
            $data = backup_getid($restore->backup_unique_code, 'grade_category', $rec->old_id);
            if ($data) {
                //Now get completed xmlized object
                $info = $data->info;
                if ($restoreall) {
                    if ($cat_count == 1) {
                        $course_category->fullname = backup_todb($info['GRADE_CATEGORY']['#']['NAME']['0']['#'], false);
                        $course_category->droplow = backup_todb($info['GRADE_CATEGORY']['#']['DROP_X_LOWEST']['0']['#'], false);
                        $course_category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
                        $course_category->aggregateonlygraded = 0;
                        $course_category->update('restore');
                        $grade_category = $course_category;
                    } else {
                        $grade_category = new grade_category();
                        $grade_category->courseid = $restore->course_id;
                        $grade_category->fullname = backup_todb($info['GRADE_CATEGORY']['#']['NAME']['0']['#'], false);
                        $grade_category->droplow = backup_todb($info['GRADE_CATEGORY']['#']['DROP_X_LOWEST']['0']['#'], false);
                        $grade_category->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN2;
                        $grade_category->aggregateonlygraded = 0;
                        $grade_category->insert('restore');
//.........这里部分代码省略.........
开发者ID:kai707,项目名称:ITSA-backup,代码行数:101,代码来源:restorelib.php

示例3: create_grade_category

 /**
  * Create a grade_category.
  *
  * @param array|stdClass $record
  * @return stdClass the grade category record
  */
 public function create_grade_category($record = null)
 {
     global $CFG;
     $this->gradecategorycounter++;
     $i = $this->gradecategorycounter;
     if (!isset($record['fullname'])) {
         $record['fullname'] = 'Grade category ' . $i;
     }
     // For gradelib classes.
     require_once $CFG->libdir . '/gradelib.php';
     // Create new grading category in this course.
     $gradecategory = new grade_category($record, false);
     $gradecategory->apply_default_settings();
     $gradecategory->apply_forced_settings();
     $gradecategory->insert();
     // This creates a default grade item for the category
     $gradeitem = $gradecategory->load_grade_item();
     if (isset($record->parentcategory)) {
         $gradecategory->set_parent($data->parentcategory);
     }
     $gradecategory->update_from_db();
     return $gradecategory->get_record_data();
 }
开发者ID:abhilash1994,项目名称:moodle,代码行数:29,代码来源:data_generator.php


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