commit 7b3e3698fbaf7796e1fe2bbf1e6deeeb4c44be29
Author: Simon Coggins <simon.coggins@totaralms.com>
Date:   Mon Mar 26 11:09:36 2012 +1300

    T-9651: Update feedback preprocessor to work with new feedback module
    
    Change-Id: I032d0c9532bb09b0a1a4753c7885671beee255fa
    Reviewed-on: https://review.totaralms.com/1634
    Reviewed-by: Alastair Munro <alastair.munro@totaralms.com>
    Tested-by: Jenkins Automation <jenkins@totaralms.com>
    Reviewed-by: Ciaran Irvine <ciaran.irvine@totaralms.com>

diff --git a/local/reportbuilder/lib.php b/local/reportbuilder/lib.php
index 283f8d3..74c64a8 100644
--- a/local/reportbuilder/lib.php
+++ b/local/reportbuilder/lib.php
@@ -3007,8 +3007,10 @@ class reportbuilder {
         $questions = get_records($questionstable, '', '', 'sortorder');
         $options = get_records($optionstable, '', '', 'qid,sortorder');
         $grouped_options = array();
-        foreach($options as $option) {
-            $grouped_options[$option->qid][] = $option;
+        if ($options) {
+            foreach ($options as $option) {
+                $grouped_options[$option->qid][] = $option;
+            }
         }
 
         // get first column and use as heading
@@ -3127,6 +3129,8 @@ class reportbuilder {
                     case 'dropdown':
                     case 'dropdownrated':
                     case 'check':
+                    case 'multichoice':
+                    case 'multichoicerated':
                     case 'radio':
                     case 'radiorated':
                         // if it's an option based question, display bar chart if there are options
diff --git a/mod/feedback/rb_sources/rb_preproc_feedback_questions.php b/mod/feedback/rb_sources/rb_preproc_feedback_questions.php
index 8fc4c02..31b7435 100644
--- a/mod/feedback/rb_sources/rb_preproc_feedback_questions.php
+++ b/mod/feedback/rb_sources/rb_preproc_feedback_questions.php
@@ -20,6 +20,8 @@
  * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  * @package totara
  */
+global $CFG;
+require_once($CFG->dirroot.'/mod/feedback/lib.php');
 class rb_preproc_feedback_questions extends rb_base_preproc {
 
     var $name;
@@ -323,6 +325,8 @@ class rb_preproc_feedback_questions extends rb_base_preproc {
         case 'radiorated':
         case 'dropdown':
         case 'dropdownrated':
+        case 'multichoice':
+        case 'multichoicerated':
             if($value != 0) {
                 $options = $this->extract_item_options($question);
                 $opt_num = 1;
@@ -656,7 +660,7 @@ class rb_preproc_feedback_questions extends rb_base_preproc {
                 // question types that have options
                 // (and are supported)
                 $option_types = array('radio', 'radiorated', 'check', 'dropdown',
-                    'dropdownrated');
+                    'dropdownrated', 'multichoice', 'multichoicerated');
 
                 foreach($questions as $question) {
                     if(in_array($question->typ, $option_types)) {
@@ -701,16 +705,26 @@ class rb_preproc_feedback_questions extends rb_base_preproc {
         $line_sep = null; // string which separates options
         $adjust_sep = null; // string containing config info
         $value_sep = null; // string which separates options from values
+        $septype_sep = null; // string which defines the type separator
 
         // based on question type, figure out the separators that have
         // been used to format the string. Where possible we get these
         // directly from the feedback module
         $this->get_feedback_option_separators($type, $line_sep,
-            $adjust_sep, $value_sep);
+            $adjust_sep, $value_sep, $septype_sep);
 
         // get rid of \r characters from question strings
         $options_string = str_replace('\r', '', $question->presentation);
 
+        // if septype separator set, remove and discard anything
+        // before it
+        if ($septype_sep !== null) {
+            $loc = strpos($options_string, $septype_sep);
+            if ($loc !== false) {
+                $options_string = substr($options_string, $loc + strlen($septype_sep));
+            }
+        }
+
         // if adjustment separator set, remove and discard anything
         // after it
         if($adjust_sep !== null) {
@@ -763,11 +777,12 @@ class rb_preproc_feedback_questions extends rb_base_preproc {
      * @param string &$line Line separator (passed by reference)
      * @param string &$adjust Adjustment separator (passed by reference)
      * @param string &$value Value separator (passed by reference)
+     * @param string &$septype Type separator (passed by reference)
      *
      * @return Returns true and updates separator variables
      */
     private function get_feedback_option_separators($type, &$line, &$adjust,
-        &$value) {
+        &$value, &$septype) {
 
         global $CFG;
         // special cases for feedback items that don't follow normal
@@ -789,9 +804,11 @@ class rb_preproc_feedback_questions extends rb_base_preproc {
         $line_sep_name = 'FEEDBACK_' . strtoupper($type) . '_LINE_SEP';
         $adjust_sep_name = 'FEEDBACK_' . strtoupper($type) . '_ADJUST_SEP';
         $value_sep_name = 'FEEDBACK_' . strtoupper($type) . '_VALUE_SEP';
+        $septype_sep_name = 'FEEDBACK_' . strtoupper($type) . '_TYPE_SEP';
         $line = defined($line_sep_name) ? constant($line_sep_name) : null;
         $adjust = defined($adjust_sep_name) ? constant($adjust_sep_name) : null;
         $value = defined($value_sep_name) ? constant($value_sep_name) : null;
+        $septype = defined($septype_sep_name) ? constant($septype_sep_name) : null;
 
         return true;
     }
@@ -931,8 +948,10 @@ class rb_preproc_feedback_questions extends rb_base_preproc {
         case 'radio':
         case 'check':
         case 'dropdown':
+        case 'multichoice':
         case 'radiorated':
         case 'dropdownrated':
+        case 'multichoicerated':
             $status = $status &&
                 $table->addFieldInfo('q' . $qnum . '_answer',
                     XMLDB_TYPE_CHAR, '255', null, null, null, null);
diff --git a/mod/feedback/rb_sources/rb_source_feedback_questions.php b/mod/feedback/rb_sources/rb_source_feedback_questions.php
index 5cf5378..ea12df0 100644
--- a/mod/feedback/rb_sources/rb_source_feedback_questions.php
+++ b/mod/feedback/rb_sources/rb_source_feedback_questions.php
@@ -226,6 +226,8 @@ class rb_source_feedback_questions extends rb_base_source {
                     case 'radiorated':
                     case 'dropdown':
                     case 'dropdownrated':
+                    case 'multichoice':
+                    case 'multichoicerated':
                     case 'check':
                         if($options = get_records($this->grouptables . 'opt',
                             'qid', $qid, 'sortorder')) {
@@ -514,6 +516,8 @@ class rb_source_feedback_questions extends rb_base_source {
                     case 'radiorated':
                     case 'dropdown':
                     case 'dropdownrated':
+                    case 'multichoice':
+                    case 'multichoicerated':
                     case 'check':
                         // average answer
                         $defaultcolumns[] = array(
diff --git a/mod/feedback/rb_sources/rb_source_graphical_feedback_questions.php b/mod/feedback/rb_sources/rb_source_graphical_feedback_questions.php
index 6d37c4f..8d7606e 100644
--- a/mod/feedback/rb_sources/rb_source_graphical_feedback_questions.php
+++ b/mod/feedback/rb_sources/rb_source_graphical_feedback_questions.php
@@ -241,6 +241,8 @@ class rb_source_graphical_feedback_questions extends rb_base_source {
                     case 'radiorated':
                     case 'dropdown':
                     case 'dropdownrated':
+                    case 'multichoice':
+                    case 'multichoicerated':
                     case 'check':
                         if($options = get_records($this->grouptables . 'opt',
                             'qid', $qid, 'sortorder')) {
diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css
index a2f1c65..d4a4cc1 100755
--- a/theme/standard/styles_layout.css
+++ b/theme/standard/styles_layout.css
@@ -6060,3 +6060,52 @@ div.multiselect-selected-item .delete-icon {
     float: right;
 }
 
+/* Graphical Feedback basic styling */
+table.feedback-table th, table.feedback-table td {
+    border: 1px solid black;
+    padding: 4px;
+}
+
+hr.feedback-separator {
+    margin: 50px;
+    border-top: 1px solid black;
+    border-bottom: none;
+    border-left: none;
+    border-right: none;
+}
+
+th.feedback-option-number {
+    width: 30px;
+    text-align: center;
+}
+
+td.feedback-option-name {
+    width: 350px;
+}
+
+td.feedback-option-chart {
+    width: 250px;
+}
+
+td.feedback-option-count {
+    width: 100px;
+    text-align: center;
+}
+
+table.feedback-bar-chart {
+    width: 100%;
+    height: 20px;
+}
+
+table.feedback-bar-chart td {
+    border: none;
+    padding: 0px;
+}
+
+td.feedback-bar-color {
+    background-color: #CCC;
+}
+
+td.feedback-bar-blank {
+    background-color: none;
+}
