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


PHP grade_outcome::fetch方法代码示例

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


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

示例1: test_grade_outcome_fetch

 function test_grade_outcome_fetch()
 {
     $grade_outcome = new grade_outcome();
     $this->assertTrue(method_exists($grade_outcome, 'fetch'));
     $grade_outcome = grade_outcome::fetch(array('id' => $this->grade_outcomes[0]->id));
     $this->assertEqual($this->grade_outcomes[0]->id, $grade_outcome->id);
     $this->assertEqual($this->grade_outcomes[0]->shortname, $grade_outcome->shortname);
     $this->assertEqual($this->scale[2]->id, $grade_outcome->scale->id);
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例2: definition_after_data

 function definition_after_data()
 {
     global $CFG;
     $mform =& $this->_form;
     // first load proper scales
     if ($courseid = $mform->getElementValue('courseid')) {
         $options = array();
         if ($scales = grade_scale::fetch_all_local($courseid)) {
             $options[-1] = '--' . get_string('scalescustom');
             foreach ($scales as $scale) {
                 $options[$scale->id] = $scale->get_name();
             }
         }
         if ($scales = grade_scale::fetch_all_global()) {
             $options[-2] = '--' . get_string('scalesstandard');
             foreach ($scales as $scale) {
                 $options[$scale->id] = $scale->get_name();
             }
         }
         $scale_el =& $mform->getElement('scaleid');
         $scale_el->load($options);
     } else {
         $options = array();
         if ($scales = grade_scale::fetch_all_global()) {
             foreach ($scales as $scale) {
                 $options[$scale->id] = $scale->get_name();
             }
         }
         $scale_el =& $mform->getElement('scaleid');
         $scale_el->load($options);
     }
     if ($id = $mform->getElementValue('id')) {
         $outcome = grade_outcome::fetch(array('id' => $id));
         $itemcount = $outcome->get_item_uses_count();
         $coursecount = $outcome->get_course_uses_count();
         if ($itemcount) {
             $mform->hardFreeze('scaleid');
         }
         if (empty($courseid)) {
             $mform->hardFreeze('standard');
         } else {
             if (empty($outcome->courseid) and !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
                 $mform->hardFreeze('standard');
             } else {
                 if ($coursecount and empty($outcome->courseid)) {
                     $mform->hardFreeze('standard');
                 }
             }
         }
     } else {
         if (empty($courseid) or !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
             $mform->hardFreeze('standard');
         }
     }
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:55,代码来源:edit_form.php

示例3: grade_get_grades

/**
 * Returns grading information for given activity - optionally with users grades
 * Manual, course or category items can not be queried.
 * @param int $courseid id of course
 * @param string $itemtype 'mod', 'block'
 * @param string $itemmodule 'forum, 'quiz', etc.
 * @param int $iteminstance id of the item module
 * @param int $userid optional id of the graded user; if userid not used, returns only information about grade_item
 * @return array of grade information objects (scaleid, name, grade and locked status, etc.) indexed with itemnumbers
 */
function grade_get_grades($courseid, $itemtype, $itemmodule, $iteminstance, $userid_or_ids = 0)
{
    global $CFG;
    $return = new object();
    $return->items = array();
    $return->outcomes = array();
    $course_item = grade_item::fetch_course_item($courseid);
    $needsupdate = array();
    if ($course_item->needsupdate) {
        $result = grade_regrade_final_grades($courseid);
        if ($result !== true) {
            $needsupdate = array_keys($result);
        }
    }
    if ($grade_items = grade_item::fetch_all(array('itemtype' => $itemtype, 'itemmodule' => $itemmodule, 'iteminstance' => $iteminstance, 'courseid' => $courseid))) {
        foreach ($grade_items as $grade_item) {
            $decimalpoints = null;
            if (empty($grade_item->outcomeid)) {
                // prepare information about grade item
                $item = new object();
                $item->itemnumber = $grade_item->itemnumber;
                $item->scaleid = $grade_item->scaleid;
                $item->name = $grade_item->get_name();
                $item->grademin = $grade_item->grademin;
                $item->grademax = $grade_item->grademax;
                $item->gradepass = $grade_item->gradepass;
                $item->locked = $grade_item->is_locked();
                $item->hidden = $grade_item->is_hidden();
                $item->grades = array();
                switch ($grade_item->gradetype) {
                    case GRADE_TYPE_NONE:
                        continue;
                    case GRADE_TYPE_VALUE:
                        $item->scaleid = 0;
                        break;
                    case GRADE_TYPE_TEXT:
                        $item->scaleid = 0;
                        $item->grademin = 0;
                        $item->grademax = 0;
                        $item->gradepass = 0;
                        break;
                }
                if (empty($userid_or_ids)) {
                    $userids = array();
                } else {
                    if (is_array($userid_or_ids)) {
                        $userids = $userid_or_ids;
                    } else {
                        $userids = array($userid_or_ids);
                    }
                }
                if ($userids) {
                    $grade_grades = grade_grade::fetch_users_grades($grade_item, $userids, true);
                    foreach ($userids as $userid) {
                        $grade_grades[$userid]->grade_item =& $grade_item;
                        $grade = new object();
                        $grade->grade = $grade_grades[$userid]->finalgrade;
                        $grade->locked = $grade_grades[$userid]->is_locked();
                        $grade->hidden = $grade_grades[$userid]->is_hidden();
                        $grade->overridden = $grade_grades[$userid]->overridden;
                        $grade->feedback = $grade_grades[$userid]->feedback;
                        $grade->feedbackformat = $grade_grades[$userid]->feedbackformat;
                        $grade->usermodified = $grade_grades[$userid]->usermodified;
                        // create text representation of grade
                        if (in_array($grade_item->id, $needsupdate)) {
                            $grade->grade = false;
                            $grade->str_grade = get_string('error');
                        } else {
                            if (is_null($grade->grade)) {
                                $grade->str_grade = '-';
                            } else {
                                $grade->str_grade = grade_format_gradevalue($grade->grade, $grade_item);
                            }
                        }
                        // create html representation of feedback
                        if (is_null($grade->feedback)) {
                            $grade->str_feedback = '';
                        } else {
                            $grade->str_feedback = format_text($grade->feedback, $grade->feedbackformat);
                        }
                        $item->grades[$userid] = $grade;
                    }
                }
                $return->items[$grade_item->itemnumber] = $item;
            } else {
                if (!($grade_outcome = grade_outcome::fetch(array('id' => $grade_item->outcomeid)))) {
                    debugging('Incorect outcomeid found');
                    continue;
                }
                // outcome info
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:101,代码来源:gradelib.php

示例4: get_course_module

 /**
  * Return information about a course module.
  *
  * @param int $cmid the course module id
  * @return array of warnings and the course module
  * @since Moodle 3.0
  * @throws moodle_exception
  */
 public static function get_course_module($cmid)
 {
     global $CFG, $DB;
     $params = self::validate_parameters(self::get_course_module_parameters(), array('cmid' => $cmid));
     $warnings = array();
     $cm = get_coursemodule_from_id(null, $params['cmid'], 0, true, MUST_EXIST);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     // If the user has permissions to manage the activity, return all the information.
     if (has_capability('moodle/course:manageactivities', $context)) {
         require_once $CFG->dirroot . '/course/modlib.php';
         require_once $CFG->libdir . '/gradelib.php';
         $info = $cm;
         // Get the extra information: grade, advanced grading and outcomes data.
         $course = get_course($cm->course);
         list($newcm, $newcontext, $module, $extrainfo, $cw) = get_moduleinfo_data($cm, $course);
         // Grades.
         $gradeinfo = array('grade', 'gradepass', 'gradecat');
         foreach ($gradeinfo as $gfield) {
             if (isset($extrainfo->{$gfield})) {
                 $info->{$gfield} = $extrainfo->{$gfield};
             }
         }
         if (isset($extrainfo->grade) and $extrainfo->grade < 0) {
             $info->scale = $DB->get_field('scale', 'scale', array('id' => abs($extrainfo->grade)));
         }
         // Advanced grading.
         if (isset($extrainfo->_advancedgradingdata)) {
             $info->advancedgrading = array();
             foreach ($extrainfo as $key => $val) {
                 if (strpos($key, 'advancedgradingmethod_') === 0) {
                     $info->advancedgrading[] = array('area' => str_replace('advancedgradingmethod_', '', $key), 'method' => $val);
                 }
             }
         }
         // Outcomes.
         foreach ($extrainfo as $key => $val) {
             if (strpos($key, 'outcome_') === 0) {
                 if (!isset($info->outcomes)) {
                     $info->outcomes = array();
                 }
                 $id = str_replace('outcome_', '', $key);
                 $outcome = grade_outcome::fetch(array('id' => $id));
                 $scaleitems = $outcome->load_scale();
                 $info->outcomes[] = array('id' => $id, 'name' => external_format_string($outcome->get_name(), $context->id), 'scale' => $scaleitems->scale);
             }
         }
     } else {
         // Return information is safe to show to any user.
         $info = new stdClass();
         $info->id = $cm->id;
         $info->course = $cm->course;
         $info->module = $cm->module;
         $info->modname = $cm->modname;
         $info->instance = $cm->instance;
         $info->section = $cm->section;
         $info->sectionnum = $cm->sectionnum;
         $info->groupmode = $cm->groupmode;
         $info->groupingid = $cm->groupingid;
         $info->completion = $cm->completion;
     }
     // Format name.
     $info->name = external_format_string($cm->name, $context->id);
     $result = array();
     $result['cm'] = $info;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:dg711,项目名称:moodle,代码行数:76,代码来源:externallib.php

示例5: load_outcome

 /**
  * Instantiates a grade_outcome object whose data is retrieved from the DB,
  * if this item's outcomeid variable is set.
  * @return object grade_outcome
  */
 function load_outcome()
 {
     if (!empty($this->outcomeid)) {
         $this->outcome = grade_outcome::fetch(array('id' => $this->outcomeid));
     }
     return $this->outcome;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:12,代码来源:grade_item.php

示例6: foreach

             foreach ($items as $item) {
                 if (empty($item->outcomeid)) {
                     continue;
                 }
                 if ($item->itemnumber > $max) {
                     $max = $item->itemnumber;
                 }
             }
             $grade_item->itemnumber = $max + 1;
         }
     } else {
         $grade_item->itemnumber = 1000;
     }
 }
 // fix scale used
 $outcome = grade_outcome::fetch(array('id' => $data->outcomeid));
 $grade_item->gradetype = GRADE_TYPE_SCALE;
 $grade_item->scaleid = $outcome->scaleid;
 //TODO: we might recalculate existing outcome grades when changing scale
 if (empty($grade_item->id)) {
     $grade_item->insert();
     // move next to activity if adding linked outcome
     if ($grade_item->itemtype == 'mod') {
         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);
         }
     } else {
         // set parent if needed
         if (isset($data->parentcategory)) {
             $grade_item->set_parent($data->parentcategory, 'gradebook');
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:outcomeitem.php

示例7: get_string

$strshortname = get_string('outcomeshortname', 'grades');
$strfullname = get_string('outcomefullname', 'grades');
$strscale = get_string('scale');
$strstandardoutcome = get_string('outcomesstandard', 'grades');
$strcustomoutcomes = get_string('outcomescustom', 'grades');
$strcreatenewoutcome = get_string('outcomecreate', 'grades');
$stritems = get_string('items', 'grades');
$strcourses = get_string('courses');
$stredit = get_string('edit');
switch ($action) {
    case 'delete':
        if (!confirm_sesskey()) {
            break;
        }
        $outcomeid = required_param('outcomeid', PARAM_INT);
        if (!($outcome = grade_outcome::fetch(array('id' => $outcomeid)))) {
            break;
        }
        if (empty($outcome->courseid)) {
            require_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM));
        } else {
            if ($outcome->courseid != $courseid) {
                print_error('invalidcourseid');
            }
        }
        if (!$outcome->can_delete()) {
            break;
        }
        $deleteconfirmed = optional_param('deleteconfirmed', 0, PARAM_BOOL);
        if (!$deleteconfirmed) {
            $PAGE->set_title(get_string('outcomedelete', 'grades'));
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:index.php

示例8: grade_get_grades

/**
 * Returns grading information for one or more activities, optionally with user grades
 * Manual, course or category items can not be queried.
 *
 * @category grade
 * @param int    $courseid ID of course
 * @param string $itemtype Type of grade item. For example, 'mod' or 'block'
 * @param string $itemmodule More specific then $itemtype. For example, 'forum' or 'quiz'. May be NULL for some item types
 * @param int    $iteminstance ID of the item module
 * @param mixed  $userid_or_ids Either a single user ID, an array of user IDs or null. If user ID or IDs are not supplied returns information about grade_item
 * @return array Array of grade information objects (scaleid, name, grade and locked status, etc.) indexed with itemnumbers
 */
function grade_get_grades($courseid, $itemtype = null, $itemmodule = null, $iteminstance = null, $userid_or_ids = null)
{
    global $CFG;
    if (empty($itemtype) or empty($itemmodule) or empty($iteminstance)) {
        debugging('itemtype, itemmodule or iteminstance parameters should not be empty. For Moodle 2.8 and onwards are required', DEBUG_DEVELOPER);
    }
    $return = new stdClass();
    $return->items = array();
    $return->outcomes = array();
    $course_item = grade_item::fetch_course_item($courseid);
    $needsupdate = array();
    if ($course_item->needsupdate) {
        $result = grade_regrade_final_grades($courseid);
        if ($result !== true) {
            $needsupdate = array_keys($result);
        }
    }
    $params = array('courseid' => $courseid);
    if (!empty($itemtype)) {
        $params['itemtype'] = $itemtype;
    }
    if (!empty($itemmodule)) {
        $params['itemmodule'] = $itemmodule;
    }
    if (!empty($iteminstance)) {
        $params['iteminstance'] = $iteminstance;
    }
    if ($grade_items = grade_item::fetch_all($params)) {
        foreach ($grade_items as $grade_item) {
            $decimalpoints = null;
            if (empty($grade_item->outcomeid)) {
                // prepare information about grade item
                $item = new stdClass();
                $item->id = $grade_item->id;
                $item->itemnumber = $grade_item->itemnumber;
                $item->itemtype = $grade_item->itemtype;
                $item->itemmodule = $grade_item->itemmodule;
                $item->iteminstance = $grade_item->iteminstance;
                $item->scaleid = $grade_item->scaleid;
                $item->name = $grade_item->get_name();
                $item->grademin = $grade_item->grademin;
                $item->grademax = $grade_item->grademax;
                $item->gradepass = $grade_item->gradepass;
                $item->locked = $grade_item->is_locked();
                $item->hidden = $grade_item->is_hidden();
                $item->grades = array();
                switch ($grade_item->gradetype) {
                    case GRADE_TYPE_NONE:
                        continue;
                    case GRADE_TYPE_VALUE:
                        $item->scaleid = 0;
                        break;
                    case GRADE_TYPE_TEXT:
                        $item->scaleid = 0;
                        $item->grademin = 0;
                        $item->grademax = 0;
                        $item->gradepass = 0;
                        break;
                }
                if (empty($userid_or_ids)) {
                    $userids = array();
                } else {
                    if (is_array($userid_or_ids)) {
                        $userids = $userid_or_ids;
                    } else {
                        $userids = array($userid_or_ids);
                    }
                }
                if ($userids) {
                    $grade_grades = grade_grade::fetch_users_grades($grade_item, $userids, true);
                    foreach ($userids as $userid) {
                        $grade_grades[$userid]->grade_item =& $grade_item;
                        $grade = new stdClass();
                        $grade->grade = $grade_grades[$userid]->finalgrade;
                        $grade->locked = $grade_grades[$userid]->is_locked();
                        $grade->hidden = $grade_grades[$userid]->is_hidden();
                        $grade->overridden = $grade_grades[$userid]->overridden;
                        $grade->feedback = $grade_grades[$userid]->feedback;
                        $grade->feedbackformat = $grade_grades[$userid]->feedbackformat;
                        $grade->usermodified = $grade_grades[$userid]->usermodified;
                        $grade->datesubmitted = $grade_grades[$userid]->get_datesubmitted();
                        $grade->dategraded = $grade_grades[$userid]->get_dategraded();
                        // create text representation of grade
                        if ($grade_item->gradetype == GRADE_TYPE_TEXT or $grade_item->gradetype == GRADE_TYPE_NONE) {
                            $grade->grade = null;
                            $grade->str_grade = '-';
                            $grade->str_long_grade = $grade->str_grade;
                        } else {
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:gradelib.php

示例9: emarking_copy_course_outcomes

/**
 * Copies the outcomes (and associates to course if necessary) from
 * a source emarking activity to a destination one
 *
 * @param unknown $emarkingsrc
 * @param unknown $emarkingdst
 * @return boolean
 */
function emarking_copy_course_outcomes($emarkingsrc, $emarkingdst)
{
    global $DB, $CFG;
    require_once $CFG->libdir . "/gradelib.php";
    require_once $CFG->libdir . "/grade/grade_outcome.php";
    if (!($coursesrc = $DB->get_record('course', array('id' => $emarkingsrc->course)))) {
        return false;
    }
    if (!($coursedst = $DB->get_record('course', array('id' => $emarkingdst->course)))) {
        return false;
    }
    $params = array($coursesrc->id, $emarkingsrc->id);
    $sql = "SELECT outcomeid, itemnumber\n          FROM {grade_items}\n         WHERE courseid=? AND outcomeid IS NOT NULL\n        AND itemmodule = 'emarking' AND iteminstance = ?\n        AND itemtype = 'mod'";
    $tocopy = $DB->get_records_sql($sql, $params);
    $outcomesready = array();
    foreach ($tocopy as $outcomeused) {
        $outcomesready[] = $outcomeused->outcomeid;
    }
    $params = array($coursedst->id, $emarkingdst->id);
    $sql = "SELECT outcomeid, itemnumber\n          FROM {grade_items}\n         WHERE courseid=? AND outcomeid IS NOT NULL\n        AND itemmodule = 'emarking' AND iteminstance = ?\n        AND itemtype = 'mod'";
    $realused = $DB->get_records_sql($sql, $params);
    $maxitemnumber = 999;
    foreach ($realused as $outcomeused) {
        if (array_search($outcomeused->outcomeid, $outcomesready)) {
            array_remove_by_value($outcomesready, $outcomeused->outcomeid);
        }
        if ($outcomeused->itemnumber > $maxitemnumber) {
            $maxitemnumber = $outcomeused->itemnumber;
        }
    }
    $outcomesdst = grade_outcome::fetch_all_available($emarkingdst->course);
    $outcomesavailable = array();
    foreach ($outcomesdst as $outcomedst) {
        $outcomesavailable[] = $outcomedst->id;
    }
    if ($maxitemnumber < 1000) {
        $maxitemnumber = 1000;
    }
    foreach ($outcomesready as $outcometocopy) {
        $outcome = grade_outcome::fetch(array('id' => $outcometocopy));
        if (!array_search($outcometocopy, $outcomesavailable)) {
            $outcome->use_in($emarkingdst->course);
        }
        $outcomeitem = new grade_item();
        $outcomeitem->courseid = $emarkingdst->course;
        $outcomeitem->itemtype = 'mod';
        $outcomeitem->itemmodule = 'emarking';
        $outcomeitem->iteminstance = $emarkingdst->id;
        $outcomeitem->itemnumber = $maxitemnumber;
        $outcomeitem->itemname = $outcome->fullname;
        $outcomeitem->outcomeid = $outcome->id;
        $outcomeitem->gradetype = GRADE_TYPE_SCALE;
        $outcomeitem->scaleid = $outcome->scaleid;
        $outcomeitem->insert();
        $maxitemnumber++;
    }
    return true;
}
开发者ID:sikeze,项目名称:emarking,代码行数:66,代码来源:locallib.php


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