Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-29804 - Clean up Feedback modules coding style

  • Loading branch information...
commit 9c5bc7a58037799817495ab4f1dc558da548b3ce 1 parent 38e9a1c
@grabs grabs authored
Showing with 5,876 additions and 4,088 deletions.
  1. +2 −1  mod/feedback/README.txt
  2. +46 −29 mod/feedback/analysis.php
  3. +74 −33 mod/feedback/analysis_course.php
  4. +126 −130 mod/feedback/analysis_to_excel.php
  5. +0 −1  mod/feedback/backup/moodle1/lib.php
  6. +1 −2  mod/feedback/backup/moodle2/backup_feedback_activity_task.class.php
  7. +0 −1  mod/feedback/backup/moodle2/backup_feedback_settingslib.php
  8. +0 −3  mod/feedback/backup/moodle2/backup_feedback_stepslib.php
  9. +0 −1  mod/feedback/backup/moodle2/restore_feedback_activity_task.class.php
  10. +0 −1  mod/feedback/backup/moodle2/restore_feedback_stepslib.php
  11. +23 −66 mod/feedback/choose_group_form.php
  12. +525 −433 mod/feedback/complete.php
  13. +487 −408 mod/feedback/complete_guest.php
  14. +15 −0 mod/feedback/db/access.php
  15. +15 −1 mod/feedback/db/install.php
  16. +1 −1  mod/feedback/db/install.xml
  17. +0 −1  mod/feedback/db/log.php
  18. +0 −1  mod/feedback/db/messages.php
  19. +96 −40 mod/feedback/db/upgrade.php
  20. +105 −86 mod/feedback/delete_completed.php
  21. +26 −13 mod/feedback/delete_completed_form.php
  22. +89 −74 mod/feedback/delete_item.php
  23. +26 −13 mod/feedback/delete_item_form.php
  24. +40 −28 mod/feedback/delete_template.php
  25. +26 −14 mod/feedback/delete_template_form.php
  26. +225 −182 mod/feedback/edit.php
  27. +79 −49 mod/feedback/edit_form.php
  28. +26 −15 mod/feedback/edit_item.php
  29. +162 −148 mod/feedback/export.php
  30. +240 −237 mod/feedback/import.php
  31. +36 −14 mod/feedback/import_form.php
  32. +24 −9 mod/feedback/index.php
  33. +19 −5 mod/feedback/item/captcha/captcha_form.php
  34. +98 −52 mod/feedback/item/captcha/lib.php
  35. +26 −20 mod/feedback/item/captcha/print_captcha.php
  36. +101 −55 mod/feedback/item/feedback_item_class.php
  37. +41 −21 mod/feedback/item/feedback_item_form_class.php
  38. +22 −5 mod/feedback/item/info/info_form.php
  39. +150 −85 mod/feedback/item/info/lib.php
  40. +21 −8 mod/feedback/item/label/label_form.php
  41. +98 −64 mod/feedback/item/label/lib.php
  42. +321 −209 mod/feedback/item/multichoice/lib.php
  43. +47 −23 mod/feedback/item/multichoice/multichoice_form.php
  44. +248 −159 mod/feedback/item/multichoicerated/lib.php
  45. +52 −22 mod/feedback/item/multichoicerated/multichoicerated_form.php
  46. +292 −178 mod/feedback/item/numeric/lib.php
  47. +29 −16 mod/feedback/item/numeric/numeric_form.php
  48. +150 −97 mod/feedback/item/textarea/lib.php
  49. +22 −8 mod/feedback/item/textarea/textarea_form.php
  50. +143 −97 mod/feedback/item/textfield/lib.php
  51. +22 −8 mod/feedback/item/textfield/textfield_form.php
  52. +5 −6 mod/feedback/lang/en/feedback.php
  53. +516 −331 mod/feedback/lib.php
  54. +29 −9 mod/feedback/mapcourse.php
  55. +105 −38 mod/feedback/mod_form.php
  56. +42 −23 mod/feedback/print.php
  57. +18 −3 mod/feedback/settings.php
  58. +109 −52 mod/feedback/show_entries.php
  59. +67 −42 mod/feedback/show_entries_anonym.php
  60. +280 −261 mod/feedback/show_nonrespondents.php
  61. +1 −1  mod/feedback/styles.css
  62. +82 −55 mod/feedback/tabs.php
  63. +14 −0 mod/feedback/unmapcourse.php
  64. +38 −23 mod/feedback/use_templ.php
  65. +23 −8 mod/feedback/use_templ_form.php
  66. +26 −12 mod/feedback/version.php
  67. +104 −57 mod/feedback/view.php
View
3  mod/feedback/README.txt
@@ -135,7 +135,8 @@ Now it only runs on Moodle 1.8 or later
- roles are full implemented
- now radiobuttons and checkboxes can be aligned horizontally or vertically
- now you can insert pagebreakes
-- a feedback what is switch to the next page is saved temporary. the user can cancel the completion and later continue at the last filled page.
+- a feedback what is switch to the next page is saved temporary.
+ the user can cancel the completion and later continue at the last filled page.
- now you can ex-/import feedbacks into/from a xml-file
- course-reseting is supported
View
75 mod/feedback/analysis.php
@@ -1,4 +1,18 @@
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* shows an analysed view of feedback
@@ -11,7 +25,6 @@
require_once("../../config.php");
require_once("lib.php");
-// $SESSION->feedback->current_tab = 'analysis';
$current_tab = 'analysis';
$id = required_param('id', PARAM_INT); //the POST dominated the GET
@@ -39,23 +52,23 @@
print_error('badcontext');
}
-if($course->id == SITEID) {
+if ($course->id == SITEID) {
require_login($course->id, true);
-}else{
+} else {
require_login($course->id, true, $cm);
}
//check whether the given courseid exists
-if($courseid AND $courseid != SITEID) {
- if($course2 = $DB->get_record('course', array('id'=>$courseid))){
+if ($courseid AND $courseid != SITEID) {
+ if ($course2 = $DB->get_record('course', array('id'=>$courseid))) {
require_course_login($course2); //this overwrites the object $course :-(
$course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
- }else {
+ } else {
print_error('invalidcourseid');
}
}
-if( !( ((intval($feedback->publish_stats) == 1) AND
+if ( !( ((intval($feedback->publish_stats) == 1) AND
has_capability('mod/feedback:viewanalysepage', $context)) OR
has_capability('mod/feedback:viewreports', $context))) {
print_error('error');
@@ -65,30 +78,29 @@
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
-$PAGE->navbar->add(get_string('analysis','feedback'));
+$PAGE->navbar->add(get_string('analysis', 'feedback'));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_title(format_string($feedback->name));
echo $OUTPUT->header();
/// print the tabs
-include('tabs.php');
+require('tabs.php');
//print analysed items
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
//get the groupid
-$groupselect = groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/feedback/analysis.php?id=' . $cm->id.'&do_show=analysis', true);
+$myurl = $CFG->wwwroot.'/mod/feedback/analysis.php?id='.$cm->id.'&do_show=analysis';
+$groupselect = groups_print_activity_menu($cm, $myurl, true);
$mygroupid = groups_get_activity_group($cm);
-if( has_capability('mod/feedback:viewreports', $context) ) {
+if ( has_capability('mod/feedback:viewreports', $context) ) {
echo isset($groupselect) ? $groupselect : '';
echo '<div class="clearer"></div>';
//button "export to excel"
- //echo '<div class="mdl-align">';
- // echo '<div class="feedback_centered_button">';
echo $OUTPUT->container_start('form-buttons');
$aurl = new moodle_url('analysis_to_excel.php', array('sesskey'=>sesskey(), 'id'=>$id));
echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback'));
@@ -99,50 +111,55 @@
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid);
//show the group, if available
-if($mygroupid and $group = $DB->get_record('groups', array('id'=>$mygroupid))) {
+if ($mygroupid and $group = $DB->get_record('groups', array('id'=>$mygroupid))) {
echo '<b>'.get_string('group').': '.$group->name. '</b><br />';
}
//show the count
echo '<b>'.get_string('completed_feedbacks', 'feedback').': '.$completedscount. '</b><br />';
// get the items of the feedback
-$items = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'hasvalue'=>1), 'position');
+$items = $DB->get_records('feedback_item',
+ array('feedback'=>$feedback->id, 'hasvalue'=>1),
+ 'position');
//show the count
-if(is_array($items)){
- echo '<b>'.get_string('questions', 'feedback').': ' .sizeof($items). ' </b><hr />';
+if (is_array($items)) {
+ echo '<b>'.get_string('questions', 'feedback').': ' .count($items). ' </b><hr />';
} else {
$items=array();
}
$check_anonymously = true;
-if($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
- if($completedscount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) {
+if ($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
+ if ($completedscount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) {
$check_anonymously = false;
}
}
-// echo '<div class="mdl-align"><table width="80%" cellpadding="10"><tr><td>';
+
echo '<div><table width="80%" cellpadding="10"><tr><td>';
-if($check_anonymously) {
+if ($check_anonymously) {
$itemnr = 0;
//print the items in an analysed form
- foreach($items as $item) {
- if($item->hasvalue == 0) continue;
+ foreach ($items as $item) {
+ if ($item->hasvalue == 0) {
+ continue;
+ }
echo '<table width="100%" class="generalbox">';
-
+
//get the class of item-typ
$itemobj = feedback_get_item_class($item->typ);
-
+
$itemnr++;
- if($feedback->autonumbering) {
+ if ($feedback->autonumbering) {
$printnr = $itemnr.'.';
} else {
$printnr = '';
}
$itemobj->print_analysed($item, $printnr, $mygroupid);
- // $itemnr = $itemobj->print_analysed($item, $itemnr, $mygroupid);
echo '</table>';
}
-}else {
- echo $OUTPUT->heading_with_help(get_string('insufficient_responses_for_this_group', 'feedback'), 'insufficient_responses', 'feedback');
+} else {
+ echo $OUTPUT->heading_with_help(get_string('insufficient_responses_for_this_group', 'feedback'),
+ 'insufficient_responses',
+ 'feedback');
}
echo '</td></tr></table></div>';
echo $OUTPUT->box_end();
View
107 mod/feedback/analysis_course.php
@@ -1,24 +1,36 @@
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
-* shows an analysed view of a feedback on the mainsite
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
+ * shows an analysed view of a feedback on the mainsite
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
require_once("../../config.php");
require_once("lib.php");
-// $SESSION->feedback->current_tab = 'analysis';
$current_tab = 'analysis';
$id = required_param('id', PARAM_INT); //the POST dominated the GET
$coursefilter = optional_param('coursefilter', '0', PARAM_INT);
$courseitemfilter = optional_param('courseitemfilter', '0', PARAM_INT);
$courseitemfiltertyp = optional_param('courseitemfiltertyp', '0', PARAM_ALPHANUM);
-// $searchcourse = optional_param('searchcourse', '', PARAM_ALPHAEXT);
$searchcourse = optional_param('searchcourse', '', PARAM_RAW);
$courseid = optional_param('courseid', false, PARAM_INT);
@@ -40,7 +52,7 @@
}
$PAGE->set_url($url);
-if(($searchcourse OR $courseitemfilter OR $coursefilter) AND !confirm_sesskey()) {
+if (($searchcourse OR $courseitemfilter OR $coursefilter) AND !confirm_sesskey()) {
print_error('invalidsesskey');
}
@@ -62,7 +74,7 @@
require_login($course->id, true, $cm);
-if( !( (intval($feedback->publish_stats) == 1) OR has_capability('mod/feedback:viewreports', $context))) {
+if (!($feedback->publish_stats OR has_capability('mod/feedback:viewreports', $context))) {
print_error('error');
}
@@ -75,15 +87,19 @@
echo $OUTPUT->header();
/// print the tabs
-include('tabs.php');
+require('tabs.php');
//print the analysed items
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
-if( has_capability('mod/feedback:viewreports', $context) ) {
+if (has_capability('mod/feedback:viewreports', $context)) {
//button "export to excel"
echo $OUTPUT->container_start('mdl-align');
- $aurl = new moodle_url('analysis_to_excel.php', array('sesskey'=>sesskey(), 'id'=>$id, 'coursefilter'=>$coursefilter));
+ $aurl = new moodle_url('analysis_to_excel.php',
+ array('sesskey' => sesskey(),
+ 'id' => $id,
+ 'coursefilter' => $coursefilter));
+
echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback'));
echo $OUTPUT->container_end();
}
@@ -98,11 +114,14 @@
echo '<b>'.get_string('completed_feedbacks', 'feedback').': '.$completedscount. '</b><br />';
// get the items of the feedback
-$items = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'hasvalue'=>1), 'position');
+$params = array('feedback' => $feedback->id, 'hasvalue' => 1);
+$items = $DB->get_records('feedback_item', $params, 'position');
//show the count
-if(is_array($items)){
- echo '<b>'.get_string('questions', 'feedback').': ' .sizeof($items). ' </b><hr />';
- echo '<a href="analysis_course.php?id=' . $id . '&courseid='.$courseid.'">'.get_string('show_all', 'feedback').'</a>';
+if (is_array($items)) {
+ echo '<b>'.get_string('questions', 'feedback').': ' .count($items). ' </b><hr />';
+ echo '<a href="analysis_course.php?id=' . $id . '&courseid='.$courseid.'">';
+ echo get_string('show_all', 'feedback');
+ echo '</a>';
} else {
$items=array();
}
@@ -114,12 +133,14 @@
if ($DB->get_dbfamily() == 'postgres') { // TODO: this should be moved to standard sql DML function ;-)
$avgvalue = 'avg(cast (value as integer))';
}
- if ($courses = $DB->get_records_sql ("SELECT fv.course_id, c.shortname, $avgvalue AS avgvalue
- FROM {feedback_value} fv, {course} c, {feedback_item} fi
- WHERE fv.course_id = c.id AND fi.id = fv.item AND fi.typ = ? AND fv.item = ?
- GROUP BY course_id, shortname
- ORDER BY avgvalue desc",
- array($courseitemfiltertyp, $courseitemfilter))) {
+
+ $sql = "SELECT fv.course_id, c.shortname, $avgvalue AS avgvalue
+ FROM {feedback_value} fv, {course} c, {feedback_item} fi
+ WHERE fv.course_id = c.id AND fi.id = fv.item AND fi.typ = ? AND fv.item = ?
+ GROUP BY course_id, shortname
+ ORDER BY avgvalue desc";
+
+ if ($courses = $DB->get_records_sql($sql, array($courseitemfiltertyp, $courseitemfilter))) {
$item = $DB->get_record('feedback_item', array('id'=>$courseitemfilter));
echo '<tr><th colspan="2">'.$item->name.'</th></tr>';
echo '<tr><td><table align="left">';
@@ -128,8 +149,15 @@
$sep_thous = get_string('separator_thousand', 'feedback');
foreach ($courses as $c) {
- $shortname = format_string($c->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $c->course_id)));
- echo '<tr><td>'.$shortname.'</td><td align="right">'.number_format(($c->avgvalue), 2, $sep_dec, $sep_thous).'</td></tr>';
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $c->course_id);
+ $shortname = format_string($c->shortname, true, array('context' => $coursecontext));
+
+ echo '<tr>';
+ echo '<td>'.$shortname.'</td>';
+ echo '<td align="right">'
+ echo number_format(($c->avgvalue), 2, $sep_dec, $sep_thous);
+ echo '</td>';
+ echo '</tr>';
}
echo '</table></td></tr>';
} else {
@@ -138,7 +166,8 @@
} else {
echo get_string('search_course', 'feedback') . ': ';
- echo '<input type="text" name="searchcourse" value="'.s($searchcourse).'"/> <input type="submit" value="'.get_string('search').'"/>';
+ echo '<input type="text" name="searchcourse" value="'.s($searchcourse).'"/> ';
+ echo '<input type="submit" value="'.get_string('search').'"/>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<input type="hidden" name="courseitemfilter" value="'.$courseitemfilter.'" />';
@@ -158,28 +187,40 @@
echo ' ' . get_string('filter_by_course', 'feedback') . ': ';
- echo html_writer::select($courses, 'coursefilter', $coursefilter, null, array('id'=>'coursefilterid'));
- $PAGE->requires->js_init_call('M.util.init_select_autosubmit', array('analysis-form', 'coursefilterid', false));
+ echo html_writer::select($courses, 'coursefilter', $coursefilter,
+ null, array('id'=>'coursefilterid'));
+
+ $PAGE->requires->js_init_call('M.util.init_select_autosubmit',
+ array('analysis-form', 'coursefilterid', false));
}
echo '<hr />';
$itemnr = 0;
//print the items in an analysed form
echo '<tr><td>';
- foreach($items as $item) {
- if($item->hasvalue == 0) continue;
+ foreach ($items as $item) {
+ if ($item->hasvalue == 0) {
+ continue;
+ }
echo '<table width="100%" class="generalbox">';
//get the class from item-typ
$itemobj = feedback_get_item_class($item->typ);
$itemnr++;
- if($feedback->autonumbering) {
+ if ($feedback->autonumbering) {
$printnr = $itemnr.'.';
} else {
$printnr = '';
}
$itemobj->print_analysed($item, $printnr, $mygroupid, $coursefilter);
if (preg_match('/rated$/i', $item->typ)) {
- echo '<tr><td colspan="2"><a href="#" onclick="setcourseitemfilter('.$item->id.',\''.$item->typ.'\'); return false;">'.
- get_string('sort_by_course', 'feedback').'</a></td></tr>';
+ $onclick = 'onclick="setcourseitemfilter'.
+ "(".$item->id.",'".$item->typ."');".
+ ' return false;"';
+
+ $anker = '<a href="#" '.$onclick.'>'.
+ get_string('sort_by_course', 'feedback').
+ '</a>';
+
+ echo '<tr><td colspan="2">'.$anker.'</td></tr>';
}
echo '</table>';
}
View
256 mod/feedback/analysis_to_excel.php
@@ -1,16 +1,29 @@
<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
-* prints an analysed excel-spreadsheet of the feedback
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
+ * prints an analysed excel-spreadsheet of the feedback
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
require_once("../../config.php");
require_once("lib.php");
-// require_once('easy_excel.php');
require_once("$CFG->libdir/excellib.class.php");
feedback_load_feedback_items();
@@ -63,12 +76,15 @@
$fstring->fullname = get_string('fullnameuser');
$fstring->courseid = get_string('courseid', 'feedback');
$fstring->course = get_string('course');
-$fstring->anonymous_user = get_string('anonymous_user','feedback');
+$fstring->anonymous_user = get_string('anonymous_user', 'feedback');
ob_end_clean();
//get the questions (item-names)
-if(!$items = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'hasvalue'=>1), 'position')) {
- print_error('no_items_available_yet', 'feedback', $CFG->wwwroot.'/mod/feedback/view.php?id='.$id);
+$params = array('feedback' => $feedback->id, 'hasvalue' => 1);
+if (!$items = $DB->get_records('feedback_item', $params, 'position')) {
+ print_error('no_items_available_yet',
+ 'feedback',
+ $CFG->wwwroot.'/mod/feedback/view.php?id='.$id);
exit;
}
@@ -77,54 +93,30 @@
$mygroupid = groups_get_activity_group($cm);
// Creating a workbook
-// $workbook = new EasyWorkbook("-");
$workbook = new MoodleExcelWorkbook('-');
-// $workbook->setTempDir($CFG->tempdir.'');
$workbook->send($filename);
-// $workbook->setVersion(8);
//creating the needed formats
-$xlsFormats = new stdClass();
-$xlsFormats->head1 = $workbook->add_format(array(
+$xls_formats = new stdClass();
+$xls_formats->head1 = $workbook->add_format(array(
'bold'=>1,
'size'=>12));
-$xlsFormats->head2 = $workbook->add_format(array(
+$xls_formats->head2 = $workbook->add_format(array(
'align'=>'left',
'bold'=>1,
'bottum'=>2));
-$xlsFormats->default = $workbook->add_format(array(
+$xls_formats->default = $workbook->add_format(array(
'align'=>'left',
'v_align'=>'top'));
-// $xlsFormats->head2_green = $workbook->add_format(array(
- // 'align'=>'left',
- // 'bold'=>1,
- // 'v_align'=>'top',
- // 'bottum'=>2,
- // 'fg_color'=>'green'));
-
-$xlsFormats->value_bold = $workbook->add_format(array(
+$xls_formats->value_bold = $workbook->add_format(array(
'align'=>'left',
'bold'=>1,
'v_align'=>'top'));
-// $xlsFormats->value_blue = $workbook->add_format(array(
- // 'align'=>'left',
- // 'bold'=>1,
- // 'v_align'=>'top',
- // 'top'=>2,
- // 'fg_color'=>'blue'));
-
-// $xlsFormats->value_red = $workbook->add_format(array(
- // 'align'=>'left',
- // 'bold'=>1,
- // 'v_align'=>'top',
- // 'top'=>2,
- // 'fg_color'=>'red'));
-
-$xlsFormats->procent = $workbook->add_format(array(
+$xls_formats->procent = $workbook->add_format(array(
'align'=>'left',
'bold'=>1,
'v_align'=>'top',
@@ -134,59 +126,57 @@
$sheetname = clean_param($feedback->name, PARAM_ALPHANUM);
error_reporting(0);
$worksheet1 =& $workbook->add_worksheet(substr($sheetname, 0, 31));
-// $worksheet1->set_workbook($workbook);
$worksheet2 =& $workbook->add_worksheet('detailed');
-// $worksheet2->set_workbook($workbook);
error_reporting($CFG->debug);
-// $worksheet1->pear_excel_worksheet->set_portrait();
-// $worksheet1->pear_excel_worksheet->set_paper(9);
-// $worksheet1->pear_excel_worksheet->center_horizontally();
$worksheet1->hide_gridlines();
-// $worksheet1->pear_excel_worksheet->set_header("&\"Arial," . $fstring->bold . "\"&14".$feedback->name);
-// $worksheet1->pear_excel_worksheet->set_footer($fstring->page." &P " . $fstring->of . " &N");
$worksheet1->set_column(0, 0, 10);
$worksheet1->set_column(1, 1, 30);
$worksheet1->set_column(2, 20, 15);
-// $worksheet1->set_margins_LR(0.10);
-
-// $worksheet2->pear_excel_worksheet->set_landscape();
-// $worksheet2->pear_excel_worksheet->set_paper(9);
-// $worksheet2->pear_excel_worksheet->center_horizontally();
//writing the table header
-$rowOffset1 = 0;
-// $worksheet1->setFormat("<f>",12,false);
-$worksheet1->write_string($rowOffset1, 0, UserDate(time()), $xlsFormats->head1);
+$row_offset1 = 0;
+$worksheet1->write_string($row_offset1, 0, userdate(time()), $xls_formats->head1);
////////////////////////////////////////////////////////////////////////
//print the analysed sheet
////////////////////////////////////////////////////////////////////////
//get the completeds
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $coursefilter);
-if($completedscount > 0){
+if ($completedscount > 0) {
//write the count of completeds
- $rowOffset1++;
- $worksheet1->write_string($rowOffset1, 0, $fstring->modulenameplural.': '.strval($completedscount), $xlsFormats->head1);
+ $row_offset1++;
+ $worksheet1->write_string($row_offset1,
+ 0,
+ $fstring->modulenameplural.': '.strval($completedscount),
+ $xls_formats->head1);
}
-if(is_array($items)){
- $rowOffset1++;
- $worksheet1->write_string($rowOffset1, 0, $fstring->questions.': '. strval(sizeof($items)), $xlsFormats->head1);
+if (is_array($items)) {
+ $row_offset1++;
+ $worksheet1->write_string($row_offset1,
+ 0,
+ $fstring->questions.': '. strval(count($items)),
+ $xls_formats->head1);
}
-$rowOffset1 += 2;
-$worksheet1->write_string($rowOffset1, 0, $fstring->itemlabel, $xlsFormats->head1);
-$worksheet1->write_string($rowOffset1, 1, $fstring->question, $xlsFormats->head1);
-$worksheet1->write_string($rowOffset1, 2, $fstring->responses, $xlsFormats->head1);
-$rowOffset1++ ;
+$row_offset1 += 2;
+$worksheet1->write_string($row_offset1, 0, $fstring->itemlabel, $xls_formats->head1);
+$worksheet1->write_string($row_offset1, 1, $fstring->question, $xls_formats->head1);
+$worksheet1->write_string($row_offset1, 2, $fstring->responses, $xls_formats->head1);
+$row_offset1++;
if (empty($items)) {
$items=array();
}
-foreach($items as $item) {
+foreach ($items as $item) {
//get the class of item-typ
$itemobj = feedback_get_item_class($item->typ);
- $rowOffset1 = $itemobj->excelprint_item($worksheet1, $rowOffset1, $xlsFormats, $item, $mygroupid, $coursefilter);
+ $row_offset1 = $itemobj->excelprint_item($worksheet1,
+ $row_offset1,
+ $xls_formats,
+ $item,
+ $mygroupid,
+ $coursefilter);
}
////////////////////////////////////////////////////////////////////////
@@ -199,14 +189,18 @@
//therefor for each completed we have to iterate over all items of the feedback
//this is done by feedback_excelprint_detailed_items
-$rowOffset2 = 0;
+$row_offset2 = 0;
//first we print the table-header
-$rowOffset2 = feedback_excelprint_detailed_head($worksheet2, $xlsFormats, $items, $rowOffset2);
+$row_offset2 = feedback_excelprint_detailed_head($worksheet2, $xls_formats, $items, $row_offset2);
-if(is_array($completeds)){
- foreach($completeds as $completed) {
- $rowOffset2 = feedback_excelprint_detailed_items($worksheet2, $xlsFormats, $completed, $items, $rowOffset2);
+if (is_array($completeds)) {
+ foreach ($completeds as $completed) {
+ $row_offset2 = feedback_excelprint_detailed_items($worksheet2,
+ $xls_formats,
+ $completed,
+ $items,
+ $row_offset2);
}
}
@@ -219,100 +213,102 @@
////////////////////////////////////////////////////////////////////////////////
-function feedback_excelprint_detailed_head(&$worksheet, $xlsFormats, $items, $rowOffset) {
+function feedback_excelprint_detailed_head(&$worksheet, $xls_formats, $items, $row_offset) {
global $fstring, $feedback;
- if(!$items) return;
- $colOffset = 0;
-
- // $worksheet->setFormat('<l><f><ru2>');
+ if (!$items) {
+ return;
+ }
+ $col_offset = 0;
- $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->idnumber, $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset + 1, $col_offset, $fstring->idnumber, $xls_formats->head2);
+ $col_offset++;
- $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->username, $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset + 1, $col_offset, $fstring->username, $xls_formats->head2);
+ $col_offset++;
- $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->fullname, $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset + 1, $col_offset, $fstring->fullname, $xls_formats->head2);
+ $col_offset++;
- foreach($items as $item) {
- // $worksheet->setFormat('<l><f><ru2>');
- $worksheet->write_string($rowOffset, $colOffset, $item->name, $xlsFormats->head2);
- $worksheet->write_string($rowOffset + 1, $colOffset, $item->label, $xlsFormats->head2);
- $colOffset++;
+ foreach ($items as $item) {
+ $worksheet->write_string($row_offset, $col_offset, $item->name, $xls_formats->head2);
+ $worksheet->write_string($row_offset + 1, $col_offset, $item->label, $xls_formats->head2);
+ $col_offset++;
}
- // $worksheet->setFormat('<l><f><ru2>');
- $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->courseid, $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset + 1, $col_offset, $fstring->courseid, $xls_formats->head2);
+ $col_offset++;
- // $worksheet->setFormat('<l><f><ru2>');
- $worksheet->write_string($rowOffset + 1, $colOffset, $fstring->course, $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset + 1, $col_offset, $fstring->course, $xls_formats->head2);
+ $col_offset++;
- return $rowOffset + 2;
+ return $row_offset + 2;
}
-function feedback_excelprint_detailed_items(&$worksheet, $xlsFormats, $completed, $items, $rowOffset) {
+function feedback_excelprint_detailed_items(&$worksheet, $xls_formats,
+ $completed, $items, $row_offset) {
global $DB, $fstring;
- if(!$items) return;
- $colOffset = 0;
+ if (!$items) {
+ return;
+ }
+ $col_offset = 0;
$courseid = 0;
$feedback = $DB->get_record('feedback', array('id'=>$completed->feedback));
//get the username
//anonymous users are separated automatically because the userid in the completed is "0"
- // $worksheet->setFormat('<l><f><ru2>');
- if($user = $DB->get_record('user', array('id'=>$completed->userid))) {
+ if ($user = $DB->get_record('user', array('id'=>$completed->userid))) {
if ($completed->anonymous_response == FEEDBACK_ANONYMOUS_NO) {
- $worksheet->write_string($rowOffset, $colOffset, $user->idnumber, $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset, $col_offset, $user->idnumber, $xls_formats->head2);
+ $col_offset++;
$userfullname = fullname($user);
- $worksheet->write_string($rowOffset, $colOffset, $user->username, $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset, $col_offset, $user->username, $xls_formats->head2);
+ $col_offset++;
} else {
$userfullname = $fstring->anonymous_user;
- $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
- $colOffset++;
- $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+ $col_offset++;
+ $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+ $col_offset++;
}
- }else {
+ } else {
$userfullname = $fstring->anonymous_user;
- $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
- $colOffset++;
- $worksheet->write_string($rowOffset, $colOffset, '-', $xlsFormats->head2);
- $colOffset++;
+ $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+ $col_offset++;
+ $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2);
+ $col_offset++;
}
- $worksheet->write_string($rowOffset, $colOffset, $userfullname, $xlsFormats->head2);
+ $worksheet->write_string($row_offset, $col_offset, $userfullname, $xls_formats->head2);
- $colOffset++;
- foreach($items as $item) {
- $value = $DB->get_record('feedback_value', array('item'=>$item->id, 'completed'=>$completed->id));
+ $col_offset++;
+ foreach ($items as $item) {
+ $params = array('item' => $item->id, 'completed' => $completed->id);
+ $value = $DB->get_record('feedback_value', $params);
$itemobj = feedback_get_item_class($item->typ);
$printval = $itemobj->get_printval($item, $value);
$printval = trim($printval);
- // $worksheet->setFormat('<l><vo>');
- if(is_numeric($printval)) {
- $worksheet->write_number($rowOffset, $colOffset, $printval, $xlsFormats->default);
- } elseif($printval != '') {
- $worksheet->write_string($rowOffset, $colOffset, $printval, $xlsFormats->default);
+ if (is_numeric($printval)) {
+ $worksheet->write_number($row_offset, $col_offset, $printval, $xls_formats->default);
+ } else if ($printval != '') {
+ $worksheet->write_string($row_offset, $col_offset, $printval, $xls_formats->default);
}
$printval = '';
- $colOffset++;
+ $col_offset++;
$courseid = isset($value->course_id) ? $value->course_id : 0;
- if($courseid == 0) $courseid = $feedback->course;
+ if ($courseid == 0) {
+ $courseid = $feedback->course;
+ }
}
- $worksheet->write_number($rowOffset, $colOffset, $courseid, $xlsFormats->default);
- $colOffset++;
+ $worksheet->write_number($row_offset, $col_offset, $courseid, $xls_formats->default);
+ $col_offset++;
if (isset($courseid) AND $course = $DB->get_record('course', array('id' => $courseid))) {
- $shortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $courseid)));
- $worksheet->write_string($rowOffset, $colOffset, $shortname, $xlsFormats->default);
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
+ $shortname = format_string($course->shortname, true, array('context' => $coursecontext));
+ $worksheet->write_string($row_offset, $col_offset, $shortname, $xls_formats->default);
}
- return $rowOffset + 1;
+ return $row_offset + 1;
}
View
1  mod/feedback/backup/moodle1/lib.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
3  mod/feedback/backup/moodle2/backup_feedback_activity_task.class.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -53,7 +52,7 @@ protected function define_my_steps() {
static public function encode_content_links($content) {
global $CFG;
- $base = preg_quote($CFG->wwwroot,"/");
+ $base = preg_quote($CFG->wwwroot, "/");
// Link to the list of feedbacks
$search="/(".$base."\/mod\/feedback\/index.php\?id\=)([0-9]+)/";
View
1  mod/feedback/backup/moodle2/backup_feedback_settingslib.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
3  mod/feedback/backup/moodle2/backup_feedback_stepslib.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@@ -54,7 +53,6 @@ protected function define_structure() {
'timemodified',
'completionsubmit'));
-
$completeds = new backup_nested_element('completeds');
$completed = new backup_nested_element('completed', array('id'), array(
@@ -92,7 +90,6 @@ protected function define_structure() {
'completed',
'value'));
-
// Build the tree
$feedback->add_child($items);
$items->add_child($item);
View
1  mod/feedback/backup/moodle2/restore_feedback_activity_task.class.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
1  mod/feedback/backup/moodle2/restore_feedback_stepslib.php
@@ -1,5 +1,4 @@
<?php
-
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
View
89 mod/feedback/choose_group_form.php
@@ -1,68 +1,25 @@
<?php
-/**
-* prints the form to choose the group you want to analyse
-*
-* @author Andreas Grabs
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package feedback
-*/
-
-if (!defined('MOODLE_INTERNAL')) {
- die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
-}
-
-require_once $CFG->libdir.'/formslib.php';
-
-class feedback_choose_group_form extends moodleform {
- var $feedbackdata;
-
- function definition() {
- $this->feedbackdata = new stdClass();
- //this function can not be called, because not all data are available at this time
- //I use set_form_elements instead
- }
-
- //this function set the data used in set_form_elements()
- //in this form the only value have to set is course
- //eg: array('course' => $course)
- function set_feedbackdata($data) {
- if(is_array($data)) {
- foreach($data as $key => $val) {
- $this->feedbackdata->{$key} = $val;
- }
- }
- }
-
- //here the elements will be set
- //this function have to be called manually
- //the advantage is that the data are already set
- function set_form_elements(){
- $mform =& $this->_form;
-
- $elementgroup = array();
- //headline
- // $mform->addElement('header', 'general', get_string('choose_group', 'feedback'));
- // hidden elements
- $mform->addElement('hidden', 'id');
- $mform->setType('id', PARAM_INT);
- $mform->addElement('hidden', 'do_show');
- $mform->setType('do-show', PARAM_INT);
-
- // visible elements
- $groups_options = array();
- if(isset($this->feedbackdata->groups)){
- $groups_options['-1'] = get_string('allgroups');
- foreach($this->feedbackdata->groups as $group) {
- $groups_options[$group->id] = $group->name;
- }
- }
- $attributes = 'onChange="this.form.submit()"';
- $elementgroup[] =& $mform->createElement('select', 'lstgroupid', '', $groups_options, $attributes);
- // buttons
- $elementgroup[] =& $mform->createElement('submit', 'switch_group', get_string('switch_group', 'feedback'));
- $mform->addGroup($elementgroup, 'elementgroup', '', array(' '), false);
-
-//-------------------------------------------------------------------------------
- }
-}
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+/**
+ * prints the form to choose the group you want to analyse
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+//This file can be deleted
View
958 mod/feedback/complete.php
@@ -1,237 +1,283 @@
<?php
-
- /**
- * prints the form so the user can fill out the feedback
- *
- * @author Andreas Grabs
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package feedback
- */
-
- require_once("../../config.php");
- require_once("lib.php");
- require_once($CFG->libdir . '/completionlib.php');
-
- feedback_init_feedback_session();
-
- $id = required_param('id', PARAM_INT);
- $completedid = optional_param('completedid', false, PARAM_INT);
- $preservevalues = optional_param('preservevalues', 0, PARAM_INT);
- $courseid = optional_param('courseid', false, PARAM_INT);
- $gopage = optional_param('gopage', -1, PARAM_INT);
- $lastpage = optional_param('lastpage', false, PARAM_INT);
- $startitempos = optional_param('startitempos', 0, PARAM_INT);
- $lastitempos = optional_param('lastitempos', 0, PARAM_INT);
- $anonymous_response = optional_param('anonymous_response', 0, PARAM_INT); //arb
-
- $highlightrequired = false;
-
- if(($formdata = data_submitted()) AND !confirm_sesskey()) {
- print_error('invalidsesskey');
- }
-
- //if the use hit enter into a textfield so the form should not submit
- if(isset($formdata->sesskey) AND !isset($formdata->savevalues) AND !isset($formdata->gonextpage) AND !isset($formdata->gopreviouspage)) {
- $gopage = $formdata->lastpage;
- }
-
- if(isset($formdata->savevalues)) {
- $savevalues = true;
- }else {
- $savevalues = false;
- }
-
- if($gopage < 0 AND !$savevalues) {
- if(isset($formdata->gonextpage)){
- $gopage = $lastpage + 1;
- $gonextpage = true;
- $gopreviouspage = false;
- }else if(isset($formdata->gopreviouspage)){
- $gopage = $lastpage - 1;
- $gonextpage = false;
- $gopreviouspage = true;
- }else {
- print_error('missingparameter');
- }
- }else {
- $gonextpage = $gopreviouspage = false;
- }
-
- if (! $cm = get_coursemodule_from_id('feedback', $id)) {
- print_error('invalidcoursemodule');
- }
-
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
- print_error('coursemisconf');
- }
-
- if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
- print_error('invalidcoursemodule');
- }
-
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
-
- $feedback_complete_cap = false;
-
- if(has_capability('mod/feedback:complete', $context)) {
- $feedback_complete_cap = true;
- }
-
- //check whether the feedback is located and! started from the mainsite
- if($course->id == SITEID AND !$courseid) {
- $courseid = SITEID;
- }
-
- //check whether the feedback is mapped to the given courseid
- if($course->id == SITEID AND !has_capability('mod/feedback:edititems', $context)) {
- if($DB->get_records('feedback_sitecourse_map', array('feedbackid'=>$feedback->id))) {
- if(!$DB->get_record('feedback_sitecourse_map', array('feedbackid'=>$feedback->id, 'courseid'=>$courseid))){
- print_error('notavailable', 'feedback');
- }
- }
- }
-
- if($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
- if($course->id == SITEID) {
- require_login($course->id, true);
- }else {
- require_login($course->id, true, $cm);
- }
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * prints the form so the user can fill out the feedback
+ *
+ * @author Andreas Grabs
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package feedback
+ */
+
+require_once("../../config.php");
+require_once("lib.php");
+require_once($CFG->libdir . '/completionlib.php');
+
+feedback_init_feedback_session();
+
+$id = required_param('id', PARAM_INT);
+$completedid = optional_param('completedid', false, PARAM_INT);
+$preservevalues = optional_param('preservevalues', 0, PARAM_INT);
+$courseid = optional_param('courseid', false, PARAM_INT);
+$gopage = optional_param('gopage', -1, PARAM_INT);
+$lastpage = optional_param('lastpage', false, PARAM_INT);
+$startitempos = optional_param('startitempos', 0, PARAM_INT);
+$lastitempos = optional_param('lastitempos', 0, PARAM_INT);
+$anonymous_response = optional_param('anonymous_response', 0, PARAM_INT); //arb
+
+$highlightrequired = false;
+
+if (($formdata = data_submitted()) AND !confirm_sesskey()) {
+ print_error('invalidsesskey');
+}
+
+//if the use hit enter into a textfield so the form should not submit
+if (isset($formdata->sesskey) AND
+ !isset($formdata->savevalues) AND
+ !isset($formdata->gonextpage) AND
+ !isset($formdata->gopreviouspage)) {
+
+ $gopage = $formdata->lastpage;
+}
+
+if (isset($formdata->savevalues)) {
+ $savevalues = true;
+} else {
+ $savevalues = false;
+}
+
+if ($gopage < 0 AND !$savevalues) {
+ if (isset($formdata->gonextpage)) {
+ $gopage = $lastpage + 1;
+ $gonextpage = true;
+ $gopreviouspage = false;
+ } else if (isset($formdata->gopreviouspage)) {
+ $gopage = $lastpage - 1;
+ $gonextpage = false;
+ $gopreviouspage = true;
} else {
- if($course->id == SITEID) {
- require_course_login($course, true);
- }else {
- require_course_login($course, true, $cm);
- }
+ print_error('missingparameter');
}
-
- //check whether the given courseid exists
- if($courseid AND $courseid != SITEID) {
- if($course2 = $DB->get_record('course', array('id'=>$courseid))){
- require_course_login($course2); //this overwrites the object $course :-(
- $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
- }else {
- print_error('invalidcourseid');
+} else {
+ $gonextpage = $gopreviouspage = false;
+}
+
+if (! $cm = get_coursemodule_from_id('feedback', $id)) {
+ print_error('invalidcoursemodule');
+}
+
+if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+ print_error('coursemisconf');
+}
+
+if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
+ print_error('invalidcoursemodule');
+}
+
+if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
+ print_error('badcontext');
+}
+
+$feedback_complete_cap = false;
+
+if (has_capability('mod/feedback:complete', $context)) {
+ $feedback_complete_cap = true;
+}
+
+//check whether the feedback is located and! started from the mainsite
+if ($course->id == SITEID AND !$courseid) {
+ $courseid = SITEID;
+}
+
+//check whether the feedback is mapped to the given courseid
+if ($course->id == SITEID AND !has_capability('mod/feedback:edititems', $context)) {
+ if ($DB->get_records('feedback_sitecourse_map', array('feedbackid'=>$feedback->id))) {
+ $params = array('feedbackid'=>$feedback->id, 'courseid'=>$courseid);
+ if (!$DB->get_record('feedback_sitecourse_map', $params)) {
+ print_error('notavailable', 'feedback');
}
}
+}
- if(!$feedback_complete_cap) {
- print_error('error');
- }
-
- // Mark activity viewed for completion-tracking
- $completion = new completion_info($course);
- $completion->set_module_viewed($cm);
-
- /// Print the page header
- $strfeedbacks = get_string("modulenameplural", "feedback");
- $strfeedback = get_string("modulename", "feedback");
-
- if($course->id == SITEID) {
- $PAGE->set_cm($cm, $course); // set's up global $COURSE
- $PAGE->set_pagelayout('incourse');
+if ($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
+ if ($course->id == SITEID) {
+ require_login($course->id, true);
+ } else {
+ require_login($course->id, true, $cm);
}
-
- $PAGE->navbar->add(get_string('feedback:complete', 'feedback'));
- $PAGE->set_url('/mod/feedback/complete.php', array('id'=>$cm->id, 'gopage'=>$gopage, 'courseid'=>$course->id));
- $PAGE->set_heading(format_string($course->fullname));
- $PAGE->set_title(format_string($feedback->name));
- echo $OUTPUT->header();
-
- //ishidden check.
- //feedback in courses
- if ((empty($cm->visible) AND
- !has_capability('moodle/course:viewhiddenactivities', $context)) AND
- $course->id != SITEID) {
- notice(get_string("activityiscurrentlyhidden"));
+} else {
+ if ($course->id == SITEID) {
+ require_course_login($course, true);
+ } else {
+ require_course_login($course, true, $cm);
}
+}
- //ishidden check.
- //feedback on mainsite
- if ((empty($cm->visible) AND
- !has_capability('moodle/course:viewhiddenactivities', $context)) AND
- $courseid == SITEID) {
- notice(get_string("activityiscurrentlyhidden"));
+//check whether the given courseid exists
+if ($courseid AND $courseid != SITEID) {
+ if ($course2 = $DB->get_record('course', array('id'=>$courseid))) {
+ require_course_login($course2); //this overwrites the object $course :-(
+ $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround
+ } else {
+ print_error('invalidcourseid');
}
-
- feedback_print_errors();
-
- //check, if the feedback is open (timeopen, timeclose)
- $checktime = time();
- if(($feedback->timeopen > $checktime) OR ($feedback->timeclose < $checktime AND $feedback->timeclose > 0)) {
- echo $OUTPUT->box_start('generalbox boxaligncenter');
- echo '<h2><font color="red">'.get_string('feedback_is_not_open', 'feedback').'</font></h2>';
- echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
- echo $OUTPUT->box_end();
- echo $OUTPUT->footer();
- exit;
+}
+
+if (!$feedback_complete_cap) {
+ print_error('error');
+}
+
+// Mark activity viewed for completion-tracking
+$completion = new completion_info($course);
+$completion->set_module_viewed($cm);
+
+/// Print the page header
+$strfeedbacks = get_string("modulenameplural", "feedback");
+$strfeedback = get_string("modulename", "feedback");
+
+if ($course->id == SITEID) {
+ $PAGE->set_cm($cm, $course); // set's up global $COURSE
+ $PAGE->set_pagelayout('incourse');
+}
+
+$PAGE->navbar->add(get_string('feedback:complete', 'feedback'));
+$urlparams = array('id'=>$cm->id, 'gopage'=>$gopage, 'courseid'=>$course->id);
+$PAGE->set_url('/mod/feedback/complete.php', $urlparams);
+$PAGE->set_heading(format_string($course->fullname));
+$PAGE->set_title(format_string($feedback->name));
+echo $OUTPUT->header();
+
+//ishidden check.
+//feedback in courses
+if ((empty($cm->visible) AND
+ !has_capability('moodle/course:viewhiddenactivities', $context)) AND
+ $course->id != SITEID) {
+ notice(get_string("activityiscurrentlyhidden"));
+}
+
+//ishidden check.
+//feedback on mainsite
+if ((empty($cm->visible) AND
+ !has_capability('moodle/course:viewhiddenactivities', $context)) AND
+ $courseid == SITEID) {
+ notice(get_string("activityiscurrentlyhidden"));
+}
+
+//check, if the feedback is open (timeopen, timeclose)
+$checktime = time();
+$feedback_is_closed = ($feedback->timeopen > $checktime) OR
+ ($feedback->timeclose < $checktime AND
+ $feedback->timeclose > 0);
+
+if ($feedback_is_closed) {
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
+ echo '<h2><font color="red">';
+ echo get_string('feedback_is_not_open', 'feedback');
+ echo '</font></h2>';
+ echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
+ echo $OUTPUT->box_end();
+ echo $OUTPUT->footer();
+ exit;
+}
+
+//additional check for multiple-submit (prevent browsers back-button).
+//the main-check is in view.php
+$feedback_can_submit = true;
+if ($feedback->multiple_submit == 0 ) {
+ if (feedback_is_already_submitted($feedback->id, $courseid)) {
+ $feedback_can_submit = false;
}
-
- //additional check for multiple-submit (prevent browsers back-button). the main-check is in view.php
- $feedback_can_submit = true;
- if($feedback->multiple_submit == 0 ) {
- if(feedback_is_already_submitted($feedback->id, $courseid)) {
- $feedback_can_submit = false;
+}
+if ($feedback_can_submit) {
+ //preserving the items
+ if ($preservevalues == 1) {
+ if (!isset($SESSION->feedback->is_started) OR !$SESSION->feedback->is_started == true) {
+ print_error('error', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
}
- }
- if($feedback_can_submit) {
- //preserving the items
- if($preservevalues == 1){
- if(!$SESSION->feedback->is_started == true)
- print_error('error', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
- //checken, ob alle required items einen wert haben
- if(feedback_check_values($startitempos, $lastitempos)) {
- $userid = $USER->id; //arb
- if($completedid = feedback_save_values($USER->id, true)){
- if($userid > 0) {
- add_to_log($course->id, 'feedback', 'startcomplete', 'view.php?id='.$cm->id, $feedback->id, $cm->id, $userid);
- }
- if(!$gonextpage AND !$gopreviouspage) $preservevalues = false;//es kann gespeichert werden
-
- }else {
- $savereturn = 'failed';
- if(isset($lastpage)) {
- $gopage = $lastpage;
- }else {
- print_error('missingparameter');
- }
+ //checken, ob alle required items einen wert haben
+ if (feedback_check_values($startitempos, $lastitempos)) {
+ $userid = $USER->id; //arb
+ if ($completedid = feedback_save_values($USER->id, true)) {
+ if ($userid > 0) {
+ add_to_log($course->id,
+ 'feedback',
+ 'startcomplete',
+ 'view.php?id='.$cm->id,
+ $feedback->id,
+ $cm->id,
+ $userid);
}
- }else {
- $savereturn = 'missing';
- $highlightrequired = true;
- if(isset($lastpage)) {
+ if (!$gonextpage AND !$gopreviouspage) {
+ $preservevalues = false;//es kann gespeichert werden
+ }
+
+ } else {
+ $savereturn = 'failed';
+ if (isset($lastpage)) {
$gopage = $lastpage;
- }else {
+ } else {
print_error('missingparameter');
}
-
}
+ } else {
+ $savereturn = 'missing';
+ $highlightrequired = true;
+ if (isset($lastpage)) {
+ $gopage = $lastpage;
+ } else {
+ print_error('missingparameter');
+ }
+
}
+ }
- //saving the items
- if($savevalues AND !$preservevalues){
- //exists there any pagebreak, so there are values in the feedback_valuetmp
- $userid = $USER->id; //arb
+ //saving the items
+ if ($savevalues AND !$preservevalues) {
+ //exists there any pagebreak, so there are values in the feedback_valuetmp
+ $userid = $USER->id; //arb
- if($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
- $feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid);
- }else{
- $feedbackcompleted = false;
- }
- $feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', array('id'=>$completedid));
- //fake saving for switchrole
- $is_switchrole = feedback_check_is_switchrole();
- if($is_switchrole) {
- $savereturn = 'saved';
- feedback_delete_completedtmp($completedid);
- }else if($new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp, $feedbackcompleted, $userid)) {
+ if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
+ $feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid);
+ } else {
+ $feedbackcompleted = false;
+ }
+ $params = array('id' => $completedid);
+ $feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', $params);
+ //fake saving for switchrole
+ $is_switchrole = feedback_check_is_switchrole();
+ if ($is_switchrole) {
+ $savereturn = 'saved';
+ feedback_delete_completedtmp($completedid);
+ } else {
+ $new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp,
+ $feedbackcompleted,
+ $userid);
+ if ($new_completed_id) {
$savereturn = 'saved';
- if($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
- add_to_log($course->id, 'feedback', 'submit', 'view.php?id='.$cm->id, $feedback->id, $cm->id, $userid);
+ if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
+ add_to_log($course->id,
+ 'feedback',
+ 'submit',
+ 'view.php?id='.$cm->id,
+ $feedback->id,
+ $cm->id,
+ $userid);
+
feedback_send_email($cm, $feedback, $course, $userid);
- }else {
+ } else {
feedback_send_email_anonym($cm, $feedback, $course, $userid);
}
//tracking the submit
@@ -241,270 +287,316 @@
$tracking->completed = $new_completed_id;
$DB->insert_record('feedback_tracking', $tracking);
unset($SESSION->feedback->is_started);
-
+
// Update completion state
$completion = new completion_info($course);
if ($completion->is_enabled($cm) && $feedback->completionsubmit) {
$completion->update_state($cm, COMPLETION_COMPLETE);
}
- }else {
+ } else {
$savereturn = 'failed';
}
-
}
+ }
- if($allbreaks = feedback_get_all_break_positions($feedback->id)){
- if($gopage <= 0) {
- $startposition = 0;
- }else {
- if(!isset($allbreaks[$gopage - 1])) {
- $gopage = count($allbreaks);
- }
- $startposition = $allbreaks[$gopage - 1];
- }
- $ispagebreak = true;
- }else {
+
+ if ($allbreaks = feedback_get_all_break_positions($feedback->id)) {
+ if ($gopage <= 0) {
$startposition = 0;
- $newpage = 0;
- $ispagebreak = false;
+ } else {
+ if (!isset($allbreaks[$gopage - 1])) {
+ $gopage = count($allbreaks);
+ }
+ $startposition = $allbreaks[$gopage - 1];
}
+ $ispagebreak = true;
+ } else {
+ $startposition = 0;
+ $newpage = 0;
+ $ispagebreak = false;
+ }
- //get the feedbackitems after the last shown pagebreak
- $feedbackitems = $DB->get_records_select('feedback_item', 'feedback = ? AND position > ?', array($feedback->id, $startposition), 'position');
+ //get the feedbackitems after the last shown pagebreak
+ $select = 'feedback = ? AND position > ?';
+ $params = array($feedback->id, $startposition);
+ $feedbackitems = $DB->get_records_select('feedback_item', $select, $params, 'position');
- //get the first pagebreak
- if($pagebreaks = $DB->get_records('feedback_item', array('feedback'=>$feedback->id, 'typ'=>'pagebreak'), 'position')) {
- $pagebreaks = array_values($pagebreaks);
- $firstpagebreak = $pagebreaks[0];
- }else {
- $firstpagebreak = false;
- }
- $maxitemcount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
-
- //get the values of completeds before done. Anonymous user can not get these values.
- if((!isset($SESSION->feedback->is_started)) AND (!isset($savereturn)) AND ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO)) {
- if(!$feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid)) {
- if($feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid)) {
- //copy the values to feedback_valuetmp create a completedtmp
- $feedbackcompletedtmp = feedback_set_tmp_values($feedbackcompleted);
- }
+ //get the first pagebreak
+ $params = array('feedback' => $feedback->id, 'typ' => 'pagebreak');
+ if ($pagebreaks = $DB->get_records('feedback_item', $params, 'position')) {
+ $pagebreaks = array_values($pagebreaks);
+ $firstpagebreak = $pagebreaks[0];
+ } else {
+ $firstpagebreak = false;
+ }
+ $maxitemcount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
+
+ //get the values of completeds before done. Anonymous user can not get these values.
+ if ((!isset($SESSION->feedback->is_started)) AND
+ (!isset($savereturn)) AND
+ ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO)) {
+
+ $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid);
+ if (!$feedbackcompletedtmp) {
+ $feedbackcompleted = feedback_get_current_completed($feedback->id, false, $courseid);
+ if ($feedbackcompleted) {
+ //copy the values to feedback_valuetmp create a completedtmp
+ $feedbackcompletedtmp = feedback_set_tmp_values($feedbackcompleted);
}
- }else {
- $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid);
}
+ } else {
+ $feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid);
+ }
- /// Print the main part of the page
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////
- $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
- if($courseid > 0) {
- $analysisurl->param('courseid', $courseid);
+ /// Print the main part of the page
+ ///////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////////
+ $analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id));
+ if ($courseid > 0) {
+ $analysisurl->param('courseid', $courseid);
+ }
+ echo $OUTPUT->heading(format_text($feedback->name));
+
+ if ( (intval($feedback->publish_stats) == 1) AND
+ ( has_capability('mod/feedback:viewanalysepage', $context)) AND
+ !( has_capability('mod/feedback:viewreports', $context)) ) {
+
+ $params = array('userid' => $USER->id, 'feedback' => $feedback->id);
+ if ($multiple_count = $DB->count_records('feedback_tracking', $params)) {
+ echo $OUTPUT->box_start('mdl-align');
+ echo '<a href="'.$analysisurl->out().'">';
+ echo get_string('completed_feedbacks', 'feedback').'</a>';
+ echo $OUTPUT->box_end();
}
- echo $OUTPUT->heading(format_text($feedback->name));
-
- if( (intval($feedback->publish_stats) == 1) AND
- ( has_capability('mod/feedback:viewanalysepage', $context)) AND
- !( has_capability('mod/feedback:viewreports', $context)) ) {
- if($multiple_count = $DB->count_records('feedback_tracking', array('userid'=>$USER->id, 'feedback'=>$feedback->id))) {
- echo $OUTPUT->box_start('mdl-align');
- echo '<a href="'.$analysisurl->out().'">';
+ }
+
+ if (isset($savereturn) && $savereturn == 'saved') {
+ if ($feedback->page_after_submit) {
+ echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
+ echo format_text($feedback->page_after_submit,
+ $feedback->page_after_submitformat,
+ array('overflowdiv' => true));
+ echo $OUTPUT->box_end();
+ } else {
+ echo '<p align="center">';
+ echo '<b><font color="green">';
+ echo get_string('entries_saved', 'feedback');
+ echo '</font></b>';
+ echo '</p>';
+ if ( intval($feedback->publish_stats) == 1) {
+ echo '<p align="center"><a href="'.$analysisurl->out().'">';
echo get_string('completed_feedbacks', 'feedback').'</a>';
- echo $OUTPUT->box_end();
+ echo '</p>';
}
}
- if(isset($savereturn) && $savereturn == 'saved') {
- if($feedback->page_after_submit) {
- echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
- echo format_text($feedback->page_after_submit, $feedback->page_after_submitformat, array('overflowdiv'=>true));
- echo $OUTPUT->box_end();
+ if ($feedback->site_after_submit) {
+ $url = feedback_encode_target_url($feedback->site_after_submit);
+ } else {
+ if ($courseid) {
+ if ($courseid == SITEID) {
+ $url = $CFG->wwwroot;
+ } else {
+ $url = $CFG->wwwroot.'/course/view.php?id='.$courseid;
+ }
} else {
- echo '<p align="center"><b><font color="green">'.get_string('entries_saved','feedback').'</font></b></p>';
- if( intval($feedback->publish_stats) == 1) {
- echo '<p align="center"><a href="'.$analysisurl->out().'">';
- echo get_string('completed_feedbacks', 'feedback').'</a>';
- echo '</p>';
+ if ($course->id == SITEID) {
+ $url = $CFG->wwwroot;
+ } else {
+ $url = $CFG->wwwroot.'/course/view.php?id='.$course->id;
}
}
+ }
+ echo $OUTPUT->continue_button($url);
+ } else {
+ if (isset($savereturn) && $savereturn == 'failed') {
+ echo $OUTPUT->box_start('mform error');
+ echo get_string('saving_failed', 'feedback');
+ echo $OUTPUT->box_end();
+ }
- if($feedback->site_after_submit) {
- echo $OUTPUT->continue_button(feedback_encode_target_url($feedback->site_after_submit));
- }else {
- if($courseid) {
- if($courseid == SITEID) {
- echo $OUTPUT->continue_button($CFG->wwwroot);
- }else {
- echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$courseid);
- }
- }else {
- if($course->id == SITEID) {
- echo $OUTPUT->continue_button($CFG->wwwroot);
- } else {
- echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
- }
- }
- }
- }else {
- if(isset($savereturn) && $savereturn == 'failed') {
- echo $OUTPUT->box_start('mform error');
- echo get_string('saving_failed','feedback');
- echo $OUTPUT->box_end();
- }
+ if (isset($savereturn) && $savereturn == 'missing') {
+ echo $OUTPUT->box_start('mform error');
+ echo get_string('saving_failed_because_missing_or_false_values', 'feedback');
+ echo $OUTPUT->box_end();
+ }
- if(isset($savereturn) && $savereturn == 'missing') {
- echo $OUTPUT->box_start('mform error');
- echo get_string('saving_failed_because_missing_or_false_values','feedback');
- echo $OUTPUT->box_end();
+ //print the items
+ if (is_array($feedbackitems)) {
+ echo $OUTPUT->box_start('feedback_form');
+ echo '<form action="complete.php" method="post" onsubmit=" ">';
+ echo '<fieldset>';
+ echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
+ echo $OUTPUT->box_start('feedback_anonymousinfo');
+ switch ($feedback->anonymous) {
+ case FEEDBACK_ANONYMOUS_YES:
+ echo '<input type="hidden" name="anonymous" value="1" />';
+ $inputvalue = 'value="'.FEEDBACK_ANONYMOUS_YES.'"';
+ echo '<input type="hidden" name="anonymous_response" '.$inputvalue.' />';
+ echo get_string('mode', 'feedback').': '.get_string('anonymous', 'feedback');
+ break;
+ case FEEDBACK_ANONYMOUS_NO:
+ echo '<input type="hidden" name="anonymous" value="0" />';
+ $inputvalue = 'value="'.FEEDBACK_ANONYMOUS_NO.'"';
+ echo '<input type="hidden" name="anonymous_response" '.$inputvalue.' />';
+ echo get_string('mode', 'feedback').': ';
+ echo get_string('non_anonymous', 'feedback');
+ break;
}
+ echo $OUTPUT->box_end();
+ //check, if there exists required-elements
+ $params = array('feedback' => $feedback->id, 'required' => 1);
+ $countreq = $DB->count_records('feedback_item', $params);
+ if ($countreq > 0) {
+ echo '<span class="feedback_required_mark">(*)';
+ echo get_string('items_are_required', 'feedback');
+ echo '</span>';
+ }
+ echo $OUTPUT->box_start('feedback_items');
+
+ unset($startitem);
+ $select = 'feedback = ? AND hasvalue = 1 AND position < ?';
+ $params = array($feedback->id, $startposition);
+ $itemnr = $DB->count_records_select('feedback_item', $select, $params);
+ $lastbreakposition = 0;
+ $align = right_to_left() ? 'right' : 'left';
+
+ foreach ($feedbackitems as $feedbackitem) {
+ if (!isset($startitem)) {
+ //avoid showing double pagebreaks
+ if ($feedbackitem->typ == 'pagebreak') {
+ continue;
+ }
+ $startitem = $feedbackitem;
+ }
- //print the items
- if(is_array($feedbackitems)){
- // echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
- echo $OUTPUT->box_start('feedback_form');
- echo '<form action="complete.php" method="post" onsubmit=" ">';
- echo '<fieldset>';
- echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
- echo $OUTPUT->box_start('feedback_anonymousinfo');
- switch ($feedback->anonymous) {
- case FEEDBACK_ANONYMOUS_YES:
- echo '<input type="hidden" name="anonymous" value="1" />';
- echo '<input type="hidden" name="anonymous_response" value="'.FEEDBACK_ANONYMOUS_YES.'" />';
- echo get_string('mode', 'feedback').': '.get_string('anonymous', 'feedback');
- break;
- case FEEDBACK_ANONYMOUS_NO:
- echo '<input type="hidden" name="anonymous" value="0" />';
- echo '<input type="hidden" name="anonymous_response" value="'.FEEDBACK_ANONYMOUS_NO.'" />';
- echo get_string('mode', 'feedback').': '.get_string('non_anonymous', 'feedback');
- break;
+ if ($feedbackitem->dependitem > 0) {
+ //chech if the conditions are ok
+ $fb_compare_value = feedback_compare_item_value($feedbackcompletedtmp->id,
+ $feedbackitem->dependitem,
+ $feedbackitem->dependvalue,
+ true);
+ if (!isset($feedbackcompletedtmp->id) OR !$fb_compare_value) {
+ $lastitem = $feedbackitem;
+ $lastbreakposition = $feedbackitem->position;
+ continue;
+ }
}
- echo $OUTPUT->box_end();
- //check, if there exists required-elements
- $countreq = $DB->count_records('feedback_item', array('feedback'=>$feedback->id, 'required'=>1));
- if($countreq > 0) {
- echo '<span class="feedback_required_mark">(*)' . get_string('items_are_required', 'feedback') . '</span>';
+
+ if ($feedbackitem->dependitem > 0) {
+ $dependstyle = ' feedback_complete_depend';
+ } else {
+ $dependstyle = '';
}
- echo $OUTPUT->box_start('feedback_items');
-
- unset($startitem);
- $itemnr = $DB->count_records_select('feedback_item', 'feedback = ? AND hasvalue = 1 AND position < ?', array($feedback->id, $startposition));
- $lastbreakposition = 0;
- $align = right_to_left() ? 'right' : 'left';
-
- foreach($feedbackitems as $feedbackitem){
- if(!isset($startitem)) {
- //avoid showing double pagebreaks
- if($feedbackitem->typ == 'pagebreak') {
- continue;
- }
- $startitem = $feedbackitem;
- }
- if($feedbackitem->dependitem > 0) {
- //chech if the conditions are ok
- if(!isset($feedbackcompletedtmp->id) OR !feedback_compare_item_value($feedbackcompletedtmp->id, $feedbackitem->dependitem, $feedbackitem->dependvalue, true)) {
- $lastitem = $feedbackitem;
- $lastbreakposition = $feedbackitem->position;
- continue;
- }
+ echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
+ $value = '';
+ //get the value
+ $frmvaluename = $feedbackitem->typ . '_'. $feedbackitem->id;
+ if (isset($savereturn)) {
+ if (isset($formdata->{$frmvaluename})) {
+ $value = $formdata->{$frmvaluename};
+ } else {
+ $value = null;
}
-
- if($feedbackitem->dependitem > 0) {
- $dependstyle = ' feedback_complete_depend';
- }else {
- $dependstyle = '';
+ } else {
+ if (isset($feedbackcompletedtmp->id)) {
+ $value = feedback_get_item_value($feedbackcompletedtmp->id,
+ $feedbackitem->id,
+ true);
}