Merge branch 'w43_MDL-29984_m22_enroltoday' of git://github.com/skodak/moodle
authorAparup Banerjee <aparup@moodle.com>
Mon, 31 Oct 2011 07:25:55 +0000 (15:25 +0800)
committerAparup Banerjee <aparup@moodle.com>
Mon, 31 Oct 2011 07:25:55 +0000 (15:25 +0800)
243 files changed:
admin/cli/install_database.php
admin/renderer.php
admin/settings/development.php
blocks/search/README.txt [deleted file]
blocks/search/block_search.php [deleted file]
blocks/search/db/install.php [deleted file]
blocks/search/db/install.xml [deleted file]
blocks/search/db/upgrade.php [deleted file]
blocks/search/lang/en/block_search.php [deleted file]
blocks/search/settings.php [deleted file]
calendar/lib.php
calendar/renderer.php
calendar/set.php
enrol/index.php
enrol/self/lang/en/enrol_self.php
enrol/self/lib.php
enrol/self/locallib.php
enrol/self/version.php
filter/data/db/install.php [new file with mode: 0644]
filter/data/filter.php [new file with mode: 0644]
filter/data/lang/en/filter_data.php [moved from blocks/search/version.php with 68% similarity]
filter/data/version.php [moved from blocks/search/db/upgradelib.php with 54% similarity]
filter/glossary/db/install.php [new file with mode: 0644]
filter/glossary/filter.php [new file with mode: 0644]
filter/glossary/lang/en/filter_glossary.php [new file with mode: 0644]
filter/glossary/styles.css [new file with mode: 0644]
filter/glossary/version.php [new file with mode: 0644]
filter/glossary/yui/autolinker/autolinker.js [moved from mod/glossary/yui/autolinker/autolinker.js with 90% similarity]
lang/en/admin.php
lib/db/upgrade.php
lib/filterlib.php
lib/mp3player/index.html [deleted file]
lib/mp3player/mp3player.fla.zip [deleted file]
lib/mp3player/mp3player.swf [deleted file]
lib/mp3player/readme.txt [deleted file]
lib/pluginlib.php
lib/resourcelib.php
mod/assignment/lib.php
mod/assignment/type/upload/assignment.class.php
mod/data/filter.php [deleted file]
mod/data/version.php
mod/feedback/README.txt
mod/feedback/analysis.php
mod/feedback/analysis_course.php
mod/feedback/analysis_to_excel.php
mod/feedback/backup/moodle1/lib.php
mod/feedback/backup/moodle2/backup_feedback_activity_task.class.php
mod/feedback/backup/moodle2/backup_feedback_settingslib.php
mod/feedback/backup/moodle2/backup_feedback_stepslib.php
mod/feedback/backup/moodle2/restore_feedback_activity_task.class.php
mod/feedback/backup/moodle2/restore_feedback_stepslib.php
mod/feedback/choose_group_form.php
mod/feedback/complete.php
mod/feedback/complete_guest.php
mod/feedback/db/access.php
mod/feedback/db/install.php
mod/feedback/db/install.xml
mod/feedback/db/log.php
mod/feedback/db/messages.php
mod/feedback/db/upgrade.php
mod/feedback/delete_completed.php
mod/feedback/delete_completed_form.php
mod/feedback/delete_item.php
mod/feedback/delete_item_form.php
mod/feedback/delete_template.php
mod/feedback/delete_template_form.php
mod/feedback/edit.php
mod/feedback/edit_form.php
mod/feedback/edit_item.php
mod/feedback/export.php
mod/feedback/import.php
mod/feedback/import_form.php
mod/feedback/index.php
mod/feedback/item/captcha/captcha_form.php
mod/feedback/item/captcha/lib.php
mod/feedback/item/captcha/print_captcha.php
mod/feedback/item/feedback_item_class.php
mod/feedback/item/feedback_item_form_class.php
mod/feedback/item/info/info_form.php
mod/feedback/item/info/lib.php
mod/feedback/item/label/label_form.php
mod/feedback/item/label/lib.php
mod/feedback/item/multichoice/lib.php
mod/feedback/item/multichoice/multichoice_form.php
mod/feedback/item/multichoicerated/lib.php
mod/feedback/item/multichoicerated/multichoicerated_form.php
mod/feedback/item/numeric/lib.php
mod/feedback/item/numeric/numeric_form.php
mod/feedback/item/textarea/lib.php
mod/feedback/item/textarea/textarea_form.php
mod/feedback/item/textfield/lib.php
mod/feedback/item/textfield/textfield_form.php
mod/feedback/lang/en/feedback.php
mod/feedback/lib.php
mod/feedback/mapcourse.php
mod/feedback/mod_form.php
mod/feedback/print.php
mod/feedback/settings.php
mod/feedback/show_entries.php
mod/feedback/show_entries_anonym.php
mod/feedback/show_nonrespondents.php
mod/feedback/styles.css
mod/feedback/tabs.php
mod/feedback/unmapcourse.php
mod/feedback/use_templ.php
mod/feedback/use_templ_form.php
mod/feedback/version.php
mod/feedback/view.php
mod/glossary/filter.php [deleted file]
mod/glossary/styles.css
mod/glossary/version.php
mod/scorm/player.php
mod/scorm/report/basic/report.php
mod/url/lang/en/url.php
mod/url/lib.php
mod/url/locallib.php
mod/url/mod_form.php
mod/url/simpletest/testlib.php [new file with mode: 0644]
mod/url/version.php
mod/url/view.php
mod/workshop/form/accumulative/assessment_form.php
mod/workshop/form/accumulative/lang/en/workshopform_accumulative.php
mod/workshop/form/numerrors/assessment_form.php
mod/workshop/form/numerrors/lib.php
repository/filepicker.js
repository/repository_ajax.php
search/.cvsignore [deleted file]
search/LISEZMOI.txt [deleted file]
search/README.txt [deleted file]
search/README_ARCHIVE.txt [deleted file]
search/Zend/Exception.php [deleted file]
search/Zend/IMPORTANT.txt [deleted file]
search/Zend/LICENSE.txt [deleted file]
search/Zend/Search/Exception.php [deleted file]
search/Zend/Search/Lucene.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Text.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Text/CaseInsensitive.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/TextNum/CaseInsensitive.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8/CaseInsensitive.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num.php [deleted file]
search/Zend/Search/Lucene/Analysis/Analyzer/Common/Utf8Num/CaseInsensitive.php [deleted file]
search/Zend/Search/Lucene/Analysis/Token.php [deleted file]
search/Zend/Search/Lucene/Analysis/TokenFilter.php [deleted file]
search/Zend/Search/Lucene/Analysis/TokenFilter/LowerCase.php [deleted file]
search/Zend/Search/Lucene/Analysis/TokenFilter/LowerCaseUtf8.php [deleted file]
search/Zend/Search/Lucene/Analysis/TokenFilter/ShortWords.php [deleted file]
search/Zend/Search/Lucene/Analysis/TokenFilter/StopWords.php [deleted file]
search/Zend/Search/Lucene/Document.php [deleted file]
search/Zend/Search/Lucene/Document/Html.php [deleted file]
search/Zend/Search/Lucene/Exception.php [deleted file]
search/Zend/Search/Lucene/FSM.php [deleted file]
search/Zend/Search/Lucene/FSMAction.php [deleted file]
search/Zend/Search/Lucene/Field.php [deleted file]
search/Zend/Search/Lucene/Index/DictionaryLoader.php [deleted file]
search/Zend/Search/Lucene/Index/FieldInfo.php [deleted file]
search/Zend/Search/Lucene/Index/SegmentInfo.php [deleted file]
search/Zend/Search/Lucene/Index/SegmentInfoPriorityQueue.php [deleted file]
search/Zend/Search/Lucene/Index/SegmentMerger.php [deleted file]
search/Zend/Search/Lucene/Index/SegmentWriter.php [deleted file]
search/Zend/Search/Lucene/Index/SegmentWriter/DocumentWriter.php [deleted file]
search/Zend/Search/Lucene/Index/SegmentWriter/StreamWriter.php [deleted file]
search/Zend/Search/Lucene/Index/Term.php [deleted file]
search/Zend/Search/Lucene/Index/TermInfo.php [deleted file]
search/Zend/Search/Lucene/Index/Writer.php [deleted file]
search/Zend/Search/Lucene/Interface.php [deleted file]
search/Zend/Search/Lucene/LockManager.php [deleted file]
search/Zend/Search/Lucene/PriorityQueue.php [deleted file]
search/Zend/Search/Lucene/Proxy.php [deleted file]
search/Zend/Search/Lucene/Search/BooleanExpressionRecognizer.php [deleted file]
search/Zend/Search/Lucene/Search/Query.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Boolean.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Empty.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Fuzzy.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Insignificant.php [deleted file]
search/Zend/Search/Lucene/Search/Query/MultiTerm.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Phrase.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Range.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Term.php [deleted file]
search/Zend/Search/Lucene/Search/Query/Wildcard.php [deleted file]
search/Zend/Search/Lucene/Search/QueryEntry.php [deleted file]
search/Zend/Search/Lucene/Search/QueryEntry/Phrase.php [deleted file]
search/Zend/Search/Lucene/Search/QueryEntry/Subquery.php [deleted file]
search/Zend/Search/Lucene/Search/QueryEntry/Term.php [deleted file]
search/Zend/Search/Lucene/Search/QueryHit.php [deleted file]
search/Zend/Search/Lucene/Search/QueryLexer.php [deleted file]
search/Zend/Search/Lucene/Search/QueryParser.php [deleted file]
search/Zend/Search/Lucene/Search/QueryParserContext.php [deleted file]
search/Zend/Search/Lucene/Search/QueryParserException.php [deleted file]
search/Zend/Search/Lucene/Search/QueryToken.php [deleted file]
search/Zend/Search/Lucene/Search/Similarity.php [deleted file]
search/Zend/Search/Lucene/Search/Similarity/Default.php [deleted file]
search/Zend/Search/Lucene/Search/Weight.php [deleted file]
search/Zend/Search/Lucene/Search/Weight/Boolean.php [deleted file]
search/Zend/Search/Lucene/Search/Weight/Empty.php [deleted file]
search/Zend/Search/Lucene/Search/Weight/MultiTerm.php [deleted file]
search/Zend/Search/Lucene/Search/Weight/Phrase.php [deleted file]
search/Zend/Search/Lucene/Search/Weight/Term.php [deleted file]
search/Zend/Search/Lucene/Storage/Directory.php [deleted file]
search/Zend/Search/Lucene/Storage/Directory/Filesystem.php [deleted file]
search/Zend/Search/Lucene/Storage/File.php [deleted file]
search/Zend/Search/Lucene/Storage/File/Filesystem.php [deleted file]
search/Zend/Search/Lucene/Storage/File/Memory.php [deleted file]
search/Zend/Search/TODO.txt [deleted file]
search/add.php [deleted file]
search/cron.php [deleted file]
search/cron_php5.php [deleted file]
search/delete.php [deleted file]
search/documents/assignment_document.php [deleted file]
search/documents/chat_document.php [deleted file]
search/documents/data_document.php [deleted file]
search/documents/document.php [deleted file]
search/documents/forum_document.php [deleted file]
search/documents/glossary_document.php [deleted file]
search/documents/label_document.php [deleted file]
search/documents/lesson_document.php [deleted file]
search/documents/physical_doc.php [deleted file]
search/documents/physical_htm.php [deleted file]
search/documents/physical_html.php [deleted file]
search/documents/physical_odt.php [deleted file]
search/documents/physical_pdf.php [deleted file]
search/documents/physical_ppt.php [deleted file]
search/documents/physical_swf.php [deleted file]
search/documents/physical_txt.php [deleted file]
search/documents/physical_xml.php [deleted file]
search/documents/resource_document.php [deleted file]
search/documents/user_document.php [deleted file]
search/documents/wiki_document.php [deleted file]
search/index.php [deleted file]
search/indexer.php [deleted file]
search/indexersplash.php [deleted file]
search/indexlib.php [deleted file]
search/lib.php [deleted file]
search/query.php [deleted file]
search/querylib.php [deleted file]
search/searchtypes.php [deleted file]
search/stats.php [deleted file]
search/tests/index.php [deleted file]
search/update.php [deleted file]
version.php

index 2ee2f82..2524c41 100644 (file)
@@ -46,8 +46,8 @@ Options:
 --adminuser=USERNAME  Username for the moodle admin account. Default is admin.
 --adminpass=PASSWORD  Password for the moodle admin account.
 --agree-license       Indicates agreement with software license.
---fullname            Name of the site
---shortname           Name of the site
+--fullname=STRING     Name of the site
+--shortname=STRING    Name of the site
 -h, --help            Print out this help
 
 Example:
index 7c23e2c..be5780b 100644 (file)
@@ -598,7 +598,7 @@ class core_admin_renderer extends plugin_renderer_base {
             if (is_null($otherplugin)) {
                 $ok = false;
             }
-            if ($requiredversion != ANY_VERSION and $otherplugin->versiondb < $requiredversion) {
+            if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
                 $ok = false;
             }
 
index 192df5b..d6c9e4f 100644 (file)
@@ -7,11 +7,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
     // Experimental settings page
     $ADMIN->add('development', new admin_category('experimental', get_string('experimental','admin')));
 
-    require_once($CFG->dirroot .'/search/lib.php');
     $temp = new admin_settingpage('experimentalsettings', get_string('experimentalsettings', 'admin'));
-    $englobalsearch = new admin_setting_configcheckbox('enableglobalsearch', get_string('enableglobalsearch', 'admin'), get_string('configenableglobalsearch', 'admin'), 0);
-    $englobalsearch->set_updatedcallback('search_updatedcallback');
-    $temp->add($englobalsearch);
     //TODO: Re-enable cc-import once re-implemented in 2.0.x
     //$temp->add(new admin_setting_configcheckbox('enableimsccimport', get_string('enable_cc_import', 'imscc'), get_string('enable_cc_import_description', 'imscc'), 0));
     $temp->add(new admin_setting_configcheckbox('enablesafebrowserintegration', get_string('enablesafebrowserintegration', 'admin'), get_string('configenablesafebrowserintegration', 'admin'), 0));
diff --git a/blocks/search/README.txt b/blocks/search/README.txt
deleted file mode 100644 (file)
index 48dfb9f..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-This block is a revamping of the Google Summer Of Code Project (2006) on Global Search engine
-for Moodle. New block version is completed and internationalized according to Moodle multilengual support.
-
-This block instanciates a startup database model for the search engine.
-
-## Installing
-
-You need installing the following elements in order the global search to be available :
-
-1. The global search bloc (this block)
-2. update the /search root package from CVS
-3. The antiword libraries
-4. The xpdf libraries
-
-Both last libraries are provided as a patch called "global_search_libraries" in the contrib section.
\ No newline at end of file
diff --git a/blocks/search/block_search.php b/blocks/search/block_search.php
deleted file mode 100644 (file)
index 1aeb08c..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-
-/** This is the global search shortcut block - a single query can be entered, and
- * the user will be redirected to the query page where they can enter more
- *  advanced queries, and view the results of their search. When searching from
- *  this block, the broadest possible selection of documents is searched.
- *
- * @package search
- * @subpackage search block
- * @author: Michael Champanis (mchampan), reengineered by Valery Fremaux
- * @date: 2006 06 25
- */
-
-class block_search extends block_base {
-
-    function init() {
-      $this->title = get_string('pluginname', 'block_search');
-    } //init
-
-    // only one instance of this block is required
-    function instance_allow_multiple() {
-      return false;
-    } //instance_allow_multiple
-
-    // label and button values can be set in admin
-    function has_config() {
-      return true;
-    } //has_config
-
-    function get_content() {
-      global $CFG;
-
-      if (empty($CFG->enableglobalsearch)) {
-        return '';
-      }
-
-      //cache block contents
-      if ($this->content !== NULL) {
-        return $this->content;
-      } //if
-
-      $this->content = new stdClass;
-
-      //basic search form
-      $this->content->text =
-            '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
-          . '<label for="block_search_q">' . get_string('searchmoodle', 'block_search') . '</label>'
-          . '<input id="block_search_q" type="text" name="query_string" />'
-          . '<input id="block_instance_id" type="hidden" name="block_instanceid" value="' . $this->instance->id . '"/>'
-          . '<input type="submit" value="' . s(get_string('go', 'block_search')) . '" />'
-          . '</div></form>';
-
-      //no footer, thanks
-      $this->content->footer = '';
-
-      return $this->content;
-    } //get_content
-
-    function specialisation() {
-      //empty!
-    } //specialisation
-
-    /**
-     * wraps up to search engine cron
-     */
-    function cron(){
-        global $CFG;
-
-        include($CFG->dirroot.'/search/cron.php');
-    }
-
-  } //block_search
-
diff --git a/blocks/search/db/install.php b/blocks/search/db/install.php
deleted file mode 100644 (file)
index f8a13cf..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-function xmldb_block_search_install() {
-    global $DB;
-
-    // Disable this block by default as its experimental.
-    $DB->set_field('block', 'visible', 0, array('name'=>'search'));
-
-}
-
diff --git a/blocks/search/db/install.xml b/blocks/search/db/install.xml
deleted file mode 100644 (file)
index c5c2b52..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="blocks/search/db" VERSION="20101012" COMMENT="XMLDB file for Moodle search engine"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
->
-  <TABLES>
-    <TABLE NAME="block_search_documents" COMMENT="table to store search index backups">
-      <FIELDS>
-        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="docid"/>
-        <FIELD NAME="docid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" PREVIOUS="id" NEXT="doctype"/>
-        <FIELD NAME="doctype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="none" SEQUENCE="false" PREVIOUS="docid" NEXT="itemtype"/>
-        <FIELD NAME="itemtype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="standard" SEQUENCE="false" PREVIOUS="doctype" NEXT="title"/>
-        <FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="itemtype" NEXT="url"/>
-        <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" PREVIOUS="title" NEXT="docdate"/>
-        <FIELD NAME="docdate" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="url" NEXT="updated"/>
-        <FIELD NAME="updated" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="docdate" NEXT="courseid"/>
-        <FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="updated" NEXT="groupid"/>
-        <FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="courseid"/>
-      </FIELDS>
-      <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
-      </KEYS>
-      <INDEXES>
-        <INDEX NAME="mdl_search_docid" UNIQUE="false" FIELDS="docid" NEXT="mdl_search_doctype"/>
-        <INDEX NAME="mdl_search_doctype" UNIQUE="false" FIELDS="doctype" PREVIOUS="mdl_search_docid" NEXT="mdl_search_itemtype"/>
-        <INDEX NAME="mdl_search_itemtype" UNIQUE="false" FIELDS="itemtype" PREVIOUS="mdl_search_doctype"/>
-      </INDEXES>
-    </TABLE>
-  </TABLES>
-</XMLDB>
\ No newline at end of file
diff --git a/blocks/search/db/upgrade.php b/blocks/search/db/upgrade.php
deleted file mode 100644 (file)
index 952a129..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Keeps track of upgrades to the global search block
- *
- * @package    blocks
- * @subpackage search
- * @copyright  2010 Aparup Banerjee <aparup@moodle.com>
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-function xmldb_block_search_upgrade($oldversion) {
-    global $CFG, $DB;
-
-    require('upgradelib.php');
-    $result = TRUE;
-    $dbman = $DB->get_manager();
-
-    if ($oldversion < 2010101800) {
-        // See MDL-24374
-        // Changing type of field docdate on table block_search_documents to int
-        // Changing type of field updated on table block_search_documents to int
-        $table = new xmldb_table('block_search_documents');
-
-        $field_docdate_new = new xmldb_field('docdate_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'docdate');
-        $field_updated_new = new xmldb_field('updated_new', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'updated');
-        $field_docdate_old = new xmldb_field('docdate');
-        $field_updated_old = new xmldb_field('updated');
-
-        // Conditionally launch add temporary fields
-        if (!$dbman->field_exists($table, $field_docdate_new)) {
-            $dbman->add_field($table, $field_docdate_new);
-        }
-        if (!$dbman->field_exists($table, $field_updated_new)) {
-            $dbman->add_field($table, $field_updated_new);
-        }
-
-        $sql = "SELECT id, docdate, updated FROM {block_search_documents}";
-        $search_documents = $DB->get_records_sql($sql);
-        if ($search_documents) {
-            foreach ($search_documents as $sd) {
-                $sd->docdate_new = convert_datetime_upgrade($sd->docdate);
-                $sd->updated_new = convert_datetime_upgrade($sd->updated);
-                $DB->update_record('block_search_documents', $sd);
-            }
-        }
-        // Conditionally launch drop the old fields
-        if ($dbman->field_exists($table, $field_docdate_old)) {
-            $dbman->drop_field($table, $field_docdate_old);
-        }
-        if ($dbman->field_exists($table, $field_updated_old)) {
-            $dbman->drop_field($table, $field_updated_old);
-        }
-
-        //rename the new fields to the original field names.
-        $dbman->rename_field($table, $field_docdate_new, 'docdate');
-        $dbman->rename_field($table, $field_updated_new, 'updated');
-
-        // search savepoint reached
-        upgrade_block_savepoint(true, 2010101800, 'search');
-    }
-
-    if ($oldversion < 2010110900) {
-        unset_config('block_search_text');
-        unset_config('block_search_button');
-        upgrade_block_savepoint(true, 2010110900, 'search');
-    }
-
-    if ($oldversion < 2010111100) {
-        // set block to hidden if global search is disabled.
-        if ($CFG->enableglobalsearch != 1) {
-            $DB->set_field('block', 'visible', 0, array('name'=>'search'));     // Hide block
-        }
-        upgrade_block_savepoint(true, 2010111100, 'search');
-    }
-    return $result;
-}
diff --git a/blocks/search/lang/en/block_search.php b/blocks/search/lang/en/block_search.php
deleted file mode 100644 (file)
index 06df0ed..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * Strings for component 'block_search', language 'en', branch 'MOODLE_20_STABLE'
- *
- * @package   block_search
- * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
- * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-$string['blockssearchswitches'] = 'Indexer activation for blocks';
-$string['bytes'] = 'bytes (0 stands for no limits)';
-$string['configenablefileindexing'] = 'Enable file indexing';
-$string['configfiletypes'] = 'File types handled';
-$string['configlimitindexbody'] = 'Indexed body size limitation';
-$string['configpdftotextcmd'] = 'Path to command pdftotext';
-$string['configtypetotxtcmd'] = 'Converter\'s command line';
-$string['configtypetotxtenv'] = 'Environment define for converter';
-$string['configwordtotextcmd'] = 'Path to command doctotext';
-$string['configwordtotextenv'] = 'Environment setting for the MSWord converter';
-$string['cmdtoconverttotextfor'] = 'Command to convert {$a} to text';
-$string['enablefileindexing'] = 'Turn on indexing of different file types';
-$string['enableindexinginmodule'] = 'Allow indexing of the {$a} module';
-$string['enableindexinginblock'] = 'Allow indexing of the {$a} block';
-$string['envforcmdtotextfor'] = 'Environment for {$a} conversion command to text';
-$string['go'] = 'Go!';
-$string['handlingfor'] = 'Extra handling for';
-$string['indexbodylimit'] = 'The limit of indexing the body';
-$string['listoffiletypes'] = 'The list of file types handled';
-$string['modulessearchswitches'] = 'Indexer activation for modules';
-$string['nosearchableblocks'] = 'No searchable blocks';
-$string['nosearchablemodules'] = 'No searchable modules';
-$string['pdfhandling'] = 'Acrobat PDF handling';
-$string['pdftotextcmd'] = 'Command to convert PDF to text';
-$string['pluginname'] = 'Global search';
-$string['searchdiscovery'] = 'Searchable items discovery';
-$string['searchmoodle'] = 'Search Moodle';
-$string['usemoodleroot'] = 'Use moodle root for external converters';
-$string['usemoodlerootdescription'] = 'Use moodle root for external converters';
-$string['wordhandling'] = 'Microsoft Word handling';
-$string['wordtotextcmd'] = 'Command to convert Microsoft Word to text';
-$string['wordtotextenv'] = 'Environment setup for Microsoft Word to text converter';
diff --git a/blocks/search/settings.php b/blocks/search/settings.php
deleted file mode 100644 (file)
index 44fee6c..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-if ($ADMIN->fulltree) {
-
-    //Enable file indexing (y/n)
-    $settings->add(new admin_setting_configcheckbox('block_search_enable_file_indexing', get_string('configenablefileindexing', 'block_search'),
-                       get_string('enablefileindexing', 'block_search'), 0, 1, 0));
-
-    //file types
-    $defaultfiletypes = 'PDF,TXT,HTML,PPT,XML,DOC,HTM';
-    $settings->add(new admin_setting_configtext('block_search_filetypes', get_string('configfiletypes', 'block_search'),
-                       get_string('listoffiletypes', 'block_search'), $defaultfiletypes, PARAM_TEXT));
-
-    // usemoodleroot
-    $settings->add(new admin_setting_configcheckbox('block_search_usemoodleroot', get_string('usemoodleroot', 'block_search'),
-                       get_string('usemoodlerootdescription', 'block_search'), 1, 1, 0));
-
-    //limit_index_body
-    $settings->add(new admin_setting_configtext('block_search_limit_index_body', get_string('configlimitindexbody', 'block_search'),
-                       get_string('indexbodylimit', 'block_search'), '', PARAM_INT));
-
-    //setup default paths for following configs.
-    if ($CFG->ostype == 'WINDOWS') {
-        $default_pdf_to_text_cmd = "lib/xpdf/win32/pdftotext.exe -eol dos -enc UTF-8 -q";
-        $default_word_to_text_cmd = "lib/antiword/win32/antiword/antiword.exe ";
-        $default_word_to_text_env = "HOME={$CFG->dirroot}\\lib\\antiword\\win32";
-    } else {
-        $default_pdf_to_text_cmd = "lib/xpdf/linux/pdftotext -enc UTF-8 -eol unix -q";
-        $default_word_to_text_cmd = "lib/antiword/linux/usr/bin/antiword";
-        $default_word_to_text_env = "ANTIWORDHOME={$CFG->dirroot}/lib/antiword/linux/usr/share/antiword";
-    }
-
-    //pdf_to_text_cmd
-    $settings->add(new admin_setting_configtext('block_search_pdf_to_text_cmd', get_string('configpdftotextcmd', 'block_search'),
-                       get_string('pdftotextcmd', 'block_search'), $default_pdf_to_text_cmd, PARAM_RAW, 60));
-
-    //word_to_text_cmd
-    $settings->add(new admin_setting_configtext('block_search_word_to_text_cmd', get_string('configwordtotextcmd', 'block_search'),
-                       get_string('wordtotextcmd', 'block_search'), $default_word_to_text_cmd, PARAM_RAW, 60));
-
-    //word_to_text_env
-    $settings->add(new admin_setting_configtext('block_search_word_to_text_env', get_string('configwordtotextenv', 'block_search'),
-                       get_string('wordtotextenv', 'block_search'), $default_word_to_text_env, PARAM_RAW, 60));
-
-
-    // modules activations
-    if (isset($CFG->block_search_filetypes)) {
-        $types = explode(',', $CFG->block_search_filetypes);
-    } else {
-        $types = explode(',', $defaultfiletypes);
-    }
-
-    if (!empty($types)) {
-        foreach($types as $type) {
-            $utype = strtoupper($type);
-            $type = strtolower($type);
-            $type = trim($type);
-            if (preg_match("/\\b$type\\b/i", $defaultfiletypes)) continue;
-
-            //header
-            $propname = 'block_search_'.$type.'_to_text';
-            $settings->add(new admin_setting_heading($propname, get_string('handlingfor', 'block_search').' '.$utype , ''));
-
-            //word_to_text_cmd
-            $propname = 'block_search_'.$type.'_to_text_cmd';
-            $settings->add(new admin_setting_configtext($propname, get_string('configtypetotxtcmd', 'block_search'),
-                               get_string('cmdtoconverttotextfor', 'block_search', $type), '', PARAM_PATH, 60));
-
-            //word_to_text_env
-            $propname = 'block_search_'.$type.'_to_text_env';
-            $settings->add(new admin_setting_configtext($propname, get_string('configtypetotxtenv', 'block_search'),
-                               get_string('envforcmdtotextfor', 'block_search', $type), '', PARAM_PATH, 60));
-
-        }
-    }
-
-    require_once($CFG->dirroot.'/search/lib.php' );
-    $searchnames = search_collect_searchables(true, false);
-    list($searchable_list, $params) = $DB->get_in_or_equal($searchnames);
-
-    //header
-    $propname = 'block_search_'.$type.'_to_text';
-    $settings->add(new admin_setting_heading($propname, get_string('searchdiscovery', 'block_search') , ''));
-
-    $found_searchable_modules = 0;
-    if ($modules = $DB->get_records_select('modules', "name $searchable_list", $params, 'name', 'id,name')){
-        foreach($modules as $module){
-            $keyname = 'search_in_'.$module->name;
-            $settings->add(new admin_setting_configcheckbox($keyname, get_string('modulename', $module->name),
-                               get_string('enableindexinginmodule', 'block_search', $module->name), 1, 1, 0));
-            $found_searchable_modules = 1;
-        }
-    }
-
-    if (!$found_searchable_modules) {
-        //header
-        $propname = 'block_search_nosearchablemodules';
-        $settings->add(new admin_setting_heading($propname, get_string('nosearchablemodules', 'block_search') , ''));
-    }
-
-    //header
-    $propname = 'block_search_searchswitches';
-    $settings->add(new admin_setting_heading($propname, get_string('blockssearchswitches', 'block_search') , ''));
-
-    $found_searchable_blocks = 0;
-    if ($blocks = $DB->get_records_select('block', "name $searchable_list", $params, 'name', 'id,name')){
-        foreach($blocks as $block){
-            $keyname = 'search_in_'.$block->name;
-            $settings->add(new admin_setting_configcheckbox($keyname, get_string('pluginname', 'block_'.$block->name),
-                               get_string('enableindexinginblock', 'block_search', $block->name), 1, 1, 0));
-            $found_searchable_blocks = 1;
-        }
-    }
-    if (!$found_searchable_blocks) {
-        //header
-        $propname = 'block_search_nosearchableblocks';
-        $settings->add(new admin_setting_heading($propname, get_string('nosearchableblocks', 'block_search') , ''));
-    }
-
-}
-
index 95f3e9a..5255a72 100644 (file)
@@ -842,7 +842,7 @@ function calendar_filter_controls(moodle_url $returnurl) {
 
     $id = optional_param( 'id',0,PARAM_INT );
 
-    $seturl = new moodle_url('/calendar/set.php', array('return' => $returnurl));
+    $seturl = new moodle_url('/calendar/set.php', array('return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
 
     $content = '<table>';
     $content .= '<tr>';
index 8e502a8..48d1ef3 100644 (file)
@@ -580,7 +580,7 @@ class core_calendar_renderer extends plugin_renderer_base {
         $output .= html_writer::start_tag('tr');
 
         // Global events
-        $link = new moodle_url(CALENDAR_URL.'set.php', array('var' => 'showglobal', 'return' => $returnurl));
+        $link = new moodle_url(CALENDAR_URL.'set.php', array('var' => 'showglobal', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
         if (calendar_show_event_type(CALENDAR_EVENT_GLOBAL)) {
             $output .= html_writer::tag('td', '', array('class'=>'calendar_event_global', 'style'=>'width:8px;'));
             $output .= html_writer::tag('td', html_writer::tag('strong', get_string('globalevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -590,7 +590,7 @@ class core_calendar_renderer extends plugin_renderer_base {
         }
 
         // Course events
-        $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showcourses', 'return' => $returnurl));
+        $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showcourses', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
         if (calendar_show_event_type(CALENDAR_EVENT_COURSE)) {
             $output .= html_writer::tag('td', '', array('class'=>'calendar_event_course', 'style'=>'width:8px;'));
             $output .= html_writer::tag('td', html_writer::tag('strong', get_string('courseevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -603,7 +603,7 @@ class core_calendar_renderer extends plugin_renderer_base {
         if(isloggedin() && !isguestuser()) {
             $output .= html_writer::start_tag('tr');
             // Group events
-            $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showgroups', 'return' => $returnurl));
+            $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showgroups', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
             if (calendar_show_event_type(CALENDAR_EVENT_GROUP)) {
                 $output .= html_writer::tag('td', '', array('class'=>'calendar_event_group', 'style'=>'width:8px;'));
                 $output .= html_writer::tag('td', html_writer::tag('strong', get_string('groupevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -612,7 +612,7 @@ class core_calendar_renderer extends plugin_renderer_base {
                 $output .= html_writer::tag('td', html_writer::tag('strong', get_string('groupevents', 'calendar')).' '.get_string('hidden', 'calendar').' ('.html_writer::link($link, get_string('clickshow', 'calendar')).')');
             }
             // User events
-            $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showuser', 'return' => $returnurl));
+            $link = new moodle_url(CALENDAR_URL.'set.php', array('var'=>'showuser', 'return' => base64_encode($returnurl->out(false)), 'sesskey'=>sesskey()));
             if (calendar_show_event_type(CALENDAR_EVENT_USER)) {
                 $output .= html_writer::tag('td', '', array('class'=>'calendar_event_user', 'style'=>'width:8px;'));
                 $output .= html_writer::tag('td', html_writer::tag('strong', get_string('userevents', 'calendar')).' '.get_string('shown', 'calendar').' ('.html_writer::link($link, get_string('clickhide', 'calendar')).')');
@@ -701,7 +701,7 @@ class core_calendar_renderer extends plugin_renderer_base {
         } else {
             $selected = '';
         }
-        $select = new single_select(new moodle_url(CALENDAR_URL.'set.php', array('return' => $returnurl, 'var' => 'setcourse')), 'id', $courseoptions, $selected, null);
+        $select = new single_select(new moodle_url(CALENDAR_URL.'set.php', array('return' => base64_encode($returnurl->out(false)), 'var' => 'setcourse', 'sesskey'=>sesskey())), 'id', $courseoptions, $selected, null);
         $select->class = 'cal_courses_flt';
         if ($label !== null) {
             $select->label = $label;
index 020a636..0122b58 100644 (file)
 require_once('../config.php');
 require_once($CFG->dirroot.'/calendar/lib.php');
 
-$return = required_param('return', PARAM_URL);
+require_sesskey();
+
 $var = required_param('var', PARAM_ALPHA);
+$return = clean_param(base64_decode(required_param('return', PARAM_RAW)), PARAM_URL);
 
-$url = new moodle_url('/calendar/set.php', array('return'=>$return,'var'=>$var));
+$url = new moodle_url('/calendar/set.php', array('return'=>base64_encode($return->out(false)),'var'=>$var, 'sesskey'=>sesskey()));
 $PAGE->set_url($url);
-$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM)); //TODO: wrong
+$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
 
 switch($var) {
     case 'showgroups':
index 02004b4..5c3caa8 100644 (file)
@@ -82,6 +82,7 @@ $PAGE->set_heading($course->fullname);
 $PAGE->navbar->add(get_string('enrolmentoptions','enrol'));
 
 echo $OUTPUT->header();
+echo $OUTPUT->heading(get_string('enrolmentoptions','enrol'));
 
 //TODO: find if future enrolments present and display some info
 
index 14a62f8..a1edd91 100644 (file)
@@ -47,6 +47,7 @@ $string['longtimenosee_help'] = 'If users haven\'t accessed a course for a long
 $string['maxenrolled'] = 'Max enrolled users';
 $string['maxenrolled_help'] = 'Specifies the maximum number of users that can self enrol. 0 means no limit.';
 $string['maxenrolledreached'] = 'Maximum number of users allowed to self-enrol was already reached.';
+$string['nopassword'] = 'No enrolment key required.';
 $string['password'] = 'Enrolment key';
 $string['password_help'] = 'An enrolment key enables access to the course to be restricted to only those who know the key.
 
index d86d0cb..378b54a 100644 (file)
@@ -189,15 +189,6 @@ class enrol_self_plugin extends enrol_plugin {
             return null;
         }
 
-        if ($instance->customint3 > 0) {
-            // max enrol limit specified
-            $count = $DB->count_records('user_enrolments', array('enrolid'=>$instance->id));
-            if ($count >= $instance->customint3) {
-                // bad luck, no more self enrolments here
-                return $OUTPUT->notification(get_string('maxenrolledreached', 'enrol_self'));
-            }
-        }
-
         require_once("$CFG->dirroot/enrol/self/locallib.php");
         require_once("$CFG->dirroot/group/lib.php");
 
index 2d74493..1742339 100644 (file)
@@ -30,6 +30,7 @@ require_once("$CFG->libdir/formslib.php");
 
 class enrol_self_enrol_form extends moodleform {
     protected $instance;
+    protected $toomany = false;
 
     /**
      * Overriding this function to get unique form id for multiple self enrolments
@@ -42,19 +43,33 @@ class enrol_self_enrol_form extends moodleform {
     }
 
     public function definition() {
+        global $DB;
+
         $mform = $this->_form;
         $instance = $this->_customdata;
         $this->instance = $instance;
         $plugin = enrol_get_plugin('self');
 
+        $heading = $plugin->get_instance_name($instance);
+        $mform->addElement('header', 'selfheader', $heading);
+
+        if ($instance->customint3 > 0) {
+            // max enrol limit specified
+            $count = $DB->count_records('user_enrolments', array('enrolid'=>$instance->id));
+            if ($count >= $instance->customint3) {
+                // bad luck, no more self enrolments here
+                $this->toomany = true;
+                $mform->addElement('static', 'notice', '', get_string('maxenrolledreached', 'enrol_self'));
+                return;
+            }
+        }
+
         if ($instance->password) {
-            $heading = $plugin->get_instance_name($instance);
-            $mform->addElement('header', 'selfheader', $heading);
             //change the id of self enrolment key input as there can be multiple self enrolment methods
             $mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_self'),
                     array('id' => $instance->id."_enrolpassword"));
         } else {
-            // nothing?
+            $mform->addElement('static', 'nokey', '', get_string('nopassword', 'enrol_self'));
         }
 
         $this->add_action_buttons(false, get_string('enrolme', 'enrol_self'));
@@ -74,6 +89,11 @@ class enrol_self_enrol_form extends moodleform {
         $errors = parent::validation($data, $files);
         $instance = $this->instance;
 
+        if ($this->toomany) {
+            $errors['notice'] = get_string('error');
+            return $errors;
+        }
+
         if ($instance->password) {
             if ($data['enrolpassword'] !== $instance->password) {
                 if ($instance->customint1) {
index e0178ca..b23c042 100644 (file)
@@ -26,5 +26,5 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$plugin->version = 2010090501;
+$plugin->version = 2010090502;
 $plugin->cron    = 180;
\ No newline at end of file
diff --git a/filter/data/db/install.php b/filter/data/db/install.php
new file mode 100644 (file)
index 0000000..dd171b8
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Database activity filter post install hook
+ *
+ * @package    filter
+ * @subpackage data
+ * @copyright  2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+function xmldb_filter_data_install() {
+    global $DB;
+
+    // If the legacy mod/data filter is installed we need to:
+    //   1- Delete new filter (filter_active and filter_config) information, in order to
+    //   2- Usurpate the identity of the legacy filter by moving all its
+    //      information to filter/data
+    // If the legacy mod/data filter was not installed, no action is needed
+    if ($DB->record_exists('filter_active', array('filter' => 'mod/data'))) {
+        $DB->delete_records('filter_active', array('filter' => 'filter/data'));
+        $DB->set_field('filter_active', 'filter', 'filter/data', array('filter' => 'mod/data'));
+    }
+}
diff --git a/filter/data/filter.php b/filter/data/filter.php
new file mode 100644 (file)
index 0000000..60ca85f
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This filter provides automatic linking to database activity entries
+ * when found inside every Moodle text.
+ *
+ * @package    filter
+ * @subpackage data
+ * @copyright  2006 Vy-Shane Sin Fat
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Database activity filtering
+ */
+class filter_data extends moodle_text_filter {
+
+    public function filter($text, array $options = array()) {
+        global $CFG, $DB;
+
+        // Trivial-cache - keyed on $cachedcontextid
+        static $cachedcontextid;
+        static $contentlist;
+
+        static $nothingtodo;
+
+        // Try to get current course
+        if (!$courseid = get_courseid_from_context($this->context)) {
+            $courseid = 0;
+        }
+
+        // Initialise/invalidate our trivial cache if dealing with a different context
+        if (!isset($cachedcontextid) || $cachedcontextid !== $this->context->id) {
+            $cachedcontextid = $this->context->id;
+            $contentlist = array();
+            $nothingtodo = false;
+        }
+
+        if ($nothingtodo === true) {
+            return $text;
+        }
+
+        // Create a list of all the resources to search for. It may be cached already.
+        if (empty($contentlist)) {
+            $coursestosearch = $courseid ? array($courseid) : array(); // Add courseid if found
+            if (get_site()->id != $courseid) { // Add siteid if was not courseid
+                $coursestosearch[] = get_site()->id;
+            }
+            // We look for text field contents only if have autolink enabled (param1)
+            list ($coursesql, $params) = $DB->get_in_or_equal($coursestosearch);
+            $sql = 'SELECT dc.id AS contentid, dr.id AS recordid, dc.content AS content, d.id AS dataid
+                      FROM {data} d
+                      JOIN {data_fields} df ON df.dataid = d.id
+                      JOIN {data_records} dr ON dr.dataid = d.id
+                      JOIN {data_content} dc ON dc.fieldid = df.id AND dc.recordid = dr.id
+                     WHERE d.course ' . $coursesql . '
+                       AND df.type = \'text\'
+                       AND ' . $DB->sql_compare_text('df.param1', 1) . ' = 1';
+
+            if (!$contents = $DB->get_records_sql($sql, $params)) {
+                $nothingtodo = true;
+                return $text;
+            }
+
+            foreach ($contents as $key => $content) {
+                // Trim empty or unlinkable concepts
+                $currentcontent = trim(strip_tags($content->content));
+                if (empty($currentcontent)) {
+                    unset($contents[$key]);
+                    continue;
+                } else {
+                    $contents[$key]->content = $currentcontent;
+                }
+
+                // Rule out any small integers.  See bug 1446
+                $currentint = intval($currentcontent);
+                if ($currentint && (strval($currentint) == $currentcontent) && $currentint < 1000) {
+                    unset($contents[$key]);
+                }
+            }
+
+            if (empty($contents)) {
+                $nothingtodo = true;
+                return $text;
+            }
+
+            usort($contents, 'filter_data::sort_entries_by_length');
+
+            foreach ($contents as $content) {
+                $href_tag_begin = '<a class="data autolink dataid'.$content->dataid.'" title="'.$content->content.'" '.
+                                  'href="'.$CFG->wwwroot.'/mod/data/view.php?d='.$content->dataid.
+                                  '&amp;rid='.$content->recordid.'">';
+                $contentlist[] = new filterobject($content->content, $href_tag_begin, '</a>', false, true);
+            }
+
+            $contentlist = filter_remove_duplicates($contentlist); // Clean dupes
+        }
+        return filter_phrases($text, $contentlist);  // Look for all these links in the text
+    }
+
+    private static function sort_entries_by_length($content0, $content1) {
+        $len0 = strlen($content0->content);
+        $len1 = strlen($content1->content);
+
+        if ($len0 < $len1) {
+            return 1;
+        } else if ($len0 > $len1) {
+            return -1;
+        } else {
+            return 0;
+        }
+    }
+}
similarity index 68%
rename from blocks/search/version.php
rename to filter/data/lang/en/filter_data.php
index b745682..a6d1f4d 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 // You should have received a copy of the GNU General Public License
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-$plugin->version = 2010111100;
-$plugin->cron = 1;
+/**
+ * Strings for filter_data
+ *
+ * @package    filter
+ * @subpackage data
+ * @copyright  2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$string['filtername'] = 'Database auto-linking';
similarity index 54%
rename from blocks/search/db/upgradelib.php
rename to filter/data/version.php
index a85c452..a6ec47b 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
- * Global search block upgrade related helper functions
+ * Data activity filter version information
  *
- * @package    blocks
- * @subpackage search
- * @copyright  2010 Aparup Banerjee
+ * @package    filter
+ * @subpackage data
+ * @copyright  2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
 
 defined('MOODLE_INTERNAL') || die();
 
-/*
-* Function to turn a mysql(datetime) or postgres(timestamp without timezone data) or any generic date string (YYYY-MM-DD HH:MM:SS)
-* read in from a database's date/time field (ie:valid) into a unix timestamp
-* @param str The string to be converted to timestamp
-* @return timestamp or 0
-*/
-
-function convert_datetime_upgrade($str) {
-
-    $timestamp = strtotime($str);
-    //process different failure returns due to different php versions
-    if ($timestamp === false || $timestamp < 1) {
-        return 0;
-    } else {
-        return $timestamp;
-    }
-}
+$plugin->version  = 2011102800;
+$plugin->requires = 2011102700;  // Requires this Moodle version
+$plugin->component= 'filter_data';
 
+$plugin->dependencies = array('mod_data' => 2011102800);
diff --git a/filter/glossary/db/install.php b/filter/glossary/db/install.php
new file mode 100644 (file)
index 0000000..76bf66f
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Glossary filter post install hook
+ *
+ * @package    filter
+ * @subpackage glossary
+ * @copyright  2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+function xmldb_filter_glossary_install() {
+    global $DB;
+
+    // If the legacy mod/glossary filter is installed we need to:
+    //   1- Delete new filter (filter_active and filter_config) information, in order to
+    //   2- Usurpate the identity of the legacy filter by moving all its
+    //      information to filter/glossary
+    // If the legacy mod/glossary filter was not installed, no action is needed
+    if ($DB->record_exists('filter_active', array('filter' => 'mod/glossary'))) {
+        $DB->delete_records('filter_active', array('filter' => 'filter/glossary'));
+        $DB->set_field('filter_active', 'filter', 'filter/glossary', array('filter' => 'mod/glossary'));
+    }
+}
diff --git a/filter/glossary/filter.php b/filter/glossary/filter.php
new file mode 100644 (file)
index 0000000..8592626
--- /dev/null
@@ -0,0 +1,226 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * This filter provides automatic linking to
+ * glossary entries, aliases and categories when
+ * found inside every Moodle text
+ *
+ * @package    filter
+ * @subpackage glossary
+ * @copyright  2004 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Glossary filtering
+ *
+ * TODO: erase the $GLOSSARY_EXCLUDECONCEPTS global => require format_text()
+ *       to be able to pass arbitrary $options['filteroptions']['glossary'] to filter_text()
+ */
+class filter_glossary extends moodle_text_filter {
+
+    public function filter($text, array $options = array()) {
+        global $CFG, $DB, $GLOSSARY_EXCLUDECONCEPTS, $PAGE;
+
+        // Trivial-cache - keyed on $cachedcontextid
+        static $cachedcontextid;
+        static $conceptlist;
+
+        static $jsinitialised;       // To control unique js init
+        static $nothingtodo;         // To avoid processing if no glossaries / concepts are found
+
+        // Try to get current course
+        if (!$courseid = get_courseid_from_context($this->context)) {
+            $courseid = 0;
+        }
+
+        // Initialise/invalidate our trivial cache if dealing with a different context
+        if (!isset($cachedcontextid) || $cachedcontextid !== $this->context->id) {
+            $cachedcontextid = $this->context->id;
+            $conceptlist = array();
+            $nothingtodo = false;
+        }
+
+        if ($nothingtodo === true) {
+            return $text;
+        }
+
+        // Create a list of all the concepts to search for.  It may be cached already.
+        if (empty($conceptlist)) {
+
+            // Find all the glossaries we need to examine
+            if (!$glossaries = $DB->get_records_sql_menu('
+                    SELECT g.id, g.name
+                      FROM {glossary} g, {course_modules} cm, {modules} m
+                     WHERE m.name = \'glossary\'
+                       AND cm.module = m.id
+                       AND cm.visible = 1
+                       AND g.id = cm.instance
+                       AND g.usedynalink != 0
+                       AND (g.course = ? OR g.globalglossary = 1)
+                  ORDER BY g.globalglossary, g.id', array($courseid))) {
+                $nothingtodo = true;
+                return $text;
+            }
+
+            // Make a list of glossary IDs for searching
+            $glossarylist = implode(',', array_keys($glossaries));
+
+            // Pull out all the raw data from the database for entries, categories and aliases
+            $entries = $DB->get_records_select('glossary_entries',
+                    'glossaryid IN ('.$glossarylist.') AND usedynalink != 0 AND approved != 0 ', null, '',
+                    'id,glossaryid, concept, casesensitive, 0 AS category, fullmatch');
+
+            $categories = $DB->get_records_select('glossary_categories',
+                    'glossaryid IN ('.$glossarylist.') AND usedynalink != 0', null, '',
+                    'id,glossaryid,name AS concept, 1 AS casesensitive, 1 AS category, 1 AS fullmatch');
+
+            $aliases = $DB->get_records_sql('
+                    SELECT ga.id, ge.id AS entryid, ge.glossaryid,
+                           ga.alias AS concept, ge.concept AS originalconcept,
+                           casesensitive, 0 AS category, fullmatch
+                      FROM {glossary_alias} ga,
+                           {glossary_entries} ge
+                      WHERE ga.entryid = ge.id
+                        AND ge.glossaryid IN ('.$glossarylist.')
+                        AND ge.usedynalink != 0
+                        AND ge.approved != 0', null);
+
+            // Combine them into one big list
+            $concepts = array();
+            if ($entries and $categories) {
+                $concepts = array_merge($entries, $categories);
+            } else if ($categories) {
+                $concepts = $categories;
+            } else if ($entries) {
+                $concepts = $entries;
+            }
+
+            if ($aliases) {
+                $concepts = array_merge($concepts, $aliases);
+            }
+
+            if (!empty($concepts)) {
+                foreach ($concepts as $key => $concept) {
+                    // Trim empty or unlinkable concepts
+                    $currentconcept = trim(strip_tags($concept->concept));
+                    if (empty($currentconcept)) {
+                        unset($concepts[$key]);
+                        continue;
+                    } else {
+                        $concepts[$key]->concept = $currentconcept;
+                    }
+
+                    // Rule out any small integers.  See bug 1446
+                    $currentint = intval($currentconcept);
+                    if ($currentint && (strval($currentint) == $currentconcept) && $currentint < 1000) {
+                        unset($concepts[$key]);
+                    }
+                }
+            }
+
+            if (empty($concepts)) {
+                $nothingtodo = true;
+                return $text;
+            }
+
+            usort($concepts, 'filter_glossary::sort_entries_by_length');
+
+            $strcategory = get_string('category', 'glossary');
+
+            // Loop through all the concepts, setting up our data structure for the filter
+            $conceptlist = array();    // We will store all the concepts here
+
+            foreach ($concepts as $concept) {
+                $glossaryname = str_replace(':', '-', $glossaries[$concept->glossaryid]);
+                if ($concept->category) {       // Link to a category
+                    // TODO: Fix this string usage
+                    $title = strip_tags($glossaryname.': '.$strcategory.' '.$concept->concept);
+                    $href_tag_begin = '<a class="glossary autolink category glossaryid'.$concept->glossaryid.'" title="'.$title.'" '.
+                                      'href="'.$CFG->wwwroot.'/mod/glossary/view.php?g='.$concept->glossaryid.
+                                      '&amp;mode=cat&amp;hook='.$concept->id.'">';
+                } else { // Link to entry or alias
+                    if (!empty($concept->originalconcept)) {  // We are dealing with an alias (so show and point to original)
+                        $title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->originalconcept));
+                        $concept->id = $concept->entryid;
+                    } else { // This is an entry
+                        $title = str_replace('"', "'", strip_tags($glossaryname.': '.$concept->concept));
+                    }
+                    // hardcoding dictionary format in the URL rather than defaulting
+                    // to the current glossary format which may not work in a popup.
+                    // for example "entry list" means the popup would only contain
+                    // a link that opens another popup.
+                    $link = new moodle_url('/mod/glossary/showentry.php', array('courseid'=>$courseid, 'eid'=>$concept->id, 'displayformat'=>'dictionary'));
+                    $attributes = array(
+                        'href' => $link,
+                        'title'=> $title,
+                        'class'=> 'glossary autolink concept glossaryid'.$concept->glossaryid);
+
+                    // this flag is optionally set by resource_pluginfile()
+                    // if processing an embedded file use target to prevent getting nested Moodles
+                    if (isset($CFG->embeddedsoforcelinktarget) && $CFG->embeddedsoforcelinktarget) {
+                        $attributes['target'] = '_top';
+                    }
+
+                    $href_tag_begin = html_writer::start_tag('a', $attributes);
+                }
+                $conceptlist[] = new filterobject($concept->concept, $href_tag_begin, '</a>',
+                    $concept->casesensitive, $concept->fullmatch);
+            }
+
+            $conceptlist = filter_remove_duplicates($conceptlist);
+
+            if (empty($jsinitialised)) {
+                // Add a JavaScript event to open popup's here. This only ever need to be
+                // added once!
+                $PAGE->requires->yui_module(
+                        'moodle-filter_glossary-autolinker',
+                        'M.filter_glossary.init_filter_autolinking',
+                        array(array('courseid' => $courseid)));
+                $jsinitialised = true;
+            }
+        }
+
+        if (!empty($GLOSSARY_EXCLUDECONCEPTS)) {
+            $reducedconceptlist=array();
+            foreach($conceptlist as $concept) {
+                if(!in_array($concept->phrase,$GLOSSARY_EXCLUDECONCEPTS)) {
+                    $reducedconceptlist[]=$concept;
+                }
+            }
+            return filter_phrases($text, $reducedconceptlist);
+        }
+
+        return filter_phrases($text, $conceptlist);   // Actually search for concepts!
+    }
+
+
+    private static function sort_entries_by_length($entry0, $entry1) {
+        $len0 = strlen($entry0->concept);
+        $len1 = strlen($entry1->concept);
+
+        if ($len0 < $len1) {
+            return 1;
+        } else if ($len0 > $len1) {
+            return -1;
+        } else {
+            return 0;
+        }
+    }
+}
diff --git a/filter/glossary/lang/en/filter_glossary.php b/filter/glossary/lang/en/filter_glossary.php
new file mode 100644 (file)
index 0000000..5ca0606
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for filter_glossary
+ *
+ * @package    filter
+ * @subpackage glossary
+ * @copyright  2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$string['filtername'] = 'Glossary auto-linking';
diff --git a/filter/glossary/styles.css b/filter/glossary/styles.css
new file mode 100644 (file)
index 0000000..8a78bdb
--- /dev/null
@@ -0,0 +1 @@
+#glossaryfilteroverlayprogress {position:fixed;top:50%;width:100%;text-align:center;}
diff --git a/filter/glossary/version.php b/filter/glossary/version.php
new file mode 100644 (file)
index 0000000..4628335
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Glossary filter version information
+ *
+ * @package    filter
+ * @subpackage glossary
+ * @copyright  2011 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version  = 2011102800;
+$plugin->requires = 2011102700;  // Requires this Moodle version
+$plugin->component= 'filter_glossary';
+
+$plugin->dependencies = array('mod_glossary' => 2011102800);
similarity index 90%
rename from mod/glossary/yui/autolinker/autolinker.js
rename to filter/glossary/yui/autolinker/autolinker.js
index e8935f3..46d04bc 100644 (file)
@@ -1,6 +1,6 @@
-YUI.add('moodle-mod_glossary-autolinker', function(Y) {
+YUI.add('moodle-filter_glossary-autolinker', function(Y) {
 
-    var AUTOLINKERNAME = 'Glossary autolinker',
+    var AUTOLINKERNAME = 'Glossary filter autolinker',
         URL = 'url',
         POPUPNAME = 'name',
         POPUPOPTIONS = 'options',
@@ -33,7 +33,7 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
 
                 //display a progress indicator
                 var title = '';
-                var content = Y.Node.create('<div id="glossaryoverlayprogress"><img src="'+M.cfg.loadingicon+'" class="spinner" /></div>');
+                var content = Y.Node.create('<div id="glossaryfilteroverlayprogress"><img src="'+M.cfg.loadingicon+'" class="spinner" /></div>');
                 var o = new Y.Overlay({
                     headerContent :  title,
                     bodyContent : content
@@ -61,7 +61,7 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
                 };
                 Y.io(fullurl, cfg);
 
-            }, Y.one(document.body), 'a.glossary.autolink');
+            }, Y.one(document.body), 'a.glossary.autolink.concept');
         },
         display_callback : function(content) {
             try {
@@ -126,9 +126,9 @@ YUI.add('moodle-mod_glossary-autolinker', function(Y) {
         }
     });
 
-    M.mod_glossary = M.mod_glossary || {};
-    M.mod_glossary.init_filter_autolinking = function(config) {
+    M.filter_glossary = M.filter_glossary || {};
+    M.filter_glossary.init_filter_autolinking = function(config) {
         return new AUTOLINKER(config);
     }
 
-}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});
\ No newline at end of file
+}, '@VERSION@', {requires:['base','node','event-delegate','overlay','moodle-enrol-notification']});
index 5dfe0f2..fcb3a95 100644 (file)
@@ -189,7 +189,6 @@ $string['configenableajax'] = 'This setting allows you to control the use of AJA
 $string['configenablecalendarexport'] = 'Enable exporting or subscribing to calendars.';
 $string['configenablecomments'] = 'Enable comments';
 $string['configenablecourserequests'] = 'This will allow any user to request a course be created.';
-$string['configenableglobalsearch'] = 'This setting enables global text searching in resources and activities, it is not compatible with PHP 4.';
 $string['configenablegroupmembersonly'] = 'If enabled, access to activities can be restricted to group members only. This may result in an increased server load. In addition, gradebook categories must be set up in a certain way to ensure that activities are hidden from non-group members.';
 $string['configenablemobilewebservice'] = 'Enable mobile service for the official Moodle app or other app requesting it. For more information, read the {$a}';
 $string['configenablerssfeeds'] = 'This switch will enable RSS feeds from across the site.  To actually see any change you will need to enable RSS feeds in the individual modules too - go to the Modules settings under Admin Configuration.';
@@ -468,7 +467,6 @@ $string['enablecourseajax'] = 'Enable AJAX course editing';
 $string['enablecourseajax_desc'] = 'Allow AJAX when editing main course pages. Note that the course format and the theme must support AJAX editing and the user has to enable AJAX in their profiles, too.';
 $string['enablecourserequests'] = 'Enable course requests';
 $string['enabledevicedetection'] = 'Enable device detection';
-$string['enableglobalsearch'] = 'Enable global search';
 $string['enablegravatar'] = 'Enable Gravatar';
 $string['enablegravatar_help'] = 'When enabled Moodle will attempt to fetch a user profile picture from Gravatar if the user has not uploaded an image.';
 $string['enablegroupmembersonly'] = 'Enable group members only';
index 0184da5..647f27d 100644 (file)
@@ -6808,6 +6808,38 @@ FROM
         upgrade_main_savepoint(true, 2011101900.02);
     }
 
+    if ($oldversion < 2011102700.01) {
+        // purge everything related to abandoned experimental global search
+
+        // unset setting - this disables it in case user does not delete the dirs
+        unset_config('enableglobalsearch');
+
+        // Delete block, instances and db table
+        $table = new xmldb_table('block_search_documents');
+        if ($dbman->table_exists($table)) {
+            $instances = $DB->get_records('block_instances', array('blockname'=>'search'));
+            foreach($instances as $instance) {
+                context_helper::delete_instance(CONTEXT_BLOCK, $instance->id);
+                $DB->delete_records('block_positions', array('blockinstanceid' => $instance->id));
+                $DB->delete_records('block_instances', array('id' => $instance->id));
+            }
+            $DB->delete_records('block', array('name'=>'search'));
+
+            $dbman->drop_table($table);
+        }
+
+        // purge all settings used by the search block
+        $like = $DB->sql_like('name', '?', true, true, false, '|');
+        $params = array($DB->sql_like_escape('block_search_', '|') . '%', $DB->sql_like_escape('search_in_', '|') . '%');
+        $settings = $DB->get_records_select('config', "$like OR $like", $params);
+        foreach ($settings as $setting) {
+            unset_config($setting->name);
+        }
+
+        upgrade_main_savepoint(true, 2011102700.01);
+    }
+
+
     return true;
 }
 
index 7dd5b93..3feb6de 100644 (file)
@@ -508,10 +508,16 @@ function filter_get_name($filter) {
 function filter_get_all_installed() {
     global $CFG;
     $filternames = array();
+    // TODO: deprecated in 2.2, delete support for "mod" legacy filters location in 2.3. MDL-29996
     $filterlocations = array('mod', 'filter');
     foreach ($filterlocations as $filterlocation) {
+        // TODO: move get_list_of_plugins() to get_plugin_list()
         $filters = get_list_of_plugins($filterlocation);
         foreach ($filters as $filter) {
+            // MDL-29994 - Ignore mod/data and mod/glossary filters forever, this will be out in 2.3
+            if ($filterlocation == 'mod' && ($filter == 'data' || $filter == 'glossary')) {
+                continue;
+            }
             $path = $filterlocation . '/' . $filter;
             if (is_readable($CFG->dirroot . '/' . $path . '/filter.php')) {
                 $strfiltername = filter_get_name($path);
diff --git a/lib/mp3player/index.html b/lib/mp3player/index.html
deleted file mode 100644 (file)
index 8d1c8b6..0000000
+++ /dev/null
@@ -1 +0,0 @@
diff --git a/lib/mp3player/mp3player.fla.zip b/lib/mp3player/mp3player.fla.zip
deleted file mode 100644 (file)
index 23c26ae..0000000
Binary files a/lib/mp3player/mp3player.fla.zip and /dev/null differ
diff --git a/lib/mp3player/mp3player.swf b/lib/mp3player/mp3player.swf
deleted file mode 100644 (file)
index de481d5..0000000
Binary files a/lib/mp3player/mp3player.swf and /dev/null differ
diff --git a/lib/mp3player/readme.txt b/lib/mp3player/readme.txt
deleted file mode 100644 (file)
index c300929..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-Many aspects of the appearance and behaviour of the mp3 player can be customised,
-these custom values are set by passing variables to the flash movie using "flashvars".
-flashvars are supplied to the movie using
-
-<param name="flashvars" value="some value">
-
-alongside the other param tags, and with an extra attribute in the embed tag
-
-flashvars="some value"
-
-the "some value" part is a list of urlencoded variables
-
-&variableName=value&anotherVariable=anotherValue&
-
- +--------------------------------------------------------------------------------------------------------------------+
- | Variable Name   | Possible Values                            | What it does                                        |
- |--------------------------------------------------------------------------------------------------------------------|
- | bgColour        | a colour in the format RRGGBB where        | sets the background colour of the player.           | 
- |                 | RR, GG and BB are hexadecimal values       |                                                     |
- |                 | (00 to FF) representing the Red, Green     |                                                     | 
- |                 | and Blue parts of the colour. eg           |                                                     |
- |                 | ffffff is white, 000000 is black,          |                                                     |
- |                 | ff9900 is orange, 000033 is a dark blue.   |                                                     |
- |                 | the default colour is black.               |                                                     |
- |--------------------------------------------------------------------------------------------------------------------|
- | btnColour       | the same as bgColour, the default colour   | sets the colour of the play and pause buttons.      |
- |                 | is white.                                  |                                                     |
- |--------------------------------------------------------------------------------------------------------------------|
- | btnBorderColour | the same as bgColour, the default colour   | the colour of the border around the buttons.        |
- |                 | is grey.                                   | make this the same as btnColour if you don't want   |
- |                 |                                            | a border.                                           |
- |--------------------------------------------------------------------------------------------------------------------|
- | iconColour      | the same as bgColour, the default colour   | the colour of the play/pause icons.                 |
- |                 | is black.                                  |                                                     |
- |--------------------------------------------------------------------------------------------------------------------|
- | iconOverColour  | the same as bgColour, the default colour   | the colour of the play/pause icons when the mouse   |
- |                 | is green.                                  | is over the button.                                 |
- |--------------------------------------------------------------------------------------------------------------------|
- | handleColour    | the same as bgColour, the default colour   | the colour of the handles on the playback slider,   |
- |                 | is white.                                  | volume and pan controls.                            |
- |--------------------------------------------------------------------------------------------------------------------|
- | trackColour     | the same as bgColour, the default colour   | the colour of the track for the playback slider,    |
- |                 | is grey.                                   | volume and pan controls.                            |
- |--------------------------------------------------------------------------------------------------------------------|
- | loaderColour    | the same as bgColour, the default colour   | the colour of the loading bar.                      |
- |                 | is white.                                  |                                                     |
- |--------------------------------------------------------------------------------------------------------------------|
- | font            | a name of a font, eg verdana. the          | the font used in the movie.                         |
- |                 | default value is Trebuchet MS.             |                                                     |
- |--------------------------------------------------------------------------------------------------------------------|
- | fontColour      | the same as bgColour, the default colour   | the colour of the text.                             |
- |                 | is white                                   |                                                     |
- |--------------------------------------------------------------------------------------------------------------------|
- | waitForPlay     | yes or no, the default is no.              | should the player wait until the play button is     |
- |                 |                                            | pressed before starting to download the file?       |
- |--------------------------------------------------------------------------------------------------------------------|
- | autoPlay        | yes or no, the default is yes.             | will the player wait until the play button is       |
- |                 |                                            | pressed before starting to play the file? if        |
- |--------------------------------------------------------------------------------------------------------------------|
- | buffer          | a value in seconds, the default is 20.     | how many seconds of the file should be buffered     |
- |                 |                                            | before playback starts?                             |
- |--------------------------------------------------------------------------------------------------------------------|
- | volText         | a string (could this come from the         | the text used in the player to label the volume     |
- |                 | language pack?) the default is "Vol".      | control.                                            |
- |--------------------------------------------------------------------------------------------------------------------|
- | panText         | the same as volText. the default is "Pan". | the text used in the player to label the pan        |
- |                 |                                            | control.                                            |
- +--------------------------------------------------------------------------------------------------------------------+
-
-
-a brightly coloured example ;)
-
-<param name="flashvars" value="&bgColour=ffff00&btnColour=00ff00&&btnBorderColour=ff9900iconColour=000000&iconOverColour=ff00ff&handleColour=ff00ff&trackColour=000000&loaderColour=ff9900&font=verdana&fontColour=ff0000&waitForPlay=no&dontAutoPlay=yes&buffer=30&">
-
-the content of the value attribute would need to be repeated and included as the value of 
-the flashvars attribute in the embed tag.
-
-
-extra notes...
-
-the song information comes from 2 sources, initally the player displays the filename (minus the file extension) 
-as the title, once the file is fully loaded it checks the id3 data in the mp3 file for the songname, artist and year 
-and displays this information instead of the filename.
-
-
-Andy Walker (www.altoncollege.ac.uk)
-
index 02719a7..a1e0ade 100644 (file)
@@ -241,7 +241,7 @@ class plugin_manager {
                 return false;
             }
 
-            if ($requiredversion != ANY_VERSION and $otherplugin->versiondb < $requiredversion) {
+            if ($requiredversion != ANY_VERSION and $otherplugin->versiondisk < $requiredversion) {
                 return false;
             }
         }
@@ -298,7 +298,7 @@ class plugin_manager {
                 'login', 'mentees', 'messages', 'mnet_hosts', 'myprofile',
                 'navigation', 'news_items', 'online_users', 'participants',
                 'private_files', 'quiz_results', 'recent_activity',
-                'rss_client', 'search', 'search_forums', 'section_links',
+                'rss_client', 'search_forums', 'section_links',
                 'selfcompletion', 'settings', 'site_main_menu',
                 'social_activities', 'tag_flickr', 'tag_youtube', 'tags'
             ),
index 25c8e72..4df0be9 100644 (file)
@@ -233,6 +233,8 @@ function resourcelib_embed_mp3($fullurl, $title, $clicktoopen) {
 
     if ($fullurl instanceof moodle_url) {
         $fullurl = $fullurl->out(false);
+    } else {
+        $fullurl = str_replace('&amp;', '&', $fullurl);
     }
 
     $id = 'resource_mp3_'.time(); //we need something unique because it might be stored in text cache
@@ -259,6 +261,8 @@ function resourcelib_embed_flashvideo($fullurl, $title, $clicktoopen) {
 
     if ($fullurl instanceof moodle_url) {
         $fullurl = $fullurl->out(false);
+    } else {
+        $fullurl = str_replace('&amp;', '&', $fullurl);
     }
 
     $id = 'resource_flv_'.time(); //we need something unique because it might be stored in text cache
index c4a390c..727b64e 100644 (file)
@@ -959,7 +959,7 @@ class assignment_base {
         /// Get all ppl that can submit assignments
 
         $currentgroup = groups_get_activity_group($cm);
-        $users = get_enrolled_users($context, 'mod/assignment:view', $currentgroup, 'u.id');
+        $users = get_enrolled_users($context, 'mod/assignment:submit', $currentgroup, 'u.id');
         if ($users) {
             $users = array_keys($users);
             // if groupmembersonly used, remove users who are not in any group
index a711570..c1d4ffd 100644 (file)
@@ -44,6 +44,7 @@ class assignment_upload extends assignment_base {
         global $USER, $OUTPUT;
 
         require_capability('mod/assignment:view', $this->context);
+        $cansubmit = has_capability('mod/assignment:submit', $this->context);
 
         add_to_log($this->course->id, 'assignment', 'view', "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
 
@@ -67,35 +68,34 @@ class assignment_upload extends assignment_base {
             } else {
                 $filecount = 0;
             }
+            if ($cansubmit or !empty($filecount)) { //if a user has submitted files using a previous role we should still show the files
+                $this->view_feedback();
 
-            $this->view_feedback();
-
-            if (!$this->drafts_tracked() or !$this->isopen() or $this->is_finalized($submission)) {
-                echo $OUTPUT->heading(get_string('submission', 'assignment'), 3);
-            } else {
-                echo $OUTPUT->heading(get_string('submissiondraft', 'assignment'), 3);
-            }
+                if (!$this->drafts_tracked() or !$this->isopen() or $this->is_finalized($submission)) {
+                    echo $OUTPUT->heading(get_string('submission', 'assignment'), 3);
+                } else {
+                    echo $OUTPUT->heading(get_string('submissiondraft', 'assignment'), 3);
+                }
 
-            if ($filecount and $submission) {
-                echo $OUTPUT->box($this->print_user_files($USER->id, true), 'generalbox boxaligncenter', 'userfiles');
-            } else {
-                if (!$this->isopen() or $this->is_finalized($submission)) {
-                    echo $OUTPUT->box(get_string('nofiles', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+                if ($filecount and $submission) {
+                    echo $OUTPUT->box($this->print_user_files($USER->id, true), 'generalbox boxaligncenter', 'userfiles');
                 } else {
-                    echo $OUTPUT->box(get_string('nofilesyet', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+                    if (!$this->isopen() or $this->is_finalized($submission)) {
+                        echo $OUTPUT->box(get_string('nofiles', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+                    } else {
+                        echo $OUTPUT->box(get_string('nofilesyet', 'assignment'), 'generalbox boxaligncenter nofiles', 'userfiles');
+                    }
                 }
-            }
 
-            if (has_capability('mod/assignment:submit', $this->context)) {
                 $this->view_upload_form();
-            }
 
-            if ($this->notes_allowed()) {
-                echo $OUTPUT->heading(get_string('notes', 'assignment'), 3);
-                $this->view_notes();
-            }
+                if ($this->notes_allowed()) {
+                    echo $OUTPUT->heading(get_string('notes', 'assignment'), 3);
+                    $this->view_notes();
+                }
 
-            $this->view_final_submission();
+                $this->view_final_submission();
+            }
         }
         $this->view_footer();
     }
diff --git a/mod/data/filter.php b/mod/data/filter.php
deleted file mode 100644 (file)
index 6a81b2b..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-    //
-    // This function provides automatic linking to data contents of text
-    // fields where these fields have autolink enabled.
-    //
-    // Original code by Williams, Stronk7, Martin D.
-    // Modified for data module by Vy-Shane SF.
-
-    function data_filter($courseid, $text) {
-        global $CFG, $DB;
-
-        static $nothingtodo;
-        static $contentlist;
-
-        if (!empty($nothingtodo)) {   // We've been here in this page already
-            return $text;
-        }
-
-        // if we don't have a courseid, we can't run the query, so
-        if (empty($courseid)) {
-            return $text;
-        }
-
-        // Create a list of all the resources to search for. It may be cached already.
-        if (empty($contentlist)) {
-            // We look for text field contents only, and only if the field has
-            // autolink enabled (param1).
-            $sql = 'SELECT dc.id AS contentid, ' .
-                   'dr.id AS recordid, ' .
-                   'dc.content AS content, ' .
-                   'd.id AS dataid ' .
-                        'FROM {data} d, ' .
-                             '{data_fields} df, ' .
-                             '{data_records} dr, ' .
-                             '{data_content} dc ' .
-                            "WHERE (d.course = ? or d.course = '".SITEID."')" .
-                            'AND d.id = df.dataid ' .
-                            'AND df.id = dc.fieldid ' .
-                            'AND d.id = dr.dataid ' .
-                            'AND dr.id = dc.recordid ' .
-                            "AND df.type = 'text' " .
-                            "AND " . $DB->sql_compare_text('df.param1', 1) . " = '1'";
-
-            if (!$datacontents = $DB->get_records_sql($sql, array($courseid))) {
-                return $text;
-            }
-
-            $contentlist = array();
-
-            foreach ($datacontents as $datacontent) {
-                $currentcontent = trim($datacontent->content);
-                $strippedcontent = strip_tags($currentcontent);
-
-                if (!empty($strippedcontent)) {
-                    $contentlist[] = new filterobject(
-                                            $currentcontent,
-                                            '<a class="data autolink" title="'.
-                                            $strippedcontent.'" href="'.
-                                            $CFG->wwwroot.'/mod/data/view.php?d='. $datacontent->dataid .
-                                            '&amp;rid='. $datacontent->recordid .'">',
-                                            '</a>', false, true);
-                }
-            } // End foreach
-        }
-        return  filter_phrases($text, $contentlist);  // Look for all these links in the text
-    }
-
-
index deba450..241c818 100644 (file)
@@ -1,12 +1,30 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
-////////////////////////////////////////////////////////////////////////////////
-//  Code fragment to define the module version etc.
-//  This fragment is called by /admin/index.php
-////////////////////////////////////////////////////////////////////////////////
-
-$module->version  = 2011052300;
-$module->requires = 2011052300;  // Requires this Moodle version
-$module->cron     = 60;
+/**
+ * Data module version information
+ *
+ * @package    mod
+ * @subpackage data
+ * @copyright  2005 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
 
+defined('MOODLE_INTERNAL') || die();
 
+$module->version  = 2011102800;
+$module->requires = 2011102700;  // Requires this Moodle version
+$module->cron     = 60;          // Period for cron to check this module (secs)
index 9a0c603..c88bf75 100644 (file)
@@ -135,7 +135,8 @@ Now it only runs on Moodle 1.8 or later
 - roles are full implemented
 - now radiobuttons and checkboxes can be aligned horizontally or vertically
 - now you can insert pagebreakes
-- a feedback what is switch to the next page is saved temporary. the user can cancel the completion and later continue at the last filled page.
+- a feedback what is switch to the next page is saved temporary.
+  the user can cancel the completion and later continue at the last filled page.
 - now you can ex-/import feedbacks into/from a xml-file
 - course-reseting is supported
 
index 78f46d5..da86ecf 100644 (file)
@@ -1,4 +1,18 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
  * shows an analysed view of feedback
@@ -11,7 +25,6 @@
 require_once("../../config.php");
 require_once("lib.php");
 
-// $SESSION->feedback->current_tab = 'analysis';
 $current_tab = 'analysis';
 
 $id = required_param('id', PARAM_INT);  //the POST dominated the GET
@@ -39,23 +52,23 @@ if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
         print_error('badcontext');
 }
 
-if($course->id == SITEID) {
+if ($course->id == SITEID) {
     require_login($course->id, true);
-}else{
+} else {
     require_login($course->id, true, $cm);
 }
 
 //check whether the given courseid exists
-if($courseid AND $courseid != SITEID) {
-    if($course2 = $DB->get_record('course', array('id'=>$courseid))){
+if ($courseid AND $courseid != SITEID) {
+    if ($course2 = $DB->get_record('course', array('id'=>$courseid))) {
         require_course_login($course2); //this overwrites the object $course :-(
         $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
-    }else {
+    } else {
         print_error('invalidcourseid');
     }
 }
 
-if( !( ((intval($feedback->publish_stats) == 1) AND
+if ( !( ((intval($feedback->publish_stats) == 1) AND
         has_capability('mod/feedback:viewanalysepage', $context)) OR
         has_capability('mod/feedback:viewreports', $context))) {
     print_error('error');
@@ -65,30 +78,29 @@ if( !( ((intval($feedback->publish_stats) == 1) AND
 $strfeedbacks = get_string("modulenameplural", "feedback");
 $strfeedback  = get_string("modulename", "feedback");
 
-$PAGE->navbar->add(get_string('analysis','feedback'));
+$PAGE->navbar->add(get_string('analysis', 'feedback'));
 $PAGE->set_heading(format_string($course->fullname));
 $PAGE->set_title(format_string($feedback->name));
 echo $OUTPUT->header();
 
 /// print the tabs
-include('tabs.php');
+require('tabs.php');
 
 
 //print analysed items
 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
 
 //get the groupid
-$groupselect = groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/feedback/analysis.php?id=' . $cm->id.'&do_show=analysis', true);
+$myurl = $CFG->wwwroot.'/mod/feedback/analysis.php?id='.$cm->id.'&do_show=analysis';
+$groupselect = groups_print_activity_menu($cm, $myurl, true);
 $mygroupid = groups_get_activity_group($cm);
 
-if( has_capability('mod/feedback:viewreports', $context) ) {
+if ( has_capability('mod/feedback:viewreports', $context) ) {
 
     echo isset($groupselect) ? $groupselect : '';
     echo '<div class="clearer"></div>';
 
     //button "export to excel"
-    //echo '<div class="mdl-align">';
-    // echo '<div class="feedback_centered_button">';
     echo $OUTPUT->container_start('form-buttons');
     $aurl = new moodle_url('analysis_to_excel.php', array('sesskey'=>sesskey(), 'id'=>$id));
     echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback'));
@@ -99,50 +111,55 @@ if( has_capability('mod/feedback:viewreports', $context) ) {
 $completedscount = feedback_get_completeds_group_count($feedback, $mygroupid);
 
 //show the group, if available
-if($mygroupid and $group = $DB->get_record('groups', array('id'=>$mygroupid))) {
+if ($mygroupid and $group = $DB->get_record('groups', array('id'=>$mygroupid))) {
     echo '<b>'.get_string('group').': '.$group->name. '</b><br />';
 }
 //show the count
 echo '<b>'.get_string('completed_feedbacks', 'feedback').': '.$completedscount. '</b><br />';
 
 // get the items of the feedback
-$items = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'hasvalue'=>1), 'position');
+$items = $DB->get_records('feedback_item',
+                          array('feedback'=>$feedback->id, 'hasvalue'=>1),
+                          'position');
 //show the count
-if(is_array($items)){
-    echo '<b>'.get_string('questions', 'feedback').': ' .sizeof($items). ' </b><hr />';
+if (is_array($items)) {
+    echo '<b>'.get_string('questions', 'feedback').': ' .count($items). ' </b><hr />';
 } else {
     $items=array();
 }
 $check_anonymously = true;
-if($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
-    if($completedscount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) {
+if ($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
+    if ($completedscount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) {
         $check_anonymously = false;
     }
 }
-// echo '<div class="mdl-align"><table width="80%" cellpadding="10"><tr><td>';
+
 echo '<div><table width="80%" cellpadding="10"><tr><td>';
-if($check_anonymously) {
+if ($check_anonymously) {
     $itemnr = 0;
     //print the items in an analysed form
-    foreach($items as $item) {
-        if($item->hasvalue == 0) continue;
+    foreach ($items as $item) {
+        if ($item->hasvalue == 0) {
+            continue;
+        }
         echo '<table width="100%" class="generalbox">';
-        
+
         //get the class of item-typ
         $itemobj = feedback_get_item_class($item->typ);
-        
+
         $itemnr++;
-        if($feedback->autonumbering) {
+        if ($feedback->autonumbering) {
             $printnr = $itemnr.'.';
         } else {
             $printnr = '';
         }
         $itemobj->print_analysed($item, $printnr, $mygroupid);
-        // $itemnr = $itemobj->print_analysed($item, $itemnr, $mygroupid);
         echo '</table>';
     }
-}else {
-    echo $OUTPUT->heading_with_help(get_string('insufficient_responses_for_this_group', 'feedback'), 'insufficient_responses', 'feedback');
+} else {
+    echo $OUTPUT->heading_with_help(get_string('insufficient_responses_for_this_group', 'feedback'),
+                                    'insufficient_responses',
+                                    'feedback');
 }
 echo '</td></tr></table></div>';
 echo $OUTPUT->box_end();
index 548d4c8..831863b 100644 (file)
@@ -1,24 +1,36 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
-* shows an analysed view of a feedback on the mainsite
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
+ * shows an analysed view of a feedback on the mainsite
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
 
 require_once("../../config.php");
 require_once("lib.php");
 
-// $SESSION->feedback->current_tab = 'analysis';
 $current_tab = 'analysis';
 
 $id = required_param('id', PARAM_INT);  //the POST dominated the GET
 $coursefilter = optional_param('coursefilter', '0', PARAM_INT);
 $courseitemfilter = optional_param('courseitemfilter', '0', PARAM_INT);
 $courseitemfiltertyp = optional_param('courseitemfiltertyp', '0', PARAM_ALPHANUM);
-// $searchcourse = optional_param('searchcourse', '', PARAM_ALPHAEXT);
 $searchcourse = optional_param('searchcourse', '', PARAM_RAW);
 $courseid = optional_param('courseid', false, PARAM_INT);
 
@@ -40,7 +52,7 @@ if ($searchcourse !== '') {
 }
 $PAGE->set_url($url);
 
-if(($searchcourse OR $courseitemfilter OR $coursefilter) AND !confirm_sesskey()) {
+if (($searchcourse OR $courseitemfilter OR $coursefilter) AND !confirm_sesskey()) {
     print_error('invalidsesskey');
 }
 
@@ -62,7 +74,7 @@ if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
 
 require_login($course->id, true, $cm);
 
-if( !( (intval($feedback->publish_stats) == 1) OR has_capability('mod/feedback:viewreports', $context))) {
+if (!($feedback->publish_stats OR has_capability('mod/feedback:viewreports', $context))) {
     print_error('error');
 }
 
@@ -75,15 +87,19 @@ $PAGE->set_title(format_string($feedback->name));
 echo $OUTPUT->header();
 
 /// print the tabs
-include('tabs.php');
+require('tabs.php');
 
 //print the analysed items
 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
 
-if( has_capability('mod/feedback:viewreports', $context) ) {
+if (has_capability('mod/feedback:viewreports', $context)) {
     //button "export to excel"
     echo $OUTPUT->container_start('mdl-align');
-    $aurl = new moodle_url('analysis_to_excel.php', array('sesskey'=>sesskey(), 'id'=>$id, 'coursefilter'=>$coursefilter));
+    $aurl = new moodle_url('analysis_to_excel.php',
+                           array('sesskey' => sesskey(),
+                                 'id' => $id,
+                                 'coursefilter' => $coursefilter));
+
     echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback'));
     echo $OUTPUT->container_end();
 }
@@ -98,11 +114,14 @@ $completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $c
 echo '<b>'.get_string('completed_feedbacks', 'feedback').': '.$completedscount. '</b><br />';
 
 // get the items of the feedback
-$items = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'hasvalue'=>1), 'position');
+$params = array('feedback' => $feedback->id, 'hasvalue' => 1);
+$items = $DB->get_records('feedback_item', $params, 'position');
 //show the count
-if(is_array($items)){
-    echo '<b>'.get_string('questions', 'feedback').': ' .sizeof($items). ' </b><hr />';
-    echo '<a href="analysis_course.php?id=' . $id . '&courseid='.$courseid.'">'.get_string('show_all', 'feedback').'</a>';
+if (is_array($items)) {
+    echo '<b>'.get_string('questions', 'feedback').': ' .count($items). ' </b><hr />';
+    echo '<a href="analysis_course.php?id=' . $id . '&courseid='.$courseid.'">';
+    echo get_string('show_all', 'feedback');
+    echo '</a>';
 } else {
     $items=array();
 }
@@ -114,12 +133,14 @@ if ($courseitemfilter > 0) {
     if ($DB->get_dbfamily() == 'postgres') { // TODO: this should be moved to standard sql DML function ;-)
          $avgvalue = 'avg(cast (value as integer))';
     }
-    if ($courses = $DB->get_records_sql ("SELECT fv.course_id, c.shortname, $avgvalue AS avgvalue
-                                            FROM {feedback_value} fv, {course} c, {feedback_item} fi
-                                           WHERE fv.course_id = c.id AND fi.id = fv.item AND fi.typ = ? AND fv.item = ?
-                                        GROUP BY course_id, shortname
-                                        ORDER BY avgvalue desc",
-                                          array($courseitemfiltertyp, $courseitemfilter))) {
+
+    $sql = "SELECT fv.course_id, c.shortname, $avgvalue AS avgvalue
+            FROM {feedback_value} fv, {course} c, {feedback_item} fi
+            WHERE fv.course_id = c.id AND fi.id = fv.item AND fi.typ = ? AND fv.item = ?
+            GROUP BY course_id, shortname
+            ORDER BY avgvalue desc";
+
+    if ($courses = $DB->get_records_sql($sql, array($courseitemfiltertyp, $courseitemfilter))) {
         $item = $DB->get_record('feedback_item', array('id'=>$courseitemfilter));
         echo '<tr><th colspan="2">'.$item->name.'</th></tr>';
         echo '<tr><td><table align="left">';
@@ -128,8 +149,15 @@ if ($courseitemfilter > 0) {
         $sep_thous = get_string('separator_thousand', 'feedback');
 
         foreach ($courses as $c) {
-            $shortname = format_string($c->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $c->course_id)));
-            echo '<tr><td>'.$shortname.'</td><td align="right">'.number_format(($c->avgvalue), 2, $sep_dec, $sep_thous).'</td></tr>';
+            $coursecontext = get_context_instance(CONTEXT_COURSE, $c->course_id);
+            $shortname = format_string($c->shortname, true, array('context' => $coursecontext));
+
+            echo '<tr>';
+            echo '<td>'.$shortname.'</td>';
+            echo '<td align="right">'
+            echo number_format(($c->avgvalue), 2, $sep_dec, $sep_thous);
+            echo '</td>';
+            echo '</tr>';
         }
          echo '</table></td></tr>';
     } else {
@@ -138,7 +166,8 @@ if ($courseitemfilter > 0) {
 } else {
 
     echo get_string('search_course', 'feedback') . ': ';
-    echo '<input type="text" name="searchcourse" value="'.s($searchcourse).'"/> <input type="submit" value="'.get_string('search').'"/>';
+    echo '<input type="text" name="searchcourse" value="'.s($searchcourse).'"/> ';
+    echo '<input type="submit" value="'.get_string('search').'"/>';
     echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
     echo '<input type="hidden" name="id" value="'.$id.'" />';
     echo '<input type="hidden" name="courseitemfilter" value="'.$courseitemfilter.'" />';
@@ -158,28 +187,40 @@ if ($courseitemfilter > 0) {
 
          echo ' ' . get_string('filter_by_course', 'feedback') . ': ';
 
-         echo html_writer::select($courses, 'coursefilter', $coursefilter, null, array('id'=>'coursefilterid'));
-         $PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('analysis-form', 'coursefilterid', false));
+         echo html_writer::select($courses, 'coursefilter', $coursefilter,
+                                  null, array('id'=>'coursefilterid'));
+
+         $PAGE->requires->js_init_call('M.util.init_select_autosubmit',
+                                        array('analysis-form', 'coursefilterid', false));
     }
     echo '<hr />';
     $itemnr = 0;
     //print the items in an analysed form
     echo '<tr><td>';
-    foreach($items as $item) {
-        if($item->hasvalue == 0) continue;
+    foreach ($items as $item) {
+        if ($item->hasvalue == 0) {
+            continue;
+        }
         echo '<table width="100%" class="generalbox">';
         //get the class from item-typ
         $itemobj = feedback_get_item_class($item->typ);
         $itemnr++;
-        if($feedback->autonumbering) {
+        if ($feedback->autonumbering) {
             $printnr = $itemnr.'.';
         } else {
             $printnr = '';
         }
         $itemobj->print_analysed($item, $printnr, $mygroupid, $coursefilter);
         if (preg_match('/rated$/i', $item->typ)) {
-             echo '<tr><td colspan="2"><a href="#" onclick="setcourseitemfilter('.$item->id.',\''.$item->typ.'\'); return false;">'.
-                get_string('sort_by_course', 'feedback').'</a></td></tr>';
+            $onclick = 'onclick="setcourseitemfilter'.
+                        "(".$item->id.",'".$item->typ."');".
+                        ' return false;"';
+
+            $anker = '<a href="#" '.$onclick.'>'.
+                     get_string('sort_by_course', 'feedback').
+                     '</a>';
+
+            echo '<tr><td colspan="2">'.$anker.'</td></tr>';
         }
         echo '</table>';
     }
index 887735e..089bc9d 100644 (file)
@@ -1,16 +1,29 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 /**
-* prints an analysed excel-spreadsheet of the feedback
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
+ * prints an analysed excel-spreadsheet of the feedback
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
 
 require_once("../../config.php");
 require_once("lib.php");
-// require_once('easy_excel.php');
 require_once("$CFG->libdir/excellib.class.php");
 
 feedback_load_feedback_items();
@@ -63,12 +76,15 @@ $fstring->username = get_string('username');
 $fstring->fullname = get_string('fullnameuser');
 $fstring->courseid = get_string('courseid', 'feedback');
 $fstring->course = get_string('course');
-$fstring->anonymous_user = get_string('anonymous_user','feedback');
+$fstring->anonymous_user = get_string('anonymous_user', 'feedback');
 ob_end_clean();
 
 //get the questions (item-names)
-if(!$items = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'hasvalue'=>1), 'position')) {
-    print_error('no_items_available_yet', 'feedback', $CFG->wwwroot.'/mod/feedback/view.php?id='.$id);
+$params = array('feedback' => $feedback->id, 'hasvalue' => 1);
+if (!$items = $DB->get_records('feedback_item', $params, 'position')) {
+    print_error('no_items_available_yet',
+                'feedback',
+                $CFG->wwwroot.'/mod/feedback/view.php?id='.$id);
     exit;
 }
 
@@ -77,54 +93,30 @@ $filename = "feedback.xls";
 $mygroupid = groups_get_activity_group($cm);
 
 // Creating a workbook
-// $workbook = new EasyWorkbook("-");
 $workbook = new MoodleExcelWorkbook('-');
-// $workbook->setTempDir($CFG->tempdir.'');
 $workbook->send($filename);
-// $workbook->setVersion(8);
 
 //creating the needed formats
-$xlsFormats = new stdClass();
-$xlsFormats->head1 = $workbook->add_format(array(
+$xls_formats = new stdClass();
+$xls_formats->head1 = $workbook->add_format(array(
                         'bold'=>1,
                         'size'=>12));
 
-$xlsFormats->head2 = $workbook->add_format(array(
+$xls_formats->head2 = $workbook->add_format(array(
                         'align'=>'left',
                         'bold'=>1,
                         'bottum'=>2));
 
-$xlsFormats->default = $workbook->add_format(array(
+$xls_formats->default = $workbook->add_format(array(
                         'align'=>'left',
                         'v_align'=>'top'));
 
-// $xlsFormats->head2_green = $workbook->add_format(array(
-                        // 'align'=>'left',
-                        // 'bold'=>1,
-                        // 'v_align'=>'top',
-                        // 'bottum'=>2,
-                        // 'fg_color'=>'green'));
-
-$xlsFormats->value_bold = $workbook->add_format(array(
+$xls_formats->value_bold = $workbook->add_format(array(
                         'align'=>'left',
                         'bold'=>1,
                         'v_align'=>'top'));
 
-// $xlsFormats->value_blue = $workbook->add_format(array(
-                        // 'align'=>'left',
-                        // 'bold'=>1,
-                        // 'v_align'=>'top',
-                        // 'top'=>2,
-                        // 'fg_color'=>'blue'));
-
-// $xlsFormats->value_red = $workbook->add_format(array(
-                        // 'align'=>'left',
-                        // 'bold'=>1,
-                        // 'v_align'=>'top',
-                        // 'top'=>2,
-                        // 'fg_color'=>'red'));
-
-$xlsFormats->procent = $workbook->add_format(array(
+$xls_formats->procent = $workbook->add_format(array(
                         'align'=>'left',
                         'bold'=>1,
                         'v_align'=>'top',
@@ -134,59 +126,57 @@ $xlsFormats->procent = $workbook->add_format(array(
 $sheetname = clean_param($feedback->name, PARAM_ALPHANUM);
 error_reporting(0);
 $worksheet1 =& $workbook->add_worksheet(substr($sheetname, 0, 31));
-// $worksheet1->set_workbook($workbook);
 $worksheet2 =& $workbook->add_worksheet('detailed');
-// $worksheet2->set_workbook($workbook);
 error_reporting($CFG->debug);
-// $worksheet1->pear_excel_worksheet->set_portrait();
-// $worksheet1->pear_excel_worksheet->set_paper(9);
-// $worksheet1->pear_excel_worksheet->center_horizontally();
 $worksheet1->hide_gridlines();
-// $worksheet1->pear_excel_worksheet->set_header("&\"Arial," . $fstring->bold . "\"&14".$feedback->name);
-// $worksheet1->pear_excel_worksheet->set_footer($fstring->page." &P " . $fstring->of . " &N");
 $worksheet1->set_column(0, 0, 10);
 $worksheet1->set_column(1, 1, 30);
 $worksheet1->set_column(2, 20, 15);
-// $worksheet1->set_margins_LR(0.10);
-
-// $worksheet2->pear_excel_worksheet->set_landscape();
-// $worksheet2->pear_excel_worksheet->set_paper(9);
-// $worksheet2->pear_excel_worksheet->center_horizontally();
 
 //writing the table header
-$rowOffset1 = 0;
-// $worksheet1->setFormat("<f>",12,false);
-$worksheet1->write_string($rowOffset1, 0, UserDate(time()), $xlsFormats->head1);
+$row_offset1 = 0;
+$worksheet1->write_string($row_offset1, 0, userdate(time()), $xls_formats->head1);
 
 ////////////////////////////////////////////////////////////////////////
 //print the analysed sheet
 ////////////////////////////////////////////////////////////////////////
 //get the completeds
 $completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $coursefilter);
-if($completedscount > 0){
+if ($completedscount > 0) {
     //write the count of completeds
-    $rowOffset1++;
-    $worksheet1->write_string($rowOffset1, 0, $fstring->modulenameplural.': '.strval($completedscount), $xlsFormats->head1);
+    $row_offset1++;
+    $worksheet1->write_string($row_offset1,
+                              0,
+                              $fstring->modulenameplural.': '.strval($completedscount),
+                              $xls_formats->head1);
 }
 
-if(is_array($items)){
-    $rowOffset1++;
-    $worksheet1->write_string($rowOffset1, 0, $fstring->questions.': '. strval(sizeof($items)), $xlsFormats->head1);
+if (is_array($items)) {
+    $row_offset1++;
+    $worksheet1->write_string($row_offset1,
+                              0,
+                              $fstring->questions.': '. strval(count($items)),
+                              $xls_formats->head1);
 }
 
-$rowOffset1 += 2;
-$worksheet1->write_string($rowOffset1, 0, $fstring->itemlabel, $xlsFormats->head1);
-$worksheet1->write_string($rowOffset1, 1, $fstring->question, $xlsFormats->head1);
-$worksheet1->write_string($rowOffset1, 2, $fstring->responses, $xlsFormats->head1);
-$rowOffset1++ ;
+$row_offset1 += 2;
+$worksheet1->write_string($row_offset1, 0, $fstring->itemlabel, $xls_formats->head1);
+$worksheet1->write_string($row_offset1, 1, $fstring->question, $xls_formats->head1);
+$worksheet1->write_string($row_offset1, 2, $fstring->responses, $xls_formats->head1);
+$row_offset1++;
 
 if (empty($items)) {
      $items=array();
 }
-foreach($items as $item) {
+foreach ($items as $item) {
     //get the class of item-typ
     $itemobj = feedback_get_item_class($item->typ);
-    $rowOffset1 = $itemobj->excelprint_item($worksheet1, $rowOffset1, $xlsFormats, $item, $mygroupid, $coursefilter);
+    $row_offset1 = $itemobj->excelprint_item($worksheet1,
+                                            $row_offset1,
+                                            $xls_formats,
+                                            $item,
+                                            $mygroupid,
+                                            $coursefilter);
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -199,14 +189,18 @@ $completeds = feedback_get_completeds_group($feedback, $mygroupid, $coursefilter
 //therefor for each completed we have to iterate over all items of the feedback
 //this is done by feedback_excelprint_detailed_items
 
-$rowOffset2 = 0;
+$row_offset2 = 0;
 //first we print the table-header
-$rowOffset2 = feedback_excelprint_detailed_head($worksheet2, $xlsFormats, $items, $rowOffset2);
+$row_offset2 = feedback_excelprint_detailed_head($worksheet2, $xls_formats, $items, $row_offset2);
 
 
-if(is_array($completeds)){
-    foreach($completeds as $completed) {
-        $rowOffset2 = feedback_excelprint_detailed_items($worksheet2, $xlsFormats, $completed, $items, $rowOffset2);
+if (is_array($completeds)) {
+    foreach ($completeds as $completed) {
+        $row_offset2 = feedback_excelprint_detailed_items($worksheet2,
+                                                         $xls_formats,
+                                                         $completed,
+                                                         $items,
+                                                         $row_offset2);
     }
 }
 
@@ -219,100 +213,102 @@ exit;
 ////////////////////////////////////////////////////////////////////////////////
 
 
-function feedback_excelprint_detailed_head(&$worksheet, $xlsFormats, $items, $rowOffset) {
+function feedback_excelprint_detailed_head(&$worksheet, $xls_formats, $items, $row_offset) {
     global $fstring, $feedback;
 
-    if(!$items) return;
-    $colOffset = 0;
-
-    // $worksheet->setFormat('<l><f><ru2>');
+    if (!$items) {
+        return;
+    }
+    $col_offset = 0;
 
-    $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->idnumber, $xlsFormats->head2);
-    $colOffset++;
+    $worksheet->write_string($row_offset + 1, $col_offset, $fstring->idnumber, $xls_formats->head2);
+    $col_offset++;
 
-    $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->username, $xlsFormats->head2);
-    $colOffset++;
+    $worksheet->write_string($row_offset + 1, $col_offset, $fstring->username, $xls_formats->head2);
+    $col_offset++;
 
-    $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->fullname, $xlsFormats->head2);
-    $colOffset++;
+    $worksheet->write_string($row_offset + 1, $col_offset, $fstring->fullname, $xls_formats->head2);
+    $col_offset++;
 
-    foreach($items as $item) {
-        // $worksheet->setFormat('<l><f><ru2>');
-        $worksheet->write_string($rowOffset, $colOffset, $item->name, $xlsFormats->head2);
-        $worksheet->write_string($rowOffset + 1, $colOffset, $item->label, $xlsFormats->head2);
-        $colOffset++;
+    foreach ($items as $item) {
+        $worksheet->write_string($row_offset, $col_offset, $item->name, $xls_formats->head2);
+        $worksheet->write_string($row_offset + 1, $col_offset, $item->label, $xls_formats->head2);
+        $col_offset++;
     }
 
-    // $worksheet->setFormat('<l><f><ru2>');
-    $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->courseid, $xlsFormats->head2);
-    $colOffset++;
+    $worksheet->write_string($row_offset + 1, $col_offset, $fstring->courseid, $xls_formats->head2);
+    $col_offset++;
 
-    // $worksheet->setFormat('<l><f><ru2>');
-    $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->course, $xlsFormats->head2);
-    $colOffset++;
+    $worksheet->write_string($row_offset + 1, $col_offset, $fstring->course, $xls_formats->head2);
+    $col_offset++;
 
-    return $rowOffset + 2;
+    return $row_offset + 2;
 }
 
-function feedback_excelprint_detailed_items(&$worksheet, $xlsFormats, $completed, $items, $rowOffset) {
+function feedback_excelprint_detailed_items(&$worksheet, $xls_formats,
+                                            $completed, $items, $row_offset) {
     global $DB, $fstring;
 
-    if(!$items) return;
-    $colOffset = 0;
+    if (!$items) {
+        return;
+    }
+    $col_offset = 0;
     $courseid = 0;
 
     $feedback = $DB->get_record('feedback', array('id'=>$completed->feedback));
     //get the username
     //anonymous users are separated automatically because the userid in the completed is "0"
-    // $worksheet->setFormat('<l><f><ru2>');
-    if($user = $DB->get_record('user', array('id'=>$completed->userid))) {
+    if ($user = $DB->get_record('user', array('id'=>$completed->userid))) {
         if ($completed->anonymous_response == FEEDBACK_ANONYMOUS_NO) {
-            $worksheet->write_string($rowOffset, $colOffset, $user->idnumber, $xlsFormats->head2);
-            $colOffset++;
+            $worksheet->write_string($row_offset, $col_offset, $user->idnumber, $xls_formats->head2);
+            $col_offset++;
             $userfullname = fullname($user);
-            $worksheet->write_string($rowOffset, $colOffset, $user->username, $xlsFormats->head2);
-            $colOffset++;
+            $worksheet->write_string($row_offset, $col_offset, $user->username, $xls_formats->head2);
+            $col_offset++;
         } else {
             $userfullname = $fstring->anonymous_user;
-            $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
-            $colOffset++;
-            $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
-            $colOffset++;
+            $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+            $col_offset++;
+            $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+            $col_offset++;
         }
-    }else {
+    } else {
         $userfullname = $fstring->anonymous_user;
-        $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
-        $colOffset++;
-        $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
-        $colOffset++;
+        $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+        $col_offset++;
+        $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+        $col_offset++;
     }
 
-    $worksheet->write_string($rowOffset, $colOffset, $userfullname, $xlsFormats->head2);
+    $worksheet->write_string($row_offset, $col_offset, $userfullname, $xls_formats->head2);
 
-    $colOffset++;
-    foreach($items as $item) {
-        $value = $DB->get_record('feedback_value', array('item'=>$item->id, 'completed'=>$completed->id));
+    $col_offset++;
+    foreach ($items as $item) {
+        $params = array('item' => $item->id, 'completed' => $completed->id);
+        $value = $DB->get_record('feedback_value', $params);
 
         $itemobj = feedback_get_item_class($item->typ);
         $printval = $itemobj->get_printval($item, $value);
         $printval = trim($printval);
 
-        // $worksheet->setFormat('<l><vo>');
-        if(is_numeric($printval)) {
-            $worksheet->write_number($rowOffset, $colOffset, $printval, $xlsFormats->default);
-        } elseif($printval != '') {
-            $worksheet->write_string($rowOffset, $colOffset, $printval, $xlsFormats->default);
+        if (is_numeric($printval)) {
+            $worksheet->write_number($row_offset, $col_offset, $printval, $xls_formats->default);
+        } else if ($printval != '') {
+            $worksheet->write_string($row_offset, $col_offset, $printval, $xls_formats->default);
         }
         $printval = '';
-        $colOffset++;
+        $col_offset++;
         $courseid = isset($value->course_id) ? $value->course_id : 0;
-        if($courseid == 0) $courseid = $feedback->course;
+        if ($courseid == 0) {
+            $courseid = $feedback->course;
+        }
     }
-    $worksheet->write_number($rowOffset, $colOffset, $courseid, $xlsFormats->default);
-    $colOffset++;
+    $worksheet->write_number($row_offset, $col_offset, $courseid, $xls_formats->default);
+    $col_offset++;
     if (isset($courseid) AND $course = $DB->get_record('course', array('id' => $courseid))) {
-        $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid)));
-        $worksheet->write_string($rowOffset, $colOffset, $shortname, $xlsFormats->default);
+        $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
+        $shortname = format_string($course->shortname, true, array('context' => $coursecontext));
+        $worksheet->write_string($row_offset, $col_offset, $shortname, $xls_formats->default);
     }
-    return $rowOffset + 1;
+    return $row_offset + 1;
 }
index 5ddd20f..ad6da8f 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
index acdc227..7fd8ceb 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
@@ -53,7 +52,7 @@ class backup_feedback_activity_task extends backup_activity_task {
     static public function encode_content_links($content) {
         global $CFG;
 
-        $base = preg_quote($CFG->wwwroot,"/");
+        $base = preg_quote($CFG->wwwroot, "/");
 
         // Link to the list of feedbacks
         $search="/(".$base."\/mod\/feedback\/index.php\?id\=)([0-9]+)/";
index b66e78a..c683516 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
index 142244a..b4681c9 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
@@ -54,7 +53,6 @@ class backup_feedback_activity_structure_step extends backup_activity_structure_
                                                 'timemodified',
                                                 'completionsubmit'));
 
-
         $completeds = new backup_nested_element('completeds');
 
         $completed = new backup_nested_element('completed', array('id'), array(
@@ -92,7 +90,6 @@ class backup_feedback_activity_structure_step extends backup_activity_structure_
                                                 'completed',
                                                 'value'));
 
-
         // Build the tree
         $feedback->add_child($items);
         $items->add_child($item);
index 362b3a8..83c18d0 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
index fea78c1..b2024d4 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
index 07e0f1a..4519aca 100644 (file)
@@ -1,68 +1,25 @@
 <?php
-/**
-* prints the form to choose the group you want to analyse
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
-
-if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
-}
-
-require_once $CFG->libdir.'/formslib.php';
-
-class feedback_choose_group_form extends moodleform {
-    var $feedbackdata;
-
-    function definition() {
-        $this->feedbackdata = new stdClass();
-        //this function can not be called, because not all data are available at this time
-        //I use set_form_elements instead
-    }
-
-    //this function set the data used in set_form_elements()
-    //in this form the only value have to set is course
-    //eg: array('course' => $course)
-    function set_feedbackdata($data) {
-        if(is_array($data)) {
-            foreach($data as $key => $val) {
-                $this->feedbackdata->{$key} = $val;
-            }
-        }
-    }
-
-    //here the elements will be set
-    //this function have to be called manually
-    //the advantage is that the data are already set
-    function set_form_elements(){
-        $mform =& $this->_form;
-
-        $elementgroup = array();
-        //headline
-        // $mform->addElement('header', 'general', get_string('choose_group', 'feedback'));
-        // hidden elements
-        $mform->addElement('hidden', 'id');
-        $mform->setType('id', PARAM_INT);
-        $mform->addElement('hidden', 'do_show');
-        $mform->setType('do-show', PARAM_INT);
-
-        // visible elements
-        $groups_options = array();
-        if(isset($this->feedbackdata->groups)){
-            $groups_options['-1'] = get_string('allgroups');
-            foreach($this->feedbackdata->groups as $group) {
-                $groups_options[$group->id] = $group->name;
-            }
-        }
-        $attributes = 'onChange="this.form.submit()"';
-        $elementgroup[] =& $mform->createElement('select', 'lstgroupid', '', $groups_options, $attributes);
-        // buttons
-        $elementgroup[] =& $mform->createElement('submit', 'switch_group', get_string('switch_group', 'feedback'));
-        $mform->addGroup($elementgroup, 'elementgroup', '', array(' '), false);
-
-//-------------------------------------------------------------------------------
-    }
-}
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
+/**
+ * prints the form to choose the group you want to analyse
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+//This file can be deleted
index 7f81b9b..e6fe6cd 100644 (file)
 <?php
-
-    /**
-    * prints the form so the user can fill out the feedback
-    *
-    * @author Andreas Grabs
-    * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-    * @package feedback
-    */
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once($CFG->libdir . '/completionlib.php');
-
-    feedback_init_feedback_session();
-
-    $id = required_param('id', PARAM_INT);
-    $completedid = optional_param('completedid', false, PARAM_INT);
-    $preservevalues  = optional_param('preservevalues', 0,  PARAM_INT);
-    $courseid = optional_param('courseid', false, PARAM_INT);
-    $gopage = optional_param('gopage', -1, PARAM_INT);
-    $lastpage = optional_param('lastpage', false, PARAM_INT);
-    $startitempos = optional_param('startitempos', 0, PARAM_INT);
-    $lastitempos = optional_param('lastitempos', 0, PARAM_INT);
-    $anonymous_response = optional_param('anonymous_response', 0, PARAM_INT); //arb
-
-    $highlightrequired = false;
-
-    if(($formdata = data_submitted()) AND !confirm_sesskey()) {
-        print_error('invalidsesskey');
-    }
-
-    //if the use hit enter into a textfield so the form should not submit
-    if(isset($formdata->sesskey) AND !isset($formdata->savevalues) AND !isset($formdata->gonextpage) AND !isset($formdata->gopreviouspage)) {
-        $gopage = $formdata->lastpage;
-    }
-
-    if(isset($formdata->savevalues)) {
-        $savevalues = true;
-    }else {
-        $savevalues = false;
-    }
-
-    if($gopage < 0 AND !$savevalues) {
-        if(isset($formdata->gonextpage)){
-            $gopage = $lastpage + 1;
-            $gonextpage = true;
-            $gopreviouspage = false;
-        }else if(isset($formdata->gopreviouspage)){
-            $gopage = $lastpage - 1;
-            $gonextpage = false;
-            $gopreviouspage = true;
-        }else {
-            print_error('missingparameter');
-        }
-    }else {
-        $gonextpage = $gopreviouspage = false;
-    }
-
-    if (! $cm = get_coursemodule_from_id('feedback', $id)) {
-        print_error('invalidcoursemodule');
-    }
-
-    if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
-        print_error('coursemisconf');
-    }
-
-    if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
-        print_error('invalidcoursemodule');
-    }
-
-    if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
-            print_error('badcontext');
-    }
-
-    $feedback_complete_cap = false;
-
-    if(has_capability('mod/feedback:complete', $context)) {
-        $feedback_complete_cap = true;
-    }
-
-    //check whether the feedback is located and! started from the mainsite
-    if($course->id == SITEID AND !$courseid) {
-        $courseid = SITEID;
-    }
-
-    //check whether the feedback is mapped to the given courseid
-    if($course->id == SITEID AND !has_capability('mod/feedback:edititems', $context)) {
-        if($DB->get_records('feedback_sitecourse_map', array('feedbackid'=>$feedback->id))) {
-            if(!$DB->get_record('feedback_sitecourse_map', array('feedbackid'=>$feedback->id, 'courseid'=>$courseid))){
-                print_error('notavailable', 'feedback');
-            }
-        }
-    }
-
-    if($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
-        if($course->id == SITEID) {
-            require_login($course->id, true);
-        }else {
-            require_login($course->id, true, $cm);
-        }
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * prints the form so the user can fill out the feedback
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+require_once("../../config.php");
+require_once("lib.php");
+require_once($CFG->libdir . '/completionlib.php');
+
+feedback_init_feedback_session();
+
+$id = required_param('id', PARAM_INT);
+$completedid = optional_param('completedid', false, PARAM_INT);
+$preservevalues  = optional_param('preservevalues', 0,  PARAM_INT);
+$courseid = optional_param('courseid', false, PARAM_INT);
+$gopage = optional_param('gopage', -1, PARAM_INT);
+$lastpage = optional_param('lastpage', false, PARAM_INT);
+$startitempos = optional_param('startitempos', 0, PARAM_INT);
+$lastitempos = optional_param('lastitempos', 0, PARAM_INT);
+$anonymous_response = optional_param('anonymous_response', 0, PARAM_INT); //arb
+
+$highlightrequired = false;
+
+if (($formdata = data_submitted()) AND !confirm_sesskey()) {
+    print_error('invalidsesskey');
+}
+
+//if the use hit enter into a textfield so the form should not submit
+if (isset($formdata->sesskey) AND
+    !isset($formdata->savevalues) AND
+    !isset($formdata->gonextpage) AND
+    !isset($formdata->gopreviouspage)) {
+
+    $gopage = $formdata->lastpage;
+}
+
+if (isset($formdata->savevalues)) {
+    $savevalues = true;
+} else {
+    $savevalues = false;
+}
+
+if ($gopage < 0 AND !$savevalues) {
+    if (isset($formdata->gonextpage)) {
+        $gopage = $lastpage + 1;
+        $gonextpage = true;
+        $gopreviouspage = false;
+    } else if (isset($formdata->gopreviouspage)) {
+        $gopage = $lastpage - 1;
+        $gonextpage = false;
+        $gopreviouspage = true;
     } else {
-        if($course->id == SITEID) {
-            require_course_login($course, true);
-        }else {
-            require_course_login($course, true, $cm);
-        }
+        print_error('missingparameter');
     }
-
-    //check whether the given courseid exists
-    if($courseid AND $courseid != SITEID) {
-        if($course2 = $DB->get_record('course', array('id'=>$courseid))){
-            require_course_login($course2); //this overwrites the object $course :-(
-            $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
-        }else {
-            print_error('invalidcourseid');
+} else {
+    $gonextpage = $gopreviouspage = false;
+}
+
+if (! $cm = get_coursemodule_from_id('feedback', $id)) {
+    print_error('invalidcoursemodule');
+}
+
+if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+    print_error('coursemisconf');
+}
+
+if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
+    print_error('invalidcoursemodule');
+}
+
+if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
+        print_error('badcontext');
+}
+
+$feedback_complete_cap = false;
+
+if (has_capability('mod/feedback:complete', $context)) {
+    $feedback_complete_cap = true;
+}
+
+//check whether the feedback is located and! started from the mainsite
+if ($course->id == SITEID AND !$courseid) {
+    $courseid = SITEID;
+}
+
+//check whether the feedback is mapped to the given courseid
+if ($course->id == SITEID AND !has_capability('mod/feedback:edititems', $context)) {
+    if ($DB->get_records('feedback_sitecourse_map', array('feedbackid'=>$feedback->id))) {
+        $params = array('feedbackid'=>$feedback->id, 'courseid'=>$courseid);
+        if (!$DB->get_record('feedback_sitecourse_map', $params)) {
+            print_error('notavailable', 'feedback');
         }
     }
+}
 
-    if(!$feedback_complete_cap) {
-        print_error('error');
-    }
-
-    // Mark activity viewed for completion-tracking
-    $completion = new completion_info($course);
-    $completion->set_module_viewed($cm);
-
-    /// Print the page header
-    $strfeedbacks = get_string("modulenameplural", "feedback");
-    $strfeedback  = get_string("modulename", "feedback");
-
-    if($course->id == SITEID) {
-        $PAGE->set_cm($cm, $course); // set's up global $COURSE
-        $PAGE->set_pagelayout('incourse');
+if ($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
+    if ($course->id == SITEID) {
+        require_login($course->id, true);
+    } else {
+        require_login($course->id, true, $cm);
     }
-
-    $PAGE->navbar->add(get_string('feedback:complete', 'feedback'));
-    $PAGE->set_url('/mod/feedback/complete.php', array('id'=>$cm->id, 'gopage'=>$gopage, 'courseid'=>$course->id));
-    $PAGE->set_heading(format_string($course->fullname));
-    $PAGE->set_title(format_string($feedback->name));
-    echo $OUTPUT->header();
-
-    //ishidden check.
-    //feedback in courses
-    if ((empty($cm->visible) AND
-            !has_capability('moodle/course:viewhiddenactivities', $context)) AND
-            $course->id != SITEID) {
-        notice(get_string("activityiscurrentlyhidden"));
+} else {
+    if ($course->id == SITEID) {
+        require_course_login($course, true);
+    } else {
+        require_course_login($course, true, $cm);
     }
+}
 
-    //ishidden check.
-    //feedback on mainsite
-    if ((empty($cm->visible) AND
-            !has_capability('moodle/course:viewhiddenactivities', $context)) AND
-            $courseid == SITEID) {
-        notice(get_string("activityiscurrentlyhidden"));
+//check whether the given courseid exists
+if ($courseid AND $courseid != SITEID) {
+    if ($course2 = $DB->get_record('course', array('id'=>$courseid))) {
+        require_course_login($course2); //this overwrites the object $course :-(
+        $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
+    } else {
+        print_error('invalidcourseid');
     }
-
-    feedback_print_errors();
-
-    //check, if the feedback is open (timeopen, timeclose)
-    $checktime = time();
-    if(($feedback->timeopen > $checktime) OR ($feedback->timeclose < $checktime AND $feedback->timeclose > 0)) {
-        echo $OUTPUT->box_start('generalbox boxaligncenter');
-            echo '<h2><font color="red">'.get_string('feedback_is_not_open', 'feedback').'</font></h2>';
-            echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
-        echo $OUTPUT->box_end();
-        echo $OUTPUT->footer();
-        exit;
+}
+
+if (!$feedback_complete_cap) {
+    print_error('error');
+}
+
+// Mark activity viewed for completion-tracking
+$completion = new completion_info($course);
+$completion->set_module_viewed($cm);
+
+/// Print the page header
+$strfeedbacks = get_string("modulenameplural", "feedback");
+$strfeedback  = get_string("modulename", "feedback");
+
+if ($course->id == SITEID) {
+    $PAGE->set_cm($cm, $course); // set's up global $COURSE
+    $PAGE->set_pagelayout('incourse');
+}
+
+$PAGE->navbar->add(get_string('feedback:complete', 'feedback'));
+$urlparams = array('id'=>$cm->id, 'gopage'=>$gopage, 'courseid'=>$course->id);
+$PAGE->set_url('/mod/feedback/complete.php', $urlparams);
+$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title(format_string($feedback->name));
+echo $OUTPUT->header();
+
+//ishidden check.
+//feedback in courses
+if ((empty($cm->visible) AND
+        !has_capability('moodle/course:viewhiddenactivities', $context)) AND
+        $course->id != SITEID) {
+    notice(get_string("activityiscurrentlyhidden"));
+}
+
+//ishidden check.
+//feedback on mainsite
+if ((empty($cm->visible) AND
+        !has_capability('moodle/course:viewhiddenactivities', $context)) AND
+        $courseid == SITEID) {
+    notice(get_string("activityiscurrentlyhidden"));
+}
+
+//check, if the feedback is open (timeopen, timeclose)
+$checktime = time();
+$feedback_is_closed = ($feedback->timeopen > $checktime) OR
+                      ($feedback->timeclose < $checktime AND
+                            $feedback->timeclose > 0);
+
+if ($feedback_is_closed) {
+    echo $OUTPUT->box_start('generalbox boxaligncenter');
+        echo '<h2><font color="red">';
+        echo get_string('feedback_is_not_open', 'feedback');
+        echo '</font></h2>';
+        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
+    echo $OUTPUT->box_end();
+    echo $OUTPUT->footer();
+    exit;
+}
+
+//additional check for multiple-submit (prevent browsers back-button).
+//the main-check is in view.php
+$feedback_can_submit = true;
+if ($feedback->multiple_submit == 0 ) {
+    if (feedback_is_already_submitted($feedback->id, $courseid)) {
+        $feedback_can_submit = false;
     }
-
-    //additional check for multiple-submit (prevent browsers back-button). the main-check is in view.php
-    $feedback_can_submit = true;
-    if($feedback->multiple_submit == 0 ) {
-        if(feedback_is_already_submitted($feedback->id, $courseid)) {
-            $feedback_can_submit = false;
+}
+if ($feedback_can_submit) {
+    //preserving the items
+    if ($preservevalues == 1) {
+        if (!isset($SESSION->feedback->is_started) OR !$SESSION->feedback->is_started == true) {
+            print_error('error', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
         }
-    }
-    if($feedback_can_submit) {
-        //preserving the items
-        if($preservevalues == 1){
-            if(!$SESSION->feedback->is_started == true)
-                print_error('error', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
-            //checken, ob alle required items einen wert haben
-            if(feedback_check_values($startitempos, $lastitempos)) {
-                    $userid = $USER->id; //arb
-                if($completedid = feedback_save_values($USER->id, true)){
-                    if($userid > 0) {
-                        add_to_log($course->id, 'feedback', 'startcomplete', 'view.php?id='.$cm->id, $feedback->id, $cm->id, $userid);
-                    }
-                    if(!$gonextpage AND !$gopreviouspage) $preservevalues = false;//es kann gespeichert werden
-
-                }else {
-                    $savereturn = 'failed';
-                    if(isset($lastpage)) {
-                        $gopage = $lastpage;
-                    }else {
-                        print_error('missingparameter');
-                    }
+        //checken, ob alle required items einen wert haben
+        if (feedback_check_values($startitempos, $lastitempos)) {
+            $userid = $USER->id; //arb
+            if ($completedid = feedback_save_values($USER->id, true)) {
+                if ($userid > 0) {
+                    add_to_log($course->id,
+                               'feedback',
+                               'startcomplete',
+                               'view.php?id='.$cm->id,
+                               $feedback->id,
+                               $cm->id,
+                               $userid);
                 }
-            }else {
-                $savereturn = 'missing';
-                $highlightrequired = true;
-                if(isset($lastpage)) {
+                if (!$gonextpage AND !$gopreviouspage) {
+                    $preservevalues = false;//es kann gespeichert werden
+                }
+
+            } else {
+                $savereturn = 'failed';
+                if (isset($lastpage)) {
                     $gopage = $lastpage;
-                }else {
+                } else {
                     print_error('missingparameter');
                 }
-
             }
+        } else {
+            $savereturn = 'missing';
+            $highlightrequired = true;
+            if (isset($lastpage)) {
+                $gopage = $lastpage;
+            } else {
+                print_error('missingparameter');
+            }
+
         }
+    }
 
-        //saving the items
-        if($savevalues AND !$preservevalues){
-            //exists there any pagebreak, so there are values in the feedback_valuetmp
-            $userid = $USER->id; //arb
+    //saving the items
+    if ($savevalues AND !$preservevalues) {
+        //exists there any pagebreak, so there are values in the feedback_valuetmp
+        $userid = $USER->id; //arb
 
-            if($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
-                $feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid);
-            }else{
-                $feedbackcompleted = false;
-            }
-            $feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', array('id'=>$completedid));
-            //fake saving for switchrole
-            $is_switchrole = feedback_check_is_switchrole();
-            if($is_switchrole) {
-                $savereturn = 'saved';
-                feedback_delete_completedtmp($completedid);
-            }else if($new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted, $userid)) {
+        if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
+            $feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid);
+        } else {
+            $feedbackcompleted = false;
+        }
+        $params = array('id' => $completedid);
+        $feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', $params);
+        //fake saving for switchrole
+        $is_switchrole = feedback_check_is_switchrole();
+        if ($is_switchrole) {
+            $savereturn = 'saved';
+            feedback_delete_completedtmp($completedid);
+        } else {
+            $new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp,
+                                                         $feedbackcompleted,
+                                                         $userid);
+            if ($new_completed_id) {
                 $savereturn = 'saved';
-                if($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
-                    add_to_log($course->id, 'feedback', 'submit', 'view.php?id='.$cm->id, $feedback->id, $cm->id, $userid);
+                if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
+                    add_to_log($course->id,
+                              'feedback',
+                              'submit',
+                              'view.php?id='.$cm->id,
+                              $feedback->id,
+                              $cm->id,
+                              $userid);
+
                     feedback_send_email($cm, $feedback, $course, $userid);
-                }else {
+                } else {
                     feedback_send_email_anonym($cm, $feedback, $course, $userid);
                 }
                 //tracking the submit
                 $tracking->completed = $new_completed_id;
                 $DB->insert_record('feedback_tracking', $tracking);
                 unset($SESSION->feedback->is_started);
-                
+
                 // Update completion state
                 $completion = new completion_info($course);
                 if ($completion->is_enabled($cm) && $feedback->completionsubmit) {
                     $completion->update_state($cm, COMPLETION_COMPLETE);
                 }
 
-            }else {
+            } else {
                 $savereturn = 'failed';
             }
-
         }
 
+    }
 
-        if($allbreaks = feedback_get_all_break_positions($feedback->id)){
-            if($gopage <= 0) {
-                $startposition = 0;
-            }else {
-                if(!isset($allbreaks[$gopage - 1])) {
-                    $gopage = count($allbreaks);
-                }
-                $startposition = $allbreaks[$gopage - 1];
-            }
-            $ispagebreak = true;
-        }else {
+
+    if ($allbreaks = feedback_get_all_break_positions($feedback->id)) {
+        if ($gopage <= 0) {
             $startposition = 0;
-            $newpage = 0;
-            $ispagebreak = false;
+        } else {
+            if (!isset($allbreaks[$gopage - 1])) {
+                $gopage = count($allbreaks);
+            }
+            $startposition = $allbreaks[$gopage - 1];
         }
+        $ispagebreak = true;
+    } else {
+        $startposition = 0;
+        $newpage = 0;
+        $ispagebreak = false;
+    }
 
-        //get the feedbackitems after the last shown pagebreak
-        $feedbackitems = $DB->get_records_select('feedback_item', 'feedback = ? AND position > ?', array($feedback->id, $startposition), 'position');
+    //get the feedbackitems after the last shown pagebreak
+    $select = 'feedback = ? AND position > ?';
+    $params = array($feedback->id, $startposition);
+    $feedbackitems = $DB->get_records_select('feedback_item', $select, $params, 'position');
 
-        //get the first pagebreak
-        if($pagebreaks = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'typ'=>'pagebreak'), 'position')) {
-            $pagebreaks = array_values($pagebreaks);
-            $firstpagebreak = $pagebreaks[0];
-        }else {
-            $firstpagebreak = false;
-        }
-        $maxitemcount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
-
-        //get the values of completeds before done. Anonymous user can not get these values.
-        if((!isset($SESSION->feedback->is_started)) AND (!isset($savereturn)) AND ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO)) {
-            if(!$feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid)) {
-                if($feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid)) {
-                    //copy the values to feedback_valuetmp create a completedtmp
-                    $feedbackcompletedtmp = feedback_set_tmp_values($feedbackcompleted);
-                }
+    //get the first pagebreak
+    $params = array('feedback' => $feedback->id, 'typ' => 'pagebreak');
+    if ($pagebreaks = $DB->get_records('feedback_item', $params, 'position')) {
+        $pagebreaks = array_values($pagebreaks);
+        $firstpagebreak = $pagebreaks[0];
+    } else {
+        $firstpagebreak = false;
+    }
+    $maxitemcount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
+
+    //get the values of completeds before done. Anonymous user can not get these values.
+    if ((!isset($SESSION->feedback->is_started)) AND
+                          (!isset($savereturn)) AND
+                          ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO)) {
+
+        $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid);
+        if (!$feedbackcompletedtmp) {
+            $feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid);
+            if ($feedbackcompleted) {
+                //copy the values to feedback_valuetmp create a completedtmp
+                $feedbackcompletedtmp = feedback_set_tmp_values($feedbackcompleted);
             }
-        }else {
-            $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid);
         }
+    } else {
+        $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid);
+    }
 
-        /// Print the main part of the page
-        ///////////////////////////////////////////////////////////////////////////
-        ///////////////////////////////////////////////////////////////////////////
-        ///////////////////////////////////////////////////////////////////////////
-        $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
-        if($courseid > 0) {
-            $analysisurl->param('courseid', $courseid);
+    /// Print the main part of the page
+    ///////////////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////////////
+    $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
+    if ($courseid > 0) {
+        $analysisurl->param('courseid', $courseid);
+    }
+    echo $OUTPUT->heading(format_text($feedback->name));
+
+    if ( (intval($feedback->publish_stats) == 1) AND
+            ( has_capability('mod/feedback:viewanalysepage', $context)) AND
+            !( has_capability('mod/feedback:viewreports', $context)) ) {
+
+        $params = array('userid' => $USER->id, 'feedback' => $feedback->id);
+        if ($multiple_count = $DB->count_records('feedback_tracking', $params)) {
+            echo $OUTPUT->box_start('mdl-align');
+            echo '<a href="'.$analysisurl->out().'">';
+            echo get_string('completed_feedbacks', 'feedback').'</a>';
+            echo $OUTPUT->box_end();
         }
-        echo $OUTPUT->heading(format_text($feedback->name));
-
-        if( (intval($feedback->publish_stats) == 1) AND
-                ( has_capability('mod/feedback:viewanalysepage', $context)) AND
-                !( has_capability('mod/feedback:viewreports', $context)) ) {
-            if($multiple_count = $DB->count_records('feedback_tracking', array('userid'=>$USER->id, 'feedback'=>$feedback->id))) {
-                echo $OUTPUT->box_start('mdl-align');
-                echo '<a href="'.$analysisurl->out().'">';
+    }
+
+    if (isset($savereturn) && $savereturn == 'saved') {
+        if ($feedback->page_after_submit) {
+            echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
+            echo format_text($feedback->page_after_submit,
+                             $feedback->page_after_submitformat,
+                             array('overflowdiv' => true));
+            echo $OUTPUT->box_end();
+        } else {
+            echo '<p align="center">';
+            echo '<b><font color="green">';
+            echo get_string('entries_saved', 'feedback');
+            echo '</font></b>';
+            echo '</p>';
+            if ( intval($feedback->publish_stats) == 1) {
+                echo '<p align="center"><a href="'.$analysisurl->out().'">';
                 echo get_string('completed_feedbacks', 'feedback').'</a>';
-                echo $OUTPUT->box_end();
+                echo '</p>';
             }
         }
 
-        if(isset($savereturn) && $savereturn == 'saved') {
-            if($feedback->page_after_submit) {
-                echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
-                echo format_text($feedback->page_after_submit, $feedback->page_after_submitformat, array('overflowdiv'=>true));
-                echo $OUTPUT->box_end();
+        if ($feedback->site_after_submit) {
+            $url = feedback_encode_target_url($feedback->site_after_submit);
+        } else {
+            if ($courseid) {
+                if ($courseid == SITEID) {
+                    $url = $CFG->wwwroot;
+                } else {
+                    $url = $CFG->wwwroot.'/course/view.php?id='.$courseid;
+                }
             } else {
-                echo '<p align="center"><b><font color="green">'.get_string('entries_saved','feedback').'</font></b></p>';
-                if( intval($feedback->publish_stats) == 1) {
-                    echo '<p align="center"><a href="'.$analysisurl->out().'">';
-                    echo get_string('completed_feedbacks', 'feedback').'</a>';
-                    echo '</p>';
+                if ($course->id == SITEID) {
+                    $url = $CFG->wwwroot;
+                } else {
+                    $url = $CFG->wwwroot.'/course/view.php?id='.$course->id;
                 }
             }
+        }
+        echo $OUTPUT->continue_button($url);
+    } else {
+        if (isset($savereturn) && $savereturn == 'failed') {
+            echo $OUTPUT->box_start('mform error');
+            echo get_string('saving_failed', 'feedback');
+            echo $OUTPUT->box_end();
+        }
 
-            if($feedback->site_after_submit) {
-                echo $OUTPUT->continue_button(feedback_encode_target_url($feedback->site_after_submit));
-            }else {
-                if($courseid) {
-                    if($courseid == SITEID) {
-                        echo $OUTPUT->continue_button($CFG->wwwroot);
-                    }else {
-                        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$courseid);
-                    }
-                }else {
-                    if($course->id == SITEID) {
-                        echo $OUTPUT->continue_button($CFG->wwwroot);
-                    } else {
-                        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
-                    }
-                }
-            }
-        }else {
-            if(isset($savereturn) && $savereturn == 'failed') {
-                echo $OUTPUT->box_start('mform error');
-                echo get_string('saving_failed','feedback');
-                echo $OUTPUT->box_end();
-            }
+        if (isset($savereturn) && $savereturn == 'missing') {
+            echo $OUTPUT->box_start('mform error');
+            echo get_string('saving_failed_because_missing_or_false_values', 'feedback');
+            echo $OUTPUT->box_end();
+        }
 
-            if(isset($savereturn) && $savereturn == 'missing') {
-                echo $OUTPUT->box_start('mform error');
-                echo get_string('saving_failed_because_missing_or_false_values','feedback');
-                echo $OUTPUT->box_end();
+        //print the items
+        if (is_array($feedbackitems)) {
+            echo $OUTPUT->box_start('feedback_form');
+            echo '<form action="complete.php" method="post" onsubmit=" ">';
+            echo '<fieldset>';
+            echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+            echo $OUTPUT->box_start('feedback_anonymousinfo');
+            switch ($feedback->anonymous) {
+                case FEEDBACK_ANONYMOUS_YES:
+                    echo '<input type="hidden" name="anonymous" value="1" />';
+                    $inputvalue = 'value="'.FEEDBACK_ANONYMOUS_YES.'"';
+                    echo '<input type="hidden" name="anonymous_response" '.$inputvalue.' />';
+                    echo get_string('mode', 'feedback').': '.get_string('anonymous', 'feedback');
+                    break;
+                case FEEDBACK_ANONYMOUS_NO:
+                    echo '<input type="hidden" name="anonymous" value="0" />';
+                    $inputvalue = 'value="'.FEEDBACK_ANONYMOUS_NO.'"';
+                    echo '<input type="hidden" name="anonymous_response" '.$inputvalue.' />';
+                    echo get_string('mode', 'feedback').': ';
+                    echo get_string('non_anonymous', 'feedback');
+                    break;
             }
+            echo $OUTPUT->box_end();
+            //check, if there exists required-elements
+            $params = array('feedback' => $feedback->id, 'required' => 1);
+            $countreq = $DB->count_records('feedback_item', $params);
+            if ($countreq > 0) {
+                echo '<span class="feedback_required_mark">(*)';
+                echo get_string('items_are_required', 'feedback');
+                echo '</span>';
+            }
+            echo $OUTPUT->box_start('feedback_items');
+
+            unset($startitem);
+            $select = 'feedback = ? AND hasvalue = 1 AND position < ?';
+            $params = array($feedback->id, $startposition);
+            $itemnr = $DB->count_records_select('feedback_item', $select, $params);
+            $lastbreakposition = 0;
+            $align = right_to_left() ? 'right' : 'left';
+
+            foreach ($feedbackitems as $feedbackitem) {
+                if (!isset($startitem)) {
+                    //avoid showing double pagebreaks
+                    if ($feedbackitem->typ == 'pagebreak') {
+                        continue;
+                    }
+                    $startitem = $feedbackitem;
+                }
 
-            //print the items
-            if(is_array($feedbackitems)){
-                // echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
-                echo $OUTPUT->box_start('feedback_form');
-                echo '<form action="complete.php" method="post" onsubmit=" ">';
-                echo '<fieldset>';
-                echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-                echo $OUTPUT->box_start('feedback_anonymousinfo');
-                switch ($feedback->anonymous) {
-                    case FEEDBACK_ANONYMOUS_YES:
-                        echo '<input type="hidden" name="anonymous" value="1" />';
-                        echo '<input type="hidden" name="anonymous_response" value="'.FEEDBACK_ANONYMOUS_YES.'" />';
-                        echo get_string('mode', 'feedback').': '.get_string('anonymous', 'feedback');
-                        break;
-                    case FEEDBACK_ANONYMOUS_NO:
-                        echo '<input type="hidden" name="anonymous" value="0" />';
-                        echo '<input type="hidden" name="anonymous_response" value="'.FEEDBACK_ANONYMOUS_NO.'" />';
-                        echo get_string('mode', 'feedback').': '.get_string('non_anonymous', 'feedback');
-                        break;
+                if ($feedbackitem->dependitem > 0) {
+                    //chech if the conditions are ok
+                    $fb_compare_value = feedback_compare_item_value($feedbackcompletedtmp->id,
+                                                                    $feedbackitem->dependitem,
+                                                                    $feedbackitem->dependvalue,
+                                                                    true);
+                    if (!isset($feedbackcompletedtmp->id) OR !$fb_compare_value) {
+                        $lastitem = $feedbackitem;
+                        $lastbreakposition = $feedbackitem->position;
+                        continue;
+                    }
                 }
-                echo $OUTPUT->box_end();
-                //check, if there exists required-elements
-                $countreq = $DB->count_records('feedback_item', array('feedback'=>$feedback->id, 'required'=>1));
-                if($countreq > 0) {
-                    echo '<span class="feedback_required_mark">(*)' . get_string('items_are_required', 'feedback') . '</span>';
+
+                if ($feedbackitem->dependitem > 0) {
+                    $dependstyle = ' feedback_complete_depend';
+                } else {
+                    $dependstyle = '';
                 }
-                echo $OUTPUT->box_start('feedback_items');
-
-                unset($startitem);
-                $itemnr = $DB->count_records_select('feedback_item', 'feedback = ? AND hasvalue = 1 AND position < ?', array($feedback->id, $startposition));
-                $lastbreakposition = 0;
-                $align = right_to_left() ? 'right' : 'left';
-
-                foreach($feedbackitems as $feedbackitem){
-                    if(!isset($startitem)) {
-                        //avoid showing double pagebreaks
-                        if($feedbackitem->typ == 'pagebreak') {
-                            continue;
-                        }
-                        $startitem = $feedbackitem;
-                    }
 
-                    if($feedbackitem->dependitem > 0) {
-                        //chech if the conditions are ok
-                        if(!isset($feedbackcompletedtmp->id) OR !feedback_compare_item_value($feedbackcompletedtmp->id, $feedbackitem->dependitem, $feedbackitem->dependvalue, true)) {
-                            $lastitem = $feedbackitem;
-                            $lastbreakposition = $feedbackitem->position;
-                            continue;
-                        }
+                echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
+                $value = '';
+                //get the value
+                $frmvaluename = $feedbackitem->typ . '_'. $feedbackitem->id;
+                if (isset($savereturn)) {
+                    if (isset($formdata->{$frmvaluename})) {
+                        $value = $formdata->{$frmvaluename};
+                    } else {
+                        $value = null;
                     }
-
-                    if($feedbackitem->dependitem > 0) {
-                        $dependstyle = ' feedback_complete_depend';
-                    }else {
-                        $dependstyle = '';
+                } else {
+                    if (isset($feedbackcompletedtmp->id)) {
+                        $value = feedback_get_item_value($feedbackcompletedtmp->id,
+                                                         $feedbackitem->id,
+                                                         true);
                     }
-
-                    echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
-                        $value = '';
-                        //get the value
-                        $frmvaluename = $feedbackitem->typ . '_'. $feedbackitem->id;
-                        if(isset($savereturn)) {
-                            $value =  isset($formdata->{$frmvaluename})?$formdata->{$frmvaluename}:NULL;
-                        }else {
-                            if(isset($feedbackcompletedtmp->id)) {
-                                $value = feedback_get_item_value($feedbackcompletedtmp->id, $feedbackitem->id, true);
-                            }
-                        }
-                        if($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
-                            $itemnr++;
-                            echo $OUTPUT->box_start('feedback_item_number_'.$align);
-                            echo $itemnr;
-                            echo $OUTPUT->box_end();
-                        }
-                        if($feedbackitem->typ != 'pagebreak') {
-                            echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
-                                feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
-                            echo $OUTPUT->box_end();
-                        }
+                }
+                if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
+                    $itemnr++;
+                    echo $OUTPUT->box_start('feedback_item_number_'.$align);
+                    echo $itemnr;
                     echo $OUTPUT->box_end();
-
-                    $lastbreakposition = $feedbackitem->position; //last item-pos (item or pagebreak)
-                    if($feedbackitem->typ == 'pagebreak'){
-                        break;
-                    }else {
-                        $lastitem = $feedbackitem;
-                    }
                 }
-                echo $OUTPUT->box_end();
-                echo '<input type="hidden" name="id" value="'.$id.'" />';
-                echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'" />';
-                echo '<input type="hidden" name="lastpage" value="'.$gopage.'" />';
-                echo '<input type="hidden" name="completedid" value="'.(isset($feedbackcompletedtmp->id)?$feedbackcompletedtmp->id:'').'" />';
-                echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
-                echo '<input type="hidden" name="preservevalues" value="1" />';
-                if(isset($startitem)) {
-                    echo '<input type="hidden" name="startitempos" value="'. $startitem->position . '" />';
-                    echo '<input type="hidden" name="lastitempos" value="'. $lastitem->position . '" />';
+                if ($feedbackitem->typ != 'pagebreak') {
+                    echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
+                    feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
+                    echo $OUTPUT->box_end();
                 }
+                echo $OUTPUT->box_end();
 
-                if( $ispagebreak AND $lastbreakposition > $firstpagebreak->position) {
-                    echo '<input name="gopreviouspage" type="submit" value="'.get_string('previous_page','feedback').'" />';
-                }
-                if($lastbreakposition < $maxitemcount){
-                    echo '<input name="gonextpage" type="submit" value="'.get_string('next_page','feedback').'" />';
-                }
-                if($lastbreakposition >= $maxitemcount) { //last page
-                    echo '<input name="savevalues" type="submit" value="'.get_string('save_entries','feedback').'" />';
+                $lastbreakposition = $feedbackitem->position; //last item-pos (item or pagebreak)
+                if ($feedbackitem->typ == 'pagebreak') {
+                    break;
+                } else {
+                    $lastitem = $feedbackitem;
                 }
+            }
+            echo $OUTPUT->box_end();
+            echo '<input type="hidden" name="id" value="'.$id.'" />';
+            echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'" />';
+            echo '<input type="hidden" name="lastpage" value="'.$gopage.'" />';
+            if (isset($feedbackcompletedtmp->id)) {
+                $inputvalue = 'value="'.$feedbackcompletedtmp->id.'"';
+            } else {
+                $inputvalue = 'value=""';
+            }
+            echo '<input type="hidden" name="completedid" '.$inputvalue.' />';
+            echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
+            echo '<input type="hidden" name="preservevalues" value="1" />';
+            if (isset($startitem)) {
+                echo '<input type="hidden" name="startitempos" value="'.$startitem->position.'" />';
+                echo '<input type="hidden" name="lastitempos" value="'.$lastitem->position.'" />';
+            }
 
-                echo '</fieldset>';
-                echo '</form>';
-                echo $OUTPUT->box_end();
+            if ( $ispagebreak AND $lastbreakposition > $firstpagebreak->position) {
+                $inputvalue = 'value="'.get_string('previous_page', 'feedback').'"';
+                echo '<input name="gopreviouspage" type="submit" '.$inputvalue.' />';
+            }
+            if ($lastbreakposition < $maxitemcount) {
+                $inputvalue = 'value="'.get_string('next_page', 'feedback').'"';
+                echo '<input name="gonextpage" type="submit" '.$inputvalue.' />';
+            }
+            if ($lastbreakposition >= $maxitemcount) { //last page
+                $inputvalue = 'value="'.get_string('save_entries', 'feedback').'"';
+                echo '<input name="savevalues" type="submit" '.$inputvalue.' />';
+            }
 
-                echo $OUTPUT->box_start('feedback_complete_cancel');
-                if($courseid) {
-                    echo '<form action="'.$CFG->wwwroot.'/course/view.php?id='.$courseid.'" method="post" onsubmit=" ">';
-                }else{
-                    if($course->id == SITEID) {
-                        echo '<form action="'.$CFG->wwwroot.'" method="post" onsubmit=" ">';
-                    } else {
-                        echo '<form action="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'" method="post" onsubmit=" ">';
-                    }
+            echo '</fieldset>';
+            echo '</form>';
+            echo $OUTPUT->box_end();
+
+            echo $OUTPUT->box_start('feedback_complete_cancel');
+            if ($courseid) {
+                $action = 'action="'.$CFG->wwwroot.'/course/view.php?id='.$courseid.'"';
+            } else {
+                if ($course->id == SITEID) {
+                    $action = 'action="'.$CFG->wwwroot.'"';
+                } else {
+                    $action = 'action="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'"';
                 }
-                echo '<fieldset>';
-                echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-                echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
-                echo '<button type="submit">'.get_string('cancel').'</button>';
-                echo '</fieldset>';
-                echo '</form>';
-                echo $OUTPUT->box_end();
-                $SESSION->feedback->is_started = true;
-                // echo $OUTPUT->box_end();
             }
+            echo '<form '.$action.' method="post" onsubmit=" ">';
+            echo '<fieldset>';
+            echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+            echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
+            echo '<button type="submit">'.get_string('cancel').'</button>';
+            echo '</fieldset>';
+            echo '</form>';
+            echo $OUTPUT->box_end();
+            $SESSION->feedback->is_started = true;
         }
-    }else {
-        echo $OUTPUT->box_start('generalbox boxaligncenter');
-            echo '<h2><font color="red">'.get_string('this_feedback_is_already_submitted', 'feedback').'</font></h2>';
-            echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
-        echo $OUTPUT->box_end();
     }
-    /// Finish the page
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-
-    echo $OUTPUT->footer();
-
+} else {
+    echo $OUTPUT->box_start('generalbox boxaligncenter');
+        echo '<h2>';
+        echo '<font color="red">';
+        echo get_string('this_feedback_is_already_submitted', 'feedback');
+        echo '</font>';
+        echo '</h2>';
+        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
+    echo $OUTPUT->box_end();
+}
+/// Finish the page
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+
+echo $OUTPUT->footer();
index a25946d..a1d8586 100644 (file)
 <?php
-
-    /**
-    * prints the form so an anonymous user can fill out the feedback on the mainsite
-    *
-    * @author Andreas Grabs
-    * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-    * @package feedback
-    */
-
-    require_once("../../config.php");
-    require_once("lib.php");
-
-    feedback_init_feedback_session();
-
-    $id = required_param('id', PARAM_INT);
-    $completedid = optional_param('completedid', false, PARAM_INT);
-    $preservevalues  = optional_param('preservevalues', 0,  PARAM_INT);
-    $courseid = optional_param('courseid', false, PARAM_INT);
-    $gopage = optional_param('gopage', -1, PARAM_INT);
-    $lastpage = optional_param('lastpage', false, PARAM_INT);
-    $startitempos = optional_param('startitempos', 0, PARAM_INT);
-    $lastitempos = optional_param('lastitempos', 0, PARAM_INT);
-
-    $url = new moodle_url('/mod/feedback/complete_guest.php', array('id'=>$id));
-    if ($completedid !== false) {
-        $url->param('completedid', $completedid);
-    }
-    if ($preservevalues !== 0) {
-        $url->param('preservevalues', $preservevalues);
-    }
-    if ($courseid !== false) {
-        $url->param('courseid', $courseid);
-    }
-    if ($gopage !== -1) {
-        $url->param('gopage', $gopage);
-    }
-    if ($lastpage !== false) {
-        $url->param('lastpage', $lastpage);
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * prints the form so an anonymous user can fill out the feedback on the mainsite
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+require_once("../../config.php");
+require_once("lib.php");
+
+feedback_init_feedback_session();
+
+$id = required_param('id', PARAM_INT);
+$completedid = optional_param('completedid', false, PARAM_INT);
+$preservevalues  = optional_param('preservevalues', 0,  PARAM_INT);
+$courseid = optional_param('courseid', false, PARAM_INT);
+$gopage = optional_param('gopage', -1, PARAM_INT);
+$lastpage = optional_param('lastpage', false, PARAM_INT);
+$startitempos = optional_param('startitempos', 0, PARAM_INT);
+$lastitempos = optional_param('lastitempos', 0, PARAM_INT);
+
+$url = new moodle_url('/mod/feedback/complete_guest.php', array('id'=>$id));
+if ($completedid !== false) {
+    $url->param('completedid', $completedid);
+}
+if ($preservevalues !== 0) {
+    $url->param('preservevalues', $preservevalues);
+}
+if ($courseid !== false) {
+    $url->param('courseid', $courseid);
+}
+if ($gopage !== -1) {
+    $url->param('gopage', $gopage);
+}
+if ($lastpage !== false) {
+    $url->param('lastpage', $lastpage);
+}
+if ($startitempos !== 0) {
+    $url->param('startitempos', $startitempos);
+}
+if ($lastitempos !== 0) {
+    $url->param('lastitempos', $lastitempos);
+}
+$PAGE->set_url($url);
+
+$highlightrequired = false;
+
+if (($formdata = data_submitted()) AND !confirm_sesskey()) {
+    print_error('invalidsesskey');
+}
+
+//if the use hit enter into a textfield so the form should not submit
+if (isset($formdata->sesskey) AND
+   !isset($formdata->savevalues) AND
+   !isset($formdata->gonextpage) AND
+   !isset($formdata->gopreviouspage)) {
+
+    $gopage = $formdata->lastpage;
+}
+if (isset($formdata->savevalues)) {
+    $savevalues = true;
+} else {
+    $savevalues = false;
+}
+
+if ($gopage < 0 AND !$savevalues) {
+    if (isset($formdata->gonextpage)) {
+        $gopage = $lastpage + 1;
+        $gonextpage = true;
+        $gopreviouspage = false;
+    } else if (isset($formdata->gopreviouspage)) {
+        $gopage = $lastpage - 1;
+        $gonextpage = false;
+        $gopreviouspage = true;
+    } else {
+        print_error('parameters_missing', 'feedback');
     }
-    if ($startitempos !== 0) {
-        $url->param('startitempos', $startitempos);
-    }
-    if ($lastitempos !== 0) {
-        $url->param('lastitempos', $lastitempos);
-    }
-    $PAGE->set_url($url);
-
-    $highlightrequired = false;
-
-    if(($formdata = data_submitted()) AND !confirm_sesskey()) {
-        print_error('invalidsesskey');
-    }
-
-    //if the use hit enter into a textfield so the form should not submit
-    if(isset($formdata->sesskey) AND !isset($formdata->savevalues) AND !isset($formdata->gonextpage) AND !isset($formdata->gopreviouspage)) {
-        $gopage = $formdata->lastpage;
-    }
-    if(isset($formdata->savevalues)) {
-        $savevalues = true;
-    }else {
-        $savevalues = false;
-    }
-
-    if($gopage < 0 AND !$savevalues) {
-        if(isset($formdata->gonextpage)){
-            $gopage = $lastpage + 1;
-            $gonextpage = true;
-            $gopreviouspage = false;
-        }else if(isset($formdata->gopreviouspage)){
-            $gopage = $lastpage - 1;
-            $gonextpage = false;
-            $gopreviouspage = true;
-        }else {
-            print_error('parameters_missing', 'feedback');
-        }
-    }else {
-        $gonextpage = $gopreviouspage = false;
-    }
-
-    if (! $cm = get_coursemodule_from_id('feedback', $id)) {
-        print_error('invalidcoursemodule');
-    }
-
-    if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
-        print_error('coursemisconf');
-    }
-
-    if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
-        print_error('invalidcoursemodule');
-    }
-
-    if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
-            print_error('badcontext');
-    }
-
-    $feedback_complete_cap = false;
-
-    if(isset($CFG->feedback_allowfullanonymous)
+} else {
+    $gonextpage = $gopreviouspage = false;
+}
+
+if (! $cm = get_coursemodule_from_id('feedback', $id)) {
+    print_error('invalidcoursemodule');
+}
+
+if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+    print_error('coursemisconf');
+}
+
+if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
+    print_error('invalidcoursemodule');
+}
+
+if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
+        print_error('badcontext');
+}
+
+$feedback_complete_cap = false;
+
+if (isset($CFG->feedback_allowfullanonymous)
+            AND $CFG->feedback_allowfullanonymous
+            AND $course->id == SITEID
+            AND (!$courseid OR $courseid == SITEID)
+            AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES ) {
+    $feedback_complete_cap = true;
+}
+
+//check whether the feedback is anonymous
+if (isset($CFG->feedback_allowfullanonymous)
                 AND $CFG->feedback_allowfullanonymous
-                AND $course->id == SITEID
-                AND (!$courseid OR $courseid == SITEID)
-                AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES ) {
-        $feedback_complete_cap = true;
-    }
-
-    //check whether the feedback is anonymous
-    if(isset($CFG->feedback_allowfullanonymous)
-                    AND $CFG->feedback_allowfullanonymous
-                    AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES
-                    AND $course->id == SITEID ) {
-        $feedback_complete_cap = true;
-    }
-    if($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
-        print_error('feedback_is_not_for_anonymous', 'feedback');
-    }
-
-    //check whether the user has a session
-    // there used to be a sesskey test - this could not work - sorry
-
-    //check whether the feedback is located and! started from the mainsite
-    if($course->id == SITEID AND !$courseid) {
-        $courseid = SITEID;
-    }
-
-    require_course_login($course);
-
-    if($courseid AND $courseid != SITEID) {
-        $course2 = $DB->get_record('course', array('id'=>$courseid));
-        require_course_login($course2); //this overwrites the object $course :-(
-        $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
-    }
-
-    if(!$feedback_complete_cap) {
-        print_error('error');
-    }
-
-
-    /// Print the page header
-    $strfeedbacks = get_string("modulenameplural", "feedback");
-    $strfeedback  = get_string("modulename", "feedback");
-
-    $PAGE->set_cm($cm, $course); // set's up global $COURSE
-    $PAGE->set_pagelayout('incourse');
-
-    $PAGE->navbar->add($strfeedbacks, new moodle_url('/mod/feedback/index.php', array('id'=>$course->id)));
-    $PAGE->navbar->add(format_string($feedback->name));
-    $PAGE->set_heading(format_string($course->fullname));
-    $PAGE->set_title(format_string($feedback->name));
-    echo $OUTPUT->header();
-
-    //ishidden check. hidden feedbacks except feedbacks on mainsite are only accessible with related capabilities
-    if ((empty($cm->visible) AND
-            !has_capability('moodle/course:viewhiddenactivities', $context)) AND
-            $course->id != SITEID) {
-        notice(get_string("activityiscurrentlyhidden"));
-    }
-
-    feedback_print_errors();
-
-    //check, if the feedback is open (timeopen, timeclose)
-    $checktime = time();
-    if(($feedback->timeopen > $checktime) OR ($feedback->timeclose < $checktime AND $feedback->timeclose > 0)) {
-        echo $OUTPUT->box_start('generalbox boxaligncenter');
-            echo '<h2><font color="red">'.get_string('feedback_is_not_open', 'feedback').'</font></h2>';
-            echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
-        echo $OUTPUT->box_end();
-        echo $OUTPUT->footer();
-        exit;
+                AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES
+                AND $course->id == SITEID ) {
+    $feedback_complete_cap = true;
+}
+if ($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
+    print_error('feedback_is_not_for_anonymous', 'feedback');
+}
+
+//check whether the user has a session
+// there used to be a sesskey test - this could not work - sorry
+
+//check whether the feedback is located and! started from the mainsite
+if ($course->id == SITEID AND !$courseid) {
+    $courseid = SITEID;
+}
+
+require_course_login($course);
+
+if ($courseid AND $courseid != SITEID) {
+    $course2 = $DB->get_record('course', array('id'=>$courseid));
+    require_course_login($course2); //this overwrites the object $course :-(
+    $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
+}
+
+if (!$feedback_complete_cap) {
+    print_error('error');
+}
+
+
+/// Print the page header
+$strfeedbacks = get_string("modulenameplural", "feedback");
+$strfeedback  = get_string("modulename", "feedback");
+
+$PAGE->set_cm($cm, $course); // set's up global $COURSE
+$PAGE->set_pagelayout('incourse');
+
+$urlparams = array('id'=>$course->id);
+$PAGE->navbar->add($strfeedbacks, new moodle_url('/mod/feedback/index.php', $urlparams));
+$PAGE->navbar->add(format_string($feedback->name));
+$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title(format_string($feedback->name));
+echo $OUTPUT->header();
+
+//ishidden check.
+//hidden feedbacks except feedbacks on mainsite are only accessible with related capabilities
+if ((empty($cm->visible) AND
+        !has_capability('moodle/course:viewhiddenactivities', $context)) AND
+        $course->id != SITEID) {
+    notice(get_string("activityiscurrentlyhidden"));
+}
+
+//check, if the feedback is open (timeopen, timeclose)
+$checktime = time();
+
+$feedback_is_closed = ($feedback->timeopen > $checktime) OR
+                      ($feedback->timeclose < $checktime AND
+                            $feedback->timeclose > 0);
+
+if ($feedback_is_closed) {
+    echo $OUTPUT->box_start('generalbox boxaligncenter');
+        echo '<h2><font color="red">';
+        echo get_string('feedback_is_not_open', 'feedback');
+        echo '</font></h2>';
+        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
+    echo $OUTPUT->box_end();
+    echo $OUTPUT->footer();
+    exit;
+}
+
+//additional check for multiple-submit (prevent browsers back-button).
+//the main-check is in view.php
+$feedback_can_submit = true;
+if ($feedback->multiple_submit == 0 ) {
+    if (feedback_is_already_submitted($feedback->id, $courseid)) {
+        $feedback_can_submit = false;
     }
-
-    //additional check for multiple-submit (prevent browsers back-button). the main-check is in view.php
-    $feedback_can_submit = true;
-    if($feedback->multiple_submit == 0 ) {
-        // if($multiple_count = $DB->get_record('feedback_tracking', array('userid'=>$USER->id, 'feedback'=>$feedback->id))) {
-        if(feedback_is_already_submitted($feedback->id, $courseid)) {
-            $feedback_can_submit = false;
+}
+if ($feedback_can_submit) {
+    //preserving the items
+    if ($preservevalues == 1) {
+        if (!$SESSION->feedback->is_started == true) {
+            print_error('error', 'error', $CFG->wwwroot.'/course/view.php?id='.$course->id);
         }
-    }
-    if($feedback_can_submit) {
-        //preserving the items
-        if($preservevalues == 1){
-            if (!$SESSION->feedback->is_started == true) {
-                print_error('error', 'error', $CFG->wwwroot.'/course/view.php?id='.$course->id);
-            }
-            //check, if all required items have a value
-            if(feedback_check_values($startitempos, $lastitempos)) {
-                $userid = $USER->id; //arb
-                if($completedid = feedback_save_guest_values(sesskey())){
-                    add_to_log($course->id, 'feedback', 'startcomplete', 'view.php?id='.$cm->id, $feedback->id); //arb: log even guest submissions or at least the startcomplete since the other add log event is elsewhere
-
-                    if(!$gonextpage AND !$gopreviouspage) $preservevalues = false;//es kann gespeichert werden
-
-                }else {
-                    $savereturn = 'failed';
-                    if(isset($lastpage)) {
-                        $gopage = $lastpage;
-                    }else {
-                        print_error('parameters_missing', 'feedback');
-                    }
+        //check, if all required items have a value
+        if (feedback_check_values($startitempos, $lastitempos)) {
+            $userid = $USER->id; //arb
+            if ($completedid = feedback_save_guest_values(sesskey())) {
+                add_to_log($course->id,
+                           'feedback',
+                           'startcomplete',
+                           'view.php?id='.$cm->id,
+                           $feedback->id);
+
+                //now it can be saved
+                if (!$gonextpage AND !$gopreviouspage) {
+                    $preservevalues = false;
                 }
-            }else {
-                $savereturn = 'missing';
-                $highlightrequired = true;
-                if(isset($lastpage)) {
+
+            } else {
+                $savereturn = 'failed';
+                if (isset($lastpage)) {
                     $gopage = $lastpage;
-                }else {
+                } else {
                     print_error('parameters_missing', 'feedback');
                 }
             }
+        } else {
+            $savereturn = 'missing';
+            $highlightrequired = true;
+            if (isset($lastpage)) {
+                $gopage = $lastpage;
+            } else {
+                print_error('parameters_missing', 'feedback');
+            }
         }
+    }
 
-        //saving the items
-        if($savevalues AND !$preservevalues){
-            //exists there any pagebreak, so there are values in the feedback_valuetmp
-            $userid = $USER->id; //arb changed from 0 to $USER->id - no strict anonymous feedbacks - if it is a guest taking it then I want to know that it was a guest (at least in the data saved in the feedback tables)
-
-            $feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', array('id'=>$completedid));
-
-            //fake saving for switchrole
-            $is_switchrole = feedback_check_is_switchrole();
-            if($is_switchrole) {
-                $savereturn = 'saved';
-                feedback_delete_completedtmp($completedid);
-            }else if($new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp, false, $userid)) {
+    //saving the items
+    if ($savevalues AND !$preservevalues) {
+        //exists there any pagebreak, so there are values in the feedback_valuetmp
+        //arb changed from 0 to $USER->id
+        //no strict anonymous feedbacks
+        //if it is a guest taking it then I want to know that it was
+        //a guest (at least in the data saved in the feedback tables)
+        $userid = $USER->id;
+
+        $params = array('id'=>$completedid);
+        $feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', $params);
+
+        //fake saving for switchrole
+        $is_switchrole = feedback_check_is_switchrole();
+        if ($is_switchrole) {
+            $savereturn = 'saved';
+            feedback_delete_completedtmp($completedid);
+        } else {
+            $new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp, false, $userid);
+            if ($new_completed_id) {
                 $savereturn = 'saved';
                 feedback_send_email_anonym($cm, $feedback, $course, $userid);
                 unset($SESSION->feedback->is_started);
 
-            }else {
+            } else {
                 $savereturn = 'failed';
             }
         }
+    }
 
-        if($allbreaks = feedback_get_all_break_positions($feedback->id)){
-            if($gopage <= 0) {
-                $startposition = 0;
-            }else {
-                if(!isset($allbreaks[$gopage - 1])) {
-                    $gopage = count($allbreaks);
-                }
-                $startposition = $allbreaks[$gopage - 1];
-            }
-            $ispagebreak = true;
-        }else {
+    if ($allbreaks = feedback_get_all_break_positions($feedback->id)) {
+        if ($gopage <= 0) {
             $startposition = 0;
-            $newpage = 0;
-            $ispagebreak = false;
+        } else {
+            if (!isset($allbreaks[$gopage - 1])) {
+                $gopage = count($allbreaks);
+            }
+            $startposition = $allbreaks[$gopage - 1];
         }
+        $ispagebreak = true;
+    } else {
+        $startposition = 0;
+        $newpage = 0;
+        $ispagebreak = false;
+    }
+
+    //get the feedbackitems after the last shown pagebreak
+    $select = 'feedback = ? AND position > ?';
+    $params = array($feedback->id, $startposition);
+    $feedbackitems = $DB->get_records_select('feedback_item', $select, $params, 'position');
+
+    //get the first pagebreak
+    $params = array('feedback'=>$feedback->id, 'typ'=>'pagebreak');
+    if ($pagebreaks = $DB->get_records('feedback_item', $params, 'position')) {
+        $pagebreaks = array_values($pagebreaks);
+        $firstpagebreak = $pagebreaks[0];
+    } else {
+        $firstpagebreak = false;
+    }
+    $maxitemcount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
+    $feedbackcompletedtmp = feedback_get_current_completed($feedback->id,
+                                                           true,
+                                                           $courseid,
+                                                           sesskey());
 
-        //get the feedbackitems after the last shown pagebreak
-        $feedbackitems = $DB->get_records_select('feedback_item', 'feedback = ? AND position > ?', array($feedback->id, $startposition), 'position');
+    /// Print the main part of the page
+    ///////////////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////////////
+    ///////////////////////////////////////////////////////////////////////////
+    $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
+    if ($courseid > 0) {
+        $analysisurl->param('courseid', $courseid);
+    }
+    echo $OUTPUT->heading(format_text($feedback->name));
+
+    if ( (intval($feedback->publish_stats) == 1) AND
+            ( has_capability('mod/feedback:viewanalysepage', $context)) AND
+            !( has_capability('mod/feedback:viewreports', $context)) ) {
+        echo $OUTPUT->box_start('mdl-align');
+        echo '<a href="'.$analysisurl->out().'">';
+        echo get_string('completed_feedbacks', 'feedback');
+        echo '</a>';
+        echo $OUTPUT->box_end();
+    }
 
-        //get the first pagebreak
-        if($pagebreaks = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'typ'=>'pagebreak'), 'position')) {
-            $pagebreaks = array_values($pagebreaks);
-            $firstpagebreak = $pagebreaks[0];
-        }else {
-            $firstpagebreak = false;
+    if (isset($savereturn) && $savereturn == 'saved') {
+        if ($feedback->page_after_submit) {
+            echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
+            echo format_text($feedback->page_after_submit,
+                             $feedback->page_after_submitformat,
+                             array('overflowdiv' => true));
+            echo $OUTPUT->box_end();
+        } else {
+            echo '<p align="center"><b><font color="green">';
+            echo get_string('entries_saved', 'feedback');
+            echo '</font></b></p>';
+            if ( intval($feedback->publish_stats) == 1) {
+                echo '<p align="center"><a href="'.$analysisurl->out().'">';
+                echo get_string('completed_feedbacks', 'feedback').'</a>';
+                echo '</p>';
+            }
+        }
+        if ($feedback->site_after_submit) {
+            $url = feedback_encode_target_url($feedback->site_after_submit);
+        } else {
+            if ($courseid) {
+                if ($courseid == SITEID) {
+                    $url = $CFG->wwwroot;
+                } else {
+                    $url = $CFG->wwwroot.'/course/view.php?id='.$courseid;
+                }
+            } else {
+                if ($course->id == SITEID) {
+                    $url = $CFG->wwwroot;
+                } else {
+                    $url = $CFG->wwwroot.'/course/view.php?id='.$course->id;
+                }
+            }
         }
-        $maxitemcount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
-        $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid, sesskey());
-
-        /// Print the main part of the page
-        ///////////////////////////////////////////////////////////////////////////
-        ///////////////////////////////////////////////////////////////////////////
-        ///////////////////////////////////////////////////////////////////////////
-        $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
-        if($courseid > 0) {
-            $analysisurl->param('courseid', $courseid);
+        echo $OUTPUT->continue_button($url);
+    } else {
+        if (isset($savereturn) && $savereturn == 'failed') {
+            echo $OUTPUT->box_start('mform error');
+            echo get_string('saving_failed', 'feedback');
+            echo $OUTPUT->box_end();
         }
-        echo $OUTPUT->heading(format_text($feedback->name));
 
-        if( (intval($feedback->publish_stats) == 1) AND
-                ( has_capability('mod/feedback:viewanalysepage', $context)) AND
-                !( has_capability('mod/feedback:viewreports', $context)) ) {
-            echo $OUTPUT->box_start('mdl-align');
-            echo '<a href="'.$analysisurl->out().'">'.get_string('completed_feedbacks', 'feedback').'</a>';
+        if (isset($savereturn) && $savereturn == 'missing') {
+            echo $OUTPUT->box_start('mform error');
+            echo get_string('saving_failed_because_missing_or_false_values', 'feedback');
             echo $OUTPUT->box_end();
         }
 
-        if(isset($savereturn) && $savereturn == 'saved') {
-            if($feedback->page_after_submit) {
-                echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
-                echo format_text($feedback->page_after_submit, $feedback->page_after_submitformat, array('overflowdiv'=>true));
-                echo $OUTPUT->box_end();
-            } else {
-                echo '<p align="center"><b><font color="green">'.get_string('entries_saved','feedback').'</font></b></p>';
-                if( intval($feedback->publish_stats) == 1) {
-                    echo '<p align="center"><a href="'.$analysisurl->out().'">';
-                    echo get_string('completed_feedbacks', 'feedback').'</a>';
-                    echo '</p>';
-                }
+        //print the items
+        if (is_array($feedbackitems)) {
+            echo $OUTPUT->box_start('feedback_form');
+            echo '<form action="complete_guest.php" method="post" onsubmit=" ">';
+            echo '<fieldset>';
+            echo '<input type="hidden" name="anonymous" value="0" />';
+            $inputvalue = 'value="'.FEEDBACK_ANONYMOUS_YES.'"';
+            echo '<input type="hidden" name="anonymous_response" '.$inputvalue.' />';
+            echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+            //check, if there exists required-elements
+            $params = array('feedback'=>$feedback->id, 'required'=>1);
+            $countreq = $DB->count_records('feedback_item', $params);
+            if ($countreq > 0) {
+                echo '<span class="feedback_required_mark">(*)';
+                echo get_string('items_are_required', 'feedback');
+                echo '</span>';
             }
-            if($feedback->site_after_submit) {
-                echo $OUTPUT->continue_button(feedback_encode_target_url($feedback->site_after_submit));
-            }else {
-                if($courseid) {
-                    if($courseid == SITEID) {
-                        echo $OUTPUT->continue_button($CFG->wwwroot);
-                    }else {
-                        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$courseid);
-                    }
-                }else {
-                    if($course->id == SITEID) {
-                        echo $OUTPUT->continue_button($CFG->wwwroot);
-                    } else {
-                        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
+            echo $OUTPUT->box_start('feedback_items');
+
+            $startitem = null;
+            $select = 'feedback = ? AND hasvalue = 1 AND position < ?';
+            $params = array($feedback->id, $startposition);
+            $itemnr = $DB->count_records_select('feedback_item', $select, $params);
+            $lastbreakposition = 0;
+            $align = right_to_left() ? 'right' : 'left';
+
+            foreach ($feedbackitems as $feedbackitem) {
+                if (!isset($startitem)) {
+                    //avoid showing double pagebreaks
+                    if ($feedbackitem->typ == 'pagebreak') {
+                        continue;
                     }
+                    $startitem = $feedbackitem;
                 }
-            }
-        }else {
-            if(isset($savereturn) && $savereturn == 'failed') {
-                echo $OUTPUT->box_start('mform error');
-                echo get_string('saving_failed','feedback');
-                echo $OUTPUT->box_end();
-            }
 
-            if(isset($savereturn) && $savereturn == 'missing') {
-                echo $OUTPUT->box_start('mform error');
-                echo get_string('saving_failed_because_missing_or_false_values','feedback');
-                echo $OUTPUT->box_end();
-            }
+                if ($feedbackitem->dependitem > 0) {
+                    //chech if the conditions are ok
+                    $fb_compare_value = feedback_compare_item_value($feedbackcompletedtmp->id,
+                                                                    $feedbackitem->dependitem,
+                                                                    $feedbackitem->dependvalue,
+                                                                    true);
+                    if (!isset($feedbackcompletedtmp->id) OR !$fb_compare_value) {
+                        $lastitem = $feedbackitem;
+                        $lastbreakposition = $feedbackitem->position;
+                        continue;
+                    }
+                }
 
-            //print the items
-            if(is_array($feedbackitems)){
-                // echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
-                echo $OUTPUT->box_start('feedback_form');
-                echo '<form action="complete_guest.php" method="post" onsubmit=" ">';
-                echo '<fieldset>';
-                echo '<input type="hidden" name="anonymous" value="0" />';
-                echo '<input type="hidden" name="anonymous_response" value="'.FEEDBACK_ANONYMOUS_YES.'" />';
-                echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-                //check, if there exists required-elements
-                $countreq = $DB->count_records('feedback_item', array('feedback'=>$feedback->id, 'required'=>1));
-                if($countreq > 0) {
-                    echo '<span class="feedback_required_mark">(*)' . get_string('items_are_required', 'feedback') . '</span>';
+                if ($feedbackitem->dependitem > 0) {
+                    $dependstyle = ' feedback_complete_depend';
+                } else {
+                    $dependstyle = '';
                 }
-                echo $OUTPUT->box_start('feedback_items');
-
-                $startitem = null;
-                $itemnr = $DB->count_records_select('feedback_item', 'feedback = ? AND hasvalue = 1 AND position < ?', array($feedback->id, $startposition));
-                $lastbreakposition = 0;
-                $align = right_to_left() ? 'right' : 'left';
-
-                foreach($feedbackitems as $feedbackitem){
-                    if(!isset($startitem)) {
-                        //avoid showing double pagebreaks
-                        if($feedbackitem->typ == 'pagebreak') {
-                            continue;
-                        }
-                        $startitem = $feedbackitem;
-                    }
 
-                    if($feedbackitem->dependitem > 0) {
-                        //chech if the conditions are ok
-                        if(!isset($feedbackcompletedtmp->id) OR !feedback_compare_item_value($feedbackcompletedtmp->id, $feedbackitem->dependitem, $feedbackitem->dependvalue, true)) {
-                            $lastitem = $feedbackitem;
-                            $lastbreakposition = $feedbackitem->position;
-                            continue;
-                        }
+                echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
+                $value = '';
+                //get the value
+                $frmvaluename = $feedbackitem->typ.'_'.$feedbackitem->id;
+                if (isset($savereturn)) {
+                    if (isset($formdata->{$frmvaluename})) {
+                        $value = $formdata->{$frmvaluename};
+                    } else {
+                        $value = null;
                     }
-
-                    if($feedbackitem->dependitem > 0) {
-                        $dependstyle = ' feedback_complete_depend';
-                    }else {
-                        $dependstyle = '';
+                } else {
+                    if (isset($feedbackcompletedtmp->id)) {
+                        $value = feedback_get_item_value($feedbackcompletedtmp->id,
+                                                         $feedbackitem->id,
+                                                         sesskey());
                     }
-
-                    echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
-                        $value = '';
-                        //get the value
-                        $frmvaluename = $feedbackitem->typ . '_'. $feedbackitem->id;
-                        if(isset($savereturn)) {
-                            $value =  isset($formdata->{$frmvaluename})?$formdata->{$frmvaluename}:NULL;
-                        }else {
-                            if(isset($feedbackcompletedtmp->id)) {
-                                $value = feedback_get_item_value($feedbackcompletedtmp->id, $feedbackitem->id, sesskey());
-                            }
-                        }
-                        if($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
-                            $itemnr++;
-                            echo $OUTPUT->box_start('feedback_item_number_'.$align);
-                            echo $itemnr;
-                            echo $OUTPUT->box_end();
-                        }
-                        if($feedbackitem->typ != 'pagebreak') {
-                            echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
-                                feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
-                            echo $OUTPUT->box_end();
-                        }
+                }
+                if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
+                    $itemnr++;
+                    echo $OUTPUT->box_start('feedback_item_number_'.$align);
+                    echo $itemnr;
                     echo $OUTPUT->box_end();
-
-                    $lastbreakposition = $feedbackitem->position; //last item-pos (item or pagebreak)
-                    if($feedbackitem->typ == 'pagebreak'){
-                        break;
-                    }else {
-                        $lastitem = $feedbackitem;
-                    }
                 }
-                echo $OUTPUT->box_end();
-                echo '<input type="hidden" name="id" value="'.$id.'" />';
-                echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'" />';
-                echo '<input type="hidden" name="lastpage" value="'.$gopage.'" />';
-                echo '<input type="hidden" name="completedid" value="'.(isset($feedbackcompletedtmp->id)?$feedbackcompletedtmp->id:'').'" />';
-                echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
-                echo '<input type="hidden" name="preservevalues" value="1" />';
-                if(isset($startitem)) {
-                    echo '<input type="hidden" name="startitempos" value="'. $startitem->position . '" />';
-                    echo '<input type="hidden" name="lastitempos" value="'. $lastitem->position . '" />';
+                if ($feedbackitem->typ != 'pagebreak') {
+                    echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
+                    feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
+                    echo $OUTPUT->box_end();
                 }
+                echo $OUTPUT->box_end();
 
-                if($ispagebreak AND $lastbreakposition > $firstpagebreak->position) {
-                    echo '<input name="gopreviouspage" type="submit" value="'.get_string('previous_page','feedback').'" />';
-                }
-                if($lastbreakposition < $maxitemcount){
-                    echo '<input name="gonextpage" type="submit" value="'.get_string('next_page','feedback').'" />';
-                }
-                if($lastbreakposition >= $maxitemcount) { //last page
-                    echo '<input name="savevalues" type="submit" value="'.get_string('save_entries','feedback').'" />';
+                $lastbreakposition = $feedbackitem->position; //last item-pos (item or pagebreak)
+                if ($feedbackitem->typ == 'pagebreak') {
+                    break;
+                } else {
+                    $lastitem = $feedbackitem;
                 }
+            }
+            echo $OUTPUT->box_end();
+            echo '<input type="hidden" name="id" value="'.$id.'" />';
+            echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'" />';
+            echo '<input type="hidden" name="lastpage" value="'.$gopage.'" />';
+            if (isset($feedbackcompletedtmp->id)) {
+                $inputvalue = 'value="'.$feedbackcompletedtmp->id;
+            } else {
+                $inputvalue = 'value=""';
+            }
+            echo '<input type="hidden" name="completedid" '.$inputvalue.' />';
+            echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
+            echo '<input type="hidden" name="preservevalues" value="1" />';
+            if (isset($startitem)) {
+                echo '<input type="hidden" name="startitempos" value="'.$startitem->position.'" />';
+                echo '<input type="hidden" name="lastitempos" value="'.$lastitem->position.'" />';
+            }
 
-                echo '</fieldset>';
-                echo '</form>';
-                echo $OUTPUT->box_end();
+            if ($ispagebreak AND $lastbreakposition > $firstpagebreak->position) {
+                $inputvalue = 'value="'.get_string('previous_page', 'feedback').'"';
+                echo '<input name="gopreviouspage" type="submit" '.$inputvalue.' />';
+            }
+            if ($lastbreakposition < $maxitemcount) {
+                $inputvalue = 'value="'.get_string('next_page', 'feedback').'"';
+                echo '<input name="gonextpage" type="submit" '.$inputvalue.' />';
+            }
+            if ($lastbreakposition >= $maxitemcount) { //last page
+                $inputvalue = 'value="'.get_string('save_entries', 'feedback').'"';
+                echo '<input name="savevalues" type="submit" '.$inputvalue.' />';
+            }
 
-                echo $OUTPUT->box_start('feedback_complete_cancel');
-                if($courseid) {
-                    echo '<form action="'.$CFG->wwwroot.'/course/view.php?id='.$courseid.'" method="post" onsubmit=" ">';
-                }else{
-                    if($course->id == SITEID) {
-                        echo '<form action="'.$CFG->wwwroot.'" method="post" onsubmit=" ">';
-                    } else {
-                        echo '<form action="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'" method="post" onsubmit=" ">';
-                    }
+            echo '</fieldset>';
+            echo '</form>';
+            echo $OUTPUT->box_end();
+
+            echo $OUTPUT->box_start('feedback_complete_cancel');
+            if ($courseid) {
+                $action = 'action="'.$CFG->wwwroot.'/course/view.php?id='.$courseid.'"';
+            } else {
+                if ($course->id == SITEID) {
+                    $action = 'action="'.$CFG->wwwroot.'"';
+                } else {
+                    $action = 'action="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'"';
                 }
-                echo '<fieldset>';
-                echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
-                echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
-                echo '<button type="submit">'.get_string('cancel').'</button>';
-                echo '</fieldset>';
-                echo '</form>';
-                echo $OUTPUT->box_end();
-                $SESSION->feedback->is_started = true;
             }
+            echo '<form '.$action.' method="post" onsubmit=" ">';
+            echo '<fieldset>';
+            echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+            echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
+            echo '<button type="submit">'.get_string('cancel').'</button>';
+            echo '</fieldset>';
+            echo '</form>';
+            echo $OUTPUT->box_end();
+            $SESSION->feedback->is_started = true;
         }
-    }else {
-        echo $OUTPUT->box_start('generalbox boxaligncenter');
-            echo '<h2><font color="red">'.get_string('this_feedback_is_already_submitted', 'feedback').'</font></h2>';
-            echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
-        echo $OUTPUT->box_end();
     }
-    /// Finish the page
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-
-    echo $OUTPUT->footer();
+} else {
+    echo $OUTPUT->box_start('generalbox boxaligncenter');
+        echo '<h2><font color="red">';
+        echo get_string('this_feedback_is_already_submitted', 'feedback');
+        echo '</font></h2>';
+        echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
+    echo $OUTPUT->box_end();
+}
+/// Finish the page
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+
+echo $OUTPUT->footer();
 
index 16986b5..9921b2a 100644 (file)
@@ -1,4 +1,19 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
 //
 // Capability definitions for the feedback module.
 //
index 696d3f3..05f6665 100644 (file)
@@ -1,9 +1,23 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 function xmldb_feedback_install() {
     global $DB;
 
-/// Disable this module by default (because it's not technically part of Moodle 2.0)
+    /// Disable this module by default (because it's not technically part of Moodle 2.0)
     $DB->set_field('modules', 'visible', 0, array('name'=>'feedback'));
 
 }
index 97d31b3..9aaba27 100644 (file)
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
\ No newline at end of file
+</XMLDB>
index 79f1891..a27ce3e 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
index e99c919..a325eac 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 // This file is part of Moodle - http://moodle.org/
 //
 // Moodle is free software: you can redistribute it and/or modify
index b0a6fcf..e81cfa0 100644 (file)
@@ -1,4 +1,18 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
 // This file keeps track of upgrades to
 // the feedback module
@@ -31,15 +45,18 @@ function xmldb_feedback_upgrade($oldversion) {
         $table = new xmldb_table('feedback_completedtmp');
 
         $field = new xmldb_field('id');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, true, null, null);
         $table->addField($field);
 
         $field = new xmldb_field('feedback');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, false, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('userid');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, false, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('guestid');
@@ -47,7 +64,8 @@ function xmldb_feedback_upgrade($oldversion) {
         $table->addField($field);
 
         $field = new xmldb_field('timemodified');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, false, '0', null);
         $table->addField($field);
 
         $key = new xmldb_key('PRIMARY');
@@ -65,23 +83,28 @@ function xmldb_feedback_upgrade($oldversion) {
         $table = new xmldb_table('feedback_valuetmp');
 
         $field = new xmldb_field('id');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, true, null, null);
         $table->addField($field);
 
         $field = new xmldb_field('course_id');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, false, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('item');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, false, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('completed');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, false, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('tmp_completed');
-        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
+                                XMLDB_NOTNULL, false, '0', null);
         $table->addField($field);
 
         $field = new xmldb_field('value');
@@ -105,25 +128,29 @@ function xmldb_feedback_upgrade($oldversion) {
 
         /// Define field random_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completed');
-        $field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
         /// Launch add field1
         $dbman->add_field($table, $field);
 
         /// Define field anonymous_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completed');
-        $field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
+        $field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
         /// Launch add field2
         $dbman->add_field($table, $field);
 
         /// Define field random_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completedtmp');
-        $field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
+        $field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
         /// Launch add field1
         $dbman->add_field($table, $field);
 
         /// Define field anonymous_response to be added to feedback_completed
         $table = new xmldb_table('feedback_completedtmp');
-        $field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
+        $field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
         /// Launch add field2
         $dbman->add_field($table, $field);
 
@@ -135,7 +162,8 @@ function xmldb_feedback_upgrade($oldversion) {
         // public is a reserved word on Oracle
 
         $table = new xmldb_table('feedback_template');
-        $field = new xmldb_field('ispublic', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
+        $field = new xmldb_field('ispublic', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED,
+                                    XMLDB_NOTNULL, false, '1', null);
         if (!$dbman->field_exists($table, $field)) {
             $dbman->add_field($table, $field);
         }
@@ -144,7 +172,9 @@ function xmldb_feedback_upgrade($oldversion) {
 
     if ($oldversion < 2008042400) { //New version in version.php
         if ($all_nonanonymous_feedbacks = $DB->get_records('feedback', array('anonymous'=>2))) {
-            $update_sql = 'UPDATE {feedback_completed} SET anonymous_response = 2 WHERE feedback = ';
+            $update_sql = 'UPDATE {feedback_completed}
+                            SET anonymous_response = 2
+                            WHERE feedback = ';
             foreach ($all_nonanonymous_feedbacks as $fb) {
                 $DB->execute($update_sql.$fb->id);
             }
@@ -153,20 +183,34 @@ function xmldb_feedback_upgrade($oldversion) {
     }
 
     if ($oldversion < 2008042401) { //New version in version.php
-        $concat_radio    = $DB->sql_concat("'r>>>>>'",'presentation');
-        $concat_check    = $DB->sql_concat("'c>>>>>'",'presentation');
-        $concat_dropdown = $DB->sql_concat("'d>>>>>'",'presentation');
+        $concat_radio    = $DB->sql_concat("'r>>>>>'", 'presentation');
+        $concat_check    = $DB->sql_concat("'c>>>>>'", 'presentation');
+        $concat_dropdown = $DB->sql_concat("'d>>>>>'", 'presentation');
+
+        $update_sql1 = "UPDATE {feedback_item}
+                        SET presentation = ".$concat_radio."
+                        WHERE typ IN('radio','radiorated')";
 
-        $update_sql1 = "UPDATE {feedback_item} SET presentation = ".$concat_radio." WHERE typ IN('radio','radiorated')";
-        $update_sql2 = "UPDATE {feedback_item} SET presentation = ".$concat_dropdown." WHERE typ IN('dropdown','dropdownrated')";
-        $update_sql3 = "UPDATE {feedback_item} SET presentation = ".$concat_check." WHERE typ = 'check'";
+        $update_sql2 = "UPDATE {feedback_item}
+                        SET presentation = ".$concat_dropdown."
+                        WHERE typ IN('dropdown','dropdownrated')";
+
+        $update_sql3 = "UPDATE {feedback_item}
+                        SET presentation = ".$concat_check."
+                        WHERE typ = 'check'";
 
         $DB->execute($update_sql1);
         $DB->execute($update_sql2);
         $DB->execute($update_sql3);
 
-        $update_sql1 = "UPDATE {feedback_item} SET typ = 'multichoice' WHERE typ IN('radio','check','dropdown')";
-        $update_sql2 = "UPDATE {feedback_item} SET typ = 'multichoicerated' WHERE typ IN('radiorated','dropdownrated')";
+        $update_sql1 = "UPDATE {feedback_item}
+                        SET typ = 'multichoice'
+                        WHERE typ IN('radio','check','dropdown')";
+
+        $update_sql2 = "UPDATE {feedback_item}
+                        SET typ = 'multichoicerated'
+                        WHERE typ IN('radiorated','dropdownrated')";
+
         $DB->execute($update_sql1);
         $DB->execute($update_sql2);
 
@@ -176,7 +220,8 @@ function xmldb_feedback_upgrade($oldversion) {
     if ($oldversion < 2008042900) {
         /// Define field autonumbering to be added to feedback
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('autonumbering', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'multiple_submit');
+        $field = new xmldb_field('autonumbering', XMLDB_TYPE_INTEGER, '1',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'multiple_submit');
         /// Launch add field2
         $dbman->add_field($table, $field);
 
@@ -186,7 +231,8 @@ function xmldb_feedback_upgrade($oldversion) {
     if ($oldversion < 2008050104) {
         /// Define field site_after_submit to be added to feedback
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('site_after_submit', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'autonumbering');
+        $field = new xmldb_field('site_after_submit', XMLDB_TYPE_CHAR, '255',
+                                    null, null, false, '', 'autonumbering');
         /// Launch add field2
         $dbman->add_field($table, $field);
 
@@ -203,7 +249,11 @@ function xmldb_feedback_upgrade($oldversion) {
     }
 
     if ($oldversion < 2008073002) {
-        $update_sql = "UPDATE {feedback_item} SET presentation = '-|-' WHERE " . $DB->sql_compare_text('presentation') . " = '0|0' AND typ = 'numeric'";
+        $update_sql = "UPDATE {feedback_item}
+                        SET presentation = '-|-'
+                        WHERE " . $DB->sql_compare_text('presentation') . " = '0|0' AND
+                            typ = 'numeric'";
+
         $DB->execute($update_sql);
 
         upgrade_mod_savepoint(true, 2008073002, 'feedback');
@@ -221,34 +271,37 @@ function xmldb_feedback_upgrade($oldversion) {
 
     if ($oldversion < 2009042000) {
 
-    /// Rename field summary on table feedback to intro
+        /// Rename field summary on table feedback to intro
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
+        $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null,
+                                    XMLDB_NOTNULL, null, null, 'name');
 
-    /// Launch rename field summary
+        /// Launch rename field summary
         $dbman->rename_field($table, $field, 'intro');
 
-    /// feedback savepoint reached
+        /// feedback savepoint reached
         upgrade_mod_savepoint(true, 2009042000, 'feedback');
     }
 
     if ($oldversion < 2009042001) {
 
-    /// Define field introformat to be added to feedback
+        /// Define field introformat to be added to feedback
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
+        $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
 
-    /// Launch add field introformat
+        /// Launch add field introformat
         $dbman->add_field($table, $field);
 
-    /// feedback savepoint reached
+        /// feedback savepoint reached
         upgrade_mod_savepoint(true, 2009042001, 'feedback');
     }
 
     if ($oldversion < 2009112000) {
         /// Define field page_after_submitformat to be added to feedback
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('page_after_submitformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'page_after_submit');
+        $field = new xmldb_field('page_after_submitformat', XMLDB_TYPE_INTEGER, '2',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'page_after_submit');
 
         if (!$dbman->field_exists($table, $field)) {
             // Launch add field page_after_submitformat
@@ -262,7 +315,8 @@ function xmldb_feedback_upgrade($oldversion) {
     if ($oldversion < 2010051101) {
         /// Define field options to be added to feedback_item
         $table = new xmldb_table('feedback_item');
-        $field = new xmldb_field('options', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'required');
+        $field = new xmldb_field('options', XMLDB_TYPE_CHAR, '255',
+                                    null, null, false, '', 'required');
         /// Launch add field
         $dbman->add_field($table, $field);
 
@@ -272,7 +326,8 @@ function xmldb_feedback_upgrade($oldversion) {
     if ($oldversion < 2010051600) {
         /// Define field options to be added to feedback_item
         $table = new xmldb_table('feedback_item');
-        $field = new xmldb_field('dependitem', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'required');
+        $field = new xmldb_field('dependitem', XMLDB_TYPE_INTEGER, '10',
+                                    XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'required');
         /// Launch add field
         $dbman->add_field($table, $field);
 
@@ -282,7 +337,8 @@ function xmldb_feedback_upgrade($oldversion) {
     if ($oldversion < 2010051601) {
         /// Define field options to be added to feedback_item
         $table = new xmldb_table('feedback_item');
-        $field = new xmldb_field('dependvalue', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'dependitem');
+        $field = new xmldb_field('dependvalue', XMLDB_TYPE_CHAR, '255',
+                                    null, null, false, '', 'dependitem');
         /// Launch add field
         $dbman->add_field($table, $field);
 
@@ -293,7 +349,8 @@ function xmldb_feedback_upgrade($oldversion) {
 
         // Define field completionsubmit to be added to feedback
         $table = new xmldb_table('feedback');
-        $field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'timemodified');
+        $field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '1',
+                                    null, XMLDB_NOTNULL, null, '0', 'timemodified');
 
         // Conditionally launch add field completionsubmit
         if (!$dbman->field_exists($table, $field)) {
@@ -303,7 +360,6 @@ function xmldb_feedback_upgrade($oldversion) {
         // feedback savepoint reached
         upgrade_mod_savepoint(true, 2010102300, 'feedback');
     }
-    
 
     // Moodle v2.1.0 release upgrade line
     // Put any upgrade step following this
index cbc3a02..a571b2a 100644 (file)
 <?php
-
-    /**
-    * prints the form to confirm the deleting of a completed
-    *
-    * @author Andreas Grabs
-    * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-    * @package feedback
-    */
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once('delete_completed_form.php');
-
-    $id = required_param('id', PARAM_INT);
-    $completedid = optional_param('completedid', 0, PARAM_INT);
-    $return = optional_param('return', 'entries', PARAM_ALPHA);
-
-    if($completedid == 0){
-        print_error('no_complete_to_delete', 'feedback', 'show_entries.php?id='.$id.'&do_show=showentries');
-    }
-
-    $PAGE->set_url('/mod/feedback/delete_completed.php', array('id'=>$id, 'completed'=>$completedid));
-
-    if (! $cm = get_coursemodule_from_id('feedback', $id)) {
-        print_error('invalidcoursemodule');
-    }
-
-    if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
-        print_error('coursemisconf');
-    }
-
-    if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
-        print_error('invalidcoursemodule');
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * prints the form to confirm the deleting of a completed
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+require_once("../../config.php");
+require_once("lib.php");
+require_once('delete_completed_form.php');
+
+$id = required_param('id', PARAM_INT);
+$completedid = optional_param('completedid', 0, PARAM_INT);
+$return = optional_param('return', 'entries', PARAM_ALPHA);
+
+if ($completedid == 0) {
+    print_error('no_complete_to_delete',
+                'feedback',
+                'show_entries.php?id='.$id.'&do_show=showentries');
+}
+
+$PAGE->set_url('/mod/feedback/delete_completed.php', array('id'=>$id, 'completed'=>$completedid));
+
+if (! $cm = get_coursemodule_from_id('feedback', $id)) {
+    print_error('invalidcoursemodule');
+}
+
+if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+    print_error('coursemisconf');
+}
+
+if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
+    print_error('invalidcoursemodule');
+}
+
+if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
+        print_error('badcontext');
+}
+
+require_login($course->id, true, $cm);
+
+require_capability('mod/feedback:deletesubmissions', $context);
+
+$mform = new mod_feedback_delete_completed_form();
+$newformdata = array('id'=>$id,
+                    'completedid'=>$completedid,
+                    'confirmdelete'=>'1',
+                    'do_show'=>'edit',
+                    'return'=>$return);
+$mform->set_data($newformdata);
+$formdata = $mform->get_data();
+
+if ($mform->is_cancelled()) {
+    if ($return == 'entriesanonym') {
+        redirect('show_entries_anonym.php?id='.$id);
+    } else {
+        redirect('show_entries.php?id='.$id.'&do_show=showentries');
     }
-
-    if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
-            print_error('badcontext');
-    }
-
-    require_login($course->id, true, $cm);
-
-    require_capability('mod/feedback:deletesubmissions', $context);
-
-    $mform = new mod_feedback_delete_completed_form();
-    $newformdata = array('id'=>$id,
-                        'completedid'=>$completedid,
-                        'confirmdelete'=>'1',
-                        'do_show'=>'edit',
-                        'return'=>$return);
-    $mform->set_data($newformdata);
-    $formdata = $mform->get_data();
-
-    if ($mform->is_cancelled()) {
-        if($return == 'entriesanonym') {
+}
+
+if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) {
+    if ($completed = $DB->get_record('feedback_completed', array('id'=>$completedid))) {
+        feedback_delete_completed($completedid);
+        add_to_log($course->id,
+                   'feedback',
+                   'delete',
+                   'view.php?id='.$cm->id,
+                   $feedback->id,
+                   $cm->id);
+
+        if ($return == 'entriesanonym') {
             redirect('show_entries_anonym.php?id='.$id);
-        }else {
+        } else {
             redirect('show_entries.php?id='.$id.'&do_show=showentries');
         }
     }
+}
 
-    if(isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1){
-        if($completed = $DB->get_record('feedback_completed', array('id'=>$completedid))) {
-            feedback_delete_completed($completedid);
-            add_to_log($course->id, 'feedback', 'delete', 'view.php?id='.$cm->id, $feedback->id,$cm->id);
-            
-            if($return == 'entriesanonym') {
-                redirect('show_entries_anonym.php?id='.$id);
-            }else {
-                redirect('show_entries.php?id='.$id.'&do_show=showentries');
-            }
-        }
-    }
-
-    /// Print the page header
-    $strfeedbacks = get_string("modulenameplural", "feedback");
-    $strfeedback  = get_string("modulename", "feedback");
-    
-    $PAGE->navbar->add(get_string('delete_entry', 'feedback'));
-    $PAGE->set_heading(format_string($course->fullname));
-    $PAGE->set_title(format_string($feedback->name));
-    echo $OUTPUT->header();
-
-    /// Print the main part of the page
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-    echo $OUTPUT->heading(format_text($feedback->name));
-    echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
-    echo $OUTPUT->heading(get_string('confirmdeleteentry', 'feedback'));
-    $mform->display();
-    echo $OUTPUT->box_end();
+/// Print the page header
+$strfeedbacks = get_string("modulenameplural", "feedback");
+$strfeedback  = get_string("modulename", "feedback");
 
+$PAGE->navbar->add(get_string('delete_entry', 'feedback'));
+$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title(format_string($feedback->name));
+echo $OUTPUT->header();
 
-    echo $OUTPUT->footer();
+/// Print the main part of the page
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+echo $OUTPUT->heading(format_text($feedback->name));
+echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
+echo $OUTPUT->heading(get_string('confirmdeleteentry', 'feedback'));
+$mform->display();
+echo $OUTPUT->box_end();
 
 
+echo $OUTPUT->footer();
index f53197e..a0f677d 100644 (file)
@@ -1,25 +1,38 @@
 <?php
-/**
-* prints the form to confirm delete a completed
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
 
+/**
+ * prints the form to confirm delete a completed
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+//It must be included from a Moodle page
 if (!defined('MOODLE_INTERNAL')) {
-    die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
+    die('Direct access to this script is forbidden.');
 }
 
-require_once $CFG->libdir.'/formslib.php';
+require_once($CFG->libdir.'/formslib.php');
 
 class mod_feedback_delete_completed_form extends moodleform {
-    function definition() {
+    public function definition() {
         $mform =& $this->_form;
 
-        //headline
-        //$mform->addElement('header', 'general', '');
-
         // hidden elements
         $mform->addElement('hidden', 'id');
         $mform->setType('id', PARAM_INT);
index 3cbf200..cbd36bf 100644 (file)
@@ -1,78 +1,93 @@
 <?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
 /**
-* deletes an item of the feedback
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
-
-    require_once("../../config.php");
-    require_once("lib.php");
-    require_once('delete_item_form.php');
-
-    $id = required_param('id', PARAM_INT);
-    $deleteitem = required_param('deleteitem', PARAM_INT);
-
-    $PAGE->set_url('/mod/feedback/delete_item.php', array('id'=>$id, 'deleteitem'=>$deleteitem));
-
-    if (! $cm = get_coursemodule_from_id('feedback', $id)) {
-        print_error('invalidcoursemodule');
-    }
-
-    if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
-        print_error('coursemisconf');
-    }
-
-    if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
-        print_error('invalidcoursemodule');
-    }
-    
-    if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
-            print_error('badcontext');
-    }
-
-    require_login($course->id, true, $cm);
-
-    require_capability('mod/feedback:edititems', $context);
-
-    $mform = new mod_feedback_delete_item_form();
-    $newformdata = array('id'=>$id,
-                        'deleteitem'=>$deleteitem,
-                        'confirmdelete'=>'1');
-    $mform->set_data($newformdata);
-    $formdata = $mform->get_data();
-
-    if ($mform->is_cancelled()) {
-        redirect('edit.php?id='.$id);
-    }
-
-    if(isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1){
-        feedback_delete_item($formdata->deleteitem);
-        redirect('edit.php?id=' . $id);
-    }
-
-
-    /// Print the page header
-    $strfeedbacks = get_string("modulenameplural", "feedback");
-    $strfeedback  = get_string("modulename", "feedback");
-    
-    $PAGE->navbar->add(get_string('delete_item', 'feedback'));
-    $PAGE->set_heading(format_string($course->fullname));
-    $PAGE->set_title(format_string($feedback->name));
-    echo $OUTPUT->header();
-
-    /// Print the main part of the page
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-    ///////////////////////////////////////////////////////////////////////////
-    echo $OUTPUT->heading(format_text($feedback->name));
-    echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
-    echo $OUTPUT->heading(get_string('confirmdeleteitem', 'feedback'));
-    print_string('relateditemsdeleted','feedback');
-    $mform->display();
-    echo $OUTPUT->box_end();
-
-    echo $OUTPUT->footer();
+ * deletes an item of the feedback
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+require_once("../../config.php");
+require_once("lib.php");
+require_once('delete_item_form.php');
+
+$id = required_param('id', PARAM_INT);
+$deleteitem = required_param('deleteitem', PARAM_INT);
+
+$PAGE->set_url('/mod/feedback/delete_item.php', array('id'=>$id, 'deleteitem'=>$deleteitem));
+
+if (! $cm = get_coursemodule_from_id('feedback', $id)) {
+    pr