]> git.mjollnir.org Git - moodle.git/commitdiff
mod-feedback MDL-20254 Upgrade feedback module to make use of new navigation blocks
authorsamhemelryk <samhemelryk>
Fri, 11 Sep 2009 02:04:38 +0000 (02:04 +0000)
committersamhemelryk <samhemelryk>
Fri, 11 Sep 2009 02:04:38 +0000 (02:04 +0000)
At the same time I also took the oppertunity to fix up the bugs within the feedback module that were making it un-usable

12 files changed:
lang/en_utf8/feedback.php
lib/simpletest/testnavigationlib.php
mod/feedback/analysis.php
mod/feedback/complete.php
mod/feedback/edit.php
mod/feedback/edit_item.php
mod/feedback/item/feedback_item_form_class.php
mod/feedback/item/textarea/lib.php
mod/feedback/item/textarea/textarea_form.php
mod/feedback/lib.php
mod/feedback/show_entries.php
mod/feedback/view.php

index f3d5dbc631b7e8bc52472272f87237537a053602..09e2d0b21bd88b80be561b29447b640b63fa9231 100644 (file)
@@ -63,6 +63,7 @@ You can view it <a href=\"$a->url\">here</a>.';
 $string['entries_saved'] = 'Your answers have been saved. Thank you.';
 $string['export_questions'] = 'Export questions';
 $string['export_to_excel'] = 'Export to Excel';
+$string['feedbackadministration'] = 'Feedback administration';
 $string['feedback:complete'] = 'Complete a feedback';
 $string['feedback:createprivatetemplate'] = 'Create private template';
 $string['feedback:createpublictemplate'] = 'Create public template';
@@ -93,7 +94,7 @@ $string['infotype'] = 'Information-Type';
 $string['item_name'] = 'Question';
 $string['items_are_required'] = 'Answers are required to starred questions.';
 $string['label'] = 'Label';
-$string['line_labels'] = 'Label';
+$string['item_label'] = 'Label';
 $string['line_values'] = 'Rating';
 $string['mapcourse'] = 'Map course';
 $string['mapcourses'] = 'Map feedback to courses';
@@ -119,6 +120,7 @@ $string['name_required'] = 'Name required';
 $string['next_page'] = 'Next page';
 $string['no_handler']='No action handler exists for';
 $string['no_itemname'] = 'No itemname';
+$string['no_itemlabel'] = 'No label';
 $string['no_items_available_yet'] = 'No questions have been set up yet';
 $string['no_templates_available_yet'] = 'No templates available yet';
 $string['non_anonymous'] = 'User\'s name will be logged and shown with answers';
index d4349745e2e4de044af321c0ac44fa1125aa3168..d2225ea868aa4a96321eaa4bad93798796e37db5 100644 (file)
@@ -725,6 +725,8 @@ class limited_global_navigation_test extends UnitTestCase {
         }
 
         $node2 = clone($this->mocknode);
+        $fakecontext = new stdClass;
+        $this->cache->coursecontext2 = $fakecontext;
         $node2->initialise(navigation_node::TYPE_CATEGORY, 2);
         $this->assertIsA($node2->get('initcall'), 'navigation_node');
         if ($node2->get('initcall')) {
index c0037a35e281837b81ba8c621ece2afda98061f2..5a5d69e6e4118405f4968131fccb787b1efe387d 100644 (file)
@@ -1,12 +1,12 @@
-<?php // $Id$
+<?php
+
 /**
-* shows an analysed view of feedback
-*
-* @version $Id$
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
+ * shows an analysed view of feedback
+ *
+ * @copyright Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
 
     require_once("../../config.php");
     require_once("lib.php");
@@ -58,9 +58,8 @@
     $strfeedback  = get_string("modulename", "feedback");
     $buttontext = update_module_button($cm->id, $course->id, $strfeedback);
 
-    $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/index.php', array('id'=>$course->id)));
-    $PAGE->navbar->add(format_string($feedback->name));
-
+    $PAGE->navbar->add(get_string('analysis','feedback'));
+    $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/edit.php', array('id'=>$cm->id, 'course'=>$courseid)));
     $PAGE->set_title(format_string($feedback->name));
     $PAGE->set_button($buttontext);
     echo $OUTPUT->header();
             //get the class of item-typ
             $itemclass = 'feedback_item_'.$item->typ;
             //get the instance of the item-class
+            require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
             $itemobj = new $itemclass();
             $itemnr++;
             if($feedback->autonumbering) {
index 1b6ee3680a42e1d8f648306fb26f117e303b5e50..019eca35dec16691146116eea46114c37c07fc07 100644 (file)
     $strfeedbacks = get_string("modulenameplural", "feedback");
     $strfeedback  = get_string("modulename", "feedback");
     $buttontext = update_module_button($cm->id, $course->id, $strfeedback);
-
-    $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/index.php', array('id'=>$course->id)));
-    $PAGE->navbar->add(format_string($feedback->name));
-
+    
+    $PAGE->navbar->add(get_string('feedback:complete', 'feedback'));
+    $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/complete.php', array('id'=>$cm->id, 'gopage'=>$gopage, 'courseid'=>$course->id)));
     $PAGE->set_title(format_string($feedback->name));
     $PAGE->set_button($buttontext);
     echo $OUTPUT->header();
index 29719c2a113f31aef7f12b76f635c2e4dc0c0156..ffe41f70e492e26c8f732f2aac0f2e234b50057d 100644 (file)
     $strfeedback  = get_string("modulename", "feedback");
     $buttontext = update_module_button($cm->id, $course->id, $strfeedback);
 
-    $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/index.php', array('id'=>$course->id)));
-    $PAGE->navbar->add(format_string($feedback->name));
-
+    if ($do_show == 'edit') {
+        $PAGE->navbar->add(get_string('edit_items', 'feedback'));
+    } else {
+        $PAGE->navbar->add(get_string($do_show, 'feedback'));
+    }
+    $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/edit.php', array('id'=>$cm->id, 'do_show'=>$do_show)));
     $PAGE->set_title(format_string($feedback->name));
     $PAGE->set_button($buttontext);
     echo $OUTPUT->header();
index 70a76a33804c8b742858ba8abf159b1e07342799..46359c4247b7d22fa0eb61741cd02d8b76286b0b 100644 (file)
@@ -69,6 +69,8 @@
         }
     }
 
+    require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
+
     ////////////////////////////////////////////////////////////////////////////////////
     ////////////////////////////////////////////////////////////////////////////////////
     if(isset($formdata->cancel)){
index 8b6dfe36ccc58c0214d283c4883ffe10902609c6..6c76344713fd9876e3468fe4d72d2cdbbe8ad8d4 100644 (file)
@@ -4,8 +4,7 @@ require_once $CFG->libdir.'/formslib.php';
 
 define('FEEDBACK_ITEM_NAME_TEXTBOX_SIZE', 80);
 define('FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE', 20);
-class feedback_item_form extends moodleform {
-    
+abstract class feedback_item_form extends moodleform {
     function get_item_form() {
         return $this->_form;
     }
index a5e678b25b97c75633a82af43d146de3b76a16c6..3bd9e5014431d0737f2ffe60de110e3753e324d9 100644 (file)
@@ -30,7 +30,7 @@ class feedback_item_textarea extends feedback_item_base {
         $widthAndHeight = explode('|',$item->presentation);
         $itemwidth = isset($widthAndHeight[0]) ? $widthAndHeight[0] : 30;
         $itemheight = isset($widthAndHeight[1]) ? $widthAndHeight[1] : 5;
-        $item_form->selectwith->setValue($itemwidth);
+        $item_form->selectwidth->setValue($itemwidth);
         $item_form->selectheight->setValue($itemheight);
 
         return $item_form;
index f40acd9b8309e3c06d0f103f5c130fe592028599..bd6124dc06c9ba4757f86b78a76153ecd9db0ced 100644 (file)
@@ -7,7 +7,7 @@ class feedback_textarea_form extends feedback_item_form {
     var $requiredcheck;
     var $itemname;
     var $itemlabel;
-    var $selectwith;
+    var $selectwidth;
     var $selectheight;
     
     function definition() {
@@ -19,7 +19,7 @@ class feedback_textarea_form extends feedback_item_form {
         $this->itemname = $mform->addElement('text', 'itemname', get_string('item_name', 'feedback'), array('size="'.FEEDBACK_ITEM_NAME_TEXTBOX_SIZE.'"','maxlength="255"'));
         $this->itemlabel = $mform->addElement('text', 'itemlabel', get_string('item_label', 'feedback'), array('size="'.FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE.'"','maxlength="255"'));
         
-        $this->selectwith = $mform->addElement('select',
+        $this->selectwidth = $mform->addElement('select',
                                             'itemwidth', 
                                             get_string('textarea_width', 'feedback').'&nbsp;', 
                                             array_slice(range(0,80),5,80,true));
index 1b4b9ab9216add323419c739fce0b8e77a447eef..2f7b286283b01a03ecc3d81dc0248cd0f10619c4 100644 (file)
@@ -997,8 +997,8 @@ function feedback_create_item($data) {
     $item->position = $data->position;
 
     $item->required=0;
-    if (isset($data->required)) {
-               $item->required=$data->required;
+    if (!empty($data->required)) {
+        $item->required = $data->required;
     }
 
     return $DB->insert_record('feedback_item', $item);
@@ -1212,11 +1212,15 @@ function feedback_move_item($moveitem, $pos){
  * @return void
  */
 function feedback_print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+    global $CFG;
     if($item->typ == 'pagebreak') return;
     if($readonly)$ro = 'readonly="readonly" disabled="disabled"';
 
     //get the class of the given item-typ
     $itemclass = 'feedback_item_'.$item->typ;
+    if (!class_exists($itemclass)) {
+        require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
+    }
     //get the instance of the item-class
     $itemobj = new $itemclass();
     $itemobj->print_item($item, $value, $readonly, $edit, $highlightrequire);
@@ -1538,7 +1542,7 @@ function feedback_get_item_value($completedid, $itemid, $tmp = false) {
  * @return boolean
  */
 function feedback_check_values($data, $firstitem, $lastitem) {
-    global $DB;
+    global $DB, $CFG;
 
     //get all items between the first- and lastitem
     $select = "feedback = ?
@@ -1567,6 +1571,11 @@ function feedback_check_values($data, $firstitem, $lastitem) {
 
         //get the class of the item-typ
         $itemclass = 'feedback_item_'.$item->typ;
+
+        if (!class_exists($itemclass)) {
+            require_once($CFG->dirroot.'/mod/feedback/item/'.$item->typ.'/lib.php');
+        }
+
         //get the instance of the item-class
         $itemobj = new $itemclass();
 
@@ -1623,6 +1632,9 @@ function feedback_create_values($data, $usrid, $timemodified, $tmp = false, $gue
             //get the class of item-typ
             $itemclass = 'feedback_item_'.$itemnr[0];
             //get the instance of item-class
+            if (!class_exists($itemclass)) {
+                require_once($CFG->dirroot.'/mod/feedback/item/'.$itemnr[0].'/lib.php');
+            }
             $itemobj = new $itemclass();
             //the kind of values can be absolutely different so we run create_value directly by the item-class
             $value->value = $itemobj->create_value($data[$key]);
@@ -1670,6 +1682,9 @@ function feedback_update_values($data, $completed, $tmp = false) {
             //get the class of item-typ
             $itemclass = 'feedback_item_'.$itemnr[0];
             //get the instace of the item-class
+            if (!class_exists($itemclass)) {
+                require_once($CFG->dirroot.'/mod/feedback/item/'.$itemnr[0].'/lib.php');
+            }
             $itemobj = new $itemclass();
             //the kind of values can be absolutely different so we run create_value directly by the item-class
             $newvalue->value = $itemobj->create_value($data[$key]);
@@ -2312,3 +2327,38 @@ function feedback_encode_target_url($url) {
         return $url;
     }
 }
+
+function feedback_extend_settings_navigation($settings, $module) {
+    global $PAGE, $USER, $OUTPUT, $CFG, $DB;
+
+    $feedback = $DB->get_record('feedback', array('id'=>$PAGE->cm->instance));
+    $feedbacknavkey = $settings->add(get_string('feedbackadministration', 'feedback'));
+    $feedbacknav = $settings->get($feedbacknavkey);
+    $feedbacknav->forceopen = true;
+
+    $capabilities = feedback_load_capabilities($PAGE->cm->id);
+
+    if($capabilities->edititems) {
+        $qkey = $feedbacknav->add(get_string('questions', 'feedback'));
+        $feedbacknav->get($qkey)->add(get_string('edit_items', 'feedback'), new moodle_url($CFG->wwwroot.'/mod/feedback/edit.php', array('id'=>$PAGE->cm->id, 'do_show'=>'edit')));
+        $feedbacknav->get($qkey)->add(get_string('export_questions', 'feedback'), new moodle_url($CFG->wwwroot.'/mod/feedback/export.php', array('id'=>$PAGE->cm->id, 'action'=>'exportfile')));
+        $feedbacknav->get($qkey)->add(get_string('import_questions', 'feedback'), new moodle_url($CFG->wwwroot.'/mod/feedback/import.php', array('id'=>$PAGE->cm->id)));
+        $feedbacknav->get($qkey)->add(get_string('templates', 'feedback'), new moodle_url($CFG->wwwroot.'/mod/feedback/edit.php', array('id'=>$PAGE->cm->id, 'do_show'=>'templates')));
+    }
+
+    if($capabilities->viewreports) {
+        if($feedback->course == SITEID){
+            $feedbacknav->add(get_string('analysis', 'feedback'), new moodle_url($CFG->wwwroot.'/mod/feedback/analysis_course.php', array('id'=>$PAGE->cm->id, 'course'=>$PAGE->course->id,'do_show'=>'analysis')));
+        }else {
+            $feedbacknav->add(get_string('analysis', 'feedback'), new moodle_url($CFG->wwwroot.'/mod/feedback/analysis.php', array('id'=>$PAGE->cm->id, 'course'=>$PAGE->course->id,'do_show'=>'analysis')));
+        }
+    }
+
+    if($capabilities->viewreports) {
+        $feedbacknav->add(get_string('show_entries', 'feedback'), new moodle_url($CFG->wwwroot.'/mod/feedback/show_entries.php', array('id'=>$PAGE->cm->id, 'do_show'=>'showentries')));
+    }
+
+    if (has_capability('moodle/course:manageactivities', $PAGE->cm->context)) {
+        $feedbacknav->add(get_string('updatethis', '', get_string('modulename', 'feedback')), new moodle_url($CFG->wwwroot.'/course/mod.php', array('update' => $PAGE->cm->id, 'return' => true, 'sesskey' => sesskey())));
+    }
+}
\ No newline at end of file
index 1306bf82865684eb79dbae437ea700b74b712e48..96025ca1c5277e23f6e910bcee01223081a17f07 100644 (file)
@@ -42,6 +42,8 @@
         }
     }
 
+    $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/edit.php', array('id'=>$cm->id, 'do_show'=>$do_show)));
+
     $capabilities = feedback_load_capabilities($cm->id);
 
     require_login($course->id, true, $cm);
@@ -68,9 +70,7 @@
     $strfeedback  = get_string("modulename", "feedback");
     $buttontext = update_module_button($cm->id, $course->id, $strfeedback);
 
-    $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/index.php', array('id'=>$course->id)));
-    $PAGE->navbar->add(format_string($feedback->name));
-
+    $PAGE->navbar->add(get_string('show_entries','feedback'));
     $PAGE->set_title(format_string($feedback->name));
     $PAGE->set_button($buttontext);
     echo $OUTPUT->header();
index 7abc102d41bc44ac00824877814901a05b6af86c..d642845d8e330a1dc766653217a2cb8c8f6c0dd7 100644 (file)
     $strfeedbacks = get_string("modulenameplural", "feedback");
     $strfeedback  = get_string("modulename", "feedback");
     $buttontext = update_module_button($cm->id, $course->id, $strfeedback);
-    
-    $PAGE->navbar->add($strfeedbacks, new moodle_url($CFG->wwwroot.'/mod/feedback/index.php', array('id'=>$course->id)));
-    $PAGE->navbar->add(format_string($feedback->name));
 
+    $PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/feedback/view.php', array('id'=>$cm->id, 'do_show'=>'view')));
     $PAGE->set_title(format_string($feedback->name));
     $PAGE->set_button($buttontext);
     echo $OUTPUT->header();