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


PHP grade_item::move_after_sortorder方法代码示例

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


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

示例1: edit_module_post_actions


//.........这里部分代码省略.........
                    } else {
                        $grade_item->aggregationcoef = 0;
                    }
                    $grade_item->update();
                }
            }
        }
    }
    require_once $CFG->libdir . '/grade/grade_outcome.php';
    // Add outcomes if requested.
    if ($hasoutcomes && ($outcomes = grade_outcome::fetch_all_available($course->id))) {
        $grade_items = array();
        // Outcome grade_item.itemnumber start at 1000, there is nothing above outcomes.
        $max_itemnumber = 999;
        if ($items) {
            foreach ($items as $item) {
                if ($item->itemnumber > $max_itemnumber) {
                    $max_itemnumber = $item->itemnumber;
                }
            }
        }
        foreach ($outcomes as $outcome) {
            $elname = 'outcome_' . $outcome->id;
            if (property_exists($moduleinfo, $elname) and $moduleinfo->{$elname}) {
                // So we have a request for new outcome grade item?
                if ($items) {
                    $outcomeexists = false;
                    foreach ($items as $item) {
                        if ($item->outcomeid == $outcome->id) {
                            $outcomeexists = true;
                            break;
                        }
                    }
                    if ($outcomeexists) {
                        continue;
                    }
                }
                $max_itemnumber++;
                $outcome_item = new grade_item();
                $outcome_item->courseid = $course->id;
                $outcome_item->itemtype = 'mod';
                $outcome_item->itemmodule = $moduleinfo->modulename;
                $outcome_item->iteminstance = $moduleinfo->instance;
                $outcome_item->itemnumber = $max_itemnumber;
                $outcome_item->itemname = $outcome->fullname;
                $outcome_item->outcomeid = $outcome->id;
                $outcome_item->gradetype = GRADE_TYPE_SCALE;
                $outcome_item->scaleid = $outcome->scaleid;
                $outcome_item->insert();
                // Move the new outcome into correct category and fix sortorder if needed.
                if ($grade_item) {
                    $outcome_item->set_parent($grade_item->categoryid);
                    $outcome_item->move_after_sortorder($grade_item->sortorder);
                } else {
                    if (isset($moduleinfo->gradecat)) {
                        $outcome_item->set_parent($moduleinfo->gradecat);
                    }
                }
                $gradecategory = $outcome_item->get_parent_category();
                if ($outcomeexists == false) {
                    if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
                        if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
                            $outcome_item->aggregationcoef = 1;
                        } else {
                            $outcome_item->aggregationcoef = 0;
                        }
                        $outcome_item->update();
                    }
                }
            }
        }
    }
    if (plugin_supports('mod', $moduleinfo->modulename, FEATURE_ADVANCED_GRADING, false) and has_capability('moodle/grade:managegradingforms', $modcontext)) {
        require_once $CFG->dirroot . '/grade/grading/lib.php';
        $gradingman = get_grading_manager($modcontext, 'mod_' . $moduleinfo->modulename);
        $showgradingmanagement = false;
        foreach ($gradingman->get_available_areas() as $areaname => $aretitle) {
            $formfield = 'advancedgradingmethod_' . $areaname;
            if (isset($moduleinfo->{$formfield})) {
                $gradingman->set_area($areaname);
                $methodchanged = $gradingman->set_active_method($moduleinfo->{$formfield});
                if (empty($moduleinfo->{$formfield})) {
                    // Going back to the simple direct grading is not a reason to open the management screen.
                    $methodchanged = false;
                }
                $showgradingmanagement = $showgradingmanagement || $methodchanged;
            }
        }
        // Update grading management information.
        $moduleinfo->gradingman = $gradingman;
        $moduleinfo->showgradingmanagement = $showgradingmanagement;
    }
    rebuild_course_cache($course->id, true);
    if ($hasgrades) {
        grade_regrade_final_grades($course->id);
    }
    require_once $CFG->libdir . '/plagiarismlib.php';
    plagiarism_save_form_elements($moduleinfo);
    return $moduleinfo;
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:101,代码来源:modlib.php

示例2: move_after_sortorder

 /**
  * Move this category after the given sortorder
  *
  * Does not change the parent
  *
  * @param int $sortorder to place after.
  * @return void
  */
 public function move_after_sortorder($sortorder)
 {
     $this->load_grade_item();
     $this->grade_item->move_after_sortorder($sortorder);
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:13,代码来源:grade_category.php

示例3: load_test_data

 /**
  * Load initial test information
  *
  * @param  string $assignmentname   Assignment name
  * @param  int $student1rawgrade    Student 1 grade
  * @param  int $student2rawgrade    Student 2 grade
  * @return array                    Array of vars with test information
  */
 protected function load_test_data($assignmentname, $student1rawgrade, $student2rawgrade)
 {
     global $DB;
     // Adds a course, a teacher, 2 students, an assignment and grades for the students.
     $course = $this->getDataGenerator()->create_course();
     $coursecontext = context_course::instance($course->id);
     $studentrole = $DB->get_record('role', array('shortname' => 'student'));
     $student1 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($student1->id, $course->id, $studentrole->id);
     $student2 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($student2->id, $course->id, $studentrole->id);
     $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher'));
     $teacher = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
     $parent = $this->getDataGenerator()->create_user();
     $this->setUser($parent);
     $student1context = context_user::instance($student1->id);
     // Creates a new role, gives it the capability and gives $USER that role.
     $parentroleid = $this->assignUserCapability('moodle/grade:viewall', $student1context->id);
     // Enrol the user in the course using the new role.
     $this->getDataGenerator()->enrol_user($parent->id, $course->id, $parentroleid);
     $assignment = $this->getDataGenerator()->create_module('assign', array('name' => $assignmentname, 'course' => $course->id));
     $modcontext = get_coursemodule_from_instance('assign', $assignment->id, $course->id);
     $assignment->cmidnumber = $modcontext->id;
     $student1grade = array('userid' => $student1->id, 'rawgrade' => $student1rawgrade);
     $student2grade = array('userid' => $student2->id, 'rawgrade' => $student2rawgrade);
     $studentgrades = array($student1->id => $student1grade, $student2->id => $student2grade);
     assign_grade_item_update($assignment, $studentgrades);
     // Insert a custom grade scale to be used by an outcome.
     $gradescale = new grade_scale();
     $gradescale->name = 'unittestscale3';
     $gradescale->courseid = $course->id;
     $gradescale->userid = 0;
     $gradescale->scale = 'Distinction, Very Good, Good, Pass, Fail';
     $gradescale->description = 'This scale is used to mark standard assignments.';
     $gradescale->insert();
     // Insert an outcome.
     $data = new stdClass();
     $data->courseid = $course->id;
     $data->fullname = 'Team work';
     $data->shortname = 'Team work';
     $data->scaleid = $gradescale->id;
     $outcome = new grade_outcome($data, false);
     $outcome->insert();
     $outcomegradeitem = new grade_item();
     $outcomegradeitem->itemname = $outcome->shortname;
     $outcomegradeitem->itemtype = 'mod';
     $outcomegradeitem->itemmodule = 'assign';
     $outcomegradeitem->iteminstance = $assignment->id;
     $outcomegradeitem->outcomeid = $outcome->id;
     $outcomegradeitem->cmid = 0;
     $outcomegradeitem->courseid = $course->id;
     $outcomegradeitem->aggregationcoef = 0;
     $outcomegradeitem->itemnumber = 1;
     // The activity's original grade item will be 0.
     $outcomegradeitem->gradetype = GRADE_TYPE_SCALE;
     $outcomegradeitem->scaleid = $outcome->scaleid;
     // This next two values for testing that returns parameters are correcly formatted.
     $outcomegradeitem->set_locked(true);
     $outcomegradeitem->hidden = '';
     $outcomegradeitem->insert();
     $assignmentgradeitem = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $assignment->id, 'itemnumber' => 0, 'courseid' => $course->id));
     $outcomegradeitem->set_parent($assignmentgradeitem->categoryid);
     $outcomegradeitem->move_after_sortorder($assignmentgradeitem->sortorder);
     return array($course, $assignment, $student1, $student2, $teacher, $parent);
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:74,代码来源:grades_externallib_test.php

示例4: test_get_course_module

 /**
  * Test get_course_module
  */
 public function test_get_course_module()
 {
     global $DB;
     $this->resetAfterTest(true);
     $this->setAdminUser();
     $course = self::getDataGenerator()->create_course();
     $record = array('course' => $course->id, 'name' => 'First Assignment');
     $options = array('idnumber' => 'ABC', 'visible' => 0);
     // Hidden activity.
     $assign = self::getDataGenerator()->create_module('assign', $record, $options);
     $outcomescale = 'Distinction, Very Good, Good, Pass, Fail';
     // Insert a custom grade scale to be used by an outcome.
     $gradescale = new grade_scale();
     $gradescale->name = 'gettcoursemodulescale';
     $gradescale->courseid = $course->id;
     $gradescale->userid = 0;
     $gradescale->scale = $outcomescale;
     $gradescale->description = 'This scale is used to mark standard assignments.';
     $gradescale->insert();
     // Insert an outcome.
     $data = new stdClass();
     $data->courseid = $course->id;
     $data->fullname = 'Team work';
     $data->shortname = 'Team work';
     $data->scaleid = $gradescale->id;
     $outcome = new grade_outcome($data, false);
     $outcome->insert();
     $outcomegradeitem = new grade_item();
     $outcomegradeitem->itemname = $outcome->shortname;
     $outcomegradeitem->itemtype = 'mod';
     $outcomegradeitem->itemmodule = 'assign';
     $outcomegradeitem->iteminstance = $assign->id;
     $outcomegradeitem->outcomeid = $outcome->id;
     $outcomegradeitem->cmid = 0;
     $outcomegradeitem->courseid = $course->id;
     $outcomegradeitem->aggregationcoef = 0;
     $outcomegradeitem->itemnumber = 1;
     // The activity's original grade item will be 0.
     $outcomegradeitem->gradetype = GRADE_TYPE_SCALE;
     $outcomegradeitem->scaleid = $outcome->scaleid;
     $outcomegradeitem->insert();
     $assignmentgradeitem = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $assign->id, 'itemnumber' => 0, 'courseid' => $course->id));
     $outcomegradeitem->set_parent($assignmentgradeitem->categoryid);
     $outcomegradeitem->move_after_sortorder($assignmentgradeitem->sortorder);
     // Test admin user can see the complete hidden activity.
     $result = core_course_external::get_course_module($assign->cmid);
     $result = external_api::clean_returnvalue(core_course_external::get_course_module_returns(), $result);
     $this->assertCount(0, $result['warnings']);
     // Test we retrieve all the fields.
     $this->assertCount(27, $result['cm']);
     $this->assertEquals($record['name'], $result['cm']['name']);
     $this->assertEquals($options['idnumber'], $result['cm']['idnumber']);
     $this->assertEquals(100, $result['cm']['grade']);
     $this->assertEquals(0.0, $result['cm']['gradepass']);
     $this->assertEquals('submissions', $result['cm']['advancedgrading'][0]['area']);
     $this->assertEmpty($result['cm']['advancedgrading'][0]['method']);
     $this->assertEquals($outcomescale, $result['cm']['outcomes'][0]['scale']);
     $student = $this->getDataGenerator()->create_user();
     $studentrole = $DB->get_record('role', array('shortname' => 'student'));
     self::getDataGenerator()->enrol_user($student->id, $course->id, $studentrole->id);
     $this->setUser($student);
     // The user shouldn't be able to see the activity.
     try {
         core_course_external::get_course_module($assign->cmid);
         $this->fail('Exception expected due to invalid permissions.');
     } catch (moodle_exception $e) {
         $this->assertEquals('requireloginerror', $e->errorcode);
     }
     // Make module visible.
     set_coursemodule_visible($assign->cmid, 1);
     // Test student user.
     $result = core_course_external::get_course_module($assign->cmid);
     $result = external_api::clean_returnvalue(core_course_external::get_course_module_returns(), $result);
     $this->assertCount(0, $result['warnings']);
     // Test we retrieve only the few files we can see.
     $this->assertCount(11, $result['cm']);
     $this->assertEquals($assign->cmid, $result['cm']['id']);
     $this->assertEquals($course->id, $result['cm']['course']);
     $this->assertEquals('assign', $result['cm']['modname']);
     $this->assertEquals($assign->id, $result['cm']['instance']);
 }
开发者ID:dg711,项目名称:moodle,代码行数:84,代码来源:externallib_test.php

示例5: RWSUQGrades

function RWSUQGrades($r_qiz)
{
    $r_gi = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => $r_qiz->modulename, 'iteminstance' => $r_qiz->instance, 'itemnumber' => 0, 'courseid' => $r_qiz->course));
    if ($r_gi && $r_gi->idnumber != $r_qiz->cmidnumber) {
        $r_gi->idnumber = $r_qiz->cmidnumber;
        $r_gi->update();
    }
    $r_its = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $r_qiz->modulename, 'iteminstance' => $r_qiz->instance, 'courseid' => $r_qiz->course));
    if ($r_its && isset($r_qiz->gradecat)) {
        if ($r_qiz->gradecat == -1) {
            $r_gcat = new grade_category();
            $r_gcat->courseid = $r_qiz->course;
            $r_gcat->fullname = $r_qiz->name;
            $r_gcat->insert();
            if ($r_gi) {
                $r_par = $r_gi->get_parent_category();
                $r_gcat->set_parent($r_par->id);
            }
            $r_qiz->gradecat = $r_gcat->id;
        }
        foreach ($r_its as $r_iti => $r_un) {
            $r_its[$r_iti]->set_parent($r_qiz->gradecat);
            if ($r_iti == $r_gi->id) {
                $r_gi = $r_its[$r_iti];
            }
        }
    }
    if ($r_ocs = grade_outcome::fetch_all_available($r_qiz->course)) {
        $r_gis = array();
        $r_mit = 999;
        if ($r_its) {
            foreach ($r_its as $r_it) {
                if ($r_it->itemnumber > $r_mit) {
                    $r_mit = $r_it->itemnumber;
                }
            }
        }
        foreach ($r_ocs as $r_oc) {
            $r_eln = 'outcome_' . $r_oc->id;
            if (property_exists($r_qiz, $r_eln) and $r_qiz->{$r_eln}) {
                if ($r_its) {
                    foreach ($r_its as $r_it) {
                        if ($r_it->outcomeid == $r_oc->id) {
                            continue 2;
                        }
                    }
                }
                $r_mit++;
                $r_oi = new grade_item();
                $r_oi->courseid = $r_qiz->course;
                $r_oi->itemtype = 'mod';
                $r_oi->itemmodule = $r_qiz->modulename;
                $r_oi->iteminstance = $r_qiz->instance;
                $r_oi->itemnumber = $r_mit;
                $r_oi->itemname = $r_oc->fullname;
                $r_oi->outcomeid = $r_oc->id;
                $r_oi->gradetype = GRADE_TYPE_SCALE;
                $r_oi->scaleid = $r_oc->scaleid;
                $r_oi->insert();
                if ($r_gi) {
                    $r_oi->set_parent($r_gi->categoryid);
                    $r_oi->move_after_sortorder($r_gi->sortorder);
                } else {
                    if (isset($r_qiz->gradecat)) {
                        $r_oi->set_parent($r_qiz->gradecat);
                    }
                }
            }
        }
    }
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:71,代码来源:servicelib.php

示例6: redirect

             $max_itemnumber++;
             $outcome_item = new grade_item();
             $outcome_item->courseid = $course->id;
             $outcome_item->itemtype = 'mod';
             $outcome_item->itemmodule = $fromform->modulename;
             $outcome_item->iteminstance = $fromform->instance;
             $outcome_item->itemnumber = $max_itemnumber;
             $outcome_item->itemname = $outcome->fullname;
             $outcome_item->outcomeid = $outcome->id;
             $outcome_item->gradetype = GRADE_TYPE_SCALE;
             $outcome_item->scaleid = $outcome->scaleid;
             $outcome_item->insert();
             // move the new outcome into correct category and fix sortorder if needed
             if ($grade_item) {
                 $outcome_item->set_parent($grade_item->categoryid);
                 $outcome_item->move_after_sortorder($grade_item->sortorder);
             } else {
                 if (isset($fromform->gradecat)) {
                     $outcome_item->set_parent($fromform->gradecat);
                 }
             }
         }
     }
 }
 rebuild_course_cache($course->id);
 grade_regrade_final_grades($course->id);
 plagiarism_save_form_elements($fromform);
 //save plagiarism settings
 if (isset($fromform->submitbutton)) {
     redirect("{$CFG->wwwroot}/mod/{$module->name}/view.php?id={$fromform->coursemodule}");
 } else {
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:modedit.php

示例7: array

             continue;
         }
         $grade_item->courseid = $COURSE->id;
         $grade_item->itemtype = 'mod';
         $grade_item->itemmodule = $fromform->modulename;
         $grade_item->iteminstance = $fromform->instance;
         $grade_item->itemnumber = $max_itemnumber + 1;
         $grade_item->itemname = $outcome->fullname;
         $grade_item->outcomeid = $outcome->id;
         $grade_item->gradetype = GRADE_TYPE_SCALE;
         $grade_item->scaleid = $outcome->scaleid;
         $grade_item->insert();
         // TODO comment on these next 4 lines
         if ($item = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => $grade_item->itemmodule, 'iteminstance' => $grade_item->iteminstance, 'itemnumber' => 0, 'courseid' => $COURSE->id))) {
             $grade_item->set_parent($item->categoryid);
             $grade_item->move_after_sortorder($item->sortorder);
         }
         $grade_items[] = $grade_item;
     }
 }
 // Create a grade_category to represent this module, if outcomes have been attached
 if (!empty($grade_items)) {
     // Add the module's normal grade_item as a child of this category
     $item_params = array('itemtype' => 'mod', 'itemmodule' => $fromform->modulename, 'iteminstance' => $fromform->instance, 'itemnumber' => 0, 'courseid' => $COURSE->id);
     $item = grade_item::fetch($item_params);
     // Only create the category if it will contain at least 2 items
     if ($item or count($grade_items) > 1) {
         // If we are here it means there is at least 1 outcome
         $cat_params = array('courseid' => $COURSE->id, 'fullname' => $fromform->name);
         $grade_category = grade_category::fetch($cat_params);
         if (!$grade_category) {
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:modedit.php


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