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


PHP grade_get_letters函数代码示例

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


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

示例1: require_login

/*if ($context->contextlevel == CONTEXT_SYSTEM or $context->contextlevel == CONTEXT_COURSECAT) {
    require_once $CFG->libdir.'/adminlib.php';
    require_login();
    admin_externalpage_setup('letters');
    $admin = true;


} else if ($context->contextlevel == CONTEXT_COURSE) {
    require_login($context->instanceid);
    $admin = false;

} else {
    error('Incorrect context level');
}
*/
$letters = grade_get_letters($context);
if ($records = $DB->get_records('grade_letters', array('contextid' => $context->id), 'lowerboundary ASC')) {
    $old_ids = array_keys($records);
    // print_r($records);
}
$action_label = "";
$action_update_count = 0;
$action_insert_count = 0;
foreach ($letters as $boundary => $letter) {
    $letter = trim($letter);
    if ($letter == '') {
        continue;
    }
    $ori_letter = $letter;
    $letter = str_replace("+", "1", $letter);
    $newboundary = $_GET['textbox_' . $letter];
开发者ID:nustlms,项目名称:moodle-gradebook,代码行数:31,代码来源:update_grades.php

示例2: get_grade_letters

 /**
  * Fetches and returns an array of grade letters indexed by their grade boundaries, as stored in course item settings or site preferences.
  * @return array
  */
 function get_grade_letters()
 {
     global $COURSE;
     $context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
     return grade_get_letters($context);
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:10,代码来源:lib.php

示例3: grade_get_letters

/**
 * Returns grade letters array used in context
 * @param object $context object or null for defaults
 * @return array of grade_boundary=>letter_string
 */
function grade_get_letters($context = null)
{
    if (empty($context)) {
        //default grading letters
        return array('93' => 'A', '90' => 'A-', '87' => 'B+', '83' => 'B', '80' => 'B-', '77' => 'C+', '73' => 'C', '70' => 'C-', '67' => 'D+', '60' => 'D', '0' => 'F');
    }
    static $cache = array();
    if (array_key_exists($context->id, $cache)) {
        return $cache[$context->id];
    }
    if (count($cache) > 100) {
        $cache = array();
        // cache size limit
    }
    $letters = array();
    $contexts = get_parent_contexts($context);
    array_unshift($contexts, $context->id);
    foreach ($contexts as $ctxid) {
        if ($records = get_records('grade_letters', 'contextid', $ctxid, 'lowerboundary DESC')) {
            foreach ($records as $record) {
                $letters[$record->lowerboundary] = $record->letter;
            }
        }
        if (!empty($letters)) {
            $cache[$context->id] = $letters;
            return $letters;
        }
    }
    $letters = grade_get_letters(null);
    $cache[$context->id] = $letters;
    return $letters;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:37,代码来源:gradelib.php

示例4: process_data

 /**
  * Processes the data sent by the form (grades and feedbacks).
  * Caller is reposible for all access control checks
  * @param array $data form submission (with magic quotes)
  * @return array empty array if success, array of warnings if something fails.
  */
 function process_data($data)
 {
     $warnings = array();
     $separategroups = false;
     $mygroups = array();
     if ($this->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $this->context)) {
         $separategroups = true;
         $mygroups = groups_get_user_groups($this->course->id);
         $mygroups = $mygroups[0];
         // ignore groupings
         // reorder the groups fro better perf bellow
         $current = array_search($this->currentgroup, $mygroups);
         if ($current !== false) {
             unset($mygroups[$current]);
             array_unshift($mygroups, $this->currentgroup);
         }
     }
     // always initialize all arrays
     $queue = array();
     foreach ($data as $varname => $postedvalue) {
         $oldvalue = $data->{'old' . $varname};
         // was change requested?
         /// BP: moved this up to speed up the process of eliminating unchanged values
         if ($oldvalue == $postedvalue) {
             // string comparison
             continue;
         }
         $needsupdate = false;
         // skip, not a grade nor feedback
         if (strpos($varname, 'grade') === 0) {
             $data_type = 'grade';
         } else {
             if (strpos($varname, 'feedback') === 0) {
                 $data_type = 'feedback';
             } else {
                 continue;
             }
         }
         $gradeinfo = explode("_", $varname);
         $userid = clean_param($gradeinfo[1], PARAM_INT);
         $itemid = clean_param($gradeinfo[2], PARAM_INT);
         // HACK: bob puffer call local object
         if (!($grade_item = grade_item::fetch(array('id' => $itemid, 'courseid' => $this->courseid)))) {
             // we must verify course id here!
             //            if (!$grade_item = grade_item_local::fetch(array('id'=>$itemid, 'courseid'=>$this->courseid))) { // we must verify course id here!
             // END OF HACK
             error('Incorrect grade item id');
         }
         // Pre-process grade
         if ($data_type == 'grade') {
             $feedback = false;
             $feedbackformat = false;
             if ($grade_item->gradetype == GRADE_TYPE_SCALE) {
                 if ($postedvalue == -1) {
                     // -1 means no grade
                     $finalgrade = null;
                 } else {
                     $finalgrade = $postedvalue;
                 }
             } else {
                 // HACK: bob puffer to allow calculating grades from input letters
                 $context = get_context_instance(CONTEXT_COURSE, $grade_item->courseid);
                 // percentage input
                 if (strpos($postedvalue, '%')) {
                     $percent = trim(substr($postedvalue, 0, strpos($postedvalue, '%')));
                     $postedvalue = $percent * 0.01 * $grade_item->grademax;
                     // letter input?
                 } elseif ($letters = grade_get_letters($context)) {
                     unset($lastitem);
                     foreach ($letters as $used => $letter) {
                         if (strtoupper($postedvalue) == $letter) {
                             if (isset($lastitem)) {
                                 $postedvalue = $lastitem;
                             } else {
                                 $postedvalue = $grade_item->grademax;
                             }
                             break;
                         } else {
                             $lastitem = ($used - 1) * 0.01 * $grade_item->grademax;
                         }
                     }
                 }
                 // END OF HACK
                 $finalgrade = unformat_float($postedvalue);
             }
             $errorstr = '';
             // Warn if the grade is out of bounds.
             if (is_null($finalgrade)) {
                 // ok
             } else {
                 $bounded = $grade_item->bounded_grade($finalgrade);
                 if ($bounded > $finalgrade) {
                     $errorstr = 'lessthanmin';
                 } else {
//.........这里部分代码省略.........
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:lib.php


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