本文整理汇总了PHP中question_possible_response类的典型用法代码示例。如果您正苦于以下问题:PHP question_possible_response类的具体用法?PHP question_possible_response怎么用?PHP question_possible_response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了question_possible_response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_get_possible_responses
public function test_get_possible_responses()
{
$q = new stdClass();
$q->id = 1;
$q->options->trueanswer = 1;
$q->options->falseanswer = 2;
$q->options->answers[1] = (object) array('fraction' => 1);
$q->options->answers[2] = (object) array('fraction' => 0);
$this->assertEqual(array($q->id => array(0 => new question_possible_response(get_string('false', 'qtype_truefalse'), 0), 1 => new question_possible_response(get_string('true', 'qtype_truefalse'), 1), null => question_possible_response::no_response())), $this->qtype->get_possible_responses($q));
}
示例2: get_possible_responses
public function get_possible_responses($questiondata) {
$responses = array();
$unit = $this->get_default_numerical_unit($questiondata);
$starfound = false;
foreach ($questiondata->options->answers as $aid => $answer) {
$responseclass = $answer->answer;
if ($responseclass === '*') {
$starfound = true;
} else {
$responseclass = $this->add_unit($questiondata, $responseclass, $unit);
$ans = new qtype_numerical_answer($answer->id, $answer->answer, $answer->fraction,
$answer->feedback, $answer->feedbackformat, $answer->tolerance);
list($min, $max) = $ans->get_tolerance_interval();
$responseclass .= " ($min..$max)";
}
$responses[$aid] = new question_possible_response($responseclass,
$answer->fraction);
}
if (!$starfound) {
$responses[0] = new question_possible_response(
get_string('didnotmatchanyanswer', 'question'), 0);
}
$responses[null] = question_possible_response::no_response();
return array($questiondata->id => $responses);
}
示例3: test_get_possible_responses_no_star
public function test_get_possible_responses_no_star() {
$q = test_question_maker::get_question_data('calculated');
unset($q->options->answers[17]);
$this->assertEqual(array(
$q->id => array(
13 => new question_possible_response(
$this->get_possible_response('{a} + {b}', 0.001, 'nominal'), 1),
14 => new question_possible_response(
$this->get_possible_response('{a} - {b}', 0.001, 'nominal'), 0),
0 => new question_possible_response(
get_string('didnotmatchanyanswer', 'question'), 0),
null => question_possible_response::no_response()
),
), $this->qtype->get_possible_responses($q));
}
示例4: test_get_possible_responses_no_star
public function test_get_possible_responses_no_star()
{
$q = test_question_maker::get_question_data('shortanswer', 'frogonly');
$this->assertEquals(array($q->id => array(13 => new question_possible_response('frog', 1), 0 => new question_possible_response(get_string('didnotmatchanyanswer', 'question'), 0), null => question_possible_response::no_response())), $this->qtype->get_possible_responses($q));
}
示例5: get_possible_responses
public function get_possible_responses($questiondata) {
$responses = array();
$unit = $this->get_default_numerical_unit($questiondata);
foreach ($questiondata->options->answers as $aid => $answer) {
$responseclass = $answer->answer;
if ($responseclass != '*') {
$responseclass = $this->add_unit($questiondata, $responseclass, $unit);
$ans = new qtype_numerical_answer($answer->id, $answer->answer, $answer->fraction,
$answer->feedback, $answer->feedbackformat, $answer->tolerance);
list($min, $max) = $ans->get_tolerance_interval();
$responseclass .= " ($min..$max)";
}
$responses[$aid] = new question_possible_response($responseclass,
$answer->fraction);
}
$responses[null] = question_possible_response::no_response();
return array($questiondata->id => $responses);
}
示例6: get_possible_responses
public function get_possible_responses($questiondata)
{
$responses = array();
$starfound = false;
foreach ($questiondata->options->answers as $aid => $answer) {
$responses[$aid] = new question_possible_response($answer->answer, $answer->fraction);
if ($answer->answer === '*') {
$starfound = true;
}
}
if (!$starfound) {
$responses[0] = new question_possible_response(get_string('didnotmatchanyanswer', 'question'), 0);
}
$responses[null] = question_possible_response::no_response();
return array($questiondata->id => $responses);
}
示例7: test_get_possible_responses
public function test_get_possible_responses()
{
$q = $this->get_test_question_data();
$this->assertEquals(array(14 => array(14 => new question_possible_response('frog: amphibian', 1 / 3), 15 => new question_possible_response('frog: mammal', 0), 17 => new question_possible_response('frog: insect', 0), null => question_possible_response::no_response()), 15 => array(14 => new question_possible_response('cat: amphibian', 0), 15 => new question_possible_response('cat: mammal', 1 / 3), 17 => new question_possible_response('cat: insect', 0), null => question_possible_response::no_response()), 16 => array(14 => new question_possible_response('newt: amphibian', 1 / 3), 15 => new question_possible_response('newt: mammal', 0), 17 => new question_possible_response('newt: insect', 0), null => question_possible_response::no_response())), $this->qtype->get_possible_responses($q));
}
示例8: get_possible_responses
public function get_possible_responses($questiondata)
{
$responses = array();
$question = $this->make_question($questiondata);
foreach ($question->correctresponse as $position => $answerid) {
$responses[] = $position . ': ' . $question->answers[$answerid]->answer;
}
$responses = array(0 => question_possible_response::no_response(), 1 => implode(', ', $responses));
return;
}
示例9: test_get_possible_responses_single
public function test_get_possible_responses_single() {
$q = $this->get_test_question_data();
$responses = $this->qtype->get_possible_responses($q);
$this->assertEquals(array(
$q->id => array(
1 => new question_possible_response('frog', 1),
2 => new question_possible_response('toad', 0),
null => question_possible_response::no_response(),
)), $this->qtype->get_possible_responses($q));
}
示例10: test_get_possible_responses
public function test_get_possible_responses()
{
$q = $this->get_test_question_data();
$this->assertEquals(array(1 => array(1 => new question_possible_response('quick', 1 / 3), 2 => new question_possible_response('slow', 0), null => question_possible_response::no_response()), 2 => array(1 => new question_possible_response('fox', 1 / 3), 2 => new question_possible_response('dog', 0), null => question_possible_response::no_response()), 3 => array(1 => new question_possible_response('lazy', 1 / 3), 2 => new question_possible_response('assiduous', 0), null => question_possible_response::no_response())), $this->qtype->get_possible_responses($q));
}
示例11: get_possible_responses
public function get_possible_responses($questiondata)
{
$question = $this->make_question($questiondata);
$parts = array();
foreach ($question->places as $place => $group) {
$choices = array();
foreach ($question->choices[$group] as $i => $choice) {
$choices[$i] = new question_possible_response(html_to_text($choice->text, 0, false), ($question->rightchoices[$place] == $i) / count($question->places));
}
$choices[null] = question_possible_response::no_response();
$parts[$place] = $choices;
}
return $parts;
}
示例12: test_get_possible_responses_no_star
public function test_get_possible_responses_no_star() {
$q = $this->get_test_question_data();
unset($q->options->answers[14]);
$this->assertEqual(array(
$q->id => array(
13 => new question_possible_response('42 m (41.5..42.5)', 1),
0 => new question_possible_response(
get_string('didnotmatchanyanswer', 'question'), 0),
null => question_possible_response::no_response()
),
), $this->qtype->get_possible_responses($q));
}
示例13: get_possible_responses
public function get_possible_responses($questiondata) {
if ($questiondata->options->single) {
$responses = array();
foreach ($questiondata->options->answers as $aid => $answer) {
$responses[$aid] = new question_possible_response(html_to_text(format_text(
$answer->answer, $answer->answerformat, array('noclean' => true)),
0, false), $answer->fraction);
}
$responses[null] = question_possible_response::no_response();
return array($questiondata->id => $responses);
} else {
$parts = array();
foreach ($questiondata->options->answers as $aid => $answer) {
$parts[$aid] = array($aid =>
new question_possible_response(html_to_text(format_text(
$answer->answer, $answer->answerformat, array('noclean' => true)),
0, false), $answer->fraction));
}
return $parts;
}
}
示例14: test_get_possible_responses
public function test_get_possible_responses()
{
$q = $this->get_test_question_data();
$this->assertEqual(array($q->id => array(13 => new question_possible_response('42 m (41.5..42.5)', 1), 14 => new question_possible_response('*', 0.1), null => question_possible_response::no_response())), $this->qtype->get_possible_responses($q));
}
示例15: get_possible_responses
public function get_possible_responses($questiondata)
{
$parts = array();
$q = $this->make_question($questiondata);
foreach ($q->prts as $index => $prt) {
foreach ($prt->get_nodes_summary() as $nodeid => $choices) {
$parts[$index . '-' . $nodeid] = array($choices->falsenote => new question_possible_response($choices->falsenote, $choices->falsescore * $prt->get_value()), $choices->truenote => new question_possible_response($choices->truenote, $choices->truescore * $prt->get_value()), null => question_possible_response::no_response());
}
}
return $parts;
}