MDL-29804 - Clean up Feedback modules coding style
This commit is contained in:
+106
-59
@@ -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
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user