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


PHP quiz_format_question_grade函数代码示例

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


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

示例1: test_quiz_format_question_grade

 public function test_quiz_format_question_grade()
 {
     $quiz = new stdClass();
     $quiz->decimalpoints = 2;
     $quiz->questiondecimalpoints = 2;
     $this->assertEquals(quiz_format_question_grade($quiz, 0.12345678), format_float(0.12, 2));
     $this->assertEquals(quiz_format_question_grade($quiz, 0), format_float(0, 2));
     $this->assertEquals(quiz_format_question_grade($quiz, 1.0), format_float(1, 2));
     $quiz->decimalpoints = 3;
     $quiz->questiondecimalpoints = -1;
     $this->assertEquals(quiz_format_question_grade($quiz, 0.12345678), format_float(0.123, 3));
     $this->assertEquals(quiz_format_question_grade($quiz, 0), format_float(0, 3));
     $this->assertEquals(quiz_format_question_grade($quiz, 1.0), format_float(1, 3));
     $quiz->questiondecimalpoints = 4;
     $this->assertEquals(quiz_format_question_grade($quiz, 0.12345678), format_float(0.1235, 4));
     $this->assertEquals(quiz_format_question_grade($quiz, 0), format_float(0, 4));
     $this->assertEquals(quiz_format_question_grade($quiz, 1.0), format_float(1, 4));
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:18,代码来源:lib_test.php

示例2: get_question_mark

 /**
  * Return the grade obtained on a particular question.
  * You must previously have called load_question_states to load the state
  * data about this question.
  *
  * @param int $slot the number used to identify this question within this attempt.
  * @return string the formatted grade, to the number of decimal places specified by the quiz.
  */
 public function get_question_mark($slot)
 {
     return quiz_format_question_grade($this->get_quiz(), $this->quba->get_question_mark($slot));
 }
开发者ID:elie89,项目名称:moodle,代码行数:12,代码来源:attemptlib.php

示例3: formatted_question_grade

 /**
  * Get the maximum mark for a question, formatted for display.
  * @param int $slotnumber the index of the slot in question.
  * @return string the maximum mark for the question in this slot.
  */
 public function formatted_question_grade($slotnumber)
 {
     return quiz_format_question_grade($this->get_quiz(), $this->slotsinorder[$slotnumber]->maxmark);
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:9,代码来源:structure.php

示例4: require_capability

     require_capability('mod/quiz:manage', $modcontext);
     $slot = $DB->get_record('quiz_slots', array('id' => $id), '*', MUST_EXIST);
     echo json_encode(array('instancemaxmark' => quiz_format_question_grade($quiz, $slot->maxmark)));
     break;
 case 'updatemaxmark':
     require_capability('mod/quiz:manage', $modcontext);
     $slot = $structure->get_slot_by_id($id);
     if ($structure->update_slot_maxmark($slot, $maxmark)) {
         // Grade has really changed.
         quiz_delete_previews($quiz);
         quiz_update_sumgrades($quiz);
         quiz_update_all_attempt_sumgrades($quiz);
         quiz_update_all_final_grades($quiz);
         quiz_update_grades($quiz, 0, true);
     }
     echo json_encode(array('instancemaxmark' => quiz_format_question_grade($quiz, $maxmark), 'newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades)));
     break;
 case 'updatepagebreak':
     require_capability('mod/quiz:manage', $modcontext);
     $slots = $structure->update_page_break($quiz, $id, $value);
     $json = array();
     foreach ($slots as $slot) {
         $json[$slot->slot] = array('id' => $slot->id, 'slot' => $slot->slot, 'page' => $slot->page);
     }
     echo json_encode(array('slots' => $json));
     break;
 case 'updatedependency':
     require_capability('mod/quiz:manage', $modcontext);
     $slot = $structure->get_slot_by_id($id);
     $value = (bool) $value;
     $structure->update_question_dependency($slot->id, $value);
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:31,代码来源:edit_rest.php

示例5: quiz_rescale_grade

/**
 * Convert the raw grade stored in $attempt into a grade out of the maximum
 * grade for this quiz.
 *
 * @param float $rawgrade the unadjusted grade, fof example $attempt->sumgrades
 * @param object $quiz the quiz object. Only the fields grade, sumgrades and decimalpoints are used.
 * @param bool|string $format whether to format the results for display
 *      or 'question' to format a question grade (different number of decimal places.
 * @return float|string the rescaled grade, or null/the lang string 'notyetgraded'
 *      if the $grade is null.
 */
function quiz_rescale_grade($rawgrade, $quiz, $format = true) {
    if (is_null($rawgrade)) {
        $grade = null;
    } else if ($quiz->sumgrades >= 0.000005) {
        $grade = $rawgrade * $quiz->grade / $quiz->sumgrades;
    } else {
        $grade = 0;
    }
    if ($format === 'question') {
        $grade = quiz_format_question_grade($quiz, $grade);
    } else if ($format) {
        $grade = quiz_format_grade($quiz, $grade);
    }
    return $grade;
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:26,代码来源:locallib.php

示例6: quiz_rescale_grade

/**
 * Convert the raw grade stored in $attempt into a grade out of the maximum
 * grade for this quiz.
 *
 * @param float $rawgrade the unadjusted grade, fof example $attempt->sumgrades
 * @param object $quiz the quiz object. Only the fields grade, sumgrades, decimalpoints and questiondecimalpoints are used.
 * @param mixed $round false = don't round, true = round using quiz_format_grade, 'question' = round using quiz_format_question_grade.
 * @return float the rescaled grade.
 */
function quiz_rescale_grade($rawgrade, $quiz, $round = true)
{
    if ($quiz->sumgrades != 0) {
        $grade = $rawgrade * $quiz->grade / $quiz->sumgrades;
        if ($round === 'question') {
            // === really necessary here true == 'question' is true in PHP!
            $grade = quiz_format_question_grade($quiz, $grade);
        } else {
            if ($round) {
                $grade = quiz_format_grade($quiz, $grade);
            }
        }
    } else {
        $grade = 0;
    }
    return $grade;
}
开发者ID:ajv,项目名称:Offline-Caching,代码行数:26,代码来源:locallib.php

示例7: marked_out_of_field

 /**
  * Display the 'marked out of' information for a question.
  * Along with the regrade action.
  * @param \stdClass $quiz the quiz settings from the database.
  * @param \stdClass $question data from the question and quiz_slots tables.
  * @return string HTML to output.
  */
 public function marked_out_of_field($quiz, $question)
 {
     if ($question->length == 0) {
         $output = html_writer::span('', 'instancemaxmark decimalplaces_' . quiz_get_grade_format($quiz));
         $output .= html_writer::span($this->pix_icon('spacer', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), 'editing_maxmark');
         return html_writer::span($output, 'instancemaxmarkcontainer infoitem');
     }
     $output = html_writer::span(quiz_format_question_grade($quiz, $question->maxmark), 'instancemaxmark decimalplaces_' . quiz_get_grade_format($quiz), array('title' => get_string('maxmark', 'quiz')));
     $output .= html_writer::span(html_writer::link(new \moodle_url('#'), $this->pix_icon('t/editstring', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), array('class' => 'editing_maxmark', 'data-action' => 'editmaxmark', 'title' => get_string('editmaxmark', 'quiz'))));
     return html_writer::span($output, 'instancemaxmarkcontainer');
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:18,代码来源:edit_renderer.php

示例8: format_average

 /**
  * Format an entry in an average row.
  * @param object $record with fields grade and numaveraged
  */
 protected function format_average($record, $question = false)
 {
     if (is_null($record->grade)) {
         $average = '-';
     } else {
         if ($question) {
             $average = quiz_format_question_grade($this->quiz, $record->grade);
         } else {
             $average = quiz_format_grade($this->quiz, $record->grade);
         }
     }
     if ($this->download) {
         return $average;
     } else {
         if (is_null($record->numaveraged) || $record->numaveraged == 0) {
             return html_writer::tag('span', html_writer::tag('span', $average, array('class' => 'average')), array('class' => 'avgcell'));
         } else {
             return html_writer::tag('span', html_writer::tag('span', $average, array('class' => 'average')) . ' ' . html_writer::tag('span', '(' . $record->numaveraged . ')', array('class' => 'count')), array('class' => 'avgcell'));
         }
     }
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:25,代码来源:overview_table.php

示例9: get_question_score

 /**
  * Return the grade obtained on a particular question, if the user is permitted to see it.
  * You must previously have called load_question_states to load the state data about this question.
  *
  * @param integer $questionid question id of a question that belongs to this quiz.
  * @return string the formatted grade, to the number of decimal places specified by the quiz.
  */
 public function get_question_score($questionid)
 {
     $options = $this->get_render_options($questionid);
     if ($options->scores) {
         return quiz_format_question_grade($this->quiz, $this->states[$questionid]->last_graded->grade);
     } else {
         return '';
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:16,代码来源:attemptlib.php

示例10: json_encode

                        echo json_encode(array('instancemaxmark' =>
                                quiz_format_question_grade($quiz, $slot->maxmark)));
                        break;

                    case 'updatemaxmark':
                        require_capability('mod/quiz:manage', $modcontext);
                        $slot = $structure->get_slot_by_id($id);
                        if ($structure->update_slot_maxmark($slot, $maxmark)) {
                            // Grade has really changed.
                            quiz_delete_previews($quiz);
                            quiz_update_sumgrades($quiz);
                            quiz_update_all_attempt_sumgrades($quiz);
                            quiz_update_all_final_grades($quiz);
                            quiz_update_grades($quiz, 0, true);
                        }
                        echo json_encode(array('instancemaxmark' => quiz_format_question_grade($quiz, $maxmark),
                                'newsummarks' => quiz_format_grade($quiz, $quiz->sumgrades)));
                        break;
                    case 'linkslottopage':
                        require_capability('mod/quiz:manage', $modcontext);
                        $slots = $structure->update_page_break($quiz, $id, $value);
                        $json = array();
                        foreach ($slots as $slot) {
                            $json[$slot->slot] = array('id' => $slot->id, 'slot' => $slot->slot,
                                                            'page' => $slot->page);
                        }
                        echo json_encode(array('slots' => $json));
                        break;
                }
                break;
开发者ID:jtibbetts,项目名称:moodle,代码行数:30,代码来源:edit_rest.php


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