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


PHP lesson_page::rewrite_answers_urls方法代码示例

本文整理汇总了PHP中lesson_page::rewrite_answers_urls方法的典型用法代码示例。如果您正苦于以下问题:PHP lesson_page::rewrite_answers_urls方法的具体用法?PHP lesson_page::rewrite_answers_urls怎么用?PHP lesson_page::rewrite_answers_urls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lesson_page的用法示例。


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

示例1: display_answers

 public function display_answers(html_table $table)
 {
     $answers = $this->get_answers();
     $options = new stdClass();
     $options->noclean = true;
     $options->para = false;
     $i = 1;
     $n = 0;
     foreach ($answers as $answer) {
         $answer = parent::rewrite_answers_urls($answer);
         if ($n < 2) {
             if ($answer->answer != null) {
                 $cells = array();
                 if ($n == 0) {
                     $cells[] = "<span class=\"label\">" . get_string("correctresponse", "lesson") . '</span>';
                 } else {
                     $cells[] = "<span class=\"label\">" . get_string("wrongresponse", "lesson") . '</span>';
                 }
                 $cells[] = format_text($answer->answer, $answer->answerformat, $options);
                 $table->data[] = new html_table_row($cells);
             }
             if ($n == 0) {
                 $cells = array();
                 $cells[] = '<span class="label">' . get_string("correctanswerscore", "lesson") . "</span>: ";
                 $cells[] = $answer->score;
                 $table->data[] = new html_table_row($cells);
                 $cells = array();
                 $cells[] = '<span class="label">' . get_string("correctanswerjump", "lesson") . "</span>: ";
                 $cells[] = $this->get_jump_name($answer->jumpto);
                 $table->data[] = new html_table_row($cells);
             } elseif ($n == 1) {
                 $cells = array();
                 $cells[] = '<span class="label">' . get_string("wronganswerscore", "lesson") . "</span>: ";
                 $cells[] = $answer->score;
                 $table->data[] = new html_table_row($cells);
                 $cells = array();
                 $cells[] = '<span class="label">' . get_string("wronganswerjump", "lesson") . "</span>: ";
                 $cells[] = $this->get_jump_name($answer->jumpto);
                 $table->data[] = new html_table_row($cells);
             }
             if ($n === 0) {
                 $table->data[count($table->data) - 1]->cells[0]->style = 'width:20%;';
             }
             $n++;
             $i--;
         } else {
             $cells = array();
             if ($this->lesson->custom && $answer->score > 0) {
                 // if the score is > 0, then it is correct
                 $cells[] = '<span class="labelcorrect">' . get_string("answer", "lesson") . " {$i}</span>: \n";
             } else {
                 if ($this->lesson->custom) {
                     $cells[] = '<span class="label">' . get_string("answer", "lesson") . " {$i}</span>: \n";
                 } else {
                     if ($this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto)) {
                         $cells[] = '<span class="labelcorrect">' . get_string("answer", "lesson") . " {$i}</span>: \n";
                     } else {
                         $cells[] = '<span class="label">' . get_string("answer", "lesson") . " {$i}</span>: \n";
                     }
                 }
             }
             $cells[] = format_text($answer->answer, $answer->answerformat, $options);
             $table->data[] = new html_table_row($cells);
             $cells = array();
             $cells[] = '<span class="label">' . get_string("matchesanswer", "lesson") . " {$i}</span>: ";
             $cells[] = format_text($answer->response, $answer->responseformat, $options);
             $table->data[] = new html_table_row($cells);
         }
         $i++;
     }
     return $table;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:72,代码来源:matching.php

示例2: report_answers

 public function report_answers($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n)
 {
     global $PAGE;
     $answers = $this->get_answers();
     $formattextdefoptions = new stdClass();
     $formattextdefoptions->para = false;
     //I'll use it widely in this page
     foreach ($answers as $answer) {
         $answer = parent::rewrite_answers_urls($answer, false);
         if ($useranswer == null && $i == 0) {
             // I have the $i == 0 because it is easier to blast through it all at once.
             if (isset($pagestats[$this->properties->id])) {
                 $stats = $pagestats[$this->properties->id];
                 $total = $stats["total"];
                 unset($stats["total"]);
                 foreach ($stats as $valentered => $ntimes) {
                     $data = '<input type="text" size="50" disabled="disabled" readonly="readonly" value="' . s($valentered) . '" />';
                     $percent = $ntimes / $total * 100;
                     $percent = round($percent, 2);
                     $percent .= "% " . get_string("enteredthis", "lesson");
                     $answerdata->answers[] = array($data, $percent);
                 }
             } else {
                 $answerdata->answers[] = array(get_string("nooneansweredthisquestion", "lesson"), " ");
             }
             $i++;
         } else {
             if ($useranswer != null && ($answer->id == $useranswer->answerid || $answer == end($answers))) {
                 // get in here when what the user entered is not one of the answers
                 $data = '<input type="text" size="50" disabled="disabled" readonly="readonly" value="' . s($useranswer->useranswer) . '">';
                 if (isset($pagestats[$this->properties->id][$useranswer->useranswer])) {
                     $percent = $pagestats[$this->properties->id][$useranswer->useranswer] / $pagestats[$this->properties->id]["total"] * 100;
                     $percent = round($percent, 2);
                     $percent .= "% " . get_string("enteredthis", "lesson");
                 } else {
                     $percent = get_string("nooneenteredthis", "lesson");
                 }
                 $answerdata->answers[] = array($data, $percent);
                 if ($answer->id == $useranswer->answerid) {
                     if ($answer->response == null) {
                         if ($useranswer->correct) {
                             $answerdata->response = get_string("thatsthecorrectanswer", "lesson");
                         } else {
                             $answerdata->response = get_string("thatsthewronganswer", "lesson");
                         }
                     } else {
                         $answerdata->response = $answer->response;
                     }
                     if ($this->lesson->custom) {
                         $answerdata->score = get_string("pointsearned", "lesson") . ": " . $answer->score;
                     } elseif ($useranswer->correct) {
                         $answerdata->score = get_string("receivedcredit", "lesson");
                     } else {
                         $answerdata->score = get_string("didnotreceivecredit", "lesson");
                     }
                     // We have found the correct answer, do not process any more answers.
                     $answerpage->answerdata = $answerdata;
                     break;
                 } else {
                     $answerdata->response = get_string("thatsthewronganswer", "lesson");
                     if ($this->lesson->custom) {
                         $answerdata->score = get_string("pointsearned", "lesson") . ": 0";
                     } else {
                         $answerdata->score = get_string("didnotreceivecredit", "lesson");
                     }
                 }
             }
         }
         $answerpage->answerdata = $answerdata;
     }
     return $answerpage;
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:72,代码来源:shortanswer.php

示例3: report_answers

 public function report_answers($answerpage, $answerdata, $useranswer, $pagestats, &$i, &$n)
 {
     $answers = $this->get_answers();
     $formattextdefoptions = new stdClass();
     //I'll use it widely in this page
     $formattextdefoptions->para = false;
     $formattextdefoptions->noclean = true;
     $formattextdefoptions->context = $answerpage->context;
     foreach ($answers as $answer) {
         $answer = parent::rewrite_answers_urls($answer);
         if ($this->properties->qoption) {
             if ($useranswer == null) {
                 $userresponse = array();
             } else {
                 $userresponse = explode(",", $useranswer->useranswer);
             }
             if (in_array($answer->id, $userresponse)) {
                 // make checked
                 $data = "<input  readonly=\"readonly\" disabled=\"disabled\" name=\"answer[{$i}]\" checked=\"checked\" type=\"checkbox\" value=\"1\" />";
                 if (!isset($answerdata->response)) {
                     if ($answer->response == null) {
                         if ($useranswer->correct) {
                             $answerdata->response = get_string("thatsthecorrectanswer", "lesson");
                         } else {
                             $answerdata->response = get_string("thatsthewronganswer", "lesson");
                         }
                     } else {
                         $answerdata->response = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
                     }
                 }
                 if (!isset($answerdata->score)) {
                     if ($this->lesson->custom) {
                         $answerdata->score = get_string("pointsearned", "lesson") . ": " . $answer->score;
                     } elseif ($useranswer->correct) {
                         $answerdata->score = get_string("receivedcredit", "lesson");
                     } else {
                         $answerdata->score = get_string("didnotreceivecredit", "lesson");
                     }
                 }
             } else {
                 // unchecked
                 $data = "<input type=\"checkbox\" readonly=\"readonly\" name=\"answer[{$i}]\" value=\"0\" disabled=\"disabled\" />";
             }
             if ($answer->score > 0 && $this->lesson->custom || $this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto) && !$this->lesson->custom) {
                 $data .= "<div class=highlight>" . format_text($answer->answer, $answer->answerformat, $formattextdefoptions) . "</div>";
             } else {
                 $data .= format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
             }
         } else {
             if ($useranswer != null and $answer->id == $useranswer->answerid) {
                 // make checked
                 $data = "<input  readonly=\"readonly\" disabled=\"disabled\" name=\"answer[{$i}]\" checked=\"checked\" type=\"checkbox\" value=\"1\" />";
                 if ($answer->response == null) {
                     if ($useranswer->correct) {
                         $answerdata->response = get_string("thatsthecorrectanswer", "lesson");
                     } else {
                         $answerdata->response = get_string("thatsthewronganswer", "lesson");
                     }
                 } else {
                     $answerdata->response = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
                 }
                 if ($this->lesson->custom) {
                     $answerdata->score = get_string("pointsearned", "lesson") . ": " . $answer->score;
                 } elseif ($useranswer->correct) {
                     $answerdata->score = get_string("receivedcredit", "lesson");
                 } else {
                     $answerdata->score = get_string("didnotreceivecredit", "lesson");
                 }
             } else {
                 // unchecked
                 $data = "<input type=\"checkbox\" readonly=\"readonly\" name=\"answer[{$i}]\" value=\"0\" disabled=\"disabled\" />";
             }
             if ($answer->score > 0 && $this->lesson->custom || $this->lesson->jumpto_is_correct($this->properties->id, $answer->jumpto) && !$this->lesson->custom) {
                 $data .= "<div class=\"highlight\">" . format_text($answer->answer, $answer->answerformat, $formattextdefoptions) . "</div>";
             } else {
                 $data .= format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
             }
         }
         if (isset($pagestats[$this->properties->id][$answer->id])) {
             $percent = $pagestats[$this->properties->id][$answer->id] / $pagestats[$this->properties->id]["total"] * 100;
             $percent = round($percent, 2);
             $percent .= "% " . get_string("checkedthisone", "lesson");
         } else {
             $percent = get_string("noonecheckedthis", "lesson");
         }
         $answerdata->answers[] = array($data, $percent);
         $answerpage->answerdata = $answerdata;
     }
     return $answerpage;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:90,代码来源:truefalse.php


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