本文整理汇总了PHP中question_classified_response类的典型用法代码示例。如果您正苦于以下问题:PHP question_classified_response类的具体用法?PHP question_classified_response怎么用?PHP question_classified_response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了question_classified_response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()));
}
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:question_test.php
示例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));
}
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:12,代码来源:question.php
示例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));
}
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:question_test.php
示例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;
}
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:question.php
示例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()));
}
开发者ID:vinoth4891,项目名称:clinique,代码行数:8,代码来源:question_test.php
示例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' => '')));
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:12,代码来源:testquestion.php
示例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' => '')));
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:18,代码来源:testquestion.php
示例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')));
}
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:8,代码来源:question_test.php
示例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')));
}
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:question_test.php
示例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')));
}
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:question_test.php
示例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' => '')));
}
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:10,代码来源:question_test.php
示例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;
}
开发者ID:nitinnagaraja,项目名称:moodle,代码行数:17,代码来源:question.php
示例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)));
}
开发者ID:nottmoo,项目名称:moodle,代码行数:25,代码来源:question.php
示例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)));
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:27,代码来源:question.php
示例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' => '')));
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:14,代码来源:question_test.php
示例16: test_classify_response
public function test_classify_response()
{
$sa = test_regexp_question_maker::make_a_regexp_question();
$sa->start_attempt(new question_attempt_step(), 1);
$this->assertEqual(array(new question_classified_response(13, "it's blue, white and red", 1.0)), $sa->classify_response(array('answer' => "it's blue, white and red")));
$this->assertEqual(array(new question_classified_response(14, 'they are blue, white, red', 0.8)), $sa->classify_response(array('answer' => 'they are blue, white, red')));
$this->assertEqual(array(new question_classified_response(14, 'it is blue, white, red', 0.8)), $sa->classify_response(array('answer' => 'it is blue, white, red')));
$this->assertEqual(array(new question_classified_response(14, 'blue, white, red', 0.8)), $sa->classify_response(array('answer' => 'blue, white, red')));
$this->assertEqual(array(new question_classified_response(15, 'red and white', 0.0)), $sa->classify_response(array('answer' => 'red and white')));
$this->assertEqual(array(new question_classified_response(15, 'black', 0.0)), $sa->classify_response(array('answer' => 'black')));
$this->assertEqual(array(question_classified_response::no_response()), $sa->classify_response(array('answer' => '')));
}
开发者ID:rezeau,项目名称:moodle-qtype_regexp,代码行数:12,代码来源:testquestion.php
示例17: add_data_from_one_attempt
/**
* Analyse the data from one question attempt.
* @param question_attempt $qa the data to analyse.
*/
protected function add_data_from_one_attempt(question_attempt $qa)
{
$blankresponse = question_classified_response::no_response();
$partresponses = $qa->classify_response();
foreach ($partresponses as $subpartid => $partresponse) {
if (!isset($this->responses[$subpartid][$partresponse->responseclassid][$partresponse->response])) {
$resp = new stdClass();
$resp->count = 0;
if (!is_null($partresponse->fraction)) {
$resp->fraction = $partresponse->fraction;
} else {
$resp->fraction = $this->responseclasses[$subpartid][$partresponse->responseclassid]->fraction;
}
$this->responses[$subpartid][$partresponse->responseclassid][$partresponse->response] = $resp;
}
$this->responses[$subpartid][$partresponse->responseclassid][$partresponse->response]->count += 1;
}
}
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:22,代码来源:responseanalysis.php
示例18: classify_response
public function classify_response(array $response)
{
$classification = array();
foreach ($this->prts as $index => $prt) {
if (!$this->can_execute_prt($prt, $response, true)) {
foreach ($prt->get_nodes_summary() as $nodeid => $choices) {
$classification[$index . '-' . $nodeid] = question_classified_response::no_response();
}
continue;
}
$prtinput = $this->get_prt_input($index, $response, true);
$results = $this->prts[$index]->evaluate_response($this->session, $this->options, $prtinput, $this->seed);
$answernotes = implode(' | ', $results->answernotes);
foreach ($prt->get_nodes_summary() as $nodeid => $choices) {
if (in_array($choices->truenote, $results->answernotes)) {
$classification[$index . '-' . $nodeid] = new question_classified_response($choices->truenote, $answernotes, $results->fraction);
} else {
if (in_array($choices->falsenote, $results->answernotes)) {
$classification[$index . '-' . $nodeid] = new question_classified_response($choices->falsenote, $answernotes, $results->fraction);
} else {
$classification[$index . '-' . $nodeid] = question_classified_response::no_response();
}
}
}
}
return $classification;
}
开发者ID:sowirepo,项目名称:moodle-qtype_stack,代码行数:27,代码来源:question.php
示例19: classify_response
public function classify_response(array $response)
{
$selectedchoices = array();
foreach ($this->stemorder as $key => $stemid) {
if (array_key_exists($this->field($key), $response) && $response[$this->field($key)]) {
$selectedchoices[$stemid] = $this->choiceorder[$response[$this->field($key)]];
} else {
$selectedchoices[$stemid] = 0;
}
}
$parts = array();
foreach ($this->stems as $stemid => $stem) {
if (empty($selectedchoices[$stemid])) {
$parts[$stemid] = question_classified_response::no_response();
continue;
}
$choice = $this->choices[$selectedchoices[$stemid]];
$parts[$stemid] = new question_classified_response($selectedchoices[$stemid], $choice, ($selectedchoices[$stemid] == $this->right[$stemid]) / count($this->stems));
}
return $parts;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:21,代码来源:question.php
示例20: classify_response
public function classify_response(array $response)
{
$parts = array();
foreach ($this->places as $placeno => $place) {
$group = $place->group;
if (!array_key_exists($this->field($placeno), $response) || !$response[$this->field($placeno)]) {
$parts[$placeno] = question_classified_response::no_response();
continue;
}
$fieldname = $this->field($placeno);
$choiceno = $this->choiceorder[$group][$response[$fieldname]];
$choice = $this->choices[$group][$choiceno];
$correct = $this->get_right_choice_for($placeno) == $response[$fieldname];
$parts[$placeno] = new question_classified_response($choiceno, $choice->summarise(), $correct ? 1 : 0);
}
return $parts;
}
开发者ID:ndunand,项目名称:moodle-qtype_ddimageortext,代码行数:17,代码来源:questionbase.php
注:本文中的question_classified_response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论