mod-feedback MDL-20254 Upgrade feedback module to make use of new navigation blocks

At the same time I also took the oppertunity to fix up the bugs within the feedback module that were making it un-usable
This commit is contained in:
samhemelryk 2009-09-11 02:04:38 +00:00
parent 5f4d4d801c
commit ab5bd34d18
12 changed files with 88 additions and 33 deletions

View 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';

View 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')) {

View 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();
@ -127,6 +126,7 @@
//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) {

View File

@ -122,10 +122,9 @@
$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();

View File

@ -144,9 +144,12 @@
$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();

View File

@ -69,6 +69,8 @@
}
}
require_once($CFG->dirroot.'/mod/feedback/item/'.$typ.'/lib.php');
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
if(isset($formdata->cancel)){

View 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;
}

View 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;

View 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));

View 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())));
}
}

View 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();

View File

@ -80,10 +80,8 @@
$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();