Merge branch 'MDL-30484' of git://github.com/timhunt/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 31 Jan 2012 16:16:04 +0000 (17:16 +0100)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Tue, 31 Jan 2012 16:16:04 +0000 (17:16 +0100)
13 files changed:
backup/converter/moodle1/handlerlib.php
backup/moodle2/restore_stepslib.php
course/modedit.php
mod/feedback/lib.php
mod/feedback/show_entries.php
mod/forum/discuss.php
mod/forum/index.php
mod/forum/subscribe.php
mod/quiz/backup/moodle2/backup_quiz_stepslib.php
mod/quiz/module.js
mod/resource/locallib.php
mod/url/locallib.php
question/engine/upgrade/upgradelib.php

index a6b7788..f0c9754 100644 (file)
@@ -345,6 +345,8 @@ class moodle1_root_handler extends moodle1_xml_handler {
         // {@see backup_general_helper::backup_is_samesite()}
         if (isset($backupinfo['original_site_identifier_hash'])) {
             $this->xmlwriter->full_tag('original_site_identifier_hash', $backupinfo['original_site_identifier_hash']);
+        } else {
+            $this->xmlwriter->full_tag('original_site_identifier_hash', null);
         }
         $this->xmlwriter->full_tag('original_course_id', $originalcourseinfo['original_course_id']);
         $this->xmlwriter->full_tag('original_course_fullname', $originalcourseinfo['original_course_fullname']);
index 14d130a..2aebdcf 100644 (file)
@@ -371,40 +371,35 @@ class restore_gradebook_structure_step extends restore_structure_step {
         }
         $rs->close();
 
-        //need to correct the grade category path and parent
+        // Need to correct the grade category path and parent
         $conditions = array(
             'courseid' => $this->get_courseid()
         );
-        $grade_category = new stdclass();
 
         $rs = $DB->get_recordset('grade_categories', $conditions);
-        if (!empty($rs)) {
-            //get all the parents correct first as grade_category::build_path() loads category parents from the DB
-            foreach($rs as $gc) {
-                if (!empty($gc->parent)) {
-                    $grade_category->id = $gc->id;
-                    $grade_category->parent = $this->get_mappingid('grade_category', $gc->parent);
-                    $DB->update_record('grade_categories', $grade_category);
-                }
+        // Get all the parents correct first as grade_category::build_path() loads category parents from the DB
+        foreach ($rs as $gc) {
+            if (!empty($gc->parent)) {
+                $grade_category = new stdClass();
+                $grade_category->id = $gc->id;
+                $grade_category->parent = $this->get_mappingid('grade_category', $gc->parent);
+                $DB->update_record('grade_categories', $grade_category);
             }
         }
-        if (isset($grade_category->parent)) {
-            unset($grade_category->parent);
-        }
         $rs->close();
 
+        // Now we can rebuild all the paths
         $rs = $DB->get_recordset('grade_categories', $conditions);
-        if (!empty($rs)) {
-            //now we can rebuild all the paths
-            foreach($rs as $gc) {
-                $grade_category->id = $gc->id;
-                $grade_category->path = grade_category::build_path($gc);
-                $DB->update_record('grade_categories', $grade_category);
-            }
+        foreach ($rs as $gc) {
+            $grade_category = new stdClass();
+            $grade_category->id = $gc->id;
+            $grade_category->path = grade_category::build_path($gc);
+            $grade_category->depth = substr_count($grade_category->path, '/') - 1;
+            $DB->update_record('grade_categories', $grade_category);
         }
         $rs->close();
 
-        //Restore marks items as needing update. Update everything now.
+        // Restore marks items as needing update. Update everything now.
         grade_regrade_final_grades($this->get_courseid());
     }
 }
index 5865e4a..9ed3f5d 100644 (file)
@@ -316,6 +316,9 @@ if ($mform->is_cancelled()) {
         $fromform->completiongradeitemnumber = null;
     }
 
+    // the type of event to trigger (mod_created/mod_updated)
+    $eventname = '';
+
     if (!empty($fromform->update)) {
 
         if (!empty($course->groupmodeforce) or !isset($fromform->groupmode)) {
@@ -380,14 +383,7 @@ if ($mform->is_cancelled()) {
             $completion->reset_all_state($cm);
         }
 
-        // Trigger mod_updated event with information about this module.
-        $eventdata = new stdClass();
-        $eventdata->modulename = $fromform->modulename;
-        $eventdata->name       = $fromform->name;
-        $eventdata->cmid       = $fromform->coursemodule;
-        $eventdata->courseid   = $course->id;
-        $eventdata->userid     = $USER->id;
-        events_trigger('mod_updated', $eventdata);
+        $eventname = 'mod_updated';
 
         add_to_log($course->id, "course", "update mod",
                    "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
@@ -492,14 +488,7 @@ if ($mform->is_cancelled()) {
             condition_info::update_cm_from_form((object)array('id'=>$fromform->coursemodule), $fromform, false);
         }
 
-        // Trigger mod_created event with information about this module.
-        $eventdata = new stdClass();
-        $eventdata->modulename = $fromform->modulename;
-        $eventdata->name       = $fromform->name;
-        $eventdata->cmid       = $fromform->coursemodule;
-        $eventdata->courseid   = $course->id;
-        $eventdata->userid     = $USER->id;
-        events_trigger('mod_created', $eventdata);
+        $eventname = 'mod_created';
 
         add_to_log($course->id, "course", "add mod",
                    "../mod/$fromform->modulename/view.php?id=$fromform->coursemodule",
@@ -511,6 +500,15 @@ if ($mform->is_cancelled()) {
         print_error('invaliddata');
     }
 
+    // Trigger mod_created/mod_updated event with information about this module.
+    $eventdata = new stdClass();
+    $eventdata->modulename = $fromform->modulename;
+    $eventdata->name       = $fromform->name;
+    $eventdata->cmid       = $fromform->coursemodule;
+    $eventdata->courseid   = $course->id;
+    $eventdata->userid     = $USER->id;
+    events_trigger($eventname, $eventdata);
+
     // sync idnumber with grade_item
     if ($grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$fromform->modulename,
                  'iteminstance'=>$fromform->instance, 'itemnumber'=>0, 'courseid'=>$course->id))) {
index 10c033e..2fc64ce 100644 (file)
@@ -958,7 +958,7 @@ function feedback_get_complete_users($cm,
     }
 
     $ufields = user_picture::fields('u');
-    $sql = 'SELECT DISTINCT '.$ufields.'
+    $sql = 'SELECT DISTINCT '.$ufields.', c.timemodified as completed_timemodified
             FROM {user} u, {feedback_completed} c '.$fromgroup.'
             WHERE '.$where.' anonymous_response = :anon
                 AND u.id = c.userid
index 945a23a..00c3d0b 100644 (file)
@@ -122,7 +122,7 @@ if ($do_show == 'showentries') {
         $baseurl = new moodle_url('/mod/feedback/show_entries.php');
         $baseurl->params(array('id'=>$id, 'do_show'=>$do_show, 'showall'=>$showall));
 
-        $tablecolumns = array('userpic', 'fullname', 'c.timemodified');
+        $tablecolumns = array('userpic', 'fullname', 'completed_timemodified');
         $tableheaders = array(get_string('userpic'), get_string('fullnameuser'), get_string('date'));
 
         if (has_capability('mod/feedback:deletesubmissions', $context)) {
index c4c5316..382b7be 100644 (file)
         redirect($return.'&moved=-1&sesskey='.sesskey());
     }
 
-    add_to_log($course->id, 'forum', 'view discussion', $PAGE->url->out(false), $discussion->id, $cm->id);
+    add_to_log($course->id, 'forum', 'view discussion', "discuss.php?d=$discussion->id", $discussion->id, $cm->id);
 
     unset($SESSION->fromdiscussion);
 
index 0ec460b..c15b40b 100644 (file)
@@ -149,8 +149,13 @@ foreach ($modinfo->instances['forum'] as $forumid=>$cm) {
     }
 }
 
-/// Do course wide subscribe/unsubscribe
-if (!is_null($subscribe) and !isguestuser()) {
+// Do course wide subscribe/unsubscribe if requested
+if (!is_null($subscribe)) {
+    if (isguestuser() or !$can_subscribe) {
+        // there should not be any links leading to this place, just redirect
+        redirect(new moodle_url('/mod/forum/index.php', array('id' => $id)), get_string('subscribeenrolledonly', 'forum'));
+    }
+    // Can proceed now, the user is not guest and is enrolled
     foreach ($modinfo->instances['forum'] as $forumid=>$cm) {
         $forum = $forums[$forumid];
         $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
@@ -417,7 +422,8 @@ $PAGE->set_heading($course->fullname);
 $PAGE->set_button($searchform);
 echo $OUTPUT->header();
 
-if (!isguestuser() && isloggedin()) {
+// Show the subscribe all options only to non-guest, enrolled users
+if (!isguestuser() && isloggedin() && $can_subscribe) {
     echo $OUTPUT->box_start('subscription');
     echo html_writer::tag('div',
         html_writer::link(new moodle_url('/mod/forum/index.php', array('id'=>$course->id, 'subscribe'=>1, 'sesskey'=>sesskey())),
index 6cdc2f1..f722456 100644 (file)
@@ -127,6 +127,7 @@ if (forum_is_forcesubscribed($forum)) {
     redirect($returnto, get_string("everyoneisnowsubscribed", "forum"), 1);
 }
 
+$info = new stdClass();
 $info->name  = fullname($user);
 $info->forum = format_string($forum->name);
 
index a8c9e54..bcf7d20 100644 (file)
@@ -81,7 +81,7 @@ class backup_quiz_activity_structure_step extends backup_questions_activity_stru
         $attempt = new backup_nested_element('attempt', array('id'), array(
             'uniqueid', 'userid', 'attemptnum', 'sumgrades',
             'timestart', 'timefinish', 'timemodified', 'layout',
-            'preview'));
+            'preview', 'currentpage'));
 
         // This module is using questions, so produce the related question states and sessions
         // attaching them to the $attempt element based in 'uniqueid' matching
index d9d217f..63c44d6 100644 (file)
@@ -186,11 +186,11 @@ M.mod_quiz.secure_window = {
         if (window.location.href.substring(0, 4) == 'file') {
             window.location = 'about:blank';
         }
-        Y.delegate('contextmenu', M.mod_quiz.secure_window.prevent, document.body, '*');
-        Y.delegate('mousedown', M.mod_quiz.secure_window.prevent_mouse, document.body, '*');
-        Y.delegate('mouseup', M.mod_quiz.secure_window.prevent_mouse, document.body, '*');
-        Y.delegate('dragstart', M.mod_quiz.secure_window.prevent, document.body, '*');
-        Y.delegate('selectstart', M.mod_quiz.secure_window.prevent, document.body, '*');
+        Y.delegate('contextmenu', M.mod_quiz.secure_window.prevent, document, '*');
+        Y.delegate('mousedown', M.mod_quiz.secure_window.prevent_mouse, document, '*');
+        Y.delegate('mouseup', M.mod_quiz.secure_window.prevent_mouse, document, '*');
+        Y.delegate('dragstart', M.mod_quiz.secure_window.prevent, document, '*');
+        Y.delegate('selectstart', M.mod_quiz.secure_window.prevent, document, '*');
         M.mod_quiz.secure_window.clear_status;
         Y.on('beforeprint', function() {
             Y.one(document.body).setStyle('display', 'none');
index dcd8dfe..df2b0b6 100644 (file)
@@ -155,6 +155,7 @@ function resource_display_frame($resource, $cm, $course, $file) {
         $navurl = "$CFG->wwwroot/mod/resource/view.php?id=$cm->id&amp;frameset=top";
         $title = strip_tags(format_string($course->shortname.': '.$resource->name));
         $framesize = $config->framesize;
+        $contentframetitle = format_string($resource->name);
         $modulename = s(get_string('modulename','resource'));
         $dir = get_string('thisdirection', 'langconfig');
 
@@ -167,7 +168,7 @@ function resource_display_frame($resource, $cm, $course, $file) {
   </head>
   <frameset rows="$framesize,*">
     <frame src="$navurl" title="$modulename" />
-    <frame src="$fileurl" title="$modulename" />
+    <frame src="$fileurl" title="$contentframetitle" />
   </frameset>
 </html>
 EOF;
index 6f02035..70e7efc 100644 (file)
@@ -228,6 +228,7 @@ function url_display_frame($url, $cm, $course) {
         $title = strip_tags($courseshortname.': '.format_string($url->name));
         $framesize = $config->framesize;
         $modulename = s(get_string('modulename','url'));
+        $contentframetitle = format_string($url->name);
         $dir = get_string('thisdirection', 'langconfig');
 
         $extframe = <<<EOF
@@ -239,7 +240,7 @@ function url_display_frame($url, $cm, $course) {
   </head>
   <frameset rows="$framesize,*">
     <frame src="$navurl" title="$modulename"/>
-    <frame src="$exteurl" title="$modulename"/>
+    <frame src="$exteurl" title="$contentframetitle"/>
   </frameset>
 </html>
 EOF;
index 7e682f0..8c6e175 100644 (file)
@@ -88,8 +88,9 @@ class question_engine_attempt_upgrader {
         global $CFG, $DB;
 
         // Look to see if the admin has set things up to only upgrade certain attempts.
-        $partialupgradefile = $CFG->dirroot . '/local/qeupgradehelper/partialupgrade.php';
-        $partialupgradefunction = 'local_qeupgradehelper_get_quizzes_to_upgrade';
+        $partialupgradefile = $CFG->dirroot . '/' . $CFG->admin .
+                '/tool/qeupgradehelper/partialupgrade.php';
+        $partialupgradefunction = 'tool_qeupgradehelper_get_quizzes_to_upgrade';
         if (is_readable($partialupgradefile)) {
             include_once($partialupgradefile);
             if (function_exists($partialupgradefunction)) {