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


PHP format_float函数代码示例

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


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

示例1: determine_format

 /**
  * Build this UI element.
  *
  * @return element
  */
 public function determine_format()
 {
     $decimals = $this->item->get_decimals();
     $min = format_float($this->item->grademin, $decimals);
     $max = format_float($this->item->grademax, $decimals);
     return new empty_element("{$min} - {$max}");
 }
开发者ID:evltuma,项目名称:moodle,代码行数:12,代码来源:range.php

示例2: col_frequency

 function col_frequency($response){
     if ($this->question->_stats->s){
         return format_float((($response->rcount / $this->question->_stats->s)*100),2).'%';
     } else {
         return '';
     }
 }
开发者ID:nfreear,项目名称:moodle,代码行数:7,代码来源:statistics_question_table.php

示例3: test_adaptive_multichoice

 public function test_adaptive_multichoice()
 {
     // Create a multiple choice, single response question.
     $mc = test_question_maker::make_a_multichoice_single_question();
     $mc->penalty = 0.3333333;
     $this->start_attempt_at_question($mc, 'adaptive', 3);
     $rightindex = $this->get_mc_right_answer_index($mc);
     $wrongindex = ($rightindex + 1) % 3;
     // Check the initial state.
     $this->check_current_state(question_state::$todo);
     $this->check_current_mark(null);
     $this->check_current_output($this->get_contains_marked_out_of_summary(), $this->get_contains_question_text_expectation($mc), $this->get_contains_mc_radio_expectation(0, true, false), $this->get_contains_mc_radio_expectation(1, true, false), $this->get_contains_mc_radio_expectation(2, true, false), $this->get_contains_submit_button_expectation(true), $this->get_does_not_contain_feedback_expectation());
     // Process a submit.
     $this->process_submission(array('answer' => $wrongindex, '-submit' => 1));
     // Verify.
     $this->check_current_state(question_state::$todo);
     $this->check_current_mark(0);
     $this->check_current_output($this->get_contains_mark_summary(0), $this->get_contains_mc_radio_expectation($wrongindex, true, true), $this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, true, false), $this->get_contains_mc_radio_expectation(($wrongindex + 2) % 3, true, false), $this->get_contains_incorrect_expectation());
     $this->assertPattern('/B|C/', $this->quba->get_response_summary($this->slot));
     // Process a change of answer to the right one, but not sumbitted.
     $this->process_submission(array('answer' => $rightindex));
     // Verify.
     $this->check_current_state(question_state::$todo);
     $this->check_current_mark(0);
     $this->check_current_output($this->get_contains_mark_summary(0), $this->get_contains_mc_radio_expectation($rightindex, true, true), $this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, true, false), $this->get_contains_mc_radio_expectation(($rightindex + 2) % 3, true, false));
     $this->assertPattern('/B|C/', $this->quba->get_response_summary($this->slot));
     // Now submit the right answer.
     $this->process_submission(array('answer' => $rightindex, '-submit' => 1));
     // Verify.
     $this->check_current_state(question_state::$complete);
     $this->check_current_mark(3 * (1 - $mc->penalty));
     $this->check_current_output($this->get_contains_mark_summary(3 * (1 - $mc->penalty)), $this->get_contains_mc_radio_expectation($rightindex, true, true), $this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, true, false), $this->get_contains_mc_radio_expectation(($rightindex + 2) % 3, true, false), $this->get_contains_correct_expectation(), new PatternExpectation('/' . preg_quote(get_string('gradingdetailspenalty', 'qbehaviour_adaptive', format_float($mc->penalty, $this->displayoptions->markdp))) . '/'));
     $this->assertEqual('A', $this->quba->get_response_summary($this->slot));
     // Finish the attempt.
     $this->quba->finish_all_questions();
     // Verify.
     $this->check_current_state(question_state::$gradedright);
     $this->check_current_mark(3 * (1 - $mc->penalty));
     $this->check_current_output($this->get_contains_mark_summary(3 * (1 - $mc->penalty)), $this->get_contains_mc_radio_expectation($rightindex, false, true), $this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, false, false), $this->get_contains_mc_radio_expectation(($rightindex + 2) % 3, false, false), $this->get_contains_correct_expectation());
     // Process a manual comment.
     $this->manual_grade('Not good enough!', 1);
     // Verify.
     $this->check_current_state(question_state::$mangrpartial);
     $this->check_current_mark(1);
     $this->check_current_output($this->get_contains_mark_summary(1), new PatternExpectation('/' . preg_quote('Not good enough!') . '/'));
     // Now change the correct answer to the question, and regrade.
     $mc->answers[13]->fraction = -0.33333333;
     $mc->answers[15]->fraction = 1;
     $this->quba->regrade_all_questions();
     // Verify.
     $this->check_current_state(question_state::$mangrpartial);
     $this->check_current_mark(1);
     $this->check_current_output($this->get_contains_mark_summary(1), $this->get_contains_partcorrect_expectation());
     $autogradedstep = $this->get_step($this->get_step_count() - 2);
     $this->assertWithinMargin($autogradedstep->get_fraction(), 0, 1.0E-7);
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:56,代码来源:testwalkthrough.php

示例4: get_value

 /**
  * Get the value for this input.
  *
  * @return string The value based on the grade_grade.
  */
 public function get_value()
 {
     $this->label = $this->grade->grade_item->itemname;
     $val = $this->grade->finalgrade;
     if ($this->grade->grade_item->scaleid) {
         return $val ? (int) $val : -1;
     } else {
         return $val ? format_float($val, $this->grade->grade_item->get_decimals()) : '';
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:15,代码来源:finalgrade.php

示例5: get_value

 /**
  * Get the value for this input.
  *
  * @return string The value based on the grade_grade.
  */
 public function get_value()
 {
     $this->label = $this->grade->grade_item->itemname;
     // Manual item raw grade support.
     $val = $this->grade->grade_item->is_manual_item() && !is_null($this->grade->rawgrade) ? $this->grade->rawgrade : $this->grade->finalgrade;
     if ($this->grade->grade_item->scaleid) {
         return $val ? (int) $val : -1;
     } else {
         return $val ? format_float($val, $this->grade->grade_item->get_decimals()) : '';
     }
 }
开发者ID:HuiChangZhai,项目名称:moodle,代码行数:16,代码来源:finalgrade.php

示例6: get_course_cost

function get_course_cost($plugininstance)
{
    $defaultplugin = enrol_get_plugin('authorize');
    $cost = (double) 0;
    $currency = !empty($plugininstance->currency) ? $plugininstance->currency : (empty($defaultplugin->currency) ? 'USD' : $defaultplugin->enrol_currency);
    if (!empty($plugininstance->cost)) {
        $cost = (double) ((double) $plugininstance->cost < 0) ? $defaultplugin->cost : $plugininstance->cost;
    }
    $cost = format_float($cost, 2);
    $ret = array('cost' => $cost, 'currency' => $currency);
    return $ret;
}
开发者ID:JP-Git,项目名称:moodle,代码行数:12,代码来源:localfuncs.php

示例7: get_course_cost

function get_course_cost($course)
{
    global $CFG;
    $cost = (double) 0;
    $currency = !empty($course->currency) ? $course->currency : (empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency);
    if (!empty($course->cost)) {
        $cost = (double) ((double) $course->cost < 0) ? $CFG->enrol_cost : $course->cost;
    }
    $cost = format_float($cost, 2);
    $ret = array('cost' => $cost, 'currency' => $currency);
    return $ret;
}
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:12,代码来源:localfuncs.php

示例8: config_form_display

 /**
  * Add appropriate form elements to the critieria form
  *
  * @param moodle_form $mform Moodle forms object
  * @param stdClass $data containing default values to be set in the form
  */
 public function config_form_display(&$mform, $data = null)
 {
     $mform->addElement('checkbox', 'criteria_grade', get_string('enable'));
     $mform->addElement('text', 'criteria_grade_value', get_string('graderequired', 'completion'));
     $mform->disabledIf('criteria_grade_value', 'criteria_grade');
     $mform->setType('criteria_grade_value', PARAM_RAW);
     // Uses unformat_float.
     $mform->setDefault('criteria_grade_value', format_float($data));
     if ($this->id) {
         $mform->setDefault('criteria_grade', 1);
         $mform->setDefault('criteria_grade_value', format_float($this->gradepass));
     }
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:19,代码来源:completion_criteria_grade.php

示例9: results_as_columns

 public static function results_as_columns($results)
 {
     $header[] = get_string('choiceoptions', 'choice');
     $votes[] = get_string('numberofuser', 'choice');
     $percent[] = get_string('numberofuserinpercentage', 'choice');
     $graph[] = get_string('responsesresultgraphheader', 'choice');
     foreach ($results as $result) {
         $header[] = $result['text'];
         $votes[] = $result['votes'];
         $percent[] = format_float($result['percent'], 1) . '%';
         $graph[] = progress::level($result['percent']);
     }
     return array('header' => $header, 'rows' => array($votes, $percent, $graph));
 }
开发者ID:rbclark,项目名称:moodle-theme_bootstrap_renderers,代码行数:14,代码来源:mod_choice_renderer.php

示例10: test_quiz_rescale_grade

 public function test_quiz_rescale_grade()
 {
     $quiz = new stdClass();
     $quiz->decimalpoints = 2;
     $quiz->questiondecimalpoints = 3;
     $quiz->grade = 10;
     $quiz->sumgrades = 10;
     $this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, false), 0.12345678);
     $this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.12, 2));
     $this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, 'question'), format_float(0.123, 3));
     $quiz->sumgrades = 5;
     $this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, false), 0.24691356);
     $this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, true), format_float(0.25, 2));
     $this->assertEquals(quiz_rescale_grade(0.12345678, $quiz, 'question'), format_float(0.247, 3));
 }
开发者ID:janeklb,项目名称:moodle,代码行数:15,代码来源:locallib_test.php

示例11: get_value

 /**
  * Get the value for this input.
  *
  * @return string The value based on the grade_grade.
  */
 public function get_value()
 {
     $this->label = $this->grade->grade_item->itemname;
     $isoverridden = $this->grade->is_overridden();
     if (!empty($isoverridden)) {
         $val = $this->grade->finalgrade;
     } else {
         $val = $this->grade->rawgrade;
     }
     if ($this->grade->grade_item->scaleid) {
         return $val ? (int) $val : -1;
     } else {
         return $val ? format_float($val, $this->grade->grade_item->get_decimals()) : '';
     }
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:20,代码来源:finalgrade.php

示例12: definition

 function definition()
 {
     $mform = $this->_form;
     list($instance, $plugin, $context) = $this->_customdata;
     $mform->addElement('header', 'header', get_string('pluginname', 'enrol_ipay'));
     $mform->addElement('text', 'name', get_string('custominstancename', 'enrol'));
     $mform->setType('name', PARAM_TEXT);
     $options = array(ENROL_INSTANCE_ENABLED => get_string('yes'), ENROL_INSTANCE_DISABLED => get_string('no'));
     $mform->addElement('select', 'status', get_string('status', 'enrol_ipay'), $options);
     $mform->setDefault('status', $plugin->get_config('status'));
     $mform->addElement('text', 'businessname', get_string('businessname', 'enrol_ipay'));
     $mform->setType('businessname', PARAM_TEXT);
     // test if i can see business name
     $mform->setDefault('businessname', $plugin->get_config('businessname'));
     //this faetches from the configured setings the business name
     $mform->addElement('text', 'cost', get_string('cost', 'enrol_ipay'), array('size' => 4));
     $mform->setType('cost', PARAM_RAW);
     // Use unformat_float to get real value.
     $mform->setDefault('cost', format_float($plugin->get_config('cost'), 2, true));
     $ipaycurrencies = $plugin->get_currencies();
     $mform->addElement('select', 'currency', get_string('currency', 'enrol_ipay'), $ipaycurrencies);
     $mform->setDefault('currency', $plugin->get_config('currency'));
     if ($instance->id) {
         $roles = get_default_enrol_roles($context, $instance->roleid);
     } else {
         $roles = get_default_enrol_roles($context, $plugin->get_config('roleid'));
     }
     $mform->addElement('select', 'roleid', get_string('assignrole', 'enrol_ipay'), $roles);
     $mform->setDefault('roleid', $plugin->get_config('roleid'));
     $mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'enrol_ipay'), array('optional' => true, 'defaultunit' => 86400));
     $mform->setDefault('enrolperiod', $plugin->get_config('enrolperiod'));
     $mform->addHelpButton('enrolperiod', 'enrolperiod', 'enrol_ipay');
     $mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_ipay'), array('optional' => true));
     $mform->setDefault('enrolstartdate', 0);
     $mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_ipay');
     $mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_ipay'), array('optional' => true));
     $mform->setDefault('enrolenddate', 0);
     $mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_ipay');
     $mform->addElement('hidden', 'id');
     $mform->setType('id', PARAM_INT);
     $mform->addElement('hidden', 'courseid');
     $mform->setType('courseid', PARAM_INT);
     if (enrol_accessing_via_instance($instance)) {
         $mform->addElement('static', 'selfwarn', get_string('instanceeditselfwarning', 'core_enrol'), get_string('instanceeditselfwarningtext', 'core_enrol'));
     }
     $this->add_action_buttons(true, $instance->id ? null : get_string('addinstance', 'enrol'));
     $this->set_data($instance);
 }
开发者ID:kiarie,项目名称:ipay,代码行数:48,代码来源:edit_form.php

示例13: get_value

 /**
  * Get the value for this input.
  *
  * @return string The value based on the grade_grade.
  */
 public function get_value()
 {
     $this->label = $this->grade->grade_item->itemname;
     $isoverridden = $this->grade->is_overridden();
     // If the grade is overridden or the grade type is not an activity then use finalgrade.
     if (!empty($isoverridden) || $this->grade->grade_item->itemtype != 'mod') {
         $val = $this->grade->finalgrade;
     } else {
         $val = $this->grade->rawgrade;
     }
     if ($this->grade->grade_item->scaleid) {
         return $val ? (int) $val : -1;
     } else {
         return $val ? format_float($val, $this->grade->grade_item->get_decimals()) : '';
     }
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:21,代码来源:finalgrade.php

示例14: 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

示例15: feedback

 public function feedback(question_attempt $qa, question_display_options $options)
 {
     if (!$options->feedback) {
         return '';
     }
     if ($qa->get_state() == question_state::$gaveup || $qa->get_state() == question_state::$mangaveup) {
         return '';
     }
     $feedback = '';
     if (!$qa->get_last_behaviour_var('certainty') && $qa->get_last_behaviour_var('_assumedcertainty')) {
         $feedback .= html_writer::tag('p', get_string('assumingcertainty', 'qbehaviour_deferredcbm', question_cbm::get_string($qa->get_last_behaviour_var('_assumedcertainty'))));
     }
     if ($options->marks >= question_display_options::MARK_AND_MAX) {
         $a->rawmark = format_float($qa->get_last_behaviour_var('_rawfraction') * $qa->get_max_mark(), $options->markdp);
         $a->mark = $qa->format_mark($options->markdp);
         $feedback .= html_writer::tag('p', get_string('markadjustment', 'qbehaviour_deferredcbm', $a));
     }
     return $feedback;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:19,代码来源:renderer.php


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