Example #1
0
 /**
  * display the form to edit answers
  *
  * @param $exId exercise id, required to get stay in the exercise context if required after posting the form
  * @param $askDuplicate display or not the form elements allowing to choose if the question must be duplicated or modified in all exercises
  * @author Sebastien Piraux <*****@*****.**>
  * @return string html code for display of answer edition form
  */
 public function getFormHtml($exId = null, $askDuplicate)
 {
     $html = '<form method="post" action="./edit_answers.php?exId=' . $exId . '&amp;quId=' . $this->questionId . '">' . "\n" . '<input type="hidden" name="cmd" value="exEdit" />' . "\n" . '<input type="hidden" name="step" value="' . $this->step . '" />' . "\n" . claro_form_relay_context() . "\n";
     if ($this->step > 1) {
         $html .= '<input type="hidden" name="answer" value="' . claro_htmlspecialchars($this->answerText) . '" />' . "\n" . '<input type="hidden" name="type" value="' . claro_htmlspecialchars($this->type) . '" />' . "\n" . '<input type="hidden" name="wrongAnswerList" value="' . claro_htmlspecialchars(implode("\n", $this->wrongAnswerList)) . '" />' . "\n\n";
         if (!empty($exId) && $askDuplicate) {
             if (isset($_REQUEST['duplicate'])) {
                 $html .= '<input type="hidden" name="duplicate" value="' . claro_htmlspecialchars($_REQUEST['duplicate']) . '" />' . "\n";
             }
         }
         $html .= '<p>' . get_lang('Please give a weighting to each blank') . '&nbsp;:</p>' . "\n" . '<table border="0" cellpadding="5" width="500">' . "\n";
         $i = 0;
         foreach ($this->answerList as $correctAnswer) {
             $value = isset($this->gradeList[$i]) ? $this->gradeList[$i] : '0';
             $html .= '<tr>' . "\n" . '<td width="50%">' . $correctAnswer . '</td>' . "\n" . '<td width="50%">' . '<input type="text" name="grade[' . $i . ']" size="5" value="' . $value . '" />' . '</td>' . "\n" . '</tr>' . "\n\n";
             $i++;
         }
         $html .= '</table>' . "\n\n" . '<input type="submit" name="cmdBack" value="&lt; ' . get_lang('Back') . '" />&nbsp;&nbsp;' . '<input type="submit" name="cmdOk" value="' . get_lang('Ok') . '" />&nbsp;&nbsp;' . claro_html_button('./edit_question.php?exId=' . $exId . '&amp;quId=' . $this->questionId, get_lang("Cancel"));
     } else {
         // populate fields of other steps
         $i = 0;
         foreach ($this->gradeList as $grade) {
             $html .= '<input type="hidden" name="grade[' . $i . ']" value="' . $grade . '" />' . "\n";
             $i++;
         }
         if (!empty($exId) && $askDuplicate) {
             $html .= '<p>' . html_ask_duplicate() . '</p>' . "\n";
         }
         // answer
         $text = $this->addslashesEncodedBrackets($this->answerText);
         $text = $this->answerDecode($text);
         $html .= '<p>' . get_lang('Please type your text below, use brackets %mask to define one or more blanks', array('%mask' => '&#91;...&#93;')) . ' :</p>' . "\n" . claro_html_textarea_editor('answer', $text) . "\n" . '<p>' . get_lang('Fill type') . '&nbsp;:</p>' . "\n" . '<p>' . "\n" . '<input type="radio" name="type" id="textFill" value="' . TEXTFIELD_FILL . '"' . ($this->type == TEXTFIELD_FILL ? 'checked="checked"' : '') . ' /><label for="textFill">' . get_lang('Fill text field') . '</label><br />' . "\n" . '<input type="radio" name="type" id="listboxFill" value="' . LISTBOX_FILL . '"' . ($this->type == LISTBOX_FILL ? 'checked="checked"' : '') . ' /><label for="listboxFill">' . get_lang('Select in drop down list') . '</label><br />' . "\n" . '</p>' . "\n" . '<p>' . get_lang('Add wrong answers for drop down lists <small>(Optionnal. One wrong answer by line.)</small>') . '</p>' . '<textarea name="wrongAnswerList" cols="30" rows="5">' . claro_htmlspecialchars($this->answerDecode(implode("\n", $this->wrongAnswerList))) . '</textarea>' . "\n" . '<p>' . "\n" . '<input type="submit" name="cmdNext" value="' . get_lang('Next') . ' &gt;" />&nbsp;&nbsp;' . claro_html_button(Url::Contextualize('./edit_question.php?exId=' . $exId . '&amp;quId=' . $this->questionId), get_lang("Cancel")) . '</p>' . "\n";
     }
     $html .= '</form>';
     return $html;
 }
Example #2
0
 /**
  * display the form to edit answers
  *
  * @param $exId exercise id, required to get stay in the exercise context if required after posting the form
  * @param $askDuplicate display or not the form elements allowing to choose if the question must be duplicated or modified in all exercises
  * @author Sebastien Piraux <*****@*****.**>
  * @return string html code for display of answer edition form
  */
 public function getFormHtml($exId = null, $askDuplicate = false)
 {
     $html = '<form method="post" action="./edit_answers.php?exId=' . $exId . '&amp;quId=' . $this->questionId . '">' . "\n" . '<input type="hidden" name="cmd" value="exEdit" />' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . claro_form_relay_context() . "\n" . '<table class="claroTable">' . "\n";
     if (!empty($exId) && $askDuplicate) {
         $html .= html_ask_duplicate();
     }
     $html .= '<thead>' . "\n" . '<tr>' . "\n" . '<th>' . get_lang('Expected choice') . '</th>' . "\n" . '<th>' . get_lang('Answer') . '</th>' . "\n" . '<th>' . get_lang('Comment') . '</th>' . "\n" . '<th>' . get_lang('Weighting') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n" . '<tr>' . "\n" . '<td valign="top" align="center">' . '<input name="correctAnswer" id="trueCorrect" ' . ($this->correctAnswer == "TRUE" ? 'checked="checked"' : '') . 'type="radio" value="true" />' . '</td>' . "\n" . '<td valign="top"><label for="trueCorrect">' . get_lang('True') . '</label></td>' . "\n" . '<td>' . claro_html_textarea_editor('trueFeedback', $this->trueFeedback, 10, 25, '', 'simple') . '</td>' . "\n" . '<td valign="top"><input name="trueGrade" size="5" value="' . $this->trueGrade . '" type="text" /></td>' . "\n" . '</tr>' . "\n\n" . '<tr>' . "\n" . '<td valign="top" align="center">' . '<input name="correctAnswer" id="falseCorrect" ' . ($this->correctAnswer == "FALSE" ? 'checked="checked"' : '') . 'type="radio" value="false" />' . '</td>' . "\n" . '<td valign="top"><label for="falseCorrect">' . get_lang('False') . '</label></td>' . "\n" . '<td>' . claro_html_textarea_editor('falseFeedback', $this->falseFeedback, 10, 25, '', 'simple') . '</td>' . "\n" . '<td valign="top"><input name="falseGrade" size="5" value="' . $this->falseGrade . '" type="text" /></td>' . "\n" . '</tr>' . "\n\n" . '<tr>' . "\n" . '<td colspan="4" align="center">' . '<input type="submit" name="cmdOk" value="' . get_lang('Ok') . '" />&nbsp;&nbsp;' . claro_html_button(Url::Contextualize('./edit_question.php?exId=' . $exId . '&amp;quId=' . $this->questionId), get_lang("Cancel")) . '</td>' . "\n" . '</tr>' . "\n\n" . '</table>' . "\n\n" . '</form>';
     return $html;
 }
Example #3
0
 /**
  * display the form to edit answers
  *
  * @param $exId exercise id, required to get stay in the exercise context if required after posting the form
  * @param $askDuplicate display or not the form elements allowing to choose if the question must be duplicated or modified in all exercises
  * @author Sebastien Piraux <*****@*****.**>
  * @return string html code for display of answer edition form
  */
 public function getFormHtml($exId = null, $askDuplicate)
 {
     $html = '<form method="post" action="./edit_answers.php?exId=' . $exId . '&amp;quId=' . $this->questionId . '">' . "\n" . '<input type="hidden" name="cmd" value="exEdit" />' . "\n" . '<input type="hidden" name="leftCount" value="' . count($this->leftList) . '" />' . "\n" . '<input type="hidden" name="rightCount" value="' . count($this->rightList) . '" />' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . claro_form_relay_context() . "\n";
     if (!empty($exId) && $askDuplicate) {
         $html .= '<p>' . html_ask_duplicate() . '</p>' . "\n";
     }
     $html .= '<table border="0" cellpadding="5">' . "\n\n" . '<tr>' . "\n" . '<td colspan="3">' . get_lang('Make correspond') . '&nbsp;:</td>' . "\n" . '<td>' . get_lang('Weighting') . '&nbsp;:</td>' . "\n" . '</tr>' . "\n\n";
     $leftCpt = 1;
     $i = 1;
     foreach ($this->leftList as $leftElt) {
         // build html option list - we have to do this here for "selected" attribute
         $optionList = '';
         $rightCpt = 'A';
         $j = 0;
         foreach ($this->rightList as $rightElt) {
             $optionList .= '<option value="' . $j . '"';
             if ($leftElt['match'] == $rightElt['code']) {
                 $optionList .= ' selected="selected"';
             }
             $optionList .= '>' . $rightCpt . '</option>' . "\n";
             $rightCpt++;
             $j++;
         }
         $html .= '<tr>' . "\n" . '<td>' . $leftCpt . '.</td>' . "\n" . '<td><input type="text" name="answer_' . $this->questionId . '_' . $i . '" size="58" value="' . claro_htmlspecialchars($leftElt['answer']) . '" /></td>' . "\n" . '<td>' . '<select name="match_' . $this->questionId . '_' . $i . '" />' . "\n" . $optionList . "\n" . '</select>' . "\n" . '</td>' . "\n" . '<td><input type="text" name="grade_' . $this->questionId . '_' . $i . '" size="8" value="' . claro_htmlspecialchars($leftElt['grade']) . '" /></td>' . "\n" . '</tr>' . "\n\n";
         $leftCpt++;
         $i++;
     }
     $html .= '<tr>' . "\n" . '<td colspan="4">' . '<input type="submit" name="cmdRemLeft" value="' . get_lang('Rem. elem.') . '" />&nbsp;&nbsp;' . '<input type="submit" name="cmdAddLeft" value="' . get_lang('Add elem.') . '" />' . '</td>' . "\n" . '</tr>' . "\n\n";
     $html .= '<tr>' . "\n" . '<td colspan="4">' . get_lang('Please define the options') . '&nbsp;:</td>' . "\n" . '</tr>' . "\n\n";
     $rightCpt = 'A';
     $i = 1;
     foreach ($this->rightList as $rightElt) {
         $html .= '<tr>' . "\n" . '<td>' . $rightCpt . '.</td>' . "\n" . '<td colspan="3"><input type="text" name="right_' . $this->questionId . '_' . $i . '" size="58" value="' . claro_htmlspecialchars($rightElt['answer']) . '" /></td>' . "\n" . '</tr>' . "\n\n";
         $rightCpt++;
         $i++;
     }
     $html .= '<tr>' . "\n" . '<td colspan="4">' . '<input type="submit" name="cmdRemRight" value="' . get_lang('Rem. elem.') . '" />&nbsp;&nbsp;' . '<input type="submit" name="cmdAddRight" value="' . get_lang('Add elem.') . '" />' . '</td>' . "\n" . '</tr>' . "\n\n";
     $html .= '<tr>' . "\n" . '<td colspan="4" align="center">' . '<input type="submit" name="cmdOk" value="' . get_lang('Ok') . '" />&nbsp;&nbsp;' . claro_html_button(Url::Contextualize('./edit_question.php?exId=' . $exId . '&amp;quId=' . $this->questionId), get_lang("Cancel")) . '</td>' . "\n" . '</tr>' . "\n\n" . '</table>';
     return $html;
 }
Example #4
0
    <input type="hidden" name="claroFormId" value="<?php 
echo uniqid('');
?>
" />
    <fieldset>
        <legend><?php 
echo get_lang('Question details');
?>
</legend>
    <dl>
        <?php 
if ($this->askDuplicate) {
    ?>
        <dt>&nbsp;</dt>
        <dd><?php 
    echo html_ask_duplicate();
    ?>
</dd>
        <?php 
}
?>
        <dt><label for="title"><?php 
echo get_lang('Title');
?>
&nbsp;<span class="required">*</span></label></dt>
        <dd><input type="text" name="title" id="title" size="60" maxlength="200" value="<?php 
echo claro_htmlspecialchars($this->data['title']);
?>
" /></dd>
        <dt><label for="description"><?php 
echo get_lang('Description');
 /**
  * display the form to edit answers
  *
  * @param $exId exercise id, required to get stay in the exercise context if required after posting the form
  * @param $askDuplicate display or not the form elements allowing to choose if the question must be duplicated or modified in all exercises
  * @author Sebastien Piraux <*****@*****.**>
  * @return string html code for display of answer edition form
  */
 public function getFormHtml($exId = null, $askDuplicate)
 {
     $html = '<form method="post" action="./edit_answers.php?exId=' . $exId . '&amp;quId=' . $this->questionId . '">' . "\n" . '<input type="hidden" name="cmd" value="exEdit" />' . "\n" . '<input type="hidden" name="answerCount" value="' . count($this->answerList) . '" />' . "\n" . '<input type="hidden" name="claroFormId" value="' . uniqid('') . '" />' . "\n" . claro_form_relay_context() . "\n";
     if ($this->multipleAnswer) {
         // warn course admin that if the user checks all answer he will have the sum of all wieghting values
         $html .= '<p><small>' . get_lang('Use negative weighting for incorrect choices to penalize a user that check all answers.') . '</small></p>' . "\n";
     }
     if (!empty($exId) && $askDuplicate) {
         $html .= '<p>' . html_ask_duplicate() . '</p>' . "\n";
     }
     $html .= '<table class="claroTable" >' . "\n" . '<thead>' . '<tr>' . "\n" . '<th>' . get_lang('Expected choice') . '</th>' . "\n" . '<th>' . get_lang('Answer') . '</th>' . "\n" . '<th>' . get_lang('Comment') . '</th>' . "\n" . '<th>' . get_lang('Weighting') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
     $i = 1;
     foreach ($this->answerList as $answer) {
         $html .= '<tr>' . "\n" . '<td valign="top" align="center">';
         if ($this->multipleAnswer) {
             $html .= '<input name="correct_' . $i . '" id="correct_' . $i . '" ' . ($answer['correct'] ? 'checked="checked"' : '') . ' type="checkbox" value="1" />';
         } else {
             $html .= '<input name="correct" id="correct_' . $i . '" ' . ($answer['correct'] ? 'checked="checked"' : '') . ' type="radio" value="correct_' . $i . '" />';
         }
         $html .= '</td>' . "\n" . '<td valign="top">' . claro_html_textarea_editor('answer_' . $i, $answer['answer'], 10, 25, '', 'simple') . '</td>' . "\n" . '<td>' . claro_html_textarea_editor('comment_' . $i, $answer['comment'], 10, 25, '', 'simple') . '</td>' . "\n" . '<td valign="top">' . '<input name="grade_' . $i . '" size="5" value="' . claro_htmlspecialchars($answer['grade']) . '" type="text" />' . '</td>' . "\n" . '</tr>' . "\n\n";
         $i++;
     }
     $html .= '<tr>' . "\n" . '<td colspan="4" align="center">' . '<input type="submit" name="cmdOk" value="' . get_lang('Ok') . '" />&nbsp;&nbsp;' . '<input type="submit" name="cmdRemAnsw" value="' . get_lang('Rem. answ.') . '" />&nbsp;&nbsp;' . '<input type="submit" name="cmdAddAnsw" value="' . get_lang('Add answ.') . '" />&nbsp;&nbsp;' . claro_html_button(Url::Contextualize('./edit_question.php?exId=' . $exId . '&amp;quId=' . $this->questionId), get_lang("Cancel")) . '</td>' . "\n" . '</tr>' . "\n\n" . '</table>' . "\n\n" . '</form>' . "\n\n";
     return $html;
 }