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


PHP question_usage_by_activity::get_question_attempt方法代码示例

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


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

示例1: summarize_response

 /**
  * Summarizes a response for us before the question attempt is finished
  *
  * This will get us the question's text and response without the info or other controls
  *
  * @param int $slot
  *
  */
 public function summarize_response($slot)
 {
     global $PAGE;
     $questionattempt = $this->quba->get_question_attempt($slot);
     $question = $this->quba->get_question($slot);
     $rtqQuestion = $this->get_question_by_slot($slot);
     // use the renderer to display just the question text area, but in read only mode
     // basically how the quiz module does it, but we're being much more specific in the output
     // we want.  This also is more in line with the question engine's rendering of specific questions
     // This will display the question text as well for each response, but for a v1 this is ok
     $qrenderer = $question->get_renderer($PAGE);
     $qoptions = $this->get_display_options(true);
     // get default review options, which is no feedback or anything
     $this->responsesummary = $qrenderer->formulation_and_controls($questionattempt, $qoptions);
     if ($rtqQuestion->getShowHistory()) {
         $this->responsesummary .= $this->question_attempt_history($questionattempt);
     }
     // Bad way of doing things
     // $response = $questionattempt->get_last_step()->get_qt_data();
     // $this->responsesummary = $question->summarise_response($response);
 }
开发者ID:agarnav,项目名称:moodle-mod_activequiz,代码行数:29,代码来源:activequiz_attempt.php

示例2: offlinequiz_create_pdf_question


//.........这里部分代码省略.........
            // Add page break if necessary because of overflow.
            if ($pdf->GetY() > 230) {
                $pdf->AddPage();
                $pdf->Ln(14);
            }
            set_time_limit(120);
            $question = $questions[$currentquestionid];
            /*****************************************************/
            /*  Either we print the question HTML */
            /*****************************************************/
            $pdf->checkpoint();
            $questiontext = $question->questiontext;
            // Filter only for tex formulas.
            if (!empty($texfilter)) {
                $questiontext = $texfilter->filter($questiontext);
            }
            // Remove all HTML comments (typically from MS Office).
            $questiontext = preg_replace("/<!--.*?--\\s*>/ms", "", $questiontext);
            // Remove <font> tags.
            $questiontext = preg_replace("/<font[^>]*>[^<]*<\\/font>/ms", "", $questiontext);
            // Remove <script> tags that are created by mathjax preview.
            $questiontext = preg_replace("/<script[^>]*>[^<]*<\\/script>/ms", "", $questiontext);
            // Remove all class info from paragraphs because TCPDF won't use CSS.
            $questiontext = preg_replace('/<p[^>]+class="[^"]*"[^>]*>/i', "<p>", $questiontext);
            $questiontext = $trans->fix_image_paths($questiontext, $question->contextid, 'questiontext', $question->id, 1, 300);
            $html = '';
            $html .= $questiontext . '<br/><br/>';
            if ($question->qtype == 'multichoice' || $question->qtype == 'multichoiceset') {
                // Save the usage slot in the group questions table.
                //                 $DB->set_field('offlinequiz_group_questions', 'usageslot', $slot,
                //                         array('offlinequizid' => $offlinequiz->id,
                //                                 'offlinegroupid' => $group->id, 'questionid' => $question->id));
                // There is only a slot for multichoice questions.
                $attempt = $templateusage->get_question_attempt($slot);
                $order = $slotquestion->get_order($attempt);
                // Order of the answers.
                foreach ($order as $key => $answer) {
                    $answertext = $question->options->answers[$answer]->answer;
                    // Filter only for tex formulas.
                    if (!empty($texfilter)) {
                        $answertext = $texfilter->filter($answertext);
                    }
                    // Remove all HTML comments (typically from MS Office).
                    $answertext = preg_replace("/<!--.*?--\\s*>/ms", "", $answertext);
                    // Remove all paragraph tags because they mess up the layout.
                    $answertext = preg_replace("/<p[^>]*>/ms", "", $answertext);
                    // Remove <script> tags that are created by mathjax preview.
                    $answertext = preg_replace("/<script[^>]*>[^<]*<\\/script>/ms", "", $answertext);
                    $answertext = preg_replace("/<\\/p[^>]*>/ms", "", $answertext);
                    $answertext = $trans->fix_image_paths($answertext, $question->contextid, 'answer', $answer, 1, 300);
                    if ($correction) {
                        if ($question->options->answers[$answer]->fraction > 0) {
                            $html .= '<b>';
                        }
                        $answertext .= " (" . round($question->options->answers[$answer]->fraction * 100) . "%)";
                    }
                    $html .= number_in_style($key, $question->options->answernumbering) . ') &nbsp; ';
                    $html .= $answertext;
                    if ($correction) {
                        if ($question->options->answers[$answer]->fraction > 0) {
                            $html .= '</b>';
                        }
                    }
                    $html .= "<br/>\n";
                }
                if ($offlinequiz->showgrades) {
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:67,代码来源:pdflib.php

示例3: get_question_attempt

 protected function get_question_attempt()
 {
     return $this->quba->get_question_attempt($this->slot);
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:4,代码来源:helpers.php

示例4: offlinequiz_create_latex_question

/**
 * Generates the LaTeX question form for an offlinequiz group.
 *
 * @param question_usage_by_activity $templateusage the template question  usage for this offline group
 * @param object $offlinequiz The offlinequiz object
 * @param object $group the offline group object
 * @param int $courseid the ID of the Moodle course
 * @param object $context the context of the offline quiz.
 * @param boolean correction if true the correction form is generated.
 * @return stored_file instance, the generated PDF file.
 */
function offlinequiz_create_latex_question(question_usage_by_activity $templateusage, $offlinequiz, $group, $courseid, $context, $correction = false)
{
    global $CFG, $DB, $OUTPUT;
    $letterstr = 'abcdefghijklmnopqrstuvwxyz';
    $groupletter = strtoupper($letterstr[$group->number - 1]);
    $coursecontext = context_course::instance($courseid);
    $course = $DB->get_record('course', array('id' => $courseid));
    $title = format_text($offlinequiz->name, FORMAT_HTML);
    $title .= ",  " . get_string('group') . $groupletter;
    // Load all the questions needed for this offline quiz group.
    $sql = "SELECT q.*, c.contextid, ogq.page, ogq.slot, ogq.maxmark\n              FROM {offlinequiz_group_questions} ogq,\n                   {question} q,\n                   {question_categories} c\n             WHERE ogq.offlinequizid = :offlinequizid\n               AND ogq.offlinegroupid = :offlinegroupid\n               AND q.id = ogq.questionid\n               AND q.category = c.id\n          ORDER BY ogq.slot ASC ";
    $params = array('offlinequizid' => $offlinequiz->id, 'offlinegroupid' => $group->id);
    // Load the questions.
    $questions = $DB->get_records_sql($sql, $params);
    if (!$questions) {
        echo $OUTPUT->box_start();
        echo $OUTPUT->error_text(get_string('noquestionsfound', 'offlinequiz', $groupletter));
        echo $OUTPUT->box_end();
        return;
    }
    // Load the question type specific information.
    if (!get_question_options($questions)) {
        print_error('Could not load question options');
    }
    $number = 1;
    // We need a mapping from question IDs to slots, assuming that each question occurs only once.
    $slots = $templateusage->get_slots();
    $latexforquestions = '\\begin{enumerate}' . "\n";
    // If shufflequestions has been activated we go through the questions in the order determined by
    // the template question usage.
    if ($offlinequiz->shufflequestions) {
        foreach ($slots as $slot) {
            $slotquestion = $templateusage->get_question($slot);
            $currentquestionid = $slotquestion->id;
            $question = $questions[$currentquestionid];
            $questiontext = offlinequiz_convert_html_to_latex($question->questiontext);
            $latexforquestions .= '\\item ' . $questiontext . "\n";
            if ($question->qtype == 'multichoice' || $question->qtype == 'multichoiceset') {
                // There is only a slot for multichoice questions.
                $attempt = $templateusage->get_question_attempt($slot);
                $order = $slotquestion->get_order($attempt);
                // Order of the answers.
                $latexforquestions .= '\\begin{enumerate}' . " \n";
                foreach ($order as $key => $answer) {
                    $latexforquestions .= offlinequiz_get_answer_latex($question, $answer);
                }
                $latexforquestions .= '\\end{enumerate}' . "\n";
                $infostr = offlinequiz_get_question_infostring($offlinequiz, $question);
                if ($infostr) {
                    $latexforquestions .= $infostr . "\n";
                }
            }
        }
        $latexforquestions .= '\\end{enumerate}' . "\n";
    } else {
        // No shufflequestions, so go through the questions as they have been added to the offlinequiz group.
        // We also have to show description questions that are not in the template.
        // First, compute mapping  questionid -> slotnumber.
        $questionslots = array();
        foreach ($slots as $slot) {
            $questionslots[$templateusage->get_question($slot)->id] = $slot;
        }
        foreach ($questions as $question) {
            $currentquestionid = $question->id;
            $questiontext = $question->questiontext;
            $questiontext = offlinequiz_convert_html_to_latex($question->questiontext);
            if ($question->qtype == 'description') {
                $latexforquestions .= "\n" . '\\ ' . $questiontext . "\n";
            } else {
                $latexforquestions .= '\\item ' . $questiontext . "\n";
            }
            if ($question->qtype == 'multichoice' || $question->qtype == 'multichoiceset') {
                $slot = $questionslots[$currentquestionid];
                // There is only a slot for multichoice questions.
                $slotquestion = $templateusage->get_question($slot);
                $attempt = $templateusage->get_question_attempt($slot);
                $order = $slotquestion->get_order($attempt);
                // Order of the answers.
                $latexforquestions .= '\\begin{enumerate}' . " \n";
                foreach ($order as $key => $answer) {
                    $latexforquestions .= offlinequiz_get_answer_latex($question, $answer);
                }
                $latexforquestions .= '\\end{enumerate}' . "\n";
                $infostr = offlinequiz_get_question_infostring($offlinequiz, $question);
                if ($infostr) {
                    $latexforquestions .= $infostr . "\n";
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:pauloangelo,项目名称:moodle-mod_offlinequiz,代码行数:101,代码来源:latexlib.php

示例5: offlinequiz_create_docx_question


//.........这里部分代码省略.........
    // If shufflequestions has been activated we go through the questions in the order determined by
    // the template question usage.
    if ($offlinequiz->shufflequestions) {
        foreach ($slots as $slot) {
            $slotquestion = $templateusage->get_question($slot);
            $myquestion = $slotquestion->id;
            set_time_limit(120);
            $question = $questions[$myquestion];
            // Either we print the question HTML.
            $questiontext = $question->questiontext;
            // Filter only for tex formulas.
            if (!empty($texfilter)) {
                $questiontext = $texfilter->filter($questiontext);
            }
            // Remove all HTML comments (typically from MS Office).
            $questiontext = preg_replace("/<!--.*?--\\s*>/ms", "", $questiontext);
            // Remove <font> tags.
            $questiontext = preg_replace("/<font[^>]*>[^<]*<\\/font>/ms", "", $questiontext);
            // Remove <script> tags that are created by mathjax preview.
            $questiontext = preg_replace("/<script[^>]*>[^<]*<\\/script>/ms", "", $questiontext);
            // Remove all class info from paragraphs because TCDOCX won't use CSS.
            $questiontext = preg_replace('/<p[^>]+class="[^"]*"[^>]*>/i', "<p>", $questiontext);
            $questiontext = $trans->fix_image_paths($questiontext, $question->contextid, 'questiontext', $question->id, 0.6, 300, 'docx');
            $blocks = offlinequiz_convert_image_docx($questiontext);
            offlinequiz_print_blocks_docx($section, $blocks, $questionnumbering, 0);
            $answernumbering = new PHPWord_Numbering_AbstractNumbering("Adv Multi-level", array(new PHPWord_Numbering_Level("1", PHPWord_Numbering_Level::NUMFMT_DECIMAL, "%1.", "left", $level1, $boldfont), new PHPWord_Numbering_Level("1", PHPWord_Numbering_Level::NUMFMT_LOWER_LETTER, "%2)", "left", $level2, $normalfont)));
            $docx->addNumbering($answernumbering);
            if ($question->qtype == 'multichoice' || $question->qtype == 'multichoiceset') {
                // Save the usage slot in the group questions table.
                //                 $DB->set_field('offlinequiz_group_questions', 'usageslot', $slot,
                //                         array('offlinequizid' => $offlinequiz->id,
                //                                 'offlinegroupid' => $group->id, 'questionid' => $question->id));
                // There is only a slot for multichoice questions.
                $attempt = $templateusage->get_question_attempt($slot);
                $order = $slotquestion->get_order($attempt);
                // Order of the answers.
                foreach ($order as $key => $answer) {
                    $answertext = $question->options->answers[$answer]->answer;
                    // Filter only for tex formulas.
                    if (!empty($texfilter)) {
                        $answertext = $texfilter->filter($answertext);
                    }
                    // Remove all HTML comments (typically from MS Office).
                    $answertext = preg_replace("/<!--.*?--\\s*>/ms", "", $answertext);
                    // Remove all paragraph tags because they mess up the layout.
                    $answertext = preg_replace("/<p[^>]*>/ms", "", $answertext);
                    // Remove <script> tags that are created by mathjax preview.
                    $answertext = preg_replace("/<script[^>]*>[^<]*<\\/script>/ms", "", $answertext);
                    $answertext = preg_replace("/<\\/p[^>]*>/ms", "", $answertext);
                    $answertext = $trans->fix_image_paths($answertext, $question->contextid, 'answer', $answer, 0.6, 200, 'docx');
                    $blocks = offlinequiz_convert_image_docx($answertext);
                    offlinequiz_print_blocks_docx($section, $blocks, $answernumbering, 1);
                }
                if ($offlinequiz->showgrades) {
                    $pointstr = get_string('points', 'grades');
                    if ($question->maxgrade == 1) {
                        $pointstr = get_string('point', 'offlinequiz');
                    }
                    // Indent the question grade like the answers.
                    $textrun = $section->createTextRun($level2);
                    $textrun->addText('(' . ($question->maxgrade + 0) . ' ' . $pointstr . ')', 'bStyle');
                }
            }
            $section->addTextBreak();
            $number++;
        }
开发者ID:frankkoch,项目名称:moodle-mod_offlinequiz,代码行数:67,代码来源:docxlib.php


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