diff --git a/lang/en_utf8/feedback.php b/lang/en_utf8/feedback.php
new file mode 100644
index 00000000000..7e56e7f8132
--- /dev/null
+++ b/lang/en_utf8/feedback.php
@@ -0,0 +1,177 @@
+username has completed feedback activity : \'$a->feedback\'
+
+You can view it here:
+
+$a->url';
+$string['emailteachermailhtml'] = '$a->username has completed feedback activity : \'$a->feedback\'
+You can view it url\">here.';
+$string['entries_saved'] = 'Your answers have been saved. Thank you.';
+$string['export_questions'] = 'Export questions';
+$string['export_to_excel'] = 'Export to Excel';
+$string['feedback:complete'] = 'Complete a feedback';
+$string['feedback:createprivatetemplate'] = 'Create private template';
+$string['feedback:createpublictemplate'] = 'Create public template';
+$string['feedback:deletesubmissions'] = 'Delete completed submissions';
+$string['feedback:deletetemplate'] = 'Delete template';
+$string['feedback:edititems'] = 'Edit items';
+$string['feedback:mapcourse'] = 'Map courses to global feedbacks';
+$string['feedback:view'] = 'View a feedback';
+$string['feedback:viewreports'] = 'View reports';
+$string['feedback_is_not_open'] = 'The feedback is not open';
+$string['feedback_options'] = 'Feedback options';
+$string['feedbackclose'] = 'Close the feedback at';
+$string['feedbackcloses'] = 'Feedback closes';
+$string['feedbackopen'] = 'Open the feedback at';
+$string['feedbackopens'] = 'Feedback opens';
+$string['file'] = 'File';
+$string['filter_by_course'] = 'Filter by course';
+$string['handling_error']='Error occurred in feedback module action handling';
+$string['horizontal']='horizontal';
+$string['insufficient_responses_for_this_group'] = 'There are insufficient responses for this group';$string['import_questions'] = 'Import questions';
+$string['importfromthisfile'] = 'Import from this file';
+$string['import_successfully'] = 'Import successfully';
+$string['item_name'] = 'Question';
+$string['items_are_required'] = 'Answers are required to starred questions.';
+$string['label'] = 'Label';
+$string['line_labels'] = 'Label';
+$string['line_values'] = 'Rating';
+$string['mapcourse'] = 'Map course';
+$string['mapcourses'] = 'Map feedback to courses';
+$string['mapcourseinfo'] = 'This is a sitewide feedback that is available to all courses using the feedback block. You can however limit the courses to which it will appear by mapping them. Search the course and map it to this feedback.';
+$string['mapcoursenone'] = 'No courses mapped. Feedback available to all courses';
+$string['mappedcourses'] = 'Mapped courses';
+$string['max_args_exceeded'] = 'Max 6 arguments can be handled, too many arguments for';
+$string['maximal'] = 'maximal';
+$string['mode'] = 'Mode';
+$string['modulename'] = 'Feedback';
+$string['modulenameplural'] = 'Feedback';
+$string['move_item'] = 'Move this question';
+$string['movedown_item'] = 'Move this question down';
+$string['move_here'] = 'Move here';
+$string['moveup_item'] = 'Move this question up';
+$string['multiple_submit'] = 'Multiple submit';
+$string['name'] = 'Name';
+$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_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';
+$string['non_anonymous_entries'] = 'non anonymous entries';
+$string['not_completed_yet'] = 'Not completed yet';
+$string['not_selected'] = 'Not selected';
+$string['numeric'] = 'Numeric answer';
+$string['numeric_range_from'] = 'Range from';
+$string['numeric_range_to'] = 'Range to';
+$string['of'] = 'of';
+$string['overview'] = 'Overview';
+$string['page'] = 'Page';
+$string['page_after_submit'] = 'Page after submit';
+$string['pagebreak']='Page break';
+$string['parameters_missing']='Parameters missing from';
+$string['picture_file_list'] = 'List of pictures';
+$string['picture_values'] = 'Choose one or more
picture files from the list:';
+$string['picture'] = 'Picture';
+$string['position'] = 'Position';
+$string['preview'] = 'Preview';
+$string['previous_page'] = 'Previous page';
+$string['public'] = 'Public';
+$string['publish_stats_on_students'] = 'Show analysis to students';
+$string['question'] = 'Question';
+$string['questions'] = 'Questions';
+$string['radio'] = 'Multiple choice - single answer';;
+$string['radio_values'] = 'Responses';
+$string['radiobutton'] = 'Multiple choice - single answer allowed (radio buttons)';;
+$string['radiobutton_rated'] = 'Radiobutton (rated)';
+$string['radiorated'] = 'Radiobutton (rated)';
+$string['ready_feedbacks'] = 'Ready feedbacks';
+$string['required'] = 'Required';
+$string['resetting_data'] = 'Reset feedback responses';
+$string['resetting_feedbacks'] = 'Resetting feedbacks';
+$string['response_nr'] = 'Response Nr.';
+$string['responses'] = 'Responses';
+$string['save_as_new_template'] = 'Save as new template';
+$string['save_entries'] = 'Submit your answers';
+$string['save_item'] = 'Save question';
+$string['saving_failed'] = 'Saving failed';
+$string['saving_failed_because_missing_or_false_values'] = 'Saving failed because missing or false values';
+$string['search_course'] = 'Search course';
+$string['selected_dump']='Selected indexes of \$SESSION variable are dumped below:';
+$string['separator_decimal'] = '.';
+$string['separator_thousand'] = ',';
+$string['show_all'] = 'Show all';
+$string['show_entries'] = 'Show responses';
+$string['show_entry'] = 'Show response';
+$string['sort_by_course'] = 'Sort by course';
+$string['start'] = 'Start';
+$string['stop'] = 'End';
+$string['switch_group'] = 'Switch group';
+$string['switch_item_to_not_required'] = 'switch to: answer not required';
+$string['switch_item_to_required'] = 'switch to: answer required';
+$string['template'] = 'Template';
+$string['template_saved'] = 'Template saved';
+$string['templates'] = 'Templates';
+$string['textarea'] = 'Longer text answer';
+$string['textarea_height'] = 'Number of lines';
+$string['textarea_width'] = 'Width';
+$string['textfield'] = 'Short text answer';
+$string['textfield_maxlength'] = 'Maximum characters accepted';
+$string['textfield_size'] = 'Textfield width';
+$string['this_feedback_is_already_submitted'] = 'You\'ve already completed this activity.';
+$string['update_item'] = 'Save changes to question';
+$string['use_one_line_for_each_value'] = '
Use one line for each answer!';
+$string['use_this_template'] = 'Use this template';
+$string['using_templates'] = 'Use a template';
+$string['vertical'] = 'vertical';
+
+?>
diff --git a/mod/feedback/README.txt b/mod/feedback/README.txt
new file mode 100644
index 00000000000..b0df9b53971
--- /dev/null
+++ b/mod/feedback/README.txt
@@ -0,0 +1,211 @@
+Feedback-Module
+===============
+Overview
+--------
+The Feedback-Module is intended to create individual surveys in an easy way.
+
+This module consists of two parts
+a) the "activity" feedback (required)
+b) the "sideblock" feedback (optional)
+
+The activity is the main part an can run without the block. Here you can create, fill out or analyse the surveys.
+The sideblock is an optional part. It works as a bridge between different courses and
+an central placed feedback-activity. So you can create one feedback on the main site of moodle and then publish
+it in many courses.
+
+Requirements
+------------
+Moodle 1.9 or later
+
+Installation
+------------
+ The zip-archive includes the same directory hierarchy as moodle
+ So you only have to copy the files to the correspondent place.
+ copy the folder feedback.zip/mod/feedback --> moodle/mod/feedback
+ and the folder feedback.zip/blocks/feedback --> moodle/blocks/feedback
+ The langfiles normaly can be left into the folder mod/feedback/lang.
+ The only exception is the feedback-block. The langfile is block_feedback.php and
+ have to be copied into the correspondent lang folder of moodle/moodledata.
+ All languages should be encoded with utf8.
+
+After it you have to run the admin-page of moodle (http://your-moodle-site/admin)
+in your browser. You have to loged in as admin before.
+The installation process will be displayed on the screen.
+That's all.
+
+using the block-feature
+-----------------------
+ 1. create one or more new feedback-activitys on the moodle main-site
+ 2. go into some course and enable the feedback-block. This block now shows the feedbacks from the main-site.
+ 3. login as student and go into the course where the feedback-block is enabled
+ 4. fill out the feedback chosen from block
+ 5. login as admin and look at the feedback you created above
+ 6. now you can analyse the answers over the courses
+
+good luck
+
+
+
+
+
+CHANGELOG
+=========
+
+04.04.2008
+- the heading has not supported multilang strings
+
+03.04.2008
+- anonymous feedback was send the userid on email-notification
+ (http://tracker.moodle.org/browse/CONTRIB-355)
+- users can not see the own values if there are chars like single-(') or doublequotas (")
+
+08.03.2008
+- admin users now respect capability-setting
+ (http://tracker.moodle.org/browse/CONTRIB-321)
+
+17.12.2007
+- resolved issue http://tracker.moodle.org/browse/CONTRIB-231
+
+03.12.2007
+- changing the table feedback_template, field public -> ispublic, public is reserved in oracle
+- resolved issue http://tracker.moodle.org/browse/CONTRIB-95
+
+16.09.2007
+- changing access.php, removed the lines with coursecreator, added some RISK_xxx
+- removed the check of legacy roles on has_capability()
+- coursesearch now use unicode characters
+
+13.09.2007
+- updated edit.php to make the output more xhtml 1.0 strict like
+
+11.09.2007
+- Update feedback settings has help showing wrongly
+- Menu on "Add question to activity" should be sorted alphabetically
+- missing "Add Pagebreak" is now at the item-list
+- no hardcoded css
+- use new print_header() (note it only is available on moodle 1.9!!!)
+- missing sesskey checks in feedback
+- uninitialised $filename when importing into feedback
+
+31.07.2007
+- fixed bug with missing numbers after xml Question-Import.
+
+29.07.2007
+- added "require_course_login()" in view.php
+- added missing langstring "no_itemname"
+
+25.07.2007
+- now defined in applicable_formats() to hide the block in moodle My-Site
+
+07.07.2007
+- all functions in lib.php now are with comments in phpdoc-style
+- removed all depricated function-calls
+- some code-styling changes (http://docs.moodle.org/en/Coding)
+
+06.07.2007
+- Adding some missing lang-strings
+- fixing some notice-messages with $SESSION-lstgroupid
+- excelexport now uses the localwincharset from langconfig.php
+ Now it is possible to export excel with utf8. But to many data will crash the excel
+ file. If the excefile crashes so you switch to latin-export in lang-settings
+- adding the default permission CAP_ALLOW to the legacy-role:user for the capabilities view and complete
+
+24.06.2007
+- fixed excel-problem with tempfiles
+- added new field "idnumber" into excel detailed report
+
+21.06.2007
+- better support for xhtml
+
+09.05.2007
+- items now are classes
+- most of forms use formslib
+- gui now uses tabs
+- new item "captcha"
+Now it only runs on Moodle 1.8 or later
+
+09.05.2007
+- added two columns (random_response,anonymous_response) to feedback_complete and feedback_complete_tmp
+- userids now will be logged even if the feedback is anonymous so you now can filter by group
+- excelexport now use pear so cell-values can be greater then 255 chars
+- logs now include the cm->id
+
+16.01.2007
+- the installation now uses the install.xml
+- 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.
+- now you can ex-/import feedbacks into/from a xml-file
+- course-reseting is supported
+
+01.01.2007
+happy new year!
+
+14.09.2006 21:22
+improve the layout of analysis (thanks to Katja Krueger)
+
+02.06.2006 21:22
+several bugfixes
+improve the block "feedback"
+
+20.05.2006 01:00
+adding the block "feedback" to publish feedback over all courses
+Thanks to Jun Yamog!
+
+21.04.2006 16:00
+version 2006042102
+adding moving behavior like moodle activities
+adding a dropdownlist on create/update item page to adjust the position
+
+21.04.2006 16:00
+version 2006042101
+prefixed all function-names like "feedback_"
+fixed security issues (e.g. optional_variable() >> optional_param())
+improve group-feature
+
+03.01.2006 16:00
+Added "addslashes" and "stripslashes_safe" for preserving (')
+
+03.10.2005 13:00
+action handling error recovery improved (failed when debug=false)
+function feedback_action_handler() argument list changed
+added action handler debug modes: silent, normal, verbose
+
+30.09.2005 00:00
+version 2005300900
+action handling functions added
+picture item (an example for action handling added)
+XHTML compliance improved
+number of PHP Notify-level errors reduced
+source code transferred to CVS
+
+14.09.2005 00:20
+fixed problem with restoring
+new feature user-tracking (prevent multiple_submit)
+new feature deleting of some completeds
+
+22.08.2005 19:12
+fixed problem with secureforms-option
+
+16.08.2005 14:07
+fixed html-syntax in edit.php
+
+12.08.2005 21:38
+fixed problem with IE
+If feedback is not anonym now guest is it not allowed to fill it out
+
+11.08.2005 22:00
+added email-notification
+anonymous feedbacks can be filled out by anonymous users
+
+03.08.2005 01:20
+item specific functions were moved into the items-librarys
+now developers can create individual feedback-items
+javascript based filling-control was replaced by php-based control
+
+version = 2005072000
+20.07.2005 01:09
+adding group-ability
+fixed missing bcmod()-Function-Problem
+fixed referer-problem under https
diff --git a/mod/feedback/TODO.txt b/mod/feedback/TODO.txt
new file mode 100644
index 00000000000..5c1347c33cf
--- /dev/null
+++ b/mod/feedback/TODO.txt
@@ -0,0 +1,6 @@
+- items use formslib
+- structured Numbering and switching visible or not
+- printview
+- css
+- the email displays the completed feedback
+-
diff --git a/mod/feedback/analysis.php b/mod/feedback/analysis.php
new file mode 100644
index 00000000000..a48a622c0bd
--- /dev/null
+++ b/mod/feedback/analysis.php
@@ -0,0 +1,161 @@
+feedback->current_tab = 'analysis';
+ $current_tab = 'analysis';
+
+ $id = required_param('id', PARAM_INT); //the POST dominated the GET
+ $courseid = optional_param('courseid', false, PARAM_INT);
+ $lstgroupid = optional_param('lstgroupid', -2, PARAM_INT); //groupid (aus der Listbox gewaehlt)
+
+ //check, whether a group is selected
+ if($lstgroupid == -1) {
+ $SESSION->feedback->lstgroupid = false;
+ }else {
+ if((!isset($SESSION->feedback->lstgroupid)) || $lstgroupid != -2)
+ $SESSION->feedback->lstgroupid = $lstgroupid;
+ }
+
+ if ($id) {
+ if (! $cm = get_coursemodule_from_id('feedback', $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $feedback = get_record("feedback", "id", $cm->instance)) {
+ error("Course module is incorrect");
+ }
+ }
+
+ if(isset($SESSION->feedback->lstgroupid)) {
+ if($tmpgroup = groups_get_group($SESSION->feedback->lstgroupid)) {
+ if($tmpgroup->courseid != $course->id) {
+ $SESSION->feedback->lstgroupid = false;
+ }
+ }else {
+ $SESSION->feedback->lstgroupid = false;
+ }
+ }
+ $capabilities = feedback_load_capabilities($cm->id);
+
+ require_login($course->id);
+
+ if( !( (intval($feedback->publish_stats) == 1) || $capabilities->viewreports)) {
+ error(get_string('error'));
+ }
+
+ /// Print the page header
+ $strfeedbacks = get_string("modulenameplural", "feedback");
+ $strfeedback = get_string("modulename", "feedback");
+ $buttontext = update_module_button($cm->id, $course->id, $strfeedback);
+
+ $navlinks = array();
+ $navlinks[] = array('name' => $strfeedbacks, 'link' => "index.php?id=$course->id", 'type' => 'activity');
+ $navlinks[] = array('name' => format_string($feedback->name), 'link' => "", 'type' => 'activityinstance');
+
+ $navigation = build_navigation($navlinks);
+
+ print_header_simple(format_string($feedback->name), "",
+ $navigation, "", "", true, $buttontext, navmenu($course, $cm));
+
+ /// print the tabs
+ include('tabs.php');
+
+
+ //print analysed items
+ // print_simple_box_start("center", '80%');
+ print_box_start('generalbox boxaligncenter boxwidthwide');
+
+ //get the groupid
+ //lstgroupid is the choosen id
+ $mygroupid = $SESSION->feedback->lstgroupid;
+
+ if( $capabilities->viewreports ) {
+
+ //available group modes (NOGROUPS, SEPARATEGROUPS or VISIBLEGROUPS)
+ $feedbackgroups = get_groups($course->id);
+ //get the effective groupmode of this course and module
+ $groupmode = groupmode($course, $cm);
+ if(is_array($feedbackgroups) && $groupmode > 0){
+ require_once('choose_group_form.php');
+ //the use_template-form
+ $choose_group_form = new feedback_choose_group_form();
+ $choose_group_form->set_feedbackdata(array('groups'=>$feedbackgroups, 'mygroupid'=>$mygroupid));
+ $choose_group_form->set_form_elements();
+ $choose_group_form->set_data(array('id'=>$id, 'lstgroupid'=>$SESSION->feedback->lstgroupid));
+ $choose_group_form->display();
+ }
+
+ //button "export to excel"
+ //echo '
';
+ echo '
';
+ $export_button_link = 'analysis_to_excel.php';
+ $export_button_options = array('sesskey'=>$USER->sesskey, 'id'=>$id);
+ $export_button_label = get_string('export_to_excel', 'feedback');
+ print_single_button($export_button_link, $export_button_options, $export_button_label, 'post');
+ echo ' ';
+ }
+
+ //get the groupid
+ //lstgroupid is the choosen id
+ $mygroupid = false;
+ //get completed feedbacks
+ $completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $coursefilter);
+
+ //show the count
+ echo ''.get_string('completed_feedbacks', 'feedback').': '.$completedscount. ''; + + // get the items of the feedback + $items = get_records_select('feedback_item', 'feedback = '. $feedback->id . ' AND hasvalue = 1', 'position'); + //show the count + if(is_array($items)){ + echo ''.get_string('questions', 'feedback').': ' .sizeof($items). ' '; + echo ''.get_string('show_all', 'feedback').''; + } else { + $items=array(); + } + + echo ''; + print_box_end(); + + print_footer($course); + +?> diff --git a/mod/feedback/analysis_to_excel.php b/mod/feedback/analysis_to_excel.php new file mode 100644 index 00000000000..8bcf9d58aa9 --- /dev/null +++ b/mod/feedback/analysis_to_excel.php @@ -0,0 +1,256 @@ +course)) { + error("Course is misconfigured"); + } + + if (! $feedback = get_record("feedback", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } + $capabilities = feedback_load_capabilities($cm->id); + + require_login($course->id); + + if(!$capabilities->viewreports){ + error(get_string('error')); + } + + //buffering any output + //this prevents some output before the excel-header will be send + ob_start(); + $fstring = new object(); + $fstring->bold = get_string('bold', 'feedback'); + $fstring->page = get_string('page', 'feedback'); + $fstring->of = get_string('of', 'feedback'); + $fstring->modulenameplural = get_string('modulenameplural', 'feedback'); + $fstring->questions = get_string('questions', 'feedback'); + $fstring->question = get_string('question', 'feedback'); + $fstring->responses = get_string('responses', 'feedback'); + $fstring->idnumber = get_string('idnumber'); + $fstring->username = get_string('username'); + $fstring->fullname = get_string('fullname'); + $fstring->courseid = get_string('courseid', 'feedback'); + $fstring->course = get_string('course'); + $fstring->anonymous_user = get_string('anonymous_user','feedback'); + ob_end_clean(); + + $filename = "feedback.xls"; + + //get the groupid for this module + //get the groupid + $mygroupid = $SESSION->feedback->lstgroupid; + + // Creating a workbook + $workbook = new EasyWorkbook("-"); + $workbook->setTempDir('/srv/www/moodledata'); + $workbook->send($filename); + $workbook->setVersion(8); + // Creating the worksheets + $sheetname = clean_param($feedback->name, PARAM_ALPHANUM); + error_reporting(0); + $worksheet1 =& $workbook->addWorksheet(substr($sheetname, 0, 31)); + $worksheet1->set_workbook($workbook); + $worksheet2 =& $workbook->addWorksheet('detailed'); + $worksheet2->set_workbook($workbook); + error_reporting($CFG->debug); + $worksheet1->setPortrait(); + $worksheet1->setPaper(9); + $worksheet1->centerHorizontally(); + $worksheet1->hideGridlines(); + $worksheet1->setHeader("&\"Arial," . $fstring->bold . "\"&14".$feedback->name); + $worksheet1->setFooter($fstring->page." &P " . $fstring->of . " &N"); + $worksheet1->setColumn(0, 0, 30); + $worksheet1->setColumn(1, 20, 15); + $worksheet1->setMargins_LR(0.10); + + $worksheet2->setLandscape(); + $worksheet2->setPaper(9); + $worksheet2->centerHorizontally(); + + //writing the table header + $rowOffset1 = 0; + $worksheet1->setFormat(" '.get_string('feedback_is_not_open', 'feedback').''; + print_continue($CFG->wwwroot.'/course/view.php?id='.$course->id); + // print_simple_box_end(); + print_box_end(); + print_footer($course); + 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; + } + } + if($feedback_can_submit) { + //preserving the items + if($preservevalues == 1){ + if(!$SESSION->feedback->is_started == true)error('error', $CFG->wwwroot.'/course/view.php?id='.$course->id); + //checken, ob alle required items einen wert haben + if(feedback_check_values($_POST, $startitempos, $lastitempos)) { + $userid = $USER->id; //arb + if($completedid = feedback_save_values($_POST, $USER->id, true)){ + if($userid > 0) { + add_to_log($course->id, "feedback", "startcomplete", "view.php?id=$cm->id", "$feedback->name", $cm->id, $userid); + } + if(!$gonextpage AND !$gopreviouspage) $preservevalues = false;//es kann gespeichert werden + + }else { + $savereturn = 'failed'; + if(isset($lastpage)) { + $gopage = $lastpage; + }else { + error('parameter failed'); + } + } + }else { + $savereturn = 'missing'; + $highlightrequired = true; + if(isset($lastpage)) { + $gopage = $lastpage; + }else { + error('parameter failed'); + } + + } + } + + //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 = get_record('feedback_completedtmp', '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)) { + $savereturn = 'saved'; + if($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) { + add_to_log($course->id, "feedback", "submit", "view.php?id=$cm->id", "$feedback->name", $cm->id, $userid); + feedback_email_teachers($cm, $feedback, $course, $userid); + }else { + feedback_email_teachers_anonym($cm, $feedback, $course, $userid); + } + //tracking the submit + $multiple_count = null; + $multiple_count->userid = $USER->id; + $multiple_count->feedback = $feedback->id; + $multiple_count->completed = $new_completed_id; + $multiple_count->count = 1; + insert_record('feedback_tracking', $multiple_count); + unset($SESSION->feedback->is_started); + + }else { + $savereturn = 'failed'; + } + + } + + + if($allbreaks = feedback_get_all_break_positions($feedback->id)){ + if($gopage <= 0) { + $startposition = 0; + }else { + $startposition = $allbreaks[$gopage - 1]; + } + $ispagebreak = true; + }else { + $startposition = 0; + $newpage = 0; + $ispagebreak = false; + } + + //get the feedbackitems after the last shown pagebreak + $feedbackitems = get_records_select('feedback_item', 'feedback = '.$feedback->id.' AND position > '.$startposition, 'position'); + + //get the first pagebreak + if($pagebreaks = get_records_select('feedback_item', "feedback = ".$feedback->id." AND typ = 'pagebreak'", 'position')) { + $pagebreaks = array_values($pagebreaks); + $firstpagebreak = $pagebreaks[0]; + }else { + $firstpagebreak = false; + } + $maxitemcount = count_records('feedback_item', '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); + } + } + }else { + $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid); + } + + /// Print the main part of the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + print_heading(format_text($feedback->name)); + + if(isset($savereturn) && $savereturn == 'saved') { + if($feedback->page_after_submit) { + // print_simple_box_start('center', '75%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + echo format_text(stripslashes_safe($feedback->page_after_submit)); + // print_simple_box_end(); + print_box_end(); + } else { + echo ''.get_string('entries_saved','feedback').' '; + if( intval($feedback->publish_stats) == 1) { + echo ''; + echo get_string('completed_feedbacks', 'feedback').''; + echo ' '; + } + } + if($courseid) { + print_continue($CFG->wwwroot.'/course/view.php?id='.$courseid); + }else { + if($course->id == SITEID) { + print_continue($CFG->wwwroot); + } else { + print_continue($CFG->wwwroot.'/course/view.php?id='.$course->id); + } + } + }else { + if(isset($savereturn) && $savereturn == 'failed') { + echo ''.get_string('saving_failed','feedback').' '; + } + + if(isset($savereturn) && $savereturn == 'missing') { + echo ''.get_string('saving_failed_because_missing_or_false_values','feedback').' '; + } + + //print the items + if(is_array($feedbackitems)){ + // print_simple_box_start('center', '75%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + echo '';
+
+ if($courseid) {
+ echo '';
+ echo ' ';
+ $SESSION->feedback->is_started = true;
+ // print_simple_box_end();
+ print_box_end();
+ }
+ }
+ }else {
+ // print_simple_box_start('center');
+ print_box_start('generalbox boxaligncenter');
+ echo ''.get_string('this_feedback_is_already_submitted', 'feedback').''; + print_continue($CFG->wwwroot.'/course/view.php?id='.$course->id); + // print_simple_box_end(); + print_box_end(); + } + /// Finish the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + print_footer($course); + +?> diff --git a/mod/feedback/complete_guest.php b/mod/feedback/complete_guest.php new file mode 100644 index 00000000000..a69a7ce6bee --- /dev/null +++ b/mod/feedback/complete_guest.php @@ -0,0 +1,379 @@ +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 { + error('parameter (gopage) required'); + } + }else { + $gonextpage = $gopreviouspage = false; + } + + + if ($id) { + if (! $cm = get_coursemodule_from_id('feedback', $id)) { + error("Course Module ID was incorrect"); + } + + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); + } + + if (! $feedback = get_record("feedback", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } + + $capabilities = feedback_load_capabilities($cm->id); + + //check whether the feedback is anonymous + if($feedback->anonymous == FEEDBACK_ANONYMOUS_YES) { + $capabilities->complete = true; + }else { + error(get_string('feedback_is_not_for_anonymous')); + } + + //check whether the user has a session + if(!isset($USER->sesskey) OR !$USER->sesskey) { + error('error'); + } + + //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 = get_record('course', 'id', $courseid); + require_course_login($course2); //this overwrites the object $course :-( + $course = get_record("course", "id", $cm->course); // the workaround + } + + if(!$capabilities->complete) { + error(get_string('error')); + } + + + /// Print the page header + $strfeedbacks = get_string("modulenameplural", "feedback"); + $strfeedback = get_string("modulename", "feedback"); + $buttontext = update_module_button($cm->id, $course->id, $strfeedback); + + $navlinks = array(); + $navlinks[] = array('name' => $strfeedbacks, 'link' => "index.php?id=$course->id", 'type' => 'activity'); + $navlinks[] = array('name' => format_string($feedback->name), 'link' => "", 'type' => 'activityinstance'); + + $navigation = build_navigation($navlinks); + + print_header_simple(format_string($feedback->name), "", + $navigation, "", "", true, $buttontext, navmenu($course, $cm)); + + //ishidden check. hidden feedbacks except feedbacks on mainsite are only accessible with related capabilities + if ((empty($cm->visible) and !$capabilities->viewhiddenactivities) 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)) { + // print_simple_box_start('center'); + print_box_start('generalbox boxaligncenter'); + echo ''.get_string('feedback_is_not_open', 'feedback').''; + print_continue($CFG->wwwroot.'/course/view.php?id='.$course->id); + // print_simple_box_end(); + print_box_end(); + print_footer($course); + 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($multiple_count = get_record('feedback_tracking', '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)error('error', $CFG->wwwroot.'/course/view.php?id='.$course->id); + //check, if all required items have a value + if(feedback_check_values($_POST, $startitempos, $lastitempos)) { + $userid = $USER->id; //arb + if($completedid = feedback_save_guest_values($_POST, $USER->sesskey)){ + add_to_log($course->id, "feedback", "startcomplete", "view.php?id=$cm->id", "$feedback->name"); //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 { + error('parameter failed'); + } + } + }else { + $savereturn = 'missing'; + $highlightrequired = true; + if(isset($lastpage)) { + $gopage = $lastpage; + }else { + error('parameter failed'); + } + } + } + + //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 = get_record('feedback_completedtmp', '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)) { + $savereturn = 'saved'; + feedback_email_teachers_anonym($cm, $feedback, $course, $userid); + unset($SESSION->feedback->is_started); + + }else { + $savereturn = 'failed'; + } + } + + + if($allbreaks = feedback_get_all_break_positions($feedback->id)){ + if($gopage <= 0) { + $startposition = 0; + }else { + $startposition = $allbreaks[$gopage - 1]; + } + $ispagebreak = true; + }else { + $startposition = 0; + $newpage = 0; + $ispagebreak = false; + } + + //get the feedbackitems after the last shown pagebreak + $feedbackitems = get_records_select('feedback_item', 'feedback = '.$feedback->id.' AND position > '.$startposition, 'position'); + //get the first pagebreak + if($pagebreaks = get_records_select('feedback_item', "feedback = ".$feedback->id." AND typ = 'pagebreak'", 'position')) { + $pagebreaks = array_values($pagebreaks); + $firstpagebreak = $pagebreaks[0]; + }else { + $firstpagebreak = false; + } + $maxitemcount = count_records('feedback_item', 'feedback', $feedback->id); + $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid, $USER->sesskey); + + /// Print the main part of the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + print_heading(format_text($feedback->name)); + + if(isset($savereturn) && $savereturn == 'saved') { + if($feedback->page_after_submit) { + // print_simple_box_start('center', '75%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + echo format_text(stripslashes_safe($feedback->page_after_submit)); + // print_simple_box_end(); + print_box_end(); + } else { + echo ''.get_string('entries_saved','feedback').' '; + if( intval($feedback->publish_stats) == 1) { + echo ''; + echo get_string('completed_feedbacks', 'feedback').''; + echo ' '; + } + } + if($courseid) { + if($courseid == SITEID) { + print_continue($CFG->wwwroot); + }else { + print_continue($CFG->wwwroot.'/course/view.php?id='.$courseid); + } + }else { + if($course->id == SITEID) { + print_continue($CFG->wwwroot); + } else { + print_continue($CFG->wwwroot.'/course/view.php?id='.$course->id); + } + } + }else { + if(isset($savereturn) && $savereturn == 'failed') { + echo ''.get_string('saving_failed','feedback').' '; + } + + if(isset($savereturn) && $savereturn == 'missing') { + echo ''.get_string('saving_failed_because_missing_or_false_values','feedback').' '; + } + + //print the items + if(is_array($feedbackitems)){ + // print_simple_box_start('center', '75%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + echo '';
+
+ if($courseid) {
+ echo '';
+ echo ' ';
+ $SESSION->feedback->is_started = true;
+ // print_simple_box_end();
+ print_box_end();
+ }
+ }
+ }else {
+ // print_simple_box_start('center');
+ print_box_start('generalbox boxaligncenter');
+ echo ''.get_string('this_feedback_is_already_submitted', 'feedback').''; + print_continue($CFG->wwwroot.'/course/view.php?id='.$course->id); + // print_simple_box_end(); + print_box_end(); + } + /// Finish the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + print_footer($course); + +?> diff --git a/mod/feedback/db/access.php b/mod/feedback/db/access.php new file mode 100644 index 00000000000..ec726d25a5d --- /dev/null +++ b/mod/feedback/db/access.php @@ -0,0 +1,144 @@ +:';
+ if(!is_array($templates)) {
+ // print_simple_box(get_string('no_templates_available_yet', 'feedback'), "center");
+ print_box(get_string('no_templates_available_yet', 'feedback'), 'generalbox boxaligncenter');
+ }else {
+ echo '
+
diff --git a/mod/feedback/delete_template_form.php b/mod/feedback/delete_template_form.php
new file mode 100644
index 00000000000..f37fe84e56f
--- /dev/null
+++ b/mod/feedback/delete_template_form.php
@@ -0,0 +1,31 @@
+libdir.'/formslib.php';
+
+class mod_feedback_delete_template_form extends moodleform {
+ function definition() {
+ $mform =& $this->_form;
+
+ //headline
+ //$mform->addElement('header', 'general', '');
+
+ // hidden elements
+ $mform->addElement('hidden', 'id');
+ $mform->addElement('hidden', 'deletetempl');
+ $mform->addElement('hidden', 'confirmdelete');
+
+ //-------------------------------------------------------------------------------
+ // buttons
+ $this->add_action_buttons(true, get_string('yes'));
+
+ }
+}
+?>
diff --git a/mod/feedback/easy_excel.php b/mod/feedback/easy_excel.php
new file mode 100644
index 00000000000..17472a4f627
--- /dev/null
+++ b/mod/feedback/easy_excel.php
@@ -0,0 +1,261 @@
+libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
+require_once 'Spreadsheet/Excel/Writer.php';
+
+class EasyWorkbook extends Spreadsheet_Excel_Writer {
+ function &addWorksheet($name = ''){
+ global $CFG;
+
+ $index = count($this->_worksheets);
+ $sheetname = $this->_sheetname;
+
+ if ($name == '') {
+ $name = $sheetname.($index+1);
+ }
+
+ // Check that sheetname is <= 31 chars (Excel limit before BIFF8).
+ if ($this->_BIFF_version != 0x0600)
+ {
+ if (strlen($name) > 31) {
+ return $this->raiseError("Sheetname $name must be <= 31 chars");
+ }
+ }
+
+ // Check that the worksheet name doesn't already exist: a fatal Excel error.
+ $total_worksheets = count($this->_worksheets);
+ for ($i = 0; $i < $total_worksheets; $i++) {
+ if ($this->_worksheets[$i]->getName() == $name) {
+ return $this->raiseError("Worksheet '$name' already exists");
+ }
+ }
+
+ $worksheet =& new EasyWorksheet($this->_BIFF_version,
+ $name, $index,
+ $this->_activesheet, $this->_firstsheet,
+ $this->_str_total, $this->_str_unique,
+ $this->_str_table, $this->_url_format,
+ $this->_parser);
+
+ $this->_worksheets[$index] = &$worksheet; // Store ref for iterator
+ $this->_sheetnames[$index] = $name; // Store EXTERNSHEET names
+ $this->_parser->setExtSheet($name, $index); // Register worksheet name with parser
+
+ if(!isset($CFG->latinexcelexport) || !$CFG->latinexcelexport) {
+ $worksheet->setInputEncoding('UTF-16LE');
+ // $worksheet->setInputEncoding('utf-8');
+ }
+ return $worksheet;
+ }
+}
+
+
+class EasyWorksheet extends Spreadsheet_Excel_Writer_Worksheet {
+ var $m_format;
+ var $m_formatbox = array();
+ var $m_workbook;
+
+ function set_workbook(&$workbook) {
+ $this->m_workbook =& $workbook;
+ }
+
+ function write($row, $col, $token)
+ {
+ parent::write($row, $col, $token, $this->m_format);
+ }
+
+ function write_number($row, $col, $num)
+ {
+ parent::writeNumber($row, $col, $num, $this->m_format);
+ }
+
+ function write_string($row, $col, $str)
+ {
+ parent::writeString($row, $col, feedback_convert_to_win($str), $this->m_format);
+ }
+
+ function write_formula($row, $col, $formula)
+ {
+ parent::writeFormula($row, $col, $formula, $this->m_format);
+ }
+
+ function write_url($row, $col, $url, $string = '')
+ {
+ parent::writeUrl($row, $col, $url, $string, $this->m_format);
+ }
+
+ /**
+ * Setz das aktuelle Format, dass zum Schreiben verwendet wird
+ * Der Formatstring setzt sich aus den folgenden Buchstaben mit folgender Bedeutung zusammen.
+ *
into newline + $newtext = str_ireplace(' ', "\n", $text); + $newtext = str_ireplace(' ', "\n", $newtext); + + return $textlib->convert($newtext, $oldcharset, $newwincharset); +} + +?> diff --git a/mod/feedback/edit.php b/mod/feedback/edit.php new file mode 100644 index 00000000000..6e737a60a6d --- /dev/null +++ b/mod/feedback/edit.php @@ -0,0 +1,419 @@ +feedback->current_tab = $do_show; + $current_tab = $do_show; + + if ($id) { + if (! $cm = get_coursemodule_from_id('feedback', $id)) { + error("Course Module ID was incorrect"); + } + + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); + } + + if (! $feedback = get_record("feedback", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } + $capabilities = feedback_load_capabilities($cm->id); + + require_login($course->id); + + if(!$capabilities->edititems){ + error(get_string('error')); + } + + //move up/down items + if($moveupitem){ + $item = get_record('feedback_item', 'id', $moveupitem); + feedback_moveup_item($item); + } + if($movedownitem){ + $item = get_record('feedback_item', 'id', $movedownitem); + feedback_movedown_item($item); + } + + //moving of items + if($movehere && isset($SESSION->feedback->moving->movingitem)){ + $item = get_record('feedback_item', 'id', intval($SESSION->feedback->moving->movingitem)); + feedback_move_item($item, intval($movehere)); + } + if($moveitem){ + $item = get_record('feedback_item', 'id', $moveitem); + $SESSION->feedback->moving->shouldmoving = 1; + $SESSION->feedback->moving->movingitem = $moveitem; + } else { + unset($SESSION->feedback->moving); + } + + if($switchitemrequired) { + $item = get_record('feedback_item', 'id', $switchitemrequired); + @feedback_switch_item_required($item); + redirect($ME.'?'.feedback_edit_get_default_query($id, $do_show)); + exit; + } + + //the create_template-form + $create_template_form = new feedback_edit_create_template_form(); + $create_template_form->set_feedbackdata(array('capabilities' => $capabilities)); + $create_template_form->set_form_elements(); + $create_template_form->set_data(array('id'=>$id, 'do_show'=>'templates')); + $create_template_formdata = $create_template_form->get_data(); + if(isset($create_template_formdata->savetemplate) && $create_template_formdata->savetemplate == 1) { + //check the capabilities to create templates + if(!$capabilities->createprivatetemplate AND !$capabilities->createpublictemplate) { + error('saving templates is not allowed'); + } + if(trim($create_template_formdata->templatename) == '') + { + $savereturn = 'notsaved_name'; + }else { + if($capabilities->createpublictemplate) { + $create_template_formdata->ispublic = isset($create_template_formdata->ispublic) ? 1 : 0; + }else { + $create_template_formdata->ispublic = 0; + } + if(!feedback_save_as_template($feedback, $create_template_formdata->templatename, $create_template_formdata->ispublic)) + { + $savereturn = 'failed'; + }else { + $savereturn = 'saved'; + } + } + } + + //get the feedbackitems + $lastposition = 0; + $feedbackitems = get_records('feedback_item', 'feedback', $feedback->id, 'position'); + if(is_array($feedbackitems)){ + $feedbackitems = array_values($feedbackitems); + $lastitem = $feedbackitems[count($feedbackitems)-1]; + $lastposition = $lastitem->position; + } + $lastposition++; + + + //the add_item-form + $add_item_form = new feedback_edit_add_question_form('edit_item.php'); + $add_item_form->set_data(array('id'=>$id, 'position'=>$lastposition)); + + //the use_template-form + $use_template_form = new feedback_edit_use_template_form('use_templ.php'); + $use_template_form->set_feedbackdata(array('course' => $course)); + $use_template_form->set_form_elements(); + $use_template_form->set_data(array('id'=>$id)); + + //the create_template-form + //$create_template_form = new feedback_edit_create_template_form('use_templ.php'); + + /// Print the page header + $strfeedbacks = get_string("modulenameplural", "feedback"); + $strfeedback = get_string("modulename", "feedback"); + $buttontext = update_module_button($cm->id, $course->id, $strfeedback); + + $navlinks = array(); + $navlinks[] = array('name' => $strfeedbacks, 'link' => "index.php?id=$course->id", 'type' => 'activity'); + $navlinks[] = array('name' => format_string($feedback->name), 'link' => "", 'type' => 'activityinstance'); + + $navigation = build_navigation($navlinks); + + print_header_simple(format_string($feedback->name), "", + $navigation, "", "", true, $buttontext, navmenu($course, $cm)); + + /// print the tabs + include('tabs.php'); + + /// Print the main part of the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + $savereturn=isset($savereturn)?$savereturn:''; + + //print the messages + if($savereturn == 'notsaved_name') { + echo ' '.get_string('name_required','feedback').' '; + } + + if($savereturn == 'saved') { + echo ''.get_string('template_saved','feedback').' '; + } + + if($savereturn == 'failed') { + echo ''.get_string('saving_failed','feedback').' '; + } + + feedback_print_errors(); + + /////////////////////////////////////////////////////////////////////////// + ///print the template-section + /////////////////////////////////////////////////////////////////////////// + if($do_show == 'templates') { + // print_simple_box_start("center", '80%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + $use_template_form->display(); + + if($capabilities->createprivatetemplate OR $capabilities->createpublictemplate) { + $create_template_form->display(); + echo ''.get_string('delete_templates', 'feedback').' '; + }else { + echo ' '; + } + + if($capabilities->edititems) { + echo '+ '.get_string('export_questions', 'feedback').'/ + '.get_string('import_questions', 'feedback').' + '; + } + // print_simple_box_end(); + print_box_end(); + } + /////////////////////////////////////////////////////////////////////////// + ///print the Item-Edit-section + /////////////////////////////////////////////////////////////////////////// + if($do_show == 'edit') { + + $add_item_form->display(); + + if(is_array($feedbackitems)){ + $itemnr = 0; + + $helpbutton = helpbutton('preview', get_string('preview','feedback'), 'feedback',true,false,'',true); + + print_heading($helpbutton . get_string('preview', 'feedback')); + if(isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) { + print_heading(''.get_string('cancel_moving', 'feedback').''); + } + // print_simple_box_start('center', '80%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + + //check, if there exists required-elements + $countreq = count_records('feedback_item', 'feedback', $feedback->id, 'required', 1); + if($countreq > 0) { + // echo '(*)' . get_string('items_are_required', 'feedback') . ''; + echo '(*)' . get_string('items_are_required', 'feedback') . ''; + } + + echo '
'; + } + // print_simple_box_end(); + print_box_end(); + } + + ?> + + + + '; + print_single_button('edit.php', array('id'=>$id, 'do_show'=>'templates'), get_string('cancel')); + echo ''; + print_footer($course); + + function feedback_load_xml_data($filename) { + global $CFG; + require_once($CFG->dirroot.'/lib/xmlize.php'); + + $datei = file_get_contents($filename); + + if(!$datei = feedback_check_xml_utf8($datei)) return false; + + $data = xmlize($datei, 1, 'UTF-8'); + + if(intval($data['FEEDBACK']['@']['VERSION']) != 200701) { + return false; + } + $data = $data['FEEDBACK']['#']['ITEMS'][0]['#']['ITEM']; + return $data; + } + + function feedback_import_loaded_data(&$data, $feedbackid){ + global $CFG; + + $deleteolditems = optional_param('deleteolditems', 0, PARAM_INT); + + $error = new object(); + $error->stat = true; + $error->msg = array(); + + if(!is_array($data)) { + $error->msg[] = get_string('data_is_not_an_array', 'feedback'); + $error->stat = false; + return $error; + } + + if($deleteolditems) { + feedback_delete_all_items($feedbackid); + $position = 0; + } else { + //items will be add to the end of the existing items + $position = count_records('feedback_item', 'feedback', $feedbackid); + } + + foreach($data as $item) { + $position++; + //check the typ + $typ = $item['@']['TYPE']; + $itemclass = 'feedback_item_'.$typ; + if($typ != 'pagebreak' AND !class_exists($itemclass)) { + $error->stat = false; + $error->msg[] = 'type ('.$typ.') not found'; + continue; + } + $itemobj = new $itemclass(); + + $newitem = new object(); + $newitem->feedback = $feedbackid; + $newitem->template = 0; + $newitem->typ = $typ; + $newitem->name = trim($item['#']['ITEMTEXT'][0]['#']); + $newitem->presentation = trim($item['#']['PRESENTATION'][0]['#']); + if($typ != 'pagebreak') { + $newitem->hasvalue = $itemobj->get_hasvalue(); + }else { + $newitem->hasvalue = 0; + } + $newitem->required = intval($item['@']['REQUIRED']); + $newitem->position = $position; + if(!insert_record('feedback_item', $newitem)) { + $error->stat = false; + $error->msg[] = 'item ('.$newitem->name.') not imported'; + } + } + return $error; + } + + function feedback_check_xml_utf8($text) { + //find the encoding + $searchpattern = '/^\<\?xml.+(encoding=\"([a-z0-9-]*)\").+\?\>/is'; + + if(!preg_match($searchpattern, $text, $match)) return false; //no xml-file + + //$match[0] = \<\? xml ... \?\> (without \) + //$match[1] = encoding="...." + //$match[2] = ISO-8859-1 or so on + if(isset($match[0]) AND !isset($match[1])){ //no encoding given. we assume utf-8 + return $text; + } + + if(isset($match[0]) AND isset($match[1]) AND isset($match[2])) { //encoding is given in $match[2] + $enc = $match[2]; + $textlib = textlib_get_instance(); + return $textlib->convert($text, $enc); + } + } +?> diff --git a/mod/feedback/index.php b/mod/feedback/index.php new file mode 100644 index 00000000000..dbf34e6f93d --- /dev/null +++ b/mod/feedback/index.php @@ -0,0 +1,116 @@ +id); + + require_login($course->id); + + add_to_log($course->id, "feedback", "view all", htmlspecialchars('index.php?id='.$course->id), ""); + + + /// Print the page header + $strfeedbacks = get_string("modulenameplural", "feedback"); + $strfeedback = get_string("modulename", "feedback"); + + $navlinks = array(); + $navlinks[] = array('name' => $strfeedbacks, 'link' => "", 'type' => 'activity'); + + $navigation = build_navigation($navlinks); + + print_header_simple(get_string('modulename', 'feedback').' '.get_string('activities'), "", + $navigation, "", "", true, null, navmenu($course)); + + /// Get all the appropriate data + + if (! $feedbacks = get_all_instances_in_course("feedback", $course)) { + notice("There are no feedbacks", htmlspecialchars('../../course/view.php?id='.$course->id)); + die; + } + + /// Print the list of instances (your module will probably extend this) + + $timenow = time(); + $strname = get_string("name"); + $strweek = get_string("week"); + $strtopic = get_string("topic"); + $strresponses = get_string('responses', 'feedback'); + + if ($course->format == "weeks") { + if($capabilities->viewreports) { + $table->head = array ($strweek, $strname, $strresponses); + $table->align = array ("center", "left", 'center'); + }else{ + $table->head = array ($strweek, $strname); + $table->align = array ("center", "left"); + } + } else if ($course->format == "topics") { + if($capabilities->viewreports) { + $table->head = array ($strtopic, $strname, $strresponses); + $table->align = array ("center", "left", "center"); + }else{ + $table->head = array ($strtopic, $strname); + $table->align = array ("center", "left"); + } + } else { + if($capabilities->viewreports) { + $table->head = array ($strname, $strresponses); + $table->align = array ("left", "center"); + }else{ + $table->head = array ($strname); + $table->align = array ("left"); + } + } + + + foreach ($feedbacks as $feedback) { + //get the responses of each feedback + + if($capabilities->viewreports) { + $completedFeedbackCount = intval(feedback_get_completeds_group_count($feedback)); + } + + if (!$feedback->visible) { + //Show dimmed if the mod is hidden + $link = ''.$feedback->name.''; + } else { + //Show normal if the mod is visible + $link = ''.$feedback->name.''; + } + + if ($course->format == "weeks" or $course->format == "topics") { + $tabledata = array ($feedback->section, $link); + } else { + $tabledata = array ($link); + } + if($capabilities->viewreports) { + $tabledata[] = $completedFeedbackCount; + } + + $table->data[] = $tabledata; + + } + + echo " "; + + print_table($table); + + /// Finish the page + + print_footer($course); + +?> diff --git a/mod/feedback/item/captcha/default.ttf b/mod/feedback/item/captcha/default.ttf new file mode 100644 index 00000000000..754a9b7b393 Binary files /dev/null and b/mod/feedback/item/captcha/default.ttf differ diff --git a/mod/feedback/item/captcha/lib.php b/mod/feedback/item/captcha/lib.php new file mode 100644 index 00000000000..0aec717184a --- /dev/null +++ b/mod/feedback/item/captcha/lib.php @@ -0,0 +1,149 @@ +dirroot.'/mod/feedback/item/feedback_item_class.php'); + +class feedback_item_captcha extends feedback_item_base { + var $type = "captcha"; + function init() { + + } + + function show_edit($item, $usehtmleditor = false) { + + $item->presentation=empty($item->presentation)? 3 : $item->presentation; + + ?> +
valign="top" align="">
+ name) . $requiredmark, true, false, false);?>
+ |
+
+
+
+
+ |
+ required != 1) return true;
+ if($SESSION->feedback->item->captcha->checkchar == $value) {
+ $SESSION->feedback->item->captcha->checked = true;
+ return true;
+ }
+ return false;
+ }
+
+ function create_value($data) {
+ $data = addslashes(clean_text($data));
+ return $data;
+ }
+
+ function get_presentation($data) {
+ return $data->count_of_nums;
+ }
+
+ function get_hasvalue() {
+ return 1;
+ }
+}
+?>
diff --git a/mod/feedback/item/captcha/print_captcha.php b/mod/feedback/item/captcha/print_captcha.php
new file mode 100644
index 00000000000..2723286b880
--- /dev/null
+++ b/mod/feedback/item/captcha/print_captcha.php
@@ -0,0 +1,113 @@
+course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $feedback = get_record("feedback", "id", $cm->instance)) {
+ error("Course module is incorrect");
+ }
+ }
+
+ if(!isset($SESSION->feedback->item->captcha)) {
+ error('not allowed');
+ }
+
+ $height = 40;
+ $charcount = $SESSION->feedback->item->captcha->charcount;
+ $fontfile = $CFG->dirroot.'/mod/feedback/item/captcha/default.ttf';
+
+ $ttfbox = imagettfbbox ( 30, 0, $fontfile, 'H' );//the text to measure
+ $charwidth = $ttfbox[2];
+
+ $width = $charcount * $charwidth;
+
+ $scale = 0.3;
+ $elipsesize = intval((($width + $height)/2) / 5);
+ $factorX = intval($width * $scale);
+ $factorY = intval($height * $scale);
+
+ //I split the colors in three ranges
+ //given are the max-min-values
+ //$colors = array(80, 155, 255);
+ $colors = array(array(0,40),array(50,200),array(210,255));
+ //shuffle($colors);
+ list($col_text1, $col_el, $col_text2) = $colors;
+
+ //if the text is in color_1 so the elipses can be in color_2 or color_3
+ //if the text is in color_2 so the elipses can be in color_1 or color_3
+ //and so on.
+ $textcolnum = rand(1, 3);
+
+ //create the numbers to print out
+ $nums = array();
+ for($i = 0; $i < $charcount; $i++) {
+ $nums[] = rand(0,9); //Ziffern von 0-
+ }
+ // $nums = range(0, 9);
+ // shuffle($nums);
+
+
+ //to draw enough elipses so I draw 0.2 * width and 0.2 * height
+ //we need th colors for that
+ $properties = array();
+ for($x = 0; $x < $factorX; $x++) {
+ for($y = 0; $y < $factorY; $y++) {
+ $propobj = null;
+ $propobj->x = intval($x / $scale);
+ $propobj->y = intval($y / $scale);
+ $propobj->red = get_random_color($col_el[0], $col_el[1]);
+ $propobj->green = get_random_color($col_el[0], $col_el[1]);
+ $propobj->blue = get_random_color($col_el[0], $col_el[1]);
+ $properties[] = $propobj;
+ }
+ }
+ shuffle($properties);
+
+ // create a blank image
+ $image = imagecreatetruecolor($width, $height);
+ $bg = imagecolorallocate($image, 0, 0, 0);
+ for($i = 0; $i < ($factorX * $factorY); $i++) {
+ $propobj = $properties[$i];
+ // choose a color for the ellipse
+ $col_ellipse = imagecolorallocate($image, $propobj->red, $propobj->green, $propobj->blue);
+ // draw the white ellipse
+ imagefilledellipse($image, $propobj->x, $propobj->y, $elipsesize, $elipsesize, $col_ellipse);
+ }
+
+ $checkchar = '';
+ for($i = 0; $i < $charcount; $i++) {
+ $colnum = rand(1,2);
+ $textcol->red = get_random_color(${'col_text'.$colnum}[0], ${'col_text'.$colnum}[1]);
+ $textcol->green = get_random_color(${'col_text'.$colnum}[0], ${'col_text'.$colnum}[1]);
+ $textcol->blue = get_random_color(${'col_text'.$colnum}[0], ${'col_text'.$colnum}[1]);
+ $color_text = imagecolorallocate($image, $textcol->red, $textcol->green, $textcol->blue);
+ $angle_text = rand(-20, 20);
+ $left_text = $i * $charwidth;
+ $text = $nums[$i];
+ $checkchar .= $text;
+ ImageTTFText ($image, 30, $angle_text, $left_text, 35, $color_text, $fontfile, $text);
+ }
+
+ $SESSION->feedback->item->captcha->checkchar = $checkchar;
+
+ // output the picture
+ header("Content-type: image/png");
+ imagepng($image);
+
+ function get_random_color($val1 = 0, $val2 = 255) {
+ $min = $val1 < $val2 ? $val1 : $val2;
+ $max = $val1 > $val2 ? $val1 : $val2;
+
+ return rand($min, $max);
+ }
+
+?>
diff --git a/mod/feedback/item/check/lib.php b/mod/feedback/item/check/lib.php
new file mode 100644
index 00000000000..65b7f789c36
--- /dev/null
+++ b/mod/feedback/item/check/lib.php
@@ -0,0 +1,314 @@
+dirroot.'/mod/feedback/item/feedback_item_class.php');
+
+define('FEEDBACK_CHECK_LINE_SEP', '|');
+define('FEEDBACK_CHECK_ADJUST_SEP', '<<<<<');
+class feedback_item_check extends feedback_item_base {
+ var $type = "check";
+ function init() {
+
+ }
+
+ function show_edit($item, $usehtmleditor = false) {
+
+ $item->presentation = empty($item->presentation) ? '' : $item->presentation;
+
+ //check, whether the buttons are vertical or horizontal
+ $presentation = $horizontal = '';
+ @list($presentation, $horizontal) = explode(FEEDBACK_CHECK_ADJUST_SEP, $item->presentation);
+ if(isset($horizontal) AND $horizontal == 1) {
+ $horizontal = true;
+ }else {
+ $horizontal = false;
+ }
+
+ ?>
+
'. $itemnr . '.) ' . $itemname .' | - ' . trim($val->answertext) . ': | '.format_text(stripslashes_safe($item->name).$requiredmark, true, false, false).' | ';
+ echo '';
+
+ $index = 1;
+ $checked = '';
+ if($readonly){
+ // print_simple_box_start($align);
+ print_box_start('generalbox boxalign'.$align);
+ foreach($presentation as $check){
+ foreach($values as $val) {
+ if($val == $index){
+ echo text_to_html($check . ' |
+ required != 1) return true;
+ if($value[0] == "")return false;
+ return true;
+ }
+
+ function create_value($data) {
+ $vallist = $data;
+ return trim($this->item_arrayToString($vallist));
+ }
+
+ function get_presentation($data) {
+ $present = str_replace("\n", FEEDBACK_CHECK_LINE_SEP, trim($data->itemvalues));
+ if($data->horizontal == 1) {
+ $present .= FEEDBACK_CHECK_ADJUST_SEP.'1';
+ }
+ return $present;
+ }
+
+ function get_hasvalue() {
+ return 1;
+ }
+
+ function item_arrayToString($arr) {
+ if(!is_array($arr)) {
+ return '';
+ }
+ $retval = '';
+ $arrvals = array_values($arr);
+ $arrvals = clean_param($arrvals, PARAM_INT); //prevent sql-injection
+ $retval = $arrvals[0];
+ for($i = 1; $i < sizeof($arrvals) - 1; $i++) {
+ $retval .= FEEDBACK_CHECK_LINE_SEP.$arrvals[$i];
+ }
+ return $retval;
+ }
+}
+?>
diff --git a/mod/feedback/item/dropdown/lib.php b/mod/feedback/item/dropdown/lib.php
new file mode 100644
index 00000000000..c92b6ec8497
--- /dev/null
+++ b/mod/feedback/item/dropdown/lib.php
@@ -0,0 +1,233 @@
+dirroot.'/mod/feedback/item/feedback_item_class.php');
+
+class feedback_item_dropdown extends feedback_item_base {
+ var $type = "dropdown";
+ function init() {
+
+ }
+
+ function show_edit($item, $usehtmleditor = false) {
+
+ $item->presentation=empty($item->presentation)?'':$item->presentation;
+
+ ?>
+ ', true, false, false); + break; + } + } + $index++; + } + // print_simple_box_end(); + print_box_end(); + } else { + if($horizontal) { + echo '
valign="top" align="">name) . $requiredmark, true, false, false);?> |
+
+
+
+
+ |
+ required != 1) return true;
+ if($value == 0)return false;
+ return true;
+ }
+
+ function create_value($data) {
+ $data = clean_param($data, PARAM_INT);
+ return $data;
+ }
+
+ function get_presentation($data) {
+ $present = str_replace("\n", '|', trim($data->itemvalues));
+ return $present;
+ }
+
+ function get_hasvalue() {
+ return 1;
+ }
+}
+?>
diff --git a/mod/feedback/item/dropdownrated/lib.php b/mod/feedback/item/dropdownrated/lib.php
new file mode 100644
index 00000000000..223a6d269a4
--- /dev/null
+++ b/mod/feedback/item/dropdownrated/lib.php
@@ -0,0 +1,303 @@
+dirroot.'/mod/feedback/item/feedback_item_class.php');
+
+define('FEEDBACK_DROPDOWNRATED_MAXCOUNT', 10); //count of possible items
+define('FEEDBACK_DROPDOWN_LINE_SEP', '|');
+define('FEEDBACK_DROPDOWN_VALUE_SEP', '####');
+
+
+class feedback_item_dropdownrated extends feedback_item_base {
+ var $type = "dropdownrated";
+ function init() {
+
+ }
+
+ function show_edit($item, $usehtmleditor = false) {
+
+ $item->presentation=empty($item->presentation)?'':$item->presentation;
+
+ ?>
+
valign="top" align="">name) . $requiredmark, true, false, false);?> |
+
+ typ . '_' . $item->id . '">';
+ echo '';
+ foreach($lines as $line){
+ if($value == $index){
+ $selected = 'selected="selected"';
+ }else{
+ $selected = '';
+ }
+ $dropdown_value = explode(FEEDBACK_DROPDOWN_VALUE_SEP, $line);
+ if($edit) {
+ echo '';
+ }else {
+ echo '';
+ }
+ $index++;
+ }
+ echo '';
+ /*
+ if($item->required == 1) {
+ echo '';
+ }
+ */
+ }
+ ?>
+ |
+ required != 1) return true;
+ if(intval($value) > 0)return true;
+ return false;
+ }
+
+ function create_value($data) {
+ $data = clean_param($data, PARAM_INT);
+ return $data;
+ }
+
+ function get_presentation($data) {
+ $valuelines = $data->fr_val;
+ $labellines = $data->fr_label;
+ $present = '';
+ if(!is_array($valuelines) AND !is_array($labellines)) {
+ return $present;
+ }
+
+ //if( trim($valuelines[0]) != ''){
+ $value = intval($valuelines[0]);
+ $label = $labellines[0];
+ $present .= $value.FEEDBACK_DROPDOWN_VALUE_SEP.$label;
+ //}
+
+ for($i = 1; $i < FEEDBACK_DROPDOWNRATED_MAXCOUNT; $i++) {
+ if( (trim($valuelines[$i]) == '') AND (trim($labellines[$i]) == ''))continue;
+
+ $value = intval($valuelines[$i]);
+ $label = $labellines[$i];
+ $present .= FEEDBACK_DROPDOWN_LINE_SEP.$value.FEEDBACK_DROPDOWN_VALUE_SEP.$label;
+ }
+ //$present = str_replace("\n", '|', trim($data->itemvalues));
+ return $present;
+ }
+
+ function get_hasvalue() {
+ return 1;
+ }
+}
+?>
diff --git a/mod/feedback/item/feedback_item_class.php b/mod/feedback/item/feedback_item_class.php
new file mode 100644
index 00000000000..1047fa7cbbd
--- /dev/null
+++ b/mod/feedback/item/feedback_item_class.php
@@ -0,0 +1,94 @@
+init();
+ }
+
+ /**
+ * Fake constructor to keep PHP5 happy
+ *
+ */
+ function __construct() {
+ $this->feedback_item_base();
+ }
+
+ /**
+ * prints the item-related sequenz on the edit-item form
+ *
+ * @param $item the db-object from feedback_item
+ * @param $usehtmleditor defines whether the editor should be shown or not
+ */
+ function show_edit($item, $usehtmleditor = false) {
+ }
+
+ /**
+ * returns an Array with three values(typ, name, XXX)
+ * XXX is also an Array (count of responses on type $this->type)
+ * each element is a structure (answertext, answercount)
+ * @param $item the db-object from feedback_item
+ * @param $groupid if given
+ * @param $courseid if given
+ * @return array
+ */
+ function get_analysed($item, $groupid = false, $courseid = false) {
+ return array();
+ }
+
+ /**
+ * @param object $item the db-object from feedback_item
+ * @param string $value a item-related value from feedback_values
+ * @return string
+ */
+ function get_printval($item, $value) {
+ return '';
+ }
+
+ /**
+ * @param $item the db-object from feedback_item
+ * @param integer $itemnr
+ * @param integer $groupid
+ * @param integer $courseid
+ * @return integer the new itemnr
+ */
+ function print_analysed($item, $itemnr = 0, $groupid = false, $courseid = false) {
+ return 0;
+ }
+
+ /**
+ * @param object $worksheet a reference to the pear_spreadsheet-object
+ * @param integer $rowOffset
+ * @param object $item the db-object from feedback_item
+ * @param integer $groupid
+ * @param integer $courseid
+ * @return integer the new rowOffset
+ */
+ function excelprint_item(&$worksheet, $rowOffset, $item, $groupid, $courseid = false) {
+ return $rowOffset;
+ }
+
+ function print_item($item, $value = false, $readonly = false, $edit = false, $highlightrequire = false){
+ }
+
+ function check_value($value, $item) {
+ return true;
+ }
+
+ function create_value($data) {
+ return '';
+ }
+
+ function get_presentation($data) {
+ return '';
+ }
+
+ function get_hasvalue() {
+ return 0;
+ }
+}
+?>
diff --git a/mod/feedback/item/label/lib.php b/mod/feedback/item/label/lib.php
new file mode 100644
index 00000000000..7a9d76b8b83
--- /dev/null
+++ b/mod/feedback/item/label/lib.php
@@ -0,0 +1,44 @@
+dirroot.'/mod/feedback/item/feedback_item_class.php');
+
+class feedback_item_label extends feedback_item_base {
+ var $type = "label";
+ function init() {
+
+ }
+
+ function show_edit($item, $usehtmleditor = false) {
+ $item->presentation=isset($item->presentation)?$item->presentation:'';
+ print_string('label', 'feedback');
+ echo ''; + print_textarea($usehtmleditor, 20, 0, 0, 0, "presentation", $item->presentation); + echo ''; + + if ($usehtmleditor) { + use_html_editor(); + } + } + function print_item($item){ + ?> +
+ presentation);?>
+ |
+ presentation);
+ }
+
+ function get_hasvalue() {
+ return 0;
+ }
+}
+?>
\ No newline at end of file
diff --git a/mod/feedback/item/numeric/lib.php b/mod/feedback/item/numeric/lib.php
new file mode 100644
index 00000000000..6e65f6d91f2
--- /dev/null
+++ b/mod/feedback/item/numeric/lib.php
@@ -0,0 +1,238 @@
+dirroot.'/mod/feedback/item/feedback_item_class.php');
+
+class feedback_item_numeric extends feedback_item_base {
+ var $type = "numeric";
+ function init() {
+
+ }
+
+ function show_edit($item, $usehtmleditor = false) {
+
+ $item->presentation=empty($item->presentation)?'':$item->presentation;
+
+ ?>
+
'.get_string('average', 'feedback').': '.$avg.' | valign="top" align="">
+ name) . $requiredmark, true, false, false);
+ switch(true) {
+ case ($range_from === 0 AND $range_to > 0):
+ echo ' ('.get_string('maximal', 'feedback').': '.$range_to.')';
+ break;
+ case ($range_from > 0 AND $range_to === 0):
+ echo ' ('.get_string('minimal', 'feedback').': '.$range_from.')';
+ break;
+ case ($range_from === 0 AND $range_to === 0):
+ break;
+ default:
+ echo ' ('.$range_from.'-'.$range_to.')';
+ break;
+ }
+ ?>
+ |
+
+
+
+
+ |
+ required != 1) return true;
+ if(!is_numeric($value))return false;
+
+ $range_from_to = explode('|',$item->presentation);
+ $range_from = isset($range_from_to[0]) ? intval($range_from_to[0]) : 0;
+ $range_to = isset($range_from_to[1]) ? intval($range_from_to[1]) : 0;
+
+ switch(true) {
+ case ($range_from === 0 AND $range_to > 0):
+ if(intval($value) <= $range_to) return true;
+ break;
+ case ($range_from > 0 AND $range_to === 0):
+ if(intval($value) >= $range_from) return true;
+ break;
+ case ($range_from === 0 AND $range_to === 0):
+ return true;
+ break;
+ default:
+ if(intval($value) >= $range_from AND intval($value) <= $range_to) return true;
+ break;
+ }
+
+ return false;
+ }
+
+ function create_value($data) {
+ if($data AND $data != '') {
+ $data = intval($data);
+ }else {
+ $data = '';
+ }
+ return $data;
+ }
+
+ function get_presentation($data) {
+ return $data->numericrangefrom . '|'. $data->numericrangeto;
+ }
+
+ function get_hasvalue() {
+ return 1;
+ }
+}
+?>
diff --git a/mod/feedback/item/radio/lib.php b/mod/feedback/item/radio/lib.php
new file mode 100644
index 00000000000..0cb2fc95a3c
--- /dev/null
+++ b/mod/feedback/item/radio/lib.php
@@ -0,0 +1,307 @@
+dirroot.'/mod/feedback/item/feedback_item_class.php');
+
+define('FEEDBACK_RADIO_LINE_SEP', '|');
+define('FEEDBACK_RADIO_ADJUST_SEP', '<<<<<');
+
+class feedback_item_radio extends feedback_item_base {
+ var $type = "radio";
+ function init() {
+
+ }
+
+ function show_edit($item, $usehtmleditor = false) {
+
+ $item->presentation = empty($item->presentation) ? '' : $item->presentation;
+
+ //check, whether the buttons are vertical or horizontal
+ $presentation = $horizontal = '';
+ @list($presentation, $horizontal) = explode(FEEDBACK_RADIO_ADJUST_SEP, $item->presentation);
+ if(isset($horizontal) AND $horizontal == 1) {
+ $horizontal = true;
+ }else {
+ $horizontal = false;
+ }
+
+ ?>
+
valign="top" align="">name) . $requiredmark, true, false, false);?> |
+
+
+ |
/>
+ |
+
+
+ |
+
+
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| + (required=isset($item->required)?$item->required:0; + echo ($item->required == 1?'checked="checked"':''); + ?> /> ) + | +|||||
|---|---|---|---|---|---|
| + : + /> + /> + | +|||||
| + | + | ||||
| + + | +
+ presentation));
+ if($itemvalues = explode(FEEDBACK_RADIORATED_LINE_SEP, stripslashes_safe($presentation), FEEDBACK_RADIORATED_MAXCOUNT)){
+ echo '
|
+ ||||
| '. $itemnr . '.) ' . $analysedItem[1] .' | |
|---|---|
| - ' . trim($val->answertext) . ' ('.$val->value.'): | |
| '.get_string('average', 'feedback').': '.$avg.' | |
| /> + | ++ + | +
| /> + | + |
| + (required=isset($item->required)?$item->required:0; + echo ($item->required == 1?'checked="checked"':''); + ?> /> ) + | +|
|---|---|
| + | + |
| + | + + | +
| + | + + | +
| '. $itemnr . '.) ' . stripslashes_safe($item->name) .' | |
|---|---|
| - | ' . str_replace("\n", ' ', $value->value) . ' |
| + (required=isset($item->required)?$item->required:0; + echo ($item->required == 1?'checked="checked"':''); + ?> /> ) + | +|
|---|---|
| + | + |
| + | + + | +
| + | + + | +
| '. $itemnr . '.) ' . stripslashes_safe($item->name) .' | |
|---|---|
| - ' . str_replace("\n", ' ', $value->value) . ' |
';
+ echo get_string('name','feedback').': '.$feedback->name.'
';
+ print_checkbox(FEEDBACK_RESETFORM_RESET.$feedback->id, 1, true, get_string('resetting_data','feedback'), '', ''); echo '
';
+ print_checkbox(FEEDBACK_RESETFORM_DROP.$feedback->id, 1, false, get_string('drop_feedback','feedback'), '', '');
+ echo '
'. + ''.$course->shortname.' ->'. + ''.get_string('modulenameplural', 'feedback').' ->'. + ''.$info->feedback.'
'; + $posthtml .= ''.get_string('emailteachermailhtml', 'feedback', $info).'
'; + $posthtml .= '';
+ print_r($SESSION->feedback->errors) . "\n";
+ echo '
('.$cmap->shortname.') '.$cmap->fullname));
+ }
+
+ $table->print_html();
+ } else {
+ echo '| ' . $itemnr . '.) | '; + } else { + echo ''; + } + if($feedbackitem->typ != 'pagebreak') { + feedback_print_item($feedbackitem, false, false, true); + }else { + echo ' | '; + } + echo ' | |
| ';
+ if (!$students) {
+ if($courseid != SITEID){
+ notify(get_string('noexistingstudents'));
+ }
+ } else{
+ echo print_string('non_anonymous_entries', 'feedback');
+ echo ' ('.count_records_select('feedback_completed', 'feedback = ' . $feedback->id.' AND anonymous_response='.FEEDBACK_ANONYMOUS_NO).') '; + + foreach ($students as $student){ + $completedCount = count_records_select('feedback_completed', 'userid = ' . $student->id . ' AND feedback = ' . $feedback->id.' AND anonymous_response='.FEEDBACK_ANONYMOUS_NO); + if($completedCount > 0) { + // Are we assuming that there is only one response per user? Should westep through a feedbackcompleteds? I added the addition anonymous check to the select so that only non-anonymous submissions are retrieved. + $feedbackcompleted = get_record_select('feedback_completed','feedback='.$feedback->id.' AND userid='.$student->id.' AND anonymous_response='.FEEDBACK_ANONYMOUS_NO); + ?> +
+
| |||||||
'.UserDate($feedbackcompleted->timemodified).'
('.fullname($usr).')
'.get_string('not_completed_yet','feedback').'
'; + } + // print_simple_box_start("center", '50%'); + print_box_start('generalbox boxaligncenter boxwidthnormal'); + echo ''; + // print_simple_box_end(); + print_box_end(); + } + print_continue(htmlspecialchars('show_entries.php?id='.$id.'&do_show=showentries')); + } + /// Finish the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + print_footer($course); + +?> diff --git a/mod/feedback/show_entries_anonym.php b/mod/feedback/show_entries_anonym.php new file mode 100644 index 00000000000..c776de40b13 --- /dev/null +++ b/mod/feedback/show_entries_anonym.php @@ -0,0 +1,181 @@ +feedback->current_tab = 'showoneentry'; + $current_tab = 'showentries'; + + $id = required_param('id', PARAM_INT); + $userid = optional_param('userid', false, PARAM_INT); + + if(($formdata = data_submitted('nomatch')) AND !confirm_sesskey()) { + error('no sesskey defined'); + } + + if ($id) { + if (! $cm = get_coursemodule_from_id('feedback', $id)) { + error("Course Module ID was incorrect"); + } + + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); + } + + if (! $feedback = get_record("feedback", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } + $capabilities = feedback_load_capabilities($cm->id); + + require_login($course->id); + + if(!$capabilities->viewreports){ + error(get_string('error')); + } + + + //get the completeds + // if a new anonymous record has not been assigned a random response number + if ($feedbackcompleteds = get_records_select('feedback_completed','feedback='.$feedback->id.' AND random_response=0 AND anonymous_response='.FEEDBACK_ANONYMOUS_YES, 'random_response')){ //arb + //then get all of the anonymous records and go through them + $feedbackcompleteds = get_records_select('feedback_completed','feedback='.$feedback->id.' AND anonymous_response='.FEEDBACK_ANONYMOUS_YES,'id'); //arb + shuffle($feedbackcompleteds); + $num = 1; + foreach($feedbackcompleteds as $compl){ + $compl->random_response = $num; + update_record('feedback_completed', $compl); + $num++; + } + } + $feedbackcompleteds = get_records_select('feedback_completed','feedback='.$feedback->id.' AND anonymous_response='.FEEDBACK_ANONYMOUS_YES, 'random_response'); //arb + + /// Print the page header + $strfeedbacks = get_string("modulenameplural", "feedback"); + $strfeedback = get_string("modulename", "feedback"); + $buttontext = update_module_button($cm->id, $course->id, $strfeedback); + + $navlinks = array(); + $navlinks[] = array('name' => $strfeedbacks, 'link' => "index.php?id=$course->id", 'type' => 'activity'); + $navlinks[] = array('name' => format_string($feedback->name), 'link' => "", 'type' => 'activityinstance'); + + $navigation = build_navigation($navlinks); + + print_header_simple(format_string($feedback->name), "", + $navigation, "", "", true, $buttontext, navmenu($course, $cm)); + + /// Print the main part of the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + include('tabs.php'); + + print_heading(format_text($feedback->name)); + + print_continue(htmlspecialchars('show_entries.php?id='.$id.'&do_show=showentries')); + //print the list with anonymous completeds + // print_simple_box_start("center"); + print_box_start('generalbox boxaligncenter boxwidthwide'); +?> + + +'.get_string('chosen_feedback_response', 'feedback').'
('.get_string('anonymous', 'feedback').')
'.get_string('not_completed_yet','feedback').'
'; + } + // print_simple_box_start("center", '50%'); + print_box_start('generalbox boxaligncenter boxwidthnormal'); + echo ''; + // print_simple_box_end(); + print_box_end(); + } + } + /// Finish the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + + print_footer($course); + +?> diff --git a/mod/feedback/styles.php b/mod/feedback/styles.php new file mode 100644 index 00000000000..2cfc1968d8b --- /dev/null +++ b/mod/feedback/styles.php @@ -0,0 +1,9 @@ +/* styles using by feedback */ +.feedback_required_mark { + color: #FF0000; +} + +.feedback_switchrequired img{ +} + + diff --git a/mod/feedback/tabs.php b/mod/feedback/tabs.php new file mode 100644 index 00000000000..f8952a61792 --- /dev/null +++ b/mod/feedback/tabs.php @@ -0,0 +1,47 @@ +feedback->current_tab; + if (!isset($current_tab)) { + $current_tab = ''; + } + + $row[] = new tabobject('view', $CFG->wwwroot.htmlspecialchars('/mod/feedback/view.php?id='.$id.'&do_show=view'), get_string('overview', 'feedback')); + + if($capabilities->edititems) { + $row[] = new tabobject('edit', $CFG->wwwroot.htmlspecialchars('/mod/feedback/edit.php?id='.$id.'&do_show=edit'), get_string('edit_items', 'feedback')); + $row[] = new tabobject('templates', $CFG->wwwroot.htmlspecialchars('/mod/feedback/edit.php?id='.$id.'&do_show=templates'), get_string('templates', 'feedback')); + } + + if($capabilities->viewreports) { + if($feedback->course == SITEID){ + $row[] = new tabobject('analysis', $CFG->wwwroot.htmlspecialchars('/mod/feedback/analysis_course.php?id='.$id.'&courseid='.$courseid.'&do_show=analysis'), get_string('analysis', 'feedback')); + }else { + $row[] = new tabobject('analysis', $CFG->wwwroot.htmlspecialchars('/mod/feedback/analysis.php?id='.$id.'&courseid='.$courseid.'&do_show=analysis'), get_string('analysis', 'feedback')); + } + } + + if($capabilities->viewreports) { + $row[] = new tabobject('showentries', $CFG->wwwroot.htmlspecialchars('/mod/feedback/show_entries.php?id='.$id.'&do_show=showentries'), get_string('show_entries', 'feedback')); + } + + if(count($row) > 1) { + $tabs[] = $row; + + print_tabs($tabs, $current_tab, $inactive, $activated); + } +?> diff --git a/mod/feedback/unmapcourse.php b/mod/feedback/unmapcourse.php new file mode 100644 index 00000000000..2b73bfc2aa5 --- /dev/null +++ b/mod/feedback/unmapcourse.php @@ -0,0 +1,46 @@ +dirroot.'/mod/feedback/lib.php'); + + $id = required_param('id', PARAM_INT); + $cmapid = required_param('cmapid', PARAM_INT); + + if ($id) { + if (! $cm = get_coursemodule_from_id('feedback', $id)) { + error("Course Module ID was incorrect"); + } + + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); + } + + if (! $feedback = get_record("feedback", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } + $capabilities = feedback_load_capabilities($cm->id); + + if (!$capabilities->mapcourse) { + error ('access not allowed'); + } + + + // cleanup all lost entries after deleting courses or feedbacks + feedback_clean_up_sitecourse_map(); + + if (delete_records('feedback_sitecourse_map', 'id', $cmapid)) { + redirect (htmlspecialchars('mapcourse.php?id='.$id)); + } else { + error('Database problem, unable to unmap'); + } + +?> \ No newline at end of file diff --git a/mod/feedback/use_templ.php b/mod/feedback/use_templ.php new file mode 100644 index 00000000000..5bcda2bdc85 --- /dev/null +++ b/mod/feedback/use_templ.php @@ -0,0 +1,128 @@ +course)) { + error("Course is misconfigured"); + } + + if (! $feedback = get_record("feedback", "id", $cm->instance)) { + error("Course module is incorrect"); + } + } + $capabilities = feedback_load_capabilities($cm->id); + + require_login($course->id); + + if(!$capabilities->edititems){ + error(get_string('error')); + } + + $mform = new mod_feedback_use_templ_form(); + $newformdata = array('id'=>$id, + 'templateid'=>$templateid, + 'confirmadd'=>'1', + 'deleteolditems'=>'1', + 'do_show'=>'edit'); + $mform->set_data($newformdata); + $formdata = $mform->get_data(); + + if ($mform->is_cancelled()) { + redirect('edit.php?id='.$id.'&do_show=templates'); + } + + if(isset($formdata->confirmadd) AND $formdata->confirmadd == 1){ + feedback_items_from_template($feedback, $templateid, $deleteolditems); + redirect('edit.php?id=' . $id); + } + + /// Print the page header + $strfeedbacks = get_string("modulenameplural", "feedback"); + $strfeedback = get_string("modulename", "feedback"); + $buttontext = update_module_button($cm->id, $course->id, $strfeedback); + + $navlinks = array(); + $navlinks[] = array('name' => $strfeedbacks, 'link' => "index.php?id=$course->id", 'type' => 'activity'); + $navlinks[] = array('name' => format_string($feedback->name), 'link' => "", 'type' => 'activityinstance'); + + $navigation = build_navigation($navlinks); + + print_header_simple(format_string($feedback->name), "", + $navigation, "", "", true, $buttontext, navmenu($course, $cm)); + + /// Print the main part of the page + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////////// + print_heading(format_text($feedback->name)); + + // print_simple_box_start("center", "60%", "#FFAAAA", 20, "noticebox"); + print_box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal'); + print_heading(get_string('confirmusetemplate', 'feedback')); + + $mform->display(); + + // print_simple_box_end(); + print_box_end(); + + $templateitems = get_records('feedback_item', 'template', $templateid, 'position'); + if(is_array($templateitems)){ + $templateitems = array_values($templateitems); + } + + if(is_array($templateitems)){ + $itemnr = 0; + echo ''.get_string('preview', 'feedback').'
'; + // print_simple_box_start('center', '75%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + echo '| ' . $itemnr . '.) | '; + } else { + echo ''; + } + if($templateitem->typ != 'pagebreak') { + feedback_print_item($templateitem); + }else { + echo ' | '.get_string('pagebreak', 'feedback').' | '; + } + echo '|
'; + + //####### mapcourse-start + if($capabilities->mapcourse) { + if($feedback->course == SITEID) { + // print_simple_box_start('center', '80%'); + print_box_start('generalbox boxaligncenter boxwidthwide'); + echo '