|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00025 require_once("../../config.php"); 00026 require_once("lib.php"); 00027 00028 $current_tab = 'analysis'; 00029 00030 $id = required_param('id', PARAM_INT); //the POST dominated the GET 00031 $courseid = optional_param('courseid', false, PARAM_INT); 00032 00033 $url = new moodle_url('/mod/feedback/analysis.php', array('id'=>$id)); 00034 if ($courseid !== false) { 00035 $url->param('courseid', $courseid); 00036 } 00037 $PAGE->set_url($url); 00038 00039 if (! $cm = get_coursemodule_from_id('feedback', $id)) { 00040 print_error('invalidcoursemodule'); 00041 } 00042 00043 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 00044 print_error('coursemisconf'); 00045 } 00046 00047 if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) { 00048 print_error('invalidcoursemodule'); 00049 } 00050 00051 if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) { 00052 print_error('badcontext'); 00053 } 00054 00055 if ($course->id == SITEID) { 00056 require_login($course->id, true); 00057 } else { 00058 require_login($course->id, true, $cm); 00059 } 00060 00061 //check whether the given courseid exists 00062 if ($courseid AND $courseid != SITEID) { 00063 if ($course2 = $DB->get_record('course', array('id'=>$courseid))) { 00064 require_course_login($course2); //this overwrites the object $course :-( 00065 $course = $DB->get_record("course", array("id"=>$cm->course)); // the workaround 00066 } else { 00067 print_error('invalidcourseid'); 00068 } 00069 } 00070 00071 if ( !( ((intval($feedback->publish_stats) == 1) AND 00072 has_capability('mod/feedback:viewanalysepage', $context)) OR 00073 has_capability('mod/feedback:viewreports', $context))) { 00074 print_error('error'); 00075 } 00076 00078 $strfeedbacks = get_string("modulenameplural", "feedback"); 00079 $strfeedback = get_string("modulename", "feedback"); 00080 00081 $PAGE->navbar->add(get_string('analysis', 'feedback')); 00082 $PAGE->set_heading(format_string($course->fullname)); 00083 $PAGE->set_title(format_string($feedback->name)); 00084 echo $OUTPUT->header(); 00085 00087 require('tabs.php'); 00088 00089 00090 //print analysed items 00091 echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); 00092 00093 //get the groupid 00094 $myurl = $CFG->wwwroot.'/mod/feedback/analysis.php?id='.$cm->id.'&do_show=analysis'; 00095 $groupselect = groups_print_activity_menu($cm, $myurl, true); 00096 $mygroupid = groups_get_activity_group($cm); 00097 00098 if ( has_capability('mod/feedback:viewreports', $context) ) { 00099 00100 echo isset($groupselect) ? $groupselect : ''; 00101 echo '<div class="clearer"></div>'; 00102 00103 //button "export to excel" 00104 echo $OUTPUT->container_start('form-buttons'); 00105 $aurl = new moodle_url('analysis_to_excel.php', array('sesskey'=>sesskey(), 'id'=>$id)); 00106 echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback')); 00107 echo $OUTPUT->container_end(); 00108 } 00109 00110 //get completed feedbacks 00111 $completedscount = feedback_get_completeds_group_count($feedback, $mygroupid); 00112 00113 //show the group, if available 00114 if ($mygroupid and $group = $DB->get_record('groups', array('id'=>$mygroupid))) { 00115 echo '<b>'.get_string('group').': '.$group->name. '</b><br />'; 00116 } 00117 //show the count 00118 echo '<b>'.get_string('completed_feedbacks', 'feedback').': '.$completedscount. '</b><br />'; 00119 00120 // get the items of the feedback 00121 $items = $DB->get_records('feedback_item', 00122 array('feedback'=>$feedback->id, 'hasvalue'=>1), 00123 'position'); 00124 //show the count 00125 if (is_array($items)) { 00126 echo '<b>'.get_string('questions', 'feedback').': ' .count($items). ' </b><hr />'; 00127 } else { 00128 $items=array(); 00129 } 00130 $check_anonymously = true; 00131 if ($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) { 00132 if ($completedscount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) { 00133 $check_anonymously = false; 00134 } 00135 } 00136 00137 echo '<div><table width="80%" cellpadding="10"><tr><td>'; 00138 if ($check_anonymously) { 00139 $itemnr = 0; 00140 //print the items in an analysed form 00141 foreach ($items as $item) { 00142 if ($item->hasvalue == 0) { 00143 continue; 00144 } 00145 echo '<table width="100%" class="generalbox">'; 00146 00147 //get the class of item-typ 00148 $itemobj = feedback_get_item_class($item->typ); 00149 00150 $itemnr++; 00151 if ($feedback->autonumbering) { 00152 $printnr = $itemnr.'.'; 00153 } else { 00154 $printnr = ''; 00155 } 00156 $itemobj->print_analysed($item, $printnr, $mygroupid); 00157 echo '</table>'; 00158 } 00159 } else { 00160 echo $OUTPUT->heading_with_help(get_string('insufficient_responses_for_this_group', 'feedback'), 00161 'insufficient_responses', 00162 'feedback'); 00163 } 00164 echo '</td></tr></table></div>'; 00165 echo $OUTPUT->box_end(); 00166 00167 echo $OUTPUT->footer(); 00168