當前位置: 首頁>>代碼示例>>PHP>>正文


PHP grade_item::set_properties方法代碼示例

本文整理匯總了PHP中grade_item::set_properties方法的典型用法代碼示例。如果您正苦於以下問題:PHP grade_item::set_properties方法的具體用法?PHP grade_item::set_properties怎麽用?PHP grade_item::set_properties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在grade_item的用法示例。


在下文中一共展示了grade_item::set_properties方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: unset

 unset($itemdata->locktime);
 $convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'aggregationcoef2');
 foreach ($convert as $param) {
     if (property_exists($itemdata, $param)) {
         $itemdata->{$param} = unformat_float($itemdata->{$param});
     }
 }
 if (isset($itemdata->aggregationcoef2)) {
     $itemdata->aggregationcoef2 = $itemdata->aggregationcoef2 / 100.0;
 }
 // When creating a new category, a number of grade item fields are filled out automatically, and are required.
 // If the user leaves these fields empty during creation of a category, we let the default values take effect
 // Otherwise, we let the user-entered grade item values take effect
 $grade_item = $grade_category->load_grade_item();
 $grade_item_copy = fullclone($grade_item);
 grade_item::set_properties($grade_item, $itemdata);
 if (empty($grade_item->id)) {
     $grade_item->id = $grade_item_copy->id;
 }
 if (empty($grade_item->grademax) && $grade_item->grademax != '0') {
     $grade_item->grademax = $grade_item_copy->grademax;
 }
 if (empty($grade_item->grademin) && $grade_item->grademin != '0') {
     $grade_item->grademin = $grade_item_copy->grademin;
 }
 if (empty($grade_item->gradepass) && $grade_item->gradepass != '0') {
     $grade_item->gradepass = $grade_item_copy->gradepass;
 }
 if (empty($grade_item->aggregationcoef) && $grade_item->aggregationcoef != '0') {
     $grade_item->aggregationcoef = $grade_item_copy->aggregationcoef;
 }
開發者ID:evltuma,項目名稱:moodle,代碼行數:31,代碼來源:category.php

示例2: test_upgrade_course_letter_boundary

 /**
  * Test that the upgrade script correctly flags courses to be frozen due to letter boundary problems.
  */
 public function test_upgrade_course_letter_boundary()
 {
     global $CFG, $DB;
     $this->resetAfterTest(true);
     require_once $CFG->libdir . '/db/upgradelib.php';
     // Create a user.
     $user = $this->getDataGenerator()->create_user();
     // Create some courses.
     $courses = array();
     $contexts = array();
     for ($i = 0; $i < 45; $i++) {
         $course = $this->getDataGenerator()->create_course();
         $context = context_course::instance($course->id);
         if (in_array($i, array(2, 5, 10, 13, 14, 19, 23, 25, 30, 34, 36))) {
             // Assign good letter boundaries.
             $this->assign_good_letter_boundary($context->id);
         }
         if (in_array($i, array(3, 6, 11, 15, 20, 24, 26, 31, 35))) {
             // Assign bad letter boundaries.
             $this->assign_bad_letter_boundary($context->id);
         }
         if (in_array($i, array(3, 9, 10, 11, 18, 19, 20, 29, 30, 31, 40))) {
             grade_set_setting($course->id, 'displaytype', '3');
         } else {
             if (in_array($i, array(8, 17, 28))) {
                 grade_set_setting($course->id, 'displaytype', '2');
             }
         }
         if (in_array($i, array(37, 43))) {
             // Show.
             grade_set_setting($course->id, 'report_user_showlettergrade', '1');
         } else {
             if (in_array($i, array(38, 42))) {
                 // Hide.
                 grade_set_setting($course->id, 'report_user_showlettergrade', '0');
             }
         }
         $assignrow = $this->getDataGenerator()->create_module('assign', array('course' => $course->id, 'name' => 'Test!'));
         $gi = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $assignrow->id, 'courseid' => $course->id));
         if (in_array($i, array(6, 13, 14, 15, 23, 24, 34, 35, 36, 41))) {
             grade_item::set_properties($gi, array('display' => 3));
             $gi->update();
         } else {
             if (in_array($i, array(12, 21, 32))) {
                 grade_item::set_properties($gi, array('display' => 2));
                 $gi->update();
             }
         }
         $gradegrade = new grade_grade();
         $gradegrade->itemid = $gi->id;
         $gradegrade->userid = $user->id;
         $gradegrade->rawgrade = 55.5563;
         $gradegrade->finalgrade = 55.5563;
         $gradegrade->rawgrademax = 100;
         $gradegrade->rawgrademin = 0;
         $gradegrade->timecreated = time();
         $gradegrade->timemodified = time();
         $gradegrade->insert();
         $contexts[] = $context;
         $courses[] = $course;
     }
     upgrade_course_letter_boundary();
     // No system setting for grade letter boundaries.
     // [0] A course with no letter boundaries.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[0]->id}));
     // [1] A course with letter boundaries which are default.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[1]->id}));
     // [2] A course with letter boundaries which are custom but not affected.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[2]->id}));
     // [3] A course with letter boundaries which are custom and will be affected.
     $this->assertEquals(20160518, $CFG->{'gradebook_calculations_freeze_' . $courses[3]->id});
     // [4] A course with no letter boundaries, but with a grade item with letter boundaries which are default.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[4]->id}));
     // [5] A course with no letter boundaries, but with a grade item with letter boundaries which are not default, but not affected.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[5]->id}));
     // [6] A course with no letter boundaries, but with a grade item with letter boundaries which are not default which will be affected.
     $this->assertEquals(20160518, $CFG->{'gradebook_calculations_freeze_' . $courses[6]->id});
     // System setting for grade letter boundaries (default).
     set_config('grade_displaytype', '3');
     for ($i = 0; $i < 45; $i++) {
         unset_config('gradebook_calculations_freeze_' . $courses[$i]->id);
     }
     upgrade_course_letter_boundary();
     // [7] A course with no grade display settings for the course or grade items.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[7]->id}));
     // [8] A course with grade display settings, but for something that isn't letters.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[8]->id}));
     // [9] A course with grade display settings of letters which are default.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[9]->id}));
     // [10] A course with grade display settings of letters which are not default, but not affected.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[10]->id}));
     // [11] A course with grade display settings of letters which are not default, which will be affected.
     $this->assertEquals(20160518, $CFG->{'gradebook_calculations_freeze_' . $courses[11]->id});
     // [12] A grade item with display settings that are not letters.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[12]->id}));
     // [13] A grade item with display settings of letters which are default.
     $this->assertTrue(empty($CFG->{'gradebook_calculations_freeze_' . $courses[13]->id}));
//.........這裏部分代碼省略.........
開發者ID:EsdrasCaleb,項目名稱:moodle,代碼行數:101,代碼來源:upgradelib_test.php


注:本文中的grade_item::set_properties方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。