Permalink
Browse files

Merge branch 'master' into install_master

  • Loading branch information...
2 parents 00db87a + fe41ba7 commit 967bc47c80346cf6280f2a1385fc50df926cde36 AMOS bot committed Nov 19, 2011
Showing with 356 additions and 104 deletions.
  1. +8 −1 backup/moodle2/restore_stepslib.php
  2. +17 −0 lib/db/upgrade.php
  3. +7 −2 lib/moodlelib.php
  4. +2 −10 lib/questionlib.php
  5. +2 −2 lib/simpletest/testcompletionlib.php
  6. +1 −1 mod/assignment/lib.php
  7. +2 −1 mod/forum/lib.php
  8. +8 −1 mod/quiz/attemptlib.php
  9. +4 −4 mod/quiz/editlib.php
  10. +56 −15 mod/quiz/grade.php
  11. +1 −1 mod/quiz/module.js
  12. +9 −1 mod/quiz/report/attemptsreport.php
  13. +1 −1 mod/quiz/startattempt.php
  14. +8 −1 mod/quiz/styles.css
  15. +1 −1 mod/quiz/summary.php
  16. +1 −1 mod/scorm/lib.php
  17. +4 −0 mod/wiki/styles.css
  18. +2 −2 question/behaviour/adaptive/behaviour.php
  19. +21 −3 question/behaviour/behaviourbase.php
  20. +2 −2 question/behaviour/deferredfeedback/behaviour.php
  21. +2 −2 question/behaviour/immediatefeedback/behaviour.php
  22. +2 −2 question/behaviour/informationitem/behaviour.php
  23. +2 −2 question/behaviour/interactive/behaviour.php
  24. +2 −2 question/behaviour/interactivecountback/behaviour.php
  25. +3 −2 question/behaviour/missing/behaviour.php
  26. +6 −1 question/behaviour/upgrade.txt
  27. +1 −1 question/editlib.php
  28. +36 −27 question/engine/datalib.php
  29. +49 −0 question/renderer.php
  30. +3 −3 question/type/edit_question_form.php
  31. +1 −1 question/type/numerical/edit_numerical_form.php
  32. +4 −3 question/type/numerical/questiontype.php
  33. +69 −0 theme/base/style/core.css
  34. +1 −1 theme/base/style/course.css
  35. +3 −3 theme/mymobile/renderers.php
  36. +2 −0 theme/standard/style/core.css
  37. +2 −2 version.php
  38. +11 −2 webservice/renderer.php
@@ -802,7 +802,14 @@ public function process_grouping_group($data) {
$data->groupingid = $this->get_new_parentid('grouping'); // Use new parentid
$data->groupid = $this->get_mappingid('group', $data->groupid); // Get from mappings
- $DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
+
+ $params = array();
+ $params['groupingid'] = $data->groupingid;
+ $params['groupid'] = $data->groupid;
+
+ if (!$DB->record_exists('groupings_groups', $params)) {
+ $DB->insert_record('groupings_groups', $data); // No need to set this mapping (no child info nor files)
+ }
}
protected function after_execute() {
View
@@ -6916,6 +6916,23 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2011110200.02);
}
+ if ($oldversion < 2011111500.01) {
+ upgrade_set_timeout(60*20); // this may take a while
+ // Remove duplicate entries from groupings_groups table
+ $sql = 'SELECT MIN(id) AS firstid, groupingid, groupid FROM {groupings_groups} '.
+ 'GROUP BY groupingid, groupid HAVING COUNT(id)>1';
+ $badrs = $DB->get_recordset_sql($sql);
+ foreach ($badrs as $badrec) {
+ $where = 'groupingid = ? and groupid = ? and id > ?';
+ $params = array($badrec->groupingid, $badrec->groupid, $badrec->firstid);
+ $DB->delete_records_select('groupings_groups', $where, $params);
+ }
+ $badrs->close();
+
+ // Main savepoint reached
+ upgrade_main_savepoint(true, 2011111500.01);
+ }
+
return true;
}
View
@@ -8725,12 +8725,17 @@ function generate_password($maxlen=10) {
$filler1 = $fillers[rand(0, strlen($fillers) - 1)];
$password = $word1 . $filler1 . $word2;
} else {
- $maxlen = !empty($CFG->minpasswordlength) ? $CFG->minpasswordlength : 0;
+ $minlen = !empty($CFG->minpasswordlength) ? $CFG->minpasswordlength : 0;
$digits = $CFG->minpassworddigits;
$lower = $CFG->minpasswordlower;
$upper = $CFG->minpasswordupper;
$nonalphanum = $CFG->minpasswordnonalphanum;
- $additional = $maxlen - ($lower + $upper + $digits + $nonalphanum);
+ $total = $lower + $upper + $digits + $nonalphanum;
+ // minlength should be the greater one of the two ( $minlen and $total )
+ $minlen = $minlen < $total ? $total : $minlen;
+ // maxlen can never be smaller than minlen
+ $maxlen = $minlen > $maxlen ? $minlen : $maxlen;
+ $additional = $maxlen - $total;
// Make sure we have enough characters to fulfill
// complexity requirements
View
@@ -825,16 +825,8 @@ function get_question_options(&$questions, $loadtags = false) {
* @return string the HTML for the img tag.
*/
function print_question_icon($question) {
- global $OUTPUT;
-
- $qtype = question_bank::get_qtype($question->qtype, false);
- $namestr = $qtype->menu_name();
-
- // TODO convert to return a moodle_icon object, or whatever the class is.
- $html = '<img src="' . $OUTPUT->pix_url('icon', $qtype->plugin_name()) . '" alt="' .
- $namestr . '" title="' . $namestr . '" />';
-
- return $html;
+ global $PAGE;
+ return $PAGE->get_renderer('question', 'bank')->qtype_icon($question->qtype);
}
/**
@@ -527,7 +527,7 @@ function test_get_progress_all() {
$c->__construct((object)array('id'=>42));
// 1) Basic usage
- $c->expectAt(0,'get_tracked_users',array(false, array(), 0, '', '', ''));
+ $c->expectAt(0,'get_tracked_users',array(false, array(), 0, '', '', '', null));
$c->setReturnValueAt(0,'get_tracked_users',array(
(object)array('id'=>100,'firstname'=>'Woot','lastname'=>'Plugh'),
(object)array('id'=>201,'firstname'=>'Vroom','lastname'=>'Xyzzy'),
@@ -556,7 +556,7 @@ function test_get_progress_all() {
),$c->get_progress_all(false));
// 2) With more than 1,000 results
- $c->expectAt(1,'get_tracked_users',array(true, 3, 0, '', '', ''));
+ $c->expectAt(1,'get_tracked_users',array(true, 3, 0, '', '', '', null));
$tracked=array();
$ids=array();
@@ -3540,7 +3540,7 @@ function assignment_get_coursemodule_info($coursemodule) {
}
if ($coursemodule->showdescription) {
// Convert intro to html. Do not filter cached version, filters run at display time.
- $info->content = format_module_intro('assignment', $assignment, $coursemodule->id, false);
+ $result->content = format_module_intro('assignment', $assignment, $coursemodule->id, false);
}
return $result;
} else {
View
@@ -5943,8 +5943,9 @@ function forum_tp_mark_posts_read($user, $postids) {
if ($new) {
list($usql, $new_params) = $DB->get_in_or_equal($new);
- $params = array($user->id, $now, $now, $user->id, $cutoffdate);
+ $params = array($user->id, $now, $now, $user->id);
$params = array_merge($params, $new_params);
+ $params[] = $cutoffdate;
$sql = "INSERT INTO {forum_read} (userid, postid, discussionid, forumid, firstread, lastread)
@@ -418,10 +418,17 @@ class quiz_attempt {
* @param object $quiz the quiz object for this attempt and user.
* @param object $cm the course_module object for this quiz.
* @param object $course the row from the course table for the course we belong to.
+ * @param bool $loadquestions (optional) if true, the default, load all the details
+ * of the state of each question. Else just set up the basic details of the attempt.
*/
- public function __construct($attempt, $quiz, $cm, $course) {
+ public function __construct($attempt, $quiz, $cm, $course, $loadquestions = true) {
$this->attempt = $attempt;
$this->quizobj = new quiz($quiz, $cm, $course);
+
+ if (!$loadquestions) {
+ return;
+ }
+
$this->quba = question_engine::load_questions_usage_by_activity($this->attempt->uniqueid);
$this->determine_layout();
$this->number_questions();
@@ -781,7 +781,7 @@ function quiz_print_singlequestion($question, $returnurl, $quiz) {
echo quiz_question_edit_button($quiz->cmid, $question, $returnurl,
quiz_question_tostring($question) . ' ');
echo '<span class="questiontype">';
- print_question_icon($question);
+ echo print_question_icon($question);
echo ' ' . question_bank::get_qtype_name($question->qtype) . '</span>';
echo '<span class="questionpreview">' .
quiz_question_preview_button($quiz, $question, true) . '</span>';
@@ -807,7 +807,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
}
echo '<div class="randomquestionfromcategory">';
- print_question_icon($question);
+ echo print_question_icon($question);
print_random_option_icon($question);
echo ' ' . get_string('randomfromcategory', 'quiz') . '</div>';
@@ -886,7 +886,7 @@ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktoo
function quiz_print_singlequestion_reordertool($question, $returnurl, $quiz) {
echo '<div class="singlequestion">';
echo '<label for="s' . $question->id . '">';
- print_question_icon($question);
+ echo print_question_icon($question);
echo ' ' . quiz_question_tostring($question);
echo '</label>';
echo '<span class="questionpreview">' .
@@ -920,7 +920,7 @@ function quiz_print_randomquestion_reordertool(&$question, &$pageurl, &$quiz) {
echo '<div class="quiz_randomquestion">';
echo '<div class="randomquestionfromcategory">';
echo $reordercheckboxlabel;
- print_question_icon($question);
+ echo print_question_icon($question);
print_random_option_icon($question);
if ($questioncount == 0) {
View
@@ -26,27 +26,68 @@
require_once(dirname(__FILE__) . '/../../config.php');
+require_once($CFG->dirroot . '/mod/quiz/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
$id = required_param('id', PARAM_INT);
+$userid = optional_param('userid', 0, PARAM_INT);
-if (!$cm = get_coursemodule_from_id('quiz', $id)) {
- print_error('invalidcoursemodule');
-}
-if (!$quiz = $DB->get_record('quiz', array('id' => $cm->instance))) {
- print_error('invalidquizid');
-}
-if (!$course = $DB->get_record('course', array('id' => $quiz->course))) {
- print_error('coursemisconf');
+$cm = get_coursemodule_from_id('quiz', $id, 0, false, MUST_EXIST);
+$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+$quiz = $DB->get_record('quiz', array('id' => $cm->instance), '*', MUST_EXIST);
+require_login($course, false, $cm);
+
+$reportlist = quiz_report_list(context_module::instance($cm->id));
+if (empty($reportlist) || $userid == $USER->id) {
+ // If the user cannot see reports, or can see reports but is looking
+ // at their own grades, redirect them to the view.php page.
+ // (The looking at their own grades case is unlikely, since users who
+ // appear in the gradebook are unlikely to be able to see quiz reports,
+ // but it is possible.)
+ redirect(new moodle_url('/mod/quiz/view.php', array('id' => $cm->id)));
}
-require_login($course, false, $cm);
+// Now we know the user is interested in reports. If they are interested in a
+// specific other user, try to send them to the most appropriate attempt review page.
+if ($userid) {
-$reportlist = quiz_report_list(get_context_instance(CONTEXT_MODULE, $cm->id));
-if (!empty($reportlist)) {
- redirect(new moodle_url('/mod/quiz/report.php', array(
- 'id' => $cm->id, 'mode' => reset($reportlist))));
-} else {
- redirect(new moodle_url('/mod/quiz/view.php', array('id' => $cm->id)));
+ // Work out which attempt is most significant from a grading point of view.
+ $attempts = quiz_get_user_attempts($quiz->id, $userid, 'finished');
+ $attempt = null;
+ switch ($quiz->grademethod) {
+ case QUIZ_ATTEMPTFIRST:
+ $attempt = reset($attempts);
+ break;
+
+ case QUIZ_ATTEMPTLAST:
+ case QUIZ_GRADEAVERAGE:
+ $attempt = end($attempts);
+ break;
+
+ case QUIZ_GRADEHIGHEST:
+ $maxmark = 0;
+ foreach ($attempts as $at) {
+ // >=, since we want to most recent relevant attempt.
+ if ((float) $at->sumgrades >= $maxmark) {
+ $maxmark = $at->sumgrades;
+ $attempt = $at;
+ }
+ }
+ break;
+ }
+
+ // If the user can review the relevant attempt, redirect to it.
+ if ($attempt) {
+ $attemptobj = new quiz_attempt($attempt, $quiz, $cm, $course, false);
+ if ($attemptobj->is_review_allowed()) {
+ redirect($attemptobj->review_url());
+ }
+ }
+
+ // Otherwise, fall thorugh to the generic case.
}
+
+// Send the user to the first report they can see.
+redirect(new moodle_url('/mod/quiz/report.php', array(
+ 'id' => $cm->id, 'mode' => reset($reportlist))));
View
@@ -170,7 +170,7 @@ M.mod_quiz.nav.init = function(Y) {
if (Y.one('a.endtestlink')) {
Y.on('click', function(e) {
- e.preventDefault(e);
+ e.preventDefault();
Y.one('#followingpage').set('value', -1);
Y.one('#responseform').submit();
}, 'a.endtestlink');
@@ -621,13 +621,21 @@ protected function add_latest_state_join($slot) {
return;
}
+ // This condition roughly filters the list of attempts to be considered.
+ // It is only used in a subselect to help crappy databases (see MDL-30122)
+ // therefore, it is better to use a very simple join, which may include
+ // too many records, than to do a super-accurate join.
+ $qubaids = new qubaid_join("{quiz_attempts} {$alias}quiza", "{$alias}quiza.uniqueid",
+ "{$alias}quiza.quiz = :{$alias}quizid", array("{$alias}quizid" => $this->sql->params['quizid']));
+
$dm = new question_engine_data_mapper();
- $inlineview = $dm->question_attempt_latest_state_view($alias);
+ list($inlineview, $viewparams) = $dm->question_attempt_latest_state_view($alias, $qubaids);
$this->sql->fields .= ",\n$fields";
$this->sql->from .= "\nLEFT JOIN $inlineview ON " .
"$alias.questionusageid = quiza.uniqueid AND $alias.slot = :{$alias}slot";
$this->sql->params[$alias . 'slot'] = $slot;
+ $this->sql->params = array_merge($this->sql->params, $viewparams);
}
/**
@@ -101,7 +101,7 @@
$output = $PAGE->get_renderer('mod_quiz');
if (!$quizobj->is_preview_user() && $messages) {
print_error('attempterror', 'quiz', $quizobj->view_url(),
- $output->print_messages($messages));
+ $output->access_messages($messages));
}
if ($accessmanager->is_preflight_check_required($currentattemptid)) {
View
@@ -96,6 +96,13 @@ div.editq div.question div.content .singlequestion a .questiontext{text-decorati
#page-mod-quiz-mod #reviewoptionshdr fieldset.fgroup span label,
#adminquizreviewoptions span label {margin-left: 0.4em;}
+#page-mod-quiz-mod.dir-rtl #reviewoptionshdr .fitem,
+#adminquizreviewoptions .group {float: right; width: 24%;}
+#page-mod-quiz-mod.dir-rtl #reviewoptionshdr fieldset.fgroup span,
+#adminquizreviewoptions span {float: right; clear: right;}
+#page-mod-quiz-mod.dir-rtl #reviewoptionshdr .fitemtitle,
+#adminquizreviewoptions .fitemtitle {text-align: right;}
+
/** Mod quiz view **/
#page-mod-quiz-view .quizinfo,
#page-mod-quiz-view #page .quizgradefeedback,
@@ -377,4 +384,4 @@ bank window's title is prominent enough*/
.qnum label {padding-right: 0.25em;}
/** settings.php */
-#adminquizreviewoptions {margin-bottom: 0.5em;}
+#adminquizreviewoptions {margin-bottom: 0.5em;}
@@ -61,7 +61,7 @@
$output = $PAGE->get_renderer('mod_quiz');
if (!$attemptobj->is_preview_user() && $messages) {
print_error('attempterror', 'quiz', $attemptobj->view_url(),
- $output->print_messages($messages));
+ $output->access_messages($messages));
}
if ($accessmanager->is_preflight_check_required($attemptobj->get_attemptid())) {
redirect($attemptobj->start_attempt_url(null, $page));
View
@@ -510,7 +510,7 @@ function scorm_cron () {
$cfg_scorm = get_config('scorm');
if (!empty($cfg_scorm->allowaicchacp)) {
$expiretime = time() - ($cfg_scorm->aicchacpkeepsessiondata*24*60*60);
- $DB->delete_records_select('scorm_aicc_session', 'WHERE timemodified < ?', array($expiretime));
+ $DB->delete_records_select('scorm_aicc_session', 'timemodified < ?', array($expiretime));
}
}
View
@@ -171,6 +171,10 @@
float: right;
}
+.dir-rtl .wiki_diffuserleft {
+ float: left;
+}
+
.wiki_diffuserright {
float: left;
}
@@ -38,8 +38,8 @@
class qbehaviour_adaptive extends question_behaviour_with_save {
const IS_ARCHETYPAL = true;
- public function required_question_definition_type() {
- return 'question_automatically_gradable';
+ public function is_compatible_question(question_definition $question) {
+ return $question instanceof question_automatically_gradable;
}
public function get_expected_data() {
Oops, something went wrong. Retry.

0 comments on commit 967bc47

Please sign in to comment.