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


PHP FormValidator::isSubmitted方法代码示例

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


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

示例1: createAnswersForm

 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 public function createAnswersForm($form)
 {
     $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
     $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
     $obj_ex = Session::read('objExercise');
     /* Mise en variable de Affichage "Reponses" et son icone, "N�", "Vrai", "Reponse" */
     $html = '<table class="data_table">
             <tr>
                 <th width="10px">
                     ' . get_lang('Number') . '
                 </th>
                 <th width="10px">
                     ' . get_lang('True') . '
                 </th>
                 <th width="50%">
                     ' . get_lang('Answer') . '
                 </th>';
     $html .= '<th>' . get_lang('Comment') . '</th>';
     $html .= '</tr>';
     $form->addElement('label', get_lang('Answers') . '<br /> <img src="../img/fill_field.png">', $html);
     $defaults = array();
     $correct = 0;
     $answer = false;
     if (!empty($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
             $nb_answers = $answer->nbrAnswers;
         }
     }
     #le nombre de r�ponses est bien enregistr� sous la forme int(nb)
     /* Ajout mise en forme nb reponse */
     $form->addElement('hidden', 'nb_answers');
     $boxes_names = array();
     /* V�rification : Cr�action d'au moins une r�ponse */
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     //D�but affichage score global dans la modification d'une question
     $scoreA = "0";
     //par reponse
     $scoreG = "0";
     //Global
     /* boucle pour sauvegarder les donn�es dans le tableau defaults */
     for ($i = 1; $i <= $nb_answers; ++$i) {
         /* si la reponse est de type objet */
         if (is_object($answer)) {
             $defaults['answer[' . $i . ']'] = $answer->answer[$i];
             $defaults['comment[' . $i . ']'] = $answer->comment[$i];
             $defaults['correct[' . $i . ']'] = $answer->correct[$i];
             // start
             $scoreA = $answer->weighting[$i];
         }
         if ($scoreA > 0) {
             $scoreG = $scoreG + $scoreA;
         }
         //------------- Fin
         //------------- Debut si un des scores par reponse est egal � 0 : la coche vaut 1 (coch�)
         if ($scoreA == 0) {
             $defaults['pts'] = 1;
         }
         $renderer =& $form->defaultRenderer();
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']');
         //$renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting['.$i.']');
         $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
         $answer_number->freeze();
         $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox"');
         $boxes_names[] = 'correct[' . $i . ']';
         $form->addHtmlEditor('answer[' . $i . ']', null, null, array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
         $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
         $form->addHtmlEditor('comment[' . $i . ']', null, null, array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
         $form->addElement('html', '</tr>');
     }
     //--------- Mise en variable du score global lors d'une modification de la question/r�ponse
     $defaults['weighting[1]'] = round($scoreG);
     $form->addElement('html', '</div></div></table>');
     //$form -> addElement ('html', '<br />');
     $form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
     //only 1 answer the all deal ...
     $form->addElement('text', 'weighting[1]', get_lang('Score'));
     global $pts;
     //--------- Creation coche pour ne pas prendre en compte les n�gatifs
     $form->addElement('checkbox', 'pts', '', get_lang('NoNegativeScore'));
     $form->addElement('html', '<br />');
     // Affiche un message si le score n'est pas renseign�
     $form->addRule('weighting[1]', get_lang('ThisFieldIsRequired'), 'required');
     global $text, $class;
     if ($obj_ex->edit_exercise_in_lp == true) {
         $form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers');
         $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers');
         $form->addButtonSave($text, 'submitQuestion');
         // setting the save button here and not in the question class.php
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:global_multiple_answer.class.php

示例2: createAnswersForm

 /**
  * function which redifines Question::createAnswersForm
  * @param FormValidator $form
  * @param the answers number to display
  */
 function createAnswersForm($form)
 {
     // getting the exercise list
     $obj_ex = Session::read('objExercise');
     $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
     //this line define how many question by default appear when creating a choice question
     $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 3;
     // The previous default value was 2. See task #1759.
     $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
     /*
      Types of Feedback
      $feedback_option[0]=get_lang('Feedback');
      $feedback_option[1]=get_lang('DirectFeedback');
      $feedback_option[2]=get_lang('NoFeedback');
     */
     $feedback_title = '';
     $comment_title = '';
     if ($obj_ex->selectFeedbackType() == 1) {
         $editor_config['Width'] = '250';
         $editor_config['Height'] = '110';
         $comment_title = '<th width="50%" >' . get_lang('Comment') . '</th>';
         $feedback_title = '<th width="50%" >' . get_lang('Scenario') . '</th>';
     } else {
         $comment_title = '<th width="50%">' . get_lang('Comment') . '</th>';
     }
     $html = '<table class="table table-striped table-hover">';
     $html .= '<thead>';
     $html .= '<tr>';
     $html .= '<th>' . get_lang('Number') . '</th>';
     $html .= '<th>' . get_lang('True') . '</th>';
     $html .= '<th width="50%">' . get_lang('Answer') . '</th>';
     $html .= $comment_title . $feedback_title;
     $html .= '<th>' . get_lang('Weighting') . '</th>';
     $html .= '</tr>';
     $html .= '</thead>';
     $html .= '<tbody>';
     $form->addHeader(get_lang('Answers'));
     $form->addHtml($html);
     $defaults = array();
     $correct = 0;
     $answer = false;
     if (!empty($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
             $nb_answers = $answer->nbrAnswers;
         }
     }
     $temp_scenario = array();
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     $editQuestion = isset($_GET['editQuestion']) ? $_GET['editQuestion'] : false;
     if ($editQuestion) {
         //fixing $nb_answers
         $new_list = array();
         $count = 1;
         if (isset($_POST['lessAnswers'])) {
             $lessFromSession = Session::read('less_answer');
             if (!isset($lessFromSession)) {
                 Session::write('less_answer', $this->id);
                 $nb_answers--;
             }
         }
         for ($k = 1; $k <= $nb_answers; ++$k) {
             if ($answer->position[$k] != '666') {
                 $new_list[$count] = $count;
                 $count++;
             }
         }
     } else {
         for ($k = 1; $k <= $nb_answers; ++$k) {
             $new_list[$k] = $k;
         }
     }
     $i = 1;
     //for ($k = 1 ; $k <= $real_nb_answers; $k++) {
     foreach ($new_list as $key) {
         $i = $key;
         $form->addElement('html', '<tr>');
         if (is_object($answer)) {
             if ($answer->position[$i] == 666) {
                 //we set nothing
             } else {
                 if ($answer->correct[$i]) {
                     $correct = $i;
                 }
                 $answer_result = $answer->answer[$i];
                 $weight_result = float_format($answer->weighting[$i], 1);
                 if ($nb_answers == $i) {
                     $weight_result = '0';
                 }
                 $defaults['answer[' . $i . ']'] = $answer_result;
                 $defaults['comment[' . $i . ']'] = $answer->comment[$i];
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:unique_answer_no_option.class.php

示例3: createAnswersForm

 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 public function createAnswersForm($form)
 {
     // Getting the exercise list
     $obj_ex = $_SESSION['objExercise'];
     $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125');
     //this line defines how many questions by default appear when creating a choice question
     // The previous default value was 2. See task #1759.
     $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4;
     $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
     /*
         Types of Feedback
         $feedback_option[0]=get_lang('Feedback');
        $feedback_option[1]=get_lang('DirectFeedback');
        $feedback_option[2]=get_lang('NoFeedback');
     */
     $feedback_title = '';
     if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) {
         //Scenario
         $editor_config['Width'] = '250';
         $editor_config['Height'] = '110';
         $comment_title = '<th width="500px" >' . get_lang('Comment') . '</th>';
         $feedback_title = '<th width="350px" >' . get_lang('Scenario') . '</th>';
     } else {
         $comment_title = '<th>' . get_lang('Comment') . '</th>';
     }
     $html = '<table class="data_table">
             <tr style="text-align: center;">
                 <th width="10px">
                     ' . get_lang('Number') . '
                 </th>
                 <th width="10px" >
                     ' . get_lang('True') . '
                 </th>
                 <th width="50%">
                     ' . get_lang('Answer') . '
                 </th>
                     ' . $comment_title . '
                     ' . $feedback_title . '
                 <th width="50px">
                     ' . get_lang('Weighting') . '
                 </th>
             </tr>';
     $form->addElement('label', get_lang('Answers') . '<br /> <img src="../img/fill_field.png">', $html);
     $defaults = array();
     $correct = 0;
     if (!empty($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
             $nb_answers = $answer->nbrAnswers;
         }
     }
     $form->addElement('hidden', 'nb_answers');
     //Feedback SELECT
     $question_list = $obj_ex->selectQuestionList();
     $select_question = array();
     $select_question[0] = get_lang('SelectTargetQuestion');
     require_once '../newscorm/learnpathList.class.php';
     if (is_array($question_list)) {
         foreach ($question_list as $key => $questionid) {
             //To avoid warning messages
             if (!is_numeric($questionid)) {
                 continue;
             }
             $question = Question::read($questionid);
             $select_question[$questionid] = 'Q' . $key . ' :' . cut($question->selectTitle(), 20);
         }
     }
     $select_question[-1] = get_lang('ExitTest');
     $list = new LearnpathList(api_get_user_id());
     $flat_list = $list->get_flat_list();
     $select_lp_id = array();
     $select_lp_id[0] = get_lang('SelectTargetLP');
     foreach ($flat_list as $id => $details) {
         $select_lp_id[$id] = cut($details['lp_name'], 20);
     }
     $temp_scenario = array();
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_answers; ++$i) {
         $form->addElement('html', '<tr>');
         if (isset($answer) && is_object($answer)) {
             if ($answer->correct[$i]) {
                 $correct = $i;
             }
             $defaults['answer[' . $i . ']'] = $answer->answer[$i];
             $defaults['comment[' . $i . ']'] = $answer->comment[$i];
             $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
             $item_list = explode('@@', $answer->destination[$i]);
             $try = $item_list[0];
             $lp = $item_list[1];
             $list_dest = $item_list[2];
             $url = $item_list[3];
             if ($try == 0) {
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:unique_answer.class.php

示例4: createAnswersForm

 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 public function createAnswersForm($form)
 {
     $defaults = array();
     $nb_matches = $nb_options = 2;
     $matches = array();
     $answer = null;
     $counter = 1;
     if (isset($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0) {
             for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                 $correct = $answer->isCorrect($i);
                 if (empty($correct)) {
                     $matches[$answer->selectAutoId($i)] = chr(64 + $counter);
                     $counter++;
                 }
             }
         }
     }
     if ($form->isSubmitted()) {
         $nb_matches = $form->getSubmitValue('nb_matches');
         $nb_options = $form->getSubmitValue('nb_options');
         if (isset($_POST['lessOptions'])) {
             $nb_matches--;
             $nb_options--;
         }
         if (isset($_POST['moreOptions'])) {
             $nb_matches++;
             $nb_options++;
         }
     } else {
         if (!empty($this->id)) {
             if (count($answer->nbrAnswers) > 0) {
                 $nb_matches = $nb_options = 0;
                 for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                     if ($answer->isCorrect($i)) {
                         $nb_matches++;
                         $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
                         $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
                         $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i];
                     } else {
                         $nb_options++;
                         $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
                     }
                 }
             }
         } else {
             $defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1');
             $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
             $defaults['matches[2]'] = '2';
             $defaults['option[1]'] = get_lang('DefaultMatchingOptA');
             $defaults['option[2]'] = get_lang('DefaultMatchingOptB');
         }
     }
     if (empty($matches)) {
         for ($i = 1; $i <= $nb_options; ++$i) {
             // fill the array with A, B, C.....
             $matches[$i] = chr(64 + $i);
         }
     } else {
         for ($i = $counter; $i <= $nb_options; ++$i) {
             // fill the array with A, B, C.....
             $matches[$i] = chr(64 + $i);
         }
     }
     $form->addElement('hidden', 'nb_matches', $nb_matches);
     $form->addElement('hidden', 'nb_options', $nb_options);
     // DISPLAY MATCHES
     $html = '<table class="table table-striped table-hover">
         <thead>
             <tr>
                 <th width="5%">' . get_lang('Number') . '</th>
                 <th width="70%">' . get_lang('Answer') . '</th>
                 <th width="15%">' . get_lang('MatchesTo') . '</th>
                 <th width="10%">' . get_lang('Weighting') . '</th>
             </tr>
         </thead>
         <tbody>';
     $form->addHeader(get_lang('MakeCorrespond'));
     $form->addHtml($html);
     if ($nb_matches < 1) {
         $nb_matches = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_matches; ++$i) {
         $renderer =& $form->defaultRenderer();
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "answer[{$i}]");
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "matches[{$i}]");
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "weighting[{$i}]");
         $form->addHtml('<tr>');
         $form->addHtml("<td>{$i}</td>");
         $form->addText("answer[{$i}]", null);
         $form->addSelect("matches[{$i}]", null, $matches);
         $form->addText("weighting[{$i}]", null, true, ['value' => 10]);
         $form->addHtml('</tr>');
//.........这里部分代码省略.........
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:matching.class.php

示例5: createAnswersForm

 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 function createAnswersForm($form)
 {
     $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 2;
     $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0);
     $obj_ex = Session::read('objExercise');
     $html = '<table class="table table-striped table-hover">';
     $html .= '<thead>';
     $html .= '<tr>';
     $html .= '<th width="10">' . get_lang('Number') . '</th>';
     $html .= '<th width="10">' . get_lang('True') . '</th>';
     $html .= '<th width="50%">' . get_lang('Comment') . '</th>';
     $html .= '<th width="50%">' . get_lang('Answer') . '</th>';
     $html .= '</tr>';
     $html .= '</thead>';
     $html .= '<tbody>';
     $form->addHeader(get_lang('Answers'));
     $form->addHtml($html);
     $defaults = array();
     $correct = 0;
     $answer = false;
     if (!empty($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
             $nb_answers = $answer->nbrAnswers;
         }
     }
     $form->addElement('hidden', 'nb_answers');
     $boxes_names = array();
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_answers; ++$i) {
         $form->addHtml('<tr>');
         if (is_object($answer)) {
             $defaults['answer[' . $i . ']'] = $answer->answer[$i];
             $defaults['comment[' . $i . ']'] = $answer->comment[$i];
             $defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1);
             $defaults['correct[' . $i . ']'] = $answer->correct[$i];
         } else {
             $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2');
             $defaults['comment[1]'] = get_lang('DefaultMultipleComment2');
             $defaults['correct[1]'] = true;
             $defaults['weighting[1]'] = 10;
             $defaults['answer[2]'] = get_lang('DefaultMultipleAnswer1');
             $defaults['comment[2]'] = get_lang('DefaultMultipleComment1');
             $defaults['correct[2]'] = false;
         }
         $renderer =& $form->defaultRenderer();
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']');
         $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
         $answer_number->freeze();
         $form->addElement('checkbox', 'correct[' . $i . ']', null, null, 'class="checkbox" style="margin-left: 0em;"');
         $boxes_names[] = 'correct[' . $i . ']';
         $form->addElement('html_editor', 'answer[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
         $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required');
         $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
         $form->addHtml('</tr>');
     }
     $form->addElement('html', '</tbody></table>');
     $form->add_multiple_required_rule($boxes_names, get_lang('ChooseAtLeastOneCheckbox'), 'multiple_required');
     //only 1 answer the all deal ...
     $form->addText('weighting[1]', get_lang('Score'), false, ['value' => 10]);
     global $text;
     //ie6 fix
     if ($obj_ex->edit_exercise_in_lp == true) {
         // setting the save button here and not in the question class.php
         $buttonGroup = [$form->addButtonDelete(get_lang('LessAnswer'), 'lessAnswers', true), $form->addButtonCreate(get_lang('PlusAnswer'), 'moreAnswers', true), $form->addButtonSave($text, 'submitQuestion', true)];
         $form->addGroup($buttonGroup);
     }
     $defaults['correct'] = $correct;
     if (!empty($this->id)) {
         $form->setDefaults($defaults);
     } else {
         if ($this->isContent == 1) {
             $form->setDefaults($defaults);
         }
     }
     $form->setConstants(array('nb_answers' => $nb_answers));
 }
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:88,代码来源:multiple_answer_combination.class.php

示例6: generate_settings_form


//.........这里部分代码省略.........
                break;
            case 'radio':
                $values = api_get_settings_options($row['variable']);
                $group = array();
                if (is_array($values)) {
                    foreach ($values as $key => $value) {
                        $element =& $form->createElement('radio', $row['variable'], '', get_lang($value['display_text']), $value['value']);
                        if ($hide_element) {
                            $element->freeze();
                        }
                        $group[] = $element;
                    }
                }
                $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '', false);
                $default_values[$row['variable']] = $row['selected_value'];
                break;
            case 'checkbox':
                // 1. We collect all the options of this variable.
                $sql = "SELECT * FROM {$table_settings_current}\n                        WHERE variable='" . $row['variable'] . "' AND access_url =  1";
                $result = Database::query($sql);
                $group = array();
                while ($rowkeys = Database::fetch_array($result)) {
                    // Profile tab option should be hidden when the social tool is enabled.
                    if (api_get_setting('social.allow_social_tool') == 'true') {
                        if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_profile') {
                            continue;
                        }
                    }
                    // Hiding the gradebook option.
                    if ($rowkeys['variable'] == 'show_tabs' && $rowkeys['subkey'] == 'my_gradebook') {
                        continue;
                    }
                    $element =& $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
                    if ($row['access_url_changeable'] == 1) {
                        // 2. We look into the DB if there is a setting for a specific access_url.
                        $access_url = $_configuration['access_url'];
                        if (empty($access_url)) {
                            $access_url = 1;
                        }
                        $sql = "SELECT selected_value FROM {$table_settings_current}\n                                WHERE\n                                    variable='" . $rowkeys['variable'] . "' AND\n                                    subkey='" . $rowkeys['subkey'] . "' AND\n                                    subkeytext='" . $rowkeys['subkeytext'] . "' AND\n                                    access_url =  {$access_url}";
                        $result_access = Database::query($sql);
                        $row_access = Database::fetch_array($result_access);
                        if ($row_access['selected_value'] == 'true' && !$form->isSubmitted()) {
                            $element->setChecked(true);
                        }
                    } else {
                        if ($rowkeys['selected_value'] == 'true' && !$form->isSubmitted()) {
                            $element->setChecked(true);
                        }
                    }
                    if ($hide_element) {
                        $element->freeze();
                    }
                    $group[] = $element;
                }
                $form->addGroup($group, $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), '');
                break;
            case 'link':
                $form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue') . ' : ' . $row['selected_value'], $hideme);
                break;
            case 'select':
                /*
                 * To populate the list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed.
                 * The functions being called must be added to the file settings.lib.php.
                 */
                $form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_' . $row['variable']), $hideme);
                $default_values[$row['variable']] = $row['selected_value'];
                break;
            case 'custom':
                break;
        }
        switch ($row['variable']) {
            case 'pdf_export_watermark_enable':
                $url = PDF::get_watermark(null);
                if ($url != false) {
                    $delete_url = '<a href="?delete_watermark">' . get_lang('DelImage') . ' ' . Display::return_icon('delete.png', get_lang('DelImage')) . '</a>';
                    $form->addElement('html', '<div style="max-height:100px; max-width:100px; margin-left:162px; margin-bottom:10px; clear:both;"><img src="' . $url . '" style="margin-bottom:10px;" />' . $delete_url . '</div>');
                }
                $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
                $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif');
                $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types);
                break;
            case 'timezone_value':
                $timezone = $row['selected_value'];
                if (empty($timezone)) {
                    $timezone = _api_get_timezone();
                }
                $form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
                break;
        }
    }
    // end for
    if (!empty($settings)) {
        $form->setDefaults($default_values);
    }
    $form->addHtml('<div class="bottom_actions">');
    $form->addButtonSave(get_lang('SaveSettings'));
    $form->addHtml('</div>');
    return $form;
}
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:101,代码来源:settings.lib.php

示例7: createAnswersForm

 /**
  * Function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 public function createAnswersForm($form)
 {
     $defaults = array();
     $nb_matches = $nb_options = 2;
     $matches = array();
     $answer = null;
     if ($form->isSubmitted()) {
         $nb_matches = $form->getSubmitValue('nb_matches');
         $nb_options = $form->getSubmitValue('nb_options');
         if (isset($_POST['lessMatches'])) {
             $nb_matches--;
         }
         if (isset($_POST['moreMatches'])) {
             $nb_matches++;
         }
         if (isset($_POST['lessOptions'])) {
             $nb_options--;
         }
         if (isset($_POST['moreOptions'])) {
             $nb_options++;
         }
     } else {
         if (!empty($this->id)) {
             $answer = new Answer($this->id);
             $answer->read();
             if (count($answer->nbrAnswers) > 0) {
                 $nb_matches = $nb_options = 0;
                 for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                     if ($answer->isCorrect($i)) {
                         $nb_matches++;
                         $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
                         $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
                         $answerInfo = $answer->getAnswerByAutoId($answer->correct[$i]);
                         $defaults['matches[' . $nb_matches . ']'] = isset($answerInfo['answer']) ? $answerInfo['answer'] : '';
                     } else {
                         $nb_options++;
                         $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
                     }
                 }
             }
         } else {
             $defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1');
             $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
             $defaults['matches[2]'] = '2';
             $defaults['option[1]'] = get_lang('DefaultMatchingOptA');
             $defaults['option[2]'] = get_lang('DefaultMatchingOptB');
         }
     }
     for ($i = 1; $i <= $nb_matches; ++$i) {
         $matches[$i] = $i;
     }
     $form->addElement('hidden', 'nb_matches', $nb_matches);
     $form->addElement('hidden', 'nb_options', $nb_options);
     // DISPLAY MATCHES
     $html = '<table class="table table-striped table-hover">
         <thead>
             <tr>
                 <th width="85%">' . get_lang('Answer') . '</th>
                 <th width="15%">' . get_lang('MatchesTo') . '</th>
                 <th width="10">' . get_lang('Weighting') . '</th>
             </tr>
         </thead>
         <tbody>';
     $form->addHeader(get_lang('MakeCorrespond'));
     $form->addHtml($html);
     if ($nb_matches < 1) {
         $nb_matches = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     for ($i = 1; $i <= $nb_matches; ++$i) {
         $renderer =& $form->defaultRenderer();
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "answer[{$i}]");
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "matches[{$i}]");
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->{element}</td>', "weighting[{$i}]");
         $form->addHtml('<tr>');
         $form->addText("answer[{$i}]", null);
         $form->addSelect("matches[{$i}]", null, $matches);
         $form->addText("weighting[{$i}]", null, true, ['value' => 10, 'style' => 'width: 60px;']);
         $form->addHtml('</tr>');
     }
     $form->addHtml('</tbody></table>');
     $renderer->setElementTemplate('<div class="form-group"><div class="col-sm-offset-2">{element}', 'lessMatches');
     $renderer->setElementTemplate('{element}</div></div>', 'moreMatches');
     global $text;
     $group = [$form->addButtonDelete(get_lang('DelElem'), 'lessMatches', true), $form->addButtonCreate(get_lang('AddElem'), 'moreMatches', true), $form->addButtonSave($text, 'submitQuestion', true)];
     $form->addGroup($group);
     if (!empty($this->id)) {
         $form->setDefaults($defaults);
     } else {
         if ($this->isContent == 1) {
             $form->setDefaults($defaults);
         }
     }
     $form->setConstants(['nb_matches' => $nb_matches, 'nb_options' => $nb_options]);
 }
开发者ID:omaoibrahim,项目名称:chamilo-lms,代码行数:99,代码来源:Draggable.php

示例8: array

     //1. we collect all the options of this variable
     $sql = "SELECT * FROM settings_current WHERE variable='" . $row['variable'] . "' AND access_url =  1";
     $result = api_sql_query($sql, __FILE__, __LINE__);
     $group = array();
     while ($rowkeys = Database::fetch_array($result)) {
         $element =& $form->createElement('checkbox', $rowkeys['subkey'], '', get_lang($rowkeys['subkeytext']));
         if ($row['access_url_changeable'] == 1) {
             //2. we look into the DB if there is a setting for a specific access_url
             $access_url = $_configuration['access_url'];
             if (empty($access_url)) {
                 $access_url = 1;
             }
             $sql = "SELECT selected_value FROM settings_current WHERE variable='" . $rowkeys['variable'] . "' AND subkey='" . $rowkeys['subkey'] . "'  AND  subkeytext='" . $rowkeys['subkeytext'] . "' AND access_url =  {$access_url}";
             $result_access = api_sql_query($sql, __FILE__, __LINE__);
             $row_access = Database::fetch_array($result_access);
             if ($row_access['selected_value'] == 'true' && !$form->isSubmitted()) {
                 $element->setChecked(true);
             }
         } else {
             if ($rowkeys['selected_value'] == 'true' && !$form->isSubmitted()) {
                 $element->setChecked(true);
             }
         }
         if ($hide_element) {
             $element->freeze();
         }
         $group[] = $element;
     }
     $form->addGroup($group, $row['variable'], get_lang($row['comment']), '<br />' . "\n");
     break;
 case "link":
开发者ID:RusticiSoftware,项目名称:SCORMCloud_DokeosMod,代码行数:31,代码来源:settings.php

示例9: createAnswersForm

 /**
  * function which redefines Question::createAnswersForm
  * @param FormValidator $form
  */
 public function createAnswersForm($form)
 {
     $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4;
     // The previous default value was 2. See task #1759.
     $nb_answers += isset($_POST['lessAnswers']) ? -1 : isset($_POST['moreAnswers']) ? 1 : 0;
     $course_id = api_get_course_int_id();
     $obj_ex = $_SESSION['objExercise'];
     $renderer =& $form->defaultRenderer();
     $defaults = array();
     $html = '<table class="table table-striped table-hover">';
     $html .= '<thead>';
     $html .= '<tr>';
     $html .= '<th>' . get_lang('Number') . '</th>';
     $html .= '<th>' . get_lang('True') . '</th>';
     $html .= '<th>' . get_lang('False') . '</th>';
     $html .= '<th>' . get_lang('Answer') . '</th>';
     // show column comment when feedback is enable
     if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
         $html .= '<th>' . get_lang('Comment') . '</th>';
     }
     $html .= '</tr>';
     $html .= '</thead>';
     $html .= '<tbody>';
     $form->addHeader(get_lang('Answers'));
     $form->addHtml($html);
     $correct = 0;
     $answer = null;
     if (!empty($this->id)) {
         $answer = new Answer($this->id);
         $answer->read();
         if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) {
             $nb_answers = $answer->nbrAnswers;
         }
     }
     $form->addElement('hidden', 'nb_answers');
     $boxes_names = array();
     if ($nb_answers < 1) {
         $nb_answers = 1;
         Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
     }
     // Can be more options
     $option_data = Question::readQuestionOption($this->id, $course_id);
     for ($i = 1; $i <= $nb_answers; ++$i) {
         $form->addHtml('<tr>');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']');
         $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']');
         $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"');
         $answer_number->freeze();
         if (is_object($answer)) {
             $defaults['answer[' . $i . ']'] = $answer->answer[$i];
             $defaults['comment[' . $i . ']'] = $answer->comment[$i];
             $correct = $answer->correct[$i];
             $defaults['correct[' . $i . ']'] = $correct;
             $j = 1;
             if (!empty($option_data)) {
                 foreach ($option_data as $id => $data) {
                     $form->addElement('radio', 'correct[' . $i . ']', null, null, $id);
                     $j++;
                     if ($j == 3) {
                         break;
                     }
                 }
             }
         } else {
             $form->addElement('radio', 'correct[' . $i . ']', null, null, 1);
             $form->addElement('radio', 'correct[' . $i . ']', null, null, 2);
             $defaults['answer[' . $i . ']'] = '';
             $defaults['comment[' . $i . ']'] = '';
             $defaults['correct[' . $i . ']'] = '';
         }
         $boxes_names[] = 'correct[' . $i . ']';
         $form->addHtmlEditor("answer[{$i}]", get_lang('ThisFieldIsRequired'), true, true, ['ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100']);
         // show comment when feedback is enable
         if ($obj_ex->selectFeedbackType() != EXERCISE_FEEDBACK_TYPE_EXAM) {
             $form->addElement('html_editor', 'comment[' . $i . ']', null, array(), array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '100'));
         }
         $form->addHtml('</tr>');
     }
     $form->addHtml('</tbody></table>');
     $correctInputTemplate = '<div class="form-group">';
     $correctInputTemplate .= '<label class="col-sm-2 control-label">';
     $correctInputTemplate .= '<span class="form_required">*</span>' . get_lang('Score');
     $correctInputTemplate .= '</label>';
     $correctInputTemplate .= '<div class="col-sm-8">';
     $correctInputTemplate .= '<table>';
     $correctInputTemplate .= '<tr>';
     $correctInputTemplate .= '<td>';
     $correctInputTemplate .= get_lang('Correct') . '{element}';
     $correctInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
     $correctInputTemplate .= '</td>';
     $wrongInputTemplate = '<td>';
     $wrongInputTemplate .= get_lang('Wrong') . '{element}';
     $wrongInputTemplate .= '<!-- BEGIN error --><span class="form_error">{error}</span><!-- END error -->';
     $wrongInputTemplate .= '</td>';
//.........这里部分代码省略.........
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:101,代码来源:multiple_answer_true_false.class.php

示例10: createAnswersForm

    /**
     * function which redefines Question::createAnswersForm
     * @param FormValidator $form
     */
    public function createAnswersForm($form)
    {
        $defaults = array();
        $navigator_info = api_get_navigator();
        $nb_matches = $nb_options = 2;
        if ($form->isSubmitted()) {
            $nb_matches = $form->getSubmitValue('nb_matches');
            $nb_options = $form->getSubmitValue('nb_options');
            if (isset($_POST['lessMatches'])) {
                $nb_matches--;
            }
            if (isset($_POST['moreMatches'])) {
                $nb_matches++;
            }
            if (isset($_POST['lessOptions'])) {
                $nb_options--;
            }
            if (isset($_POST['moreOptions'])) {
                $nb_options++;
            }
        } else {
            if (!empty($this->id)) {
                $answer = new Answer($this->id);
                $answer->read();
                if (count($answer->nbrAnswers) > 0) {
                    $a_matches = $a_options = array();
                    $nb_matches = $nb_options = 0;
                    for ($i = 1; $i <= $answer->nbrAnswers; $i++) {
                        if ($answer->isCorrect($i)) {
                            $nb_matches++;
                            $defaults['answer[' . $nb_matches . ']'] = $answer->selectAnswer($i);
                            $defaults['weighting[' . $nb_matches . ']'] = float_format($answer->selectWeighting($i), 1);
                            $defaults['matches[' . $nb_matches . ']'] = $answer->correct[$i];
                        } else {
                            $nb_options++;
                            $defaults['option[' . $nb_options . ']'] = $answer->selectAnswer($i);
                        }
                    }
                }
            } else {
                $defaults['answer[1]'] = get_lang('DefaultMakeCorrespond1');
                $defaults['answer[2]'] = get_lang('DefaultMakeCorrespond2');
                $defaults['matches[2]'] = '2';
                $defaults['option[1]'] = get_lang('DefaultMatchingOptA');
                $defaults['option[2]'] = get_lang('DefaultMatchingOptB');
            }
        }
        $a_matches = array();
        for ($i = 1; $i <= $nb_options; ++$i) {
            $a_matches[$i] = chr(64 + $i);
            // fill the array with A, B, C.....
        }
        $form->addElement('hidden', 'nb_matches', $nb_matches);
        $form->addElement('hidden', 'nb_options', $nb_options);
        // DISPLAY MATCHES
        $html = '<table class="data_table">
					<tr>
						<th width="10px">
							' . get_lang('Number') . '
						</th>
						<th width="40%">
							' . get_lang('Answer') . '
						</th>
						<th width="40%">
							' . get_lang('MatchesTo') . '
						</th>
						<th width="50px">
							' . get_lang('Weighting') . '
						</th>
					</tr>';
        $form->addElement('label', get_lang('MakeCorrespond') . '<br /> <img src="../img/fill_field.png">', $html);
        if ($nb_matches < 1) {
            $nb_matches = 1;
            Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer'));
        }
        for ($i = 1; $i <= $nb_matches; ++$i) {
            $form->addElement('html', '<tr><td>');
            $group = array();
            $puce = $form->createElement('text', null, null, 'value="' . $i . '"');
            $puce->freeze();
            $group[] = $puce;
            $group[] = $form->createElement('text', 'answer[' . $i . ']', null, 'size="60" style="margin-left: 0em;"');
            $group[] = $form->createElement('select', 'matches[' . $i . ']', null, $a_matches);
            $group[] = $form->createElement('text', 'weighting[' . $i . ']', null, array('class' => 'span1', 'value' => 10));
            $form->addGroup($group, null, null, '</td><td>');
            $form->addElement('html', '</td></tr>');
        }
        $form->addElement('html', '</table></div></div>');
        $group = array();
        if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
            $group[] = $form->createElement('submit', 'lessMatches', get_lang('DelElem'), 'class="btn minus"');
            $group[] = $form->createElement('submit', 'moreMatches', get_lang('AddElem'), 'class="btn plus"');
        } else {
            $group[] = $form->createElement('style_submit_button', 'moreMatches', get_lang('AddElem'), 'class="btn plus"');
            $group[] = $form->createElement('style_submit_button', 'lessMatches', get_lang('DelElem'), 'class="btn minus"');
        }
//.........这里部分代码省略.........
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:101,代码来源:matching.class.php


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