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


PHP grade_category::fetch_course_category方法代码示例

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


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

示例1: test_event

 /**
  * Test the event.
  */
 public function test_event()
 {
     global $CFG;
     require_once "{$CFG->libdir}/gradelib.php";
     $this->resetAfterTest();
     $course = $this->getDataGenerator()->create_course();
     $user = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user->id, $course->id);
     $grade_category = grade_category::fetch_course_category($course->id);
     $grade_category->load_grade_item();
     $grade_item = $grade_category->grade_item;
     $grade_item->update_final_grade($user->id, 10, 'gradebook');
     $grade_grade = new grade_grade(array('userid' => $user->id, 'itemid' => $grade_item->id), true);
     $grade_grade->grade_item = $grade_item;
     $event = \core\event\user_graded::create_from_grade($grade_grade);
     $this->assertEventLegacyLogData(array($course->id, 'grade', 'update', '/report/grader/index.php?id=' . $course->id, $grade_item->itemname . ': ' . fullname($user)), $event);
     $this->assertEquals(context_course::instance($course->id), $event->get_context());
     $this->assertSame($event->objecttable, 'grade_grades');
     $this->assertEquals($event->objectid, $grade_grade->id);
     $this->assertEquals($event->other['itemid'], $grade_item->id);
     $this->assertTrue($event->other['overridden']);
     $this->assertEquals(10, $event->other['finalgrade']);
     // Trigger the events.
     $sink = $this->redirectEvents();
     $event->trigger();
     $result = $sink->get_events();
     $sink->close();
     $this->assertCount(1, $result);
     $event = reset($result);
     $this->assertEventContextNotUsed($event);
     $grade = $event->get_grade();
     $this->assertInstanceOf('grade_grade', $grade);
     $this->assertEquals($grade_grade->id, $grade->id);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:37,代码来源:event_user_graded_test.php

示例2: sub_test_grade_category_fetch_course_category

 protected function sub_test_grade_category_fetch_course_category()
 {
     $category = new grade_category();
     $this->assertTrue(method_exists($category, 'fetch_course_category'));
     $category = grade_category::fetch_course_category($this->courseid);
     $this->assertTrue(empty($category->parent));
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:7,代码来源:grade_category_test.php

示例3: redirect

        $url = $CFG->wwwroot . '/grade/edit/tree/outcomeitem.php?id=' . $id . '&courseid=' . $courseid;
        redirect($gpr->add_url_params($url));
    }
    if ($grade_item->is_course_item() or $grade_item->is_category_item()) {
        $grade_category = $grade_item->get_item_category();
        $url = $CFG->wwwroot . '/grade/edit/tree/category.php?id=' . $grade_category->id . '&courseid=' . $courseid;
        redirect($gpr->add_url_params($url));
    }
    $item = $grade_item->get_record_data();
    $parent_category = $grade_item->get_parent_category();
    $item->parentcategory = $parent_category->id;
} else {
    $heading = get_string('newitem', 'grades');
    $grade_item = new grade_item(array('courseid' => $courseid, 'itemtype' => 'manual'), false);
    $item = $grade_item->get_record_data();
    $parent_category = grade_category::fetch_course_category($courseid);
    $item->parentcategory = $parent_category->id;
}
$decimalpoints = $grade_item->get_decimals();
if ($item->hidden > 1) {
    $item->hiddenuntil = $item->hidden;
    $item->hidden = 0;
} else {
    $item->hiddenuntil = 0;
}
$item->locked = !empty($item->locked);
$item->grademax = format_float($item->grademax, $decimalpoints);
$item->grademin = format_float($item->grademin, $decimalpoints);
$item->gradepass = format_float($item->gradepass, $decimalpoints);
$item->multfactor = format_float($item->multfactor, 4);
$item->plusfactor = format_float($item->plusfactor, 4);
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:item.php

示例4: load_grade_items

 /**
  * Load grade_item data into the database, and adds the corresponding objects to this class' variable.
  */
 function load_grade_items()
 {
     global $DB;
     $course_category = grade_category::fetch_course_category($this->courseid);
     // id = 0
     $grade_item = new stdClass();
     $grade_item->courseid = $this->courseid;
     $grade_item->categoryid = $this->grade_categories[1]->id;
     $grade_item->itemname = 'unittestgradeitem1';
     $grade_item->itemtype = 'mod';
     $grade_item->itemmodule = 'quiz';
     $grade_item->iteminstance = 1;
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->grademin = 30;
     $grade_item->grademax = 110;
     $grade_item->itemnumber = 1;
     $grade_item->idnumber = 'item id 0';
     $grade_item->iteminfo = 'Grade item 0 used for unit testing';
     $grade_item->timecreated = mktime();
     $grade_item->timemodified = mktime();
     $grade_item->sortorder = 3;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[0] = $grade_item;
     // id = 1
     $grade_item = new stdClass();
     $grade_item->courseid = $this->courseid;
     $grade_item->categoryid = $this->grade_categories[1]->id;
     $grade_item->itemname = 'unittestgradeitem2';
     $grade_item->itemtype = 'import';
     $grade_item->itemmodule = 'assignment';
     $grade_item->calculation = '= ##gi' . $this->grade_items[0]->id . '## + 30 + [[item id 0]] - [[item id 0]]';
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->iteminstance = 2;
     $grade_item->itemnumber = null;
     $grade_item->grademin = 0;
     $grade_item->grademax = 100;
     $grade_item->iteminfo = 'Grade item 1 used for unit testing';
     $grade_item->timecreated = mktime();
     $grade_item->timemodified = mktime();
     $grade_item->sortorder = 4;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[1] = $grade_item;
     // id = 2
     $grade_item = new stdClass();
     $grade_item->courseid = $this->courseid;
     $grade_item->categoryid = $this->grade_categories[2]->id;
     $grade_item->itemname = 'unittestgradeitem3';
     $grade_item->itemtype = 'mod';
     $grade_item->itemmodule = 'forum';
     $grade_item->iteminstance = 3;
     $grade_item->gradetype = GRADE_TYPE_SCALE;
     $grade_item->scaleid = $this->scale[0]->id;
     $grade_item->grademin = 0;
     $grade_item->grademax = $this->scalemax[0];
     $grade_item->iteminfo = 'Grade item 2 used for unit testing';
     $grade_item->timecreated = mktime();
     $grade_item->timemodified = mktime();
     $grade_item->sortorder = 6;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[2] = $grade_item;
     // Load grade_items associated with the 3 categories
     // id = 3
     $grade_item = new stdClass();
     $grade_item->courseid = $this->courseid;
     $grade_item->iteminstance = $this->grade_categories[0]->id;
     $grade_item->itemname = 'unittestgradeitemcategory1';
     $grade_item->needsupdate = 0;
     $grade_item->itemtype = 'category';
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->grademin = 0;
     $grade_item->grademax = 100;
     $grade_item->iteminfo = 'Grade item 3 used for unit testing';
     $grade_item->timecreated = mktime();
     $grade_item->timemodified = mktime();
     $grade_item->sortorder = 1;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[3] = $grade_item;
     // id = 4
     $grade_item = new stdClass();
     $grade_item->courseid = $this->courseid;
     $grade_item->iteminstance = $this->grade_categories[1]->id;
     $grade_item->itemname = 'unittestgradeitemcategory2';
     $grade_item->itemtype = 'category';
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->needsupdate = 0;
     $grade_item->grademin = 0;
     $grade_item->grademax = 100;
     $grade_item->iteminfo = 'Grade item 4 used for unit testing';
     $grade_item->timecreated = mktime();
     $grade_item->timemodified = mktime();
     $grade_item->sortorder = 2;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[4] = $grade_item;
     // id = 5
     $grade_item = new stdClass();
     $grade_item->courseid = $this->courseid;
     $grade_item->iteminstance = $this->grade_categories[2]->id;
//.........这里部分代码省略.........
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:101,代码来源:gradetest.php

示例5: test_upgrade_extra_credit_weightoverride

 public function test_upgrade_extra_credit_weightoverride()
 {
     global $DB, $CFG;
     $this->resetAfterTest(true);
     $c = array();
     $a = array();
     $gi = array();
     for ($i = 0; $i < 5; $i++) {
         $c[$i] = $this->getDataGenerator()->create_course();
         $a[$i] = array();
         $gi[$i] = array();
         for ($j = 0; $j < 3; $j++) {
             $a[$i][$j] = $this->getDataGenerator()->create_module('assign', array('course' => $c[$i], 'grade' => 100));
             $giparams = array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $a[$i][$j]->id, 'courseid' => $c[$i]->id, 'itemnumber' => 0);
             $gi[$i][$j] = grade_item::fetch($giparams);
         }
     }
     // Case 1: Course $c[0] has aggregation method different from natural.
     $coursecategory = grade_category::fetch_course_category($c[0]->id);
     $coursecategory->aggregation = GRADE_AGGREGATE_WEIGHTED_MEAN;
     $coursecategory->update();
     $gi[0][1]->aggregationcoef = 1;
     $gi[0][1]->update();
     $gi[0][2]->weightoverride = 1;
     $gi[0][2]->update();
     // Case 2: Course $c[1] has neither extra credits nor overrides
     // Case 3: Course $c[2] has extra credits but no overrides
     $gi[2][1]->aggregationcoef = 1;
     $gi[2][1]->update();
     // Case 4: Course $c[3] has no extra credits and has overrides
     $gi[3][2]->weightoverride = 1;
     $gi[3][2]->update();
     // Case 5: Course $c[4] has both extra credits and overrides
     $gi[4][1]->aggregationcoef = 1;
     $gi[4][1]->update();
     $gi[4][2]->weightoverride = 1;
     $gi[4][2]->update();
     // Run the upgrade script and make sure only course $c[4] was marked as needed to be fixed.
     upgrade_extra_credit_weightoverride();
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $c[0]->id}));
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $c[1]->id}));
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $c[2]->id}));
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $c[3]->id}));
     $this->assertEquals(20150619, $CFG->{'gradebook_calculations_freeze_' . $c[4]->id});
     set_config('gradebook_calculations_freeze_' . $c[4]->id, null);
     // Run the upgrade script for a single course only.
     upgrade_extra_credit_weightoverride($c[0]->id);
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $c[0]->id}));
     upgrade_extra_credit_weightoverride($c[4]->id);
     $this->assertEquals(20150619, $CFG->{'gradebook_calculations_freeze_' . $c[4]->id});
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:51,代码来源:upgradelib_test.php

示例6: definition_after_data

 function definition_after_data()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     if ($id = $mform->getElementValue('id')) {
         $grade_item = grade_item::fetch(array('id' => $id));
         //remove the aggregation coef element if not needed
         if ($grade_item->is_course_item()) {
             $mform->removeElement('aggregationcoef');
         } else {
             if ($grade_item->is_category_item()) {
                 $category = $grade_item->get_item_category();
                 $parent_category = $category->get_parent_category();
                 if (!$parent_category->is_aggregationcoef_used()) {
                     $mform->removeElement('aggregationcoef');
                 }
             } else {
                 $parent_category = $grade_item->get_parent_category();
                 if (!$parent_category->is_aggregationcoef_used()) {
                     $mform->removeElement('aggregationcoef');
                 }
             }
         }
     } else {
         $course_category = grade_category::fetch_course_category($COURSE->id);
         if (!$course_category->is_aggregationcoef_used()) {
             $mform->removeElement('aggregationcoef');
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:30,代码来源:outcomeitem_form.php

示例7: fetch_course_tree

 /**
  * Returns tree with all grade_items and categories as elements
  *
  * @param int $courseid The course ID
  * @param bool $include_category_items as category children
  * @return array
  */
 public static function fetch_course_tree($courseid, $include_category_items = false)
 {
     $course_category = grade_category::fetch_course_category($courseid);
     $category_array = array('object' => $course_category, 'type' => 'category', 'depth' => 1, 'children' => $course_category->get_children($include_category_items));
     $course_category->sortorder = $course_category->get_sortorder();
     $sortorder = $course_category->get_sortorder();
     return grade_category::_fetch_course_tree_recursion($category_array, $sortorder);
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:15,代码来源:grade_category.php

示例8: remove_course_grades

/**
 * Remove all grade related course data
 * Grade history is kept
 *
 * @param int $courseid The course ID
 * @param bool $showfeedback If true success notifications will be displayed
 */
function remove_course_grades($courseid, $showfeedback)
{
    global $DB, $OUTPUT;
    $fs = get_file_storage();
    $strdeleted = get_string('deleted');
    $course_category = grade_category::fetch_course_category($courseid);
    $course_category->delete('coursedelete');
    $fs->delete_area_files(get_context_instance(CONTEXT_COURSE, $courseid)->id, 'grade', 'feedback');
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('grades', 'grades') . ', ' . get_string('items', 'grades') . ', ' . get_string('categories', 'grades'), 'notifysuccess');
    }
    if ($outcomes = grade_outcome::fetch_all(array('courseid' => $courseid))) {
        foreach ($outcomes as $outcome) {
            $outcome->delete('coursedelete');
        }
    }
    $DB->delete_records('grade_outcomes_courses', array('courseid' => $courseid));
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('outcomes', 'grades'), 'notifysuccess');
    }
    if ($scales = grade_scale::fetch_all(array('courseid' => $courseid))) {
        foreach ($scales as $scale) {
            $scale->delete('coursedelete');
        }
    }
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('scales'), 'notifysuccess');
    }
    $DB->delete_records('grade_settings', array('courseid' => $courseid));
    if ($showfeedback) {
        echo $OUTPUT->notification($strdeleted . ' - ' . get_string('settings', 'grades'), 'notifysuccess');
    }
}
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:40,代码来源:gradelib.php

示例9: load_grade_items

 /**
  * Load grade_item data into the database, and adds the corresponding objects to this class' variable.
  */
 protected function load_grade_items()
 {
     global $DB;
     // Purge all items created by module generators.
     $DB->delete_records('grade_items', array('itemtype' => 'mod'));
     $course_category = grade_category::fetch_course_category($this->course->id);
     // id = 0
     $grade_item = new stdClass();
     $grade_item->courseid = $this->course->id;
     $grade_item->categoryid = $this->grade_categories[1]->id;
     $grade_item->itemname = 'unittestgradeitem1';
     $grade_item->itemtype = 'mod';
     $grade_item->itemmodule = $this->course_module[0]->modname;
     $grade_item->iteminstance = $this->course_module[0]->instance;
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->grademin = 30;
     $grade_item->grademax = 110;
     $grade_item->itemnumber = 1;
     $grade_item->idnumber = 'item id 0';
     $grade_item->iteminfo = 'Grade item 0 used for unit testing';
     $grade_item->timecreated = time();
     $grade_item->timemodified = time();
     $grade_item->sortorder = 3;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[0] = $grade_item;
     // id = 1
     $grade_item = new stdClass();
     $grade_item->courseid = $this->course->id;
     $grade_item->categoryid = $this->grade_categories[1]->id;
     $grade_item->itemname = 'unittestgradeitem2';
     $grade_item->itemtype = 'import';
     $grade_item->itemmodule = $this->course_module[1]->modname;
     $grade_item->iteminstance = $this->course_module[1]->instance;
     $grade_item->calculation = '= ##gi' . $this->grade_items[0]->id . '## + 30 + [[item id 0]] - [[item id 0]]';
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->itemnumber = null;
     $grade_item->grademin = 0;
     $grade_item->grademax = 100;
     $grade_item->iteminfo = 'Grade item 1 used for unit testing';
     $grade_item->timecreated = time();
     $grade_item->timemodified = time();
     $grade_item->sortorder = 4;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[1] = $grade_item;
     // id = 2
     $grade_item = new stdClass();
     $grade_item->courseid = $this->course->id;
     $grade_item->categoryid = $this->grade_categories[2]->id;
     $grade_item->itemname = 'unittestgradeitem3';
     $grade_item->itemtype = 'mod';
     $grade_item->itemmodule = $this->course_module[2]->modname;
     $grade_item->iteminstance = $this->course_module[2]->instance;
     $grade_item->gradetype = GRADE_TYPE_SCALE;
     $grade_item->scaleid = $this->scale[0]->id;
     $grade_item->grademin = 0;
     $grade_item->grademax = $this->scalemax[0];
     $grade_item->iteminfo = 'Grade item 2 used for unit testing';
     $grade_item->timecreated = time();
     $grade_item->timemodified = time();
     $grade_item->sortorder = 6;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[2] = $grade_item;
     // Load grade_items associated with the 3 categories.
     // id = 3
     $grade_item = new stdClass();
     $grade_item->courseid = $this->course->id;
     $grade_item->iteminstance = $this->grade_categories[0]->id;
     $grade_item->itemname = 'unittestgradeitemcategory1';
     $grade_item->needsupdate = 0;
     $grade_item->itemtype = 'category';
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->grademin = 0;
     $grade_item->grademax = 100;
     $grade_item->iteminfo = 'Grade item 3 used for unit testing';
     $grade_item->timecreated = time();
     $grade_item->timemodified = time();
     $grade_item->sortorder = 1;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[3] = $grade_item;
     // id = 4
     $grade_item = new stdClass();
     $grade_item->courseid = $this->course->id;
     $grade_item->iteminstance = $this->grade_categories[1]->id;
     $grade_item->itemname = 'unittestgradeitemcategory2';
     $grade_item->itemtype = 'category';
     $grade_item->gradetype = GRADE_TYPE_VALUE;
     $grade_item->needsupdate = 0;
     $grade_item->grademin = 0;
     $grade_item->grademax = 100;
     $grade_item->iteminfo = 'Grade item 4 used for unit testing';
     $grade_item->timecreated = time();
     $grade_item->timemodified = time();
     $grade_item->sortorder = 2;
     $grade_item->id = $DB->insert_record('grade_items', $grade_item);
     $this->grade_items[4] = $grade_item;
     // id = 5
     $grade_item = new stdClass();
//.........这里部分代码省略.........
开发者ID:Jinelle,项目名称:moodle,代码行数:101,代码来源:lib.php

示例10: restore_create_gradebook

function restore_create_gradebook($restore, $xml_file)
{
    global $CFG, $db, $SESSION;
    $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 ($info <= 0) {
        return $status;
    }
    // Count how many we have
    $categoriescount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_categories');
    $itemscount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_items');
    $outcomecount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_outcomes');
    $outcomescoursescount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_outcomes_courses');
    $gchcount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_categories_history');
    $gghcount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_grades_history');
    $gihcount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_items_history');
    $gohcount = count_records('backup_ids', 'backup_code', $restore->backup_unique_code, 'table_name', 'grade_outcomes_history');
    // 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
    if ($recs = get_records_select("backup_ids", "table_name = 'grade_items' AND backup_code = '{$restore->backup_unique_code}'", "old_id", "old_id")) {
        foreach ($recs as $rec) {
            if ($data = backup_getid($restore->backup_unique_code, 'grade_items', $rec->old_id)) {
                $info = $data->info;
                // do not restore if this grade_item is a mod, and
                $itemtype = backup_todb($info['GRADE_ITEM']['#']['ITEMTYPE']['0']['#']);
                if ($itemtype == 'mod') {
                    $iteminstance = backup_todb($info['GRADE_ITEM']['#']['ITEMINSTANCE']['0']['#']);
                    $itemmodule = backup_todb($info['GRADE_ITEM']['#']['ITEMMODULE']['0']['#']);
                    if (!restore_userdata_selected($restore, $itemmodule, $iteminstance)) {
                        // module instance not selected when restored using granular
                        // we are not restoring all grade items, set flag to false
                        // so that we do not process grade categories and related grade items/grades
                        $restoreall = false;
                        break;
                    }
                }
            }
        }
    }
    // return if nothing to restore
    if (!$itemscount && !$categoriescount && !$outcomecount) {
        return $status;
    }
    // Start ul
    if (!defined('RESTORE_SILENTLY')) {
        echo '<ul>';
    }
    // fetch the course grade item
    require_once $CFG->libdir . '/grade/grade_item.php';
    require_once $CFG->libdir . '/grade/grade_category.php';
    require_once $CFG->libdir . '/gradelib.php';
    $courseitem = grade_item::fetch_course_item($restore->course_id);
    $coursecategory = grade_category::fetch_course_category($restore->course_id);
    // Number of records to get in every chunk
    $recordset_size = 2;
    // Flag to mark if we must continue
    $continue = true;
    // Process categories
    if ($categoriescount && $continue && $restoreall) {
        if (!defined('RESTORE_SILENTLY')) {
            echo '<li>' . get_string('gradecategories', 'grades') . '</li>';
        }
        $counter = 0;
        while ($counter < $categoriescount) {
            // Fetch recordset_size records in each iteration
            $recs = get_records_select("backup_ids", "table_name = 'grade_categories' AND backup_code = '{$restore->backup_unique_code}'", "old_id", "old_id", $counter, $recordset_size);
            if ($recs) {
                foreach ($recs as $rec) {
                    // Get the full record from backup_ids
                    $data = backup_getid($restore->backup_unique_code, 'grade_categories', $rec->old_id);
                    if ($data) {
                        // Now get completed xmlized object
                        $info = $data->info;
                        //traverse_xmlize($info);                            //Debug
                        //print_object ($GLOBALS['traverse_array']);         //Debug
                        //$GLOBALS['traverse_array']="";                     //Debug
                        //Now build the GRADE_PREFERENCES record structure
                        $dbrec->courseid = $restore->course_id;
                        // categories are not backed up during import.
                        // however, depth 1 categories needs to be skipped during restore into exisiting course
                        // get the new grade category parent
                        //if (!empty($info['GRADE_CATEGORY']['#']['PARENT']['0']['#']) && $info['GRADE_CATEGORY']['#']['PARENT']['0']['#'] != '$@NULL@$') {
                        $parent = backup_getid($restore->backup_unique_code, 'grade_categories', backup_todb($info['GRADE_CATEGORY']['#']['PARENT']['0']['#']));
                        if (isset($parent->new_id)) {
                            $dbrec->parent = $parent->new_id;
                        } else {
                            // orphans should get adopted by course category
                            $dbrec->parent = $coursecategory->id;
                        }
                        //}
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:restorelib.php

示例11: current

        $courses = current($distributed_selector->find_users());
    }
}
if (!empty($courses)) {
    set_time_limit(0);
    // This could take a while, so disable max execution time
    $output = '';
    $itemnames = array('target' => get_string('item_mtg', 'report_targetgrades'), 'min' => get_string('item_alis', 'report_targetgrades'), 'alisnum' => get_string('item_alisnum', 'report_targetgrades'), 'avgcse' => get_string('item_avgcse', 'report_targetgrades'), 'cpg' => get_string('item_cpg', 'report_targetgrades'));
    $empty_courses = array();
    $unconfigured_courses = array();
    $empty_students = array();
    $failed_grade_calcs = array();
    $errors = '';
    $infofield = $DB->get_record('user_info_field', array('id' => $config->gcse_field));
    foreach ($courses as $course) {
        $category = grade_category::fetch_course_category($course->id);
        $records = null;
        $regrade = false;
        foreach ($itemnames as $item => $itemname) {
            try {
                if ($grade_item = grade_item::fetch(array('idnumber' => 'targetgrades_' . $item, 'courseid' => $course->id))) {
                    $itemdata = new stdClass();
                    if (empty($grade_item->timecreated)) {
                        $itemdata->timecreated = time();
                    }
                    if (empty($grade_item->itemnumber)) {
                        $itemdata->itemnumber = 0;
                    }
                    grade_item::set_properties($grade_item, $itemdata);
                    $grade_item->update();
                    unset($itemdata);
开发者ID:rtsfc,项目名称:moodle-report_targetgrades,代码行数:31,代码来源:distribute.php

示例12: completion_aggregation

        $aggregation = new completion_aggregation();
        $aggregation->course = $data->id;
        $aggregation->criteriatype = COMPLETION_CRITERIA_TYPE_COURSE;
        $aggregation->setMethod($data->course_aggregation);
        $aggregation->insert();
        // Role aggregation
        if (empty($data->role_aggregation)) {
            $data->role_aggregation = 0;
        }
        $aggregation = new completion_aggregation();
        $aggregation->course = $data->id;
        $aggregation->criteriatype = COMPLETION_CRITERIA_TYPE_ROLE;
        $aggregation->setMethod($data->role_aggregation);
        $aggregation->insert();
        // Update course total passing grade
        if (!empty($data->criteria_grade)) {
            if ($grade_item = grade_category::fetch_course_category($course->id)->grade_item) {
                $grade_item->gradepass = $data->criteria_grade_value;
                if (method_exists($grade_item, 'update')) {
                    $grade_item->update('course/completion.php');
                }
            }
        }
        redirect($CFG->wwwroot . "/course/view.php?id={$course->id}", get_string('changessaved'));
    }
}
/// Print the form
echo $OUTPUT->header();
echo $OUTPUT->heading($streditcompletionsettings);
$form->display();
echo $OUTPUT->footer();
开发者ID:nmicha,项目名称:moodle,代码行数:31,代码来源:completion.php

示例13: definition_after_data

 function definition_after_data()
 {
     global $CFG, $COURSE;
     $mform =& $this->_form;
     if ($id = $mform->getElementValue('id')) {
         $grade_item = grade_item::fetch(array('id' => $id));
         if (!$grade_item->is_raw_used()) {
             $mform->removeElement('plusfactor');
             $mform->removeElement('multfactor');
         }
         if ($grade_item->is_outcome_item()) {
             // we have to prevent incompatible modifications of outcomes if outcomes disabled
             $mform->removeElement('grademax');
             $mform->removeElement('grademin');
             $mform->removeElement('gradetype');
             $mform->removeElement('display');
             $mform->removeElement('decimals');
             $mform->hardFreeze('scaleid');
         } else {
             if ($grade_item->is_normal_item()) {
                 // following items are set up from modules and should not be overrided by user
                 $mform->hardFreeze('itemname,idnumber,gradetype,grademax,grademin,scaleid');
                 //$mform->removeElement('calculation');
             }
         }
         //remove the aggregation coef element if not needed
         if ($grade_item->is_course_item()) {
             $mform->removeElement('aggregationcoef');
         } else {
             if ($grade_item->is_category_item()) {
                 $category = $grade_item->get_item_category();
                 $parent_category = $category->get_parent_category();
                 if (!$parent_category->is_aggregationcoef_used()) {
                     $mform->removeElement('aggregationcoef');
                 }
             } else {
                 $parent_category = $grade_item->get_parent_category();
                 if (!$parent_category->is_aggregationcoef_used()) {
                     $mform->removeElement('aggregationcoef');
                 }
             }
         }
     } else {
         // all new items are manual, children of course category
         $mform->removeElement('plusfactor');
         $mform->removeElement('multfactor');
         $course_category = grade_category::fetch_course_category($COURSE->id);
         if (!$course_category->is_aggregationcoef_used()) {
             $mform->removeElement('aggregationcoef');
         }
     }
     // setup defaults and extra locking based on it
     $course_item = grade_item::fetch_course_item($COURSE->id);
     $default_gradedisplaytype = $course_item->get_displaytype();
     $default_gradedecimals = $course_item->get_decimals();
     $option_value = 'error';
     foreach ($this->displayoptions as $key => $option) {
         if ($key == $default_gradedisplaytype) {
             $option_value = $option;
             break;
         }
     }
     $displaytypeEl =& $mform->getElement('display');
     $displaytypeEl->setLabel(get_string('gradedisplaytype', 'grades') . ' (' . get_string('default', 'grades') . ': ' . $option_value . ')');
     $decimalsEl =& $mform->getElement('decimals');
     $decimalsEl->setLabel(get_string('decimalpoints', 'grades') . ' (' . get_string('default', 'grades') . ': ' . $default_gradedecimals . ')');
     // Disable decimals if displaytype is DEFAULT and course or site displaytype is LETTER
     if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
         $mform->disabledIf('decimals', 'display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:71,代码来源:item_form.php

示例14: fetch_course_items

 /**
  * Returns the grade items associated with the courses.
  *
  * @param array $courseids Array of course ids.
  * @return array Array of grade_items for each course level grade item.
  */
 public static function fetch_course_items(array $courseids)
 {
     global $DB;
     $courseitems = array();
     if (!empty($courseids)) {
         list($courseidssql, $courseidsparams) = $DB->get_in_or_equal($courseids);
         $select = 'courseid ' . $courseidssql . ' AND itemtype = ?';
         $params = array_merge($courseidsparams, array('course'));
         $rs = $DB->get_recordset_select('grade_items', $select, $params);
         $courseitems = array();
         foreach ($rs as $data) {
             $instance = new \grade_item();
             \grade_object::set_properties($instance, $data);
             $courseitems[$instance->id] = $instance;
         }
         $rs->close();
     }
     // Determine if any courses were missing.
     $receivedids = array();
     foreach ($courseitems as $item) {
         $receivedids[] = $item->courseid;
     }
     $missingids = array_diff($courseids, $receivedids);
     // Create grade items for any courses that didn't have one.
     if (!empty($missingids)) {
         foreach ($missingids as $courseid) {
             // First get category - it creates the associated grade item.
             $coursecategory = \grade_category::fetch_course_category($courseid);
             $gradeitem = $coursecategory->get_grade_item();
             $courseitems[$gradeitem->id] = $gradeitem;
         }
     }
     return $courseitems;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:40,代码来源:synchronize.php

示例15: fetch_course_item

 /**
  * Returns grade item associated with the course
  * @param int $courseid
  * @return course item object
  */
 function fetch_course_item($courseid)
 {
     if ($course_item = grade_item::fetch(array('courseid' => $courseid, 'itemtype' => 'course'))) {
         return $course_item;
     }
     // first get category - it creates the associated grade item
     $course_category = grade_category::fetch_course_category($courseid);
     return $course_category->get_grade_item();
 }
开发者ID:r007,项目名称:PMoodle,代码行数:14,代码来源:grade_item.php


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