• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP grade_set_setting函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中grade_set_setting函数的典型用法代码示例。如果您正苦于以下问题:PHP grade_set_setting函数的具体用法?PHP grade_set_setting怎么用?PHP grade_set_setting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_upgrade_minmaxgrade

 /**
  * Test upgrade minmaxgrade step.
  */
 public function test_upgrade_minmaxgrade()
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/gradelib.php';
     $initialminmax = $CFG->grade_minmaxtouse;
     $this->resetAfterTest();
     $c1 = $this->getDataGenerator()->create_course();
     $c2 = $this->getDataGenerator()->create_course();
     $c3 = $this->getDataGenerator()->create_course();
     $u1 = $this->getDataGenerator()->create_user();
     $a1 = $this->getDataGenerator()->create_module('assign', array('course' => $c1, 'grade' => 100));
     $a2 = $this->getDataGenerator()->create_module('assign', array('course' => $c2, 'grade' => 100));
     $a3 = $this->getDataGenerator()->create_module('assign', array('course' => $c3, 'grade' => 100));
     $cm1 = get_coursemodule_from_instance('assign', $a1->id);
     $ctx1 = context_module::instance($cm1->id);
     $assign1 = new assign($ctx1, $cm1, $c1);
     $cm2 = get_coursemodule_from_instance('assign', $a2->id);
     $ctx2 = context_module::instance($cm2->id);
     $assign2 = new assign($ctx2, $cm2, $c2);
     $cm3 = get_coursemodule_from_instance('assign', $a3->id);
     $ctx3 = context_module::instance($cm3->id);
     $assign3 = new assign($ctx3, $cm3, $c3);
     // Give a grade to the student.
     $ug = $assign1->get_user_grade($u1->id, true);
     $ug->grade = 10;
     $assign1->update_grade($ug);
     $ug = $assign2->get_user_grade($u1->id, true);
     $ug->grade = 20;
     $assign2->update_grade($ug);
     $ug = $assign3->get_user_grade($u1->id, true);
     $ug->grade = 30;
     $assign3->update_grade($ug);
     // Run the upgrade.
     upgrade_minmaxgrade();
     // Nothing has happened.
     $this->assertFalse($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c1->id)));
     $this->assertSame(false, grade_get_setting($c1->id, 'minmaxtouse', false, true));
     $this->assertFalse($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c1->id)));
     $this->assertFalse($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c2->id)));
     $this->assertSame(false, grade_get_setting($c2->id, 'minmaxtouse', false, true));
     $this->assertFalse($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c2->id)));
     $this->assertFalse($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c3->id)));
     $this->assertSame(false, grade_get_setting($c3->id, 'minmaxtouse', false, true));
     $this->assertFalse($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c3->id)));
     // Create inconsistency in c1 and c2.
     $giparams = array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $a1->id, 'courseid' => $c1->id, 'itemnumber' => 0);
     $gi = grade_item::fetch($giparams);
     $gi->grademin = 5;
     $gi->update();
     $giparams = array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $a2->id, 'courseid' => $c2->id, 'itemnumber' => 0);
     $gi = grade_item::fetch($giparams);
     $gi->grademax = 50;
     $gi->update();
     // C1 and C2 should be updated, but the course setting should not be set.
     $CFG->grade_minmaxtouse = GRADE_MIN_MAX_FROM_GRADE_GRADE;
     // Run the upgrade.
     upgrade_minmaxgrade();
     // C1 and C2 were partially updated.
     $this->assertTrue($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c1->id)));
     $this->assertSame(false, grade_get_setting($c1->id, 'minmaxtouse', false, true));
     $this->assertTrue($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c1->id)));
     $this->assertTrue($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c2->id)));
     $this->assertSame(false, grade_get_setting($c2->id, 'minmaxtouse', false, true));
     $this->assertTrue($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c2->id)));
     // Nothing has happened for C3.
     $this->assertFalse($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c3->id)));
     $this->assertSame(false, grade_get_setting($c3->id, 'minmaxtouse', false, true));
     $this->assertFalse($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c3->id)));
     // Course setting should not be set on a course that has the setting already.
     $CFG->grade_minmaxtouse = GRADE_MIN_MAX_FROM_GRADE_ITEM;
     grade_set_setting($c1->id, 'minmaxtouse', -1);
     // Sets different value than constant to check that it remained the same.
     // Run the upgrade.
     upgrade_minmaxgrade();
     // C2 was updated.
     $this->assertSame((string) GRADE_MIN_MAX_FROM_GRADE_GRADE, grade_get_setting($c2->id, 'minmaxtouse', false, true));
     // Nothing has happened for C1.
     $this->assertSame('-1', grade_get_setting($c1->id, 'minmaxtouse', false, true));
     // Nothing has happened for C3.
     $this->assertFalse($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c3->id)));
     $this->assertSame(false, grade_get_setting($c3->id, 'minmaxtouse', false, true));
     $this->assertFalse($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c3->id)));
     // Final check, this time we'll unset the default config.
     unset($CFG->grade_minmaxtouse);
     grade_set_setting($c1->id, 'minmaxtouse', null);
     // Run the upgrade.
     upgrade_minmaxgrade();
     // C1 was updated.
     $this->assertSame((string) GRADE_MIN_MAX_FROM_GRADE_GRADE, grade_get_setting($c1->id, 'minmaxtouse', false, true));
     // Nothing has happened for C3.
     $this->assertFalse($DB->record_exists('config', array('name' => 'show_min_max_grades_changed_' . $c3->id)));
     $this->assertSame(false, grade_get_setting($c3->id, 'minmaxtouse', false, true));
     $this->assertFalse($DB->record_exists('grade_items', array('needsupdate' => 1, 'courseid' => $c3->id)));
     // Restore value.
     $CFG->grade_minmaxtouse = $initialminmax;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:99,代码来源:upgradelib_test.php


示例2: grade_upgrade_use_min_max_from_grade_item

/**
 * Use the grade min and max from the grade_item.
 *
 * This is reserved for core use after an upgrade.
 *
 * @param int $courseid The current course id.
 */
function grade_upgrade_use_min_max_from_grade_item($courseid)
{
    grade_set_setting($courseid, 'minmaxtouse', GRADE_MIN_MAX_FROM_GRADE_ITEM);
    grade_force_full_regrading($courseid);
    // Do this now, because it probably happened to late in the page load to be happen automatically.
    grade_regrade_final_grades($courseid);
}
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:14,代码来源:lib.php


示例3: check_minmaxtouse

 /**
  * Checks what should happen with the course grade setting minmaxtouse.
  *
  * This is related to the upgrade step at the time the setting was added.
  *
  * @see MDL-48618
  * @return void
  */
 protected function check_minmaxtouse()
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/gradelib.php';
     $userinfo = $this->task->get_setting_value('users');
     $settingname = 'minmaxtouse';
     $courseid = $this->get_courseid();
     $minmaxtouse = $DB->get_field('grade_settings', 'value', array('courseid' => $courseid, 'name' => $settingname));
     $version28start = 2014111000.0;
     $version28last = 2014111006.05;
     $version29start = 2015051100.0;
     $version29last = 2015060400.02;
     $target = $this->get_task()->get_target();
     if ($minmaxtouse === false && ($target != backup::TARGET_CURRENT_ADDING && $target != backup::TARGET_EXISTING_ADDING)) {
         // The setting was not found because this setting did not exist at the time the backup was made.
         // And we are not restoring as merge, in which case we leave the course as it was.
         $version = $this->get_task()->get_info()->moodle_version;
         if ($version < $version28start) {
             // We need to set it to use grade_item, but only if the site-wide setting is different. No need to notice them.
             if ($CFG->grade_minmaxtouse != GRADE_MIN_MAX_FROM_GRADE_ITEM) {
                 grade_set_setting($courseid, $settingname, GRADE_MIN_MAX_FROM_GRADE_ITEM);
             }
         } else {
             if ($version >= $version28start && $version < $version28last || $version >= $version29start && $version < $version29last) {
                 // They should be using grade_grade when the course has inconsistencies.
                 $sql = "SELECT gi.id\n                          FROM {grade_items} gi\n                          JOIN {grade_grades} gg\n                            ON gg.itemid = gi.id\n                         WHERE gi.courseid = ?\n                           AND (gi.itemtype != ? AND gi.itemtype != ?)\n                           AND (gg.rawgrademax != gi.grademax OR gg.rawgrademin != gi.grademin)";
                 // The course can only have inconsistencies when we restore the user info,
                 // we do not need to act on existing grades that were not restored as part of this backup.
                 if ($userinfo && $DB->record_exists_sql($sql, array($courseid, 'course', 'category'))) {
                     // Display the notice as we do during upgrade.
                     set_config('show_min_max_grades_changed_' . $courseid, 1);
                     if ($CFG->grade_minmaxtouse != GRADE_MIN_MAX_FROM_GRADE_GRADE) {
                         // We need set the setting as their site-wise setting is not GRADE_MIN_MAX_FROM_GRADE_GRADE.
                         // If they are using the site-wide grade_grade setting, we only want to notice them.
                         grade_set_setting($courseid, $settingname, GRADE_MIN_MAX_FROM_GRADE_GRADE);
                     }
                 }
             } else {
                 // This should never happen because from now on minmaxtouse is always saved in backups.
             }
         }
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:51,代码来源:restore_stepslib.php


示例4: get_string

$strgrades = get_string('grades');
$pagename = get_string('coursesettings', 'grades');
$navigation = grade_build_nav(__FILE__, $pagename, $courseid);
$returnurl = $CFG->wwwroot . '/grade/index.php?id=' . $course->id;
$mform = new course_settings_form();
$settings = grade_get_settings($course->id);
$mform->set_data($settings);
if ($mform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($data = $mform->get_data()) {
        $data = (array) $data;
        $general = array('displaytype', 'decimalpoints', 'aggregationposition');
        foreach ($data as $key => $value) {
            if (!in_array($key, $general) and strpos($key, 'report_') !== 0 and strpos($key, 'import_') !== 0 and strpos($key, 'export_') !== 0) {
                continue;
            }
            if ($value == -1) {
                $value = null;
            }
            grade_set_setting($course->id, $key, $value);
        }
        redirect($returnurl);
    }
}
print_grade_page_head($courseid, 'settings', 'coursesettings', get_string('coursesettings', 'grades'));
print_box_start('generalbox boxaligncenter boxwidthnormal centerpara');
echo get_string('coursesettingsexplanation', 'grades');
print_box_end();
$mform->display();
print_footer($course);
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:31,代码来源:index.php


示例5: 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


示例6: test_grade_grade_min_max_with_category_item

 public function test_grade_grade_min_max_with_category_item()
 {
     global $CFG, $DB;
     $initialminmaxtouse = $CFG->grade_minmaxtouse;
     $this->setAdminUser();
     $course = $this->getDataGenerator()->create_course();
     $user = $this->getDataGenerator()->create_user();
     $coursegi = grade_item::fetch_course_item($course->id);
     // Create a category item.
     $gc = new grade_category(array('courseid' => $course->id, 'fullname' => 'test'), false);
     $gc->insert();
     $gi = $gc->get_grade_item();
     $gi->grademax = 100;
     $gi->grademin = 0;
     $gi->update();
     // Fetch the category item.
     $giparams = array('itemtype' => 'category', 'iteminstance' => $gc->id);
     $gi = grade_item::fetch($giparams);
     $this->assertEquals(0, $gi->grademin);
     $this->assertEquals(100, $gi->grademax);
     // Give a grade to the student.
     $gi->update_final_grade($user->id, 10);
     // Check the grade min/max stored in gradebook.
     $gg = grade_grade::fetch(array('userid' => $user->id, 'itemid' => $gi->id));
     $this->assertEquals(0, $gg->get_grade_min());
     $this->assertEquals(100, $gg->get_grade_max());
     // Change the min/max grade of the item.
     $gi->grademin = 2;
     $gi->grademax = 50;
     $gi->update();
     // Fetch the updated item.
     $gi = grade_item::fetch($giparams);
     // Now check the grade grade min/max with system setting.
     $CFG->grade_minmaxtouse = GRADE_MIN_MAX_FROM_GRADE_ITEM;
     grade_set_setting($course->id, 'minmaxtouse', null);
     // Ensure no course setting.
     $gg = grade_grade::fetch(array('userid' => $user->id, 'itemid' => $gi->id));
     $this->assertEquals(0, $gg->get_grade_min());
     $this->assertEquals(100, $gg->get_grade_max());
     // Now with other system setting.
     $CFG->grade_minmaxtouse = GRADE_MIN_MAX_FROM_GRADE_GRADE;
     grade_set_setting($course->id, 'minmaxtouse', null);
     // Ensure no course setting, and reset static cache.
     $gg = grade_grade::fetch(array('userid' => $user->id, 'itemid' => $gi->id));
     $this->assertEquals(0, $gg->get_grade_min());
     $this->assertEquals(100, $gg->get_grade_max());
     // Now with overriden setting in course.
     $CFG->grade_minmaxtouse = GRADE_MIN_MAX_FROM_GRADE_ITEM;
     grade_set_setting($course->id, 'minmaxtouse', GRADE_MIN_MAX_FROM_GRADE_GRADE);
     $gg = grade_grade::fetch(array('userid' => $user->id, 'itemid' => $gi->id));
     $this->assertEquals(0, $gg->get_grade_min());
     $this->assertEquals(100, $gg->get_grade_max());
     $CFG->grade_minmaxtouse = GRADE_MIN_MAX_FROM_GRADE_GRADE;
     grade_set_setting($course->id, 'minmaxtouse', GRADE_MIN_MAX_FROM_GRADE_ITEM);
     $gg = grade_grade::fetch(array('userid' => $user->id, 'itemid' => $gi->id));
     $this->assertEquals(0, $gg->get_grade_min());
     $this->assertEquals(100, $gg->get_grade_max());
     $CFG->grade_minmaxtouse = $initialminmaxtouse;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:59,代码来源:grade_grade_test.php


示例7: test_get_grade_items_student

 /**
  * Test get_grades_items function case student
  */
 public function test_get_grade_items_student()
 {
     $this->resetAfterTest(true);
     $s1grade = 80;
     $s2grade = 60;
     list($course, $teacher, $student1, $student2, $assignment) = $this->load_data($s1grade, $s2grade);
     grade_set_setting($course->id, 'report_user_showrank', 1);
     grade_set_setting($course->id, 'report_user_showpercentage', 1);
     grade_set_setting($course->id, 'report_user_showgrade', 1);
     grade_set_setting($course->id, 'report_user_showfeedback', 1);
     grade_set_setting($course->id, 'report_user_showweight', 1);
     grade_set_setting($course->id, 'report_user_showcontributiontocoursetotal', 1);
     grade_set_setting($course->id, 'report_user_showlettergrade', 1);
     grade_set_setting($course->id, 'report_user_showaverage', 1);
     $this->setUser($student1);
     $studentgrades = gradereport_user_external::get_grade_items($course->id, $student1->id);
     $studentgrades = external_api::clean_returnvalue(gradereport_user_external::get_grade_items_returns(), $studentgrades);
     // No warnings returned.
     $this->assertCount(0, $studentgrades['warnings']);
     // Check that only grades for the student in the teacher group are returned.
     $this->assertCount(1, $studentgrades['usergrades']);
     $this->assertCount(2, $studentgrades['usergrades'][0]['gradeitems']);
     $this->assertEquals($course->id, $studentgrades['usergrades'][0]['courseid']);
     $this->assertEquals($student1->id, $studentgrades['usergrades'][0]['userid']);
     $this->assertEquals('mod', $studentgrades['usergrades'][0]['gradeitems'][0]['itemtype']);
     $this->assertEquals('assign', $studentgrades['usergrades'][0]['gradeitems'][0]['itemmodule']);
     $this->assertEquals($assignment->id, $studentgrades['usergrades'][0]['gradeitems'][0]['iteminstance']);
     $this->assertEquals($assignment->cmidnumber, $studentgrades['usergrades'][0]['gradeitems'][0]['cmid']);
     $this->assertEquals(0, $studentgrades['usergrades'][0]['gradeitems'][0]['itemnumber']);
     $this->assertEmpty($studentgrades['usergrades'][0]['gradeitems'][0]['outcomeid']);
     $this->assertEmpty($studentgrades['usergrades'][0]['gradeitems'][0]['scaleid']);
     $this->assertEquals(80, $studentgrades['usergrades'][0]['gradeitems'][0]['graderaw']);
     $this->assertEquals('80.00', $studentgrades['usergrades'][0]['gradeitems'][0]['gradeformatted']);
     $this->assertEquals(0, $studentgrades['usergrades'][0]['gradeitems'][0]['grademin']);
     $this->assertEquals(100, $studentgrades['usergrades'][0]['gradeitems'][0]['grademax']);
     $this->assertEquals('0&ndash;100', $studentgrades['usergrades'][0]['gradeitems'][0]['rangeformatted']);
     $this->assertEquals('80.00 %', $studentgrades['usergrades'][0]['gradeitems'][0]['percentageformatted']);
     $this->assertEmpty($studentgrades['usergrades'][0]['gradeitems'][0]['feedback']);
     $this->assertFalse($studentgrades['usergrades'][0]['gradeitems'][0]['gradehiddenbydate']);
     $this->assertFalse($studentgrades['usergrades'][0]['gradeitems'][0]['gradeneedsupdate']);
     $this->assertFalse($studentgrades['usergrades'][0]['gradeitems'][0]['gradeishidden']);
     $this->assertEquals('B-', $studentgrades['usergrades'][0]['gradeitems'][0]['lettergradeformatted']);
     $this->assertEquals(1, $studentgrades['usergrades'][0]['gradeitems'][0]['rank']);
     $this->assertEquals(2, $studentgrades['usergrades'][0]['gradeitems'][0]['numusers']);
     $this->assertEquals(70, $studentgrades['usergrades'][0]['gradeitems'][0]['averageformatted']);
     // Hide one grade for the user.
     $gradegrade = new grade_grade(array('userid' => $student1->id, 'itemid' => $studentgrades['usergrades'][0]['gradeitems'][0]['id']), true);
     $gradegrade->set_hidden(1);
     $studentgrades = gradereport_user_external::get_grade_items($course->id, $student1->id);
     $studentgrades = external_api::clean_returnvalue(gradereport_user_external::get_grade_items_returns(), $studentgrades);
     // Check we get only the course final grade.
     $this->assertCount(1, $studentgrades['usergrades']);
     $this->assertCount(1, $studentgrades['usergrades'][0]['gradeitems']);
     $this->assertEquals('course', $studentgrades['usergrades'][0]['gradeitems'][0]['itemtype']);
 }
开发者ID:janeklb,项目名称:moodle,代码行数:58,代码来源:externallib_test.php


示例8: upgrade_mark_grading_configuration

/**
 * Configure current courses to use correct grading setting.
 *
 * Current courses should be forcibly set to use the 2.6 style grading initially.
 *
 * @return void
 */
function upgrade_mark_grading_configuration()
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/gradelib.php';
    // Identify the courses that have inconsistencies grade_item vs grade_grade.
    $sql = "SELECT DISTINCT(gi.courseid)\n              FROM {grade_items} gi\n              JOIN {grade_grades} gg\n                ON gg.itemid = gi.id\n             WHERE (gi.itemtype != ? AND gi.itemtype != ?)\n               AND (gg.rawgrademax != gi.grademax OR gg.rawgrademin != gi.grademin)";
    $rs = $DB->get_recordset_sql($sql, array('course', 'category'));
    foreach ($rs as $record) {
        set_config('noshow_min_max_grades_changed_' . $record->courseid, 1);
        // Set course to use grade_item value for max/min calculations.
        grade_set_setting($record->courseid, 'minmaxtouse', GRADE_MIN_MAX_FROM_GRADE_ITEM);
    }
    $rs->close();
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:21,代码来源:upgradelib.php


示例9: test_version1importdeletecoursedeletesassociations

 /**
  * Validate that the version 1 plugin deletes appropriate associations when
  * deleting a course
  */
 public function test_version1importdeletecoursedeletesassociations()
 {
     global $DB, $CFG, $USER;
     require_once $CFG->dirroot . '/user/lib.php';
     require_once $CFG->dirroot . '/lib/gradelib.php';
     require_once $CFG->dirroot . '/group/lib.php';
     require_once $CFG->dirroot . '/lib/conditionlib.php';
     require_once $CFG->dirroot . '/lib/enrollib.php';
     require_once $CFG->dirroot . '/tag/lib.php';
     require_once $CFG->dirroot . '/lib/questionlib.php';
     // Setup.
     $initialnumcontexts = $DB->count_records('context', array('contextlevel' => CONTEXT_COURSE));
     $DB->delete_records('block_instances');
     // Set up the course with one section, including default blocks.
     set_config('defaultblocks_topics', 'search_forums');
     set_config('maxsections', 10, 'moodlecourse');
     $this->run_core_course_import(array('shortname' => 'deleteassociationsshortname', 'numsections' => 1));
     // Create a user record.
     $record = new stdClass();
     $record->username = 'testuser';
     $record->password = 'Testpass!0';
     $userid = user_create_user($record);
     // Create a course-level role.
     $courseid = $DB->get_field('course', 'id', array('shortname' => 'deleteassociationsshortname'));
     $coursecontext = context_course::instance($courseid);
     $roleid = create_role('deleterole', 'deleterole', 'deleterole');
     set_role_contextlevels($roleid, array(CONTEXT_COURSE));
     $enrol = new stdClass();
     $enrol->enrol = 'manual';
     $enrol->courseid = $courseid;
     $enrol->status = ENROL_INSTANCE_ENABLED;
     if (!$DB->record_exists('enrol', (array) $enrol)) {
         $DB->insert_record('enrol', $enrol);
     }
     // Assign the user to the course-level role.
     enrol_try_internal_enrol($courseid, $userid, $roleid);
     // Create a grade item.
     $gradeitem = new grade_item(array('courseid' => $courseid, 'itemtype' => 'manual', 'itemname' => 'testitem'), false);
     $gradeitem->insert();
     $gradegrade = new grade_grade(array('itemid' => $gradeitem->id, 'userid' => $userid), false);
     // Assign the user a grade.
     $gradegrade->insert();
     // Create a grade outcome.
     $gradeoutcome = new grade_outcome(array('courseid' => $courseid, 'shortname' => 'bogusshortname', 'fullname' => 'bogusfullname'));
     $gradeoutcome->insert();
     // Create a grade scale.
     $gradescale = new grade_scale(array('courseid' => $courseid, 'name' => 'bogusname', 'userid' => $userid, 'scale' => 'bogusscale', 'description' => 'bogusdescription'));
     $gradescale->insert();
     // Set a grade setting value.
     grade_set_setting($courseid, 'bogus', 'bogus');
     // Set up a grade letter.
     $gradeletter = new stdClass();
     $gradeletter->contextid = $coursecontext->id;
     $gradeletter->lowerboundary = 80;
     $gradeletter->letter = 'A';
     $DB->insert_record('grade_letters', $gradeletter);
     // Set up a forum instance.
     $forum = new stdClass();
     $forum->course = $courseid;
     $forum->intro = 'intro';
     $forum->id = $DB->insert_record('forum', $forum);
     // Add it as a course module.
     $forum->module = $DB->get_field('modules', 'id', array('name' => 'forum'));
     $forum->instance = $forum->id;
     $cmid = add_course_module($forum);
     // Set up a completion record.
     $completion = new stdClass();
     $completion->coursemoduleid = $cmid;
     $completion->completionstate = 0;
     $completion->userid = 9999;
     $completion->timemodified = time();
     $DB->insert_record('course_modules_completion', $completion);
     // Set up a completion condition.
     $forum->id = $cmid;
     $ci = new condition_info($forum, CONDITION_MISSING_EVERYTHING, false);
     $ci->add_completion_condition($cmid, COMPLETION_ENABLED);
     // Set the blocks position.
     $instances = $DB->get_records('block_instances', array('parentcontextid' => $coursecontext->id));
     $page = new stdClass();
     $page->context = $coursecontext;
     $page->pagetype = 'course-view-*';
     $page->subpage = false;
     foreach ($instances as $instance) {
         blocks_set_visibility($instance, $page, 1);
     }
     // Create a group.
     $group = new stdClass();
     $group->name = 'testgroup';
     $group->courseid = $courseid;
     $groupid = groups_create_group($group);
     // Add the user to the group.
     groups_add_member($groupid, $userid);
     // Create a grouping containing our group.
     $grouping = new stdClass();
     $grouping->name = 'testgrouping';
     $grouping->courseid = $courseid;
//.........这里部分代码省略.........
开发者ID:jamesmcq,项目名称:elis,代码行数:101,代码来源:version1_course_import_test.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP grade_update函数代码示例发布时间:2022-05-15
下一篇:
PHP grade_regrade_final_grades函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap