mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-29804 - Clean up Feedback modules coding style
This commit is contained in:
parent
38e9a1cc79
commit
9c5bc7a580
@ -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
|
||||
|
||||
|
@ -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 @@ if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
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 @@ if( !( ((intval($feedback->publish_stats) == 1) AND
|
||||
$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 @@ if( has_capability('mod/feedback:viewreports', $context) ) {
|
||||
$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();
|
||||
|
@ -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 @@ if ($searchcourse !== '') {
|
||||
}
|
||||
$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 @@ if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
|
||||
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 @@ $PAGE->set_title(format_string($feedback->name));
|
||||
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 @@ $completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $c
|
||||
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 ($courseitemfilter > 0) {
|
||||
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 @@ if ($courseitemfilter > 0) {
|
||||
$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 @@ if ($courseitemfilter > 0) {
|
||||
} 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 @@ if ($courseitemfilter > 0) {
|
||||
|
||||
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>';
|
||||
}
|
||||
|
@ -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->username = get_string('username');
|
||||
$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 @@ $filename = "feedback.xls";
|
||||
$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 @@ $xlsFormats->procent = $workbook->add_format(array(
|
||||
$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 @@ $completeds = feedback_get_completeds_group($feedback, $mygroupid, $coursefilter
|
||||
//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 @@ exit;
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
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;
|
||||
if (!$items) {
|
||||
return;
|
||||
}
|
||||
$col_offset = 0;
|
||||
|
||||
// $worksheet->setFormat('<l><f><ru2>');
|
||||
$worksheet->write_string($row_offset + 1, $col_offset, $fstring->idnumber, $xls_formats->head2);
|
||||
$col_offset++;
|
||||
|
||||
$worksheet->write_string($rowOffset + 1, $colOffset, $fstring->idnumber, $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->username, $xlsFormats->head2);
|
||||
$colOffset++;
|
||||
$worksheet->write_string($row_offset + 1, $col_offset, $fstring->fullname, $xls_formats->head2);
|
||||
$col_offset++;
|
||||
|
||||
$worksheet->write_string($rowOffset + 1, $colOffset, $fstring->fullname, $xlsFormats->head2);
|
||||
$colOffset++;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 @@ class backup_feedback_activity_task extends backup_activity_task {
|
||||
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]+)/";
|
||||
|
@ -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
|
||||
|
@ -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 @@ class backup_feedback_activity_structure_step extends backup_activity_structure_
|
||||
'timemodified',
|
||||
'completionsubmit'));
|
||||
|
||||
|
||||
$completeds = new backup_nested_element('completeds');
|
||||
|
||||
$completed = new backup_nested_element('completed', array('id'), array(
|
||||
@ -92,7 +90,6 @@ class backup_feedback_activity_structure_step extends backup_activity_structure_
|
||||
'completed',
|
||||
'value'));
|
||||
|
||||
|
||||
// Build the tree
|
||||
$feedback->add_child($items);
|
||||
$items->add_child($item);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,68 +1,25 @@
|
||||
<?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 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);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
* 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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,459 +1,538 @@
|
||||
<?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 the form so an anonymous user can fill out the feedback on the mainsite
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
/**
|
||||
* prints the form so an anonymous user can fill out the 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");
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
feedback_init_feedback_session();
|
||||
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);
|
||||
$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);
|
||||
|
||||
$url = new moodle_url('/mod/feedback/complete_guest.php', array('id'=>$id));
|
||||
if ($completedid !== false) {
|
||||
$url->param('completedid', $completedid);
|
||||
}
|
||||
if ($preservevalues !== 0) {
|
||||
$url->param('preservevalues', $preservevalues);
|
||||
}
|
||||
if ($courseid !== false) {
|
||||
$url->param('courseid', $courseid);
|
||||
}
|
||||
if ($gopage !== -1) {
|
||||
$url->param('gopage', $gopage);
|
||||
}
|
||||
if ($lastpage !== false) {
|
||||
$url->param('lastpage', $lastpage);
|
||||
}
|
||||
if ($startitempos !== 0) {
|
||||
$url->param('startitempos', $startitempos);
|
||||
}
|
||||
if ($lastitempos !== 0) {
|
||||
$url->param('lastitempos', $lastitempos);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$url = new moodle_url('/mod/feedback/complete_guest.php', array('id'=>$id));
|
||||
if ($completedid !== false) {
|
||||
$url->param('completedid', $completedid);
|
||||
}
|
||||
if ($preservevalues !== 0) {
|
||||
$url->param('preservevalues', $preservevalues);
|
||||
}
|
||||
if ($courseid !== false) {
|
||||
$url->param('courseid', $courseid);
|
||||
}
|
||||
if ($gopage !== -1) {
|
||||
$url->param('gopage', $gopage);
|
||||
}
|
||||
if ($lastpage !== false) {
|
||||
$url->param('lastpage', $lastpage);
|
||||
}
|
||||
if ($startitempos !== 0) {
|
||||
$url->param('startitempos', $startitempos);
|
||||
}
|
||||
if ($lastitempos !== 0) {
|
||||
$url->param('lastitempos', $lastitempos);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
$highlightrequired = false;
|
||||
$highlightrequired = false;
|
||||
|
||||
if(($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
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('parameters_missing', 'feedback');
|
||||
}
|
||||
} else {
|
||||
$gonextpage = $gopreviouspage = false;
|
||||
}
|
||||
|
||||
//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 (! $cm = get_coursemodule_from_id('feedback', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
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('parameters_missing', 'feedback');
|
||||
}
|
||||
}else {
|
||||
$gonextpage = $gopreviouspage = false;
|
||||
}
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
$feedback_complete_cap = false;
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
if (isset($CFG->feedback_allowfullanonymous)
|
||||
AND $CFG->feedback_allowfullanonymous
|
||||
AND $course->id == SITEID
|
||||
AND (!$courseid OR $courseid == SITEID)
|
||||
AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES ) {
|
||||
$feedback_complete_cap = true;
|
||||
}
|
||||
|
||||
$feedback_complete_cap = false;
|
||||
|
||||
if(isset($CFG->feedback_allowfullanonymous)
|
||||
//check whether the feedback is anonymous
|
||||
if (isset($CFG->feedback_allowfullanonymous)
|
||||
AND $CFG->feedback_allowfullanonymous
|
||||
AND $course->id == SITEID
|
||||
AND (!$courseid OR $courseid == SITEID)
|
||||
AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES ) {
|
||||
$feedback_complete_cap = true;
|
||||
AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES
|
||||
AND $course->id == SITEID ) {
|
||||
$feedback_complete_cap = true;
|
||||
}
|
||||
if ($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
|
||||
print_error('feedback_is_not_for_anonymous', 'feedback');
|
||||
}
|
||||
|
||||
//check whether the user has a session
|
||||
// there used to be a sesskey test - this could not work - sorry
|
||||
|
||||
//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 = $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
|
||||
}
|
||||
|
||||
if (!$feedback_complete_cap) {
|
||||
print_error('error');
|
||||
}
|
||||
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->set_cm($cm, $course); // set's up global $COURSE
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$urlparams = array('id'=>$course->id);
|
||||
$PAGE->navbar->add($strfeedbacks, new moodle_url('/mod/feedback/index.php', $urlparams));
|
||||
$PAGE->navbar->add(format_string($feedback->name));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
//ishidden check.
|
||||
//hidden feedbacks except feedbacks on mainsite are only accessible with related capabilities
|
||||
if ((empty($cm->visible) AND
|
||||
!has_capability('moodle/course:viewhiddenactivities', $context)) AND
|
||||
$course->id != 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;
|
||||
}
|
||||
|
||||
//check whether the feedback is anonymous
|
||||
if(isset($CFG->feedback_allowfullanonymous)
|
||||
AND $CFG->feedback_allowfullanonymous
|
||||
AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES
|
||||
AND $course->id == SITEID ) {
|
||||
$feedback_complete_cap = true;
|
||||
}
|
||||
if($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
|
||||
print_error('feedback_is_not_for_anonymous', 'feedback');
|
||||
}
|
||||
|
||||
//check whether the user has a session
|
||||
// there used to be a sesskey test - this could not work - sorry
|
||||
|
||||
//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 = $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
|
||||
}
|
||||
|
||||
if(!$feedback_complete_cap) {
|
||||
print_error('error');
|
||||
}
|
||||
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->set_cm($cm, $course); // set's up global $COURSE
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$PAGE->navbar->add($strfeedbacks, new moodle_url('/mod/feedback/index.php', array('id'=>$course->id)));
|
||||
$PAGE->navbar->add(format_string($feedback->name));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
//ishidden check. hidden feedbacks except feedbacks on mainsite are only accessible with related capabilities
|
||||
if ((empty($cm->visible) AND
|
||||
!has_capability('moodle/course:viewhiddenactivities', $context)) 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)) {
|
||||
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;
|
||||
}
|
||||
|
||||
//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 = $DB->get_record('feedback_tracking', array('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) {
|
||||
print_error('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', 'error', $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
//check, if all required items have a value
|
||||
if(feedback_check_values($startitempos, $lastitempos)) {
|
||||
$userid = $USER->id; //arb
|
||||
if($completedid = feedback_save_guest_values(sesskey())){
|
||||
add_to_log($course->id, 'feedback', 'startcomplete', 'view.php?id='.$cm->id, $feedback->id); //arb: log even guest submissions or at least the startcomplete since the other add log event is elsewhere
|
||||
//check, if all required items have a value
|
||||
if (feedback_check_values($startitempos, $lastitempos)) {
|
||||
$userid = $USER->id; //arb
|
||||
if ($completedid = feedback_save_guest_values(sesskey())) {
|
||||
add_to_log($course->id,
|
||||
'feedback',
|
||||
'startcomplete',
|
||||
'view.php?id='.$cm->id,
|
||||
$feedback->id);
|
||||
|
||||
if(!$gonextpage AND !$gopreviouspage) $preservevalues = false;//es kann gespeichert werden
|
||||
|
||||
}else {
|
||||
$savereturn = 'failed';
|
||||
if(isset($lastpage)) {
|
||||
$gopage = $lastpage;
|
||||
}else {
|
||||
print_error('parameters_missing', 'feedback');
|
||||
}
|
||||
//now it can be saved
|
||||
if (!$gonextpage AND !$gopreviouspage) {
|
||||
$preservevalues = false;
|
||||
}
|
||||
}else {
|
||||
$savereturn = 'missing';
|
||||
$highlightrequired = true;
|
||||
if(isset($lastpage)) {
|
||||
|
||||
} else {
|
||||
$savereturn = 'failed';
|
||||
if (isset($lastpage)) {
|
||||
$gopage = $lastpage;
|
||||
}else {
|
||||
} else {
|
||||
print_error('parameters_missing', 'feedback');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$savereturn = 'missing';
|
||||
$highlightrequired = true;
|
||||
if (isset($lastpage)) {
|
||||
$gopage = $lastpage;
|
||||
} else {
|
||||
print_error('parameters_missing', 'feedback');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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)
|
||||
//saving the items
|
||||
if ($savevalues AND !$preservevalues) {
|
||||
//exists there any pagebreak, so there are values in the feedback_valuetmp
|
||||
//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)
|
||||
$userid = $USER->id;
|
||||
|
||||
$feedbackcompletedtmp = $DB->get_record('feedback_completedtmp', array('id'=>$completedid));
|
||||
$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 if($new_completed_id = feedback_save_tmp_values($feedbackcompletedtmp, false, $userid)) {
|
||||
//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, false, $userid);
|
||||
if ($new_completed_id) {
|
||||
$savereturn = 'saved';
|
||||
feedback_send_email_anonym($cm, $feedback, $course, $userid);
|
||||
unset($SESSION->feedback->is_started);
|
||||
|
||||
}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;
|
||||
//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));
|
||||
$feedbackcompletedtmp = feedback_get_current_completed($feedback->id,
|
||||
true,
|
||||
$courseid,
|
||||
sesskey());
|
||||
|
||||
/// 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)) ) {
|
||||
echo $OUTPUT->box_start('mdl-align');
|
||||
echo '<a href="'.$analysisurl->out().'">';
|
||||
echo get_string('completed_feedbacks', 'feedback');
|
||||
echo '</a>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
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"><b><font color="green">';
|
||||
echo get_string('entries_saved', 'feedback');
|
||||
echo '</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>';
|
||||
}
|
||||
}
|
||||
$maxitemcount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
$feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid, sesskey());
|
||||
|
||||
/// 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);
|
||||
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 {
|
||||
if ($course->id == SITEID) {
|
||||
$url = $CFG->wwwroot;
|
||||
} else {
|
||||
$url = $CFG->wwwroot.'/course/view.php?id='.$course->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)) ) {
|
||||
echo $OUTPUT->box_start('mdl-align');
|
||||
echo '<a href="'.$analysisurl->out().'">'.get_string('completed_feedbacks', 'feedback').'</a>';
|
||||
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(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"><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($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();
|
||||
}
|
||||
|
||||
//print the items
|
||||
if(is_array($feedbackitems)){
|
||||
// echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo $OUTPUT->box_start('feedback_form');
|
||||
echo '<form action="complete_guest.php" method="post" onsubmit=" ">';
|
||||
echo '<fieldset>';
|
||||
echo '<input type="hidden" name="anonymous" value="0" />';
|
||||
echo '<input type="hidden" name="anonymous_response" value="'.FEEDBACK_ANONYMOUS_YES.'" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
//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>';
|
||||
}
|
||||
echo $OUTPUT->box_start('feedback_items');
|
||||
|
||||
$startitem = null;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
if($feedbackitem->dependitem > 0) {
|
||||
$dependstyle = ' feedback_complete_depend';
|
||||
}else {
|
||||
$dependstyle = '';
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
|
||||
$value = '';
|
||||
//get the value
|
||||
$frmvaluename = $feedbackitem->typ . '_'. $feedbackitem->id;
|
||||
if(isset($savereturn)) {
|
||||
$value = isset($formdata->{$frmvaluename})?$formdata->{$frmvaluename}:NULL;
|
||||
}else {
|
||||
if(isset($feedbackcompletedtmp->id)) {
|
||||
$value = feedback_get_item_value($feedbackcompletedtmp->id, $feedbackitem->id, sesskey());
|
||||
}
|
||||
}
|
||||
if($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if($feedbackitem->typ != 'pagebreak') {
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$lastbreakposition = $feedbackitem->position; //last item-pos (item or pagebreak)
|
||||
if($feedbackitem->typ == 'pagebreak'){
|
||||
break;
|
||||
}else {
|
||||
$lastitem = $feedbackitem;
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
||||
echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'" />';
|
||||
echo '<input type="hidden" name="lastpage" value="'.$gopage.'" />';
|
||||
echo '<input type="hidden" name="completedid" value="'.(isset($feedbackcompletedtmp->id)?$feedbackcompletedtmp->id:'').'" />';
|
||||
echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
|
||||
echo '<input type="hidden" name="preservevalues" value="1" />';
|
||||
if(isset($startitem)) {
|
||||
echo '<input type="hidden" name="startitempos" value="'. $startitem->position . '" />';
|
||||
echo '<input type="hidden" name="lastitempos" value="'. $lastitem->position . '" />';
|
||||
}
|
||||
|
||||
if($ispagebreak AND $lastbreakposition > $firstpagebreak->position) {
|
||||
echo '<input name="gopreviouspage" type="submit" value="'.get_string('previous_page','feedback').'" />';
|
||||
}
|
||||
if($lastbreakposition < $maxitemcount){
|
||||
echo '<input name="gonextpage" type="submit" value="'.get_string('next_page','feedback').'" />';
|
||||
}
|
||||
if($lastbreakposition >= $maxitemcount) { //last page
|
||||
echo '<input name="savevalues" type="submit" value="'.get_string('save_entries','feedback').'" />';
|
||||
}
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->box_start('feedback_complete_cancel');
|
||||
if($courseid) {
|
||||
echo '<form action="'.$CFG->wwwroot.'/course/view.php?id='.$courseid.'" method="post" onsubmit=" ">';
|
||||
}else{
|
||||
if($course->id == SITEID) {
|
||||
echo '<form action="'.$CFG->wwwroot.'" method="post" onsubmit=" ">';
|
||||
} else {
|
||||
echo '<form action="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'" method="post" onsubmit=" ">';
|
||||
}
|
||||
}
|
||||
echo '<fieldset>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
|
||||
echo '<button type="submit">'.get_string('cancel').'</button>';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
echo $OUTPUT->box_end();
|
||||
$SESSION->feedback->is_started = true;
|
||||
}
|
||||
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_guest.php" method="post" onsubmit=" ">';
|
||||
echo '<fieldset>';
|
||||
echo '<input type="hidden" name="anonymous" value="0" />';
|
||||
$inputvalue = 'value="'.FEEDBACK_ANONYMOUS_YES.'"';
|
||||
echo '<input type="hidden" name="anonymous_response" '.$inputvalue.' />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
//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');
|
||||
|
||||
$startitem = null;
|
||||
$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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
if ($feedbackitem->dependitem > 0) {
|
||||
$dependstyle = ' feedback_complete_depend';
|
||||
} else {
|
||||
$dependstyle = '';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
if (isset($feedbackcompletedtmp->id)) {
|
||||
$value = feedback_get_item_value($feedbackcompletedtmp->id,
|
||||
$feedbackitem->id,
|
||||
sesskey());
|
||||
}
|
||||
}
|
||||
if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if ($feedbackitem->typ != 'pagebreak') {
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
feedback_print_item_complete($feedbackitem, $value, $highlightrequired);
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$lastbreakposition = $feedbackitem->position; //last item-pos (item or pagebreak)
|
||||
if ($feedbackitem->typ == 'pagebreak') {
|
||||
break;
|
||||
} else {
|
||||
$lastitem = $feedbackitem;
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
||||
echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'" />';
|
||||
echo '<input type="hidden" name="lastpage" value="'.$gopage.'" />';
|
||||
if (isset($feedbackcompletedtmp->id)) {
|
||||
$inputvalue = 'value="'.$feedbackcompletedtmp->id;
|
||||
} else {
|
||||
$inputvalue = 'value=""';
|
||||
}
|
||||
echo '<input type="hidden" name="completedid" '.$inputvalue.' />';
|
||||
echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
|
||||
echo '<input type="hidden" name="preservevalues" value="1" />';
|
||||
if (isset($startitem)) {
|
||||
echo '<input type="hidden" name="startitempos" value="'.$startitem->position.'" />';
|
||||
echo '<input type="hidden" name="lastitempos" value="'.$lastitem->position.'" />';
|
||||
}
|
||||
|
||||
if ($ispagebreak AND $lastbreakposition > $firstpagebreak->position) {
|
||||
$inputvalue = 'value="'.get_string('previous_page', 'feedback').'"';
|
||||
echo '<input name="gopreviouspage" type="submit" '.$inputvalue.' />';
|
||||
}
|
||||
if ($lastbreakposition < $maxitemcount) {
|
||||
$inputvalue = 'value="'.get_string('next_page', 'feedback').'"';
|
||||
echo '<input name="gonextpage" type="submit" '.$inputvalue.' />';
|
||||
}
|
||||
if ($lastbreakposition >= $maxitemcount) { //last page
|
||||
$inputvalue = 'value="'.get_string('save_entries', 'feedback').'"';
|
||||
echo '<input name="savevalues" type="submit" '.$inputvalue.' />';
|
||||
}
|
||||
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->box_start('feedback_complete_cancel');
|
||||
if ($courseid) {
|
||||
$action = 'action="'.$CFG->wwwroot.'/course/view.php?id='.$courseid.'"';
|
||||
} else {
|
||||
if ($course->id == SITEID) {
|
||||
$action = 'action="'.$CFG->wwwroot.'"';
|
||||
} else {
|
||||
$action = 'action="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'"';
|
||||
}
|
||||
}
|
||||
echo '<form '.$action.' method="post" onsubmit=" ">';
|
||||
echo '<fieldset>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
|
||||
echo '<button type="submit">'.get_string('cancel').'</button>';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
echo $OUTPUT->box_end();
|
||||
$SESSION->feedback->is_started = true;
|
||||
}
|
||||
}else {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter');
|
||||
echo '<h2><font color="red">'.get_string('this_feedback_is_already_submitted', 'feedback').'</font></h2>';
|
||||
echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
/// Finish the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
} else {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter');
|
||||
echo '<h2><font color="red">';
|
||||
echo get_string('this_feedback_is_already_submitted', 'feedback');
|
||||
echo '</font></h2>';
|
||||
echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
/// Finish the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?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/>.
|
||||
|
||||
//
|
||||
// Capability definitions for the feedback module.
|
||||
//
|
||||
|
@ -1,9 +1,23 @@
|
||||
<?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/>.
|
||||
|
||||
function xmldb_feedback_install() {
|
||||
global $DB;
|
||||
|
||||
/// Disable this module by default (because it's not technically part of Moodle 2.0)
|
||||
/// Disable this module by default (because it's not technically part of Moodle 2.0)
|
||||
$DB->set_field('modules', 'visible', 0, array('name'=>'feedback'));
|
||||
|
||||
}
|
||||
|
@ -168,4 +168,4 @@
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
</TABLES>
|
||||
</XMLDB>
|
||||
</XMLDB>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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/>.
|
||||
|
||||
// This file keeps track of upgrades to
|
||||
// the feedback module
|
||||
@ -31,15 +45,18 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
$table = new xmldb_table('feedback_completedtmp');
|
||||
|
||||
$field = new xmldb_field('id');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, true, null, null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('feedback');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('userid');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('guestid');
|
||||
@ -47,7 +64,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('timemodified');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$key = new xmldb_key('PRIMARY');
|
||||
@ -65,23 +83,28 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
$table = new xmldb_table('feedback_valuetmp');
|
||||
|
||||
$field = new xmldb_field('id');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, true, null, null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, true, null, null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('course_id');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('item');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('completed');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('tmp_completed');
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '0', null);
|
||||
$table->addField($field);
|
||||
|
||||
$field = new xmldb_field('value');
|
||||
@ -105,25 +128,29 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
/// Define field random_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completed');
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
/// Launch add field1
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// Define field anonymous_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completed');
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// Define field random_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completedtmp');
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
$field = new xmldb_field('random_response', XMLDB_TYPE_INTEGER, '10',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '0', null);
|
||||
/// Launch add field1
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// Define field anonymous_response to be added to feedback_completed
|
||||
$table = new xmldb_table('feedback_completedtmp');
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
$field = new xmldb_field('anonymous_response', XMLDB_TYPE_INTEGER, '1',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -135,7 +162,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
// public is a reserved word on Oracle
|
||||
|
||||
$table = new xmldb_table('feedback_template');
|
||||
$field = new xmldb_field('ispublic', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, false, '1', null);
|
||||
$field = new xmldb_field('ispublic', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED,
|
||||
XMLDB_NOTNULL, false, '1', null);
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
@ -144,7 +172,9 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2008042400) { //New version in version.php
|
||||
if ($all_nonanonymous_feedbacks = $DB->get_records('feedback', array('anonymous'=>2))) {
|
||||
$update_sql = 'UPDATE {feedback_completed} SET anonymous_response = 2 WHERE feedback = ';
|
||||
$update_sql = 'UPDATE {feedback_completed}
|
||||
SET anonymous_response = 2
|
||||
WHERE feedback = ';
|
||||
foreach ($all_nonanonymous_feedbacks as $fb) {
|
||||
$DB->execute($update_sql.$fb->id);
|
||||
}
|
||||
@ -153,20 +183,34 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2008042401) { //New version in version.php
|
||||
$concat_radio = $DB->sql_concat("'r>>>>>'",'presentation');
|
||||
$concat_check = $DB->sql_concat("'c>>>>>'",'presentation');
|
||||
$concat_dropdown = $DB->sql_concat("'d>>>>>'",'presentation');
|
||||
$concat_radio = $DB->sql_concat("'r>>>>>'", 'presentation');
|
||||
$concat_check = $DB->sql_concat("'c>>>>>'", 'presentation');
|
||||
$concat_dropdown = $DB->sql_concat("'d>>>>>'", 'presentation');
|
||||
|
||||
$update_sql1 = "UPDATE {feedback_item} SET presentation = ".$concat_radio." WHERE typ IN('radio','radiorated')";
|
||||
$update_sql2 = "UPDATE {feedback_item} SET presentation = ".$concat_dropdown." WHERE typ IN('dropdown','dropdownrated')";
|
||||
$update_sql3 = "UPDATE {feedback_item} SET presentation = ".$concat_check." WHERE typ = 'check'";
|
||||
$update_sql1 = "UPDATE {feedback_item}
|
||||
SET presentation = ".$concat_radio."
|
||||
WHERE typ IN('radio','radiorated')";
|
||||
|
||||
$update_sql2 = "UPDATE {feedback_item}
|
||||
SET presentation = ".$concat_dropdown."
|
||||
WHERE typ IN('dropdown','dropdownrated')";
|
||||
|
||||
$update_sql3 = "UPDATE {feedback_item}
|
||||
SET presentation = ".$concat_check."
|
||||
WHERE typ = 'check'";
|
||||
|
||||
$DB->execute($update_sql1);
|
||||
$DB->execute($update_sql2);
|
||||
$DB->execute($update_sql3);
|
||||
|
||||
$update_sql1 = "UPDATE {feedback_item} SET typ = 'multichoice' WHERE typ IN('radio','check','dropdown')";
|
||||
$update_sql2 = "UPDATE {feedback_item} SET typ = 'multichoicerated' WHERE typ IN('radiorated','dropdownrated')";
|
||||
$update_sql1 = "UPDATE {feedback_item}
|
||||
SET typ = 'multichoice'
|
||||
WHERE typ IN('radio','check','dropdown')";
|
||||
|
||||
$update_sql2 = "UPDATE {feedback_item}
|
||||
SET typ = 'multichoicerated'
|
||||
WHERE typ IN('radiorated','dropdownrated')";
|
||||
|
||||
$DB->execute($update_sql1);
|
||||
$DB->execute($update_sql2);
|
||||
|
||||
@ -176,7 +220,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($oldversion < 2008042900) {
|
||||
/// Define field autonumbering to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('autonumbering', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'multiple_submit');
|
||||
$field = new xmldb_field('autonumbering', XMLDB_TYPE_INTEGER, '1',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '1', 'multiple_submit');
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -186,7 +231,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($oldversion < 2008050104) {
|
||||
/// Define field site_after_submit to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('site_after_submit', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'autonumbering');
|
||||
$field = new xmldb_field('site_after_submit', XMLDB_TYPE_CHAR, '255',
|
||||
null, null, false, '', 'autonumbering');
|
||||
/// Launch add field2
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -203,7 +249,11 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2008073002) {
|
||||
$update_sql = "UPDATE {feedback_item} SET presentation = '-|-' WHERE " . $DB->sql_compare_text('presentation') . " = '0|0' AND typ = 'numeric'";
|
||||
$update_sql = "UPDATE {feedback_item}
|
||||
SET presentation = '-|-'
|
||||
WHERE " . $DB->sql_compare_text('presentation') . " = '0|0' AND
|
||||
typ = 'numeric'";
|
||||
|
||||
$DB->execute($update_sql);
|
||||
|
||||
upgrade_mod_savepoint(true, 2008073002, 'feedback');
|
||||
@ -221,34 +271,37 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
if ($oldversion < 2009042000) {
|
||||
|
||||
/// Rename field summary on table feedback to intro
|
||||
/// Rename field summary on table feedback to intro
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, 'name');
|
||||
$field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null,
|
||||
XMLDB_NOTNULL, null, null, 'name');
|
||||
|
||||
/// Launch rename field summary
|
||||
/// Launch rename field summary
|
||||
$dbman->rename_field($table, $field, 'intro');
|
||||
|
||||
/// feedback savepoint reached
|
||||
/// feedback savepoint reached
|
||||
upgrade_mod_savepoint(true, 2009042000, 'feedback');
|
||||
}
|
||||
|
||||
if ($oldversion < 2009042001) {
|
||||
|
||||
/// Define field introformat to be added to feedback
|
||||
/// Define field introformat to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
$field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'intro');
|
||||
|
||||
/// Launch add field introformat
|
||||
/// Launch add field introformat
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
/// feedback savepoint reached
|
||||
/// feedback savepoint reached
|
||||
upgrade_mod_savepoint(true, 2009042001, 'feedback');
|
||||
}
|
||||
|
||||
if ($oldversion < 2009112000) {
|
||||
/// Define field page_after_submitformat to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('page_after_submitformat', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'page_after_submit');
|
||||
$field = new xmldb_field('page_after_submitformat', XMLDB_TYPE_INTEGER, '2',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'page_after_submit');
|
||||
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
// Launch add field page_after_submitformat
|
||||
@ -262,7 +315,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($oldversion < 2010051101) {
|
||||
/// Define field options to be added to feedback_item
|
||||
$table = new xmldb_table('feedback_item');
|
||||
$field = new xmldb_field('options', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'required');
|
||||
$field = new xmldb_field('options', XMLDB_TYPE_CHAR, '255',
|
||||
null, null, false, '', 'required');
|
||||
/// Launch add field
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -272,7 +326,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($oldversion < 2010051600) {
|
||||
/// Define field options to be added to feedback_item
|
||||
$table = new xmldb_table('feedback_item');
|
||||
$field = new xmldb_field('dependitem', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'required');
|
||||
$field = new xmldb_field('dependitem', XMLDB_TYPE_INTEGER, '10',
|
||||
XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'required');
|
||||
/// Launch add field
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -282,7 +337,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
if ($oldversion < 2010051601) {
|
||||
/// Define field options to be added to feedback_item
|
||||
$table = new xmldb_table('feedback_item');
|
||||
$field = new xmldb_field('dependvalue', XMLDB_TYPE_CHAR, '255', null, null, false, '', 'dependitem');
|
||||
$field = new xmldb_field('dependvalue', XMLDB_TYPE_CHAR, '255',
|
||||
null, null, false, '', 'dependitem');
|
||||
/// Launch add field
|
||||
$dbman->add_field($table, $field);
|
||||
|
||||
@ -293,7 +349,8 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
|
||||
// Define field completionsubmit to be added to feedback
|
||||
$table = new xmldb_table('feedback');
|
||||
$field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0', 'timemodified');
|
||||
$field = new xmldb_field('completionsubmit', XMLDB_TYPE_INTEGER, '1',
|
||||
null, XMLDB_NOTNULL, null, '0', 'timemodified');
|
||||
|
||||
// Conditionally launch add field completionsubmit
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
@ -303,7 +360,6 @@ function xmldb_feedback_upgrade($oldversion) {
|
||||
// feedback savepoint reached
|
||||
upgrade_mod_savepoint(true, 2010102300, 'feedback');
|
||||
}
|
||||
|
||||
|
||||
// Moodle v2.1.0 release upgrade line
|
||||
// Put any upgrade step following this
|
||||
|
@ -1,97 +1,116 @@
|
||||
<?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 the form to confirm the deleting of a completed
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
/**
|
||||
* prints the form to confirm the deleting of a completed
|
||||
*
|
||||
* @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('delete_completed_form.php');
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once('delete_completed_form.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$completedid = optional_param('completedid', 0, PARAM_INT);
|
||||
$return = optional_param('return', 'entries', PARAM_ALPHA);
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$completedid = optional_param('completedid', 0, PARAM_INT);
|
||||
$return = optional_param('return', 'entries', PARAM_ALPHA);
|
||||
|
||||
if($completedid == 0){
|
||||
print_error('no_complete_to_delete', 'feedback', 'show_entries.php?id='.$id.'&do_show=showentries');
|
||||
if ($completedid == 0) {
|
||||
print_error('no_complete_to_delete',
|
||||
'feedback',
|
||||
'show_entries.php?id='.$id.'&do_show=showentries');
|
||||
}
|
||||
|
||||
$PAGE->set_url('/mod/feedback/delete_completed.php', array('id'=>$id, 'completed'=>$completedid));
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
require_capability('mod/feedback:deletesubmissions', $context);
|
||||
|
||||
$mform = new mod_feedback_delete_completed_form();
|
||||
$newformdata = array('id'=>$id,
|
||||
'completedid'=>$completedid,
|
||||
'confirmdelete'=>'1',
|
||||
'do_show'=>'edit',
|
||||
'return'=>$return);
|
||||
$mform->set_data($newformdata);
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
if ($return == 'entriesanonym') {
|
||||
redirect('show_entries_anonym.php?id='.$id);
|
||||
} else {
|
||||
redirect('show_entries.php?id='.$id.'&do_show=showentries');
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->set_url('/mod/feedback/delete_completed.php', array('id'=>$id, 'completed'=>$completedid));
|
||||
if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) {
|
||||
if ($completed = $DB->get_record('feedback_completed', array('id'=>$completedid))) {
|
||||
feedback_delete_completed($completedid);
|
||||
add_to_log($course->id,
|
||||
'feedback',
|
||||
'delete',
|
||||
'view.php?id='.$cm->id,
|
||||
$feedback->id,
|
||||
$cm->id);
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
require_capability('mod/feedback:deletesubmissions', $context);
|
||||
|
||||
$mform = new mod_feedback_delete_completed_form();
|
||||
$newformdata = array('id'=>$id,
|
||||
'completedid'=>$completedid,
|
||||
'confirmdelete'=>'1',
|
||||
'do_show'=>'edit',
|
||||
'return'=>$return);
|
||||
$mform->set_data($newformdata);
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
if($return == 'entriesanonym') {
|
||||
if ($return == 'entriesanonym') {
|
||||
redirect('show_entries_anonym.php?id='.$id);
|
||||
}else {
|
||||
} else {
|
||||
redirect('show_entries.php?id='.$id.'&do_show=showentries');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1){
|
||||
if($completed = $DB->get_record('feedback_completed', array('id'=>$completedid))) {
|
||||
feedback_delete_completed($completedid);
|
||||
add_to_log($course->id, 'feedback', 'delete', 'view.php?id='.$cm->id, $feedback->id,$cm->id);
|
||||
|
||||
if($return == 'entriesanonym') {
|
||||
redirect('show_entries_anonym.php?id='.$id);
|
||||
}else {
|
||||
redirect('show_entries.php?id='.$id.'&do_show=showentries');
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->navbar->add(get_string('delete_entry', 'feedback'));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
$PAGE->navbar->add(get_string('delete_entry', 'feedback'));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
echo $OUTPUT->heading(format_text($feedback->name));
|
||||
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
|
||||
echo $OUTPUT->heading(get_string('confirmdeleteentry', 'feedback'));
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
echo $OUTPUT->heading(format_text($feedback->name));
|
||||
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
|
||||
echo $OUTPUT->heading(get_string('confirmdeleteentry', 'feedback'));
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -1,25 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* prints the form to confirm delete a completed
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
// 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 confirm delete a completed
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
//It must be included from a Moodle page
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class mod_feedback_delete_completed_form extends moodleform {
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
//headline
|
||||
//$mform->addElement('header', 'general', '');
|
||||
|
||||
// hidden elements
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
@ -1,78 +1,93 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* deletes an item of the feedback
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
* deletes an item 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('delete_item_form.php');
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once('delete_item_form.php');
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$deleteitem = required_param('deleteitem', PARAM_INT);
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$deleteitem = required_param('deleteitem', PARAM_INT);
|
||||
|
||||
$PAGE->set_url('/mod/feedback/delete_item.php', array('id'=>$id, 'deleteitem'=>$deleteitem));
|
||||
$PAGE->set_url('/mod/feedback/delete_item.php', array('id'=>$id, 'deleteitem'=>$deleteitem));
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
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 (! $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');
|
||||
}
|
||||
if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
$mform = new mod_feedback_delete_item_form();
|
||||
$newformdata = array('id'=>$id,
|
||||
'deleteitem'=>$deleteitem,
|
||||
'confirmdelete'=>'1');
|
||||
$mform->set_data($newformdata);
|
||||
$formdata = $mform->get_data();
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect('edit.php?id='.$id);
|
||||
}
|
||||
$mform = new mod_feedback_delete_item_form();
|
||||
$newformdata = array('id'=>$id,
|
||||
'deleteitem'=>$deleteitem,
|
||||
'confirmdelete'=>'1');
|
||||
$mform->set_data($newformdata);
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
if(isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1){
|
||||
feedback_delete_item($formdata->deleteitem);
|
||||
redirect('edit.php?id=' . $id);
|
||||
}
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect('edit.php?id='.$id);
|
||||
}
|
||||
|
||||
if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) {
|
||||
feedback_delete_item($formdata->deleteitem);
|
||||
redirect('edit.php?id=' . $id);
|
||||
}
|
||||
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->navbar->add(get_string('delete_item', 'feedback'));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
echo $OUTPUT->heading(format_text($feedback->name));
|
||||
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
|
||||
echo $OUTPUT->heading(get_string('confirmdeleteitem', 'feedback'));
|
||||
print_string('relateditemsdeleted','feedback');
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
$PAGE->navbar->add(get_string('delete_item', 'feedback'));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
echo $OUTPUT->heading(format_text($feedback->name));
|
||||
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
|
||||
echo $OUTPUT->heading(get_string('confirmdeleteitem', 'feedback'));
|
||||
print_string('relateditemsdeleted', 'feedback');
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
||||
|
@ -1,25 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* prints the form to confirm delete a completed
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
// 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 confirm delete a completed
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
//It must be included from a Moodle page
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class mod_feedback_delete_item_form extends moodleform {
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
//headline
|
||||
//$mform->addElement('header', 'general', '');
|
||||
|
||||
// hidden elements
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
@ -1,26 +1,38 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* deletes a template
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
* deletes a template
|
||||
*
|
||||
* @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('delete_template_form.php');
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
// $SESSION->feedback->current_tab = 'templates';
|
||||
$current_tab = 'templates';
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$canceldelete = optional_param('canceldelete', false, PARAM_INT);
|
||||
$shoulddelete = optional_param('shoulddelete', false, PARAM_INT);
|
||||
$deletetempl = optional_param('deletetempl', false, PARAM_INT);
|
||||
// $formdata = data_submitted();
|
||||
|
||||
$url = new moodle_url('/mod/feedback/delete_template.php', array('id'=>$id));
|
||||
if ($canceldelete !== false) {
|
||||
@ -34,11 +46,11 @@ if ($deletetempl !== false) {
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if(($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
if($canceldelete == 1){
|
||||
if ($canceldelete == 1) {
|
||||
$editurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$id, 'do_show'=>'templates'));
|
||||
redirect($editurl->out(false));
|
||||
}
|
||||
@ -77,12 +89,12 @@ if ($mform->is_cancelled()) {
|
||||
redirect($deleteurl->out(false));
|
||||
}
|
||||
|
||||
if(isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1){
|
||||
if(!$template = $DB->get_record("feedback_template", array("id"=>$deletetempl))) {
|
||||
if (isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1) {
|
||||
if (!$template = $DB->get_record("feedback_template", array("id"=>$deletetempl))) {
|
||||
print_error('error');
|
||||
}
|
||||
|
||||
if($template->ispublic) {
|
||||
if ($template->ispublic) {
|
||||
$systemcontext = get_system_context();
|
||||
require_capability('mod/feedback:createpublictemplate', $systemcontext);
|
||||
require_capability('mod/feedback:deletetemplate', $systemcontext);
|
||||
@ -95,32 +107,33 @@ if(isset($formdata->confirmdelete) AND $formdata->confirmdelete == 1){
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
$strdeletefeedback = get_string('delete_template','feedback');
|
||||
$strdeletefeedback = get_string('delete_template', '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 the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
echo $OUTPUT->heading($strdeletefeedback);
|
||||
if($shoulddelete == 1) {
|
||||
if ($shoulddelete == 1) {
|
||||
|
||||
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
|
||||
echo $OUTPUT->heading(get_string('confirmdeletetemplate', 'feedback'));
|
||||
$mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
}else {
|
||||
} else {
|
||||
//first we get the own templates
|
||||
$templates = feedback_get_template_list($course, 'own');
|
||||
if(!is_array($templates)) {
|
||||
echo $OUTPUT->box(get_string('no_templates_available_yet', 'feedback'), 'generalbox boxaligncenter');
|
||||
}else {
|
||||
if (!is_array($templates)) {
|
||||
echo $OUTPUT->box(get_string('no_templates_available_yet', 'feedback'),
|
||||
'generalbox boxaligncenter');
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('course'), 3);
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
$tablecolumns = array('template', 'action');
|
||||
@ -137,7 +150,7 @@ if($shoulddelete == 1) {
|
||||
$tablecourse->set_attribute('class', 'generaltable');
|
||||
$tablecourse->setup();
|
||||
|
||||
foreach($templates as $template) {
|
||||
foreach ($templates as $template) {
|
||||
$data = array();
|
||||
$data[] = $template->name;
|
||||
$url = new moodle_url($deleteurl, array(
|
||||
@ -154,12 +167,13 @@ if($shoulddelete == 1) {
|
||||
}
|
||||
//now we get the public templates if it is permitted
|
||||
$systemcontext = get_system_context();
|
||||
if(has_capability('mod/feedback:createpublictemplate', $systemcontext) AND
|
||||
if (has_capability('mod/feedback:createpublictemplate', $systemcontext) AND
|
||||
has_capability('mod/feedback:deletetemplate', $systemcontext)) {
|
||||
$templates = feedback_get_template_list($course, 'public');
|
||||
if(!is_array($templates)) {
|
||||
echo $OUTPUT->box(get_string('no_templates_available_yet', 'feedback'), 'generalbox boxaligncenter');
|
||||
}else {
|
||||
if (!is_array($templates)) {
|
||||
echo $OUTPUT->box(get_string('no_templates_available_yet', 'feedback'),
|
||||
'generalbox boxaligncenter');
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('public', 'feedback'), 3);
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
$tablecolumns = array('template', 'action');
|
||||
@ -176,9 +190,7 @@ if($shoulddelete == 1) {
|
||||
$tablepublic->set_attribute('class', 'generaltable');
|
||||
$tablepublic->setup();
|
||||
|
||||
// echo $OUTPUT->heading(get_string('public', 'feedback'), 3);
|
||||
// echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
foreach($templates as $template) {
|
||||
foreach ($templates as $template) {
|
||||
$data = array();
|
||||
$data[] = $template->name;
|
||||
$url = new moodle_url($deleteurl, array(
|
||||
|
@ -1,25 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* prints the form to confirm delete a completed
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
// 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 confirm delete a completed
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
//It must be included from a Moodle page
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class mod_feedback_delete_template_form extends moodleform {
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
//headline
|
||||
//$mform->addElement('header', 'general', '');
|
||||
|
||||
// hidden elements
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
@ -34,4 +47,3 @@ class mod_feedback_delete_template_form extends moodleform {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,26 @@
|
||||
<?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 the form to edit the feedback items such moving, deleting and so on
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
* prints the form to edit the feedback items such moving, deleting and so on
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
@ -16,7 +30,7 @@ feedback_init_feedback_session();
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
|
||||
if(($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
@ -27,7 +41,6 @@ $moveitem = optional_param('moveitem', false, PARAM_INT);
|
||||
$movehere = optional_param('movehere', false, PARAM_INT);
|
||||
$switchitemrequired = optional_param('switchitemrequired', false, PARAM_INT);
|
||||
|
||||
// $SESSION->feedback->current_tab = $do_show;
|
||||
$current_tab = $do_show;
|
||||
|
||||
$url = new moodle_url('/mod/feedback/edit.php', array('id'=>$id, 'do_show'=>$do_show));
|
||||
@ -53,22 +66,22 @@ require_login($course->id, true, $cm);
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
|
||||
//move up/down items
|
||||
if($moveupitem){
|
||||
if ($moveupitem) {
|
||||
$item = $DB->get_record('feedback_item', array('id'=>$moveupitem));
|
||||
feedback_moveup_item($item);
|
||||
}
|
||||
if($movedownitem){
|
||||
if ($movedownitem) {
|
||||
$item = $DB->get_record('feedback_item', array('id'=>$movedownitem));
|
||||
feedback_movedown_item($item);
|
||||
}
|
||||
|
||||
//moving of items
|
||||
if($movehere && isset($SESSION->feedback->moving->movingitem)){
|
||||
if ($movehere && isset($SESSION->feedback->moving->movingitem)) {
|
||||
$item = $DB->get_record('feedback_item', array('id'=>$SESSION->feedback->moving->movingitem));
|
||||
feedback_move_item($item, intval($movehere));
|
||||
$moveitem = false;
|
||||
}
|
||||
if($moveitem){
|
||||
if ($moveitem) {
|
||||
$item = $DB->get_record('feedback_item', array('id'=>$moveitem));
|
||||
$SESSION->feedback->moving->shouldmoving = 1;
|
||||
$SESSION->feedback->moving->movingitem = $moveitem;
|
||||
@ -76,7 +89,7 @@ if($moveitem){
|
||||
unset($SESSION->feedback->moving);
|
||||
}
|
||||
|
||||
if($switchitemrequired) {
|
||||
if ($switchitemrequired) {
|
||||
$item = $DB->get_record('feedback_item', array('id'=>$switchitemrequired));
|
||||
@feedback_switch_item_required($item);
|
||||
redirect($url->out(false));
|
||||
@ -89,24 +102,26 @@ $create_template_form->set_feedbackdata(array('context'=>$context, 'course'=>$co
|
||||
$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) {
|
||||
if (isset($create_template_formdata->savetemplate) && $create_template_formdata->savetemplate == 1) {
|
||||
//check the capabilities to create templates
|
||||
if(!has_capability('mod/feedback:createprivatetemplate', $context) AND
|
||||
if (!has_capability('mod/feedback:createprivatetemplate', $context) AND
|
||||
!has_capability('mod/feedback:createpublictemplate', $context)) {
|
||||
print_error('cannotsavetempl', 'feedback');
|
||||
}
|
||||
if(trim($create_template_formdata->templatename) == '') {
|
||||
if (trim($create_template_formdata->templatename) == '') {
|
||||
$savereturn = 'notsaved_name';
|
||||
}else {
|
||||
} else {
|
||||
//if the feedback is located on the frontpage then templates can be public
|
||||
if(has_capability('mod/feedback:createpublictemplate', get_system_context())) {
|
||||
if (has_capability('mod/feedback:createpublictemplate', get_system_context())) {
|
||||
$create_template_formdata->ispublic = isset($create_template_formdata->ispublic) ? 1 : 0;
|
||||
}else {
|
||||
} else {
|
||||
$create_template_formdata->ispublic = 0;
|
||||
}
|
||||
if(!feedback_save_as_template($feedback, $create_template_formdata->templatename, $create_template_formdata->ispublic)) {
|
||||
if (!feedback_save_as_template($feedback,
|
||||
$create_template_formdata->templatename,
|
||||
$create_template_formdata->ispublic)) {
|
||||
$savereturn = 'failed';
|
||||
}else {
|
||||
} else {
|
||||
$savereturn = 'saved';
|
||||
}
|
||||
}
|
||||
@ -115,12 +130,12 @@ if(isset($create_template_formdata->savetemplate) && $create_template_formdata->
|
||||
//get the feedbackitems
|
||||
$lastposition = 0;
|
||||
$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position');
|
||||
if(is_array($feedbackitems)){
|
||||
if (is_array($feedbackitems)) {
|
||||
$feedbackitems = array_values($feedbackitems);
|
||||
if(count($feedbackitems) > 0) {
|
||||
if (count($feedbackitems) > 0) {
|
||||
$lastitem = $feedbackitems[count($feedbackitems)-1];
|
||||
$lastposition = $lastitem->position;
|
||||
}else {
|
||||
} else {
|
||||
$lastposition = 0;
|
||||
}
|
||||
}
|
||||
@ -137,9 +152,6 @@ $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");
|
||||
@ -150,7 +162,7 @@ $PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// print the tabs
|
||||
include('tabs.php');
|
||||
require('tabs.php');
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -160,38 +172,45 @@ include('tabs.php');
|
||||
$savereturn=isset($savereturn)?$savereturn:'';
|
||||
|
||||
//print the messages
|
||||
if($savereturn == 'notsaved_name') {
|
||||
echo '<p align="center"><b><font color="red">'.get_string('name_required','feedback').'</font></b></p>';
|
||||
if ($savereturn == 'notsaved_name') {
|
||||
echo '<p align="center"><b><font color="red">'.
|
||||
get_string('name_required', 'feedback').
|
||||
'</font></b></p>';
|
||||
}
|
||||
|
||||
if($savereturn == 'saved') {
|
||||
echo '<p align="center"><b><font color="green">'.get_string('template_saved','feedback').'</font></b></p>';
|
||||
if ($savereturn == 'saved') {
|
||||
echo '<p align="center"><b><font color="green">'.
|
||||
get_string('template_saved', 'feedback').
|
||||
'</font></b></p>';
|
||||
}
|
||||
|
||||
if($savereturn == 'failed') {
|
||||
echo '<p align="center"><b><font color="red">'.get_string('saving_failed','feedback').'</font></b></p>';
|
||||
if ($savereturn == 'failed') {
|
||||
echo '<p align="center"><b><font color="red">'.
|
||||
get_string('saving_failed', 'feedback').
|
||||
'</font></b></p>';
|
||||
}
|
||||
|
||||
feedback_print_errors();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///print the template-section
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
if($do_show == 'templates') {
|
||||
if ($do_show == 'templates') {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
$use_template_form->display();
|
||||
|
||||
if(has_capability('mod/feedback:createprivatetemplate', $context) OR
|
||||
if (has_capability('mod/feedback:createprivatetemplate', $context) OR
|
||||
has_capability('mod/feedback:createpublictemplate', $context)) {
|
||||
$deleteurl = new moodle_url('/mod/feedback/delete_template.php', array('id'=>$id));
|
||||
$deleteurl = new moodle_url('/mod/feedback/delete_template.php', array('id' => $id));
|
||||
$create_template_form->display();
|
||||
echo '<p><a href="'.$deleteurl->out().'">'.get_string('delete_templates', 'feedback').'</a></p>';
|
||||
}else {
|
||||
echo '<p><a href="'.$deleteurl->out().'">'.
|
||||
get_string('delete_templates', 'feedback').
|
||||
'</a></p>';
|
||||
} else {
|
||||
echo ' ';
|
||||
}
|
||||
|
||||
if(has_capability('mod/feedback:edititems', $context)) {
|
||||
$exporturl = new moodle_url('/mod/feedback/export.php', array('action'=>'exportfile', 'id'=>$id));
|
||||
if (has_capability('mod/feedback:edititems', $context)) {
|
||||
$urlparams = array('action'=>'exportfile', 'id'=>$id);
|
||||
$exporturl = new moodle_url('/mod/feedback/export.php', $urlparams);
|
||||
$importurl = new moodle_url('/mod/feedback/import.php', array('id'=>$id));
|
||||
echo '<p>
|
||||
<a href="'.$exporturl->out().'">'.get_string('export_questions', 'feedback').'</a>/
|
||||
@ -203,11 +222,11 @@ if($do_show == 'templates') {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///print the Item-Edit-section
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
if($do_show == 'edit') {
|
||||
if ($do_show == 'edit') {
|
||||
|
||||
$add_item_form->display();
|
||||
|
||||
if(is_array($feedbackitems)){
|
||||
if (is_array($feedbackitems)) {
|
||||
$itemnr = 0;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
@ -215,156 +234,180 @@ if($do_show == 'edit') {
|
||||
$helpbutton = $OUTPUT->help_icon('preview', 'feedback');
|
||||
|
||||
echo $OUTPUT->heading($helpbutton . get_string('preview', 'feedback'));
|
||||
if(isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
|
||||
echo $OUTPUT->heading('<a href="edit.php?id='.$id.'">'.get_string('cancel_moving', 'feedback').'</a>');
|
||||
if (isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
|
||||
$anker = '<a href="edit.php?id='.$id.'">';
|
||||
$anker .= get_string('cancel_moving', 'feedback');
|
||||
$anker .= '</a>';
|
||||
echo $OUTPUT->heading($anker);
|
||||
}
|
||||
// echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
|
||||
//check, if there exists required-elements
|
||||
$countreq = $DB->count_records('feedback_item', array('feedback'=>$feedback->id, 'required'=> 1));
|
||||
if($countreq > 0) {
|
||||
// echo '<font color="red">(*)' . get_string('items_are_required', 'feedback') . '</font>';
|
||||
echo '<span class="feedback_required_mark">(*)' . get_string('items_are_required', 'feedback') . '</span>';
|
||||
$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>';
|
||||
}
|
||||
|
||||
//use list instead a table
|
||||
echo $OUTPUT->box_start('feedback_items');
|
||||
if(isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
|
||||
$moveposition = 1;
|
||||
$movehereurl = new moodle_url($url, array('movehere'=>$moveposition));
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align.' clipboard'); //only shown if shouldmoving = 1
|
||||
$buttonlink = $movehereurl->out();
|
||||
echo '<a title="'.get_string('move_here','feedback').'" href="'.$buttonlink.'">
|
||||
<img class="movetarget" alt="'.get_string('move_here','feedback').'" src="'.$OUTPUT->pix_url('movehere') . '" />
|
||||
</a>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
//print the inserted items
|
||||
$itempos = 0;
|
||||
foreach($feedbackitems as $feedbackitem){
|
||||
$itempos++;
|
||||
if(isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->movingitem == $feedbackitem->id){ //hiding the item to move
|
||||
if (isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
|
||||
$moveposition = 1;
|
||||
$movehereurl = new moodle_url($url, array('movehere'=>$moveposition));
|
||||
//only shown if shouldmoving = 1
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align.' clipboard');
|
||||
$buttonlink = $movehereurl->out();
|
||||
$strbutton = get_string('move_here', 'feedback');
|
||||
$src = $OUTPUT->pix_url('movehere');
|
||||
echo '<a title="'.$strbutton.'" href="'.$buttonlink.'">
|
||||
<img class="movetarget" alt="'.$strbutton.'" src="'.$src.'" />
|
||||
</a>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
//print the inserted items
|
||||
$itempos = 0;
|
||||
foreach ($feedbackitems as $feedbackitem) {
|
||||
$itempos++;
|
||||
//hiding the item to move
|
||||
if (isset($SESSION->feedback->moving)) {
|
||||
if ($SESSION->feedback->moving->movingitem == $feedbackitem->id) {
|
||||
continue;
|
||||
}
|
||||
if($feedbackitem->dependitem > 0) {
|
||||
$dependstyle = ' feedback_depend';
|
||||
}else {
|
||||
$dependstyle = '';
|
||||
}
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
|
||||
//items without value only are labels
|
||||
if($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align) . $itemnr . $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
echo $OUTPUT->box_start('feedback_item_commands_'.$align);
|
||||
echo '<span class="feedback_item_commands">('.get_string('position', 'feedback').':'.$itempos .')</span>';
|
||||
//print the moveup-button
|
||||
if($feedbackitem->position > 1){
|
||||
echo '<span class="feedback_item_command_moveup">';
|
||||
$moveupurl = new moodle_url($url, array('moveupitem'=>$feedbackitem->id));
|
||||
$buttonlink = $moveupurl->out();
|
||||
echo '<a class="icon up" title="'.get_string('moveup_item','feedback').'" href="'.$buttonlink.'">
|
||||
<img alt="'.get_string('moveup_item','feedback').'" src="'.$OUTPUT->pix_url('t/up') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
//print the movedown-button
|
||||
if($feedbackitem->position < $lastposition - 1){
|
||||
echo '<span class="feedback_item_command_movedown">';
|
||||
$movedownurl = new moodle_url($url, array('movedownitem'=>$feedbackitem->id));
|
||||
$buttonlink = $movedownurl->out();
|
||||
echo '<a class="icon down" title="'.get_string('movedown_item','feedback').'" href="'.$buttonlink.'">
|
||||
<img alt="'.get_string('movedown_item','feedback').'" src="'.$OUTPUT->pix_url('t/down') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
//print the move-button
|
||||
echo '<span class="feedback_item_command_move">';
|
||||
$moveurl = new moodle_url($url, array('moveitem'=>$feedbackitem->id));
|
||||
$buttonlink = $moveurl->out();
|
||||
echo '<a class="editing_move" title="'.get_string('move_item','feedback').'" href="'.$buttonlink.'">
|
||||
<img alt="'.get_string('move_item','feedback').'" src="'.$OUTPUT->pix_url('t/move') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
//print the button to edit the item
|
||||
if($feedbackitem->typ != 'pagebreak') {
|
||||
echo '<span class="feedback_item_command_edit">';
|
||||
$editurl = new moodle_url('/mod/feedback/edit_item.php');
|
||||
$editurl->params(array('do_show'=>$do_show,
|
||||
'cmid'=>$id,
|
||||
'id'=>$feedbackitem->id,
|
||||
'typ'=>$feedbackitem->typ));
|
||||
|
||||
// in edit_item.php the param id is used for the itemid and the cmid is the id to get the module
|
||||
$buttonlink = $editurl->out();
|
||||
echo '<a class="editing_update" title="'.get_string('edit_item','feedback').'" href="'.$buttonlink.'">
|
||||
<img alt="'.get_string('edit_item','feedback').'" src="'.$OUTPUT->pix_url('t/edit') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
//print the toggle-button to switch required yes/no
|
||||
if($feedbackitem->hasvalue == 1) {
|
||||
echo '<span class="feedback_item_command_toggle">';
|
||||
// echo '<form action="edit.php" method="post"><fieldset>';
|
||||
if($feedbackitem->required == 1) {
|
||||
// echo '<input title="'.get_string('switch_item_to_not_required','feedback').'" type="image" src="pics/required.gif" hspace="1" height="11" width="11" border="0" />';
|
||||
// echo '<input class="feedback_required_button" title="'.get_string('switch_item_to_not_required','feedback').'" type="image" src="pics/required.gif" />';
|
||||
$buttontitle = get_string('switch_item_to_not_required','feedback');
|
||||
$buttonimg = 'pics/required.gif';
|
||||
} else {
|
||||
// echo '<input title="'.get_string('switch_item_to_required','feedback').'" type="image" src="pics/notrequired.gif" hspace="1" height="11" width="11" border="0" />';
|
||||
// echo '<input class="feedback_required_button" title="'.get_string('switch_item_to_required','feedback').'" type="image" src="pics/notrequired.gif" />';
|
||||
$buttontitle = get_string('switch_item_to_required','feedback');
|
||||
$buttonimg = 'pics/notrequired.gif';
|
||||
}
|
||||
$requiredurl = new moodle_url($url, array('switchitemrequired'=>$feedbackitem->id));
|
||||
$buttonlink = $requiredurl->out();
|
||||
echo '<a class="icon feedback_switchrequired" title="'.$buttontitle.'" href="'.$buttonlink.'">
|
||||
<img alt="'.$buttontitle.'" src="'.$buttonimg.'" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
//print the delete-button
|
||||
echo '<span class="feedback_item_command_toggle">';
|
||||
$deleteitemurl = new moodle_url('/mod/feedback/delete_item.php');
|
||||
$deleteitemurl->params(array('id'=>$id,
|
||||
'do_show'=>$do_show,
|
||||
'deleteitem'=>$feedbackitem->id));
|
||||
|
||||
$buttonlink = $deleteitemurl->out();
|
||||
echo '<a class="icon delete" title="'.get_string('delete_item','feedback').'" href="'.$buttonlink.'">
|
||||
<img alt="'.get_string('delete_item','feedback').'" src="'.$OUTPUT->pix_url('t/delete') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
echo $OUTPUT->box_end();
|
||||
if($feedbackitem->typ != 'pagebreak') {
|
||||
feedback_print_item_preview($feedbackitem);
|
||||
}else {
|
||||
echo $OUTPUT->box_start('feedback_pagebreak');
|
||||
echo get_string('pagebreak', 'feedback').'<hr class="feedback_pagebreak" />';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
if(isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
|
||||
$moveposition++;
|
||||
$movehereurl->param('movehere', $moveposition);
|
||||
echo $OUTPUT->box_start('clipboard'); //only shown if shouldmoving = 1
|
||||
$buttonlink = $movehereurl->out();
|
||||
echo '<a title="'.get_string('move_here','feedback').'" href="'.$buttonlink.'">
|
||||
<img class="movetarget" alt="'.get_string('move_here','feedback').'" src="'.$OUTPUT->pix_url('movehere') . '" />
|
||||
</a>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo '<div class="clearer"> </div>';
|
||||
}
|
||||
if ($feedbackitem->dependitem > 0) {
|
||||
$dependstyle = ' feedback_depend';
|
||||
} else {
|
||||
$dependstyle = '';
|
||||
}
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align.$dependstyle);
|
||||
//items without value only are labels
|
||||
if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
echo $OUTPUT->box_start('feedback_item_commands_'.$align);
|
||||
echo '<span class="feedback_item_commands">';
|
||||
echo '('.get_string('position', 'feedback').':'.$itempos .')';
|
||||
echo '</span>';
|
||||
//print the moveup-button
|
||||
if ($feedbackitem->position > 1) {
|
||||
echo '<span class="feedback_item_command_moveup">';
|
||||
$moveupurl = new moodle_url($url, array('moveupitem'=>$feedbackitem->id));
|
||||
$buttonlink = $moveupurl->out();
|
||||
$strbutton = get_string('moveup_item', 'feedback');
|
||||
echo '<a class="icon up" title="'.$strbutton.'" href="'.$buttonlink.'">
|
||||
<img alt="'.$strbutton.'" src="'.$OUTPUT->pix_url('t/up') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
//print the movedown-button
|
||||
if ($feedbackitem->position < $lastposition - 1) {
|
||||
echo '<span class="feedback_item_command_movedown">';
|
||||
$urlparams = array('movedownitem'=>$feedbackitem->id);
|
||||
$movedownurl = new moodle_url($url, $urlparams);
|
||||
$buttonlink = $movedownurl->out();
|
||||
$strbutton = get_string('movedown_item', 'feedback');
|
||||
echo '<a class="icon down" title="'.$strbutton.'" href="'.$buttonlink.'">
|
||||
<img alt="'.$strbutton.'" src="'.$OUTPUT->pix_url('t/down') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
//print the move-button
|
||||
echo '<span class="feedback_item_command_move">';
|
||||
$moveurl = new moodle_url($url, array('moveitem'=>$feedbackitem->id));
|
||||
$buttonlink = $moveurl->out();
|
||||
$strbutton = get_string('move_item', 'feedback');
|
||||
echo '<a class="editing_move" title="'.$strbutton.'" href="'.$buttonlink.'">
|
||||
<img alt="'.$strbutton.'" src="'.$OUTPUT->pix_url('t/move') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
//print the button to edit the item
|
||||
if ($feedbackitem->typ != 'pagebreak') {
|
||||
echo '<span class="feedback_item_command_edit">';
|
||||
$editurl = new moodle_url('/mod/feedback/edit_item.php');
|
||||
$editurl->params(array('do_show'=>$do_show,
|
||||
'cmid'=>$id,
|
||||
'id'=>$feedbackitem->id,
|
||||
'typ'=>$feedbackitem->typ));
|
||||
|
||||
// in edit_item.php the param id is used for the itemid
|
||||
// and the cmid is the id to get the module
|
||||
$buttonlink = $editurl->out();
|
||||
$strbutton = get_string('edit_item', 'feedback');
|
||||
echo '<a class="editing_update" title="'.$strbutton.'" href="'.$buttonlink.'">
|
||||
<img alt="'.$strbutton.'" src="'.$OUTPUT->pix_url('t/edit') . '" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
//print the toggle-button to switch required yes/no
|
||||
if ($feedbackitem->hasvalue == 1) {
|
||||
echo '<span class="feedback_item_command_toggle">';
|
||||
if ($feedbackitem->required == 1) {
|
||||
$buttontitle = get_string('switch_item_to_not_required', 'feedback');
|
||||
$buttonimg = 'pics/required.gif';
|
||||
} else {
|
||||
$buttontitle = get_string('switch_item_to_required', 'feedback');
|
||||
$buttonimg = 'pics/notrequired.gif';
|
||||
}
|
||||
$urlparams = array('switchitemrequired'=>$feedbackitem->id);
|
||||
$requiredurl = new moodle_url($url, $urlparams);
|
||||
$buttonlink = $requiredurl->out();
|
||||
echo '<a class="icon '.
|
||||
'feedback_switchrequired" '.
|
||||
'title="'.$buttontitle.'" '.
|
||||
'href="'.$buttonlink.'">'.
|
||||
'<img alt="'.$buttontitle.'" src="'.$buttonimg.'" />'.
|
||||
'</a>';
|
||||
echo '</span>';
|
||||
}
|
||||
|
||||
//print the delete-button
|
||||
echo '<span class="feedback_item_command_toggle">';
|
||||
$deleteitemurl = new moodle_url('/mod/feedback/delete_item.php');
|
||||
$deleteitemurl->params(array('id'=>$id,
|
||||
'do_show'=>$do_show,
|
||||
'deleteitem'=>$feedbackitem->id));
|
||||
|
||||
$buttonlink = $deleteitemurl->out();
|
||||
$strbutton = get_string('delete_item', 'feedback');
|
||||
$src = $OUTPUT->pix_url('t/delete');
|
||||
echo '<a class="icon delete" title="'.$strbutton.'" href="'.$buttonlink.'">
|
||||
<img alt="'.$strbutton.'" src="'.$src.'" />
|
||||
</a>';
|
||||
echo '</span>';
|
||||
echo $OUTPUT->box_end();
|
||||
if ($feedbackitem->typ != 'pagebreak') {
|
||||
feedback_print_item_preview($feedbackitem);
|
||||
} else {
|
||||
echo $OUTPUT->box_start('feedback_pagebreak');
|
||||
echo get_string('pagebreak', 'feedback').'<hr class="feedback_pagebreak" />';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
if (isset($SESSION->feedback->moving) AND $SESSION->feedback->moving->shouldmoving == 1) {
|
||||
$moveposition++;
|
||||
$movehereurl->param('movehere', $moveposition);
|
||||
echo $OUTPUT->box_start('clipboard'); //only shown if shouldmoving = 1
|
||||
$buttonlink = $movehereurl->out();
|
||||
$strbutton = get_string('move_here', 'feedback');
|
||||
$src = $OUTPUT->pix_url('movehere');
|
||||
echo '<a title="'.$strbutton.'" href="'.$buttonlink.'">
|
||||
<img class="movetarget" alt="'.$strbutton.'" src="'.$src.'" />
|
||||
</a>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo '<div class="clearer"> </div>';
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}else{
|
||||
echo $OUTPUT->box(get_string('no_items_available_yet','feedback'),'generalbox boxaligncenter');
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string('no_items_available_yet', 'feedback'),
|
||||
'generalbox boxaligncenter');
|
||||
}
|
||||
}
|
||||
/// Finish the page
|
||||
|
@ -1,31 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* prints the forms to choose an item-typ to create items and to choose a template to use
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
// 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 forms to choose an item-typ to create items and to choose a template to use
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
//It must be included from a Moodle page
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class feedback_edit_add_question_form extends moodleform {
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
//headline
|
||||
$mform->addElement('header', 'general', get_string('add_items', 'feedback'));
|
||||
// visible elements
|
||||
// $feedback_names = feedback_load_feedback_items('mod/feedback/item');
|
||||
// $feedback_names_options = array();
|
||||
// $feedback_names_options[' '] = get_string('select');
|
||||
// foreach($feedback_names as $fn) {
|
||||
// $feedback_names_options[$fn] = get_string($fn,'feedback');
|
||||
// }
|
||||
$feedback_names_options = feedback_load_feedback_items_options();
|
||||
|
||||
$attributes = 'onChange="this.form.submit()"';
|
||||
@ -36,16 +46,16 @@ class feedback_edit_add_question_form extends moodleform {
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
$mform->addElement('hidden', 'position');
|
||||
$mform->setType('position', PARAM_INT);
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
// buttons
|
||||
$mform->addElement('submit', 'add_item', get_string('add_item', 'feedback'));
|
||||
}
|
||||
}
|
||||
|
||||
class feedback_edit_use_template_form extends moodleform {
|
||||
var $feedbackdata;
|
||||
private $feedbackdata;
|
||||
|
||||
function definition() {
|
||||
public 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
|
||||
@ -54,9 +64,9 @@ class feedback_edit_use_template_form extends moodleform {
|
||||
//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) {
|
||||
public function set_feedbackdata($data) {
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $key => $val) {
|
||||
$this->feedbackdata->{$key} = $val;
|
||||
}
|
||||
}
|
||||
@ -65,7 +75,7 @@ class feedback_edit_use_template_form extends moodleform {
|
||||
//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(){
|
||||
public function set_form_elements() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
$elementgroup = array();
|
||||
@ -81,58 +91,63 @@ class feedback_edit_use_template_form extends moodleform {
|
||||
$publictemplates = feedback_get_template_list($this->feedbackdata->course, 'public');
|
||||
|
||||
$options = array();
|
||||
if($owntemplates or $publictemplates) {
|
||||
if ($owntemplates or $publictemplates) {
|
||||
$options[''] = array('' => get_string('choose'));
|
||||
|
||||
if($owntemplates) {
|
||||
|
||||
if ($owntemplates) {
|
||||
$courseoptions = array();
|
||||
foreach($owntemplates as $template) {
|
||||
foreach ($owntemplates as $template) {
|
||||
$courseoptions[$template->id] = $template->name;
|
||||
}
|
||||
$options[get_string('course')] = $courseoptions;
|
||||
}
|
||||
|
||||
if($publictemplates) {
|
||||
|
||||
if ($publictemplates) {
|
||||
$publicoptions = array();
|
||||
foreach($publictemplates as $template) {
|
||||
foreach ($publictemplates as $template) {
|
||||
$publicoptions[$template->id] = $template->name;
|
||||
}
|
||||
$options[get_string('public', 'feedback')] = $publicoptions;
|
||||
}
|
||||
|
||||
$attributes = 'onChange="this.form.submit()"';
|
||||
$elementgroup[] =& $mform->createElement('selectgroups', 'templateid', '', $options, $attributes);
|
||||
$elementgroup[] =& $mform->createElement('submit', 'use_template', get_string('use_this_template', 'feedback'));
|
||||
}else {
|
||||
$elementgroup[] =& $mform->createElement('selectgroups',
|
||||
'templateid',
|
||||
'',
|
||||
$options,
|
||||
$attributes);
|
||||
|
||||
$elementgroup[] =& $mform->createElement('submit',
|
||||
'use_template',
|
||||
get_string('use_this_template', 'feedback'));
|
||||
} else {
|
||||
$mform->addElement('static', 'info', get_string('no_templates_available_yet', 'feedback'));
|
||||
}
|
||||
$mform->addGroup($elementgroup, 'elementgroup', '', array(' '), false);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
class feedback_edit_create_template_form extends moodleform {
|
||||
var $feedbackdata;
|
||||
private $feedbackdata;
|
||||
|
||||
function definition() {
|
||||
public function definition() {
|
||||
}
|
||||
|
||||
function data_preprocessing(&$default_values){
|
||||
public function data_preprocessing(&$default_values) {
|
||||
$default_values['templatename'] = '';
|
||||
}
|
||||
|
||||
function set_feedbackdata($data) {
|
||||
if(is_array($data)) {
|
||||
foreach($data as $key => $val) {
|
||||
public function set_feedbackdata($data) {
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $key => $val) {
|
||||
$this->feedbackdata->{$key} = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function set_form_elements(){
|
||||
public function set_form_elements() {
|
||||
$mform =& $this->_form;
|
||||
// $capabilities = $this->feedbackdata->capabilities;
|
||||
|
||||
// hidden elements
|
||||
$mform->addElement('hidden', 'id');
|
||||
@ -148,20 +163,35 @@ class feedback_edit_create_template_form extends moodleform {
|
||||
// visible elements
|
||||
$elementgroup = array();
|
||||
|
||||
$elementgroup[] =& $mform->createElement('static', 'templatenamelabel', get_string('name', 'feedback'));
|
||||
$elementgroup[] =& $mform->createElement('text', 'templatename', get_string('name', 'feedback'), array('size'=>'40', 'maxlength'=>'200'));
|
||||
$elementgroup[] =& $mform->createElement('static',
|
||||
'templatenamelabel',
|
||||
get_string('name', 'feedback'));
|
||||
|
||||
if(has_capability('mod/feedback:createpublictemplate', get_system_context())) {
|
||||
$elementgroup[] =& $mform->createElement('checkbox', 'ispublic', get_string('public', 'feedback'), get_string('public', 'feedback'));
|
||||
$elementgroup[] =& $mform->createElement('text',
|
||||
'templatename',
|
||||
get_string('name', 'feedback'),
|
||||
array('size'=>'40', 'maxlength'=>'200'));
|
||||
|
||||
if (has_capability('mod/feedback:createpublictemplate', get_system_context())) {
|
||||
$elementgroup[] =& $mform->createElement('checkbox',
|
||||
'ispublic',
|
||||
get_string('public', 'feedback'),
|
||||
get_string('public', 'feedback'));
|
||||
}
|
||||
|
||||
// buttons
|
||||
$elementgroup[] =& $mform->createElement('submit', 'create_template', get_string('save_as_new_template', 'feedback'));
|
||||
$mform->addGroup($elementgroup, 'elementgroup', get_string('name', 'feedback'), array(' '), false);
|
||||
$elementgroup[] =& $mform->createElement('submit',
|
||||
'create_template',
|
||||
get_string('save_as_new_template', 'feedback'));
|
||||
|
||||
$mform->addGroup($elementgroup,
|
||||
'elementgroup',
|
||||
get_string('name', 'feedback'),
|
||||
array(' '),
|
||||
false);
|
||||
|
||||
$mform->setType('templatename', PARAM_TEXT);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* prints the form to edit a dedicated item
|
||||
@ -13,7 +27,6 @@ require_once("lib.php");
|
||||
|
||||
feedback_init_feedback_session();
|
||||
|
||||
// $cmid = optional_param('cmid', NULL, PARAM_INT);
|
||||
$cmid = required_param('cmid', PARAM_INT);
|
||||
$typ = optional_param('typ', false, PARAM_ALPHA);
|
||||
$id = optional_param('id', false, PARAM_INT);
|
||||
@ -21,7 +34,9 @@ $action = optional_param('action', false, PARAM_ALPHA);
|
||||
|
||||
$editurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$cmid));
|
||||
|
||||
if(!$typ)redirect($editurl->out(false));
|
||||
if (!$typ) {
|
||||
redirect($editurl->out(false));
|
||||
}
|
||||
|
||||
$url = new moodle_url('/mod/feedback/edit_item.php', array('cmid'=>$cmid));
|
||||
if ($typ !== false) {
|
||||
@ -36,7 +51,7 @@ $PAGE->set_url($url);
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
|
||||
if(($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
@ -61,7 +76,7 @@ require_login($course->id, true, $cm);
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
|
||||
//if the typ is pagebreak so the item will be saved directly
|
||||
if($typ == 'pagebreak') {
|
||||
if ($typ == 'pagebreak') {
|
||||
feedback_create_pagebreak($feedback->id);
|
||||
redirect($editurl->out(false));
|
||||
exit;
|
||||
@ -69,9 +84,9 @@ if($typ == 'pagebreak') {
|
||||
|
||||
//get the existing item or create it
|
||||
// $formdata->itemid = isset($formdata->itemid) ? $formdata->itemid : NULL;
|
||||
if($id and $item = $DB->get_record('feedback_item', array('id'=>$id))) {
|
||||
if ($id and $item = $DB->get_record('feedback_item', array('id'=>$id))) {
|
||||
$typ = $item->typ;
|
||||
}else {
|
||||
} else {
|
||||
$item = new stdClass();
|
||||
$item->id = null;
|
||||
$item->position = -1;
|
||||
@ -88,12 +103,12 @@ $itemobj = feedback_get_item_class($typ);
|
||||
|
||||
$itemobj->build_editform($item, $feedback, $cm);
|
||||
|
||||
if($itemobj->is_cancelled()) {
|
||||
if ($itemobj->is_cancelled()) {
|
||||
redirect($editurl->out(false));
|
||||
exit;
|
||||
}
|
||||
if($itemobj->get_data()) {
|
||||
if($item = $itemobj->save_item()) {
|
||||
if ($itemobj->get_data()) {
|
||||
if ($item = $itemobj->save_item()) {
|
||||
feedback_move_item($item, $item->position);
|
||||
redirect($editurl->out(false));
|
||||
}
|
||||
@ -113,18 +128,15 @@ $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 the main part of the page
|
||||
echo $OUTPUT->heading(format_text($feedback->name));
|
||||
//print errormsg
|
||||
if(isset($error)) {
|
||||
if (isset($error)) {
|
||||
echo $error;
|
||||
}
|
||||
feedback_print_errors();
|
||||
$itemobj->show_editform();
|
||||
|
||||
// echo $OUTPUT->box_end();
|
||||
|
||||
if ($typ!='label') {
|
||||
$PAGE->requires->js('/mod/feedback/feedback.js');
|
||||
$PAGE->requires->js_function_call('set_item_focus', Array('id_itemname'));
|
||||
@ -136,4 +148,3 @@ if ($typ!='label') {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
@ -1,159 +1,173 @@
|
||||
<?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 the form to export the items as xml-file
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
/**
|
||||
* prints the form to export the items as xml-file
|
||||
*
|
||||
* @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("../../config.php");
|
||||
require_once("lib.php");
|
||||
|
||||
// get parameters
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$action = optional_param('action', false, PARAM_ALPHA);
|
||||
// get parameters
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$action = optional_param('action', false, PARAM_ALPHA);
|
||||
|
||||
$url = new moodle_url('/mod/feedback/export.php', array('id'=>$id));
|
||||
if ($action !== false) {
|
||||
$url->param('action', $action);
|
||||
$url = new moodle_url('/mod/feedback/export.php', array('id'=>$id));
|
||||
if ($action !== false) {
|
||||
$url->param('action', $action);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
|
||||
if ($action == 'exportfile') {
|
||||
if (!$exportdata = feedback_get_xml_data($feedback->id)) {
|
||||
print_error('nodata');
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
|
||||
if ($action == 'exportfile') {
|
||||
if(!$exportdata = feedback_get_xml_data($feedback->id)) {
|
||||
print_error('nodata');
|
||||
}
|
||||
@feedback_send_xml_data($exportdata, 'feedback_'.$feedback->id.'.xml');
|
||||
exit;
|
||||
}
|
||||
|
||||
redirect('view.php?id='.$id);
|
||||
@feedback_send_xml_data($exportdata, 'feedback_'.$feedback->id.'.xml');
|
||||
exit;
|
||||
}
|
||||
|
||||
function feedback_get_xml_data($feedbackid) {
|
||||
global $DB;
|
||||
redirect('view.php?id='.$id);
|
||||
exit;
|
||||
|
||||
$space = ' ';
|
||||
//get all items of the feedback
|
||||
if(!$items = $DB->get_records('feedback_item', array('feedback'=>$feedbackid), 'position')) {
|
||||
return false;
|
||||
}
|
||||
function feedback_get_xml_data($feedbackid) {
|
||||
global $DB;
|
||||
|
||||
//writing the header of the xml file including the charset of the currrent used language
|
||||
$data = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
|
||||
$data .= '<FEEDBACK VERSION="200701" COMMENT="XML-Importfile for mod/feedback">'."\n";
|
||||
$data .= $space.'<ITEMS>'."\n";
|
||||
|
||||
//writing all the items
|
||||
foreach($items as $item) {
|
||||
//start of item
|
||||
$data .= $space.$space.'<ITEM TYPE="'.$item->typ.'" REQUIRED="'.$item->required.'">'."\n";
|
||||
|
||||
//start of itemid
|
||||
$data .= $space.$space.$space.'<ITEMID>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->id;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of itemid
|
||||
$data .= $space.$space.$space.'</ITEMID>'."\n";
|
||||
|
||||
//start of itemtext
|
||||
$data .= $space.$space.$space.'<ITEMTEXT>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->name;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of itemtext
|
||||
$data .= $space.$space.$space.'</ITEMTEXT>'."\n";
|
||||
|
||||
//start of itemtext
|
||||
$data .= $space.$space.$space.'<ITEMLABEL>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->label;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of itemtext
|
||||
$data .= $space.$space.$space.'</ITEMLABEL>'."\n";
|
||||
|
||||
//start of presentation
|
||||
$data .= $space.$space.$space.'<PRESENTATION>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->presentation;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of presentation
|
||||
$data .= $space.$space.$space.'</PRESENTATION>'."\n";
|
||||
|
||||
//start of options
|
||||
$data .= $space.$space.$space.'<OPTIONS>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->options;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of options
|
||||
$data .= $space.$space.$space.'</OPTIONS>'."\n";
|
||||
|
||||
//start of dependitem
|
||||
$data .= $space.$space.$space.'<DEPENDITEM>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->dependitem;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of dependitem
|
||||
$data .= $space.$space.$space.'</DEPENDITEM>'."\n";
|
||||
|
||||
//start of dependvalue
|
||||
$data .= $space.$space.$space.'<DEPENDVALUE>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->dependvalue;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of dependvalue
|
||||
$data .= $space.$space.$space.'</DEPENDVALUE>'."\n";
|
||||
|
||||
//end of item
|
||||
$data .= $space.$space.'</ITEM>'."\n";
|
||||
}
|
||||
|
||||
//writing the footer of the xml file
|
||||
$data .= $space.'</ITEMS>'."\n";
|
||||
$data .= '</FEEDBACK>'."\n";
|
||||
|
||||
return $data;
|
||||
$space = ' ';
|
||||
//get all items of the feedback
|
||||
if (!$items = $DB->get_records('feedback_item', array('feedback'=>$feedbackid), 'position')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function feedback_send_xml_data($data, $filename) {
|
||||
@header('Content-Type: application/xml; charset=UTF-8');
|
||||
@header('Content-Disposition: attachment; filename='.$filename);
|
||||
print($data);
|
||||
//writing the header of the xml file including the charset of the currrent used language
|
||||
$data = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
|
||||
$data .= '<FEEDBACK VERSION="200701" COMMENT="XML-Importfile for mod/feedback">'."\n";
|
||||
$data .= $space.'<ITEMS>'."\n";
|
||||
|
||||
//writing all the items
|
||||
foreach ($items as $item) {
|
||||
//start of item
|
||||
$data .= $space.$space.'<ITEM TYPE="'.$item->typ.'" REQUIRED="'.$item->required.'">'."\n";
|
||||
|
||||
//start of itemid
|
||||
$data .= $space.$space.$space.'<ITEMID>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->id;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of itemid
|
||||
$data .= $space.$space.$space.'</ITEMID>'."\n";
|
||||
|
||||
//start of itemtext
|
||||
$data .= $space.$space.$space.'<ITEMTEXT>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->name;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of itemtext
|
||||
$data .= $space.$space.$space.'</ITEMTEXT>'."\n";
|
||||
|
||||
//start of itemtext
|
||||
$data .= $space.$space.$space.'<ITEMLABEL>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->label;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of itemtext
|
||||
$data .= $space.$space.$space.'</ITEMLABEL>'."\n";
|
||||
|
||||
//start of presentation
|
||||
$data .= $space.$space.$space.'<PRESENTATION>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->presentation;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of presentation
|
||||
$data .= $space.$space.$space.'</PRESENTATION>'."\n";
|
||||
|
||||
//start of options
|
||||
$data .= $space.$space.$space.'<OPTIONS>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->options;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of options
|
||||
$data .= $space.$space.$space.'</OPTIONS>'."\n";
|
||||
|
||||
//start of dependitem
|
||||
$data .= $space.$space.$space.'<DEPENDITEM>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->dependitem;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of dependitem
|
||||
$data .= $space.$space.$space.'</DEPENDITEM>'."\n";
|
||||
|
||||
//start of dependvalue
|
||||
$data .= $space.$space.$space.'<DEPENDVALUE>'."\n";
|
||||
//start of CDATA
|
||||
$data .= $space.$space.$space.$space.'<![CDATA[';
|
||||
$data .= $item->dependvalue;
|
||||
//end of CDATA
|
||||
$data .= ']]>'."\n";
|
||||
//end of dependvalue
|
||||
$data .= $space.$space.$space.'</DEPENDVALUE>'."\n";
|
||||
|
||||
//end of item
|
||||
$data .= $space.$space.'</ITEM>'."\n";
|
||||
}
|
||||
|
||||
//writing the footer of the xml file
|
||||
$data .= $space.'</ITEMS>'."\n";
|
||||
$data .= '</FEEDBACK>'."\n";
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function feedback_send_xml_data($data, $filename) {
|
||||
@header('Content-Type: application/xml; charset=UTF-8');
|
||||
@header('Content-Disposition: attachment; filename='.$filename);
|
||||
print($data);
|
||||
}
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* prints the form to import items from xml-file
|
||||
@ -8,282 +22,271 @@
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once('import_form.php');
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once('import_form.php');
|
||||
|
||||
// get parameters
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$choosefile = optional_param('choosefile', false, PARAM_PATH);
|
||||
$action = optional_param('action', false, PARAM_ALPHA);
|
||||
// get parameters
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$choosefile = optional_param('choosefile', false, PARAM_PATH);
|
||||
$action = optional_param('action', false, PARAM_ALPHA);
|
||||
|
||||
$url = new moodle_url('/mod/feedback/import.php', array('id'=>$id));
|
||||
if ($choosefile !== false) {
|
||||
$url->param('choosefile', $choosefile);
|
||||
}
|
||||
if ($action !== false) {
|
||||
$url->param('action', $action);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$url = new moodle_url('/mod/feedback/import.php', array('id'=>$id));
|
||||
if ($choosefile !== false) {
|
||||
$url->param('choosefile', $choosefile);
|
||||
}
|
||||
if ($action !== false) {
|
||||
$url->param('action', $action);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
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');
|
||||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
|
||||
$mform = new feedback_import_form();
|
||||
$newformdata = array('id'=>$id,
|
||||
'deleteolditems'=>'1',
|
||||
'action'=>'choosefile',
|
||||
'confirmadd'=>'1',
|
||||
'do_show'=>'templates');
|
||||
$mform->set_data($newformdata);
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect('edit.php?id='.$id.'&do_show=templates');
|
||||
}
|
||||
|
||||
// process if we are happy file is ok
|
||||
if ($choosefile) {
|
||||
$xmlcontent = $mform->get_file_content('choosefile');
|
||||
|
||||
if (!$xmldata = feedback_load_xml_data($xmlcontent)) {
|
||||
print_error('cannotloadxml', 'feedback', 'edit.php?id='.$id);
|
||||
}
|
||||
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
$importerror = feedback_import_loaded_data($xmldata, $feedback->id);
|
||||
if ($importerror->stat == true) {
|
||||
$url = 'edit.php?id='.$id.'&do_show=templates';
|
||||
redirect($url, get_string('import_successfully', 'feedback'), 3);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// print the tabs
|
||||
require('tabs.php');
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
echo $OUTPUT->heading(get_string('import_questions', 'feedback'));
|
||||
|
||||
if (isset($importerror->msg) AND is_array($importerror->msg)) {
|
||||
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter');
|
||||
foreach ($importerror->msg as $msg) {
|
||||
echo $msg.'<br />';
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
$mform->display();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function feedback_load_xml_data($xmlcontent) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot.'/lib/xmlize.php');
|
||||
|
||||
if (!$xmlcontent = feedback_check_xml_utf8($xmlcontent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
$data = xmlize($xmlcontent, 1, 'UTF-8');
|
||||
|
||||
if (intval($data['FEEDBACK']['@']['VERSION']) != 200701) {
|
||||
return false;
|
||||
}
|
||||
$data = $data['FEEDBACK']['#']['ITEMS'][0]['#']['ITEM'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
function feedback_import_loaded_data(&$data, $feedbackid) {
|
||||
global $CFG, $DB;
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
feedback_load_feedback_items();
|
||||
|
||||
require_capability('mod/feedback:edititems', $context);
|
||||
$deleteolditems = optional_param('deleteolditems', 0, PARAM_INT);
|
||||
|
||||
$mform = new feedback_import_form();
|
||||
$newformdata = array('id'=>$id,
|
||||
'deleteolditems'=>'1',
|
||||
'action'=>'choosefile',
|
||||
'confirmadd'=>'1',
|
||||
'do_show'=>'templates');
|
||||
$mform->set_data($newformdata);
|
||||
$formdata = $mform->get_data();
|
||||
|
||||
if ($mform->is_cancelled()) {
|
||||
redirect('edit.php?id='.$id.'&do_show=templates');
|
||||
}
|
||||
|
||||
|
||||
// unset($filename);
|
||||
// if ($action == 'choosefile' AND confirm_sesskey() ) {
|
||||
|
||||
////file checks out ok
|
||||
// $fileisgood = false;
|
||||
|
||||
////work out if this is an uploaded file
|
||||
////or one from the filesarea.
|
||||
// if ($choosefile) {
|
||||
// $filename = "{$CFG->dataroot}/{$course->id}/{$choosefile}";
|
||||
// }
|
||||
// }
|
||||
|
||||
// process if we are happy file is ok
|
||||
if ($choosefile) {
|
||||
$xmlcontent = $mform->get_file_content('choosefile');
|
||||
|
||||
if(!$xmldata = feedback_load_xml_data($xmlcontent)) {
|
||||
print_error('cannotloadxml', 'feedback', 'edit.php?id='.$id);
|
||||
}
|
||||
|
||||
$importerror = feedback_import_loaded_data($xmldata, $feedback->id);
|
||||
if($importerror->stat == true) {
|
||||
redirect('edit.php?id='.$id.'&do_show=templates', get_string('import_successfully', 'feedback'), 3);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// print the tabs
|
||||
include('tabs.php');
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
echo $OUTPUT->heading(get_string('import_questions','feedback'));
|
||||
|
||||
if(isset($importerror->msg) AND is_array($importerror->msg)) {
|
||||
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter');
|
||||
foreach($importerror->msg as $msg) {
|
||||
echo $msg.'<br />';
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
$mform->display();
|
||||
|
||||
// echo $OUTPUT->container_start('mdl-align');
|
||||
// echo $OUTPUT->single_button(new moodle_url('edit.php', array('id'=>$id, 'do_show'=>'templates')), get_string('cancel'));
|
||||
// echo $OUTPUT->container_end();
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
function feedback_load_xml_data($xmlcontent) {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot.'/lib/xmlize.php');
|
||||
|
||||
if(!$xmlcontent = feedback_check_xml_utf8($xmlcontent)) return false;
|
||||
|
||||
$data = xmlize($xmlcontent, 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, $DB;
|
||||
|
||||
feedback_load_feedback_items();
|
||||
|
||||
$deleteolditems = optional_param('deleteolditems', 0, PARAM_INT);
|
||||
|
||||
$error = new stdClass();
|
||||
$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 = $DB->count_records('feedback_item', array('feedback'=>$feedbackid));
|
||||
}
|
||||
|
||||
//depend items we are storing temporary in an mapping list array(new id => dependitem)
|
||||
//we also store a mapping of all items array(oldid => newid)
|
||||
$dependitemsmap = array();
|
||||
$itembackup = array();
|
||||
foreach($data as $item) {
|
||||
$position++;
|
||||
//check the typ
|
||||
$typ = $item['@']['TYPE'];
|
||||
|
||||
//check oldtypes first
|
||||
switch($typ) {
|
||||
case 'radio':
|
||||
$typ = 'multichoice';
|
||||
$oldtyp = 'radio';
|
||||
break;
|
||||
case 'dropdown':
|
||||
$typ = 'multichoice';
|
||||
$oldtyp = 'dropdown';
|
||||
break;
|
||||
case 'check':
|
||||
$typ = 'multichoice';
|
||||
$oldtyp = 'check';
|
||||
break;
|
||||
case 'radiorated':
|
||||
$typ = 'multichoicerated';
|
||||
$oldtyp = 'radiorated';
|
||||
break;
|
||||
case 'dropdownrated':
|
||||
$typ = 'multichoicerated';
|
||||
$oldtyp = 'dropdownrated';
|
||||
break;
|
||||
default:
|
||||
$oldtyp = $typ;
|
||||
}
|
||||
|
||||
$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 stdClass();
|
||||
$newitem->feedback = $feedbackid;
|
||||
$newitem->template = 0;
|
||||
$newitem->typ = $typ;
|
||||
$newitem->name = trim($item['#']['ITEMTEXT'][0]['#']);
|
||||
$newitem->label = trim($item['#']['ITEMLABEL'][0]['#']);
|
||||
$newitem->options = trim($item['#']['OPTIONS'][0]['#']);
|
||||
$newitem->presentation = trim($item['#']['PRESENTATION'][0]['#']);
|
||||
//check old types of radio, check, and so on
|
||||
switch($oldtyp) {
|
||||
case 'radio':
|
||||
$newitem->presentation = 'r>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'dropdown':
|
||||
$newitem->presentation = 'd>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'check':
|
||||
$newitem->presentation = 'c>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'radiorated':
|
||||
$newitem->presentation = 'r>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'dropdownrated':
|
||||
$newitem->presentation = 'd>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
}
|
||||
|
||||
if(isset($item['#']['DEPENDITEM'][0]['#'])) {
|
||||
$newitem->dependitem = intval($item['#']['DEPENDITEM'][0]['#']);
|
||||
}else {
|
||||
$newitem->dependitem = 0;
|
||||
}
|
||||
if(isset($item['#']['DEPENDVALUE'][0]['#'])) {
|
||||
$newitem->dependvalue = trim($item['#']['DEPENDVALUE'][0]['#']);
|
||||
}else {
|
||||
$newitem->dependvalue = '';
|
||||
}
|
||||
$olditemid = intval($item['#']['ITEMID'][0]['#']);
|
||||
|
||||
if($typ != 'pagebreak') {
|
||||
$newitem->hasvalue = $itemobj->get_hasvalue();
|
||||
}else {
|
||||
$newitem->hasvalue = 0;
|
||||
}
|
||||
$newitem->required = intval($item['@']['REQUIRED']);
|
||||
$newitem->position = $position;
|
||||
$newid = $DB->insert_record('feedback_item', $newitem);
|
||||
|
||||
$itembackup[$olditemid] = $newid;
|
||||
if($newitem->dependitem) {
|
||||
$dependitemsmap[$newid] = $newitem->dependitem;
|
||||
}
|
||||
|
||||
}
|
||||
//remapping the dependency
|
||||
foreach($dependitemsmap as $key => $dependitem) {
|
||||
$newitem = $DB->get_record('feedback_item', array('id'=>$key));
|
||||
$newitem->dependitem = $itembackup[$newitem->dependitem];
|
||||
$DB->update_record('feedback_item', $newitem);
|
||||
}
|
||||
$error = new stdClass();
|
||||
$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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if ($deleteolditems) {
|
||||
feedback_delete_all_items($feedbackid);
|
||||
$position = 0;
|
||||
} else {
|
||||
//items will be add to the end of the existing items
|
||||
$position = $DB->count_records('feedback_item', array('feedback'=>$feedbackid));
|
||||
}
|
||||
|
||||
//depend items we are storing temporary in an mapping list array(new id => dependitem)
|
||||
//we also store a mapping of all items array(oldid => newid)
|
||||
$dependitemsmap = array();
|
||||
$itembackup = array();
|
||||
foreach ($data as $item) {
|
||||
$position++;
|
||||
//check the typ
|
||||
$typ = $item['@']['TYPE'];
|
||||
|
||||
//check oldtypes first
|
||||
switch($typ) {
|
||||
case 'radio':
|
||||
$typ = 'multichoice';
|
||||
$oldtyp = 'radio';
|
||||
break;
|
||||
case 'dropdown':
|
||||
$typ = 'multichoice';
|
||||
$oldtyp = 'dropdown';
|
||||
break;
|
||||
case 'check':
|
||||
$typ = 'multichoice';
|
||||
$oldtyp = 'check';
|
||||
break;
|
||||
case 'radiorated':
|
||||
$typ = 'multichoicerated';
|
||||
$oldtyp = 'radiorated';
|
||||
break;
|
||||
case 'dropdownrated':
|
||||
$typ = 'multichoicerated';
|
||||
$oldtyp = 'dropdownrated';
|
||||
break;
|
||||
default:
|
||||
$oldtyp = $typ;
|
||||
}
|
||||
|
||||
$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 stdClass();
|
||||
$newitem->feedback = $feedbackid;
|
||||
$newitem->template = 0;
|
||||
$newitem->typ = $typ;
|
||||
$newitem->name = trim($item['#']['ITEMTEXT'][0]['#']);
|
||||
$newitem->label = trim($item['#']['ITEMLABEL'][0]['#']);
|
||||
$newitem->options = trim($item['#']['OPTIONS'][0]['#']);
|
||||
$newitem->presentation = trim($item['#']['PRESENTATION'][0]['#']);
|
||||
//check old types of radio, check, and so on
|
||||
switch($oldtyp) {
|
||||
case 'radio':
|
||||
$newitem->presentation = 'r>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'dropdown':
|
||||
$newitem->presentation = 'd>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'check':
|
||||
$newitem->presentation = 'c>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'radiorated':
|
||||
$newitem->presentation = 'r>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
case 'dropdownrated':
|
||||
$newitem->presentation = 'd>>>>>'.$newitem->presentation;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($item['#']['DEPENDITEM'][0]['#'])) {
|
||||
$newitem->dependitem = intval($item['#']['DEPENDITEM'][0]['#']);
|
||||
} else {
|
||||
$newitem->dependitem = 0;
|
||||
}
|
||||
if (isset($item['#']['DEPENDVALUE'][0]['#'])) {
|
||||
$newitem->dependvalue = trim($item['#']['DEPENDVALUE'][0]['#']);
|
||||
} else {
|
||||
$newitem->dependvalue = '';
|
||||
}
|
||||
$olditemid = intval($item['#']['ITEMID'][0]['#']);
|
||||
|
||||
if ($typ != 'pagebreak') {
|
||||
$newitem->hasvalue = $itemobj->get_hasvalue();
|
||||
} else {
|
||||
$newitem->hasvalue = 0;
|
||||
}
|
||||
$newitem->required = intval($item['@']['REQUIRED']);
|
||||
$newitem->position = $position;
|
||||
$newid = $DB->insert_record('feedback_item', $newitem);
|
||||
|
||||
$itembackup[$olditemid] = $newid;
|
||||
if ($newitem->dependitem) {
|
||||
$dependitemsmap[$newid] = $newitem->dependitem;
|
||||
}
|
||||
|
||||
}
|
||||
//remapping the dependency
|
||||
foreach ($dependitemsmap as $key => $dependitem) {
|
||||
$newitem = $DB->get_record('feedback_item', array('id'=>$key));
|
||||
$newitem->dependitem = $itembackup[$newitem->dependitem];
|
||||
$DB->update_record('feedback_item', $newitem);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//encoding is given in $match[2]
|
||||
if (isset($match[0]) AND isset($match[1]) AND isset($match[2])) {
|
||||
$enc = $match[2];
|
||||
$textlib = textlib_get_instance();
|
||||
return $textlib->convert($text, $enc);
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* prints the forms to choose an xml-template file to import items
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
// 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 forms to choose an xml-template file to import items
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
//It must be included from a Moodle page
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class feedback_import_form extends moodleform {
|
||||
function definition() {
|
||||
public function definition() {
|
||||
global $CFG;
|
||||
$mform =& $this->_form;
|
||||
|
||||
//headline
|
||||
$mform->addElement('header', 'general', '');
|
||||
$strdeleteolditmes = get_string('delete_old_items', 'feedback').' ('.get_string('oldvalueswillbedeleted','feedback').')';
|
||||
$strnodeleteolditmes = get_string('append_new_items', 'feedback').' ('.get_string('oldvaluespreserved','feedback').')';
|
||||
|
||||
$strdeleteolditmes = get_string('delete_old_items', 'feedback').
|
||||
' ('.get_string('oldvalueswillbedeleted', 'feedback').')';
|
||||
|
||||
$strnodeleteolditmes = get_string('append_new_items', 'feedback').
|
||||
' ('.get_string('oldvaluespreserved', 'feedback').')';
|
||||
|
||||
$deleteolditemsarray = array();
|
||||
$mform->addElement('radio', 'deleteolditems', '', $strdeleteolditmes, true);
|
||||
$mform->addElement('radio', 'deleteolditems', '', $strnodeleteolditmes);
|
||||
@ -31,9 +50,12 @@ class feedback_import_form extends moodleform {
|
||||
// hidden elements
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
$mform->addElement('filepicker', 'choosefile', get_string('file'), null, array('maxbytes' => $CFG->maxbytes, 'filetypes' => '*'));
|
||||
$mform->addElement('filepicker',
|
||||
'choosefile',
|
||||
get_string('file'),
|
||||
null,
|
||||
array('maxbytes' => $CFG->maxbytes, 'filetypes' => '*'));
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// buttons
|
||||
$this->add_action_buttons(true, get_string('yes'));
|
||||
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* prints the overview of all feedbacks included into the current course
|
||||
@ -43,7 +57,8 @@ echo $OUTPUT->header();
|
||||
/// Get all the appropriate data
|
||||
|
||||
if (! $feedbacks = get_all_instances_in_course("feedback", $course)) {
|
||||
notice(get_string('thereareno', 'moodle', $strfeedbacks), new moodle_url('/course/view.php', array('id'=>$course->id)));
|
||||
$url = new moodle_url('/course/view.php', array('id'=>$course->id));
|
||||
notice(get_string('thereareno', 'moodle', $strfeedbacks), $url);
|
||||
die;
|
||||
}
|
||||
|
||||
@ -62,18 +77,18 @@ $strresponses = get_string('responses', 'feedback');
|
||||
$table = new html_table();
|
||||
|
||||
if ($usesections) {
|
||||
if(has_capability('mod/feedback:viewreports', $context)) {
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
$table->head = array ($strsectionname, $strname, $strresponses);
|
||||
$table->align = array ("center", "left", 'center');
|
||||
}else{
|
||||
} else {
|
||||
$table->head = array ($strsectionname, $strname);
|
||||
$table->align = array ("center", "left");
|
||||
}
|
||||
} else {
|
||||
if(has_capability('mod/feedback:viewreports', $context)) {
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
$table->head = array ($strname, $strresponses);
|
||||
$table->align = array ("left", "center");
|
||||
}else{
|
||||
} else {
|
||||
$table->head = array ($strname);
|
||||
$table->align = array ("left");
|
||||
}
|
||||
@ -84,8 +99,8 @@ foreach ($feedbacks as $feedback) {
|
||||
//get the responses of each feedback
|
||||
$viewurl = new moodle_url('/mod/feedback/view.php', array('id'=>$feedback->coursemodule));
|
||||
|
||||
if(has_capability('mod/feedback:viewreports', $context)) {
|
||||
$completedFeedbackCount = intval(feedback_get_completeds_group_count($feedback));
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
$completed_feedback_count = intval(feedback_get_completeds_group_count($feedback));
|
||||
}
|
||||
|
||||
$dimmedclass = $feedback->visible ? '' : 'class="dimmed"';
|
||||
@ -96,8 +111,8 @@ foreach ($feedbacks as $feedback) {
|
||||
} else {
|
||||
$tabledata = array ($link);
|
||||
}
|
||||
if(has_capability('mod/feedback:viewreports', $context)) {
|
||||
$tabledata[] = $completedFeedbackCount;
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
$tabledata[] = $completed_feedback_count;
|
||||
}
|
||||
|
||||
$table->data[] = $tabledata;
|
||||
|
@ -1,17 +1,31 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_captcha_form extends feedback_item_form {
|
||||
var $type = "captcha";
|
||||
protected $type = "captcha";
|
||||
|
||||
public function definition() {
|
||||
|
||||
function definition() {
|
||||
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
$position = $this->_customdata['position'];
|
||||
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('header', 'general', get_string($this->type, 'feedback'));
|
||||
@ -28,7 +42,7 @@ class feedback_captcha_form extends feedback_item_form {
|
||||
$mform->addElement('select',
|
||||
'presentation',
|
||||
get_string('count_of_nums', 'feedback').' ',
|
||||
array_slice(range(0,10),3,10,true));
|
||||
array_slice(range(0, 10), 3, 10, true));
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
@ -1,31 +1,47 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_captcha extends feedback_item_base {
|
||||
var $type = "captcha";
|
||||
var $commonparams;
|
||||
var $item_form = false;
|
||||
var $item = false;
|
||||
var $feedback = false;
|
||||
protected $type = "captcha";
|
||||
private $commonparams;
|
||||
private $item_form = false;
|
||||
private $item = false;
|
||||
private $feedback = false;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB;
|
||||
|
||||
$editurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$cm->id));
|
||||
|
||||
//ther are no settings for recaptcha
|
||||
if(isset($item->id) AND $item->id > 0) {
|
||||
if (isset($item->id) AND $item->id > 0) {
|
||||
notice(get_string('there_are_no_settings_for_recaptcha', 'feedback'), $editurl->out());
|
||||
exit;
|
||||
}
|
||||
|
||||
//only one recaptcha can be in a feedback
|
||||
if($DB->record_exists('feedback_item', array('feedback'=>$feedback->id, 'typ'=>$this->type))) {
|
||||
$params = array('feedback' => $feedback->id, 'typ' => $this->type);
|
||||
if ($DB->record_exists('feedback_item', $params)) {
|
||||
notice(get_string('only_one_captcha_allowed', 'feedback'), $editurl->out());
|
||||
exit;
|
||||
}
|
||||
@ -50,27 +66,27 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
$this->item->options = '';
|
||||
}
|
||||
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
public function is_cancelled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
public function get_data() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$this->item) {
|
||||
if (!$this->item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($this->item->id)) {
|
||||
if (empty($this->item->id)) {
|
||||
$this->item->id = $DB->insert_record('feedback_item', $this->item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $this->item);
|
||||
}
|
||||
|
||||
@ -78,20 +94,22 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
}
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function get_printval($item, $value) {
|
||||
public function get_printval($item, $value) {
|
||||
return '';
|
||||
}
|
||||
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
return $itemnr;
|
||||
}
|
||||
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||
return $rowOffset;
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,16 +119,17 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $DB;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$cmid = 0;
|
||||
$feedbackid = $item->feedback;
|
||||
if($feedbackid > 0) {
|
||||
if ($feedbackid > 0) {
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
|
||||
if($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
|
||||
$cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course);
|
||||
if ($cm) {
|
||||
$cmid = $cm->id;
|
||||
}
|
||||
}
|
||||
@ -134,7 +153,7 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $SESSION, $CFG, $DB, $USER;
|
||||
require_once($CFG->libdir.'/recaptchalib.php');
|
||||
|
||||
@ -142,33 +161,38 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
|
||||
$cmid = 0;
|
||||
$feedbackid = $item->feedback;
|
||||
if($feedbackid > 0) {
|
||||
if ($feedbackid > 0) {
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
|
||||
if($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
|
||||
$cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course);
|
||||
if ($cm) {
|
||||
$cmid = $cm->id;
|
||||
}
|
||||
}
|
||||
|
||||
//check if an false value even the value is not required
|
||||
if($highlightrequire AND !$this->check_value($value, $item)) {
|
||||
if ($highlightrequire AND !$this->check_value($value, $item)) {
|
||||
$falsevalue = true;
|
||||
}else {
|
||||
} else {
|
||||
$falsevalue = false;
|
||||
}
|
||||
|
||||
if($falsevalue) {
|
||||
if ($falsevalue) {
|
||||
$highlight = 'missingrequire';
|
||||
}else {
|
||||
} else {
|
||||
$highlight = '';
|
||||
}
|
||||
$requiredmark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
if(isset($SESSION->feedback->captchacheck) AND $SESSION->feedback->captchacheck == $USER->sesskey AND $value == $USER->sesskey) {
|
||||
if (isset($SESSION->feedback->captchacheck) AND
|
||||
$SESSION->feedback->captchacheck == $USER->sesskey AND
|
||||
$value == $USER->sesskey) {
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name.$requiredmark, true, false, false);
|
||||
echo '<input type="hidden" value="'.$USER->sesskey.'" name="'.$item->typ.'_'.$item->id.'" />';
|
||||
$inputname = 'name="'.$item->typ.'_'.$item->id.'"';
|
||||
echo '<input type="hidden" value="'.$USER->sesskey.'" '.$inputname.' />';
|
||||
echo '</div>';
|
||||
return;
|
||||
}
|
||||
@ -187,19 +211,31 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
<div class="'.$highlight.'" id="recaptcha_widget" style="display:none">
|
||||
|
||||
<div id="recaptcha_image"></div>
|
||||
<div class="recaptcha_only_if_incorrect_sol" style="color:red">' . $strincorrectpleasetryagain . '</div>
|
||||
<span class="recaptcha_only_if_image"><label for="recaptcha_response_field">' . $strenterthewordsabove . $requiredmark. '</label></span>
|
||||
<span class="recaptcha_only_if_audio"><label for="recaptcha_response_field">' . $strenterthenumbersyouhear . '</label></span>
|
||||
<div class="recaptcha_only_if_incorrect_sol" style="color:red">'.
|
||||
$strincorrectpleasetryagain.
|
||||
'</div>
|
||||
<span class="recaptcha_only_if_image">
|
||||
<label for="recaptcha_response_field">'.$strenterthewordsabove.$requiredmark.'</label>
|
||||
</span>
|
||||
<span class="recaptcha_only_if_audio">
|
||||
<label for="recaptcha_response_field">'.$strenterthenumbersyouhear.'</label>
|
||||
</span>
|
||||
|
||||
<input type="text" id="recaptcha_response_field" name="'.$item->typ.'_'.$item->id.'" />
|
||||
|
||||
<div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div>
|
||||
<div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a></div>
|
||||
<div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a></div>
|
||||
<div class="recaptcha_only_if_image">
|
||||
<a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a>
|
||||
</div>
|
||||
<div class="recaptcha_only_if_audio">
|
||||
<a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a>
|
||||
</div>
|
||||
</div>';
|
||||
//we have to rename the challengefield
|
||||
$captchahtml = recaptcha_get_html($CFG->recaptchapublickey, NULL);
|
||||
echo $html.$captchahtml;
|
||||
if (!empty($CFG->recaptchaprivatekey) AND !empty($CFG->recaptchapublickey)) {
|
||||
$captchahtml = recaptcha_get_html($CFG->recaptchapublickey, null);
|
||||
echo $html.$captchahtml;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,16 +246,16 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $DB;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$cmid = 0;
|
||||
$feedbackid = $item->feedback;
|
||||
if($feedbackid > 0) {
|
||||
if ($feedbackid > 0) {
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$feedbackid));
|
||||
if($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
|
||||
if ($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) {
|
||||
$cmid = $cm->id;
|
||||
}
|
||||
}
|
||||
@ -234,18 +270,22 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
}
|
||||
|
||||
|
||||
function check_value($value, $item) {
|
||||
public function check_value($value, $item) {
|
||||
global $SESSION, $CFG, $USER;
|
||||
require_once($CFG->libdir.'/recaptchalib.php');
|
||||
|
||||
//is recaptcha configured in moodle?
|
||||
if (empty($CFG->recaptchaprivatekey) OR empty($CFG->recaptchapublickey)) {
|
||||
return true;
|
||||
}
|
||||
$challenge = optional_param('recaptcha_challenge_field', '', PARAM_RAW);
|
||||
|
||||
if($value == $USER->sesskey AND $challenge == '') {
|
||||
if ($value == $USER->sesskey AND $challenge == '') {
|
||||
return true;
|
||||
}
|
||||
$remoteip = getremoteaddr(null);
|
||||
$response = recaptcha_check_answer($CFG->recaptchaprivatekey, $remoteip, $challenge, $value);
|
||||
if($response->is_valid) {
|
||||
if ($response->is_valid) {
|
||||
$SESSION->feedback->captchacheck = $USER->sesskey;
|
||||
return true;
|
||||
}
|
||||
@ -254,7 +294,7 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
global $USER;
|
||||
return $USER->sesskey;
|
||||
}
|
||||
@ -262,22 +302,28 @@ class feedback_item_captcha extends feedback_item_base {
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is value stored in the db
|
||||
//dependvalue is the value to check
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if($dbvalue == $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_presentation($data) {
|
||||
public function get_presentation($data) {
|
||||
return '';
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
global $CFG;
|
||||
|
||||
//is recaptcha configured in moodle?
|
||||
if (empty($CFG->recaptchaprivatekey) OR empty($CFG->recaptchapublickey)) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
public function can_switch_require() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -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/>.
|
||||
|
||||
require_once('../../../../config.php');
|
||||
|
||||
@ -20,13 +34,12 @@ if ($id) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($SESSION->feedback->item->captcha)) {
|
||||
if (!isset($SESSION->feedback->item->captcha)) {
|
||||
print_error('captchanotset', 'feedback');
|
||||
}
|
||||
|
||||
$height = 40;
|
||||
$charcount = $SESSION->feedback->item->captcha->charcount;
|
||||
// $fontfile = $CFG->dirroot.'/mod/feedback/item/captcha/default.ttf';
|
||||
$fontfile = $CFG->libdir.'/default.ttf';
|
||||
|
||||
$ttfbox = imagettfbbox ( 30, 0, $fontfile, 'H' );//the text to measure
|
||||
@ -36,14 +49,12 @@ $width = $charcount * $charwidth;
|
||||
|
||||
$scale = 0.3;
|
||||
$elipsesize = intval((($width + $height)/2) / 5);
|
||||
$factorX = intval($width * $scale);
|
||||
$factorY = intval($height * $scale);
|
||||
$factor_x = intval($width * $scale);
|
||||
$factor_y = 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);
|
||||
$colors = array(array(0, 40), array(50, 200), array(210, 255));
|
||||
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
|
||||
@ -53,18 +64,15 @@ $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-
|
||||
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++) {
|
||||
for ($x = 0; $x < $factor_x; $x++) {
|
||||
for ($y = 0; $y < $factor_y; $y++) {
|
||||
$propobj = new stdClass();
|
||||
$propobj->x = intval($x / $scale);
|
||||
$propobj->y = intval($y / $scale);
|
||||
@ -79,7 +87,7 @@ shuffle($properties);
|
||||
// create a blank image
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
$bg = imagecolorallocate($image, 0, 0, 0);
|
||||
for($i = 0; $i < ($factorX * $factorY); $i++) {
|
||||
for ($i = 0; $i < ($factor_x * $factor_y); $i++) {
|
||||
$propobj = $properties[$i];
|
||||
// choose a color for the ellipse
|
||||
$col_ellipse = imagecolorallocate($image, $propobj->red, $propobj->green, $propobj->blue);
|
||||
@ -88,8 +96,8 @@ for($i = 0; $i < ($factorX * $factorY); $i++) {
|
||||
}
|
||||
|
||||
$checkchar = '';
|
||||
for($i = 0; $i < $charcount; $i++) {
|
||||
$colnum = rand(1,2);
|
||||
for ($i = 0; $i < $charcount; $i++) {
|
||||
$colnum = rand(1, 2);
|
||||
$textcol = new stdClass();
|
||||
$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]);
|
||||
@ -99,7 +107,7 @@ for($i = 0; $i < $charcount; $i++) {
|
||||
$left_text = $i * $charwidth;
|
||||
$text = $nums[$i];
|
||||
$checkchar .= $text;
|
||||
ImageTTFText ($image, 30, $angle_text, $left_text, 35, $color_text, $fontfile, $text);
|
||||
imagettftext($image, 30, $angle_text, $left_text, 35, $color_text, $fontfile, $text);
|
||||
}
|
||||
|
||||
$SESSION->feedback->item->captcha->checkchar = $checkchar;
|
||||
@ -114,5 +122,3 @@ function get_random_color($val1 = 0, $val2 = 255) {
|
||||
|
||||
return rand($min, $max);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,51 +1,75 @@
|
||||
<?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/>.
|
||||
|
||||
abstract class feedback_item_base {
|
||||
var $type;
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
*/
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract function init();
|
||||
abstract function build_editform($item, $feedback, $cm);
|
||||
abstract function save_item();
|
||||
abstract function check_value($value, $item);
|
||||
abstract function create_value($data);
|
||||
abstract function compare_value($item, $dbvalue, $dependvalue);
|
||||
abstract function get_presentation($data);
|
||||
abstract function get_hasvalue();
|
||||
abstract function can_switch_require();
|
||||
|
||||
public function value_type() {
|
||||
return PARAM_RAW;
|
||||
}
|
||||
|
||||
public function value_is_array() {
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract public function init();
|
||||
abstract public function build_editform($item, $feedback, $cm);
|
||||
abstract public function save_item();
|
||||
abstract public function check_value($value, $item);
|
||||
abstract public function create_value($data);
|
||||
abstract public function compare_value($item, $dbvalue, $dependvalue);
|
||||
abstract public function get_presentation($data);
|
||||
abstract public function get_hasvalue();
|
||||
abstract public function can_switch_require();
|
||||
|
||||
/**
|
||||
* @param object $worksheet a reference to the pear_spreadsheet-object
|
||||
* @param integer $rowOffset
|
||||
* @param integer $row_offset
|
||||
* @param object $item the db-object from feedback_item
|
||||
* @param integer $groupid
|
||||
* @param integer $courseid
|
||||
* @return integer the new rowOffset
|
||||
*/
|
||||
abstract function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false);
|
||||
* @return integer the new row_offset
|
||||
*/
|
||||
abstract public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false);
|
||||
|
||||
/**
|
||||
* @param $item the db-object from feedback_item
|
||||
@ -53,16 +77,16 @@ abstract class feedback_item_base {
|
||||
* @param integer $groupid
|
||||
* @param integer $courseid
|
||||
* @return integer the new itemnr
|
||||
*/
|
||||
abstract function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false);
|
||||
|
||||
*/
|
||||
abstract public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false);
|
||||
|
||||
/**
|
||||
* @param object $item the db-object from feedback_item
|
||||
* @param string $value a item-related value from feedback_values
|
||||
* @return string
|
||||
*/
|
||||
abstract function get_printval($item, $value);
|
||||
|
||||
*/
|
||||
abstract public function get_printval($item, $value);
|
||||
|
||||
/**
|
||||
* returns an Array with three values(typ, name, XXX)
|
||||
* XXX is also an Array (count of responses on type $this->type)
|
||||
@ -71,9 +95,9 @@ abstract class feedback_item_base {
|
||||
* @param $groupid if given
|
||||
* @param $courseid if given
|
||||
* @return array
|
||||
*/
|
||||
abstract function get_analysed($item, $groupid = false, $courseid = false);
|
||||
|
||||
*/
|
||||
abstract public function get_analysed($item, $groupid = false, $courseid = false);
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
@ -81,8 +105,8 @@ abstract class feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
abstract function print_item_preview($item);
|
||||
|
||||
abstract public function print_item_preview($item);
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
@ -92,7 +116,7 @@ abstract class feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
abstract function print_item_complete($item, $value = '', $highlightrequire = false);
|
||||
abstract public function print_item_complete($item, $value = '', $highlightrequire = false);
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
@ -102,33 +126,55 @@ abstract class feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
abstract function print_item_show_value($item, $value = '');
|
||||
abstract public function print_item_show_value($item, $value = '');
|
||||
|
||||
}
|
||||
|
||||
//a dummy class to realize pagebreaks
|
||||
class feedback_item_pagebreak extends feedback_item_base {
|
||||
var $type = "pagebreak";
|
||||
protected $type = "pagebreak";
|
||||
|
||||
function show_editform() {}
|
||||
function is_cancelled() {}
|
||||
function get_data() {}
|
||||
function init() {}
|
||||
function build_editform($item, $feedback, $cm) {}
|
||||
function save_item() {}
|
||||
function check_value($value, $item) {}
|
||||
function create_value($data) {}
|
||||
function compare_value($item, $dbvalue, $dependvalue) {}
|
||||
function get_presentation($data) {}
|
||||
function get_hasvalue() {}
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {}
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {}
|
||||
function get_printval($item, $value) {}
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {}
|
||||
function print_item_preview($item) {}
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {}
|
||||
function print_item_show_value($item, $value = '') {}
|
||||
function can_switch_require(){}
|
||||
public function show_editform() {
|
||||
}
|
||||
public function is_cancelled() {
|
||||
}
|
||||
public function get_data() {
|
||||
}
|
||||
public function init() {
|
||||
}
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
}
|
||||
public function save_item() {
|
||||
}
|
||||
public function check_value($value, $item) {
|
||||
}
|
||||
public function create_value($data) {
|
||||
}
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
}
|
||||
public function get_presentation($data) {
|
||||
}
|
||||
public function get_hasvalue() {
|
||||
}
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
}
|
||||
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
}
|
||||
public function get_printval($item, $value) {
|
||||
}
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
}
|
||||
public function print_item_preview($item) {
|
||||
}
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
}
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
}
|
||||
public function can_switch_require() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,27 @@
|
||||
<?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/>.
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
define('FEEDBACK_ITEM_NAME_TEXTBOX_SIZE', 80);
|
||||
define('FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE', 20);
|
||||
abstract class feedback_item_form extends moodleform {
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$item = $this->_customdata['item']; //the item object
|
||||
|
||||
|
||||
//common is an array like:
|
||||
// array('cmid'=>$cm->id,
|
||||
// 'id'=>isset($item->id) ? $item->id : NULL,
|
||||
@ -15,16 +29,16 @@ abstract class feedback_item_form extends moodleform {
|
||||
// 'items'=>$feedbackitems,
|
||||
// 'feedback'=>$feedback->id);
|
||||
$common = $this->_customdata['common'];
|
||||
|
||||
|
||||
//positionlist is an array with possible positions for the item location
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
|
||||
|
||||
//the current position of the item
|
||||
$position = $this->_customdata['position'];
|
||||
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
if($common['items']) {
|
||||
|
||||
if ($common['items']) {
|
||||
$mform->addElement('select',
|
||||
'dependitem',
|
||||
get_string('dependitem', 'feedback').' ',
|
||||
@ -35,7 +49,7 @@ abstract class feedback_item_form extends moodleform {
|
||||
'dependvalue',
|
||||
get_string('dependvalue', 'feedback'),
|
||||
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 'maxlength'=>255));
|
||||
}else {
|
||||
} else {
|
||||
$mform->addElement('hidden', 'dependitem', 0);
|
||||
$mform->setType('dependitem', PARAM_INT);
|
||||
$mform->addElement('hidden', 'dependvalue', '');
|
||||
@ -47,23 +61,22 @@ abstract class feedback_item_form extends moodleform {
|
||||
get_string('position', 'feedback').' ',
|
||||
$positionlist);
|
||||
$position_select->setValue($position);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'cmid', $common['cmid']);
|
||||
$mform->setType('cmid', PARAM_INT);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'id', $common['id']);
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'feedback', $common['feedback']);
|
||||
$mform->setType('feedback', PARAM_INT);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'template', 0);
|
||||
$mform->setType('template', PARAM_INT);
|
||||
|
||||
|
||||
$mform->setType('name', PARAM_RAW);
|
||||
$mform->setType('label', PARAM_ALPHANUM);
|
||||
|
||||
|
||||
$mform->addElement('hidden', 'typ', $this->type);
|
||||
$mform->setType('typ', PARAM_ALPHA);
|
||||
|
||||
@ -74,17 +87,24 @@ abstract class feedback_item_form extends moodleform {
|
||||
$mform->setType('options', PARAM_ALPHA);
|
||||
|
||||
$buttonarray = array();
|
||||
if(!empty($item->id)){
|
||||
$buttonarray[] = &$mform->createElement('submit', 'update_item', get_string('update_item', 'feedback'));
|
||||
$buttonarray[] = &$mform->createElement('submit', 'clone_item', get_string('save_as_new_item', 'feedback'));
|
||||
}else{
|
||||
if (!empty($item->id)) {
|
||||
$buttonarray[] = &$mform->createElement('submit',
|
||||
'update_item',
|
||||
get_string('update_item', 'feedback'));
|
||||
|
||||
$buttonarray[] = &$mform->createElement('submit',
|
||||
'clone_item',
|
||||
get_string('save_as_new_item', 'feedback'));
|
||||
} else {
|
||||
$mform->addElement('hidden', 'clone_item', 0);
|
||||
$mform->setType('clone_item', PARAM_INT);
|
||||
$buttonarray[] = &$mform->createElement('submit', 'save_item', get_string('save_item', 'feedback'));
|
||||
$buttonarray[] = &$mform->createElement('submit',
|
||||
'save_item',
|
||||
get_string('save_item', 'feedback'));
|
||||
}
|
||||
$buttonarray[] = &$mform->createElement('cancel');
|
||||
$mform->addGroup($buttonarray, 'buttonar', ' ', array(' '), false);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,31 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_info_form extends feedback_item_form {
|
||||
var $type = "info";
|
||||
protected $type = "info";
|
||||
|
||||
public function definition() {
|
||||
|
||||
function definition() {
|
||||
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
$position = $this->_customdata['position'];
|
||||
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('header', 'general', get_string($this->type, 'feedback'));
|
||||
@ -31,7 +45,10 @@ class feedback_info_form extends feedback_item_form {
|
||||
$options[1] = get_string('responsetime', 'feedback');
|
||||
$options[2] = get_string('course');
|
||||
$options[3] = get_string('coursecategory');
|
||||
$this->infotype = &$mform->addElement('select', 'presentation', get_string('infotype', 'feedback'), $options);
|
||||
$this->infotype = &$mform->addElement('select',
|
||||
'presentation',
|
||||
get_string('infotype', 'feedback'),
|
||||
$options);
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
@ -1,34 +1,49 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_info extends feedback_item_base {
|
||||
var $type = "info";
|
||||
var $commonparams;
|
||||
var $item_form;
|
||||
var $item;
|
||||
protected $type = "info";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
require_once('info_form.php');
|
||||
|
||||
//get the lastposition number of the feedback_items
|
||||
$position = $item->position;
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
if($position == -1){
|
||||
if ($position == -1) {
|
||||
$i_formselect_last = $lastposition + 1;
|
||||
$i_formselect_value = $lastposition + 1;
|
||||
$item->position = $lastposition + 1;
|
||||
}else {
|
||||
} else {
|
||||
$i_formselect_last = $lastposition;
|
||||
$i_formselect_value = $item->position;
|
||||
}
|
||||
//the elements for position dropdownlist
|
||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
||||
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
|
||||
|
||||
$item->presentation = empty($item->presentation) ? 1 : $item->presentation;
|
||||
$item->required = 0;
|
||||
@ -36,47 +51,51 @@ class feedback_item_info extends feedback_item_base {
|
||||
//all items for dependitem
|
||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
||||
$commonparams = array('cmid'=>$cm->id,
|
||||
'id'=>isset($item->id) ? $item->id : NULL,
|
||||
'id'=>isset($item->id) ? $item->id : null,
|
||||
'typ'=>$item->typ,
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
|
||||
//build the form
|
||||
$this->item_form = new feedback_info_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
|
||||
$this->item_form = new feedback_info_form('edit_item.php',
|
||||
array('item'=>$item,
|
||||
'common'=>$commonparams,
|
||||
'positionlist'=>$positionlist,
|
||||
'position' => $position));
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$item = $this->item_form->get_data()) {
|
||||
if (!$item = $this->item_form->get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($item->clone_item) AND $item->clone_item) {
|
||||
if (isset($item->clone_item) AND $item->clone_item) {
|
||||
$item->id = ''; //to clone this item
|
||||
$item->position++;
|
||||
}
|
||||
|
||||
$item->hasvalue = $this->get_hasvalue();
|
||||
if(!$item->id) {
|
||||
if (!$item->id) {
|
||||
$item->id = $DB->insert_record('feedback_item', $item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $item);
|
||||
}
|
||||
|
||||
@ -84,23 +103,22 @@ class feedback_item_info extends feedback_item_base {
|
||||
}
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
|
||||
$presentation = $item->presentation;
|
||||
$aVal = null;
|
||||
$aVal->data = null;
|
||||
$aVal->name = $item->name;
|
||||
//$values = get_records('feedback_value', 'item', $item->id);
|
||||
$analysed_val = null;
|
||||
$analysed_val->data = null;
|
||||
$analysed_val->name = $item->name;
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid);
|
||||
if($values) {
|
||||
if ($values) {
|
||||
$data = array();
|
||||
$datavalue = new stdClass();
|
||||
foreach($values as $value) {
|
||||
foreach ($values as $value) {
|
||||
|
||||
switch($presentation) {
|
||||
case 1:
|
||||
$datavalue->value = $value->value;
|
||||
$datavalue->show = UserDate($datavalue->value);
|
||||
$datavalue->show = userdate($datavalue->value);
|
||||
break;
|
||||
case 2:
|
||||
$datavalue->value = $value->value;
|
||||
@ -114,50 +132,54 @@ class feedback_item_info extends feedback_item_base {
|
||||
|
||||
$data[] = $datavalue;
|
||||
}
|
||||
$aVal->data = $data;
|
||||
$analysed_val->data = $data;
|
||||
}
|
||||
return $aVal;
|
||||
return $analysed_val;
|
||||
}
|
||||
|
||||
function get_printval($item, $value) {
|
||||
public function get_printval($item, $value) {
|
||||
|
||||
if(!isset($value->value)) return '';
|
||||
return UserDate($value->value);
|
||||
if (!isset($value->value)) {
|
||||
return '';
|
||||
}
|
||||
return userdate($value->value);
|
||||
}
|
||||
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
$data = $analysed_item->data;
|
||||
if (is_array($data)) {
|
||||
echo '<tr><th colspan="2" align="left">'. $itemnr . ' ('. $item->label .') ' . $item->name .'</th></tr>';
|
||||
$sizeofdata = sizeof($data);
|
||||
echo '<tr><th colspan="2" align="left">';
|
||||
echo $itemnr.' ('.$item->label.') '.$item->name;
|
||||
echo '</th></tr>';
|
||||
$sizeofdata = count($data);
|
||||
for ($i = 0; $i < $sizeofdata; $i++) {
|
||||
echo '<tr><td colspan="2" valign="top" align="left">- ' . str_replace("\n", '<br />', $data[$i]->show) . '</td></tr>';
|
||||
echo '<tr><td colspan="2" valign="top" align="left">- ';
|
||||
echo str_replace("\n", '<br />', $data[$i]->show);
|
||||
echo '</td></tr>';
|
||||
}
|
||||
}
|
||||
// return $itemnr;
|
||||
}
|
||||
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:green>");
|
||||
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
|
||||
$worksheet->write_string($rowOffset, 1, $item->name, $xlsFormats->head2);
|
||||
$worksheet->write_string($row_offset, 0, $item->label, $xls_formats->head2);
|
||||
$worksheet->write_string($row_offset, 1, $item->name, $xls_formats->head2);
|
||||
$data = $analysed_item->data;
|
||||
if (is_array($data)) {
|
||||
// $worksheet->setFormat("<l><ro2><vo>");
|
||||
$worksheet->write_string($rowOffset, 2, $data[0]->show, $xlsFormats->value_bold);
|
||||
$rowOffset++;
|
||||
$sizeofdata = sizeof($data);
|
||||
$worksheet->write_string($row_offset, 2, $data[0]->show, $xls_formats->value_bold);
|
||||
$row_offset++;
|
||||
$sizeofdata = count($data);
|
||||
for ($i = 1; $i < $sizeofdata; $i++) {
|
||||
// $worksheet->setFormat("<l><vo>");
|
||||
$worksheet->write_string($rowOffset, 2, $data[$i]->show, $xlsFormats->default);
|
||||
$rowOffset++;
|
||||
$worksheet->write_string($row_offset, 2, $data[$i]->show, $xls_formats->default);
|
||||
$row_offset++;
|
||||
}
|
||||
}
|
||||
$rowOffset++;
|
||||
return $rowOffset;
|
||||
$row_offset++;
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,29 +189,52 @@ class feedback_item_info extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$presentation = $item->presentation;
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$item->feedback));
|
||||
$course = $DB->get_record('course', array('id'=>$feedback->course));
|
||||
$coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
|
||||
if ($item->feedback) {
|
||||
$courseid = $DB->get_field('feedback', 'course', array('id'=>$item->feedback));
|
||||
} else { // the item must be a template item
|
||||
$cmid = required_param('id', PARAM_INT);
|
||||
$courseid = $DB->get_field('course_modules', 'course', array('id'=>$cmid));
|
||||
}
|
||||
if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
|
||||
print_error('error');
|
||||
}
|
||||
if ($course->id !== SITEID) {
|
||||
$coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
|
||||
} else {
|
||||
$coursecategory = false;
|
||||
}
|
||||
switch($presentation) {
|
||||
case 1:
|
||||
$itemvalue = time();
|
||||
$itemshowvalue = UserDate($itemvalue);
|
||||
$itemshowvalue = userdate($itemvalue);
|
||||
break;
|
||||
case 2:
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$itemvalue = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$itemvalue = format_string($course->shortname,
|
||||
true,
|
||||
array('context' => $coursecontext));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
break;
|
||||
case 3:
|
||||
$itemvalue = format_string($coursecategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $coursecategory->id)));
|
||||
$itemshowvalue = $itemvalue;
|
||||
if ($coursecategory) {
|
||||
$category_context = get_context_instance(CONTEXT_COURSECAT, $coursecategory->id);
|
||||
$itemvalue = format_string($coursecategory->name,
|
||||
true,
|
||||
array('context' => $category_context));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
} else {
|
||||
$itemvalue = '';
|
||||
$itemshowvalue = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -197,16 +242,18 @@ class feedback_item_info extends feedback_item_base {
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name.$requiredmark, true, false, false);
|
||||
if($item->dependitem) {
|
||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.$dependitem->label.'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<input type="hidden" name="'.$item->typ.'_'.$item->id.'" value="'.$itemvalue.'" />';
|
||||
echo '<span class="feedback_item_info">'.$itemshowvalue.'</span>';
|
||||
echo '<input type="hidden" name="'.$item->typ.'_'.$item->id.'" value="'.$itemvalue.'" />';
|
||||
echo '<span class="feedback_item_info">'.$itemshowvalue.'</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
@ -219,34 +266,52 @@ class feedback_item_info extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$presentation = $item->presentation;
|
||||
if($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
if ($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
$highlight = ' missingrequire';
|
||||
}else {
|
||||
} else {
|
||||
$highlight = '';
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
$feedback = $DB->get_record('feedback', array('id'=>$item->feedback));
|
||||
$course = $DB->get_record('course', array('id'=>$feedback->course));
|
||||
$coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
|
||||
|
||||
if ($course->id !== SITEID) {
|
||||
$coursecategory = $DB->get_record('course_categories', array('id'=>$course->category));
|
||||
} else {
|
||||
$coursecategory = false;
|
||||
}
|
||||
|
||||
switch($presentation) {
|
||||
case 1:
|
||||
$itemvalue = time();
|
||||
$itemshowvalue = UserDate($itemvalue);
|
||||
$itemshowvalue = userdate($itemvalue);
|
||||
break;
|
||||
case 2:
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$itemvalue = format_string($course->shortname, true, array('context' => $coursecontext));
|
||||
$itemvalue = format_string($course->shortname,
|
||||
true,
|
||||
array('context' => $coursecontext));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
break;
|
||||
case 3:
|
||||
$itemvalue = format_string($coursecategory->name, true, array('context' => get_context_instance(CONTEXT_COURSECAT, $coursecategory->id)));
|
||||
$itemshowvalue = $itemvalue;
|
||||
if ($coursecategory) {
|
||||
$category_context = get_context_instance(CONTEXT_COURSECAT, $coursecategory->id);
|
||||
$itemvalue = format_string($coursecategory->name,
|
||||
true,
|
||||
array('context' => $category_context));
|
||||
|
||||
$itemshowvalue = $itemvalue;
|
||||
} else {
|
||||
$itemvalue = '';
|
||||
$itemshowvalue = '';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -257,8 +322,8 @@ class feedback_item_info extends feedback_item_base {
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<input type="hidden" name="'.$item->typ.'_'.$item->id.'" value="'.$itemvalue.'" />';
|
||||
echo '<span class="feedback_item_info">'.$itemshowvalue.'</span>';
|
||||
echo '<input type="hidden" name="'.$item->typ.'_'.$item->id.'" value="'.$itemvalue.'" />';
|
||||
echo '<span class="feedback_item_info">'.$itemshowvalue.'</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
@ -270,15 +335,15 @@ class feedback_item_info extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $USER, $DB, $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$presentation = $item->presentation;
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
if($presentation == 1) {
|
||||
$value = $value ? UserDate($value) : ' ';
|
||||
if ($presentation == 1) {
|
||||
$value = $value ? userdate($value) : ' ';
|
||||
}
|
||||
|
||||
//print the question and label
|
||||
@ -293,11 +358,11 @@ class feedback_item_info extends feedback_item_base {
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
function check_value($value, $item) {
|
||||
public function check_value($value, $item) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
$data = clean_text($data);
|
||||
return $data;
|
||||
}
|
||||
@ -305,22 +370,22 @@ class feedback_item_info extends feedback_item_base {
|
||||
//compares the dbvalue with the dependvalue
|
||||
//the values can be the shortname of a course or the category name
|
||||
//the date is not compareable :(.
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if($dbvalue == $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_presentation($data) {
|
||||
public function get_presentation($data) {
|
||||
return $data->infotype;
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
public function can_switch_require() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,34 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_label_form extends feedback_item_form {
|
||||
var $type = "label";
|
||||
var $area;
|
||||
protected $type = "label";
|
||||
private $area;
|
||||
|
||||
function definition() {
|
||||
public function definition() {
|
||||
global $CFG;
|
||||
|
||||
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$presentationoptions = $this->_customdata['presentationoptions'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
$position = $this->_customdata['position'];
|
||||
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $common['cmid']);
|
||||
|
||||
$mform =& $this->_form;
|
||||
@ -25,12 +39,11 @@ class feedback_label_form extends feedback_item_form {
|
||||
$mform->setType('template', PARAM_ALPHA);
|
||||
$mform->addElement('hidden', 'label', '-');
|
||||
$mform->setType('label', PARAM_ALPHA);
|
||||
|
||||
|
||||
|
||||
$mform->addElement('header', 'general', get_string($this->type, 'feedback'));
|
||||
$mform->addElement('editor', 'presentation_editor', '', null, $presentationoptions);
|
||||
$mform->setType('presentation_editor', PARAM_CLEANHTML);
|
||||
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
|
@ -1,57 +1,73 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class feedback_item_label extends feedback_item_base {
|
||||
var $type = "label";
|
||||
var $presentationoptions = null;
|
||||
var $commonparams;
|
||||
var $item_form;
|
||||
var $context;
|
||||
var $item;
|
||||
protected $type = "label";
|
||||
private $presentationoptions = null;
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $context;
|
||||
private $item;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
global $CFG;
|
||||
$this->presentationoptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'trusttext'=>true);
|
||||
$this->presentationoptions = array('maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||
'trusttext'=>true);
|
||||
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
require_once('label_form.php');
|
||||
|
||||
//get the lastposition number of the feedback_items
|
||||
$position = $item->position;
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
if($position == -1){
|
||||
if ($position == -1) {
|
||||
$i_formselect_last = $lastposition + 1;
|
||||
$i_formselect_value = $lastposition + 1;
|
||||
$item->position = $lastposition + 1;
|
||||
}else {
|
||||
} else {
|
||||
$i_formselect_last = $lastposition;
|
||||
$i_formselect_value = $item->position;
|
||||
}
|
||||
//the elements for position dropdownlist
|
||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
||||
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
|
||||
|
||||
//all items for dependitem
|
||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
||||
$commonparams = array('cmid'=>$cm->id,
|
||||
'id'=>isset($item->id) ? $item->id : NULL,
|
||||
'id'=>isset($item->id) ? $item->id : null,
|
||||
'typ'=>$item->typ,
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
|
||||
$this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
|
||||
//preparing the editor for new file-api
|
||||
$item->presentationformat = FORMAT_HTML;
|
||||
$item->presentationtrust = 1;
|
||||
|
||||
// Append editor context to presentation options, giving preference to existing context.
|
||||
$this->presentationoptions = array_merge(array('context' => $this->context), $this->presentationoptions);
|
||||
$this->presentationoptions = array_merge(array('context' => $this->context),
|
||||
$this->presentationoptions);
|
||||
|
||||
$item = file_prepare_standard_editor($item,
|
||||
'presentation', //name of the form element
|
||||
@ -62,33 +78,39 @@ class feedback_item_label extends feedback_item_base {
|
||||
$item->id);
|
||||
|
||||
//build the form
|
||||
$this->item_form = new feedback_label_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position, 'presentationoptions'=>$this->presentationoptions));
|
||||
$customdata = array('item' => $item,
|
||||
'common' => $commonparams,
|
||||
'positionlist' => $positionlist,
|
||||
'position' => $position,
|
||||
'presentationoptions' => $this->presentationoptions);
|
||||
|
||||
$this->item_form = new feedback_label_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$item = $this->item_form->get_data()) {
|
||||
if (!$item = $this->item_form->get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($item->clone_item) AND $item->clone_item) {
|
||||
if (isset($item->clone_item) AND $item->clone_item) {
|
||||
$item->id = ''; //to clone this item
|
||||
$item->position++;
|
||||
}
|
||||
@ -96,9 +118,9 @@ class feedback_item_label extends feedback_item_base {
|
||||
$item->presentation = '';
|
||||
|
||||
$item->hasvalue = $this->get_hasvalue();
|
||||
if(!$item->id) {
|
||||
if (!$item->id) {
|
||||
$item->id = $DB->insert_record('feedback_item', $item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $item);
|
||||
}
|
||||
|
||||
@ -115,21 +137,21 @@ class feedback_item_label extends feedback_item_base {
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
function print_item($item){
|
||||
public function print_item($item) {
|
||||
global $DB, $CFG;
|
||||
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
//is the item a template?
|
||||
if(!$item->feedback AND $item->template) {
|
||||
if (!$item->feedback AND $item->template) {
|
||||
$template = $DB->get_record('feedback_template', array('id'=>$item->template));
|
||||
if($template->ispublic) {
|
||||
if ($template->ispublic) {
|
||||
$context = get_system_context();
|
||||
}else {
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $template->course);
|
||||
}
|
||||
$filearea = 'template';
|
||||
}else {
|
||||
} else {
|
||||
$cm = get_coursemodule_from_instance('feedback', $item->feedback);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$filearea = 'item';
|
||||
@ -138,7 +160,13 @@ class feedback_item_label extends feedback_item_base {
|
||||
$item->presentationformat = FORMAT_HTML;
|
||||
$item->presentationtrust = 1;
|
||||
|
||||
$output = file_rewrite_pluginfile_urls($item->presentation, 'pluginfile.php', $context->id, 'mod_feedback', $filearea, $item->id);
|
||||
$output = file_rewrite_pluginfile_urls($item->presentation,
|
||||
'pluginfile.php',
|
||||
$context->id,
|
||||
'mod_feedback',
|
||||
$filearea,
|
||||
$item->id);
|
||||
|
||||
echo format_text($output, FORMAT_HTML, array('overflowdiv'=>true));
|
||||
}
|
||||
|
||||
@ -149,12 +177,14 @@ class feedback_item_label extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
if($item->dependitem) {
|
||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.$dependitem->label.'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
$this->print_item($item);
|
||||
@ -169,7 +199,7 @@ class feedback_item_label extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
$this->print_item($item);
|
||||
}
|
||||
|
||||
@ -181,58 +211,62 @@ class feedback_item_label extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
$this->print_item($item);
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//used by create_item and update_item functions,
|
||||
//when provided $data submitted from feedback_show_edit
|
||||
function get_presentation($data) {
|
||||
// $context = get_context_instance(CONTEXT_MODULE, $data->cmid);
|
||||
|
||||
// $presentation = new stdClass();
|
||||
// $presentation->id = null;
|
||||
// $presentation->definition = '';
|
||||
// $presentation->format = FORMAT_HTML;
|
||||
|
||||
// $draftid_editor = file_get_submitted_draft_itemid('presentation');
|
||||
// $currenttext = file_prepare_draft_area($draftid_editor, $context->id, 'mod_feedback', 'item_label', $presentation->id, array('subdirs'=>true), $presentation->definition);
|
||||
// $presentation->entry = array('text'=>$currenttext, 'format'=>$presentation->format, 'itemid'=>$draftid_editor);
|
||||
|
||||
// return $data->presentation;
|
||||
public function get_presentation($data) {
|
||||
}
|
||||
|
||||
function postupdate($item) {
|
||||
public function postupdate($item) {
|
||||
global $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $item->cmid);
|
||||
$item = file_postupdate_standard_editor($item, 'presentation', $this->presentationoptions, $context, 'mod_feedback', 'item', $item->id);
|
||||
$item = file_postupdate_standard_editor($item,
|
||||
'presentation',
|
||||
$this->presentationoptions,
|
||||
$context,
|
||||
'mod_feedback',
|
||||
'item',
|
||||
$item->id);
|
||||
|
||||
// $item = new stdClass();
|
||||
// $item->id = $data->id
|
||||
$DB->update_record('feedback_item', $item);
|
||||
return $item->id;
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
public function can_switch_require() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function check_value($value, $item) {}
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {}
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {}
|
||||
function get_printval($item, $value) {}
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {}
|
||||
public function check_value($value, $item) {
|
||||
}
|
||||
|
||||
public function excelprint_item(&$worksheet,
|
||||
$row_offset,
|
||||
$xls_formats,
|
||||
$item,
|
||||
$groupid,
|
||||
$courseid = false) {
|
||||
}
|
||||
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
}
|
||||
public function get_printval($item, $value) {
|
||||
}
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
@ -9,32 +24,32 @@ define('FEEDBACK_MULTICHOICE_IGNOREEMPTY', 'i');
|
||||
define('FEEDBACK_MULTICHOICE_HIDENOSELECT', 'h');
|
||||
|
||||
class feedback_item_multichoice extends feedback_item_base {
|
||||
var $type = "multichoice";
|
||||
var $commonparams;
|
||||
var $item_form;
|
||||
var $item;
|
||||
protected $type = "multichoice";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
require_once('multichoice_form.php');
|
||||
|
||||
//get the lastposition number of the feedback_items
|
||||
$position = $item->position;
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
if($position == -1){
|
||||
if ($position == -1) {
|
||||
$i_formselect_last = $lastposition + 1;
|
||||
$i_formselect_value = $lastposition + 1;
|
||||
$item->position = $lastposition + 1;
|
||||
}else {
|
||||
} else {
|
||||
$i_formselect_last = $lastposition;
|
||||
$i_formselect_value = $item->position;
|
||||
}
|
||||
//the elements for position dropdownlist
|
||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
||||
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
|
||||
|
||||
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
$info = $this->get_info($item);
|
||||
@ -45,39 +60,45 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
//all items for dependitem
|
||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
||||
$commonparams = array('cmid'=>$cm->id,
|
||||
'id'=>isset($item->id) ? $item->id : NULL,
|
||||
'id'=>isset($item->id) ? $item->id : null,
|
||||
'typ'=>$item->typ,
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
|
||||
//build the form
|
||||
$this->item_form = new feedback_multichoice_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position, 'info'=>$info));
|
||||
$customdata = array('item' => $item,
|
||||
'common' => $commonparams,
|
||||
'positionlist' => $positionlist,
|
||||
'position' => $position,
|
||||
'info' => $info);
|
||||
|
||||
$this->item_form = new feedback_multichoice_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$item = $this->item_form->get_data()) {
|
||||
if (!$item = $this->item_form->get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($item->clone_item) AND $item->clone_item) {
|
||||
if (isset($item->clone_item) AND $item->clone_item) {
|
||||
$item->id = ''; //to clone this item
|
||||
$item->position++;
|
||||
}
|
||||
@ -86,9 +107,9 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$this->set_hidenoselect($item, $item->hidenoselect);
|
||||
|
||||
$item->hasvalue = $this->get_hasvalue();
|
||||
if(!$item->id) {
|
||||
if (!$item->id) {
|
||||
$item->id = $DB->insert_record('feedback_item', $item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $item);
|
||||
}
|
||||
|
||||
@ -96,30 +117,32 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
|
||||
|
||||
//liefert ein eindimensionales Array mit drei Werten(typ, name, XXX)
|
||||
//XXX ist ein eindimensionales Array (anzahl der Antworten bei Typ Radio) Jedes Element ist eine Struktur (answertext, answercount)
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
//gets an array with three values(typ, name, XXX)
|
||||
//XXX is an object with answertext, answercount and quotient
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
$info = $this->get_info($item);
|
||||
|
||||
$analysedItem = array();
|
||||
$analysedItem[] = $item->typ;
|
||||
$analysedItem[] = $item->name;
|
||||
//die moeglichen Antworten extrahieren
|
||||
$analysed_item = array();
|
||||
$analysed_item[] = $item->typ;
|
||||
$analysed_item[] = $item->name;
|
||||
|
||||
//get the possible answers
|
||||
$answers = null;
|
||||
// $presentation = '';
|
||||
// @list($presentation) = explode(FEEDBACK_RADIO_ADJUST_SEP, $item->presentation); //remove the adjustment-info
|
||||
|
||||
$answers = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
if(!is_array($answers)) return null;
|
||||
if (!is_array($answers)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//die Werte holen
|
||||
//get the values
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid, $this->ignoreempty($item));
|
||||
if(!$values) return null;
|
||||
//schleife ueber den Werten und ueber die Antwortmoeglichkeiten
|
||||
if (!$values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$analysedAnswer = array();
|
||||
if($info->subtype == 'c') {
|
||||
$sizeofanswers = sizeof($answers);
|
||||
//get answertext, answercount and quotient for each answer
|
||||
$analysed_answer = array();
|
||||
if ($info->subtype == 'c') {
|
||||
$sizeofanswers = count($answers);
|
||||
for ($i = 1; $i <= $sizeofanswers; $i++) {
|
||||
$ans = null;
|
||||
$ans->answertext = $answers[$i-1];
|
||||
@ -129,15 +152,15 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$vallist = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value->value);
|
||||
foreach ($vallist as $val) {
|
||||
if ($val == $i) {
|
||||
$ans->answercount++;
|
||||
$ans->answercount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$ans->quotient = $ans->answercount / sizeof($values);
|
||||
$analysedAnswer[] = $ans;
|
||||
$ans->quotient = $ans->answercount / count($values);
|
||||
$analysed_answer[] = $ans;
|
||||
}
|
||||
}else {
|
||||
$sizeofanswers = sizeof($answers);
|
||||
} else {
|
||||
$sizeofanswers = count($answers);
|
||||
for ($i = 1; $i <= $sizeofanswers; $i++) {
|
||||
$ans = null;
|
||||
$ans->answertext = $answers[$i-1];
|
||||
@ -148,15 +171,15 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$ans->answercount++;
|
||||
}
|
||||
}
|
||||
$ans->quotient = $ans->answercount / sizeof($values);
|
||||
$analysedAnswer[] = $ans;
|
||||
$ans->quotient = $ans->answercount / count($values);
|
||||
$analysed_answer[] = $ans;
|
||||
}
|
||||
}
|
||||
$analysedItem[] = $analysedAnswer;
|
||||
return $analysedItem;
|
||||
$analysed_item[] = $analysed_answer;
|
||||
return $analysed_item;
|
||||
}
|
||||
|
||||
function get_printval($item, $value) {
|
||||
public function get_printval($item, $value) {
|
||||
$info = $this->get_info($item);
|
||||
|
||||
$printval = '';
|
||||
@ -165,14 +188,12 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
return $printval;
|
||||
}
|
||||
|
||||
// @list($presentation) = explode(FEEDBACK_RADIO_ADJUST_SEP, $item->presentation); //remove the adjustment-info
|
||||
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
|
||||
if ($info->subtype == 'c') {
|
||||
$vallist = array_values(explode (FEEDBACK_MULTICHOICE_LINE_SEP, $value->value));
|
||||
$sizeofvallist = sizeof($vallist);
|
||||
$sizeofpresentation = sizeof($presentation);
|
||||
$sizeofvallist = count($vallist);
|
||||
$sizeofpresentation = count($presentation);
|
||||
for ($i = 0; $i < $sizeofvallist; $i++) {
|
||||
for ($k = 0; $k < $sizeofpresentation; $k++) {
|
||||
if ($vallist[$i] == ($k + 1)) {//Die Werte beginnen bei 1, das Array aber mit 0
|
||||
@ -183,8 +204,8 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
} else {
|
||||
$index = 1;
|
||||
foreach($presentation as $pres){
|
||||
if ($value->value == $index){
|
||||
foreach ($presentation as $pres) {
|
||||
if ($value->value == $index) {
|
||||
$printval = $pres;
|
||||
break;
|
||||
}
|
||||
@ -194,61 +215,83 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
return $printval;
|
||||
}
|
||||
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
$sep_dec = get_string('separator_decimal', 'feedback');
|
||||
if(substr($sep_dec, 0, 2) == '[['){
|
||||
if (substr($sep_dec, 0, 2) == '[[') {
|
||||
$sep_dec = FEEDBACK_DECIMAL;
|
||||
}
|
||||
|
||||
$sep_thous = get_string('separator_thousand', 'feedback');
|
||||
if(substr($sep_thous, 0, 2) == '[['){
|
||||
if (substr($sep_thous, 0, 2) == '[[') {
|
||||
$sep_thous = FEEDBACK_THOUSAND;
|
||||
}
|
||||
|
||||
$analysedItem = $this->get_analysed($item, $groupid, $courseid);
|
||||
if($analysedItem) {
|
||||
// $itemnr++;
|
||||
$itemname = $analysedItem[1];
|
||||
echo '<tr><th colspan="2" align="left">'. $itemnr . ' ('. $item->label .') ' . $itemname .'</th></tr>';
|
||||
$analysedVals = $analysedItem[2];
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
if ($analysed_item) {
|
||||
$itemname = $analysed_item[1];
|
||||
echo '<tr><th colspan="2" align="left">';
|
||||
echo $itemnr.' ('.$item->label.') '.$itemname;
|
||||
echo '</th></tr>';
|
||||
|
||||
$analysed_vals = $analysed_item[2];
|
||||
$pixnr = 0;
|
||||
foreach($analysedVals as $val) {
|
||||
foreach ($analysed_vals as $val) {
|
||||
$intvalue = $pixnr % 10;
|
||||
$pix = "pics/$intvalue.gif";
|
||||
$pixnr++;
|
||||
$pixwidth = intval($val->quotient * FEEDBACK_MAX_PIX_LENGTH);
|
||||
$quotient = number_format(($val->quotient * 100), 2, $sep_dec, $sep_thous);
|
||||
echo '<tr><td align="left" valign="top">- ' . trim($val->answertext) . ':</td><td align="left" style="width: '.FEEDBACK_MAX_PIX_LENGTH.'"><img alt="'.$intvalue.'" src="'.$pix.'" height="5" width="'.$pixwidth.'" /> ' . $val->answercount . (($val->quotient > 0)?' ('. $quotient . ' %)':'').'</td></tr>';
|
||||
$str_quotient = '';
|
||||
if ($val->quotient > 0) {
|
||||
$str_quotient = ' ('. $quotient . ' %)';
|
||||
}
|
||||
echo '<tr>';
|
||||
echo '<td align="left" valign="top">
|
||||
- '.trim($val->answertext).':
|
||||
</td>
|
||||
<td align="left" style="width:'.FEEDBACK_MAX_PIX_LENGTH.';">
|
||||
<img alt="'.$intvalue.'" src="'.$pix.'" height="5" width="'.$pixwidth.'" />
|
||||
'.$val->answercount.$str_quotient.'
|
||||
</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
}
|
||||
// return $itemnr;
|
||||
}
|
||||
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
$data = $analysed_item[2];
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:green>");
|
||||
//frage schreiben
|
||||
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
|
||||
$worksheet->write_string($rowOffset, 1, $analysed_item[1], $xlsFormats->head2);
|
||||
$worksheet->write_string($row_offset, 0, $item->label, $xls_formats->head2);
|
||||
$worksheet->write_string($row_offset, 1, $analysed_item[1], $xls_formats->head2);
|
||||
if (is_array($data)) {
|
||||
$sizeofdata = sizeof($data);
|
||||
$sizeofdata = count($data);
|
||||
for ($i = 0; $i < $sizeofdata; $i++) {
|
||||
$aData = $data[$i];
|
||||
$analysed_data = $data[$i];
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:blue>");
|
||||
$worksheet->write_string($rowOffset, $i + 2, trim($aData->answertext), $xlsFormats->head2);
|
||||
$worksheet->write_string($row_offset,
|
||||
$i + 2,
|
||||
trim($analysed_data->answertext),
|
||||
$xls_formats->head2);
|
||||
|
||||
// $worksheet->setFormat("<l><vo>");
|
||||
$worksheet->write_number($rowOffset + 1, $i + 2, $aData->answercount, $xlsFormats->default);
|
||||
// $worksheet->setFormat("<l><f><vo><pr>");
|
||||
$worksheet->write_number($rowOffset + 2, $i + 2, $aData->quotient, $xlsFormats->procent);
|
||||
$worksheet->write_number($row_offset + 1,
|
||||
$i + 2,
|
||||
$analysed_data->answercount,
|
||||
$xls_formats->default);
|
||||
|
||||
$worksheet->write_number($row_offset + 2,
|
||||
$i + 2,
|
||||
$analysed_data->quotient,
|
||||
$xls_formats->procent);
|
||||
}
|
||||
}
|
||||
$rowOffset += 3;
|
||||
return $rowOffset;
|
||||
$row_offset += 3;
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -258,25 +301,27 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
$info = $this->get_info($item);
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
//test if required and no value is set so we have to mark this item
|
||||
//we have to differ check and the other subtypes
|
||||
$requiredmark = ($item->required == 1) ? '<span class="feedback_required_mark">*</span>' : '';
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name.$requiredmark, true, false, false);
|
||||
if($item->dependitem) {
|
||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.$dependitem->label.'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
@ -286,23 +331,30 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
echo '<ul>';
|
||||
if($info->horizontal) {
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
}else {
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
if($info->subtype == 'r' AND !$this->hidenoselect($item)) {
|
||||
if ($info->subtype == 'r' AND !$this->hidenoselect($item)) {
|
||||
//print the "not_selected" item on radiobuttons
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<input type="radio" name="<?php echo $item->typ . '_' . $item->id ;?>" id="<?php echo $item->typ . '_' . $item->id.'_xxx';?>" value="" checked="checked" />
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>"><?php print_string('not_selected', 'feedback');?> </label>
|
||||
</span>
|
||||
</li>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'[]" '.
|
||||
'id="'.$item->typ.'_'.$item->id.'_xxx" '.
|
||||
'value="" checked="checked" />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>">
|
||||
<?php print_string('not_selected', 'feedback');?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
@ -330,36 +382,40 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = null, $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$info = $this->get_info($item);
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
if ($value == null) {
|
||||
$value = array();
|
||||
}
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
//test if required and no value is set so we have to mark this item
|
||||
//we have to differ check and the other subtypes
|
||||
if($info->subtype == 'c') {
|
||||
// if ($info->subtype == 'c') {
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
}else {
|
||||
} else {
|
||||
$values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
|
||||
}
|
||||
if($highlightrequire AND $item->required AND $values[0] == '') {
|
||||
$highlight = ' missingrequire';
|
||||
}else {
|
||||
$highlight = '';
|
||||
$highlight = '';
|
||||
if ($highlightrequire AND $item->required) {
|
||||
if (count($values) == 0 OR $values[0] == '' OR $values[0] == 0) {
|
||||
$highlight = ' missingrequire';
|
||||
}
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
}else {
|
||||
if($highlightrequire AND $item->required AND intval($value) <= 0) {
|
||||
$highlight = ' missingrequire';
|
||||
}else {
|
||||
$highlight = '';
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
}
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
// } else {
|
||||
// if ($highlightrequire AND $item->required AND intval($value) <= 0) {
|
||||
// $highlight = ' missingrequire';
|
||||
// } else {
|
||||
// $highlight = '';
|
||||
// }
|
||||
// $requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
// }
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.$highlight.'">';
|
||||
@ -370,20 +426,34 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
echo '<div class="feedback_item_presentation_'.$align.$highlight.'">';
|
||||
|
||||
echo '<ul>';
|
||||
if($info->horizontal) {
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
}else {
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
//print the "not_selected" item on radiobuttons
|
||||
if($info->subtype == 'r' AND !$this->hidenoselect($item)) {
|
||||
if ($info->subtype == 'r' AND !$this->hidenoselect($item)) {
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<input type="radio" name="<?php echo $item->typ.'_'.$item->id ;?>" id="<?php echo $item->typ . '_' . $item->id.'_xxx';?>" value="" <?php echo $value ? '' : 'checked="checked"';?> />
|
||||
<?php
|
||||
$checked = '';
|
||||
// if (!$value) {
|
||||
// $checked = 'checked="checked"';
|
||||
// }
|
||||
if (count($values) == 0 OR $values[0] == '' OR $values[0] == 0) {
|
||||
$checked = 'checked="checked"';
|
||||
}
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'[]" '.
|
||||
'id="'.$item->typ.'_'.$item->id.'_xxx" '.
|
||||
'value="" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $item->typ.'_'.$item->id.'_xxx';?>"><?php print_string('not_selected', 'feedback');?> </label>
|
||||
<label for="<?php echo $item->typ.'_'.$item->id.'_xxx';?>">
|
||||
<?php print_string('not_selected', 'feedback');?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
@ -412,25 +482,29 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = null) {
|
||||
global $OUTPUT;
|
||||
$info = $this->get_info($item);
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
if ($value == null) {
|
||||
$value = array();
|
||||
}
|
||||
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
|
||||
//test if required and no value is set so we have to mark this item
|
||||
//we have to differ check and the other subtypes
|
||||
if($info->subtype == 'c') {
|
||||
if ($info->subtype == 'c') {
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
}else {
|
||||
} else {
|
||||
$values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
}else {
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
}
|
||||
$requiredmark = '';
|
||||
if ($item->required == 1) {
|
||||
$requiredmark = '<span class="feedback_required_mark">*</span>';
|
||||
}
|
||||
|
||||
//print the question and label
|
||||
@ -442,11 +516,11 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
$index = 1;
|
||||
if($info->subtype == 'c') {
|
||||
if ($info->subtype == 'c') {
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
foreach($presentation as $pres){
|
||||
foreach($values as $val) {
|
||||
if($val == $index){
|
||||
foreach ($presentation as $pres) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
echo '<div class="feedback_item_multianswer">';
|
||||
echo text_to_html($pres, true, false, false);
|
||||
echo '</div>';
|
||||
@ -456,9 +530,9 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$index++;
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}else {
|
||||
foreach($presentation as $pres){
|
||||
if($value == $index){
|
||||
} else {
|
||||
foreach ($presentation as $pres) {
|
||||
if ($value == $index) {
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo text_to_html($pres, true, false, false);
|
||||
echo $OUTPUT->box_end();
|
||||
@ -470,47 +544,42 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function check_value($value, $item) {
|
||||
public function check_value($value, $item) {
|
||||
$info = $this->get_info($item);
|
||||
|
||||
if($info->subtype == 'c') {
|
||||
if((!isset($value) OR !is_array($value) OR $value[0] == '' OR $value[0] == 0) AND $item->required != 1){
|
||||
return true;
|
||||
}
|
||||
if($value[0] == ""){
|
||||
return false;
|
||||
}
|
||||
if ($item->required != 1) {
|
||||
return true;
|
||||
}else {
|
||||
//if the item is not required, so the check is true if no value is given
|
||||
if((!isset($value) OR $value == '' OR $value == 0) AND $item->required != 1) return true;
|
||||
if(intval($value) > 0)return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (!isset($value) OR !is_array($value) OR $value[0] == '' OR $value[0] == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
$vallist = $data;
|
||||
return trim($this->item_arrayToString($vallist));
|
||||
return trim($this->item_array_to_string($vallist));
|
||||
}
|
||||
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the number of one selection
|
||||
//dependvalue is the presentation of one selection
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
|
||||
if (is_array($dbvalue)) {
|
||||
$dbvalues = $dbvalue;
|
||||
}else {
|
||||
} else {
|
||||
$dbvalues = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $dbvalue);
|
||||
}
|
||||
|
||||
$info = $this->get_info($item);
|
||||
$presentation = explode (FEEDBACK_MULTICHOICE_LINE_SEP, $info->presentation);
|
||||
$index = 1;
|
||||
foreach($presentation as $pres) {
|
||||
foreach($dbvalues as $dbval) {
|
||||
if($dbval == $index AND trim($pres) == $dependvalue) {
|
||||
foreach ($presentation as $pres) {
|
||||
foreach ($dbvalues as $dbval) {
|
||||
if ($dbval == $index AND trim($pres) == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -519,24 +588,24 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_presentation($data) {
|
||||
public function get_presentation($data) {
|
||||
$present = str_replace("\n", FEEDBACK_MULTICHOICE_LINE_SEP, trim($data->itemvalues));
|
||||
if(!isset($data->subtype)) {
|
||||
if (!isset($data->subtype)) {
|
||||
$subtype = 'r';
|
||||
}else {
|
||||
} else {
|
||||
$subtype = substr($data->subtype, 0, 1);
|
||||
}
|
||||
if(isset($data->horizontal) AND $data->horizontal == 1 AND $subtype != 'd') {
|
||||
if (isset($data->horizontal) AND $data->horizontal == 1 AND $subtype != 'd') {
|
||||
$present .= FEEDBACK_MULTICHOICE_ADJUST_SEP.'1';
|
||||
}
|
||||
return $subtype.FEEDBACK_MULTICHOICE_TYPE_SEP.$present;
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function get_info($item) {
|
||||
private function get_info($item) {
|
||||
$presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
$info = new stdClass();
|
||||
@ -546,62 +615,80 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
$info->presentation = '';
|
||||
$info->horizontal = false;
|
||||
|
||||
@list($info->subtype, $info->presentation) = explode(FEEDBACK_MULTICHOICE_TYPE_SEP, $item->presentation);
|
||||
if(!isset($info->subtype)) {
|
||||
$parts = explode(FEEDBACK_MULTICHOICE_TYPE_SEP, $item->presentation);
|
||||
@list($info->subtype, $info->presentation) = $parts;
|
||||
if (!isset($info->subtype)) {
|
||||
$info->subtype = 'r';
|
||||
}
|
||||
|
||||
if($info->subtype != 'd') {
|
||||
@list($info->presentation, $info->horizontal) = explode(FEEDBACK_MULTICHOICE_ADJUST_SEP, $info->presentation);
|
||||
if(isset($info->horizontal) AND $info->horizontal == 1) {
|
||||
if ($info->subtype != 'd') {
|
||||
$parts = explode(FEEDBACK_MULTICHOICE_ADJUST_SEP, $info->presentation);
|
||||
@list($info->presentation, $info->horizontal) = $parts;
|
||||
if (isset($info->horizontal) AND $info->horizontal == 1) {
|
||||
$info->horizontal = true;
|
||||
}else {
|
||||
} else {
|
||||
$info->horizontal = false;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
function item_arrayToString($value) {
|
||||
private function item_array_to_string($value) {
|
||||
if (!is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
$retval = '';
|
||||
$arrvals = array_values($value);
|
||||
$arrvals = clean_param($arrvals, PARAM_INT); //prevent sql-injection
|
||||
$arrvals = clean_param_array($arrvals, PARAM_INT); //prevent sql-injection
|
||||
$retval = $arrvals[0];
|
||||
$sizeofarrvals = sizeof($arrvals);
|
||||
$sizeofarrvals = count($arrvals);
|
||||
for ($i = 1; $i < $sizeofarrvals; $i++) {
|
||||
$retval .= FEEDBACK_MULTICHOICE_LINE_SEP.$arrvals[$i];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
function print_item_radio($presentation, $item, $value, $info, $align) {
|
||||
private function print_item_radio($presentation, $item, $value, $info, $align) {
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
|
||||
if($info->horizontal) {
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
} else {
|
||||
$values = array($value);
|
||||
}
|
||||
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
}else {
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
foreach($presentation as $radio){
|
||||
if($value == $index){
|
||||
$checked = 'checked="checked"';
|
||||
}else{
|
||||
$checked = '';
|
||||
foreach ($presentation as $radio) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
$checked = 'checked="checked"';
|
||||
break;
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
}
|
||||
$inputname = $item->typ . '_' . $item->id;
|
||||
$inputid = $inputname.'_'.$index;
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<input type="radio" name="<?php echo $inputname;?>" id="<?php echo $inputid;?>" value="<?php echo $index;?>" <?php echo $checked;?> />
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$inputname.'[]" '.
|
||||
'id="'.$inputid.'" '.
|
||||
'value="'.$index.'" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $inputid;?>"><?php echo text_to_html($radio, true, false, false);?> </label>
|
||||
<label for="<?php echo $inputid;?>">
|
||||
<?php echo text_to_html($radio, true, false, false);?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
@ -609,28 +696,28 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
}
|
||||
|
||||
function print_item_check($presentation, $item, $value, $info, $align) {
|
||||
private function print_item_check($presentation, $item, $value, $info, $align) {
|
||||
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
}else {
|
||||
} else {
|
||||
$values = explode(FEEDBACK_MULTICHOICE_LINE_SEP, $value);
|
||||
}
|
||||
|
||||
if($info->horizontal) {
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
}else {
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
foreach($presentation as $check){
|
||||
foreach($values as $val) {
|
||||
if($val == $index){
|
||||
foreach ($presentation as $check) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
$checked = 'checked="checked"';
|
||||
break;
|
||||
}else{
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
}
|
||||
@ -639,10 +726,17 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
?>
|
||||
<li class="feedback_item_check_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_check_<?php echo $hv.'_'.$align;?>">
|
||||
<input type="checkbox" name="<?php echo $inputname;?>[]" id="<?php echo $inputid;?>" value="<?php echo $index;?>" <?php echo $checked;?> />
|
||||
<?php
|
||||
echo '<input type="checkbox" '.
|
||||
'name="'.$inputname.'[]" '.
|
||||
'id="'.$inputid.'" '.
|
||||
'value="'.$index.'" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $inputid;?>"><?php echo text_to_html($check, true, false, false);?> </label>
|
||||
<label for="<?php echo $inputid;?>">
|
||||
<?php echo text_to_html($check, true, false, false);?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
@ -650,28 +744,39 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
}
|
||||
}
|
||||
|
||||
function print_item_dropdown($presentation, $item, $value, $info, $align) {
|
||||
if($info->horizontal) {
|
||||
private function print_item_dropdown($presentation, $item, $value, $info, $align) {
|
||||
if (is_array($value)) {
|
||||
$values = $value;
|
||||
} else {
|
||||
$values = array($value);
|
||||
}
|
||||
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
}else {
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
|
||||
?>
|
||||
<li class="feedback_item_select_<?php echo $hv.'_'.$align;?>">
|
||||
<select name="<?php echo $item->typ .'_' . $item->id;?>" size="1">
|
||||
<select name="<?php echo $item->typ .'_' . $item->id;?>[]" size="1">
|
||||
<option value="0"> </option>
|
||||
<?php
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
foreach($presentation as $dropdown){
|
||||
if($value == $index){
|
||||
$selected = 'selected="selected"';
|
||||
}else{
|
||||
$selected = '';
|
||||
$selected = '';
|
||||
foreach ($presentation as $dropdown) {
|
||||
foreach ($values as $val) {
|
||||
if ($val == $index) {
|
||||
$selected = 'selected="selected"';
|
||||
break;
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<option value="<?php echo $index;?>" <?php echo $selected;?>><?php echo text_to_html($dropdown, true, false, false);?></option>
|
||||
<option value="<?php echo $index;?>" <?php echo $selected;?>>
|
||||
<?php echo text_to_html($dropdown, true, false, false);?>
|
||||
</option>
|
||||
<?php
|
||||
$index++;
|
||||
}
|
||||
@ -681,36 +786,43 @@ class feedback_item_multichoice extends feedback_item_base {
|
||||
<?php
|
||||
}
|
||||
|
||||
function set_ignoreempty($item, $ignoreempty=true) {
|
||||
public function set_ignoreempty($item, $ignoreempty=true) {
|
||||
$item->options = str_replace(FEEDBACK_MULTICHOICE_IGNOREEMPTY, '', $item->options);
|
||||
if($ignoreempty) {
|
||||
if ($ignoreempty) {
|
||||
$item->options .= FEEDBACK_MULTICHOICE_IGNOREEMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
function ignoreempty($item) {
|
||||
if(strstr($item->options, FEEDBACK_MULTICHOICE_IGNOREEMPTY)) {
|
||||
public function ignoreempty($item) {
|
||||
if (strstr($item->options, FEEDBACK_MULTICHOICE_IGNOREEMPTY)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function set_hidenoselect($item, $hidenoselect=true) {
|
||||
public function set_hidenoselect($item, $hidenoselect=true) {
|
||||
$item->options = str_replace(FEEDBACK_MULTICHOICE_HIDENOSELECT, '', $item->options);
|
||||
if($hidenoselect) {
|
||||
if ($hidenoselect) {
|
||||
$item->options .= FEEDBACK_MULTICHOICE_HIDENOSELECT;
|
||||
}
|
||||
}
|
||||
|
||||
function hidenoselect($item) {
|
||||
if(strstr($item->options, FEEDBACK_MULTICHOICE_HIDENOSELECT)) {
|
||||
public function hidenoselect($item) {
|
||||
if (strstr($item->options, FEEDBACK_MULTICHOICE_HIDENOSELECT)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
public function value_type() {
|
||||
return PARAM_INT;
|
||||
}
|
||||
|
||||
public function value_is_array() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,25 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_multichoice_form extends feedback_item_form {
|
||||
var $type = "multichoice";
|
||||
protected $type = "multichoice";
|
||||
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
@ -20,16 +34,20 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
$mform->addElement('text',
|
||||
'name',
|
||||
get_string('item_name', 'feedback'),
|
||||
array('size'=>FEEDBACK_ITEM_NAME_TEXTBOX_SIZE, 'maxlength'=>255));
|
||||
array('size' => FEEDBACK_ITEM_NAME_TEXTBOX_SIZE,
|
||||
'maxlength' => 255));
|
||||
|
||||
$mform->addElement('text',
|
||||
'label',
|
||||
get_string('item_label', 'feedback'),
|
||||
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 'maxlength'=>255));
|
||||
array('size' => FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE,
|
||||
'maxlength' => 255));
|
||||
|
||||
$mform->addElement('select',
|
||||
'horizontal',
|
||||
get_string('adjustment', 'feedback').' ',
|
||||
array(0 => get_string('vertical', 'feedback'), 1 => get_string('horizontal', 'feedback')));
|
||||
array(0 => get_string('vertical', 'feedback'),
|
||||
1 => get_string('horizontal', 'feedback')));
|
||||
|
||||
$mform->addElement('select',
|
||||
'subtype',
|
||||
@ -38,11 +56,18 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
'c'=>get_string('check', 'feedback'),
|
||||
'd'=>get_string('dropdown', 'feedback')));
|
||||
|
||||
|
||||
$mform->addElement('selectyesno', 'ignoreempty', get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
$mform->addElement('selectyesno', 'hidenoselect', get_string('hide_no_select_option', 'feedback'));
|
||||
|
||||
$mform->addElement('static', 'hint', get_string('multichoice_values', 'feedback'), get_string('use_one_line_for_each_value', 'feedback'));
|
||||
$mform->addElement('selectyesno',
|
||||
'ignoreempty',
|
||||
get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'hidenoselect',
|
||||
get_string('hide_no_select_option', 'feedback'));
|
||||
|
||||
$mform->addElement('static',
|
||||
'hint',
|
||||
get_string('multichoice_values', 'feedback'),
|
||||
get_string('use_one_line_for_each_value', 'feedback'));
|
||||
|
||||
$mform->addElement('textarea', 'values', '', 'wrap="virtual" rows="10" cols="65"');
|
||||
|
||||
@ -50,8 +75,8 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
||||
function set_data($item) {
|
||||
|
||||
public function set_data($item) {
|
||||
$info = $this->_customdata['info'];
|
||||
|
||||
$item->horizontal = $info->horizontal;
|
||||
@ -61,27 +86,26 @@ class feedback_multichoice_form extends feedback_item_form {
|
||||
$itemvalues = str_replace(FEEDBACK_MULTICHOICE_LINE_SEP, "\n", $info->presentation);
|
||||
$itemvalues = str_replace("\n\n", "\n", $itemvalues);
|
||||
$item->values = $itemvalues;
|
||||
|
||||
return parent::set_data($item);
|
||||
|
||||
return parent::set_data($item);
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if(!$item = parent::get_data()) {
|
||||
|
||||
public function get_data() {
|
||||
if (!$item = parent::get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$presentation = str_replace("\n", FEEDBACK_MULTICHOICE_LINE_SEP, trim($item->values));
|
||||
if(!isset($item->subtype)) {
|
||||
if (!isset($item->subtype)) {
|
||||
$subtype = 'r';
|
||||
}else {
|
||||
} else {
|
||||
$subtype = substr($item->subtype, 0, 1);
|
||||
}
|
||||
if(isset($item->horizontal) AND $item->horizontal == 1 AND $subtype != 'd') {
|
||||
if (isset($item->horizontal) AND $item->horizontal == 1 AND $subtype != 'd') {
|
||||
$presentation .= FEEDBACK_MULTICHOICE_ADJUST_SEP.'1';
|
||||
}
|
||||
|
||||
|
||||
$item->presentation = $subtype.FEEDBACK_MULTICHOICE_TYPE_SEP.$presentation;
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,19 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
@ -14,32 +29,32 @@ define('FEEDBACK_MULTICHOICERATED_IGNOREEMPTY', 'i');
|
||||
define('FEEDBACK_MULTICHOICERATED_HIDENOSELECT', 'h');
|
||||
|
||||
class feedback_item_multichoicerated extends feedback_item_base {
|
||||
var $type = "multichoicerated";
|
||||
var $commonparams;
|
||||
var $item_form;
|
||||
var $item;
|
||||
protected $type = "multichoicerated";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
require_once('multichoicerated_form.php');
|
||||
|
||||
//get the lastposition number of the feedback_items
|
||||
$position = $item->position;
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
if($position == -1){
|
||||
if ($position == -1) {
|
||||
$i_formselect_last = $lastposition + 1;
|
||||
$i_formselect_value = $lastposition + 1;
|
||||
$item->position = $lastposition + 1;
|
||||
}else {
|
||||
} else {
|
||||
$i_formselect_last = $lastposition;
|
||||
$i_formselect_value = $item->position;
|
||||
}
|
||||
//the elements for position dropdownlist
|
||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
||||
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
|
||||
|
||||
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
$info = $this->get_info($item);
|
||||
@ -50,39 +65,45 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
//all items for dependitem
|
||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
||||
$commonparams = array('cmid'=>$cm->id,
|
||||
'id'=>isset($item->id) ? $item->id : NULL,
|
||||
'id'=>isset($item->id) ? $item->id : null,
|
||||
'typ'=>$item->typ,
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
|
||||
//build the form
|
||||
$this->item_form = new feedback_multichoicerated_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position, 'info'=>$info));
|
||||
$customdata = array('item' => $item,
|
||||
'common' => $commonparams,
|
||||
'positionlist' => $positionlist,
|
||||
'position' => $position,
|
||||
'info' => $info);
|
||||
|
||||
$this->item_form = new feedback_multichoicerated_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$item = $this->item_form->get_data()) {
|
||||
if (!$item = $this->item_form->get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($item->clone_item) AND $item->clone_item) {
|
||||
if (isset($item->clone_item) AND $item->clone_item) {
|
||||
$item->id = ''; //to clone this item
|
||||
$item->position++;
|
||||
}
|
||||
@ -91,9 +112,9 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
$this->set_hidenoselect($item, $item->hidenoselect);
|
||||
|
||||
$item->hasvalue = $this->get_hasvalue();
|
||||
if(!$item->id) {
|
||||
if (!$item->id) {
|
||||
$item->id = $DB->insert_record('feedback_item', $item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $item);
|
||||
}
|
||||
|
||||
@ -101,33 +122,37 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
|
||||
|
||||
//liefert ein eindimensionales Array mit drei Werten(typ, name, XXX)
|
||||
//XXX ist ein eindimensionales Array (Mittelwert der Werte der Antworten bei Typ Radio_rated) Jedes Element ist eine Struktur (answertext, avg)
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
$analysedItem = array();
|
||||
$analysedItem[] = $item->typ;
|
||||
$analysedItem[] = $item->name;
|
||||
//gets an array with three values(typ, name, XXX)
|
||||
//XXX is an object with answertext, answercount and quotient
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
$analysed_item = array();
|
||||
$analysed_item[] = $item->typ;
|
||||
$analysed_item[] = $item->name;
|
||||
|
||||
//die moeglichen Antworten extrahieren
|
||||
$info = $this->get_info($item);
|
||||
$lines = null;
|
||||
$lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
if(!is_array($lines)) return null;
|
||||
if (!is_array($lines)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
//die Werte holen
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid, $this->ignoreempty($item));
|
||||
if(!$values) return null;
|
||||
if (!$values) {
|
||||
return null;
|
||||
}
|
||||
//schleife ueber den Werten und ueber die Antwortmoeglichkeiten
|
||||
|
||||
$analysedAnswer = array();
|
||||
$sizeoflines = sizeof($lines);
|
||||
for($i = 1; $i <= $sizeoflines; $i++) {
|
||||
$analysed_answer = array();
|
||||
$sizeoflines = count($lines);
|
||||
for ($i = 1; $i <= $sizeoflines; $i++) {
|
||||
$item_values = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $lines[$i-1]);
|
||||
$ans = null;
|
||||
$ans->answertext = $item_values[1];
|
||||
$avg = 0.0;
|
||||
$anscount = 0;
|
||||
foreach($values as $value) {
|
||||
foreach ($values as $value) {
|
||||
//ist die Antwort gleich dem index der Antworten + 1?
|
||||
if ($value->value == $i) {
|
||||
$avg += $item_values[0]; //erst alle Werte aufsummieren
|
||||
@ -135,26 +160,28 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
}
|
||||
$ans->answercount = $anscount;
|
||||
$ans->avg = doubleval($avg) / doubleval(sizeof($values));
|
||||
$ans->avg = doubleval($avg) / doubleval(count($values));
|
||||
$ans->value = $item_values[0];
|
||||
$ans->quotient = $ans->answercount / sizeof($values);
|
||||
$analysedAnswer[] = $ans;
|
||||
$ans->quotient = $ans->answercount / count($values);
|
||||
$analysed_answer[] = $ans;
|
||||
}
|
||||
$analysedItem[] = $analysedAnswer;
|
||||
return $analysedItem;
|
||||
$analysed_item[] = $analysed_answer;
|
||||
return $analysed_item;
|
||||
}
|
||||
|
||||
function get_printval($item, $value) {
|
||||
public function get_printval($item, $value) {
|
||||
$printval = '';
|
||||
|
||||
if(!isset($value->value)) return $printval;
|
||||
if (!isset($value->value)) {
|
||||
return $printval;
|
||||
}
|
||||
|
||||
$info = $this->get_info($item);
|
||||
|
||||
$presentation = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$index = 1;
|
||||
foreach($presentation as $pres){
|
||||
if($value->value == $index){
|
||||
foreach ($presentation as $pres) {
|
||||
if ($value->value == $index) {
|
||||
$item_label = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $pres);
|
||||
$printval = $item_label[1];
|
||||
break;
|
||||
@ -164,26 +191,26 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
return $printval;
|
||||
}
|
||||
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
$sep_dec = get_string('separator_decimal', 'feedback');
|
||||
if(substr($sep_dec, 0, 2) == '[['){
|
||||
if (substr($sep_dec, 0, 2) == '[[') {
|
||||
$sep_dec = FEEDBACK_DECIMAL;
|
||||
}
|
||||
|
||||
$sep_thous = get_string('separator_thousand', 'feedback');
|
||||
if(substr($sep_thous, 0, 2) == '[['){
|
||||
if (substr($sep_thous, 0, 2) == '[[') {
|
||||
$sep_thous = FEEDBACK_THOUSAND;
|
||||
}
|
||||
|
||||
$analysedItem = $this->get_analysed($item, $groupid, $courseid);
|
||||
if($analysedItem) {
|
||||
//echo '<table>';
|
||||
// $itemnr++;
|
||||
echo '<tr><th colspan="2" align="left">'. $itemnr . ' ('. $item->label .') ' . $analysedItem[1] .'</th></tr>';
|
||||
$analysedVals = $analysedItem[2];
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
if ($analysed_item) {
|
||||
echo '<tr><th colspan="2" align="left">';
|
||||
echo $itemnr.' ('.$item->label.') '.$analysed_item[1];
|
||||
echo '</th></tr>';
|
||||
$analysed_vals = $analysed_item[2];
|
||||
$pixnr = 0;
|
||||
$avg = 0.0;
|
||||
foreach($analysedVals as $val) {
|
||||
foreach ($analysed_vals as $val) {
|
||||
$intvalue = $pixnr % 10;
|
||||
$pix = "pics/$intvalue.gif";
|
||||
$pixnr++;
|
||||
@ -191,48 +218,68 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
|
||||
$avg += $val->avg;
|
||||
$quotient = number_format(($val->quotient * 100), 2, $sep_dec, $sep_thous);
|
||||
echo '<tr><td align="left" valign="top">- ' . trim($val->answertext) . ' ('.$val->value.'):</td><td align="left" style="width: '.FEEDBACK_MAX_PIX_LENGTH.'"><img alt="'.$intvalue.'" src="'.$pix.'" height="5" width="'.$pixwidth.'" />' . $val->answercount. (($val->quotient > 0)?' ('. $quotient . ' %)':'') . '</td></tr>';
|
||||
echo '<tr>';
|
||||
echo '<td align="left" valign="top">';
|
||||
echo '- '.trim($val->answertext).' ('.$val->value.'):</td>';
|
||||
echo '<td align="left" style="width: '.FEEDBACK_MAX_PIX_LENGTH.'">';
|
||||
echo '<img alt="'.$intvalue.'" src="'.$pix.'" height="5" width="'.$pixwidth.'" />';
|
||||
echo $val->answercount;
|
||||
if ($val->quotient > 0) {
|
||||
echo ' ('.$quotient.' %)';
|
||||
} else {
|
||||
echo '';
|
||||
}
|
||||
echo '</td></tr>';
|
||||
}
|
||||
$avg = number_format(($avg), 2, $sep_dec, $sep_thous);
|
||||
echo '<tr><td align="left" colspan="2"><b>'.get_string('average', 'feedback').': '.$avg.'</b></td></tr>';
|
||||
//echo '</table>';
|
||||
echo '<tr><td align="left" colspan="2"><b>';
|
||||
echo get_string('average', 'feedback').': '.$avg.'</b>';
|
||||
echo '</td></tr>';
|
||||
}
|
||||
// return $itemnr;
|
||||
}
|
||||
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
$data = $analysed_item[2];
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:green>");
|
||||
//frage schreiben
|
||||
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
|
||||
$worksheet->write_string($rowOffset, 1, $analysed_item[1], $xlsFormats->head2);
|
||||
if(is_array($data)) {
|
||||
//write the item
|
||||
$worksheet->write_string($row_offset, 0, $item->label, $xls_formats->head2);
|
||||
$worksheet->write_string($row_offset, 1, $analysed_item[1], $xls_formats->head2);
|
||||
if (is_array($data)) {
|
||||
$avg = 0.0;
|
||||
$sizeofdata = sizeof($data);
|
||||
for($i = 0; $i < $sizeofdata; $i++) {
|
||||
$aData = $data[$i];
|
||||
$sizeofdata = count($data);
|
||||
for ($i = 0; $i < $sizeofdata; $i++) {
|
||||
$analysed_data = $data[$i];
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:blue>");
|
||||
$worksheet->write_string($rowOffset, $i + 2, trim($aData->answertext).' ('.$aData->value.')', $xlsFormats->value_bold);
|
||||
$worksheet->write_string($row_offset,
|
||||
$i + 2,
|
||||
trim($analysed_data->answertext).' ('.$analysed_data->value.')',
|
||||
$xls_formats->value_bold);
|
||||
|
||||
// $worksheet->setFormat("<l><vo>");
|
||||
$worksheet->write_number($rowOffset + 1, $i + 2, $aData->answercount, $xlsFormats->default);
|
||||
//$worksheet->setFormat("<l><f><vo>");
|
||||
//$worksheet->write_number($rowOffset + 2, $i + 1, $aData->avg);
|
||||
$avg += $aData->avg;
|
||||
$worksheet->write_number($row_offset + 1,
|
||||
$i + 2,
|
||||
$analysed_data->answercount,
|
||||
$xls_formats->default);
|
||||
|
||||
$avg += $analysed_data->avg;
|
||||
}
|
||||
//mittelwert anzeigen
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:red>");
|
||||
$worksheet->write_string($rowOffset, sizeof($data) + 2, get_string('average', 'feedback'), $xlsFormats->value_bold);
|
||||
$worksheet->write_string($row_offset,
|
||||
count($data) + 2,
|
||||
get_string('average', 'feedback'),
|
||||
$xls_formats->value_bold);
|
||||
|
||||
// $worksheet->setFormat("<l><f><vo>");
|
||||
$worksheet->write_number($rowOffset + 1, sizeof($data) + 2, $avg, $xlsFormats->value_bold);
|
||||
$worksheet->write_number($row_offset + 1,
|
||||
count($data) + 2,
|
||||
$avg,
|
||||
$xls_formats->value_bold);
|
||||
}
|
||||
$rowOffset +=2 ;
|
||||
return $rowOffset;
|
||||
$row_offset +=2;
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -242,21 +289,24 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$info = $this->get_info($item);
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name.$requiredmark, true, false, false);
|
||||
if($item->dependitem) {
|
||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.$dependitem->label.'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
@ -283,16 +333,17 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$info = $this->get_info($item);
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
if($highlightrequire AND $item->required AND intval($value) <= 0) {
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
if ($highlightrequire AND $item->required AND intval($value) <= 0) {
|
||||
$highlight = ' missingrequire';
|
||||
}else {
|
||||
} else {
|
||||
$highlight = '';
|
||||
}
|
||||
|
||||
@ -322,13 +373,13 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$info = $this->get_info($item);
|
||||
|
||||
$lines = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
@ -339,8 +390,8 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
$index = 1;
|
||||
foreach($lines as $line){
|
||||
if($value == $index){
|
||||
foreach ($lines as $line) {
|
||||
if ($value == $index) {
|
||||
$item_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo text_to_html($item_value[1], true, false, false);
|
||||
@ -352,13 +403,17 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function check_value($value, $item) {
|
||||
if((!isset($value) OR $value == '' OR $value == 0) AND $item->required != 1) return true;
|
||||
if(intval($value) > 0)return true;
|
||||
public function check_value($value, $item) {
|
||||
if ((!isset($value) OR $value == '' OR $value == 0) AND $item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
if (intval($value) > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
$data = trim($data);
|
||||
return $data;
|
||||
}
|
||||
@ -366,22 +421,22 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the number of one selection
|
||||
//dependvalue is the presentation of one selection
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
|
||||
if (is_array($dbvalue)) {
|
||||
$dbvalues = $dbvalue;
|
||||
}else {
|
||||
} else {
|
||||
$dbvalues = explode(FEEDBACK_MULTICHOICERATED_LINE_SEP, $dbvalue);
|
||||
}
|
||||
|
||||
$info = $this->get_info($item);
|
||||
$presentation = explode (FEEDBACK_MULTICHOICERATED_LINE_SEP, $info->presentation);
|
||||
$index = 1;
|
||||
foreach($presentation as $pres) {
|
||||
foreach ($presentation as $pres) {
|
||||
$presvalues = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $pres);
|
||||
|
||||
foreach($dbvalues as $dbval) {
|
||||
if($dbval == $index AND trim($presvalues[1]) == $dependvalue) {
|
||||
foreach ($dbvalues as $dbval) {
|
||||
if ($dbval == $index AND trim($presvalues[1]) == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -389,26 +444,27 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function get_presentation($data) {
|
||||
// $present = str_replace("\n", FEEDBACK_MULTICHOICERATED_LINE_SEP, trim($data->itemvalues));
|
||||
$present = $this->prepare_presentation_values_save(trim($data->itemvalues), FEEDBACK_MULTICHOICERATED_VALUE_SEP2, FEEDBACK_MULTICHOICERATED_VALUE_SEP);
|
||||
// $present = str_replace("\n", FEEDBACK_MULTICHOICERATED_LINE_SEP, trim($data->itemvalues));
|
||||
if(!isset($data->subtype)) {
|
||||
|
||||
public function get_presentation($data) {
|
||||
$present = $this->prepare_presentation_values_save(trim($data->itemvalues),
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP2,
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP);
|
||||
if (!isset($data->subtype)) {
|
||||
$subtype = 'r';
|
||||
}else {
|
||||
} else {
|
||||
$subtype = substr($data->subtype, 0, 1);
|
||||
}
|
||||
if(isset($data->horizontal) AND $data->horizontal == 1 AND $subtype != 'd') {
|
||||
if (isset($data->horizontal) AND $data->horizontal == 1 AND $subtype != 'd') {
|
||||
$present .= FEEDBACK_MULTICHOICERATED_ADJUST_SEP.'1';
|
||||
}
|
||||
return $subtype.FEEDBACK_MULTICHOICERATED_TYPE_SEP.$present;
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function get_info($item) {
|
||||
private function get_info($item) {
|
||||
$presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
$info = new stdClass();
|
||||
@ -418,53 +474,63 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
$info->presentation = '';
|
||||
$info->horizontal = false;
|
||||
|
||||
@list($info->subtype, $info->presentation) = explode(FEEDBACK_MULTICHOICERATED_TYPE_SEP, $item->presentation);
|
||||
$parts = explode(FEEDBACK_MULTICHOICERATED_TYPE_SEP, $item->presentation);
|
||||
@list($info->subtype, $info->presentation) = $parts;
|
||||
|
||||
if(!isset($info->subtype)) {
|
||||
if (!isset($info->subtype)) {
|
||||
$info->subtype = 'r';
|
||||
}
|
||||
|
||||
if ($info->subtype != 'd') {
|
||||
$parts = explode(FEEDBACK_MULTICHOICERATED_ADJUST_SEP, $info->presentation);
|
||||
@list($info->presentation, $info->horizontal) = $parts;
|
||||
|
||||
if($info->subtype != 'd') {
|
||||
@list($info->presentation, $info->horizontal) = explode(FEEDBACK_MULTICHOICERATED_ADJUST_SEP, $info->presentation);
|
||||
|
||||
if(isset($info->horizontal) AND $info->horizontal == 1) {
|
||||
if (isset($info->horizontal) AND $info->horizontal == 1) {
|
||||
$info->horizontal = true;
|
||||
}else {
|
||||
} else {
|
||||
$info->horizontal = false;
|
||||
}
|
||||
}
|
||||
|
||||
$info->values = $this->prepare_presentation_values_print($info->presentation, FEEDBACK_MULTICHOICERATED_VALUE_SEP, FEEDBACK_MULTICHOICERATED_VALUE_SEP2);
|
||||
$info->values = $this->prepare_presentation_values_print($info->presentation,
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP,
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP2);
|
||||
return $info;
|
||||
}
|
||||
|
||||
function print_item_radio($item, $value, $info, $align, $showrating, $lines) {
|
||||
private function print_item_radio($item, $value, $info, $align, $showrating, $lines) {
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
|
||||
if($info->horizontal) {
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
}else {
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
echo '<ul>';
|
||||
if(!$this->hidenoselect($item)) {
|
||||
if (!$this->hidenoselect($item)) {
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<input type="radio" name="<?php echo $item->typ . '_' . $item->id ;?>" id="<?php echo $item->typ . '_' . $item->id.'_xxx';?>" value="" checked="checked" />
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'id="'.$item->typ.'_'.$item->id.'_xxx" '.
|
||||
'value="" checked="checked" />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>"><?php print_string('not_selected', 'feedback');?> </label>
|
||||
<label for="<?php echo $item->typ . '_' . $item->id.'_xxx';?>">
|
||||
<?php print_string('not_selected', 'feedback');?>
|
||||
</label>
|
||||
</span>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
foreach($lines as $line){
|
||||
if($value == $index){
|
||||
foreach ($lines as $line) {
|
||||
if ($value == $index) {
|
||||
$checked = 'checked="checked"';
|
||||
}else{
|
||||
} else {
|
||||
$checked = '';
|
||||
}
|
||||
$radio_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
|
||||
@ -473,14 +539,20 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
?>
|
||||
<li class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<span class="feedback_item_radio_<?php echo $hv.'_'.$align;?>">
|
||||
<input type="radio" name="<?php echo $inputname;?>" id="<?php echo $inputid;?>" value="<?php echo $index;?>" <?php echo $checked;?> />
|
||||
<?php
|
||||
echo '<input type="radio" '.
|
||||
'name="'.$inputname.'" '.
|
||||
'id="'.$inputid.'" '.
|
||||
'value="'.$index.'" '.$checked.' />';
|
||||
?>
|
||||
</span>
|
||||
<span class="feedback_item_radiolabel_<?php echo $hv.'_'.$align;?>">
|
||||
<label for="<?php echo $inputid;?>">
|
||||
<?php
|
||||
if($showrating) {
|
||||
echo text_to_html('('.$radio_value[0].') '.$radio_value[1], true, false, false);
|
||||
}else {
|
||||
if ($showrating) {
|
||||
$str_rating_value = '('.$radio_value[0].') '.$radio_value[1];
|
||||
echo text_to_html($str_rating_value, true, false, false);
|
||||
} else {
|
||||
echo text_to_html($radio_value[1], true, false, false);
|
||||
}
|
||||
?>
|
||||
@ -493,10 +565,10 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
function print_item_dropdown($item, $value, $info, $align, $showrating, $lines) {
|
||||
if($info->horizontal) {
|
||||
private function print_item_dropdown($item, $value, $info, $align, $showrating, $lines) {
|
||||
if ($info->horizontal) {
|
||||
$hv = 'h';
|
||||
}else {
|
||||
} else {
|
||||
$hv = 'v';
|
||||
}
|
||||
echo '<ul>';
|
||||
@ -507,17 +579,21 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
<?php
|
||||
$index = 1;
|
||||
$checked = '';
|
||||
foreach($lines as $line){
|
||||
if($value == $index){
|
||||
foreach ($lines as $line) {
|
||||
if ($value == $index) {
|
||||
$selected = 'selected="selected"';
|
||||
}else{
|
||||
} else {
|
||||
$selected = '';
|
||||
}
|
||||
$dropdown_value = explode(FEEDBACK_MULTICHOICERATED_VALUE_SEP, $line);
|
||||
if($showrating) {
|
||||
echo '<option value="'.$index.'" '.$selected.'>'.clean_text('('.$dropdown_value[0].') '.$dropdown_value[1]).'</option>';
|
||||
}else {
|
||||
echo '<option value="'.$index.'" '.$selected.'>'.clean_text($dropdown_value[1]).'</option>';
|
||||
if ($showrating) {
|
||||
echo '<option value="'.$index.'" '.$selected.'>';
|
||||
echo clean_text('('.$dropdown_value[0].') '.$dropdown_value[1]);
|
||||
echo '</option>';
|
||||
} else {
|
||||
echo '<option value="'.$index.'" '.$selected.'>';
|
||||
echo clean_text($dropdown_value[1]);
|
||||
echo '</option>';
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
@ -528,16 +604,21 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
function prepare_presentation_values($linesep1, $linesep2, $valuestring, $valuesep1, $valuesep2) {
|
||||
public function prepare_presentation_values($linesep1,
|
||||
$linesep2,
|
||||
$valuestring,
|
||||
$valuesep1,
|
||||
$valuesep2) {
|
||||
|
||||
$lines = explode($linesep1, $valuestring);
|
||||
$newlines = array();
|
||||
foreach($lines as $line) {
|
||||
foreach ($lines as $line) {
|
||||
$value = '';
|
||||
$text = '';
|
||||
if(strpos($line, $valuesep1) === false) {
|
||||
if (strpos($line, $valuesep1) === false) {
|
||||
$value = 0;
|
||||
$text = $line;
|
||||
}else {
|
||||
} else {
|
||||
@list($value, $text) = explode($valuesep1, $line, 2);
|
||||
}
|
||||
|
||||
@ -548,43 +629,51 @@ class feedback_item_multichoicerated extends feedback_item_base {
|
||||
return $newlines;
|
||||
}
|
||||
|
||||
function prepare_presentation_values_print($valuestring, $valuesep1, $valuesep2) {
|
||||
return $this->prepare_presentation_values(FEEDBACK_MULTICHOICERATED_LINE_SEP, "\n", $valuestring, $valuesep1, $valuesep2);
|
||||
public function prepare_presentation_values_print($valuestring, $valuesep1, $valuesep2) {
|
||||
return $this->prepare_presentation_values(FEEDBACK_MULTICHOICERATED_LINE_SEP,
|
||||
"\n",
|
||||
$valuestring,
|
||||
$valuesep1,
|
||||
$valuesep2);
|
||||
}
|
||||
|
||||
function prepare_presentation_values_save($valuestring, $valuesep1, $valuesep2) {
|
||||
return $this->prepare_presentation_values("\n", FEEDBACK_MULTICHOICERATED_LINE_SEP, $valuestring, $valuesep1, $valuesep2);
|
||||
public function prepare_presentation_values_save($valuestring, $valuesep1, $valuesep2) {
|
||||
return $this->prepare_presentation_values("\n",
|
||||
FEEDBACK_MULTICHOICERATED_LINE_SEP,
|
||||
$valuestring,
|
||||
$valuesep1,
|
||||
$valuesep2);
|
||||
}
|
||||
|
||||
function set_ignoreempty($item, $ignoreempty=true) {
|
||||
public function set_ignoreempty($item, $ignoreempty=true) {
|
||||
$item->options = str_replace(FEEDBACK_MULTICHOICERATED_IGNOREEMPTY, '', $item->options);
|
||||
if($ignoreempty) {
|
||||
if ($ignoreempty) {
|
||||
$item->options .= FEEDBACK_MULTICHOICERATED_IGNOREEMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
function ignoreempty($item) {
|
||||
if(strstr($item->options, FEEDBACK_MULTICHOICERATED_IGNOREEMPTY)) {
|
||||
public function ignoreempty($item) {
|
||||
if (strstr($item->options, FEEDBACK_MULTICHOICERATED_IGNOREEMPTY)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function set_hidenoselect($item, $hidenoselect=true) {
|
||||
public function set_hidenoselect($item, $hidenoselect=true) {
|
||||
$item->options = str_replace(FEEDBACK_MULTICHOICERATED_HIDENOSELECT, '', $item->options);
|
||||
if($hidenoselect) {
|
||||
if ($hidenoselect) {
|
||||
$item->options .= FEEDBACK_MULTICHOICERATED_HIDENOSELECT;
|
||||
}
|
||||
}
|
||||
|
||||
function hidenoselect($item) {
|
||||
if(strstr($item->options, FEEDBACK_MULTICHOICERATED_HIDENOSELECT)) {
|
||||
public function hidenoselect($item) {
|
||||
if (strstr($item->options, FEEDBACK_MULTICHOICERATED_HIDENOSELECT)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,25 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_multichoicerated_form extends feedback_item_form {
|
||||
var $type = "multichoicerated";
|
||||
protected $type = "multichoicerated";
|
||||
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
@ -20,16 +34,20 @@ class feedback_multichoicerated_form extends feedback_item_form {
|
||||
$mform->addElement('text',
|
||||
'name',
|
||||
get_string('item_name', 'feedback'),
|
||||
array('size'=>FEEDBACK_ITEM_NAME_TEXTBOX_SIZE, 'maxlength'=>255));
|
||||
array('size'=>FEEDBACK_ITEM_NAME_TEXTBOX_SIZE,
|
||||
'maxlength'=>255));
|
||||
|
||||
$mform->addElement('text',
|
||||
'label',
|
||||
get_string('item_label', 'feedback'),
|
||||
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE, 'maxlength'=>255));
|
||||
array('size'=>FEEDBACK_ITEM_LABEL_TEXTBOX_SIZE,
|
||||
'maxlength'=>255));
|
||||
|
||||
$mform->addElement('select',
|
||||
'horizontal',
|
||||
get_string('adjustment', 'feedback').' ',
|
||||
array(0 => get_string('vertical', 'feedback'), 1 => get_string('horizontal', 'feedback')));
|
||||
array(0 => get_string('vertical', 'feedback'),
|
||||
1 => get_string('horizontal', 'feedback')));
|
||||
|
||||
$mform->addElement('select',
|
||||
'subtype',
|
||||
@ -37,19 +55,30 @@ class feedback_multichoicerated_form extends feedback_item_form {
|
||||
array('r'=>get_string('radio', 'feedback'),
|
||||
'd'=>get_string('dropdown', 'feedback')));
|
||||
|
||||
$mform->addElement('selectyesno', 'ignoreempty', get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
$mform->addElement('selectyesno', 'hidenoselect', get_string('hide_no_select_option', 'feedback'));
|
||||
|
||||
$mform->addElement('static', 'hint', get_string('multichoice_values', 'feedback'), get_string('use_one_line_for_each_value', 'feedback'));
|
||||
$mform->addElement('selectyesno',
|
||||
'ignoreempty',
|
||||
get_string('do_not_analyse_empty_submits', 'feedback'));
|
||||
|
||||
$this->values = $mform->addElement('textarea', 'values', '', 'wrap="virtual" rows="10" cols="65"');
|
||||
$mform->addElement('selectyesno',
|
||||
'hidenoselect',
|
||||
get_string('hide_no_select_option', 'feedback'));
|
||||
|
||||
$mform->addElement('static',
|
||||
'hint',
|
||||
get_string('multichoice_values', 'feedback'),
|
||||
get_string('use_one_line_for_each_value', 'feedback'));
|
||||
|
||||
$this->values = $mform->addElement('textarea',
|
||||
'values',
|
||||
'',
|
||||
'wrap="virtual" rows="10" cols="65"');
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
||||
function set_data($item) {
|
||||
public function set_data($item) {
|
||||
$info = $this->_customdata['info'];
|
||||
|
||||
$item->horizontal = $info->horizontal;
|
||||
@ -58,27 +87,28 @@ class feedback_multichoicerated_form extends feedback_item_form {
|
||||
|
||||
$item->values = $info->values;
|
||||
|
||||
return parent::set_data($item);
|
||||
return parent::set_data($item);
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if(!$item = parent::get_data()) {
|
||||
|
||||
public function get_data() {
|
||||
if (!$item = parent::get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$itemobj = new feedback_item_multichoicerated();
|
||||
|
||||
$presentation = $itemobj->prepare_presentation_values_save(trim($item->values), FEEDBACK_MULTICHOICERATED_VALUE_SEP2, FEEDBACK_MULTICHOICERATED_VALUE_SEP);
|
||||
if(!isset($item->subtype)) {
|
||||
|
||||
$presentation = $itemobj->prepare_presentation_values_save(trim($item->values),
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP2,
|
||||
FEEDBACK_MULTICHOICERATED_VALUE_SEP);
|
||||
if (!isset($item->subtype)) {
|
||||
$subtype = 'r';
|
||||
}else {
|
||||
} else {
|
||||
$subtype = substr($item->subtype, 0, 1);
|
||||
}
|
||||
if(isset($item->horizontal) AND $item->horizontal == 1 AND $subtype != 'd') {
|
||||
if (isset($item->horizontal) AND $item->horizontal == 1 AND $subtype != 'd') {
|
||||
$presentation .= FEEDBACK_MULTICHOICERATED_ADJUST_SEP.'1';
|
||||
}
|
||||
$item->presentation = $subtype.FEEDBACK_MULTICHOICERATED_TYPE_SEP.$presentation;
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,119 +1,152 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_numeric extends feedback_item_base {
|
||||
var $type = "numeric";
|
||||
var $sep_dec, $sep_thous;
|
||||
var $commonparams;
|
||||
var $item_form;
|
||||
var $item;
|
||||
protected $type = "numeric";
|
||||
public $sep_dec, $sep_thous;
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
$this->sep_dec = get_string('separator_decimal', 'feedback');
|
||||
if(substr($this->sep_dec, 0, 2) == '[['){
|
||||
if (substr($this->sep_dec, 0, 2) == '[[') {
|
||||
$this->sep_dec = FEEDBACK_DECIMAL;
|
||||
}
|
||||
|
||||
$this->sep_thous = get_string('separator_thousand', 'feedback');
|
||||
if(substr($this->sep_thous, 0, 2) == '[['){
|
||||
if (substr($this->sep_thous, 0, 2) == '[[') {
|
||||
$this->sep_thous = FEEDBACK_THOUSAND;
|
||||
}
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
require_once('numeric_form.php');
|
||||
|
||||
//get the lastposition number of the feedback_items
|
||||
$position = $item->position;
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
if($position == -1){
|
||||
if ($position == -1) {
|
||||
$i_formselect_last = $lastposition + 1;
|
||||
$i_formselect_value = $lastposition + 1;
|
||||
$item->position = $lastposition + 1;
|
||||
}else {
|
||||
} else {
|
||||
$i_formselect_last = $lastposition;
|
||||
$i_formselect_value = $item->position;
|
||||
}
|
||||
//the elements for position dropdownlist
|
||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
||||
|
||||
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
|
||||
|
||||
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
$range_from_to = explode('|',$item->presentation);
|
||||
$range_from = (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) ? str_replace(FEEDBACK_DECIMAL, $this->sep_dec, floatval($range_from_to[0])) : '-';
|
||||
$range_to = (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) ? str_replace(FEEDBACK_DECIMAL, $this->sep_dec, floatval($range_from_to[1])) : '-';
|
||||
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = str_replace(FEEDBACK_DECIMAL,
|
||||
$this->sep_dec,
|
||||
floatval($range_from_to[0]));
|
||||
} else {
|
||||
$range_from = '-';
|
||||
}
|
||||
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = str_replace(FEEDBACK_DECIMAL,
|
||||
$this->sep_dec,
|
||||
floatval($range_from_to[1]));
|
||||
} else {
|
||||
$range_to = '-';
|
||||
}
|
||||
|
||||
$item->rangefrom = $range_from;
|
||||
$item->rangeto = $range_to;
|
||||
|
||||
//all items for dependitem
|
||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
||||
$commonparams = array('cmid'=>$cm->id,
|
||||
'id'=>isset($item->id) ? $item->id : NULL,
|
||||
'id'=>isset($item->id) ? $item->id : null,
|
||||
'typ'=>$item->typ,
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
|
||||
//build the form
|
||||
$this->item_form = new feedback_numeric_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
|
||||
$customdata = array('item' => $item,
|
||||
'common' => $commonparams,
|
||||
'positionlist' => $positionlist,
|
||||
'position' => $position);
|
||||
|
||||
$this->item_form = new feedback_numeric_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$item = $this->item_form->get_data()) {
|
||||
|
||||
if (!$item = $this->item_form->get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($item->clone_item) AND $item->clone_item) {
|
||||
|
||||
if (isset($item->clone_item) AND $item->clone_item) {
|
||||
$item->id = ''; //to clone this item
|
||||
$item->position++;
|
||||
}
|
||||
|
||||
|
||||
$item->hasvalue = $this->get_hasvalue();
|
||||
if(!$item->id) {
|
||||
if (!$item->id) {
|
||||
$item->id = $DB->insert_record('feedback_item', $item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $item);
|
||||
}
|
||||
|
||||
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
global $DB;
|
||||
|
||||
$analysed = null;
|
||||
$analysed->data = array();
|
||||
$analysed->name = $item->name;
|
||||
//$values = $DB->get_records('feedback_value', array('item'=>$item->id));
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid);
|
||||
|
||||
$avg = 0.0;
|
||||
$counter = 0;
|
||||
if($values) {
|
||||
if ($values) {
|
||||
$data = array();
|
||||
foreach($values as $value) {
|
||||
if(is_numeric($value->value)) {
|
||||
foreach ($values as $value) {
|
||||
if (is_numeric($value->value)) {
|
||||
$data[] = $value->value;
|
||||
$avg += $value->value;
|
||||
$counter++;
|
||||
@ -126,64 +159,67 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
return $analysed;
|
||||
}
|
||||
|
||||
function get_printval($item, $value) {
|
||||
if(!isset($value->value)) return '';
|
||||
public function get_printval($item, $value) {
|
||||
if (!isset($value->value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value->value;
|
||||
}
|
||||
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
|
||||
// $values = feedback_get_group_values($item, $groupid, $courseid);
|
||||
$values = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
if(isset($values->data) AND is_array($values->data)) {
|
||||
//echo '<table>';2
|
||||
// $itemnr++;
|
||||
echo '<tr><th colspan="2" align="left">'. $itemnr . ' ('. $item->label .') ' . $item->name .'</th></tr>';
|
||||
foreach($values->data as $value) {
|
||||
echo '<tr><td colspan="2" valign="top" align="left">- ' . number_format($value, 2, $this->sep_dec, $this->sep_thous) . '</td></tr>';
|
||||
if (isset($values->data) AND is_array($values->data)) {
|
||||
echo '<tr><th colspan="2" align="left">';
|
||||
echo $itemnr.' ('.$item->label.') '.$item->name;
|
||||
echo '</th></tr>';
|
||||
|
||||
foreach ($values->data as $value) {
|
||||
echo '<tr><td colspan="2" valign="top" align="left">';
|
||||
echo '- '.number_format($value, 2, $this->sep_dec, $this->sep_thous);
|
||||
echo '</td></tr>';
|
||||
}
|
||||
//echo '</table>';
|
||||
if(isset($values->avg)) {
|
||||
|
||||
if (isset($values->avg)) {
|
||||
$avg = number_format($values->avg, 2, $this->sep_dec, $this->sep_thous);
|
||||
} else {
|
||||
$avg = number_format(0, 2, $this->sep_dec, $this->sep_thous);
|
||||
}
|
||||
echo '<tr><td align="left" colspan="2"><b>'.get_string('average', 'feedback').': '.$avg.'</b></td></tr>';
|
||||
echo '<tr><td align="left" colspan="2"><b>';
|
||||
echo get_string('average', 'feedback').': '.$avg;
|
||||
echo '</b></td></tr>';
|
||||
}
|
||||
// return $itemnr;
|
||||
}
|
||||
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:green>");
|
||||
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
|
||||
$worksheet->write_string($rowOffset, 1, $item->name, $xlsFormats->head2);
|
||||
$worksheet->write_string($row_offset, 0, $item->label, $xls_formats->head2);
|
||||
$worksheet->write_string($row_offset, 1, $item->name, $xls_formats->head2);
|
||||
$data = $analysed_item->data;
|
||||
if(is_array($data)) {
|
||||
// $worksheet->setFormat("<l><ro2><vo>");
|
||||
// $worksheet->write_number($rowOffset, 1, $data[0]);
|
||||
// $rowOffset++;
|
||||
// for($i = 1; $i < sizeof($data); $i++) {
|
||||
// $worksheet->setFormat("<l><vo>");
|
||||
// $worksheet->write_number($rowOffset, 1, $data[$i]);
|
||||
// $rowOffset++;
|
||||
// }
|
||||
if (is_array($data)) {
|
||||
|
||||
//mittelwert anzeigen
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:red>");
|
||||
$worksheet->write_string($rowOffset, 2, get_string('average', 'feedback'), $xlsFormats->value_bold);
|
||||
$worksheet->write_string($row_offset,
|
||||
2,
|
||||
get_string('average', 'feedback'),
|
||||
$xls_formats->value_bold);
|
||||
|
||||
// $worksheet->setFormat("<l><f><vo>");
|
||||
$worksheet->write_number($rowOffset + 1, 2, $analysed_item->avg, $xlsFormats->value_bold);
|
||||
$rowOffset++;
|
||||
$worksheet->write_number($row_offset + 1,
|
||||
2,
|
||||
$analysed_item->avg,
|
||||
$xls_formats->value_bold);
|
||||
$row_offset++;
|
||||
}
|
||||
$rowOffset++;
|
||||
return $rowOffset;
|
||||
$row_offset++;
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
@ -191,52 +227,75 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
//get the range
|
||||
$range_from_to = explode('|',$item->presentation);
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
|
||||
//get the min-value
|
||||
$range_from = (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) ? floatval($range_from_to[0]) : 0;
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = 0;
|
||||
}
|
||||
|
||||
//get the max-value
|
||||
$range_to = (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) ? floatval($range_from_to[1]) : 0;
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = 0;
|
||||
}
|
||||
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
if($item->dependitem) {
|
||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
||||
}
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
if ($item->dependitem) {
|
||||
$params = array('id'=>$item->dependitem);
|
||||
if ($dependitem = $DB->get_record('feedback_item', $params)) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.$dependitem->label.'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
echo '<span class="feedback_item_numinfo">';
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '</span>';
|
||||
}
|
||||
echo '<span class="feedback_item_numinfo">';
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').
|
||||
': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').
|
||||
': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).
|
||||
' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" name="'.$item->typ.'_'.$item->id.'" size="10" maxlength="10" value="" />';
|
||||
echo '<input type="text" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'size="10" '.
|
||||
'maxlength="10" '.
|
||||
'value="" />';
|
||||
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
@ -246,47 +305,67 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
//get the range
|
||||
$range_from_to = explode('|',$item->presentation);
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
|
||||
//get the min-value
|
||||
$range_from = (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) ? floatval($range_from_to[0]) : 0;
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = 0;
|
||||
}
|
||||
|
||||
//get the max-value
|
||||
$range_to = (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) ? floatval($range_from_to[1]) : 0;
|
||||
if($highlightrequire AND (!$this->check_value($value, $item))) {
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = 0;
|
||||
}
|
||||
|
||||
if ($highlightrequire AND (!$this->check_value($value, $item))) {
|
||||
$highlight = ' missingrequire';
|
||||
}else {
|
||||
} else {
|
||||
$highlight = '';
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.$highlight.'">';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
echo '<span class="feedback_item_numinfo">';
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '</span>';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
echo '<span class="feedback_item_numinfo">';
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').
|
||||
': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').
|
||||
': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).
|
||||
' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.$highlight.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" name="'.$item->typ.'_'.$item->id.'" size="10" maxlength="10" value="'.($value ? $value : '').'" />';
|
||||
echo '<input type="text" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'size="10" '.
|
||||
'maxlength="10" '.
|
||||
'value="'.($value ? $value : '').'" />';
|
||||
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
@ -299,79 +378,114 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
//get the range
|
||||
$range_from_to = explode('|',$item->presentation);
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
//get the min-value
|
||||
$range_from = (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) ? floatval($range_from_to[0]) : 0;
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = 0;
|
||||
}
|
||||
//get the max-value
|
||||
$range_to = (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) ? floatval($range_from_to[1]) : 0;
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = 0;
|
||||
}
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
echo ' ('.get_string('maximal', 'feedback').
|
||||
': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
echo ' ('.get_string('minimal', 'feedback').
|
||||
': '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).')';
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
break;
|
||||
default:
|
||||
echo ' ('.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_from).
|
||||
' - '.str_replace(FEEDBACK_DECIMAL, $this->sep_dec, $range_to).')';
|
||||
break;
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo (is_numeric($value)) ? number_format($value, 2, $this->sep_dec, $this->sep_thous) : ' ';
|
||||
if (is_numeric($value)) {
|
||||
$str_num_value = number_format($value, 2, $this->sep_dec, $this->sep_thous);
|
||||
} else {
|
||||
$str_num_value = ' ';
|
||||
}
|
||||
echo $str_num_value;
|
||||
echo $OUTPUT->box_end();
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
function check_value($value, $item) {
|
||||
public function check_value($value, $item) {
|
||||
$value = str_replace($this->sep_dec, FEEDBACK_DECIMAL, $value);
|
||||
//if the item is not required, so the check is true if no value is given
|
||||
if((!isset($value) OR $value == '') AND $item->required != 1) return true;
|
||||
if(!is_numeric($value))return false;
|
||||
if ((!isset($value) OR $value == '') AND $item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
if (!is_numeric($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$range_from_to = explode('|',$item->presentation);
|
||||
$range_from = (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) ? floatval($range_from_to[0]) : '-';
|
||||
$range_to = (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) ? floatval($range_from_to[1]) : '-';
|
||||
$range_from_to = explode('|', $item->presentation);
|
||||
if (isset($range_from_to[0]) AND is_numeric($range_from_to[0])) {
|
||||
$range_from = floatval($range_from_to[0]);
|
||||
} else {
|
||||
$range_from = '-';
|
||||
}
|
||||
if (isset($range_from_to[1]) AND is_numeric($range_from_to[1])) {
|
||||
$range_to = floatval($range_from_to[1]);
|
||||
} else {
|
||||
$range_to = '-';
|
||||
}
|
||||
|
||||
switch(true) {
|
||||
case ($range_from === '-' AND is_numeric($range_to)):
|
||||
if(floatval($value) <= $range_to) return true;
|
||||
if (floatval($value) <= $range_to) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case (is_numeric($range_from) AND $range_to === '-'):
|
||||
if(floatval($value) >= $range_from) return true;
|
||||
if (floatval($value) >= $range_from) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case ($range_from === '-' AND $range_to === '-'):
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
if(floatval($value) >= $range_from AND floatval($value) <= $range_to) return true;
|
||||
if (floatval($value) >= $range_from AND floatval($value) <= $range_to) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
$data = str_replace($this->sep_dec, FEEDBACK_DECIMAL, $data);
|
||||
|
||||
if(is_numeric($data)) {
|
||||
if (is_numeric($data)) {
|
||||
$data = floatval($data);
|
||||
}else {
|
||||
} else {
|
||||
$data = '';
|
||||
}
|
||||
return $data;
|
||||
@ -380,44 +494,44 @@ class feedback_item_numeric extends feedback_item_base {
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the number put in by the user
|
||||
//dependvalue is the value that is compared
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if($dbvalue == $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_presentation($data) {
|
||||
|
||||
public function get_presentation($data) {
|
||||
$num1 = str_replace($this->sep_dec, FEEDBACK_DECIMAL, $data->numericrangefrom);
|
||||
if(is_numeric($num1)) {
|
||||
if (is_numeric($num1)) {
|
||||
$num1 = floatval($num1);
|
||||
}else {
|
||||
} else {
|
||||
$num1 = '-';
|
||||
}
|
||||
|
||||
$num2 = str_replace($this->sep_dec, FEEDBACK_DECIMAL, $data->numericrangeto);
|
||||
if(is_numeric($num2)) {
|
||||
if (is_numeric($num2)) {
|
||||
$num2 = floatval($num2);
|
||||
}else {
|
||||
} else {
|
||||
$num2 = '-';
|
||||
}
|
||||
|
||||
if($num1 === '-' OR $num2 === '-') {
|
||||
if ($num1 === '-' OR $num2 === '-') {
|
||||
return $num1 . '|'. $num2;
|
||||
}
|
||||
|
||||
if($num1 > $num2) {
|
||||
if ($num1 > $num2) {
|
||||
return $num2 . '|'. $num1;
|
||||
}else {
|
||||
} else {
|
||||
return $num1 . '|'. $num2;
|
||||
}
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,31 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_numeric_form extends feedback_item_form {
|
||||
var $type = "numeric";
|
||||
protected $type = "numeric";
|
||||
|
||||
public function definition() {
|
||||
|
||||
function definition() {
|
||||
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
$position = $this->_customdata['position'];
|
||||
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('header', 'general', get_string($this->type, 'feedback'));
|
||||
@ -34,46 +48,45 @@ class feedback_numeric_form extends feedback_item_form {
|
||||
$mform->addElement('text',
|
||||
'rangeto',
|
||||
get_string('numeric_range_to', 'feedback'),
|
||||
array('size'=>10,'maxlength'=>10));
|
||||
array('size'=>10, 'maxlength'=>10));
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if(!$item = parent::get_data()) {
|
||||
public function get_data() {
|
||||
if (!$item = parent::get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$itemobj = new feedback_item_numeric();
|
||||
|
||||
$num1 = str_replace($itemobj->sep_dec, FEEDBACK_DECIMAL, $item->rangefrom);
|
||||
if(is_numeric($num1)) {
|
||||
if (is_numeric($num1)) {
|
||||
$num1 = floatval($num1);
|
||||
}else {
|
||||
} else {
|
||||
$num1 = '-';
|
||||
}
|
||||
|
||||
$num2 = str_replace($itemobj->sep_dec, FEEDBACK_DECIMAL, $item->rangeto);
|
||||
if(is_numeric($num2)) {
|
||||
if (is_numeric($num2)) {
|
||||
$num2 = floatval($num2);
|
||||
}else {
|
||||
} else {
|
||||
$num2 = '-';
|
||||
}
|
||||
|
||||
if($num1 === '-' OR $num2 === '-') {
|
||||
if ($num1 === '-' OR $num2 === '-') {
|
||||
$item->presentation = $num1 . '|'. $num2;
|
||||
return $item;
|
||||
}
|
||||
|
||||
if($num1 > $num2) {
|
||||
if ($num1 > $num2) {
|
||||
$item->presentation = $num2 . '|'. $num1;
|
||||
}else {
|
||||
} else {
|
||||
$item->presentation = $num1 . '|'. $num2;
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,158 +1,195 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_textarea extends feedback_item_base {
|
||||
var $type = "textarea";
|
||||
var $commonparams;
|
||||
var $item_form;
|
||||
var $item;
|
||||
protected $type = "textarea";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
require_once('textarea_form.php');
|
||||
|
||||
//get the lastposition number of the feedback_items
|
||||
$position = $item->position;
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
if($position == -1){
|
||||
if ($position == -1) {
|
||||
$i_formselect_last = $lastposition + 1;
|
||||
$i_formselect_value = $lastposition + 1;
|
||||
$item->position = $lastposition + 1;
|
||||
}else {
|
||||
} else {
|
||||
$i_formselect_last = $lastposition;
|
||||
$i_formselect_value = $item->position;
|
||||
}
|
||||
//the elements for position dropdownlist
|
||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
||||
|
||||
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
|
||||
|
||||
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
$widthAndHeight = explode('|',$item->presentation);
|
||||
$itemwidth = (isset($widthAndHeight[0]) AND $widthAndHeight[0] >= 5) ? $widthAndHeight[0] : 30;
|
||||
$itemheight = isset($widthAndHeight[1]) ? $widthAndHeight[1] : 5;
|
||||
|
||||
$width_and_height = explode('|', $item->presentation);
|
||||
|
||||
if (isset($width_and_height[0]) AND $width_and_height[0] >= 5) {
|
||||
$itemwidth = $width_and_height[0];
|
||||
} else {
|
||||
$itemwidth = 30;
|
||||
}
|
||||
|
||||
if (isset($width_and_height[1])) {
|
||||
$itemheight = $width_and_height[1];
|
||||
} else {
|
||||
$itemheight = 5;
|
||||
}
|
||||
$item->itemwidth = $itemwidth;
|
||||
$item->itemheight = $itemheight;
|
||||
|
||||
//all items for dependitem
|
||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
||||
$commonparams = array('cmid'=>$cm->id,
|
||||
'id'=>isset($item->id) ? $item->id : NULL,
|
||||
'id'=>isset($item->id) ? $item->id : null,
|
||||
'typ'=>$item->typ,
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
|
||||
//build the form
|
||||
$this->item_form = new feedback_textarea_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
|
||||
$customdata = array('item' => $item,
|
||||
'common' => $commonparams,
|
||||
'positionlist' => $positionlist,
|
||||
'position' => $position);
|
||||
|
||||
$this->item_form = new feedback_textarea_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$item = $this->item_form->get_data()) {
|
||||
|
||||
if (!$item = $this->item_form->get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($item->clone_item) AND $item->clone_item) {
|
||||
|
||||
if (isset($item->clone_item) AND $item->clone_item) {
|
||||
$item->id = ''; //to clone this item
|
||||
$item->position++;
|
||||
}
|
||||
|
||||
|
||||
$item->hasvalue = $this->get_hasvalue();
|
||||
if(!$item->id) {
|
||||
if (!$item->id) {
|
||||
$item->id = $DB->insert_record('feedback_item', $item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $item);
|
||||
}
|
||||
|
||||
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
global $DB;
|
||||
|
||||
$aVal = null;
|
||||
$aVal->data = array();
|
||||
$aVal->name = $item->name;
|
||||
//$values = $DB->get_records('feedback_value', array('item'=>$item->id));
|
||||
$analysed_val = null;
|
||||
$analysed_val->data = array();
|
||||
$analysed_val->name = $item->name;
|
||||
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid);
|
||||
if($values) {
|
||||
if ($values) {
|
||||
$data = array();
|
||||
foreach($values as $value) {
|
||||
foreach ($values as $value) {
|
||||
$data[] = str_replace("\n", '<br />', $value->value);
|
||||
}
|
||||
$aVal->data = $data;
|
||||
$analysed_val->data = $data;
|
||||
}
|
||||
return $aVal;
|
||||
return $analysed_val;
|
||||
}
|
||||
|
||||
function get_printval($item, $value) {
|
||||
public function get_printval($item, $value) {
|
||||
|
||||
if(!isset($value->value)) return '';
|
||||
if (!isset($value->value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value->value;
|
||||
}
|
||||
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid);
|
||||
if($values) {
|
||||
//echo '<table>';2
|
||||
// $itemnr++;
|
||||
echo '<tr><th colspan="2" align="left">'. $itemnr . ' ('. $item->label .') ' . $item->name .'</th></tr>';
|
||||
foreach($values as $value) {
|
||||
echo '<tr><td valign="top" align="left">- </td><td align="left" valign="top">' . str_replace("\n", '<br />', $value->value) . '</td></tr>';
|
||||
if ($values) {
|
||||
echo '<tr><th colspan="2" align="left">';
|
||||
echo $itemnr.' ('.$item->label.') '.$item->name;
|
||||
echo '</th></tr>';
|
||||
foreach ($values as $value) {
|
||||
echo '<tr>';
|
||||
echo '<td valign="top" align="left">';
|
||||
echo '- ';
|
||||
echo '</td>';
|
||||
echo '<td align="left" valign="top">';
|
||||
echo str_replace("\n", '<br />', $value->value);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
//echo '</table>';
|
||||
}
|
||||
// return $itemnr;
|
||||
}
|
||||
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:green>");
|
||||
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
|
||||
$worksheet->write_string($rowOffset, 1, $item->name, $xlsFormats->head2);
|
||||
$worksheet->write_string($row_offset, 0, $item->label, $xls_formats->head2);
|
||||
$worksheet->write_string($row_offset, 1, $item->name, $xls_formats->head2);
|
||||
$data = $analysed_item->data;
|
||||
if(is_array($data)) {
|
||||
// $worksheet->setFormat("<l><ro2><vo>");
|
||||
if(isset($data[0])) {
|
||||
$worksheet->write_string($rowOffset, 2, $data[0], $xlsFormats->value_bold);
|
||||
if (is_array($data)) {
|
||||
if (isset($data[0])) {
|
||||
$worksheet->write_string($row_offset, 2, $data[0], $xls_formats->value_bold);
|
||||
}
|
||||
$rowOffset++;
|
||||
$sizeofdata = sizeof($data);
|
||||
for($i = 1; $i < $sizeofdata; $i++) {
|
||||
// $worksheet->setFormat("<l><vo>");
|
||||
$worksheet->write_string($rowOffset, 2, $data[$i], $xlsFormats->default);
|
||||
$rowOffset++;
|
||||
$row_offset++;
|
||||
$sizeofdata = count($data);
|
||||
for ($i = 1; $i < $sizeofdata; $i++) {
|
||||
$worksheet->write_string($row_offset, 2, $data[$i], $xls_formats->default);
|
||||
$row_offset++;
|
||||
}
|
||||
}
|
||||
$rowOffset++;
|
||||
return $rowOffset;
|
||||
$row_offset++;
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
@ -160,20 +197,23 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
|
||||
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name.$requiredmark, true, false, false);
|
||||
if($item->dependitem) {
|
||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.$dependitem->label.'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
@ -181,11 +221,14 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textarea">';
|
||||
echo '<textarea name="'.$item->typ.'_'.$item->id.'" cols="'.$presentation[0].'" rows="'.$presentation[1].'"></textarea>';
|
||||
echo '<textarea name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'cols="'.$presentation[0].'" '.
|
||||
'rows="'.$presentation[1].'">';
|
||||
echo '</textarea>';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
@ -195,27 +238,32 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
if($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
if ($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
$highlight = ' missingrequire';
|
||||
}else {
|
||||
} else {
|
||||
$highlight = '';
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark :'';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.$highlight.'">';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
echo '</div>';
|
||||
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.$highlight.'">';
|
||||
echo '<span class="feedback_item_textarea">';
|
||||
echo '<textarea name="'.$item->typ.'_'.$item->id.'" cols="'.$presentation[0].'" rows="'.$presentation[1].'">'.($value ? htmlspecialchars($value) : '').'</textarea>';
|
||||
echo '<textarea name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'cols="'.$presentation[0].'" '.
|
||||
'rows="'.$presentation[1].'">';
|
||||
echo ($value ? htmlspecialchars($value) : '');
|
||||
echo '</textarea>';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
@ -228,33 +276,38 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name . $requiredmark, true, false, false);
|
||||
echo '</div>';
|
||||
|
||||
|
||||
//print the presentation
|
||||
echo $OUTPUT->box_start('generalbox boxalign'.$align);
|
||||
echo $value?str_replace("\n",'<br />',$value):' ';
|
||||
echo $value ? str_replace("\n", '<br />', $value) : ' ';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
function check_value($value, $item) {
|
||||
public function check_value($value, $item) {
|
||||
//if the item is not required, so the check is true if no value is given
|
||||
if((!isset($value) OR $value == '') AND $item->required != 1) return true;
|
||||
if($value == "")return false;
|
||||
if ((!isset($value) OR $value == '') AND $item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
if ($value == "") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
$data = clean_text($data);
|
||||
return $data;
|
||||
}
|
||||
@ -262,22 +315,22 @@ class feedback_item_textarea extends feedback_item_base {
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the value put in by the user
|
||||
//dependvalue is the value that is compared
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if($dbvalue == $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_presentation($data) {
|
||||
return $data->itemwidth . '|'. $data->itemheight;
|
||||
|
||||
public function get_presentation($data) {
|
||||
return $data->itemwidth.'|'.$data->itemheight;
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,25 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_textarea_form extends feedback_item_form {
|
||||
var $type = "textarea";
|
||||
protected $type = "textarea";
|
||||
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
@ -28,23 +42,23 @@ class feedback_textarea_form extends feedback_item_form {
|
||||
$mform->addElement('select',
|
||||
'itemwidth',
|
||||
get_string('textarea_width', 'feedback').' ',
|
||||
array_slice(range(0,80),5,80,true));
|
||||
array_slice(range(0, 80), 5, 80, true));
|
||||
|
||||
$mform->addElement('select',
|
||||
'itemheight',
|
||||
get_string('textarea_height', 'feedback').' ',
|
||||
array_slice(range(0,40),5,40,true));
|
||||
array_slice(range(0, 40), 5, 40, true));
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if(!$item = parent::get_data()) {
|
||||
|
||||
public function get_data() {
|
||||
if (!$item = parent::get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$item->presentation = $item->itemwidth . '|'. $item->itemheight;
|
||||
return $item;
|
||||
}
|
||||
|
@ -1,155 +1,184 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_class.php');
|
||||
|
||||
class feedback_item_textfield extends feedback_item_base {
|
||||
var $type = "textfield";
|
||||
var $commonparams;
|
||||
var $item_form;
|
||||
var $item;
|
||||
protected $type = "textfield";
|
||||
private $commonparams;
|
||||
private $item_form;
|
||||
private $item;
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
|
||||
}
|
||||
|
||||
function build_editform($item, $feedback, $cm) {
|
||||
public function build_editform($item, $feedback, $cm) {
|
||||
global $DB, $CFG;
|
||||
require_once('textfield_form.php');
|
||||
|
||||
//get the lastposition number of the feedback_items
|
||||
$position = $item->position;
|
||||
$lastposition = $DB->count_records('feedback_item', array('feedback'=>$feedback->id));
|
||||
if($position == -1){
|
||||
if ($position == -1) {
|
||||
$i_formselect_last = $lastposition + 1;
|
||||
$i_formselect_value = $lastposition + 1;
|
||||
$item->position = $lastposition + 1;
|
||||
}else {
|
||||
} else {
|
||||
$i_formselect_last = $lastposition;
|
||||
$i_formselect_value = $item->position;
|
||||
}
|
||||
//the elements for position dropdownlist
|
||||
$positionlist = array_slice(range(0,$i_formselect_last),1,$i_formselect_last,true);
|
||||
|
||||
$positionlist = array_slice(range(0, $i_formselect_last), 1, $i_formselect_last, true);
|
||||
|
||||
$item->presentation = empty($item->presentation) ? '' : $item->presentation;
|
||||
|
||||
$sizeAndLength = explode('|',$item->presentation);
|
||||
$itemsize = (isset($sizeAndLength[0]) AND $sizeAndLength[0] >= 5) ? $sizeAndLength[0] : 30;
|
||||
$itemlength = isset($sizeAndLength[1]) ? $sizeAndLength[1] : 5;
|
||||
|
||||
$size_and_length = explode('|', $item->presentation);
|
||||
|
||||
if (isset($size_and_length[0]) AND $size_and_length[0] >= 5) {
|
||||
$itemsize = $size_and_length[0];
|
||||
} else {
|
||||
$itemsize = 30;
|
||||
}
|
||||
|
||||
$itemlength = isset($size_and_length[1]) ? $size_and_length[1] : 5;
|
||||
|
||||
$item->itemsize = $itemsize;
|
||||
$item->itemmaxlength = $itemlength;
|
||||
|
||||
//all items for dependitem
|
||||
$feedbackitems = feedback_get_depend_candidates_for_item($feedback, $item);
|
||||
$commonparams = array('cmid'=>$cm->id,
|
||||
'id'=>isset($item->id) ? $item->id : NULL,
|
||||
'typ'=>$item->typ,
|
||||
'items'=>$feedbackitems,
|
||||
'feedback'=>$feedback->id);
|
||||
$commonparams = array('cmid' => $cm->id,
|
||||
'id' => isset($item->id) ? $item->id : null,
|
||||
'typ' => $item->typ,
|
||||
'items' => $feedbackitems,
|
||||
'feedback' => $feedback->id);
|
||||
|
||||
//build the form
|
||||
$this->item_form = new feedback_textfield_form('edit_item.php', array('item'=>$item, 'common'=>$commonparams, 'positionlist'=>$positionlist, 'position'=>$position));
|
||||
$customdata = array('item' => $item,
|
||||
'common' => $commonparams,
|
||||
'positionlist' => $positionlist,
|
||||
'position' => $position);
|
||||
|
||||
$this->item_form = new feedback_textfield_form('edit_item.php', $customdata);
|
||||
}
|
||||
|
||||
//this function only can used after the call of build_editform()
|
||||
function show_editform() {
|
||||
public function show_editform() {
|
||||
$this->item_form->display();
|
||||
}
|
||||
|
||||
function is_cancelled() {
|
||||
|
||||
public function is_cancelled() {
|
||||
return $this->item_form->is_cancelled();
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if($this->item = $this->item_form->get_data()) {
|
||||
public function get_data() {
|
||||
if ($this->item = $this->item_form->get_data()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function save_item() {
|
||||
public function save_item() {
|
||||
global $DB;
|
||||
|
||||
if(!$item = $this->item_form->get_data()) {
|
||||
|
||||
if (!$item = $this->item_form->get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($item->clone_item) AND $item->clone_item) {
|
||||
|
||||
if (isset($item->clone_item) AND $item->clone_item) {
|
||||
$item->id = ''; //to clone this item
|
||||
$item->position++;
|
||||
}
|
||||
|
||||
|
||||
$item->hasvalue = $this->get_hasvalue();
|
||||
if(!$item->id) {
|
||||
if (!$item->id) {
|
||||
$item->id = $DB->insert_record('feedback_item', $item);
|
||||
}else {
|
||||
} else {
|
||||
$DB->update_record('feedback_item', $item);
|
||||
}
|
||||
|
||||
|
||||
return $DB->get_record('feedback_item', array('id'=>$item->id));
|
||||
}
|
||||
|
||||
|
||||
//liefert eine Struktur ->name, ->data = array(mit Antworten)
|
||||
function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
public function get_analysed($item, $groupid = false, $courseid = false) {
|
||||
global $DB;
|
||||
|
||||
$aVal = null;
|
||||
$aVal->data = null;
|
||||
$aVal->name = $item->name;
|
||||
//$values = $DB->get_records('feedback_value', array('item'=>$item->id));
|
||||
$analysed_val = null;
|
||||
$analysed_val->data = null;
|
||||
$analysed_val->name = $item->name;
|
||||
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid);
|
||||
if($values) {
|
||||
if ($values) {
|
||||
$data = array();
|
||||
foreach($values as $value) {
|
||||
foreach ($values as $value) {
|
||||
$data[] = str_replace("\n", '<br />', $value->value);
|
||||
}
|
||||
$aVal->data = $data;
|
||||
$analysed_val->data = $data;
|
||||
}
|
||||
return $aVal;
|
||||
return $analysed_val;
|
||||
}
|
||||
|
||||
function get_printval($item, $value) {
|
||||
public function get_printval($item, $value) {
|
||||
|
||||
if(!isset($value->value)) return '';
|
||||
if (!isset($value->value)) {
|
||||
return '';
|
||||
}
|
||||
return $value->value;
|
||||
}
|
||||
|
||||
function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
public function print_analysed($item, $itemnr = '', $groupid = false, $courseid = false) {
|
||||
$values = feedback_get_group_values($item, $groupid, $courseid);
|
||||
if($values) {
|
||||
//echo '<table>';2
|
||||
// $itemnr++;
|
||||
echo '<tr><th colspan="2" align="left">'. $itemnr . ' ('. $item->label .') ' . $item->name .'</th></tr>';
|
||||
foreach($values as $value) {
|
||||
echo '<tr><td colspan="2" valign="top" align="left">- ' . str_replace("\n", '<br />', $value->value) . '</td></tr>';
|
||||
if ($values) {
|
||||
echo '<tr><th colspan="2" align="left">';
|
||||
echo $itemnr.' ('.$item->label.') '.$item->name;
|
||||
echo '</th></tr>';
|
||||
foreach ($values as $value) {
|
||||
echo '<tr><td colspan="2" valign="top" align="left">';
|
||||
echo '- '.str_replace("\n", '<br />', $value->value);
|
||||
echo '</td></tr>';
|
||||
}
|
||||
//echo '</table>';
|
||||
}
|
||||
// return $itemnr;
|
||||
}
|
||||
|
||||
function excelprint_item(&$worksheet, $rowOffset, $xlsFormats, $item, $groupid, $courseid = false) {
|
||||
public function excelprint_item(&$worksheet, $row_offset,
|
||||
$xls_formats, $item,
|
||||
$groupid, $courseid = false) {
|
||||
|
||||
$analysed_item = $this->get_analysed($item, $groupid, $courseid);
|
||||
|
||||
// $worksheet->setFormat("<l><f><ro2><vo><c:green>");
|
||||
$worksheet->write_string($rowOffset, 0, $item->label, $xlsFormats->head2);
|
||||
$worksheet->write_string($rowOffset, 1, $item->name, $xlsFormats->head2);
|
||||
$worksheet->write_string($row_offset, 0, $item->label, $xls_formats->head2);
|
||||
$worksheet->write_string($row_offset, 1, $item->name, $xls_formats->head2);
|
||||
$data = $analysed_item->data;
|
||||
if(is_array($data)) {
|
||||
// $worksheet->setFormat("<l><ro2><vo>");
|
||||
$worksheet->write_string($rowOffset, 2, $data[0], $xlsFormats->value_bold);
|
||||
$rowOffset++;
|
||||
$sizeofdata = sizeof($data);
|
||||
for($i = 1; $i < $sizeofdata; $i++) {
|
||||
// $worksheet->setFormat("<l><vo>");
|
||||
$worksheet->write_string($rowOffset, 2, $data[$i], $xlsFormats->default);
|
||||
$rowOffset++;
|
||||
if (is_array($data)) {
|
||||
$worksheet->write_string($row_offset, 2, $data[0], $xls_formats->value_bold);
|
||||
$row_offset++;
|
||||
$sizeofdata = count($data);
|
||||
for ($i = 1; $i < $sizeofdata; $i++) {
|
||||
$worksheet->write_string($row_offset, 2, $data[$i], $xls_formats->default);
|
||||
$row_offset++;
|
||||
}
|
||||
}
|
||||
$rowOffset++;
|
||||
return $rowOffset;
|
||||
$row_offset++;
|
||||
return $row_offset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print the item at the edit-page of feedback
|
||||
*
|
||||
@ -157,19 +186,22 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
* @param object $item
|
||||
* @return void
|
||||
*/
|
||||
function print_item_preview($item) {
|
||||
public function print_item_preview($item) {
|
||||
global $OUTPUT, $DB;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
echo format_text($item->name.$requiredmark, true, false, false);
|
||||
if($item->dependitem) {
|
||||
if($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">('.$dependitem->label.'->'.$item->dependvalue.')</span>';
|
||||
if ($item->dependitem) {
|
||||
if ($dependitem = $DB->get_record('feedback_item', array('id'=>$item->dependitem))) {
|
||||
echo ' <span class="feedback_depend">';
|
||||
echo '('.$dependitem->label.'->'.$item->dependvalue.')';
|
||||
echo '</span>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
@ -177,11 +209,15 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" name="'.$item->typ . '_' . $item->id.'" size="'.$presentation[0].'" maxlength="'.$presentation[1].'" value="" />';
|
||||
echo '<input type="text" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'size="'.$presentation[0].'" '.
|
||||
'maxlength="'.$presentation[1].'" '.
|
||||
'value="" />';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* print the item at the complete-page of feedback
|
||||
*
|
||||
@ -191,27 +227,32 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
* @param bool $highlightrequire
|
||||
* @return void
|
||||
*/
|
||||
function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
public function print_item_complete($item, $value = '', $highlightrequire = false) {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
if($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
if ($highlightrequire AND $item->required AND strval($value) == '') {
|
||||
$highlight = ' missingrequire';
|
||||
}else {
|
||||
} else {
|
||||
$highlight = '';
|
||||
}
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.$highlight.'">';
|
||||
echo format_text($item->name.$requiredmark, true, false, false);
|
||||
echo '</div>';
|
||||
|
||||
|
||||
//print the presentation
|
||||
echo '<div class="feedback_item_presentation_'.$align.$highlight.'">';
|
||||
echo '<span class="feedback_item_textfield">';
|
||||
echo '<input type="text" name="'.$item->typ.'_'.$item->id.'" size="'.$presentation[0].'" maxlength="'.$presentation[1].'" value="'.($value ? htmlspecialchars($value) : '').'" />';
|
||||
echo '<input type="text" '.
|
||||
'name="'.$item->typ.'_'.$item->id.'" '.
|
||||
'size="'.$presentation[0].'" '.
|
||||
'maxlength="'.$presentation[1].'" '.
|
||||
'value="'.($value ? htmlspecialchars($value) : '').'" />';
|
||||
echo '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
@ -224,13 +265,14 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
function print_item_show_value($item, $value = '') {
|
||||
public function print_item_show_value($item, $value = '') {
|
||||
global $OUTPUT;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$str_required_mark = '<span class="feedback_required_mark">*</span>';
|
||||
|
||||
$presentation = explode ("|", $item->presentation);
|
||||
$requiredmark = ($item->required == 1)?'<span class="feedback_required_mark">*</span>':'';
|
||||
|
||||
$requiredmark = ($item->required == 1) ? $str_required_mark : '';
|
||||
|
||||
//print the question and label
|
||||
echo '<div class="feedback_item_label_'.$align.'">';
|
||||
echo '('.$item->label.') ';
|
||||
@ -241,14 +283,18 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
function check_value($value, $item) {
|
||||
public function check_value($value, $item) {
|
||||
//if the item is not required, so the check is true if no value is given
|
||||
if((!isset($value) OR $value == '') AND $item->required != 1) return true;
|
||||
if($value == "")return false;
|
||||
if ((!isset($value) OR $value == '') AND $item->required != 1) {
|
||||
return true;
|
||||
}
|
||||
if ($value == "") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function create_value($data) {
|
||||
public function create_value($data) {
|
||||
$data = clean_text($data);
|
||||
return $data;
|
||||
}
|
||||
@ -256,22 +302,22 @@ class feedback_item_textfield extends feedback_item_base {
|
||||
//compares the dbvalue with the dependvalue
|
||||
//dbvalue is the value put in by the user
|
||||
//dependvalue is the value that is compared
|
||||
function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if($dbvalue == $dependvalue) {
|
||||
public function compare_value($item, $dbvalue, $dependvalue) {
|
||||
if ($dbvalue == $dependvalue) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_presentation($data) {
|
||||
|
||||
public function get_presentation($data) {
|
||||
return $data->itemsize . '|'. $data->itemmaxlength;
|
||||
}
|
||||
|
||||
function get_hasvalue() {
|
||||
public function get_hasvalue() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
function can_switch_require() {
|
||||
public function can_switch_require() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,25 @@
|
||||
<?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/>.
|
||||
|
||||
require_once($CFG->dirroot.'/mod/feedback/item/feedback_item_form_class.php');
|
||||
|
||||
class feedback_textfield_form extends feedback_item_form {
|
||||
var $type = "textfield";
|
||||
protected $type = "textfield";
|
||||
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$item = $this->_customdata['item'];
|
||||
$common = $this->_customdata['common'];
|
||||
$positionlist = $this->_customdata['positionlist'];
|
||||
@ -28,23 +42,23 @@ class feedback_textfield_form extends feedback_item_form {
|
||||
$mform->addElement('select',
|
||||
'itemsize',
|
||||
get_string('textfield_size', 'feedback').' ',
|
||||
array_slice(range(0,255),5,255,true));
|
||||
array_slice(range(0, 255), 5, 255, true));
|
||||
|
||||
$mform->addElement('select',
|
||||
'itemmaxlength',
|
||||
get_string('textfield_maxlength', 'feedback').' ',
|
||||
array_slice(range(0,255),5,255,true));
|
||||
array_slice(range(0, 255), 5, 255, true));
|
||||
|
||||
parent::definition();
|
||||
$this->set_data($item);
|
||||
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
if(!$item = parent::get_data()) {
|
||||
|
||||
public function get_data() {
|
||||
if (!$item = parent::get_data()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$item->presentation = $item->itemsize . '|'. $item->itemmaxlength;
|
||||
return $item;
|
||||
}
|
||||
|
@ -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
|
||||
@ -97,12 +96,12 @@ $string['edit_items'] = 'Edit questions';
|
||||
$string['email_notification'] = 'Send e-mail notifications';
|
||||
$string['emailnotification'] = 'emailnotifications';
|
||||
$string['emailnotification_help'] = 'If enabled, administrators receive email notification of feedback submissions.';
|
||||
$string['emailteachermail'] = '{$a->username} has completed feedback activity : \'{$a->feedback}\'
|
||||
|
||||
You can view it here:
|
||||
|
||||
$string['emailteachermail'] = '{$a->username} has completed feedback activity : \'{$a->feedback}\'
|
||||
|
||||
You can view it here:
|
||||
|
||||
{$a->url}';
|
||||
$string['emailteachermailhtml'] = '{$a->username} has completed feedback activity : <i>\'{$a->feedback}\'</i><br /><br />
|
||||
$string['emailteachermailhtml'] = '{$a->username} has completed feedback activity : <i>\'{$a->feedback}\'</i><br /><br />
|
||||
You can view it <a href="{$a->url}">here</a>.';
|
||||
$string['entries_saved'] = 'Your answers have been saved. Thank you.';
|
||||
$string['export_questions'] = 'Export questions';
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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/>.
|
||||
|
||||
/**
|
||||
* print the form to map courses for global feedbacks
|
||||
@ -29,11 +43,10 @@ if ($courseid !== false) {
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if(($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
// $SESSION->feedback->current_tab = 'mapcourse';
|
||||
$current_tab = 'mapcourse';
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
|
||||
@ -76,7 +89,7 @@ $PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
include('tabs.php');
|
||||
require('tabs.php');
|
||||
|
||||
echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'), 'generalbox boxaligncenter boxwidthwide');
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
@ -95,18 +108,22 @@ if (($courses = $DB->get_records_sql_menu($sql, $params)) && !empty($searchcours
|
||||
echo html_writer::select($courses, 'coursefilter', $coursefilter);
|
||||
echo '<input type="submit" value="'.get_string('mapcourse', 'feedback').'"/>';
|
||||
echo $OUTPUT->help_icon('mapcourses', 'feedback');
|
||||
echo '<input type="button" value="'.get_string('searchagain').'" onclick="document.location=\'mapcourse.php?id='.$id.'\'"/>';
|
||||
echo '<input type="button" '.
|
||||
'value="'.get_string('searchagain').'" '.
|
||||
'onclick="document.location=\'mapcourse.php?id='.$id.'\'"/>';
|
||||
|
||||
echo '<input type="hidden" name="searchcourse" value="'.$searchcourse.'"/>';
|
||||
echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'"/>';
|
||||
echo $OUTPUT->help_icon('searchcourses', 'feedback');
|
||||
} else {
|
||||
echo '<input type="text" name="searchcourse" value="'.$searchcourse.'"/> <input type="submit" value="'.get_string('searchcourses').'"/>';
|
||||
echo '<input type="text" name="searchcourse" value="'.$searchcourse.'"/> ';
|
||||
echo '<input type="submit" value="'.get_string('searchcourses').'"/>';
|
||||
echo $OUTPUT->help_icon('searchcourses', 'feedback');
|
||||
}
|
||||
|
||||
echo '</form>';
|
||||
|
||||
if($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) {
|
||||
if ($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) {
|
||||
$table = new flexible_table('coursemaps');
|
||||
$table->define_columns( array('course'));
|
||||
$table->define_headers( array(get_string('mappedcourses', 'feedback')));
|
||||
@ -117,9 +134,13 @@ if($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) {
|
||||
foreach ($coursemap as $cmap) {
|
||||
$cmapcontext = get_context_instance(CONTEXT_COURSE, $cmap->id);
|
||||
$cmapshortname = format_string($cmap->shortname, true, array('context' => $cmapcontext));
|
||||
$cmapfullname = format_string($cmap->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $cmap->courseid)));
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $cmap->courseid);
|
||||
$cmapfullname = format_string($cmap->fullname, true, array('context' => $coursecontext));
|
||||
$unmapurl->params(array('id'=>$id, 'cmapid'=>$cmap->id));
|
||||
$table->add_data(array('<a href="'.$unmapurl->out().'"><img src="'.$OUTPUT->pix_url('t/delete') . '" alt="Delete" /></a> ('.$cmapshortname.') '.$cmapfullname));
|
||||
$anker = '<a href="'.$unmapurl->out().'">';
|
||||
$anker .= '<img src="'.$OUTPUT->pix_url('t/delete').'" alt="Delete" />';
|
||||
$anker .= '</a>';
|
||||
$table->add_data(array($anker.' ('.$cmapshortname.') '.$cmapfullname));
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
@ -131,4 +152,3 @@ if($coursemap = feedback_get_courses_from_sitecourse_map($feedback->id)) {
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
@ -1,21 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* print the form to add or edit a feedback-instance
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* print the form to add or edit a feedback-instance
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
//It must be included from a Moodle page
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
require_once($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
|
||||
class mod_feedback_mod_form extends moodleform_mod {
|
||||
|
||||
function definition() {
|
||||
public function definition() {
|
||||
global $CFG, $DB;
|
||||
|
||||
$mform =& $this->_form;
|
||||
@ -33,16 +49,32 @@ class mod_feedback_mod_form extends moodleform_mod {
|
||||
$mform->addElement('header', 'timinghdr', get_string('timing', 'form'));
|
||||
|
||||
$enableopengroup = array();
|
||||
$enableopengroup[] =& $mform->createElement('checkbox', 'openenable', get_string('feedbackopen', 'feedback'));
|
||||
$enableopengroup[] =& $mform->createElement('checkbox',
|
||||
'openenable',
|
||||
get_string('feedbackopen', 'feedback'));
|
||||
|
||||
$enableopengroup[] =& $mform->createElement('date_time_selector', 'timeopen', '');
|
||||
$mform->addGroup($enableopengroup, 'enableopengroup', get_string('feedbackopen', 'feedback'), ' ', false);
|
||||
$mform->addGroup($enableopengroup,
|
||||
'enableopengroup',
|
||||
get_string('feedbackopen', 'feedback'),
|
||||
' ',
|
||||
false);
|
||||
|
||||
$mform->addHelpButton('enableopengroup', 'timeopen', 'feedback');
|
||||
$mform->disabledIf('enableopengroup', 'openenable', 'notchecked');
|
||||
|
||||
$enableclosegroup = array();
|
||||
$enableclosegroup[] =& $mform->createElement('checkbox', 'closeenable', get_string('feedbackclose', 'feedback'));
|
||||
$enableclosegroup[] =& $mform->createElement('checkbox',
|
||||
'closeenable',
|
||||
get_string('feedbackclose', 'feedback'));
|
||||
|
||||
$enableclosegroup[] =& $mform->createElement('date_time_selector', 'timeclose', '');
|
||||
$mform->addGroup($enableclosegroup, 'enableclosegroup', get_string('feedbackclose', 'feedback'), ' ', false);
|
||||
$mform->addGroup($enableclosegroup,
|
||||
'enableclosegroup',
|
||||
get_string('feedbackclose', 'feedback'),
|
||||
' ',
|
||||
false);
|
||||
|
||||
$mform->addHelpButton('enableclosegroup', 'timeclose', 'feedback');
|
||||
$mform->disabledIf('enableclosegroup', 'closeenable', 'notchecked');
|
||||
|
||||
@ -52,27 +84,48 @@ class mod_feedback_mod_form extends moodleform_mod {
|
||||
$options=array();
|
||||
$options[1] = get_string('anonymous', 'feedback');
|
||||
$options[2] = get_string('non_anonymous', 'feedback');
|
||||
$mform->addElement('select', 'anonymous', get_string('anonymous_edit', 'feedback'), $options);
|
||||
$mform->addElement('select',
|
||||
'anonymous',
|
||||
get_string('anonymous_edit', 'feedback'),
|
||||
$options);
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'publish_stats',
|
||||
get_string('show_analysepage_after_submit', 'feedback'));
|
||||
|
||||
$mform->addElement('selectyesno',
|
||||
'email_notification',
|
||||
get_string('email_notification', 'feedback'));
|
||||
|
||||
$mform->addElement('selectyesno', 'publish_stats', get_string('show_analysepage_after_submit', 'feedback'));
|
||||
$mform->addElement('selectyesno', 'email_notification', get_string('email_notification', 'feedback'));
|
||||
$mform->addHelpButton('email_notification', 'emailnotification', 'feedback');
|
||||
|
||||
// check if there is existing responses to this feedback
|
||||
if (is_numeric($this->_instance) AND $this->_instance and $feedback = $DB->get_record("feedback", array("id"=>$this->_instance))) {
|
||||
$completedFeedbackCount = feedback_get_completeds_group_count($feedback);
|
||||
if (is_numeric($this->_instance) AND
|
||||
$this->_instance AND
|
||||
$feedback = $DB->get_record("feedback", array("id"=>$this->_instance))) {
|
||||
|
||||
$completed_feedback_count = feedback_get_completeds_group_count($feedback);
|
||||
} else {
|
||||
$completedFeedbackCount = false;
|
||||
$completed_feedback_count = false;
|
||||
}
|
||||
|
||||
if($completedFeedbackCount) {
|
||||
if ($completed_feedback_count) {
|
||||
$multiple_submit_value = $feedback->multiple_submit ? get_string('yes') : get_string('no');
|
||||
$mform->addElement('text', 'multiple_submit_static', get_string('multiple_submit', 'feedback'), array('size'=>'4','disabled'=>'disabled', 'value'=>$multiple_submit_value));
|
||||
$mform->addElement('text',
|
||||
'multiple_submit_static',
|
||||
get_string('multiple_submit', 'feedback'),
|
||||
array('size'=>'4',
|
||||
'disabled'=>'disabled',
|
||||
'value'=>$multiple_submit_value));
|
||||
|
||||
$mform->addElement('hidden', 'multiple_submit', '');
|
||||
$mform->setType('', PARAM_INT);
|
||||
$mform->addHelpButton('multiple_submit_static', 'multiplesubmit', 'feedback');
|
||||
}else {
|
||||
$mform->addElement('selectyesno', 'multiple_submit', get_string('multiple_submit', 'feedback'));
|
||||
} else {
|
||||
$mform->addElement('selectyesno',
|
||||
'multiple_submit',
|
||||
get_string('multiple_submit', 'feedback'));
|
||||
|
||||
$mform->addHelpButton('multiple_submit', 'multiplesubmit', 'feedback');
|
||||
}
|
||||
$mform->addElement('selectyesno', 'autonumbering', get_string('autonumbering', 'feedback'));
|
||||
@ -81,10 +134,19 @@ class mod_feedback_mod_form extends moodleform_mod {
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', 'aftersubmithdr', get_string('after_submit', 'feedback'));
|
||||
|
||||
$mform->addElement('editor', 'page_after_submit', get_string("page_after_submit", "feedback"), null, null);
|
||||
$mform->addElement('editor',
|
||||
'page_after_submit',
|
||||
get_string("page_after_submit", "feedback"),
|
||||
null,
|
||||
null);
|
||||
|
||||
$mform->setType('page_after_submit', PARAM_RAW);
|
||||
|
||||
$mform->addElement('text', 'site_after_submit', get_string('url_for_continue_button', 'feedback'), array('size'=>'64','maxlength'=>'255'));
|
||||
$mform->addElement('text',
|
||||
'site_after_submit',
|
||||
get_string('url_for_continue_button', 'feedback'),
|
||||
array('size'=>'64', 'maxlength'=>'255'));
|
||||
|
||||
$mform->setType('site_after_submit', PARAM_TEXT);
|
||||
$mform->addHelpButton('site_after_submit', 'url_for_continue', 'feedback');
|
||||
//-------------------------------------------------------------------------------
|
||||
@ -94,7 +156,7 @@ class mod_feedback_mod_form extends moodleform_mod {
|
||||
$this->add_action_buttons();
|
||||
}
|
||||
|
||||
function data_preprocessing(&$default_values){
|
||||
public function data_preprocessing(&$default_values) {
|
||||
if (empty($default_values['timeopen'])) {
|
||||
$default_values['openenable'] = 0;
|
||||
} else {
|
||||
@ -111,41 +173,46 @@ class mod_feedback_mod_form extends moodleform_mod {
|
||||
if (!isset($default_values['page_after_submit'])) {
|
||||
$default_values['page_after_submit'] = '';
|
||||
}
|
||||
$default_values['page_after_submit'] = array('text'=>$default_values['page_after_submit'],'format'=>$default_values['page_after_submitformat']);
|
||||
$default_values['page_after_submit'] = array('text'=>$default_values['page_after_submit'],
|
||||
'format'=>$default_values['page_after_submitformat']);
|
||||
}
|
||||
|
||||
function get_data() {
|
||||
public function get_data() {
|
||||
$data = parent::get_data();
|
||||
if ($data) {
|
||||
$data->page_after_submitformat = $data->page_after_submit['format'];
|
||||
$data->page_after_submit = $data->page_after_submit['text'];
|
||||
|
||||
|
||||
// Turn off completion settings if the checkboxes aren't ticked
|
||||
$autocompletion = !empty($data->completion) && $data->completion==COMPLETION_TRACKING_AUTOMATIC;
|
||||
if(empty($data->completion) || !$autocompletion) {
|
||||
$autocompletion = !empty($data->completion) AND
|
||||
$data->completion==COMPLETION_TRACKING_AUTOMATIC;
|
||||
if (empty($data->completion) || !$autocompletion) {
|
||||
$data->completionsubmit=0;
|
||||
}
|
||||
if(empty($data->completionsubmit)) {
|
||||
if (empty($data->completionsubmit)) {
|
||||
$data->completionsubmit=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function validation($data, $files){
|
||||
public function validation($data, $files) {
|
||||
$errors = parent::validation($data, $files);
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function add_completion_rules() {
|
||||
public function add_completion_rules() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
$mform->addElement('checkbox', 'completionsubmit', '', get_string('completionsubmit', 'feedback'));
|
||||
$mform->addElement('checkbox',
|
||||
'completionsubmit',
|
||||
'',
|
||||
get_string('completionsubmit', 'feedback'));
|
||||
return array('completionsubmit');
|
||||
}
|
||||
|
||||
function completion_rule_enabled($data) {
|
||||
public function completion_rule_enabled($data) {
|
||||
return !empty($data['completionsubmit']);
|
||||
}
|
||||
}
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* print a printview of feedback-items
|
||||
@ -40,7 +54,8 @@ $PAGE->set_pagelayout('embedded');
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->navbar->add($strfeedbacks, new moodle_url('/mod/feedback/index.php', array('id'=>$course->id)));
|
||||
$feedback_url = new moodle_url('/mod/feedback/index.php', array('id'=>$course->id));
|
||||
$PAGE->navbar->add($strfeedbacks, $feedback_url);
|
||||
$PAGE->navbar->add(format_string($feedback->name));
|
||||
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
@ -56,42 +71,46 @@ echo $OUTPUT->heading(format_text($feedback->name));
|
||||
$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position');
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo $OUTPUT->continue_button('view.php?id='.$id);
|
||||
if(is_array($feedbackitems)){
|
||||
if (is_array($feedbackitems)) {
|
||||
$itemnr = 0;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
echo $OUTPUT->box_start('feedback_items printview');
|
||||
//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>';
|
||||
$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>';
|
||||
}
|
||||
//print the inserted items
|
||||
$itempos = 0;
|
||||
foreach($feedbackitems as $feedbackitem){
|
||||
foreach ($feedbackitems as $feedbackitem) {
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align);
|
||||
$itempos++;
|
||||
//Items without value only are labels
|
||||
if($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
if($feedbackitem->typ != 'pagebreak') {
|
||||
feedback_print_item_complete($feedbackitem, false, false);
|
||||
}else {
|
||||
echo $OUTPUT->box_start('feedback_pagebreak');
|
||||
echo '<hr class="feedback_pagebreak" />';
|
||||
$itempos++;
|
||||
//Items without value only are labels
|
||||
if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
if ($feedbackitem->typ != 'pagebreak') {
|
||||
feedback_print_item_complete($feedbackitem, false, false);
|
||||
} else {
|
||||
echo $OUTPUT->box_start('feedback_pagebreak');
|
||||
echo '<hr class="feedback_pagebreak" />';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}else{
|
||||
echo $OUTPUT->box(get_string('no_items_available_yet','feedback'),'generalbox boxaligncenter boxwidthwide');
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string('no_items_available_yet', 'feedback'),
|
||||
'generalbox boxaligncenter boxwidthwide');
|
||||
}
|
||||
echo $OUTPUT->continue_button('view.php?id='.$id);
|
||||
echo $OUTPUT->box_end();
|
||||
|
@ -1,10 +1,25 @@
|
||||
<?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/>.
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$options = array(0=>get_string('no'), 1=>get_string('yes'));
|
||||
$str = get_string('configallowfullanonymous', 'feedback');
|
||||
$settings->add(new admin_setting_configselect('feedback_allowfullanonymous', get_string('allowfullanonymous', 'feedback'),
|
||||
$str, 0, $options));
|
||||
}
|
||||
$settings->add(new admin_setting_configselect('feedback_allowfullanonymous',
|
||||
get_string('allowfullanonymous', 'feedback'),
|
||||
$str, 0, $options));
|
||||
}
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* print the single entries
|
||||
@ -27,7 +41,7 @@ $current_tab = $do_show;
|
||||
//get the objects
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
if($userid) {
|
||||
if ($userid) {
|
||||
$formdata->userid = intval($userid);
|
||||
}
|
||||
|
||||
@ -53,7 +67,7 @@ if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
if(($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
@ -62,10 +76,15 @@ require_capability('mod/feedback:viewreports', $context);
|
||||
////////////////////////////////////////////////////////
|
||||
//get the responses of given user
|
||||
////////////////////////////////////////////////////////
|
||||
if($do_show == 'showoneentry') {
|
||||
if ($do_show == 'showoneentry') {
|
||||
//get the feedbackitems
|
||||
$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position');
|
||||
$feedbackcompleted = $DB->get_record('feedback_completed', array('feedback'=>$feedback->id, 'userid'=>$userid, 'anonymous_response'=>FEEDBACK_ANONYMOUS_NO)); //arb
|
||||
|
||||
$params = array('feedback'=>$feedback->id,
|
||||
'userid'=>$userid,
|
||||
'anonymous_response'=>FEEDBACK_ANONYMOUS_NO);
|
||||
|
||||
$feedbackcompleted = $DB->get_record('feedback_completed', $params); //arb
|
||||
}
|
||||
|
||||
/// Print the page header
|
||||
@ -76,7 +95,7 @@ $PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
include('tabs.php');
|
||||
require('tabs.php');
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -86,9 +105,9 @@ include('tabs.php');
|
||||
////////////////////////////////////////////////////////
|
||||
/// Print the links to get responses and analysis
|
||||
////////////////////////////////////////////////////////
|
||||
if($do_show == 'showentries'){
|
||||
if ($do_show == 'showentries') {
|
||||
//print the link to analysis
|
||||
if(has_capability('mod/feedback:viewreports', $context)) {
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
//get the effective groupmode of this course and module
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
@ -96,7 +115,6 @@ if($do_show == 'showentries'){
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
// $groupselect = groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/feedback/show_entries.php?id=' . $cm->id.'&do_show=showentries', true);
|
||||
$groupselect = groups_print_activity_menu($cm, $url->out(), true);
|
||||
$mygroupid = groups_get_activity_group($cm);
|
||||
|
||||
@ -107,7 +125,7 @@ if($do_show == 'showentries'){
|
||||
$tablecolumns = array('userpic', 'fullname', 'c.timemodified');
|
||||
$tableheaders = array(get_string('userpic'), get_string('fullnameuser'), get_string('date'));
|
||||
|
||||
if(has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
if (has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
$tablecolumns[] = 'deleteentry';
|
||||
$tableheaders[] = '';
|
||||
}
|
||||
@ -130,9 +148,9 @@ if($do_show == 'showentries'){
|
||||
));
|
||||
$table->setup();
|
||||
|
||||
if($table->get_sql_sort()) {
|
||||
if ($table->get_sql_sort()) {
|
||||
$sort = $table->get_sql_sort();
|
||||
}else {
|
||||
} else {
|
||||
$sort = '';
|
||||
}
|
||||
|
||||
@ -142,79 +160,101 @@ if($do_show == 'showentries'){
|
||||
}
|
||||
|
||||
//get students in conjunction with groupmode
|
||||
if($groupmode > 0) {
|
||||
if($mygroupid > 0) {
|
||||
if ($groupmode > 0) {
|
||||
if ($mygroupid > 0) {
|
||||
$usedgroupid = $mygroupid;
|
||||
} else {
|
||||
$usedgroupid = false;
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
$usedgroupid = false;
|
||||
}
|
||||
|
||||
$matchcount = feedback_count_complete_users($cm, $usedgroupid);
|
||||
$table->initialbars(true);
|
||||
|
||||
if($showall) {
|
||||
if ($showall) {
|
||||
$startpage = false;
|
||||
$pagecount = false;
|
||||
}else {
|
||||
} else {
|
||||
$table->pagesize($perpage, $matchcount);
|
||||
$startpage = $table->get_page_start();
|
||||
$pagecount = $table->get_page_size();
|
||||
}
|
||||
|
||||
$students = feedback_get_complete_users($cm, $usedgroupid, $where, $params, $sort, $startpage, $pagecount);
|
||||
$str_analyse = get_string('analysis', 'feedback');
|
||||
$str_complete = get_string('completed_feedbacks', 'feedback');
|
||||
$str_course = get_string('course');
|
||||
|
||||
$completedFeedbackCount = feedback_get_completeds_group_count($feedback, $mygroupid);
|
||||
if($feedback->course == SITEID){
|
||||
$completed_fb_count = feedback_get_completeds_group_count($feedback, $mygroupid);
|
||||
if ($feedback->course == SITEID) {
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis_course.php', array('id'=>$id, 'courseid'=>$courseid));
|
||||
echo $OUTPUT->box_start('mdl-align');
|
||||
echo '<a href="'.$analysisurl->out().'">'.get_string('course').' '.get_string('analysis', 'feedback').' ('.get_string('completed_feedbacks', 'feedback').': '.intval($completedFeedbackCount).')</a>';
|
||||
echo '<a href="'.$analysisurl->out().'">';
|
||||
echo $str_course.' '.$str_analyse.' ('.$str_complete.': '.intval($completed_fb_count).')';
|
||||
echo '</a>';
|
||||
echo $OUTPUT->help_icon('viewcompleted', 'feedback');
|
||||
echo $OUTPUT->box_end();
|
||||
}else {
|
||||
} else {
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id, 'courseid'=>$courseid));
|
||||
echo $OUTPUT->box_start('mdl-align');
|
||||
echo '<a href="'.$analysisurl->out().'">'.get_string('analysis', 'feedback').' ('.get_string('completed_feedbacks', 'feedback').': '.intval($completedFeedbackCount).')</a>';
|
||||
echo '<a href="'.$analysisurl->out().'">';
|
||||
echo $str_analyse.' ('.$str_complete.': '.intval($completed_fb_count).')';
|
||||
echo '</a>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
}
|
||||
|
||||
//####### viewreports-start
|
||||
if(has_capability('mod/feedback:viewreports', $context)) {
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
//print the list of students
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo isset($groupselect) ? $groupselect : '';
|
||||
echo '<div class="clearer"></div>';
|
||||
echo $OUTPUT->box_start('mdl-align');
|
||||
// echo '<table><tr><td width="400">';
|
||||
if (!$students) {
|
||||
if($courseid != SITEID){
|
||||
if ($courseid != SITEID) {
|
||||
echo $OUTPUT->notification(get_string('noexistingparticipants', 'enrol'));
|
||||
}
|
||||
} else{
|
||||
} else {
|
||||
echo print_string('non_anonymous_entries', 'feedback');
|
||||
echo ' ('.count($students).')<hr />';
|
||||
|
||||
foreach ($students as $student){
|
||||
$completedCount = $DB->count_records('feedback_completed', array('userid'=>$student->id, 'feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_NO));
|
||||
if($completedCount > 0) {
|
||||
foreach ($students as $student) {
|
||||
$params = array('userid'=>$student->id,
|
||||
'feedback'=>$feedback->id,
|
||||
'anonymous_response'=>FEEDBACK_ANONYMOUS_NO);
|
||||
|
||||
$completed_count = $DB->count_records('feedback_completed', $params);
|
||||
if ($completed_count > 0) {
|
||||
|
||||
//userpicture and link to the profilepage
|
||||
$profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&course='.$course->id.'">'.fullname($student).'</a></strong>';
|
||||
$fullname_url = $CFG->wwwroot.'/user/view.php?id='.$student->id.'&course='.$course->id;
|
||||
$profilelink = '<strong><a href="'.$fullname_url.'">'.fullname($student).'</a></strong>';
|
||||
$data = array ($OUTPUT->user_picture($student, array('courseid'=>$course->id)), $profilelink);
|
||||
|
||||
//link to the entry of the user
|
||||
$feedbackcompleted = $DB->get_record('feedback_completed', array('feedback'=>$feedback->id, 'userid'=>$student->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_NO));
|
||||
$showentryurl = new moodle_url($url, array('userid'=>$student->id, 'do_show'=>'showoneentry'));
|
||||
$showentrylink = '<a href="'.$showentryurl->out().'">'.UserDate($feedbackcompleted->timemodified).'</a>';
|
||||
$params = array('feedback'=>$feedback->id,
|
||||
'userid'=>$student->id,
|
||||
'anonymous_response'=>FEEDBACK_ANONYMOUS_NO);
|
||||
|
||||
$feedbackcompleted = $DB->get_record('feedback_completed', $params);
|
||||
$showentryurl_params = array('userid'=>$student->id, 'do_show'=>'showoneentry');
|
||||
$showentryurl = new moodle_url($url, $showentryurl_params);
|
||||
$showentrylink = '<a href="'.$showentryurl->out().'">'.userdate($feedbackcompleted->timemodified).'</a>';
|
||||
$data[] = $showentrylink;
|
||||
|
||||
//link to delete the entry
|
||||
if(has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
$deleteentryurl = new moodle_url($CFG->wwwroot.'/mod/feedback/delete_completed.php', array('id'=>$cm->id, 'completedid'=>$feedbackcompleted->id, 'do_show'=>'showoneentry'));
|
||||
$deleteentrylink = '<a href="'.$deleteentryurl->out().'">'.get_string('delete_entry', 'feedback').'</a>';
|
||||
if (has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
$delete_url_params = array('id' => $cm->id,
|
||||
'completedid' => $feedbackcompleted->id,
|
||||
'do_show' => 'showoneentry');
|
||||
|
||||
$deleteentryurl = new moodle_url($CFG->wwwroot.'/mod/feedback/delete_completed.php', $delete_url_params);
|
||||
$deleteentrylink = '<a href="'.$deleteentryurl->out().'">'.
|
||||
get_string('delete_entry', 'feedback').
|
||||
'</a>';
|
||||
$data[] = $deleteentrylink;
|
||||
}
|
||||
$table->add_data($data);
|
||||
@ -226,28 +266,44 @@ if($do_show == 'showentries'){
|
||||
|
||||
if ($showall) {
|
||||
$allurl->param('showall', 0);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT)), array(), 'showall');
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT)),
|
||||
array(),
|
||||
'showall');
|
||||
|
||||
} else if ($matchcount > 0 && $perpage < $matchcount) {
|
||||
$allurl->param('showall', 1);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), array(), 'showall');
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)),
|
||||
array(),
|
||||
'showall');
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<hr />
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td align="left" colspan="2">
|
||||
<?php print_string('anonymous_entries', 'feedback');?> (<?php echo $DB->count_records('feedback_completed', array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES));?>)
|
||||
<?php
|
||||
$params = array('feedback' => $feedback->id,
|
||||
'anonymous_response' => FEEDBACK_ANONYMOUS_YES);
|
||||
|
||||
$feedback_completeds_count = $DB->count_records('feedback_completed', $params);
|
||||
print_string('anonymous_entries', 'feedback');
|
||||
echo ' ('.$feedback_completeds_count.')';
|
||||
?>
|
||||
</td>
|
||||
<td align="right">
|
||||
<?php
|
||||
$aurl = new moodle_url('show_entries_anonym.php', array('sesskey'=>sesskey(), 'userid'=>0, 'do_show'=>'showoneentry', 'id'=>$id));
|
||||
$url_params = array('sesskey'=>sesskey(),
|
||||
'userid'=>0,
|
||||
'do_show'=>'showoneentry',
|
||||
'id'=>$id);
|
||||
$aurl = new moodle_url('show_entries_anonym.php', $url_params);
|
||||
echo $OUTPUT->single_button($aurl, get_string('show_entries', 'feedback'));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
<?php
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
@ -256,38 +312,39 @@ if($do_show == 'showentries'){
|
||||
////////////////////////////////////////////////////////
|
||||
/// Print the responses of the given user
|
||||
////////////////////////////////////////////////////////
|
||||
if($do_show == 'showoneentry') {
|
||||
if ($do_show == 'showoneentry') {
|
||||
echo $OUTPUT->heading(format_text($feedback->name));
|
||||
|
||||
//print the items
|
||||
if(is_array($feedbackitems)){
|
||||
if (is_array($feedbackitems)) {
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
$usr = $DB->get_record('user', array('id'=>$userid));
|
||||
|
||||
if($feedbackcompleted) {
|
||||
echo $OUTPUT->heading(UserDate($feedbackcompleted->timemodified).' ('.fullname($usr).')', 3);
|
||||
if ($feedbackcompleted) {
|
||||
echo $OUTPUT->heading(userdate($feedbackcompleted->timemodified).' ('.fullname($usr).')', 3);
|
||||
} else {
|
||||
echo $OUTPUT->heading(get_string('not_completed_yet','feedback'), 3);
|
||||
echo $OUTPUT->heading(get_string('not_completed_yet', 'feedback'), 3);
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start('feedback_items');
|
||||
$itemnr = 0;
|
||||
foreach($feedbackitems as $feedbackitem){
|
||||
foreach ($feedbackitems as $feedbackitem) {
|
||||
//get the values
|
||||
$value = $DB->get_record('feedback_value', array('completed'=>$feedbackcompleted->id, 'item'=>$feedbackitem->id));
|
||||
$params = array('completed'=>$feedbackcompleted->id, 'item'=>$feedbackitem->id);
|
||||
$value = $DB->get_record('feedback_value', $params);
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align);
|
||||
if($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if($feedbackitem->typ != 'pagebreak') {
|
||||
if ($feedbackitem->typ != 'pagebreak') {
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
if(isset($value->value)) {
|
||||
if (isset($value->value)) {
|
||||
feedback_print_item_show_value($feedbackitem, $value->value);
|
||||
}else {
|
||||
} else {
|
||||
feedback_print_item_show_value($feedbackitem, false);
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* print the single-values of anonymous completeds
|
||||
@ -12,10 +26,7 @@ require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
// $SESSION->feedback->current_tab = 'showoneentry';
|
||||
|
||||
$id = required_param('id', PARAM_INT);
|
||||
// $userid = optional_param('userid', false, PARAM_INT);
|
||||
$showcompleted = optional_param('showcompleted', false, PARAM_INT);
|
||||
$do_show = optional_param('do_show', false, PARAM_ALPHA);
|
||||
$perpage = optional_param('perpage', FEEDBACK_DEFAULT_PAGE_COUNT, PARAM_INT); // how many per page
|
||||
@ -61,28 +72,34 @@ echo $OUTPUT->header();
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
include('tabs.php');
|
||||
require('tabs.php');
|
||||
|
||||
echo $OUTPUT->heading(format_text($feedback->name));
|
||||
|
||||
//print the list with anonymous completeds
|
||||
if(!$showcompleted) {
|
||||
if (!$showcompleted) {
|
||||
|
||||
//get the completeds
|
||||
// if a new anonymous record has not been assigned a random response number
|
||||
if ($feedbackcompleteds = $DB->get_records('feedback_completed', array('feedback'=>$feedback->id, 'random_response'=>0, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES), 'random_response')){ //arb
|
||||
$params = array('feedback'=>$feedback->id,
|
||||
'random_response'=>0,
|
||||
'anonymous_response'=>FEEDBACK_ANONYMOUS_YES);
|
||||
|
||||
if ($feedbackcompleteds = $DB->get_records('feedback_completed', $params, 'random_response')) {
|
||||
//then get all of the anonymous records and go through them
|
||||
$feedbackcompleteds = $DB->get_records('feedback_completed', array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES), 'id'); //arb
|
||||
$params = array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES);
|
||||
$feedbackcompleteds = $DB->get_records('feedback_completed', $params, 'id'); //arb
|
||||
shuffle($feedbackcompleteds);
|
||||
$num = 1;
|
||||
foreach($feedbackcompleteds as $compl){
|
||||
foreach ($feedbackcompleteds as $compl) {
|
||||
$compl->random_response = $num;
|
||||
$DB->update_record('feedback_completed', $compl);
|
||||
$num++;
|
||||
}
|
||||
}
|
||||
|
||||
$feedbackcompletedscount = $DB->count_records('feedback_completed', array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES));
|
||||
|
||||
$params = array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES);
|
||||
$feedbackcompletedscount = $DB->count_records('feedback_completed', $params);
|
||||
|
||||
// preparing the table for output
|
||||
$baseurl = new moodle_url('/mod/feedback/show_entries_anonym.php');
|
||||
@ -90,8 +107,8 @@ if(!$showcompleted) {
|
||||
|
||||
$tablecolumns = array('response', 'showresponse');
|
||||
$tableheaders = array('', '');
|
||||
|
||||
if(has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
|
||||
if (has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
$tablecolumns[] = 'deleteentry';
|
||||
$tableheaders[] = '';
|
||||
}
|
||||
@ -117,51 +134,57 @@ if(!$showcompleted) {
|
||||
$matchcount = $feedbackcompletedscount;
|
||||
$table->initialbars(true);
|
||||
|
||||
if($showall) {
|
||||
if ($showall) {
|
||||
$startpage = false;
|
||||
$pagecount = false;
|
||||
}else {
|
||||
} else {
|
||||
$table->pagesize($perpage, $matchcount);
|
||||
$startpage = $table->get_page_start();
|
||||
$pagecount = $table->get_page_size();
|
||||
}
|
||||
|
||||
|
||||
$feedbackcompleteds = $DB->get_records('feedback_completed',
|
||||
$feedbackcompleteds = $DB->get_records('feedback_completed',
|
||||
array('feedback'=>$feedback->id, 'anonymous_response'=>FEEDBACK_ANONYMOUS_YES),
|
||||
'random_response',
|
||||
'id,random_response',
|
||||
$startpage,
|
||||
$pagecount);
|
||||
|
||||
if(is_array($feedbackcompleteds)) {
|
||||
if (is_array($feedbackcompleteds)) {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo $OUTPUT->heading(get_string('anonymous_entries', 'feedback'), 3);
|
||||
foreach($feedbackcompleteds as $compl) {
|
||||
foreach ($feedbackcompleteds as $compl) {
|
||||
$data = array();
|
||||
|
||||
|
||||
$data[] = get_string('response_nr', 'feedback').': '. $compl->random_response;
|
||||
|
||||
|
||||
//link to the entry
|
||||
$showentryurl = new moodle_url($baseurl, array('showcompleted'=>$compl->id));
|
||||
$showentrylink = '<a href="'.$showentryurl->out().'">'.get_string('show_entry', 'feedback').'</a>';
|
||||
$data[] = $showentrylink;
|
||||
|
||||
|
||||
//link to delete the entry
|
||||
if(has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
$deleteentryurl = new moodle_url($CFG->wwwroot.'/mod/feedback/delete_completed.php', array('id'=>$cm->id, 'completedid'=>$compl->id, 'do_show'=>'', 'return'=>'entriesanonym'));
|
||||
if (has_capability('mod/feedback:deletesubmissions', $context)) {
|
||||
$delet_url_params = array('id'=>$cm->id,
|
||||
'completedid'=>$compl->id,
|
||||
'do_show'=>'',
|
||||
'return'=>'entriesanonym');
|
||||
|
||||
$deleteentryurl = new moodle_url($CFG->wwwroot.'/mod/feedback/delete_completed.php', $delet_url_params);
|
||||
$deleteentrylink = '<a href="'.$deleteentryurl->out().'">'.get_string('delete_entry', 'feedback').'</a>';
|
||||
$data[] = $deleteentrylink;
|
||||
}
|
||||
$table->add_data($data);
|
||||
}
|
||||
$table->print_html();
|
||||
|
||||
|
||||
$allurl = new moodle_url($baseurl);
|
||||
|
||||
|
||||
if ($showall) {
|
||||
$allurl->param('showall', 0);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT)), array(), 'showall');
|
||||
$str_showperpage = get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, $str_showperpage), array(), 'showall');
|
||||
} else if ($matchcount > 0 && $perpage < $matchcount) {
|
||||
$allurl->param('showall', 1);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), array(), 'showall');
|
||||
@ -170,44 +193,47 @@ if(!$showcompleted) {
|
||||
}
|
||||
}
|
||||
//print the items
|
||||
// if(isset($formdata->showanonym) && $formdata->showanonym == FEEDBACK_ANONYMOUS_YES) {
|
||||
if($showcompleted) {
|
||||
$continueurl = new moodle_url('/mod/feedback/show_entries_anonym.php', array('id'=>$id, 'do_show'=>''));
|
||||
if ($showcompleted) {
|
||||
$continueurl = new moodle_url('/mod/feedback/show_entries_anonym.php',
|
||||
array('id'=>$id, 'do_show'=>''));
|
||||
|
||||
echo $OUTPUT->continue_button($continueurl);
|
||||
|
||||
|
||||
//get the feedbackitems
|
||||
$feedbackitems = $DB->get_records('feedback_item', array('feedback'=>$feedback->id), 'position');
|
||||
$params = array('feedback'=>$feedback->id);
|
||||
$feedbackitems = $DB->get_records('feedback_item', $params, 'position');
|
||||
$feedbackcompleted = $DB->get_record('feedback_completed', array('id'=>$showcompleted));
|
||||
if(is_array($feedbackitems)){
|
||||
if (is_array($feedbackitems)) {
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
|
||||
if($feedbackcompleted) {
|
||||
|
||||
if ($feedbackcompleted) {
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo get_string('chosen_feedback_response', 'feedback');
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo get_string('response_nr', 'feedback').': '. $feedbackcompleted->random_response.' ('.get_string('anonymous', 'feedback').')';
|
||||
echo get_string('response_nr', 'feedback').': ';
|
||||
echo $feedbackcompleted->random_response.' ('.get_string('anonymous', 'feedback').')';
|
||||
echo $OUTPUT->box_end();
|
||||
} else {
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo get_string('not_completed_yet','feedback');
|
||||
echo get_string('not_completed_yet', 'feedback');
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
|
||||
echo $OUTPUT->box_start('feedback_items');
|
||||
// echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthnormal');
|
||||
$itemnr = 0;
|
||||
foreach($feedbackitems as $feedbackitem){
|
||||
foreach ($feedbackitems as $feedbackitem) {
|
||||
//get the values
|
||||
$value = $DB->get_record('feedback_value', array('completed'=>$feedbackcompleted->id, 'item'=>$feedbackitem->id));
|
||||
$params = array('completed'=>$feedbackcompleted->id, 'item'=>$feedbackitem->id);
|
||||
$value = $DB->get_record('feedback_value', $params);
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align);
|
||||
if($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
if ($feedbackitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if($feedbackitem->typ != 'pagebreak') {
|
||||
if ($feedbackitem->typ != 'pagebreak') {
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
$itemvalue = isset($value->value) ? $value->value : false;
|
||||
feedback_print_item_show_value($feedbackitem, $itemvalue);
|
||||
@ -215,7 +241,6 @@ if($showcompleted) {
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
// echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
}
|
||||
|
@ -1,279 +1,298 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* print the single entries
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
/**
|
||||
* print the single entries
|
||||
*
|
||||
* @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.'/tablelib.php');
|
||||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//get the params
|
||||
////////////////////////////////////////////////////////
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$subject = optional_param('subject','',PARAM_CLEANHTML);
|
||||
$message = optional_param('message','',PARAM_CLEANHTML);
|
||||
$format = optional_param('format',FORMAT_MOODLE,PARAM_INT);
|
||||
$messageuser = optional_param('messageuser', false, PARAM_INT);
|
||||
$action = optional_param('action', '',PARAM_ALPHA);
|
||||
$perpage = optional_param('perpage', FEEDBACK_DEFAULT_PAGE_COUNT, PARAM_INT); // how many per page
|
||||
$showall = optional_param('showall', false, PARAM_INT); // should we show all users
|
||||
// $SESSION->feedback->current_tab = $do_show;
|
||||
$current_tab = 'nonrespondents';
|
||||
////////////////////////////////////////////////////////
|
||||
//get the params
|
||||
////////////////////////////////////////////////////////
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$subject = optional_param('subject', '', PARAM_CLEANHTML);
|
||||
$message = optional_param('message', '', PARAM_CLEANHTML);
|
||||
$format = optional_param('format', FORMAT_MOODLE, PARAM_INT);
|
||||
$messageuser = optional_param('messageuser', false, PARAM_INT);
|
||||
$action = optional_param('action', '', PARAM_ALPHA);
|
||||
$perpage = optional_param('perpage', FEEDBACK_DEFAULT_PAGE_COUNT, PARAM_INT); // how many per page
|
||||
$showall = optional_param('showall', false, PARAM_INT); // should we show all users
|
||||
// $SESSION->feedback->current_tab = $do_show;
|
||||
$current_tab = 'nonrespondents';
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//get the objects
|
||||
////////////////////////////////////////////////////////
|
||||
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
////////////////////////////////////////////////////////
|
||||
//get the objects
|
||||
////////////////////////////////////////////////////////
|
||||
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 (! $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 (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
//this page only can be shown on nonanonymous feedbacks in courses
|
||||
//we should never reach this page
|
||||
if($feedback->anonymous != FEEDBACK_ANONYMOUS_NO OR $feedback->course == SITEID) {
|
||||
print_error('error');
|
||||
}
|
||||
//this page only can be shown on nonanonymous feedbacks in courses
|
||||
//we should never reach this page
|
||||
if ($feedback->anonymous != FEEDBACK_ANONYMOUS_NO OR $feedback->course == SITEID) {
|
||||
print_error('error');
|
||||
}
|
||||
|
||||
$url = new moodle_url('/mod/feedback/show_nonrespondents.php', array('id'=>$cm->id));
|
||||
$url = new moodle_url('/mod/feedback/show_nonrespondents.php', array('id'=>$cm->id));
|
||||
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_url($url);
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
//we need the coursecontext to allow sending of mass mails
|
||||
if (!$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
//we need the coursecontext to allow sending of mass mails
|
||||
if (!$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
require_login($course->id, true, $cm);
|
||||
require_login($course->id, true, $cm);
|
||||
|
||||
if(($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
|
||||
print_error('invalidsesskey');
|
||||
}
|
||||
|
||||
require_capability('mod/feedback:viewreports', $context);
|
||||
require_capability('mod/feedback:viewreports', $context);
|
||||
|
||||
if($action == 'sendmessage' AND has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
// require_once($CFG->dirroot.'/message/lib.php');
|
||||
$good = 1;
|
||||
if(is_array($messageuser)) {
|
||||
foreach ($messageuser as $userid) {
|
||||
$senduser = $DB->get_record('user', array('id'=>$userid));
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->name = 'message';
|
||||
$eventdata->component = 'mod_feedback';
|
||||
$eventdata->userfrom = $USER;
|
||||
$eventdata->userto = $senduser;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $message;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
$good = $good && message_send($eventdata);
|
||||
}
|
||||
if (!empty($good)) {
|
||||
$msg = $OUTPUT->heading(get_string('messagedselectedusers'));
|
||||
} else {
|
||||
$msg = $OUTPUT->heading(get_string('messagedselectedusersfailed'));
|
||||
}
|
||||
redirect($url, $msg, 4);
|
||||
exit;
|
||||
if ($action == 'sendmessage' AND has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$good = 1;
|
||||
if (is_array($messageuser)) {
|
||||
foreach ($messageuser as $userid) {
|
||||
$senduser = $DB->get_record('user', array('id'=>$userid));
|
||||
$eventdata = new stdClass();
|
||||
$eventdata->name = 'message';
|
||||
$eventdata->component = 'mod_feedback';
|
||||
$eventdata->userfrom = $USER;
|
||||
$eventdata->userto = $senduser;
|
||||
$eventdata->subject = $subject;
|
||||
$eventdata->fullmessage = $message;
|
||||
$eventdata->fullmessageformat = FORMAT_PLAIN;
|
||||
$eventdata->fullmessagehtml = '';
|
||||
$eventdata->smallmessage = '';
|
||||
$good = $good && message_send($eventdata);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//get the responses of given user
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->navbar->add(get_string('show_nonrespondents','feedback'));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
include('tabs.php');
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
/// Print the users with no responses
|
||||
////////////////////////////////////////////////////////
|
||||
//get the effective groupmode of this course and module
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
$groupselect = groups_print_activity_menu($cm, $url->out(), true);
|
||||
$mygroupid = groups_get_activity_group($cm);
|
||||
|
||||
// preparing the table for output
|
||||
$baseurl = new moodle_url('/mod/feedback/show_nonrespondents.php');
|
||||
$baseurl->params(array('id'=>$id, 'showall'=>$showall));
|
||||
|
||||
$tablecolumns = array('userpic', 'fullname', 'status');
|
||||
$tableheaders = array(get_string('userpic'), get_string('fullnameuser'), get_string('status'));
|
||||
|
||||
if(has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$tablecolumns[] = 'select';
|
||||
$tableheaders[] = get_string('select');
|
||||
}
|
||||
|
||||
$table = new flexible_table('feedback-shownonrespondents-'.$course->id);
|
||||
|
||||
$table->define_columns($tablecolumns);
|
||||
$table->define_headers($tableheaders);
|
||||
$table->define_baseurl($baseurl);
|
||||
|
||||
$table->sortable(true, 'lastname', SORT_DESC);
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'showentrytable');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
$table->set_control_variables(array(
|
||||
TABLE_VAR_SORT => 'ssort',
|
||||
TABLE_VAR_IFIRST => 'sifirst',
|
||||
TABLE_VAR_ILAST => 'silast',
|
||||
TABLE_VAR_PAGE => 'spage'
|
||||
));
|
||||
|
||||
$table->no_sorting('select');
|
||||
$table->no_sorting('status');
|
||||
|
||||
$table->setup();
|
||||
|
||||
if($table->get_sql_sort()) {
|
||||
$sort = $table->get_sql_sort();
|
||||
}else {
|
||||
$sort = '';
|
||||
}
|
||||
|
||||
//get students in conjunction with groupmode
|
||||
if($groupmode > 0) {
|
||||
if($mygroupid > 0) {
|
||||
$usedgroupid = $mygroupid;
|
||||
if (!empty($good)) {
|
||||
$msg = $OUTPUT->heading(get_string('messagedselectedusers'));
|
||||
} else {
|
||||
$usedgroupid = false;
|
||||
$msg = $OUTPUT->heading(get_string('messagedselectedusersfailed'));
|
||||
}
|
||||
}else {
|
||||
redirect($url, $msg, 4);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//get the responses of given user
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
$PAGE->navbar->add(get_string('show_nonrespondents', 'feedback'));
|
||||
$PAGE->set_heading(format_string($course->fullname));
|
||||
$PAGE->set_title(format_string($feedback->name));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
require('tabs.php');
|
||||
|
||||
/// Print the main part of the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
/// Print the users with no responses
|
||||
////////////////////////////////////////////////////////
|
||||
//get the effective groupmode of this course and module
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
$groupselect = groups_print_activity_menu($cm, $url->out(), true);
|
||||
$mygroupid = groups_get_activity_group($cm);
|
||||
|
||||
// preparing the table for output
|
||||
$baseurl = new moodle_url('/mod/feedback/show_nonrespondents.php');
|
||||
$baseurl->params(array('id'=>$id, 'showall'=>$showall));
|
||||
|
||||
$tablecolumns = array('userpic', 'fullname', 'status');
|
||||
$tableheaders = array(get_string('userpic'), get_string('fullnameuser'), get_string('status'));
|
||||
|
||||
if (has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$tablecolumns[] = 'select';
|
||||
$tableheaders[] = get_string('select');
|
||||
}
|
||||
|
||||
$table = new flexible_table('feedback-shownonrespondents-'.$course->id);
|
||||
|
||||
$table->define_columns($tablecolumns);
|
||||
$table->define_headers($tableheaders);
|
||||
$table->define_baseurl($baseurl);
|
||||
|
||||
$table->sortable(true, 'lastname', SORT_DESC);
|
||||
$table->set_attribute('cellspacing', '0');
|
||||
$table->set_attribute('id', 'showentrytable');
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
$table->set_control_variables(array(
|
||||
TABLE_VAR_SORT => 'ssort',
|
||||
TABLE_VAR_IFIRST => 'sifirst',
|
||||
TABLE_VAR_ILAST => 'silast',
|
||||
TABLE_VAR_PAGE => 'spage'
|
||||
));
|
||||
|
||||
$table->no_sorting('select');
|
||||
$table->no_sorting('status');
|
||||
|
||||
$table->setup();
|
||||
|
||||
if ($table->get_sql_sort()) {
|
||||
$sort = $table->get_sql_sort();
|
||||
} else {
|
||||
$sort = '';
|
||||
}
|
||||
|
||||
//get students in conjunction with groupmode
|
||||
if ($groupmode > 0) {
|
||||
if ($mygroupid > 0) {
|
||||
$usedgroupid = $mygroupid;
|
||||
} else {
|
||||
$usedgroupid = false;
|
||||
}
|
||||
} else {
|
||||
$usedgroupid = false;
|
||||
}
|
||||
|
||||
$matchcount = feedback_count_incomplete_users($cm, $usedgroupid);
|
||||
$table->initialbars(false);
|
||||
$matchcount = feedback_count_incomplete_users($cm, $usedgroupid);
|
||||
$table->initialbars(false);
|
||||
|
||||
if($showall) {
|
||||
$startpage = false;
|
||||
$pagecount = false;
|
||||
}else {
|
||||
$table->pagesize($perpage, $matchcount);
|
||||
$startpage = $table->get_page_start();
|
||||
$pagecount = $table->get_page_size();
|
||||
if ($showall) {
|
||||
$startpage = false;
|
||||
$pagecount = false;
|
||||
} else {
|
||||
$table->pagesize($perpage, $matchcount);
|
||||
$startpage = $table->get_page_start();
|
||||
$pagecount = $table->get_page_size();
|
||||
}
|
||||
|
||||
$students = feedback_get_incomplete_users($cm, $usedgroupid, $sort, $startpage, $pagecount);
|
||||
//####### viewreports-start
|
||||
//print the list of students
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo isset($groupselect) ? $groupselect : '';
|
||||
echo '<div class="clearer"></div>';
|
||||
echo $OUTPUT->box_start('mdl-align');
|
||||
|
||||
if (!$students) {
|
||||
echo $OUTPUT->notification(get_string('noexistingparticipants', 'enrol'));
|
||||
} else {
|
||||
echo print_string('non_respondents_students', 'feedback');
|
||||
echo ' ('.$matchcount.')<hr />';
|
||||
|
||||
if (has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
echo '<form class="mform" action="show_nonrespondents.php" method="post" id="feedback_sendmessageform">';
|
||||
}
|
||||
foreach ($students as $student) {
|
||||
$user = $DB->get_record('user', array('id'=>$student));
|
||||
//userpicture and link to the profilepage
|
||||
$profile_url = $CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id;
|
||||
$profilelink = '<strong><a href="'.$profile_url.'">'.fullname($user).'</a></strong>';
|
||||
$data = array ($OUTPUT->user_picture($user, array('courseid'=>$course->id)), $profilelink);
|
||||
|
||||
$students = feedback_get_incomplete_users($cm, $usedgroupid, $sort, $startpage, $pagecount);
|
||||
//####### viewreports-start
|
||||
//print the list of students
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo isset($groupselect) ? $groupselect : '';
|
||||
echo '<div class="clearer"></div>';
|
||||
echo $OUTPUT->box_start('mdl-align');
|
||||
// echo '<table><tr><td width="400">';
|
||||
if (!$students) {
|
||||
echo $OUTPUT->notification(get_string('noexistingparticipants', 'enrol'));
|
||||
} else{
|
||||
echo print_string('non_respondents_students', 'feedback');
|
||||
echo ' ('.$matchcount.')<hr />';
|
||||
|
||||
if(has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
echo '<form class="mform" action="show_nonrespondents.php" method="post" id="feedback_sendmessageform">';
|
||||
if ($DB->record_exists('feedback_completedtmp', array('userid'=>$user->id))) {
|
||||
$data[] = get_string('started', 'feedback');
|
||||
} else {
|
||||
$data[] = get_string('not_started', 'feedback');
|
||||
}
|
||||
foreach ($students as $student){
|
||||
$user = $DB->get_record('user', array('id'=>$student));
|
||||
//userpicture and link to the profilepage
|
||||
$profilelink = '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.fullname($user).'</a></strong>';
|
||||
$data = array ($OUTPUT->user_picture($user, array('courseid'=>$course->id)), $profilelink);
|
||||
|
||||
if($DB->record_exists('feedback_completedtmp', array('userid'=>$user->id))) {
|
||||
$data[] = get_string('started', 'feedback');
|
||||
}else {
|
||||
$data[] = get_string('not_started', 'feedback');
|
||||
}
|
||||
|
||||
//selections to bulk messaging
|
||||
if(has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$data[] = '<input type="checkbox" class="usercheckbox" name="messageuser[]" value="'.$user->id.'" />';
|
||||
}
|
||||
$table->add_data($data);
|
||||
}
|
||||
$table->print_html();
|
||||
|
||||
$allurl = new moodle_url($baseurl);
|
||||
|
||||
if ($showall) {
|
||||
$allurl->param('showall', 0);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT)), array(), 'showall');
|
||||
} else if ($matchcount > 0 && $perpage < $matchcount) {
|
||||
$allurl->param('showall', 1);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), array(), 'showall');
|
||||
}
|
||||
if(has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
echo '<div class="buttons"><br />';
|
||||
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> ';
|
||||
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> ';
|
||||
echo '</div>';
|
||||
echo '<fieldset class="clearfix">';
|
||||
echo '<legend class="ftoggler">'.get_string('send_message', 'feedback').'</legend>';
|
||||
echo '<div><label for="feedback_subject">'.get_string('subject', 'feedback').' </label><input type="text" id="feedback_subject" size="50" maxlength="255" name="subject" value="'.$subject.'" /></div>';
|
||||
print_textarea($usehtmleditor, 15, 25, 30, 10, "message", $message);
|
||||
if ($usehtmleditor) {
|
||||
print_string('formathtml');
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
|
||||
} else {
|
||||
choose_from_menu(format_text_menu(), "format", $format, "");
|
||||
}
|
||||
echo '<br /><div class="buttons">';
|
||||
echo '<input type="submit" name="send_message" value="'.get_string('send', 'feedback').'" />';
|
||||
echo '</div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="action" value="sendmessage" />';
|
||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
//include the needed js
|
||||
$module = array('name'=>'mod_feedback', 'fullpath'=>'/mod/feedback/feedback.js');
|
||||
$PAGE->requires->js_init_call('M.mod_feedback.init_sendmessage', null, false, $module);
|
||||
//selections to bulk messaging
|
||||
if (has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$data[] = '<input type="checkbox" class="usercheckbox" name="messageuser[]" value="'.$user->id.'" />';
|
||||
}
|
||||
$table->add_data($data);
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
$table->print_html();
|
||||
|
||||
/// Finish the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
$allurl = new moodle_url($baseurl);
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
if ($showall) {
|
||||
$allurl->param('showall', 0);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT)),
|
||||
array(), 'showall');
|
||||
|
||||
} else if ($matchcount > 0 && $perpage < $matchcount) {
|
||||
$allurl->param('showall', 1);
|
||||
echo $OUTPUT->container(html_writer::link($allurl, get_string('showall', '', $matchcount)), array(), 'showall');
|
||||
}
|
||||
if (has_capability('moodle/course:bulkmessaging', $coursecontext)) {
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
echo '<div class="buttons"><br />';
|
||||
echo '<input type="button" id="checkall" value="'.get_string('selectall').'" /> ';
|
||||
echo '<input type="button" id="checknone" value="'.get_string('deselectall').'" /> ';
|
||||
echo '</div>';
|
||||
echo '<fieldset class="clearfix">';
|
||||
echo '<legend class="ftoggler">'.get_string('send_message', 'feedback').'</legend>';
|
||||
echo '<div>';
|
||||
echo '<label for="feedback_subject">'.get_string('subject', 'feedback').' </label>';
|
||||
echo '<input type="text" id="feedback_subject" size="50" maxlength="255" name="subject" value="'.$subject.'" />';
|
||||
echo '</div>';
|
||||
print_textarea($usehtmleditor, 15, 25, 30, 10, "message", $message);
|
||||
if ($usehtmleditor) {
|
||||
print_string('formathtml');
|
||||
echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
|
||||
} else {
|
||||
choose_from_menu(format_text_menu(), "format", $format, "");
|
||||
}
|
||||
echo '<br /><div class="buttons">';
|
||||
echo '<input type="submit" name="send_message" value="'.get_string('send', 'feedback').'" />';
|
||||
echo '</div>';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<input type="hidden" name="action" value="sendmessage" />';
|
||||
echo '<input type="hidden" name="id" value="'.$id.'" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
//include the needed js
|
||||
$module = array('name'=>'mod_feedback', 'fullpath'=>'/mod/feedback/feedback.js');
|
||||
$PAGE->requires->js_init_call('M.mod_feedback.init_sendmessage', null, false, $module);
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Finish the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
|
@ -81,4 +81,4 @@ hr.feedback_pagebreak {
|
||||
color:#aaaaaa;
|
||||
background-color:#aaaaaa;
|
||||
border:0px;
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +1,95 @@
|
||||
<?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 the tabbed bar
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
* prints the tabbed bar
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
defined('MOODLE_INTERNAL') OR die('not allowed');
|
||||
|
||||
$tabs = array();
|
||||
$row = array();
|
||||
$inactive = array();
|
||||
$activated = array();
|
||||
$tabs = array();
|
||||
$row = array();
|
||||
$inactive = array();
|
||||
$activated = array();
|
||||
|
||||
//some pages deliver the cmid instead the id
|
||||
if(isset($cmid) AND intval($cmid) AND $cmid > 0) {
|
||||
$usedid = $cmid;
|
||||
}else {
|
||||
$usedid = $id;
|
||||
//some pages deliver the cmid instead the id
|
||||
if (isset($cmid) AND intval($cmid) AND $cmid > 0) {
|
||||
$usedid = $cmid;
|
||||
} else {
|
||||
$usedid = $id;
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $usedid)) {
|
||||
print_error('badcontext');
|
||||
}
|
||||
|
||||
|
||||
$courseid = optional_param('courseid', false, PARAM_INT);
|
||||
// $current_tab = $SESSION->feedback->current_tab;
|
||||
if (!isset($current_tab)) {
|
||||
$current_tab = '';
|
||||
}
|
||||
|
||||
$viewurl = new moodle_url('/mod/feedback/view.php', array('id'=>$usedid, 'do_show'=>'view'));
|
||||
$row[] = new tabobject('view', $viewurl->out(), get_string('overview', 'feedback'));
|
||||
|
||||
if (has_capability('mod/feedback:edititems', $context)) {
|
||||
$editurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$usedid, 'do_show'=>'edit'));
|
||||
$row[] = new tabobject('edit', $editurl->out(), get_string('edit_items', 'feedback'));
|
||||
|
||||
$templateurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$usedid, 'do_show'=>'templates'));
|
||||
$row[] = new tabobject('templates', $templateurl->out(), get_string('templates', 'feedback'));
|
||||
}
|
||||
|
||||
if (has_capability('mod/feedback:viewreports', $context)) {
|
||||
if ($feedback->course == SITEID) {
|
||||
$url_params = array('id'=>$usedid, 'courseid'=>$courseid, 'do_show'=>'analysis');
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis_course.php', $url_params);
|
||||
$row[] = new tabobject('analysis',
|
||||
$analysisurl->out(),
|
||||
get_string('analysis', 'feedback'));
|
||||
|
||||
} else {
|
||||
$url_params = array('id'=>$usedid, 'courseid'=>$courseid, 'do_show'=>'analysis');
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis.php', $url_params);
|
||||
$row[] = new tabobject('analysis',
|
||||
$analysisurl->out(),
|
||||
get_string('analysis', 'feedback'));
|
||||
}
|
||||
|
||||
if (!$context = get_context_instance(CONTEXT_MODULE, $usedid)) {
|
||||
print_error('badcontext');
|
||||
$url_params = array('id'=>$usedid, 'do_show'=>'showentries');
|
||||
$reporturl = new moodle_url('/mod/feedback/show_entries.php', $url_params);
|
||||
$row[] = new tabobject('showentries',
|
||||
$reporturl->out(),
|
||||
get_string('show_entries', 'feedback'));
|
||||
|
||||
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO AND $feedback->course != SITEID) {
|
||||
$nonrespondenturl = new moodle_url('/mod/feedback/show_nonrespondents.php', array('id'=>$usedid));
|
||||
$row[] = new tabobject('nonrespondents',
|
||||
$nonrespondenturl->out(),
|
||||
get_string('show_nonrespondents', 'feedback'));
|
||||
}
|
||||
}
|
||||
|
||||
if (count($row) > 1) {
|
||||
$tabs[] = $row;
|
||||
|
||||
$courseid = optional_param('courseid', false, PARAM_INT);
|
||||
// $current_tab = $SESSION->feedback->current_tab;
|
||||
if (!isset($current_tab)) {
|
||||
$current_tab = '';
|
||||
}
|
||||
|
||||
$viewurl = new moodle_url('/mod/feedback/view.php', array('id'=>$usedid, 'do_show'=>'view'));
|
||||
$row[] = new tabobject('view', $viewurl->out(), get_string('overview', 'feedback'));
|
||||
|
||||
if(has_capability('mod/feedback:edititems', $context)) {
|
||||
$editurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$usedid, 'do_show'=>'edit'));
|
||||
$row[] = new tabobject('edit', $editurl->out(), get_string('edit_items', 'feedback'));
|
||||
|
||||
$templateurl = new moodle_url('/mod/feedback/edit.php', array('id'=>$usedid, 'do_show'=>'templates'));
|
||||
$row[] = new tabobject('templates', $templateurl->out(), get_string('templates', 'feedback'));
|
||||
}
|
||||
|
||||
if(has_capability('mod/feedback:viewreports', $context)) {
|
||||
if($feedback->course == SITEID){
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis_course.php', array('id'=>$usedid, 'courseid'=>$courseid, 'do_show'=>'analysis'));
|
||||
$row[] = new tabobject('analysis', $analysisurl->out(), get_string('analysis', 'feedback'));
|
||||
}else {
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$usedid, 'courseid'=>$courseid, 'do_show'=>'analysis'));
|
||||
$row[] = new tabobject('analysis', $analysisurl->out(), get_string('analysis', 'feedback'));
|
||||
}
|
||||
|
||||
$reporturl = new moodle_url('/mod/feedback/show_entries.php', array('id'=>$usedid, 'do_show'=>'showentries'));
|
||||
$row[] = new tabobject('showentries', $reporturl->out(), get_string('show_entries', 'feedback'));
|
||||
|
||||
if($feedback->anonymous == FEEDBACK_ANONYMOUS_NO AND $feedback->course != SITEID) {
|
||||
$nonrespondenturl = new moodle_url('/mod/feedback/show_nonrespondents.php', array('id'=>$usedid));
|
||||
$row[] = new tabobject('nonrespondents', $nonrespondenturl->out(), get_string('show_nonrespondents', 'feedback'));
|
||||
}
|
||||
}
|
||||
|
||||
if(count($row) > 1) {
|
||||
$tabs[] = $row;
|
||||
|
||||
print_tabs($tabs, $current_tab, $inactive, $activated);
|
||||
}
|
||||
print_tabs($tabs, $current_tab, $inactive, $activated);
|
||||
}
|
||||
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* drops records from feedback_sitecourse_map
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* print the confirm dialog to use template and create new items from template
|
||||
@ -16,11 +30,11 @@ $id = required_param('id', PARAM_INT);
|
||||
$templateid = optional_param('templateid', false, PARAM_INT);
|
||||
$deleteolditems = optional_param('deleteolditems', 0, PARAM_INT);
|
||||
|
||||
if(!$templateid) {
|
||||
if (!$templateid) {
|
||||
redirect('edit.php?id='.$id);
|
||||
}
|
||||
|
||||
$url = new moodle_url('/mod/feedback/use_templ.php', array('id'=>$id,'templateid'=>$templateid));
|
||||
$url = new moodle_url('/mod/feedback/use_templ.php', array('id'=>$id, 'templateid'=>$templateid));
|
||||
if ($deleteolditems !== 0) {
|
||||
$url->param('deleteolditems', $deleteolditems);
|
||||
}
|
||||
@ -59,7 +73,7 @@ if ($mform->is_cancelled()) {
|
||||
redirect('edit.php?id='.$id.'&do_show=templates');
|
||||
}
|
||||
|
||||
if(isset($formdata->confirmadd) AND $formdata->confirmadd == 1){
|
||||
if (isset($formdata->confirmadd) AND $formdata->confirmadd == 1) {
|
||||
feedback_items_from_template($feedback, $templateid, $deleteolditems);
|
||||
redirect('edit.php?id=' . $id);
|
||||
}
|
||||
@ -88,37 +102,38 @@ $mform->display();
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
$templateitems = $DB->get_records('feedback_item', array('template'=>$templateid), 'position');
|
||||
if(is_array($templateitems)){
|
||||
if (is_array($templateitems)) {
|
||||
$templateitems = array_values($templateitems);
|
||||
}
|
||||
|
||||
if(is_array($templateitems)){
|
||||
if (is_array($templateitems)) {
|
||||
$itemnr = 0;
|
||||
$align = right_to_left() ? 'right' : 'left';
|
||||
echo $OUTPUT->box_start('feedback_items');
|
||||
foreach($templateitems as $templateitem){
|
||||
foreach ($templateitems as $templateitem) {
|
||||
echo $OUTPUT->box_start('feedback_item_box_'.$align);
|
||||
if($templateitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
if($templateitem->typ != 'pagebreak') {
|
||||
// echo '<div class="feedback_item_'.$align.'">';
|
||||
feedback_print_item_preview($templateitem);
|
||||
}else {
|
||||
echo $OUTPUT->box_start('feedback_pagebreak');
|
||||
echo get_string('pagebreak', 'feedback').'<hr class="feedback_pagebreak" />';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if ($templateitem->hasvalue == 1 AND $feedback->autonumbering) {
|
||||
$itemnr++;
|
||||
echo $OUTPUT->box_start('feedback_item_number_'.$align);
|
||||
echo $itemnr;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_start('box generalbox boxalign_'.$align);
|
||||
if ($templateitem->typ != 'pagebreak') {
|
||||
// echo '<div class="feedback_item_'.$align.'">';
|
||||
feedback_print_item_preview($templateitem);
|
||||
} else {
|
||||
echo $OUTPUT->box_start('feedback_pagebreak');
|
||||
echo get_string('pagebreak', 'feedback').'<hr class="feedback_pagebreak" />';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}else{
|
||||
echo $OUTPUT->box(get_string('no_items_available_at_this_template','feedback'),'generalbox boxaligncenter boxwidthwide');
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string('no_items_available_at_this_template', 'feedback'),
|
||||
'generalbox boxaligncenter boxwidthwide');
|
||||
}
|
||||
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -1,20 +1,35 @@
|
||||
<?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 the form to confirm use template
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
* prints the form to confirm use template
|
||||
*
|
||||
* @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';
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
|
||||
class mod_feedback_use_templ_form extends moodleform {
|
||||
function definition() {
|
||||
public function definition() {
|
||||
$mform =& $this->_form;
|
||||
|
||||
//headline
|
||||
|
@ -1,17 +1,31 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Code fragment to define the version of feedback
|
||||
* This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
* Code fragment to define the version of feedback
|
||||
* This fragment is called by moodle_needs_upgrading() and /admin/index.php
|
||||
*
|
||||
* @author Andreas Grabs
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
|
||||
* @package feedback
|
||||
*/
|
||||
|
||||
|
||||
$module->version = 2011100800; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2010080300; // Requires this Moodle version
|
||||
$feedback_version_intern = 1; //this version is used for restore older backups
|
||||
$module->cron = 0; // Period for cron to check this module (secs)
|
||||
|
||||
$module->version = 2011102800; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2011102700; // Requires this Moodle version
|
||||
$feedback_version_intern = 1; //this version is used for restore older backups
|
||||
$module->cron = 0; // Period for cron to check this module (secs)
|
||||
|
||||
|
@ -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/>.
|
||||
|
||||
/**
|
||||
* the first page to view the feedback
|
||||
@ -13,7 +27,6 @@ require_once("lib.php");
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$courseid = optional_param('courseid', false, PARAM_INT);
|
||||
|
||||
// $SESSION->feedback->current_tab = 'view';
|
||||
$current_tab = 'view';
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
|
||||
@ -34,11 +47,11 @@ if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
|
||||
|
||||
$feedback_complete_cap = false;
|
||||
|
||||
if(has_capability('mod/feedback:complete', $context)) {
|
||||
if (has_capability('mod/feedback:complete', $context)) {
|
||||
$feedback_complete_cap = true;
|
||||
}
|
||||
|
||||
if(isset($CFG->feedback_allowfullanonymous)
|
||||
if (isset($CFG->feedback_allowfullanonymous)
|
||||
AND $CFG->feedback_allowfullanonymous
|
||||
AND $course->id == SITEID
|
||||
AND (!$courseid OR $courseid == SITEID)
|
||||
@ -47,52 +60,53 @@ if(isset($CFG->feedback_allowfullanonymous)
|
||||
}
|
||||
|
||||
//check whether the feedback is located and! started from the mainsite
|
||||
if($course->id == SITEID AND !$courseid) {
|
||||
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))){
|
||||
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('invalidcoursemodule');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
|
||||
if($course->id == SITEID) {
|
||||
if ($feedback->anonymous != FEEDBACK_ANONYMOUS_YES) {
|
||||
if ($course->id == SITEID) {
|
||||
require_login($course->id, true);
|
||||
}else {
|
||||
} else {
|
||||
require_login($course->id, true, $cm);
|
||||
}
|
||||
} else {
|
||||
if($course->id == SITEID) {
|
||||
if ($course->id == SITEID) {
|
||||
require_course_login($course, true);
|
||||
}else {
|
||||
} else {
|
||||
require_course_login($course, 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($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
|
||||
add_to_log($course->id, 'feedback', 'view', 'view.php?id='.$cm->id, $feedback->id,$cm->id);
|
||||
if ($feedback->anonymous == FEEDBACK_ANONYMOUS_NO) {
|
||||
add_to_log($course->id, 'feedback', 'view', 'view.php?id='.$cm->id, $feedback->id, $cm->id);
|
||||
}
|
||||
|
||||
/// Print the page header
|
||||
$strfeedbacks = get_string("modulenameplural", "feedback");
|
||||
$strfeedback = get_string("modulename", "feedback");
|
||||
|
||||
if($course->id == SITEID) {
|
||||
if ($course->id == SITEID) {
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_cm($cm, $course); // set's up global $COURSE
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
@ -104,13 +118,14 @@ echo $OUTPUT->header();
|
||||
|
||||
//ishidden check.
|
||||
//feedback in courses
|
||||
if ((empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) AND $course->id != SITEID) {
|
||||
$cap_viewhiddenactivities = has_capability('moodle/course:viewhiddenactivities', $context);
|
||||
if ((empty($cm->visible) and !$cap_viewhiddenactivities) 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) {
|
||||
if ((empty($cm->visible) and !$cap_viewhiddenactivities) AND $courseid == SITEID) {
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
|
||||
@ -120,7 +135,7 @@ if ((empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// print the tabs
|
||||
include('tabs.php');
|
||||
require('tabs.php');
|
||||
|
||||
$previewimg = $OUTPUT->pix_icon('t/preview', get_string('preview'));
|
||||
$previewlnk = '<a href="'.$CFG->wwwroot.'/mod/feedback/print.php?id='.$id.'">'.$previewimg.'</a>';
|
||||
@ -128,36 +143,58 @@ $previewlnk = '<a href="'.$CFG->wwwroot.'/mod/feedback/print.php?id='.$id.'">'.$
|
||||
echo $OUTPUT->heading(format_text($feedback->name.' '.$previewlnk));
|
||||
|
||||
//show some infos to the feedback
|
||||
if(has_capability('mod/feedback:edititems', $context)) {
|
||||
if (has_capability('mod/feedback:edititems', $context)) {
|
||||
//get the groupid
|
||||
$groupselect = groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/feedback/view.php?id=' . $cm->id, true);
|
||||
$groupselect = groups_print_activity_menu($cm, $CFG->wwwroot.'/mod/feedback/view.php?id='.$cm->id, true);
|
||||
$mygroupid = groups_get_activity_group($cm);
|
||||
|
||||
echo $OUTPUT->box_start('boxaligncenter boxwidthwide');
|
||||
echo $groupselect.'<div class="clearer"> </div>';
|
||||
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid);
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo '<span class="feedback_info">'.get_string('completed_feedbacks', 'feedback').': </span><span class="feedback_info_value">'.$completedscount. '</span>';
|
||||
echo $OUTPUT->box_end();
|
||||
$itemscount = $DB->count_records('feedback_item', array('feedback'=>$feedback->id, 'hasvalue'=>1));
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo '<span class="feedback_info">'.get_string('questions', 'feedback').': </span><span class="feedback_info_value">' .$itemscount. '</span>';
|
||||
echo '<span class="feedback_info">';
|
||||
echo get_string('completed_feedbacks', 'feedback').': ';
|
||||
echo '</span>';
|
||||
echo '<span class="feedback_info_value">';
|
||||
echo $completedscount;
|
||||
echo '</span>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
if($feedback->timeopen) {
|
||||
$params = array('feedback'=>$feedback->id, 'hasvalue'=>1);
|
||||
$itemscount = $DB->count_records('feedback_item', $params);
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo '<span class="feedback_info">';
|
||||
echo get_string('questions', 'feedback').': ';
|
||||
echo '</span>';
|
||||
echo '<span class="feedback_info_value">';
|
||||
echo $itemscount;
|
||||
echo '</span>';
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
if ($feedback->timeopen) {
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo '<span class="feedback_info">'.get_string('feedbackopen', 'feedback').': </span><span class="feedback_info_value">' .UserDate($feedback->timeopen). '</span>';
|
||||
echo '<span class="feedback_info">';
|
||||
echo get_string('feedbackopen', 'feedback').': ';
|
||||
echo '</span>';
|
||||
echo '<span class="feedback_info_value">';
|
||||
echo userdate($feedback->timeopen);
|
||||
echo '</span>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
if($feedback->timeclose) {
|
||||
if ($feedback->timeclose) {
|
||||
echo $OUTPUT->box_start('feedback_info');
|
||||
echo '<span class="feedback_info">'.get_string('timeclose', 'feedback').': </span><span class="feedback_info_value">' .UserDate($feedback->timeclose). '</span>';
|
||||
echo '<span class="feedback_info">';
|
||||
echo get_string('timeclose', 'feedback').': ';
|
||||
echo '</span>';
|
||||
echo '<span class="feedback_info_value">';
|
||||
echo userdate($feedback->timeclose);
|
||||
echo '</span>';
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if(has_capability('mod/feedback:edititems', $context)) {
|
||||
if (has_capability('mod/feedback:edititems', $context)) {
|
||||
echo $OUTPUT->heading(get_string('description', 'feedback'), 4);
|
||||
}
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
@ -165,28 +202,33 @@ $options = (object)array('noclean'=>true);
|
||||
echo format_module_intro('feedback', $feedback, $cm->id);
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
if(has_capability('mod/feedback:edititems', $context)) {
|
||||
if (has_capability('mod/feedback:edititems', $context)) {
|
||||
echo $OUTPUT->heading(get_string("page_after_submit", "feedback"), 4);
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo format_text($feedback->page_after_submit, $feedback->page_after_submitformat, array('overflowdiv'=>true));
|
||||
echo format_text($feedback->page_after_submit,
|
||||
$feedback->page_after_submitformat,
|
||||
array('overflowdiv'=>true));
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
|
||||
if( (intval($feedback->publish_stats) == 1) AND
|
||||
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))) {
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id, 'courseid'=>$courseid));
|
||||
|
||||
$params = array('userid'=>$USER->id, 'feedback'=>$feedback->id);
|
||||
if ($multiple_count = $DB->count_records('feedback_tracking', $params)) {
|
||||
$url_params = array('id'=>$id, 'courseid'=>$courseid);
|
||||
$analysisurl = new moodle_url('/mod/feedback/analysis.php', $url_params);
|
||||
echo '<div class="mdl-align"><a href="'.$analysisurl->out().'">';
|
||||
echo get_string('completed_feedbacks', 'feedback').'</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
// echo '<p>';
|
||||
|
||||
//####### mapcourse-start
|
||||
if(has_capability('mod/feedback:mapcourse', $context)) {
|
||||
if($feedback->course == SITEID) {
|
||||
if (has_capability('mod/feedback:mapcourse', $context)) {
|
||||
if ($feedback->course == SITEID) {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
echo '<div class="mdl-align">';
|
||||
echo '<form action="mapcourse.php" method="get">';
|
||||
@ -205,13 +247,15 @@ if(has_capability('mod/feedback:mapcourse', $context)) {
|
||||
//####### mapcourse-end
|
||||
|
||||
//####### completed-start
|
||||
if($feedback_complete_cap) {
|
||||
if ($feedback_complete_cap) {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
|
||||
//check, whether the feedback is open (timeopen, timeclose)
|
||||
$checktime = time();
|
||||
if(($feedback->timeopen > $checktime) OR ($feedback->timeclose < $checktime AND $feedback->timeclose > 0)) {
|
||||
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);
|
||||
if (($feedback->timeopen > $checktime) OR
|
||||
($feedback->timeclose < $checktime AND $feedback->timeclose > 0)) {
|
||||
|
||||
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;
|
||||
@ -219,42 +263,45 @@ if($feedback_complete_cap) {
|
||||
|
||||
//check multiple Submit
|
||||
$feedback_can_submit = true;
|
||||
if($feedback->multiple_submit == 0 ) {
|
||||
if(feedback_is_already_submitted($feedback->id, $courseid)) {
|
||||
if ($feedback->multiple_submit == 0 ) {
|
||||
if (feedback_is_already_submitted($feedback->id, $courseid)) {
|
||||
$feedback_can_submit = false;
|
||||
}
|
||||
}
|
||||
if($feedback_can_submit) {
|
||||
if ($feedback_can_submit) {
|
||||
//if the user is not known so we cannot save the values temporarly
|
||||
if(!isloggedin() or isguestuser()) {
|
||||
if (!isloggedin() or isguestuser()) {
|
||||
$completefile = 'complete_guest.php';
|
||||
$guestid = sesskey();
|
||||
}else {
|
||||
} else {
|
||||
$completefile = 'complete.php';
|
||||
$guestid = false;
|
||||
}
|
||||
$completeurl = new moodle_url('/mod/feedback/'.$completefile, array('id'=>$id, 'courseid'=>$courseid, 'gopage'=>0));
|
||||
$url_params = array('id'=>$id, 'courseid'=>$courseid, 'gopage'=>0);
|
||||
$completeurl = new moodle_url('/mod/feedback/'.$completefile, $url_params);
|
||||
|
||||
if($feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid, $guestid)) {
|
||||
if($startpage = feedback_get_page_to_continue($feedback->id, $courseid, $guestid)) {
|
||||
$feedbackcompletedtmp = feedback_get_current_completed($feedback->id, true, $courseid, $guestid);
|
||||
if ($feedbackcompletedtmp) {
|
||||
if ($startpage = feedback_get_page_to_continue($feedback->id, $courseid, $guestid)) {
|
||||
$completeurl->param('gopage', $startpage);
|
||||
}
|
||||
echo '<a href="'.$completeurl->out().'">'.get_string('continue_the_form', 'feedback').'</a>';
|
||||
}else {
|
||||
} else {
|
||||
echo '<a href="'.$completeurl->out().'">'.get_string('complete_the_form', 'feedback').'</a>';
|
||||
}
|
||||
}else {
|
||||
echo '<h2><font color="red">'.get_string('this_feedback_is_already_submitted', 'feedback').'</font></h2>';
|
||||
if($courseid) {
|
||||
} else {
|
||||
echo '<h2><font color="red">';
|
||||
echo get_string('this_feedback_is_already_submitted', 'feedback');
|
||||
echo '</font></h2>';
|
||||
if ($courseid) {
|
||||
echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$courseid);
|
||||
}else {
|
||||
} else {
|
||||
echo $OUTPUT->continue_button($CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
}
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
//####### completed-end
|
||||
// echo "</p>";
|
||||
|
||||
/// Finish the page
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user