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


PHP question_get_feedback_image函数代码示例

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


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

 /**
  * Prints the main content of the question including any interactions
  */
 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG;
     $readonly = $options->readonly ? ' disabled="disabled"' : '';
     $formatoptions = new stdClass();
     $formatoptions->noclean = true;
     $formatoptions->para = false;
     // Print question formulation
     $questiontext = format_text($question->questiontext, $question->questiontextformat, $formatoptions, $cmoptions->course);
     $image = get_question_image($question);
     $answers =& $question->options->answers;
     $trueanswer =& $answers[$question->options->trueanswer];
     $falseanswer =& $answers[$question->options->falseanswer];
     $correctanswer = $trueanswer->fraction == 1 ? $trueanswer : $falseanswer;
     $trueclass = '';
     $falseclass = '';
     $truefeedbackimg = '';
     $falsefeedbackimg = '';
     // Work out which radio button to select (if any)
     if (isset($state->responses[''])) {
         $response = $state->responses[''];
     } else {
         $response = '';
     }
     $truechecked = $response == $trueanswer->id ? ' checked="checked"' : '';
     $falsechecked = $response == $falseanswer->id ? ' checked="checked"' : '';
     // Work out visual feedback for answer correctness.
     if ($options->feedback) {
         if ($truechecked) {
             $trueclass = question_get_feedback_class($trueanswer->fraction);
         } else {
             if ($falsechecked) {
                 $falseclass = question_get_feedback_class($falseanswer->fraction);
             }
         }
     }
     if ($options->feedback || $options->correct_responses) {
         if (isset($answers[$response])) {
             $truefeedbackimg = question_get_feedback_image($trueanswer->fraction, !empty($truechecked) && $options->feedback);
             $falsefeedbackimg = question_get_feedback_image($falseanswer->fraction, !empty($falsechecked) && $options->feedback);
         }
     }
     $inputname = ' name="' . $question->name_prefix . '" ';
     $trueid = $question->name_prefix . 'true';
     $falseid = $question->name_prefix . 'false';
     $radiotrue = '<input type="radio"' . $truechecked . $readonly . $inputname . 'id="' . $trueid . '" value="' . $trueanswer->id . '" /><label for="' . $trueid . '">' . s($trueanswer->answer) . '</label>';
     $radiofalse = '<input type="radio"' . $falsechecked . $readonly . $inputname . 'id="' . $falseid . '" value="' . $falseanswer->id . '" /><label for="' . $falseid . '">' . s($falseanswer->answer) . '</label>';
     $feedback = '';
     if ($options->feedback and isset($answers[$response])) {
         $chosenanswer = $answers[$response];
         $feedback = format_text($chosenanswer->feedback, true, $formatoptions, $cmoptions->course);
     }
     include "{$CFG->dirroot}/question/type/truefalse/display.html";
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:57,代码来源:questiontype.php

示例3: 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

示例4: print_question_formulation_and_controls

 function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options)
 {
     global $CFG;
     $context = $this->get_context_by_category_id($question->category);
     /// 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);
     /// Print input controls
     if (isset($state->responses['']) && $state->responses[''] != '') {
         $value = ' value="' . s($state->responses['']) . '" ';
     } else {
         $value = ' value="" ';
     }
     $inputname = ' name="' . $nameprefix . '" ';
     $feedback = '';
     $class = '';
     $feedbackimg = '';
     if ($options->feedback) {
         $class = question_get_feedback_class(0);
         $feedbackimg = question_get_feedback_image(0);
         //this is OK for the first answer with a good response
         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) {
                     $answer->feedback = quiz_rewrite_question_urls($answer->feedback, 'pluginfile.php', $context->id, 'question', 'answerfeedback', array($state->attempt, $state->question), $answer->id);
                     $feedback = format_text($answer->feedback, $answer->feedbackformat, $formatoptions, $cmoptions->course);
                 }
                 break;
             }
         }
     }
     /// Removed correct answer, to be displayed later MDL-7496
     include $this->get_display_html_path();
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:42,代码来源:questiontype.php

示例5: 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

示例6: 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;
     }
     $feedback = '';
     $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) {
         $feedback = question_get_feedback_image(1);
     } else {
         if ($hasanswer && !$weight) {
             $feedback = question_get_feedback_image(0);
         } else {
             if (!$hasanswer && $weight) {
                 $feedback = question_get_feedback_image(1);
             }
         }
     }
     return $base . $feedback;
 }
开发者ID:sunilwebaccess,项目名称:moodle-question-matrix.1-9,代码行数:22,代码来源:questiontype.php

示例7: 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

示例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: wrsqz_print_question_formulation_and_controls


//.........这里部分代码省略.........
    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;
        }
      } else {
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:67,代码来源:libquestiontype.php

示例10: 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

示例11: 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

示例12: 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;
     //find webworkquestion object
     $wwquestion = $question->webwork;
     if (!isset($question->webwork)) {
         print_error('error_no_wwquestion', 'qtype_webwork');
         return false;
     }
     //find seed
     if (!isset($state->responses['seed'])) {
         print_error('error_no_seed', 'qtype_webwork');
         return false;
     }
     //find answers
     if (isset($state->responses['answers'])) {
         $answers = $state->responses['answers'];
     } else {
         $answers = array();
     }
     $seed = $state->responses['seed'];
     $event = $state->event;
     $questionhtml = $wwquestion->render($seed, $answers, $event);
     $showPartiallyCorrectAnswers = $wwquestion->getGrading();
     $qid = $wwquestion->getQuestion();
     //Answer Table construction
     if ($state->event == QUESTION_EVENTGRADE) {
         $answertable = new stdClass();
         $answertable->head = array();
         if ($showPartiallyCorrectAnswers == 1) {
             array_push($answertable->head, 'Result');
         }
         array_push($answertable->head, 'Answer', 'Preview', 'Evaluated', 'Errors');
         $answertable->width = "100%";
         $answertabledata = array();
         foreach ($answers as $answer) {
             $answertablerow = array();
             if ($showPartiallyCorrectAnswers == 1) {
                 $firstfield = '';
                 $firstfield .= question_get_feedback_image($answer->score);
                 if ($answer->score == 1) {
                     $firstfield .= "Correct";
                 } else {
                     $firstfield .= "Incorrect";
                 }
                 array_push($answertablerow, $firstfield);
             }
             array_push($answertablerow, $answer->answer, $answer->preview, $answer->evaluated, $answer->answer_msg);
             array_push($answertabledata, $answertablerow);
         }
         $answertable->data = $answertabledata;
         $answertable = make_table($answertable);
     } else {
         $answertable = "";
     }
     include "{$CFG->dirroot}/question/type/webwork/display.html";
     flush();
 }
开发者ID:xiongchiamiov,项目名称:wwmqt-svn,代码行数:65,代码来源:questiontype.php

示例13: other_cols

 function other_cols($colname, $attempt)
 {
     global $QTYPES, $OUTPUT;
     static $states = array();
     if (preg_match('/^qsanswer([0-9]+)$/', $colname, $matches)) {
         if ($attempt->uniqueid == 0) {
             return '-';
         }
         $questionid = $matches[1];
         if (isset($this->gradedstatesbyattempt[$attempt->uniqueid][$questionid])) {
             $stateforqinattempt = $this->gradedstatesbyattempt[$attempt->uniqueid][$questionid];
         } else {
             return '-';
         }
         $question = $this->questions[$questionid];
         restore_question_state($question, $stateforqinattempt);
         if (!$this->is_downloading() || $this->is_downloading() == 'xhtml') {
             $formathtml = true;
         } else {
             $formathtml = false;
         }
         $summary = $QTYPES[$question->qtype]->response_summary($question, $stateforqinattempt, QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY, $formathtml);
         if (!$this->is_downloading()) {
             if ($summary) {
                 $link = html_link::make("/mod/quiz/reviewquestion.php?attempt={$attempt->attempt}&question={$question->id}", $summary);
                 $link->add_action(new popup_action('click', $link->url, 'reviewquestion', array('height' => 450, 'width' => 650)));
                 $link->title = $question->formattedname;
                 $summary = $OUTPUT->link($link);
                 if (question_state_is_graded($stateforqinattempt) && $question->maxgrade > 0) {
                     $grade = $stateforqinattempt->grade / $question->maxgrade;
                     $qclass = question_get_feedback_class($grade);
                     $feedbackimg = question_get_feedback_image($grade);
                     $questionclass = "que";
                     return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $summary . "</span></span>{$feedbackimg}";
                 } else {
                     return $summary;
                 }
             } else {
                 return '';
             }
         } else {
             return $summary;
         }
     } else {
         return NULL;
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:47,代码来源:responses_table.php

示例14: other_cols

 function other_cols($colname, $attempt)
 {
     global $QTYPES;
     static $states = array();
     if (preg_match('/^qsanswer([0-9]+)$/', $colname, $matches)) {
         if ($attempt->uniqueid == 0) {
             return '-';
         }
         $questionid = $matches[1];
         if (isset($this->gradedstatesbyattempt[$attempt->uniqueid][$questionid])) {
             $stateforqinattempt = $this->gradedstatesbyattempt[$attempt->uniqueid][$questionid];
         } else {
             return '-';
         }
         $question = $this->questions[$questionid];
         restore_question_state($question, $stateforqinattempt);
         if (!$this->is_downloading() || $this->is_downloading() == 'xhtml') {
             $formathtml = true;
         } else {
             $formathtml = false;
         }
         $summary = $QTYPES[$question->qtype]->response_summary($question, $stateforqinattempt, QUIZ_REPORT_RESPONSES_MAX_LEN_TO_DISPLAY, $formathtml);
         if (!$this->is_downloading()) {
             if ($summary) {
                 $summary = link_to_popup_window('/mod/quiz/reviewquestion.php?attempt=' . $attempt->attempt . '&amp;question=' . $question->id, 'reviewquestion', $summary, 450, 650, get_string('reviewresponse', 'quiz'), 'none', true);
                 if (question_state_is_graded($stateforqinattempt) && $question->maxgrade > 0) {
                     $grade = $stateforqinattempt->grade / $question->maxgrade;
                     $qclass = question_get_feedback_class($grade);
                     $feedbackimg = question_get_feedback_image($grade);
                     $questionclass = "que";
                     return "<span class=\"{$questionclass}\"><span class=\"{$qclass}\">" . $summary . "</span></span>{$feedbackimg}";
                 } else {
                     return $summary;
                 }
             } else {
                 return '';
             }
         } else {
             return $summary;
         }
     } else {
         return NULL;
     }
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:44,代码来源:responses_table.php


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