Merge branch 'w35_MDL-35061_m24_enrolfields' of git://github.com/skodak/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 27 Aug 2012 13:58:19 +0000 (15:58 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 27 Aug 2012 13:58:19 +0000 (15:58 +0200)
14 files changed:
admin/tool/assignmentupgrade/lang/en/tool_assignmentupgrade.php
admin/tool/assignmentupgrade/module.js
admin/tool/assignmentupgrade/renderer.php
blocks/html/block_html.php
blocks/html/edit_form.php
blocks/html/lang/en/block_html.php
blocks/html/settings.php [new file with mode: 0644]
course/lib.php
grade/lib.php
lib/completionlib.php
lib/modinfolib.php
lib/tests/completionlib_test.php
mod/assign/locallib.php
mod/feedback/lang/en/feedback.php

index e9a61dc..9dc8c6e 100644 (file)
@@ -36,6 +36,7 @@ $string['conversioncomplete'] = 'Assignment converted';
 $string['conversionfailed'] = 'The assignment conversion was not successful. The log from the upgrade was: <br />{$a}';
 $string['listnotupgraded'] = 'List assignments that have not been upgraded';
 $string['listnotupgraded_desc'] = 'You can upgrade individual assignments from here';
+$string['noassignmentsselected'] = 'No assignments selected';
 $string['noassignmentstoupgrade'] = 'There are no assignments that require upgrading';
 $string['notsupported'] = '';
 $string['notupgradedintro'] = 'This page lists the assignments created with an older version of Moodle that have not been upgraded to the new assignment module in Moodle 2.3. Not all assignments can be upgraded - if they were created with a custom assignment subtype, then that subtype will need to be upgraded to the new assignment plugin format in order to complete the upgrade.';
index edee839..6370e70 100644 (file)
@@ -56,7 +56,7 @@ M.tool_assignmentupgrade = {
             assignmentsinput = Y.one('input.selectedassignments');
             assignmentsinput.set('value', selectedassignments.join(','));
             if (selectedassignments.length == 0) {
-                alert(M.str.assign.noassignmentsselected);
+                alert(M.str.tool_assignmentupgrade.noassignmentsselected);
                 e.preventDefault();
             }
         });
index ddb8cfa..29192d7 100644 (file)
@@ -119,7 +119,7 @@ class tool_assignmentupgrade_renderer extends plugin_renderer_base {
         $output = '';
         $output .= $this->header();
         $this->page->requires->js_init_call('M.tool_assignmentupgrade.init_upgrade_table', array());
-
+        $this->page->requires->string_for_js('noassignmentsselected', 'tool_assignmentupgrade');
 
         $output .= $this->heading(get_string('notupgradedtitle', 'tool_assignmentupgrade'));
         $output .= $this->box(get_string('notupgradedintro', 'tool_assignmentupgrade'));
index 39040ae..b616925 100644 (file)
@@ -29,6 +29,10 @@ class block_html extends block_base {
         $this->title = get_string('pluginname', 'block_html');
     }
 
+    function has_config() {
+        return true;
+    }
+
     function applicable_formats() {
         return array('all' => true);
     }
@@ -138,10 +142,14 @@ class block_html extends block_base {
      * @return array
      */
     function html_attributes() {
+        global $CFG;
+
         $attributes = parent::html_attributes();
 
-        if (!empty($this->config->classes)) {
-            $attributes['class'] .= ' '.$this->config->classes;
+        if (!empty($CFG->block_html_allowcssclasses)) {
+            if (!empty($this->config->classes)) {
+                $attributes['class'] .= ' '.$this->config->classes;
+            }
         }
 
         return $attributes;
index f544f98..edb5705 100644 (file)
@@ -31,6 +31,8 @@
  */
 class block_html_edit_form extends block_edit_form {
     protected function specific_definition($mform) {
+        global $CFG;
+
         // Fields for editing HTML block title and contents.
         $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
 
@@ -42,9 +44,11 @@ class block_html_edit_form extends block_edit_form {
         $mform->addRule('config_text', null, 'required', null, 'client');
         $mform->setType('config_text', PARAM_RAW); // XSS is prevented when printing the block contents and serving files
 
-        $mform->addElement('text', 'config_classes', get_string('configclasses', 'block_html'));
-        $mform->setType('config_classes', PARAM_TEXT);
-        $mform->addHelpButton('config_classes', 'configclasses', 'block_html');
+        if (!empty($CFG->block_html_allowcssclasses)) {
+            $mform->addElement('text', 'config_classes', get_string('configclasses', 'block_html'));
+            $mform->setType('config_classes', PARAM_TEXT);
+            $mform->addHelpButton('config_classes', 'configclasses', 'block_html');
+        }
     }
 
     function set_data($defaults) {
index 6e82be8..d331059 100644 (file)
@@ -23,7 +23,9 @@
  * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
-$string['configclasses'] = 'Additional HTML classes';
+$string['allowadditionalcssclasses'] = 'Allow additional CSS classes';
+$string['configallowadditionalcssclasses'] = 'Adds a configuration option to HTML block instances allowing additional CSS classes to be set.';
+$string['configclasses'] = 'Additional CSS classes';
 $string['configclasses_help'] = 'The purpose of this configuration is to aid with theming by helping distinguish HTML blocks from each other. Any CSS classes entered here (space delimited) will be appended to the block\'s default classes.';
 $string['configcontent'] = 'Content';
 $string['configtitle'] = 'Block title';
diff --git a/blocks/html/settings.php b/blocks/html/settings.php
new file mode 100644 (file)
index 0000000..59cb797
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+defined('MOODLE_INTERNAL') || die;
+
+if ($ADMIN->fulltree) {
+    $settings->add(new admin_setting_configcheckbox('block_html_allowcssclasses', get_string('allowadditionalcssclasses', 'block_html'),
+                       get_string('configallowadditionalcssclasses', 'block_html'), 0));
+}
+
+
index 75cc734..cf8f372 100644 (file)
@@ -531,10 +531,19 @@ function print_mnet_log($hostid, $course, $user=0, $date=0, $order="l.time ASC",
 
 function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
                         $modid, $modaction, $groupid) {
-    global $DB;
+    global $DB, $CFG;
+
+    require_once($CFG->libdir . '/csvlib.class.php');
 
-    $text = get_string('course')."\t".get_string('time')."\t".get_string('ip_address')."\t".
-            get_string('fullnameuser')."\t".get_string('action')."\t".get_string('info');
+    $csvexporter = new csv_export_writer('tab');
+
+    $header = array();
+    $header[] = get_string('course');
+    $header[] = get_string('time');
+    $header[] = get_string('ip_address');
+    $header[] = get_string('fullnameuser');
+    $header[] = get_string('action');
+    $header[] = get_string('info');
 
     if (!$logs = build_logs_array($course, $user, $date, $order, '', '',
                        $modname, $modid, $modaction, $groupid)) {
@@ -561,16 +570,10 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
 
     $strftimedatetime = get_string("strftimedatetime");
 
-    $filename = 'logs_'.userdate(time(),get_string('backupnameformat', 'langconfig'),99,false);
-    $filename .= '.txt';
-    header("Content-Type: application/download\n");
-    header("Content-Disposition: attachment; filename=\"$filename\"");
-    header("Expires: 0");
-    header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
-    header("Pragma: public");
-
-    echo get_string('savedat').userdate(time(), $strftimedatetime)."\n";
-    echo $text."\n";
+    $csvexporter->set_filename('logs', '.txt');
+    $title = array(get_string('savedat').userdate(time(), $strftimedatetime));
+    $csvexporter->add_data($title);
+    $csvexporter->add_data($header);
 
     if (empty($logs['logs'])) {
         return true;
@@ -600,9 +603,9 @@ function print_log_csv($course, $user, $date, $order='l.time DESC', $modname,
         $firstField = format_string($courses[$log->course], true, array('context' => $coursecontext));
         $fullname = fullname($log, has_capability('moodle/site:viewfullnames', $coursecontext));
         $row = array($firstField, userdate($log->time, $strftimedatetime), $log->ip, $fullname, $log->module.' '.$log->action, $log->info);
-        $text = implode("\t", $row);
-        echo $text." \n";
+        $csvexporter->add_data($row);
     }
+    $csvexporter->download_file();
     return true;
 }
 
index 7765f82..37629eb 100644 (file)
@@ -2610,6 +2610,7 @@ abstract class grade_helper {
      * @return array
      */
     public static function get_info_letters($courseid) {
+        global $SITE;
         if (self::$letterinfo !== null) {
             return self::$letterinfo;
         }
@@ -2617,9 +2618,15 @@ abstract class grade_helper {
         $canmanage = has_capability('moodle/grade:manage', $context);
         $canmanageletters = has_capability('moodle/grade:manageletters', $context);
         if ($canmanage || $canmanageletters) {
+            // Redirect to system context when report is accessed from admin settings MDL-31633
+            if ($context->instanceid == $SITE->id) {
+                $param = array('edit' => 1);
+            } else {
+                $param = array('edit' => 1,'id' => $context->id);
+            }
             self::$letterinfo = array(
                 'view' => new grade_plugin_info('view', new moodle_url('/grade/edit/letter/index.php', array('id'=>$context->id)), get_string('view')),
-                'edit' => new grade_plugin_info('edit', new moodle_url('/grade/edit/letter/index.php', array('edit'=>1,'id'=>$context->id)), get_string('edit'))
+                'edit' => new grade_plugin_info('edit', new moodle_url('/grade/edit/letter/index.php', $param), get_string('edit'))
             );
         } else {
             self::$letterinfo = false;
index c962037..4d6ea82 100644 (file)
@@ -621,16 +621,20 @@ class completion_info {
             debugging('set_module_viewed must be called before header is printed',
                     DEBUG_DEVELOPER);
         }
+
         // Don't do anything if view condition is not turned on
         if ($cm->completionview == COMPLETION_VIEW_NOT_REQUIRED || !$this->is_enabled($cm)) {
             return;
         }
+
         // Get current completion state
-        $data = $this->get_data($cm, $userid);
+        $data = $this->get_data($cm, false, $userid);
+
         // If we already viewed it, don't do anything
         if ($data->viewed == COMPLETION_VIEWED) {
             return;
         }
+
         // OK, change state, save it, and update completion
         $data->viewed = COMPLETION_VIEWED;
         $this->internal_set_data($cm, $data);
index fc24b9b..6c8997c 100644 (file)
@@ -1204,6 +1204,10 @@ function get_fast_modinfo(&$course, $userid=0) {
         debugging('Coding problem - missing course modinfo property in get_fast_modinfo() call');
     }
 
+    if (!property_exists($course, 'sectioncache')) {
+        debugging('Coding problem - missing course sectioncache property in get_fast_modinfo() call');
+    }
+
     unset($cache[$course->id]); // prevent potential reference problems when switching users
 
     $cache[$course->id] = new course_modinfo($course, $userid);
index 6e81cd7..5092831 100644 (file)
@@ -257,7 +257,7 @@ class completionlib_testcase extends basic_testcase {
             ->will($this->returnValue(true));
         $c->expects($this->at(1))
             ->method('get_data')
-            ->with($cm, 1337)
+            ->with($cm, false, 1337)
             ->will($this->returnValue((object)array('viewed'=>COMPLETION_NOT_VIEWED)));
         $c->expects($this->at(2))
             ->method('internal_set_data')
index 60a3f92..455afd1 100644 (file)
@@ -417,7 +417,7 @@ class assign {
         $update->duedate = $formdata->duedate;
         $update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
         $update->grade = $formdata->grade;
-        $update->completionsubmit = $formdata->completionsubmit;
+        $update->completionsubmit = !empty($formdata->completionsubmit);
         $returnid = $DB->insert_record('assign', $update);
         $this->instance = $DB->get_record('assign', array('id'=>$returnid), '*', MUST_EXIST);
         // cache the course record
@@ -637,7 +637,7 @@ class assign {
         $update->duedate = $formdata->duedate;
         $update->allowsubmissionsfromdate = $formdata->allowsubmissionsfromdate;
         $update->grade = $formdata->grade;
-        $update->completionsubmit = $formdata->completionsubmit;
+        $update->completionsubmit = !empty($formdata->completionsubmit);
 
         $result = $DB->update_record('assign', $update);
         $this->instance = $DB->get_record('assign', array('id'=>$update->id), '*', MUST_EXIST);
index c35b24c..2e27645 100644 (file)
@@ -62,28 +62,26 @@ $string['delete_item'] = 'Delete question';
 $string['delete_old_items'] = 'Delete old items';
 $string['delete_template'] = 'Delete template';
 $string['delete_templates'] = 'Delete template...';
-$string['depending'] = 'depending items';
-$string['depending_help'] = 'Depending items allow you to show items depend on values from other items.<br />
-<strong>Here an build example to use it:</strong><br />
+$string['depending'] = 'Dependencies';
+$string['depending_help'] = 'It is possible to show an item depending on the value of another item.<br />
+<strong>Here is an example.</strong><br />
 <ul>
-<li>First create an item on which value other items depends.</li>
-<li>Next add a pagebreak.</li>
-<li>Next add the items depend on the item-value before<br />
-Choose in the item creation-form the item in the list "depend item" and put the needed value into the textbox "depend value".</li>
+<li>First, create an item on which another item will depend on.</li>
+<li>Next, add a pagebreak.</li>
+<li>Then add the items dependant on the value of the item created before. Choose the item from the list labelled "Dependence item" and write the required value in the textbox labelled "Dependence value".</li>
 </ul>
-<strong>The structure should looks like this:</strong>
+<strong>The item structure should look like this.</strong>
 <ol>
-<li>Item Q: do you have a car? A: yes/no</li>
+<li>Item Q: Do you have a car? A: yes/no</li>
 <li>Pagebreak</li>
-<li>Item Q: what color has your car?<br />
+<li>Item Q: What colour is your car?<br />
 (this item depends on item 1 with value = yes)</li>
-<li>Item Q: why you have not a car?<br />
+<li>Item Q: Why don\'t you have a car?<br />
 (this item depends on item 1 with value = no)</li>
 <li> ... other items</li>
-</ol>
-That is all. Have fun!';
-$string['dependitem'] = 'depend item';
-$string['dependvalue'] = 'depend value';
+</ol>';
+$string['dependitem'] = 'Dependence item';
+$string['dependvalue'] = 'Dependence value';
 $string['description'] = 'Description';
 $string['do_not_analyse_empty_submits'] = 'Do not analyse empty submits';
 $string['dropdown'] = 'Multiple choice - single answer allowed (dropdownlist)';