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


PHP backup_nested_element::get_attribute方法代码示例

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


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

示例1: define_structure

 protected function define_structure()
 {
     global $CFG, $DB;
     // are we including user info?
     $userinfo = $this->get_setting_value('users');
     $gradebook = new backup_nested_element('gradebook');
     //grade_letters are done in backup_activity_grades_structure_step()
     //calculated grade items
     $grade_items = new backup_nested_element('grade_items');
     $grade_item = new backup_nested_element('grade_item', array('id'), array('categoryid', 'itemname', 'itemtype', 'itemmodule', 'iteminstance', 'itemnumber', 'iteminfo', 'idnumber', 'calculation', 'gradetype', 'grademax', 'grademin', 'scaleid', 'outcomeid', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'aggregationcoef2', 'weightoverride', 'sortorder', 'display', 'decimals', 'hidden', 'locked', 'locktime', 'needsupdate', 'timecreated', 'timemodified'));
     $grade_grades = new backup_nested_element('grade_grades');
     $grade_grade = new backup_nested_element('grade_grade', array('id'), array('userid', 'rawgrade', 'rawgrademax', 'rawgrademin', 'rawscaleid', 'usermodified', 'finalgrade', 'hidden', 'locked', 'locktime', 'exported', 'overridden', 'excluded', 'feedback', 'feedbackformat', 'information', 'informationformat', 'timecreated', 'timemodified', 'aggregationstatus', 'aggregationweight'));
     //grade_categories
     $grade_categories = new backup_nested_element('grade_categories');
     $grade_category = new backup_nested_element('grade_category', array('id'), array('parent', 'depth', 'path', 'fullname', 'aggregation', 'keephigh', 'droplow', 'aggregateonlygraded', 'aggregateoutcomes', 'timecreated', 'timemodified', 'hidden'));
     $letters = new backup_nested_element('grade_letters');
     $letter = new backup_nested_element('grade_letter', 'id', array('lowerboundary', 'letter'));
     $grade_settings = new backup_nested_element('grade_settings');
     $grade_setting = new backup_nested_element('grade_setting', 'id', array('name', 'value'));
     // Build the tree
     $gradebook->add_child($grade_categories);
     $grade_categories->add_child($grade_category);
     $gradebook->add_child($grade_items);
     $grade_items->add_child($grade_item);
     $grade_item->add_child($grade_grades);
     $grade_grades->add_child($grade_grade);
     $gradebook->add_child($letters);
     $letters->add_child($letter);
     $gradebook->add_child($grade_settings);
     $grade_settings->add_child($grade_setting);
     // Add attribute with gradebook calculation freeze date if needed.
     $gradebookcalculationfreeze = get_config('core', 'gradebook_calculations_freeze_' . $this->get_courseid());
     if ($gradebookcalculationfreeze) {
         $gradebook->add_attributes(array('calculations_freeze'));
         $gradebook->get_attribute('calculations_freeze')->set_value($gradebookcalculationfreeze);
     }
     // Define sources
     //Include manual, category and the course grade item
     $grade_items_sql = "SELECT * FROM {grade_items}\n                           WHERE courseid = :courseid\n                           AND (itemtype='manual' OR itemtype='course' OR itemtype='category')";
     $grade_items_params = array('courseid' => backup::VAR_COURSEID);
     $grade_item->set_source_sql($grade_items_sql, $grade_items_params);
     if ($userinfo) {
         $grade_grade->set_source_table('grade_grades', array('itemid' => backup::VAR_PARENTID));
     }
     $grade_category_sql = "SELECT gc.*, gi.sortorder\n                               FROM {grade_categories} gc\n                               JOIN {grade_items} gi ON (gi.iteminstance = gc.id)\n                               WHERE gc.courseid = :courseid\n                               AND (gi.itemtype='course' OR gi.itemtype='category')\n                               ORDER BY gc.parent ASC";
     //need parent categories before their children
     $grade_category_params = array('courseid' => backup::VAR_COURSEID);
     $grade_category->set_source_sql($grade_category_sql, $grade_category_params);
     $letter->set_source_table('grade_letters', array('contextid' => backup::VAR_CONTEXTID));
     // Set the grade settings source, forcing the inclusion of minmaxtouse if not present.
     $settings = array();
     $rs = $DB->get_recordset('grade_settings', array('courseid' => $this->get_courseid()));
     foreach ($rs as $record) {
         $settings[$record->name] = $record;
     }
     $rs->close();
     if (!isset($settings['minmaxtouse'])) {
         $settings['minmaxtouse'] = (object) array('name' => 'minmaxtouse', 'value' => $CFG->grade_minmaxtouse);
     }
     $grade_setting->set_source_array($settings);
     // Annotations (both as final as far as they are going to be exported in next steps)
     $grade_item->annotate_ids('scalefinal', 'scaleid');
     // Straight as scalefinal because it's > 0
     $grade_item->annotate_ids('outcomefinal', 'outcomeid');
     //just in case there are any users not already annotated by the activities
     $grade_grade->annotate_ids('userfinal', 'userid');
     // Return the root element
     return $gradebook;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:69,代码来源:backup_stepslib.php


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