Merge branch 'MDL-53140-master' of git://github.com/rezaies/moodle
authorAdrian Greeve <abgreeve@gmail.com>
Wed, 1 May 2019 02:30:22 +0000 (10:30 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Wed, 1 May 2019 02:30:22 +0000 (10:30 +0800)
1  2 
lib/formslib.php
lib/questionlib.php

diff --combined lib/formslib.php
@@@ -163,8 -163,6 +163,8 @@@ abstract class moodleform 
       * @param string $target target frame for form submission. You will rarely use this. Don't use
       *               it if you don't need to as the target attribute is deprecated in xhtml strict.
       * @param mixed $attributes you can pass a string of html attributes here or an array.
 +     *               Special attribute 'data-random-ids' will randomise generated elements ids. This
 +     *               is necessary when there are several forms on the same page.
       * @param bool $editable
       * @param array $ajaxformdata Forms submitted via ajax, must pass their data here, instead of relying on _GET and _POST.
       */
                              $params = array_merge(array($realelementname), $params);
                              call_user_func_array(array(&$mform, 'disabledIf'), $params);
                              break;
 +                        case 'hideif' :
 +                            foreach ($namecloned as $num => $name){
 +                                if ($params[0] == $name){
 +                                    $params[0] = $params[0]."[$i]";
 +                                    break;
 +                                }
 +                            }
 +                            $params = array_merge(array($realelementname), $params);
 +                            call_user_func_array(array(&$mform, 'hideIf'), $params);
 +                            break;
                          case 'rule' :
                              if (is_string($params)){
                                  $params = array(null, $params, null, 'client');
@@@ -3253,6 -3241,7 +3253,7 @@@ MoodleQuickForm::registerElementType('e
  MoodleQuickForm::registerElementType('filemanager', "$CFG->libdir/form/filemanager.php", 'MoodleQuickForm_filemanager');
  MoodleQuickForm::registerElementType('filepicker', "$CFG->libdir/form/filepicker.php", 'MoodleQuickForm_filepicker');
  MoodleQuickForm::registerElementType('filetypes', "$CFG->libdir/form/filetypes.php", 'MoodleQuickForm_filetypes');
+ MoodleQuickForm::registerElementType('float', "$CFG->libdir/form/float.php", 'MoodleQuickForm_float');
  MoodleQuickForm::registerElementType('grading', "$CFG->libdir/form/grading.php", 'MoodleQuickForm_grading');
  MoodleQuickForm::registerElementType('group', "$CFG->libdir/form/group.php", 'MoodleQuickForm_group');
  MoodleQuickForm::registerElementType('header', "$CFG->libdir/form/header.php", 'MoodleQuickForm_header');
diff --combined lib/questionlib.php
@@@ -380,11 -380,6 +380,11 @@@ function question_delete_question($ques
      // Finally delete the question record itself
      $DB->delete_records('question', array('id' => $questionid));
      question_bank::notify_question_edited($questionid);
 +
 +    // Log the deletion of this question.
 +    $event = \core\event\question_deleted::create_from_question_instance($question);
 +    $event->add_record_snapshot('question', $question);
 +    $event->trigger();
  }
  
  /**
@@@ -678,7 -673,7 +678,7 @@@ function question_move_questions_to_cat
              array('id' => $newcategoryid));
      list($questionidcondition, $params) = $DB->get_in_or_equal($questionids);
      $questions = $DB->get_records_sql("
 -            SELECT q.id, q.qtype, qc.contextid, q.idnumber
 +            SELECT q.id, q.qtype, qc.contextid, q.idnumber, q.category
                FROM {question} q
                JOIN {question_categories} qc ON q.category = qc.id
               WHERE  q.id $questionidcondition", $params);
              $q->idnumber = $question->idnumber . '_' . $unique;
              $DB->update_record('question', $q);
          }
 +
 +        // Log this question move.
 +        $event = \core\event\question_moved::create_from_question_instance($question, context::instance_by_id($question->contextid),
 +                ['oldcategoryid' => $question->category, 'newcategoryid' => $newcategoryid]);
 +        $event->trigger();
      }
  
      // Move the questions themselves.
@@@ -806,7 -796,7 +806,7 @@@ function question_preview_url($question
      }
  
      if (!is_null($maxmark)) {
-         $params['maxmark'] = $maxmark;
+         $params['maxmark'] = format_float($maxmark, strlen($maxmark), true, true);
      }
  
      if (!is_null($displayoptions)) {