本文整理汇总了PHP中question_classified_response::no_response方法的典型用法代码示例。如果您正苦于以下问题:PHP question_classified_response::no_response方法的具体用法?PHP question_classified_response::no_response怎么用?PHP question_classified_response::no_response使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类question_classified_response
的用法示例。
在下文中一共展示了question_classified_response::no_response方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_classify_response
public function test_classify_response()
{
$tf = test_question_maker::make_question('truefalse', 'true');
$tf->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array($tf->id => new question_classified_response(0, get_string('false', 'qtype_truefalse'), 0.0)), $tf->classify_response(array('answer' => '0')));
$this->assertEquals(array($tf->id => new question_classified_response(1, get_string('true', 'qtype_truefalse'), 1.0)), $tf->classify_response(array('answer' => '1')));
$this->assertEquals(array($tf->id => question_classified_response::no_response()), $tf->classify_response(array()));
}
示例2: classify_response
public function classify_response(array $response)
{
if (!array_key_exists('answer', $response)) {
return array($this->id => question_classified_response::no_response());
}
list($fraction) = $this->grade_response($response);
if ($response['answer']) {
return array($this->id => new question_classified_response(1, get_string('true', 'qtype_truefalse'), $fraction));
} else {
return array($this->id => new question_classified_response(0, get_string('false', 'qtype_truefalse'), $fraction));
}
}
示例3: test_classify_response_choice_added_after_attempt
public function test_classify_response_choice_added_after_attempt()
{
$match = test_question_maker::make_a_matching_question();
$firststep = new question_attempt_step();
$match->start_attempt($firststep, 1);
$response = $match->prepare_simulated_post_data(array('Dog' => 'Amphibian', 'Frog' => 'Insect', 'Toad' => '', 'Cat' => 'Mammal'));
$match = test_question_maker::make_a_matching_question();
$match->stems[5] = "Snake";
$match->stemsformat[5] = FORMAT_HTML;
$match->choices[5] = "Reptile";
$match->right[5] = 5;
$match->apply_attempt_state($firststep);
$this->assertEquals(array(1 => new question_classified_response(2, 'Amphibian', 0), 2 => new question_classified_response(3, 'Insect', 0), 3 => question_classified_response::no_response(), 4 => new question_classified_response(1, 'Mammal', 0.2)), $match->classify_response($response));
}
示例4: classify_response
public function classify_response(array $response)
{
$selectedchoicekeys = array();
foreach ($this->stemorder as $key => $stemid) {
if (array_key_exists($this->field($key), $response) && $response[$this->field($key)]) {
$selectedchoicekeys[$stemid] = $this->choiceorder[$response[$this->field($key)]];
} else {
$selectedchoicekeys[$stemid] = 0;
}
}
$parts = array();
foreach ($this->stems as $stemid => $stem) {
if ($this->right[$stemid] == 0 || !isset($selectedchoicekeys[$stemid])) {
// Choice for a deleted subquestion, ignore. (See apply_attempt_state.)
continue;
}
$selectedchoicekey = $selectedchoicekeys[$stemid];
if (empty($selectedchoicekey)) {
$parts[$stemid] = question_classified_response::no_response();
continue;
}
$choice = $this->choices[$selectedchoicekey];
if ($choice == get_string('deletedchoice', 'qtype_match')) {
// Deleted choice, ignore. (See apply_attempt_state.)
continue;
}
$parts[$stemid] = new question_classified_response($selectedchoicekey, $choice, ($selectedchoicekey == $this->right[$stemid]) / count($this->stems));
}
return $parts;
}
示例5: test_classify_response
public function test_classify_response()
{
$mc = test_question_maker::make_a_multichoice_single_question();
$mc->shuffleanswers = false;
$mc->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array($mc->id => new question_classified_response(14, 'B', -0.3333333)), $mc->classify_response(array('answer' => 1)));
$this->assertEquals(array($mc->id => question_classified_response::no_response()), $mc->classify_response(array()));
}
示例6: test_classify_response_unit
public function test_classify_response_unit()
{
$num = test_question_maker::make_question('numerical', 'unit');
$num->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array(new question_classified_response(13, '1.25', 0.5)), $num->classify_response(array('answer' => '1.25', 'unit' => '')));
$this->assertEqual(array(new question_classified_response(13, '1.25 m', 1.0)), $num->classify_response(array('answer' => '1.25', 'unit' => 'm')));
$this->assertEqual(array(new question_classified_response(13, '125 cm', 1.0)), $num->classify_response(array('answer' => '125', 'unit' => 'cm')));
$this->assertEqual(array(new question_classified_response(14, '123 cm', 0.5)), $num->classify_response(array('answer' => '123', 'unit' => 'cm')));
$this->assertEqual(array(new question_classified_response(14, '1.27 m', 0.5)), $num->classify_response(array('answer' => '1.27', 'unit' => 'm')));
$this->assertEqual(array(new question_classified_response(17, '3.0 m', 0)), $num->classify_response(array('answer' => '3.0', 'unit' => 'm')));
$this->assertEqual(array(question_classified_response::no_response()), $num->classify_response(array('answer' => '')));
}
示例7: test_classify_response
public function test_classify_response() {
$question = test_question_maker::make_question('calculated');
$question->start_attempt(new question_attempt_step(), 1);
$values = $question->vs->get_values();
$this->assertEqual(array(
new question_classified_response(13, $values['a'] + $values['b'], 1.0)),
$question->classify_response(array('answer' => $values['a'] + $values['b'])));
$this->assertEqual(array(
new question_classified_response(14, $values['a'] - $values['b'], 0.0)),
$question->classify_response(array('answer' => $values['a'] - $values['b'])));
$this->assertEqual(array(
new question_classified_response(17, 7 * $values['a'], 0.0)),
$question->classify_response(array('answer' => 7 * $values['a'])));
$this->assertEqual(array(
question_classified_response::no_response()),
$question->classify_response(array('answer' => '')));
}
示例8: test_classify_response
public function test_classify_response()
{
$dd = test_question_maker::make_question('ddmarker');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array(1 => new question_classified_response(1, 'quick', 1 / 3), 2 => new question_classified_response(2, 'fox', 1 / 3), 3 => new question_classified_response(3, 'lazy', 1 / 3)), $dd->classify_response(array('c1' => '50,50', 'c2' => '150,50', 'c3' => '100,150')));
$this->assertEquals(array(1 => new question_classified_response(1, 'quick', 1 / 3), 2 => question_classified_response::no_response(), 3 => question_classified_response::no_response()), $dd->classify_response(array('c1' => '50,50', 'c2' => '100,150', 'c3' => '150,50')));
}
示例9: test_classify_response
public function test_classify_response()
{
$dd = test_question_maker::make_question('ddimageortext');
$dd->shufflechoices = false;
$dd->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array(1 => new question_classified_response(1, '1. quick', 1), 2 => new question_classified_response(2, '2. fox', 1), 3 => new question_classified_response(3, '3. lazy', 1), 4 => new question_classified_response(4, '4. dog', 1)), $dd->classify_response(array('p1' => '1', 'p2' => '2', 'p3' => '1', 'p4' => '2')));
$this->assertEquals(array(1 => question_classified_response::no_response(), 2 => new question_classified_response(1, '1. quick', 0), 3 => new question_classified_response(4, '4. dog', 0), 4 => new question_classified_response(4, '4. dog', 1)), $dd->classify_response(array('p1' => '', 'p2' => '1', 'p3' => '2', 'p4' => '2')));
}
示例10: test_classify_response
public function test_classify_response()
{
$gapselect = qtype_gapselect_test_helper::make_a_gapselect_question();
$gapselect->shufflechoices = false;
$gapselect->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array(1 => new question_classified_response(1, 'quick', 1 / 3), 2 => new question_classified_response(2, 'dog', 0), 3 => new question_classified_response(1, 'lazy', 1 / 3)), $gapselect->classify_response(array('p1' => '1', 'p2' => '2', 'p3' => '1')));
$this->assertEquals(array(1 => question_classified_response::no_response(), 2 => new question_classified_response(1, 'fox', 1 / 3), 3 => new question_classified_response(2, 'assiduous', 0)), $gapselect->classify_response(array('p1' => '0', 'p2' => '1', 'p3' => '2')));
}
示例11: test_classify_response_unit_no_star
public function test_classify_response_unit_no_star()
{
$num = test_question_maker::make_question('numerical', 'unit');
unset($num->answers[17]);
$num->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array(new question_classified_response(0, '42 cm', 0)), $num->classify_response(array('answer' => '42', 'unit' => 'cm')));
$this->assertEquals(array(new question_classified_response(0, '3.0', 0)), $num->classify_response(array('answer' => '3.0', 'unit' => '')));
$this->assertEquals(array(new question_classified_response(0, '3.0 m', 0)), $num->classify_response(array('answer' => '3.0', 'unit' => 'm')));
$this->assertEquals(array(question_classified_response::no_response()), $num->classify_response(array('answer' => '', 'unit' => '')));
}
示例12: classify_response
public function classify_response(array $response) {
$parts = array();
$hits = $this->choose_hits($response);
foreach ($this->places as $placeno => $place) {
if (isset($hits[$placeno])) {
$shuffledchoiceno = $this->get_right_choice_for($placeno);
$choice = $this->get_selected_choice(1, $shuffledchoiceno);
$parts[$placeno] = new question_classified_response(
$choice->no,
$choice->summarise(),
1 / count($this->places));
} else {
$parts[$placeno] = question_classified_response::no_response();
}
}
return $parts;
}
示例13: classify_response
public function classify_response(array $response) {
if (empty($response['answer'])) {
return array($this->id => question_classified_response::no_response());
}
if ($this->unitdisplay == qtype_numerical::UNITSELECT) {
$selectedunit = $response['unit'];
} else {
$selectedunit = null;
}
list($value, $unit) = $this->ap->apply_units($response['answer'], $selectedunit);
$ans = $this->get_matching_answer($value);
if (!$ans) {
return array($this->id => question_classified_response::no_response());
}
$resp = $response['answer'];
if ($this->unitdisplay == qtype_numerical::UNITSELECT) {
$resp = $this->ap->add_unit($resp, $unit);
}
return array($this->id => new question_classified_response($ans->id,
$resp,
$this->apply_unit_penalty($ans->fraction, $unit)));
}
示例14: classify_response
public function classify_response(array $response)
{
if (!$this->is_gradable_response($response)) {
return array($this->id => question_classified_response::no_response());
}
if ($this->has_separate_unit_field()) {
$selectedunit = $response['unit'];
} else {
$selectedunit = null;
}
list($value, $unit, $multiplier) = $this->ap->apply_units($response['answer'], $selectedunit);
$ans = $this->get_matching_answer($value, $multiplier);
$resp = $response['answer'];
if ($this->has_separate_unit_field()) {
$resp = $this->ap->add_unit($resp, $unit);
}
if ($value === null) {
// Invalid response shown as no response (but show actual response).
return array($this->id => new question_classified_response(null, $resp, 0));
} else {
if (!$ans) {
// Does not match any answer.
return array($this->id => new question_classified_response(0, $resp, 0));
}
}
return array($this->id => new question_classified_response($ans->id, $resp, $this->apply_unit_penalty($ans->fraction, $ans->unitisright)));
}
示例15: test_classify_response_no_star
public function test_classify_response_no_star() {
$sa = test_question_maker::make_question('shortanswer', 'frogonly');
$sa->start_attempt(new question_attempt_step(), 1);
$this->assertEquals(array(
new question_classified_response(13, 'frog', 1.0)),
$sa->classify_response(array('answer' => 'frog')));
$this->assertEquals(array(
new question_classified_response(0, 'toad', 0.0)),
$sa->classify_response(array('answer' => 'toad')));
$this->assertEquals(array(
question_classified_response::no_response()),
$sa->classify_response(array('answer' => '')));
}