本文整理汇总了PHP中grade_category::aggregation_uses_aggregationcoef方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_category::aggregation_uses_aggregationcoef方法的具体用法?PHP grade_category::aggregation_uses_aggregationcoef怎么用?PHP grade_category::aggregation_uses_aggregationcoef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_category
的用法示例。
在下文中一共展示了grade_category::aggregation_uses_aggregationcoef方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit_module_post_actions
/**
* Common create/update module module actions that need to be processed as soon as a module is created/updaded.
* For example:create grade parent category, add outcomes, rebuild caches, regrade, save plagiarism settings...
* Please note this api does not trigger events as of MOODLE 2.6. Please trigger events before calling this api.
*
* @param object $moduleinfo the module info
* @param object $course the course of the module
*
* @return object moduleinfo update with grading management info
*/
function edit_module_post_actions($moduleinfo, $course)
{
global $CFG;
require_once $CFG->libdir . '/gradelib.php';
$modcontext = context_module::instance($moduleinfo->coursemodule);
$hasgrades = plugin_supports('mod', $moduleinfo->modulename, FEATURE_GRADE_HAS_GRADE, false);
$hasoutcomes = plugin_supports('mod', $moduleinfo->modulename, FEATURE_GRADE_OUTCOMES, true);
// Sync idnumber with grade_item.
if ($hasgrades && ($grade_item = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => $moduleinfo->modulename, 'iteminstance' => $moduleinfo->instance, 'itemnumber' => 0, 'courseid' => $course->id)))) {
if ($grade_item->idnumber != $moduleinfo->cmidnumber) {
$grade_item->idnumber = $moduleinfo->cmidnumber;
$grade_item->update();
}
}
if ($hasgrades) {
$items = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => $moduleinfo->modulename, 'iteminstance' => $moduleinfo->instance, 'courseid' => $course->id));
} else {
$items = array();
}
// Create parent category if requested and move to correct parent category.
if ($items and isset($moduleinfo->gradecat)) {
if ($moduleinfo->gradecat == -1) {
$grade_category = new grade_category();
$grade_category->courseid = $course->id;
$grade_category->fullname = $moduleinfo->name;
$grade_category->insert();
if ($grade_item) {
$parent = $grade_item->get_parent_category();
$grade_category->set_parent($parent->id);
}
$moduleinfo->gradecat = $grade_category->id;
}
$gradecategory = $grade_item->get_parent_category();
foreach ($items as $itemid => $unused) {
$items[$itemid]->set_parent($moduleinfo->gradecat);
if ($itemid == $grade_item->id) {
// Use updated grade_item.
$grade_item = $items[$itemid];
}
if (!empty($moduleinfo->add)) {
if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
$grade_item->aggregationcoef = 1;
} 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;
//.........这里部分代码省略.........
示例2: workshopplus_grade_item_category_update
/**
* Update the grade items categories if they are changed via mod_form.php
*
* We must do it manually here in the workshopplus module because modedit supports only
* single grade item while we use two.
*
* @param stdClass $workshopplus An object from the form in mod_form.php
*/
function workshopplus_grade_item_category_update($workshopplus)
{
$gradeitems = grade_item::fetch_all(array('itemtype' => 'mod', 'itemmodule' => 'workshopplus', 'iteminstance' => $workshopplus->id, 'courseid' => $workshopplus->course));
if (!empty($gradeitems)) {
foreach ($gradeitems as $gradeitem) {
if ($gradeitem->itemnumber == 0) {
if ($gradeitem->categoryid != $workshopplus->gradecategory) {
$gradeitem->set_parent($workshopplus->gradecategory);
}
} else {
if ($gradeitem->itemnumber == 1) {
if ($gradeitem->categoryid != $workshopplus->gradinggradecategory) {
$gradeitem->set_parent($workshopplus->gradinggradecategory);
}
}
}
if (!empty($workshopplus->add)) {
$gradecategory = $gradeitem->get_parent_category();
if (grade_category::aggregation_uses_aggregationcoef($gradecategory->aggregation)) {
if ($gradecategory->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
$gradeitem->aggregationcoef = 1;
} else {
$gradeitem->aggregationcoef = 0;
}
$gradeitem->update();
}
}
}
}
}
示例3: sub_test_grade_category_aggregation_uses_aggregationcoef
protected function sub_test_grade_category_aggregation_uses_aggregationcoef()
{
$this->assertTrue(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_WEIGHTED_MEAN));
$this->assertTrue(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_WEIGHTED_MEAN2));
$this->assertTrue(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_EXTRACREDIT_MEAN));
$this->assertTrue(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_SUM));
$this->assertFalse(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_MAX));
$this->assertFalse(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_MEAN));
$this->assertFalse(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_MEDIAN));
$this->assertFalse(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_MIN));
$this->assertFalse(grade_category::aggregation_uses_aggregationcoef(GRADE_AGGREGATE_MODE));
}