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


PHP info::add_legacy_availability_condition方法代码示例

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


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

示例1: test_add_legacy_availability_condition

 /**
  * Tests the add_legacy_availability_condition function used in restore.
  */
 public function test_add_legacy_availability_condition()
 {
     // Completion condition tests.
     $rec = (object) array('sourcecmid' => 7, 'requiredcompletion' => 1);
     // No previous availability, show = true.
     $this->assertEquals('{"op":"&","showc":[true],"c":[{"type":"completion","cm":7,"e":1}]}', info::add_legacy_availability_condition(null, $rec, true));
     // No previous availability, show = false.
     $this->assertEquals('{"op":"&","showc":[false],"c":[{"type":"completion","cm":7,"e":1}]}', info::add_legacy_availability_condition(null, $rec, false));
     // Existing availability.
     $before = '{"op":"&","showc":[true],"c":[{"type":"date","d":">=","t":70}]}';
     $this->assertEquals('{"op":"&","showc":[true,true],"c":[' . '{"type":"date","d":">=","t":70},' . '{"type":"completion","cm":7,"e":1}' . ']}', info::add_legacy_availability_condition($before, $rec, true));
     // Grade condition tests.
     $rec = (object) array('gradeitemid' => 3, 'grademin' => 7, 'grademax' => null);
     $this->assertEquals('{"op":"&","showc":[true],"c":[{"type":"grade","id":3,"min":7.00000}]}', info::add_legacy_availability_condition(null, $rec, true));
     $rec->grademax = 8;
     $this->assertEquals('{"op":"&","showc":[true],"c":[{"type":"grade","id":3,"min":7.00000,"max":8.00000}]}', info::add_legacy_availability_condition(null, $rec, true));
     unset($rec->grademax);
     unset($rec->grademin);
     $this->assertEquals('{"op":"&","showc":[true],"c":[{"type":"grade","id":3}]}', info::add_legacy_availability_condition(null, $rec, true));
     // Note: There is no need to test the grade condition with show
     // true/false and existing availability, because this uses the same
     // function.
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:26,代码来源:info_test.php

示例2: define_execution

 protected function define_execution()
 {
     global $CFG, $DB;
     // Site hasn't availability enabled
     if (empty($CFG->enableavailability)) {
         return;
     }
     // Do both modules and sections.
     foreach (array('module', 'section') as $table) {
         // Get all the availability objects to process.
         $params = array('backupid' => $this->get_restoreid(), 'itemname' => $table . '_availability');
         $rs = $DB->get_recordset('backup_ids_temp', $params, '', 'itemid, info');
         // Process availabilities, creating them if everything matches ok.
         foreach ($rs as $availrec) {
             $allmatchesok = true;
             // Get the complete legacy availability object.
             $availability = backup_controller_dbops::decode_backup_temp_info($availrec->info);
             // Note: This code used to update IDs, but that is now handled by the
             // current code (after restore) instead of this legacy code.
             // Get showavailability option.
             $thingid = $table === 'module' ? $availability->coursemoduleid : $availability->coursesectionid;
             $showrec = restore_dbops::get_backup_ids_record($this->get_restoreid(), $table . '_showavailability', $thingid);
             if (!$showrec) {
                 // Should not happen.
                 throw new coding_exception('No matching showavailability record');
             }
             $show = $showrec->info->showavailability;
             // The $availability object is now in the format used in the old
             // system. Interpret this and convert to new system.
             $currentvalue = $DB->get_field('course_' . $table . 's', 'availability', array('id' => $thingid), MUST_EXIST);
             $newvalue = \core_availability\info::add_legacy_availability_condition($currentvalue, $availability, $show);
             $DB->set_field('course_' . $table . 's', 'availability', $newvalue, array('id' => $thingid));
         }
     }
     $rs->close();
 }
开发者ID:Jinelle,项目名称:moodle,代码行数:36,代码来源:restore_stepslib.php


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