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


PHP question_get_feedback_class函数代码示例

本文整理汇总了PHP中question_get_feedback_class函数的典型用法代码示例。如果您正苦于以下问题:PHP question_get_feedback_class函数的具体用法?PHP question_get_feedback_class怎么用?PHP question_get_feedback_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: print_question_formulation_and_controls

 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG;
     /// This implementation is also used by question type 'numerical'
     $readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
     $formatoptions = new stdClass();
     $formatoptions->noclean = true;
     $formatoptions->para = false;
     $nameprefix = $question->name_prefix;
     /// Print question text and media
     $questiontext = format_text($question->questiontext, $question->questiontextformat, $formatoptions, $cmoptions->course);
     $image = get_question_image($question);
     $this->compute_feedbackperconditions($question, $state);
     /// Print input controls
     $values = array();
     $params = explode(",", $question->options->parameters);
     foreach ($params as &$param) {
         $param = trim($param);
         $paramparts = explode(" ", $param);
         $paramname = trim($paramparts[0]);
         $paramunity = trim($paramparts[1]);
         if (isset($state->responses[$paramname]) && $state->responses[$paramname] != '') {
             $value[$paramname] = ' value="' . s($state->responses[$paramname], true) . '" ';
         } else {
             $value[$paramname] = ' value="" ';
         }
         $inputname[$paramname] = ' name="' . $nameprefix . $paramname . '" ';
     }
     $feedback = '';
     $class = '';
     $feedbackimg = '';
     $feedbackperconditions = '';
     if ($options->feedback) {
         $class = question_get_feedback_class($state->raw_grade);
         $feedbackimg = question_get_feedback_image($state->raw_grade);
         $feedbackperconditions = $question->options->computedfeedbackperconditions;
     }
     include "{$CFG->dirroot}/question/type/multinumerical/display.html";
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:39,代码来源:questiontype.php

示例2: print_question_grading_details

 /**
  * Prints the score obtained and maximum score available plus any penalty
  * information
  *
  * This function prints a summary of the scoring in the most recently
  * graded state (the question may not have been submitted for marking at
  * the current state). The default implementation should be suitable for most
  * question types.
  * @param object $question The question for which the grading details are
  *                         to be rendered. Question type specific information
  *                         is included. The maximum possible grade is in
  *                         ->maxgrade.
  * @param object $state    The state. In particular the grading information
  *                          is in ->grade, ->raw_grade and ->penalty.
  * @param object $cmoptions
  * @param object $options  An object describing the rendering options.
  */
 function print_question_grading_details(&$question, &$state, $cmoptions, $options)
 {
     /* The default implementation prints the number of marks if no attempt
        has been made. Otherwise it displays the grade obtained out of the
        maximum grade available and a warning if a penalty was applied for the
        attempt and displays the overall grade obtained counting all previous
        responses (and penalties) */
     global $QTYPES;
     // MDL-7496 show correct answer after "Incorrect"
     $correctanswer = '';
     if ($correctanswers = $QTYPES[$question->qtype]->get_correct_responses($question, $state)) {
         if ($options->readonly && $options->correct_responses) {
             $delimiter = '';
             if ($correctanswers) {
                 foreach ($correctanswers as $ca) {
                     $correctanswer .= $delimiter . $ca;
                     $delimiter = ', ';
                 }
             }
         }
     }
     if (QUESTION_EVENTDUPLICATE == $state->event) {
         echo ' ';
         print_string('duplicateresponse', 'quiz');
     }
     if ($question->maxgrade > 0 && $options->scores) {
         if (question_state_is_graded($state->last_graded)) {
             // Display the grading details from the last graded state
             $grade = new stdClass();
             $grade->cur = question_format_grade($cmoptions, $state->last_graded->grade);
             $grade->max = question_format_grade($cmoptions, $question->maxgrade);
             $grade->raw = question_format_grade($cmoptions, $state->last_graded->raw_grade);
             // let student know wether the answer was correct
             $class = question_get_feedback_class($state->last_graded->raw_grade / $question->maxgrade);
             echo '<div class="correctness ' . $class . '">' . get_string($class, 'quiz');
             if ($correctanswer != '' && ($class == 'partiallycorrect' || $class == 'incorrect')) {
                 echo '<div class="correctness">';
                 print_string('correctansweris', 'quiz', s($correctanswer));
                 echo '</div>';
             }
             echo '</div>';
             echo '<div class="gradingdetails">';
             // print grade for this submission
             print_string('gradingdetails', 'quiz', $grade);
             // A unit penalty for numerical was applied so display it
             // a temporary solution for unit rendering in numerical
             // waiting for the new question engine code for a permanent one
             if (isset($state->options->raw_unitpenalty) && $state->options->raw_unitpenalty > 0.0) {
                 echo ' ';
                 print_string('unitappliedpenalty', 'qtype_numerical', question_format_grade($cmoptions, $state->options->raw_unitpenalty));
             }
             if ($cmoptions->penaltyscheme) {
                 // print details of grade adjustment due to penalties
                 if ($state->last_graded->raw_grade > $state->last_graded->grade) {
                     echo ' ';
                     print_string('gradingdetailsadjustment', 'quiz', $grade);
                 }
                 // print info about new penalty
                 // penalty is relevant only if the answer is not correct and further attempts are possible
                 if ($state->last_graded->raw_grade < $question->maxgrade and QUESTION_EVENTCLOSEANDGRADE != $state->event) {
                     if ('' !== $state->last_graded->penalty && (double) $state->last_graded->penalty > 0.0) {
                         echo ' ';
                         print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $state->last_graded->penalty));
                     } else {
                         /* No penalty was applied even though the answer was
                            not correct (eg. a syntax error) so tell the student
                            that they were not penalised for the attempt */
                         echo ' ';
                         print_string('gradingdetailszeropenalty', 'quiz');
                     }
                 }
             }
             echo '</div>';
         }
     }
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:93,代码来源:questiontype.php

示例3: print_question_formulation_and_controls

 /**
  * @desc Prints the question. Calls question_webwork_derived, and prints out the html associated with derivedid.
  * @param $question object The question object to print.
  * @param $state object The state of the responses for the question.
  * @param $cmoptions object Options containing course ID.
  * @param $options object
  */
 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG, $USER;
     $readonly = empty($options->readonly) ? '' : 'disabled="disabled"';
     //Formulate question image and text
     $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
     $image = get_question_image($question, $cmoptions->course);
     $derivationid = $state->responses['derivationid'];
     $derivation = get_record('question_webwork_derived', 'id', $derivationid);
     $unparsedhtml = base64_decode($derivation->html);
     //partial answers
     $showPartiallyCorrectAnswers = $question->grading;
     //new array keyed by field
     $fieldhash = $state->responses['answers'];
     $answerfields = array();
     $parser = new HtmlParser($unparsedhtml);
     $currentselect = "";
     while ($parser->parse()) {
         //change some attributes of html tags for moodle compliance
         if ($parser->iNodeType == NODE_TYPE_ELEMENT) {
             $nodename = $parser->iNodeName;
             $name = $parser->iNodeAttributes['name'];
             //handle generic change of node's attribute name
             if ($nodename == "INPUT" || $nodename == "SELECT" || $nodename == "TEXTAREA") {
                 $parser->iNodeAttributes['name'] = 'resp' . $question->id . '_' . $name;
                 if ($state->event == QUESTION_EVENTGRADE && isset($fieldhash[$name])) {
                     if ($showPartiallyCorrectAnswers) {
                         $parser->iNodeAttributes['class'] = $parser->iNodeAttributes['class'] . ' ' . question_get_feedback_class($fieldhash[$name]['score']);
                     }
                 }
                 if (!strstr($name, 'previous')) {
                     $answerfields[$name] = $fieldhash[$name];
                 }
             }
             //handle specific change
             if ($nodename == "INPUT") {
                 //put submitted value into field
                 if (isset($fieldhash[$name])) {
                     $parser->iNodeAttributes['value'] = $fieldhash[$name]['answer'];
                 }
             } else {
                 if ($nodename == "SELECT") {
                     $currentselect = $name;
                 } else {
                     if ($nodename == "OPTION") {
                         if ($parser->iNodeAttributes['value'] == $fieldhash[$currentselect]['answer']) {
                             $parser->iNodeAttributes['selected'] = '1';
                         }
                     } else {
                         if ($nodename == "TEXTAREA") {
                         }
                     }
                 }
             }
         }
         $problemhtml .= $parser->printTag();
     }
     //for the seed form field
     $qid = $question->id;
     $seed = $state->responses['seed'];
     //if the student has answered
     include "{$CFG->dirroot}/question/type/webwork/display.html";
 }
开发者ID:bjornbe,项目名称:wwassignment,代码行数:70,代码来源:questiontype.php

示例4: print_question_formulation_and_controls


//.........这里部分代码省略.........
                            $testedstate->responses[''] = $response;
                            foreach ($answers as $answer) {
                                if ($QTYPES[$wrapped->qtype]->test_response($wrapped, $testedstate, $answer)) {
                                    $chosenanswer = clone $answer;
                                    break;
                                }
                            }
                            break;
                        case 'multichoice':
                            if (isset($answers[$response])) {
                                $chosenanswer = clone $answers[$response];
                            }
                            break;
                        default:
                            break;
                    }
                    // Set up a default chosenanswer so that all non-empty wrong
                    // answers are highlighted red
                    if (empty($chosenanswer) && $response != '') {
                        $chosenanswer = new stdClass();
                        $chosenanswer->fraction = 0.0;
                    }
                    if (!empty($chosenanswer->feedback)) {
                        $feedback = s(str_replace(array("\\", "'"), array("\\\\", "\\'"), $feedback . $chosenanswer->feedback));
                        if ($options->readonly && $options->correct_responses) {
                            $strfeedbackwrapped = get_string('correctanswerandfeedback', 'qtype_multianswer');
                        } else {
                            $strfeedbackwrapped = get_string('feedback', 'quiz');
                        }
                        $popup = " onmouseover=\"return overlib('{$feedback}', STICKY, MOUSEOFF, CAPTION, '{$strfeedbackwrapped}', FGCOLOR, '#FFFFFF');\" " . " onmouseout=\"return nd();\" ";
                    }
                    /// Determine style
                    if ($options->feedback && $response != '') {
                        $style = 'class = "' . question_get_feedback_class($chosenanswer->fraction) . '"';
                        $feedbackimg = question_get_feedback_image($chosenanswer->fraction);
                    } else {
                        $style = '';
                        $feedbackimg = '';
                    }
                }
                if ($feedback != '' && $popup == '') {
                    $strfeedbackwrapped = get_string('correctanswer', 'qtype_multianswer');
                    $feedback = s(str_replace(array("\\", "'"), array("\\\\", "\\'"), $feedback));
                    $popup = " onmouseover=\"return overlib('{$feedback}', STICKY, MOUSEOFF, CAPTION, '{$strfeedbackwrapped}', FGCOLOR, '#FFFFFF');\" " . " onmouseout=\"return nd();\" ";
                }
                // Print the input control
                switch ($wrapped->qtype) {
                    case 'shortanswer':
                    case 'numerical':
                        $size = 1;
                        foreach ($answers as $answer) {
                            if (strlen(trim($answer->answer)) > $size) {
                                $size = strlen(trim($answer->answer));
                            }
                        }
                        if (strlen(trim($response)) > $size) {
                            $size = strlen(trim($response)) + 1;
                        }
                        $size = $size + rand(0, $size * 0.15);
                        $size > 60 ? $size = 60 : ($size = $size);
                        $styleinfo = "size=\"{$size}\"";
                        /**
                         * Uncomment the following lines if you want to limit for small sizes.
                         * Results may vary with browsers see MDL-3274
                         */
                        /*
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:67,代码来源:questiontype.php

示例5: print_question_formulation_and_controls

 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG, $OUTPUT;
     $context = $this->get_context_by_category_id($question->category);
     $subquestions = $state->options->subquestions;
     $correctanswers = $this->get_correct_responses($question, $state);
     $nameprefix = $question->name_prefix;
     $answers = array();
     // Answer choices formatted ready for output.
     $allanswers = array();
     // This and the next used to detect identical answers
     $answerids = array();
     // and adjust ids.
     $responses =& $state->responses;
     // Prepare a list of answers, removing duplicates.
     foreach ($subquestions as $subquestion) {
         foreach ($subquestion->options->answers as $ans) {
             $allanswers[$ans->id] = $ans->answer;
             if (!in_array($ans->answer, $answers)) {
                 $answers[$ans->id] = strip_tags(format_string($ans->answer, false));
                 $answerids[$ans->answer] = $ans->id;
             }
         }
     }
     // Fix up the ids of any responses that point the the eliminated duplicates.
     foreach ($responses as $subquestionid => $ignored) {
         if ($responses[$subquestionid]) {
             $responses[$subquestionid] = $answerids[$allanswers[$responses[$subquestionid]]];
         }
     }
     foreach ($correctanswers as $subquestionid => $ignored) {
         $correctanswers[$subquestionid] = $answerids[$allanswers[$correctanswers[$subquestionid]]];
     }
     // Shuffle the answers
     $answers = draw_rand_array($answers, count($answers));
     // Print formulation
     $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
     // Print the input controls
     foreach ($subquestions as $key => $subquestion) {
         if ($subquestion->questiontext !== '' && !is_null($subquestion->questiontext)) {
             // Subquestion text:
             $a = new stdClass();
             $text = $this->format_subquestion_text($subquestion, $state, $context);
             $a->text = $this->format_text($text, $subquestion->questiontextformat, $cmoptions);
             // Drop-down list:
             $menuname = $nameprefix . $subquestion->id;
             $response = isset($state->responses[$subquestion->id]) ? $state->responses[$subquestion->id] : '0';
             $a->class = ' ';
             $a->feedbackimg = ' ';
             if ($options->readonly and $options->correct_responses) {
                 if (isset($correctanswers[$subquestion->id]) and $correctanswers[$subquestion->id] == $response) {
                     $correctresponse = 1;
                 } else {
                     $correctresponse = 0;
                 }
                 if ($options->feedback && $response) {
                     $a->class = question_get_feedback_class($correctresponse);
                     $a->feedbackimg = question_get_feedback_image($correctresponse);
                 }
             }
             $attributes = array();
             $attributes['disabled'] = $options->readonly ? 'disabled' : null;
             $a->control = html_writer::select($answers, $menuname, $response, array('' => 'choosedots'), $attributes);
             // Neither the editing interface or the database allow to provide
             // fedback for this question type.
             // However (as was pointed out in bug bug 3294) the randomsamatch
             // type which reuses this method can have feedback defined for
             // the wrapped shortanswer questions.
             //if ($options->feedback
             // && !empty($subquestion->options->answers[$responses[$key]]->feedback)) {
             //    print_comment($subquestion->options->answers[$responses[$key]]->feedback);
             //}
             $anss[] = $a;
         }
     }
     include "{$CFG->dirroot}/question/type/match/display.html";
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:77,代码来源:questiontype.php

示例6: print_question_grading_details

 /**
  * Prints the score obtained and maximum score available plus any penalty
  * information
  *
  * This function prints a summary of the scoring in the most recently
  * graded state (the question may not have been submitted for marking at
  * the current state). The default implementation should be suitable for most
  * question types.
  * @param object $question The question for which the grading details are
  *                         to be rendered. Question type specific information
  *                         is included. The maximum possible grade is in
  *                         ->maxgrade.
  * @param object $state    The state. In particular the grading information
  *                          is in ->grade, ->raw_grade and ->penalty.
  * @param object $cmoptions
  * @param object $options  An object describing the rendering options.
  */
 function print_question_grading_details(&$question, &$state, $cmoptions, $options)
 {
     /* The default implementation prints the number of marks if no attempt
        has been made. Otherwise it displays the grade obtained out of the
        maximum grade available and a warning if a penalty was applied for the
        attempt and displays the overall grade obtained counting all previous
        responses (and penalties) */
     if (QUESTION_EVENTDUPLICATE == $state->event) {
         echo ' ';
         print_string('duplicateresponse', 'quiz');
     }
     if ($question->maxgrade > 0 && $options->scores) {
         if (question_state_is_graded($state->last_graded)) {
             // Display the grading details from the last graded state
             $grade = new stdClass();
             $grade->cur = question_format_grade($cmoptions, $state->last_graded->grade);
             $grade->max = question_format_grade($cmoptions, $question->maxgrade);
             $grade->raw = question_format_grade($cmoptions, $state->last_graded->raw_grade);
             // let student know wether the answer was correct
             $class = question_get_feedback_class($state->last_graded->raw_grade / $question->maxgrade);
             echo '<div class="correctness ' . $class . '">' . get_string($class, 'quiz') . '</div>';
             echo '<div class="gradingdetails">';
             // print grade for this submission
             print_string('gradingdetails', 'quiz', $grade);
             if ($cmoptions->penaltyscheme) {
                 // print details of grade adjustment due to penalties
                 if ($state->last_graded->raw_grade > $state->last_graded->grade) {
                     echo ' ';
                     print_string('gradingdetailsadjustment', 'quiz', $grade);
                 }
                 // print info about new penalty
                 // penalty is relevant only if the answer is not correct and further attempts are possible
                 if ($state->last_graded->raw_grade < $question->maxgrade / 1.01 and QUESTION_EVENTCLOSEANDGRADE != $state->event) {
                     if ('' !== $state->last_graded->penalty && (double) $state->last_graded->penalty > 0.0) {
                         // A penalty was applied so display it
                         echo ' ';
                         print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $state->last_graded->penalty));
                     } else {
                         /* No penalty was applied even though the answer was
                            not correct (eg. a syntax error) so tell the student
                            that they were not penalised for the attempt */
                         echo ' ';
                         print_string('gradingdetailszeropenalty', 'quiz');
                     }
                 }
             }
             echo '</div>';
         }
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:67,代码来源:questiontype.php

示例7: render_cell

 public function render_cell($x, $y, $readonly = false, $showcorrect = false)
 {
     $base = $this->render_cell_base($x, $y, $readonly);
     if (empty($showcorrect)) {
         return $base;
     }
     $class = '';
     $hasanswer = $this->has_answer($this->responses, $x, $y);
     $weight = array_key_exists($x, $this->weights) && array_key_exists($y, $this->weights[$x]) ? $this->weights[$x][$y] : 0;
     if ($hasanswer && $weight > 0) {
         $class = question_get_feedback_class(1);
     } else {
         if ($hasanswer && $weight < 0) {
             $class = question_get_feedback_class(0);
         } else {
             if (!$hasanswer && $weight > 0) {
                 $class = question_get_feedback_class(0);
             }
         }
     }
     $weighttext = $weight ? '<span class="smalltext ' . $class . '">(' . $weight * 100 . '%)</span>' : '';
     return $base . $weighttext;
 }
开发者ID:sunilwebaccess,项目名称:moodle-question-matrix.1-9,代码行数:23,代码来源:questiontype.php

示例8: other_cols

 /**
  * @param string $colname the name of the column.
  * @param object $attempt the row of data - see the SQL in display() in
  * mod/quiz/report/overview/report.php to see what fields are present,
  * and what they are called.
  * @return string the contents of the cell.
  */
 function other_cols($colname, $attempt)
 {
     global $OUTPUT;
     if (preg_match('/^qsgrade([0-9]+)$/', $colname, $matches)) {
         $questionid = $matches[1];
         $question = $this->questions[$questionid];
         if (isset($this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid])) {
             $stateforqinattempt = $this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
         } else {
             $stateforqinattempt = false;
         }
         if ($stateforqinattempt && question_state_is_graded($stateforqinattempt)) {
             $grade = quiz_rescale_grade($stateforqinattempt->grade, $this->quiz, 'question');
             if (!$this->is_downloading()) {
                 if (isset($this->regradedqs[$attempt->attemptuniqueid][$questionid])) {
                     $gradefromdb = $grade;
                     $newgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->newgrade, $this->quiz, 'question');
                     $oldgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->oldgrade, $this->quiz, 'question');
                     $grade = '<del>' . $oldgrade . '</del><br />' . $newgrade;
                 }
                 $link = new moodle_url("/mod/quiz/reviewquestion.php?attempt={$attempt->attempt}&question={$question->id}");
                 $action = new popup_action('click', $link, 'reviewquestion', array('height' => 450, 'width' => 650));
                 $linktopopup = $OUTPUT->action_link($link, $grade, $action, array('title' => get_string('reviewresponsetoq', 'quiz', $question->formattedname)));
                 if ($this->questions[$questionid]->maxgrade != 0) {
                     $fractionofgrade = $stateforqinattempt->grade / $this->questions[$questionid]->maxgrade;
                     $qclass = question_get_feedback_class($fractionofgrade);
                     $feedbackimg = question_get_feedback_image($fractionofgrade);
                     $questionclass = "que";
                     return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $linktopopup . "</span></span>{$feedbackimg}";
                 } else {
                     return $linktopopup;
                 }
             } else {
                 return $grade;
             }
         } else {
             if ($stateforqinattempt && question_state_is_closed($stateforqinattempt)) {
                 $text = get_string('requiresgrading', 'quiz_overview');
                 if (!$this->is_downloading()) {
                     $link = new moodle_url("/mod/quiz/reviewquestion.php?attempt={$attempt->attempt}&question={$question->id}");
                     $action = new popup_action('click', $link, 'reviewquestion', array('height' => 450, 'width' => 650));
                     return $OUTPUT->action_link($link, $text, $action, array('title' => get_string('reviewresponsetoq', 'quiz', $question->formattedname)));
                 } else {
                     return $text;
                 }
             } else {
                 return '--';
             }
         }
     } else {
         return NULL;
     }
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:60,代码来源:overview_table.php

示例9: render

 /**
  * @desc Generates the HTML for a particular question.
  * @param integer $seed The seed of the question.
  * @param array $answers An array of answers that needs to be rendered.
  * @param object $event The event object.
  * @return string The HTML question representation.
  */
 public function render($seed, &$answers, $event)
 {
     //JIT Derivation creation
     //Usually we have this from the check answers call
     if (!isset($this->_derivation)) {
         $client = WebworkClient::Get();
         $env = WebworkQuestion::DefaultEnvironment();
         $env->problemSeed = $seed;
         $result = $client->renderProblem($env, $this->_data->code);
         $derivation = new stdClass();
         $derivation->html = base64_decode($result->output);
         $derivation->seed = $result->seed;
         $this->_derivation = $derivation;
     }
     $orderedanswers = array();
     $tempanswers = array();
     foreach ($answers as $answer) {
         $tempanswers[$answer->field] = $answer;
     }
     $answers = $tempanswers;
     $showpartialanswers = $this->_data->grading;
     $questionhtml = "";
     $parser = new HtmlParser($this->_derivation->html);
     $currentselect = "";
     $textarea = false;
     $checkboxes = array();
     while ($parser->parse()) {
         //change some attributes of html tags for moodle compliance
         if ($parser->iNodeType == NODE_TYPE_ELEMENT) {
             $nodename = $parser->iNodeName;
             if (isset($parser->iNodeAttributes['name'])) {
                 $name = $parser->iNodeAttributes['name'];
             }
             //handle generic change of node's attribute name
             if ($nodename == "INPUT" || $nodename == "SELECT" || $nodename == "TEXTAREA") {
                 $parser->iNodeAttributes['name'] = 'resp' . $this->_data->question . '_' . $name;
                 if ($event == QUESTION_EVENTGRADE && isset($answers[$name])) {
                     if ($showpartialanswers) {
                         if (isset($parser->iNodeAttributes['class'])) {
                             $class = $parser->iNodeAttributes['class'];
                         } else {
                             $class = "";
                         }
                         $parser->iNodeAttributes['class'] = $class . ' ' . question_get_feedback_class($answers[$name]->score);
                     }
                 }
             }
             //handle specific change
             if ($nodename == "INPUT") {
                 $nodetype = strtoupper($parser->iNodeAttributes['type']);
                 if ($nodetype == "CHECKBOX") {
                     if (strstr($answers[$name]->answer, $parser->iNodeAttributes['value'])) {
                         //FILLING IN ANSWER (CHECKBOX)
                         array_push($orderedanswers, $answers[$name]);
                         $parser->iNodeAttributes['checked'] = '1';
                     }
                     $parser->iNodeAttributes['name'] = $parser->iNodeAttributes['name'] . '_' . $parser->iNodeAttributes['value'];
                 } else {
                     if ($nodetype == "TEXT") {
                         if (isset($answers[$name])) {
                             //FILLING IN ANSWER (FIELD)
                             array_push($orderedanswers, $answers[$name]);
                             $parser->iNodeAttributes['value'] = $answers[$name]->answer;
                         }
                     }
                 }
             } else {
                 if ($nodename == "SELECT") {
                     $currentselect = $name;
                 } else {
                     if ($nodename == "OPTION") {
                         if ($parser->iNodeAttributes['value'] == $answers[$currentselect]->answer) {
                             //FILLING IN ANSWER (DROPDOWN)
                             array_push($orderedanswers, $answers[$currentselect]);
                             $parser->iNodeAttributes['selected'] = '1';
                         }
                     } else {
                         if ($nodename == "TEXTAREA") {
                             if (isset($answers[$name])) {
                                 array_push($orderedanswers, $answers[$name]);
                                 $textarea = true;
                                 $questionhtml .= $parser->printTag();
                                 $questionhtml .= $answers[$name]->answer;
                             }
                         }
                     }
                 }
             }
         }
         if (!$textarea) {
             $questionhtml .= $parser->printTag();
         } else {
             $textarea = false;
//.........这里部分代码省略.........
开发者ID:xiongchiamiov,项目名称:wwmqt-svn,代码行数:101,代码来源:question.php

示例10: wrsqz_print_question_formulation_and_controls


//.........这里部分代码省略.........
    // Fix up the ids of any responses that point the the eliminated duplicates.
    foreach ($responses as $subquestionid => $ignored) {
      if ($responses[$subquestionid]) {
        $responses[$subquestionid] = $answerids[$allanswers[$responses[$subquestionid]]];
      }
    }
    foreach ($correctanswers as $subquestionid => $ignored) {
      $correctanswers[$subquestionid] = $answerids[$allanswers[$correctanswers[$subquestionid]]];
    }
    // Shuffle the answers
    $answers = draw_rand_array($answers, count($answers));
    // Print the input controls
    foreach ($subquestions as $key => $subquestion) {
      if ($subquestion->questiontext !== '' && !is_null($subquestion->questiontext)) {
        // Subquestion text:
        $a = new stdClass;
        $a->text = format_text($subquestion->questiontext,
        $question->questiontextformat, $cmoptions);
        // Drop-down list:
        $menuname = $inputname.$subquestion->id;
        $response = isset($state->responses[$subquestion->id])
                    ? $state->responses[$subquestion->id] : '0';
        $a->class = ' ';
        $a->feedbackimg = ' ';

        if ($options->readonly and $options->correct_responses) {
          if (isset($correctanswers[$subquestion->id])
          and ($correctanswers[$subquestion->id] == $response)) {
            $correctresponse = 1;
          } else {
            $correctresponse = 0;
          }
          if ($options->feedback && $response) {
            $a->class = question_get_feedback_class($correctresponse);
            $a->feedbackimg = question_get_feedback_image($correctresponse);
          }
        }

        $a->control = choose_from_menu($answers, $menuname, $response, 'choose',
                                       '', 0, true, $options->readonly);
        $anss[] = $a;
      }
    }

  }else if($questionType == 'multianswer'){

  }else if($questionType == 'multichoice'){
  
    $answers = &$question->options->answers;
    $correctanswers = $QTYPES['multichoicewiris']->get_correct_responses($question, $state);
    $readonly = empty($options->readonly) ? '' : 'disabled="disabled"';
    $answerprompt = ($question->options->single) ? get_string('singleanswer', 'quiz') :
                    get_string('multipleanswers', 'quiz');
    // Print each answer in a separate row
    foreach ($state->options->order as $key => $aid) {
      $answer = &$answers[$aid];
      $checked = '';
      $chosen = false;

      if ($question->options->single) {
        $type = 'type="radio"';
        $name   = "name=\"{$question->name_prefix}\"";
        if (isset($state->responses['']) and $aid == $state->responses['']) {
          $checked = 'checked="checked"';
          $chosen = true;
        }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:67,代码来源:libquestiontype.php

示例11: print_question_formulation_and_controls

 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG;
     /// This implementation is also used by question type 'numerical'
     $readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
     $formatoptions = new stdClass();
     $formatoptions->noclean = true;
     $formatoptions->para = false;
     $nameprefix = $question->name_prefix;
     /// Print question text and media
     $questiontext = format_text($question->questiontext, $question->questiontextformat, $formatoptions, $cmoptions->course);
     $image = get_question_image($question, $cmoptions->course);
     /// Print input controls
     if (isset($state->responses['']) && $state->responses[''] != '') {
         $value = ' value="' . s($state->responses[''], true) . '" ';
     } else {
         $value = ' value="" ';
     }
     $inputname = ' name="' . $nameprefix . '" ';
     $feedback = '';
     $class = '';
     $feedbackimg = '';
     if ($options->feedback) {
         $class = question_get_feedback_class(0);
         $feedbackimg = question_get_feedback_image(0);
         foreach ($question->options->answers as $answer) {
             if ($this->test_response($question, $state, $answer)) {
                 // Answer was correct or partially correct.
                 $class = question_get_feedback_class($answer->fraction);
                 $feedbackimg = question_get_feedback_image($answer->fraction);
                 if ($answer->feedback) {
                     $feedback = format_text($answer->feedback, true, $formatoptions, $cmoptions->course);
                 }
                 break;
             }
         }
     }
     /// Removed correct answer, to be displayed later MDL-7496
     include "{$CFG->dirroot}/question/type/shortanswer/display.html";
 }
开发者ID:veritech,项目名称:pare-project,代码行数:40,代码来源:questiontype.php

示例12: print_question_formulation_and_controls

 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG;
     $subquestions = $state->options->subquestions;
     $correctanswers = $this->get_correct_responses($question, $state);
     $nameprefix = $question->name_prefix;
     $answers = array();
     $allanswers = array();
     $answerids = array();
     $responses =& $state->responses;
     // Prepare a list of answers, removing duplicates.
     foreach ($subquestions as $subquestion) {
         foreach ($subquestion->options->answers as $ans) {
             $allanswers[$ans->id] = $ans->answer;
             if (!in_array($ans->answer, $answers)) {
                 $answers[$ans->id] = $ans->answer;
                 $answerids[$ans->answer] = $ans->id;
             }
         }
     }
     // Fix up the ids of any responses that point the the eliminated duplicates.
     foreach ($responses as $subquestionid => $ignored) {
         if ($responses[$subquestionid]) {
             $responses[$subquestionid] = $answerids[$allanswers[$responses[$subquestionid]]];
         }
     }
     foreach ($correctanswers as $subquestionid => $ignored) {
         $correctanswers[$subquestionid] = $answerids[$allanswers[$correctanswers[$subquestionid]]];
     }
     // Shuffle the answers
     $answers = draw_rand_array($answers, count($answers));
     // Print formulation
     $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
     $image = get_question_image($question);
     // Print the input controls
     foreach ($subquestions as $key => $subquestion) {
         if ($subquestion->questiontext != '') {
             // Subquestion text:
             $a = new stdClass();
             $a->text = $this->format_text($subquestion->questiontext, $question->questiontextformat, $cmoptions);
             // Drop-down list:
             $menuname = $nameprefix . $subquestion->id;
             $response = isset($state->responses[$subquestion->id]) ? $state->responses[$subquestion->id] : '0';
             $a->class = ' ';
             $a->feedbackimg = ' ';
             if ($options->readonly and $options->correct_responses) {
                 if (isset($correctanswers[$subquestion->id]) and $correctanswers[$subquestion->id] == $response) {
                     $correctresponse = 1;
                 } else {
                     $correctresponse = 0;
                 }
                 if ($options->feedback && $response) {
                     $a->class = question_get_feedback_class($correctresponse);
                     $a->feedbackimg = question_get_feedback_image($correctresponse);
                 }
             }
             $a->control = choose_from_menu($answers, $menuname, $response, 'choose', '', 0, true, $options->readonly);
             // Neither the editing interface or the database allow to provide
             // fedback for this question type.
             // However (as was pointed out in bug bug 3294) the randomsamatch
             // type which reuses this method can have feedback defined for
             // the wrapped shortanswer questions.
             //if ($options->feedback
             // && !empty($subquestion->options->answers[$responses[$key]]->feedback)) {
             //    print_comment($subquestion->options->answers[$responses[$key]]->feedback);
             //}
             $anss[] = $a;
         }
     }
     include "{$CFG->dirroot}/question/type/match/display.html";
 }
开发者ID:r007,项目名称:PMoodle,代码行数:71,代码来源:questiontype.php

示例13: other_cols

 /**
  * @param string $colname the name of the column.
  * @param object $attempt the row of data - see the SQL in display() in
  * mod/quiz/report/overview/report.php to see what fields are present,
  * and what they are called.
  * @return string the contents of the cell.
  */
 function other_cols($colname, $attempt)
 {
     if (preg_match('/^qsgrade([0-9]+)$/', $colname, $matches)) {
         $questionid = $matches[1];
         $question = $this->questions[$questionid];
         if (isset($this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid])) {
             $stateforqinattempt = $this->gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
         } else {
             $stateforqinattempt = false;
         }
         if ($stateforqinattempt && question_state_is_graded($stateforqinattempt)) {
             $grade = quiz_rescale_grade($stateforqinattempt->grade, $this->quiz, 'question');
             if (!$this->is_downloading()) {
                 if (isset($this->regradedqs[$attempt->attemptuniqueid][$questionid])) {
                     $gradefromdb = $grade;
                     $newgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->newgrade, $this->quiz, 'question');
                     $oldgrade = quiz_rescale_grade($this->regradedqs[$attempt->attemptuniqueid][$questionid]->oldgrade, $this->quiz, 'question');
                     $grade = '<del>' . $oldgrade . '</del><br />' . $newgrade;
                 }
                 $linktopopup = link_to_popup_window('/mod/quiz/reviewquestion.php?attempt=' . $attempt->attempt . '&amp;question=' . $question->id, 'reviewquestion', $grade, 450, 650, get_string('reviewresponse', 'quiz'), 'none', true);
                 if ($this->questions[$questionid]->maxgrade != 0) {
                     $fractionofgrade = $stateforqinattempt->grade / $this->questions[$questionid]->maxgrade;
                     $qclass = question_get_feedback_class($fractionofgrade);
                     $feedbackimg = question_get_feedback_image($fractionofgrade);
                     $questionclass = "que";
                     return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $linktopopup . "</span></span>{$feedbackimg}";
                 } else {
                     return $linktopopup;
                 }
             } else {
                 return $grade;
             }
         } else {
             return '--';
         }
     } else {
         return NULL;
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:46,代码来源:overview_table.php

示例14: grade_responses

 /**
  * Performs response processing and grading
  * The function was redefined for handling correctly the two parts
  * number and unit of numerical or calculated questions
  * The code handles also the case when there no unit defined by the user or
  * when used in a multianswer (Cloze) question.
  * This function performs response processing and grading and updates
  * the state accordingly.
  * @return boolean         Indicates success or failure.
  * @param object $question The question to be graded. Question type
  *                         specific information is included.
  * @param object $state    The state of the question to grade. The current
  *                         responses are in ->responses. The last graded state
  *                         is in ->last_graded (hence the most recently graded
  *                         responses are in ->last_graded->responses). The
  *                         question type specific information is also
  *                         included. The ->raw_grade and ->penalty fields
  *                         must be updated. The method is able to
  *                         close the question session (preventing any further
  *                         attempts at this question) by setting
  *                         $state->event to QUESTION_EVENTCLOSEANDGRADE
  * @param object $cmoptions
  */
 function grade_responses(&$question, &$state, $cmoptions)
 {
     if (isset($state->responses['']) && $state->responses[''] != '' && !isset($state->responses['answer'])) {
         $this->split_old_answer($state->responses[''], $question->options->units, $state->responses['answer'], $state->responses['unit']);
     }
     $state->raw_grade = 0;
     $valid_numerical_unit = false;
     $break = 0;
     $unittested = '';
     $hasunits = 0;
     $answerasterisk = false;
     $break = 0;
     foreach ($question->options->answers as $answer) {
         if ($this->test_response($question, $state, $answer)) {
             // Answer was correct or partially correct.
             $state->raw_grade = $answer->fraction;
             if ($question->options->unitgradingtype == 0 || $answer->answer === '*') {
                 // if * then unit has the $answer->fraction value
                 // if $question->options->unitgradingtype == 0 everything has been checked
                 // if $question->options->showunits == NUMERICALQUESTIONUNITTEXTINPUTDISPLAY
                 // then number - unit combination has been used to test response
                 // so the unit should have same color
             } else {
                 // so we need to apply unit grading i.e. to check if the number-unit combination
                 // was the rigth one
                 $valid_numerical_unit = false;
                 $class = question_get_feedback_class($answer->fraction);
                 $feedbackimg = question_get_feedback_image($answer->fraction);
                 if (isset($state->responses['unit']) && $state->responses['unit'] != '') {
                     foreach ($question->options->units as $key => $unit) {
                         if ($unit->unit == $state->responses['unit']) {
                             $response = $this->apply_unit($state->responses['answer'] . $state->responses['unit'], array($question->options->units[$key]));
                             if ($response !== false) {
                                 $this->get_tolerance_interval($answer);
                                 if ($answer->min <= $response && $response <= $answer->max) {
                                     $valid_numerical_unit = true;
                                 }
                             }
                             break;
                         }
                     }
                 }
             }
             break;
         }
     }
     // apply unit penalty
     $raw_unitpenalty = 0;
     if ($question->options->unitgradingtype != 0 && !empty($question->options->unitpenalty) && $valid_numerical_unit != true) {
         if ($question->options->unitgradingtype == 1) {
             $raw_unitpenalty = $question->options->unitpenalty * $state->raw_grade;
         } else {
             $raw_unitpenalty = $question->options->unitpenalty;
         }
         $state->raw_grade -= $raw_unitpenalty;
     }
     // Make sure we don't assign negative or too high marks.
     $state->raw_grade = min(max((double) $state->raw_grade, 0.0), 1.0) * $question->maxgrade;
     // Update the penalty.
     $state->penalty = $question->penalty * $question->maxgrade;
     // mark the state as graded
     $state->event = $state->event == QUESTION_EVENTCLOSE ? QUESTION_EVENTCLOSEANDGRADE : QUESTION_EVENTGRADE;
     return true;
 }
开发者ID:esyacelga,项目名称:sisadmaca,代码行数:87,代码来源:questiontype.php

示例15: question_get_feedback_image

/**
 * Returns the html for question feedback image.
 * @param float   $fraction  value representing the correctness of the user's
 *                           response to a question.
 * @param boolean $selected  whether or not the answer is the one that the
 *                           user picked.
 * @return string
 */
function question_get_feedback_image($fraction, $selected = true)
{
    global $CFG;
    static $icons = array('correct' => 'tick_green', 'partiallycorrect' => 'tick_amber', 'incorrect' => 'cross_red');
    if ($selected) {
        $size = 'big';
    } else {
        $size = 'small';
    }
    $class = question_get_feedback_class($fraction);
    return '<img src="' . $CFG->pixpath . '/i/' . $icons[$class] . '_' . $size . '.gif" ' . 'alt="' . get_string($class, 'quiz') . '" class="icon" />';
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:20,代码来源:questionlib.php


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