2009-09-24 06:11:39 +00:00
< ? php
2008-04-23 09:33:54 +00:00
/**
2009-09-24 06:11:39 +00:00
* print the single entries
*
* @ author Andreas Grabs
* @ license http :// www . gnu . org / copyleft / gpl . html GNU Public License
* @ package feedback
*/
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
require_once ( " ../../config.php " );
require_once ( " lib.php " );
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
////////////////////////////////////////////////////////
//get the params
////////////////////////////////////////////////////////
$id = required_param ( 'id' , PARAM_INT );
$userid = optional_param ( 'userid' , false , PARAM_INT );
$do_show = required_param ( 'do_show' , PARAM_ALPHA );
// $SESSION->feedback->current_tab = $do_show;
$current_tab = $do_show ;
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
////////////////////////////////////////////////////////
//get the objects
////////////////////////////////////////////////////////
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
if ( $userid ) {
$formdata -> userid = intval ( $userid );
}
2008-04-23 09:33:54 +00:00
2010-03-28 15:29:49 +00:00
if ( ! $cm = get_coursemodule_from_id ( 'feedback' , $id )) {
print_error ( 'invalidcoursemodule' );
}
2009-08-10 04:59:26 +00:00
2010-03-28 15:29:49 +00:00
if ( ! $course = $DB -> get_record ( " course " , array ( " id " => $cm -> course ))) {
print_error ( 'coursemisconf' );
}
2009-08-10 04:59:26 +00:00
2010-03-28 15:29:49 +00:00
if ( ! $feedback = $DB -> get_record ( " feedback " , array ( " id " => $cm -> instance ))) {
print_error ( 'invalidcoursemodule' );
2009-09-24 06:11:39 +00:00
}
2009-08-10 04:59:26 +00:00
2010-03-28 15:29:49 +00:00
$url = new moodle_url ( '/mod/feedback/show_entries.php' , array ( 'id' => $cm -> id , 'do_show' => $do_show ));
$PAGE -> set_url ( $url );
2009-09-11 02:04:38 +00:00
2010-04-02 11:34:28 +00:00
if ( ! $context = get_context_instance ( CONTEXT_MODULE , $cm -> id )) {
print_error ( 'badcontext' );
}
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
require_login ( $course -> id , true , $cm );
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
if (( $formdata = data_submitted ()) AND ! confirm_sesskey ()) {
print_error ( 'invalidsesskey' );
}
2009-08-10 04:59:26 +00:00
2010-04-02 20:38:17 +00:00
require_capability ( 'mod/feedback:viewreports' , $context );
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
////////////////////////////////////////////////////////
//get the responses of given user
////////////////////////////////////////////////////////
if ( $do_show == 'showoneentry' ) {
//get the feedbackitems
$feedbackitems = $DB -> get_records ( 'feedback_item' , array ( 'feedback' => $feedback -> id ), 'position' );
2010-04-30 10:36:23 +00:00
$feedbackcompleted = $DB -> get_record ( 'feedback_completed' , array ( 'feedback' => $feedback -> id , 'userid' => $userid , 'anonymous_response' => FEEDBACK_ANONYMOUS_NO )); //arb
2009-09-24 06:11:39 +00:00
}
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
/// Print the page header
$strfeedbacks = get_string ( " modulenameplural " , " feedback " );
$strfeedback = get_string ( " modulename " , " feedback " );
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
$PAGE -> navbar -> add ( get_string ( 'show_entries' , 'feedback' ));
$PAGE -> set_title ( format_string ( $feedback -> name ));
echo $OUTPUT -> header ();
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
include ( 'tabs.php' );
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
/// Print the main part of the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
////////////////////////////////////////////////////////
/// Print the links to get responses and analysis
////////////////////////////////////////////////////////
if ( $do_show == 'showentries' ){
//print the link to analysis
2010-04-02 11:34:28 +00:00
if ( has_capability ( 'mod/feedback:viewreports' , $context )) {
2009-09-24 06:11:39 +00:00
//get the effective groupmode of this course and module
if ( isset ( $cm -> groupmode ) && empty ( $course -> groupmodeforce )) {
$groupmode = $cm -> groupmode ;
} else {
$groupmode = $course -> groupmode ;
}
2010-03-28 15:29:49 +00:00
// $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 );
2009-09-24 06:11:39 +00:00
$mygroupid = groups_get_activity_group ( $cm );
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
//get students in conjunction with groupmode
if ( $groupmode > 0 ) {
2009-06-13 14:17:00 +00:00
2009-09-24 06:11:39 +00:00
if ( $mygroupid > 0 ) {
$students = feedback_get_complete_users ( $cm , $mygroupid );
} else {
2009-05-25 19:48:33 +00:00
$students = feedback_get_complete_users ( $cm );
2008-04-23 09:33:54 +00:00
}
2009-09-24 06:11:39 +00:00
} else {
$students = feedback_get_complete_users ( $cm );
}
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
$completedFeedbackCount = feedback_get_completeds_group_count ( $feedback , $mygroupid );
if ( $feedback -> course == SITEID ){
2010-03-28 15:29:49 +00:00
$analysisurl = new moodle_url ( '/mod/feedback/analysis_course.php' , array ( 'id' => $id , 'courseid' => $courseid ));
2010-05-02 12:00:56 +00:00
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>' ;
2010-04-18 19:21:54 +00:00
echo $OUTPUT -> help_icon ( 'viewcompleted' , 'feedback' );
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_end ();
2009-09-24 06:11:39 +00:00
} else {
2010-03-28 15:29:49 +00:00
$analysisurl = new moodle_url ( '/mod/feedback/analysis.php' , array ( 'id' => $id , 'courseid' => $courseid ));
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_start ( 'mdl-align' );
echo '<a href="' . $analysisurl -> out () . '">' . get_string ( 'analysis' , 'feedback' ) . ' (' . get_string ( 'completed_feedbacks' , 'feedback' ) . ': ' . intval ( $completedFeedbackCount ) . ')</a>' ;
echo $OUTPUT -> box_end ();
2008-04-23 09:33:54 +00:00
}
2009-09-24 06:11:39 +00:00
}
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
//####### viewreports-start
2010-04-02 11:34:28 +00:00
if ( has_capability ( 'mod/feedback:viewreports' , $context )) {
2009-09-24 06:11:39 +00:00
//print the list of students
echo $OUTPUT -> box_start ( 'generalbox boxaligncenter boxwidthwide' );
echo isset ( $groupselect ) ? $groupselect : '' ;
echo '<div class="clearer"></div>' ;
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_start ( 'mdl-align' );
echo '<table><tr><td width="400">' ;
2009-09-24 06:11:39 +00:00
if ( ! $students ) {
if ( $courseid != SITEID ){
echo $OUTPUT -> notification ( get_string ( 'noexistingstudents' ));
}
} else {
echo print_string ( 'non_anonymous_entries' , 'feedback' );
echo ' (' . count ( $students ) . ')<hr />' ;
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
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 ) {
// Are we assuming that there is only one response per user? Should westep through a feedbackcompleteds? I added the addition anonymous check to the select so that only non-anonymous submissions are retrieved.
$feedbackcompleted = $DB -> get_record ( 'feedback_completed' , array ( 'feedback' => $feedback -> id , ' userid' => $student -> id , 'anonymous_response' => FEEDBACK_ANONYMOUS_NO ));
?>
< table width = " 100% " >
< tr >
< td align = " left " >
2009-12-27 19:47:21 +00:00
< ? php echo $OUTPUT -> user_picture ( $student , array ( 'courseid' => $course -> id )); ?>
2009-09-24 06:11:39 +00:00
</ td >
< td align = " left " >
< ? php echo fullname ( $student ); ?>
</ td >
< td align = " right " >
< ? php
2010-03-28 15:29:49 +00:00
$aurl = new moodle_url ( $url , array ( 'sesskey' => sesskey (), 'userid' => $student -> id , 'do_show' => 'showoneentry' ));
2010-01-03 15:46:14 +00:00
echo $OUTPUT -> single_button ( $aurl , get_string ( 'show_entries' , 'feedback' ));
2009-09-24 06:11:39 +00:00
?>
</ td >
< ? php
2010-04-02 11:34:28 +00:00
if ( has_capability ( 'mod/feedback:deletesubmissions' , $context )) {
2009-09-24 06:11:39 +00:00
?>
< td align = " right " >
< ? php
2010-04-30 10:36:23 +00:00
$aurl = new moodle_url ( $CFG -> wwwroot . '/mod/feedback/delete_completed.php' , array ( 'sesskey' => sesskey (), 'id' => $cm -> id , 'completedid' => $feedbackcompleted -> id , 'do_show' => 'showoneentry' ));
2010-01-03 15:46:14 +00:00
echo $OUTPUT -> single_button ( $aurl , get_string ( 'delete_entry' , 'feedback' ));
2009-09-24 06:11:39 +00:00
?>
</ td >
< ? php
2008-04-23 09:33:54 +00:00
}
2009-09-24 06:11:39 +00:00
?>
</ tr >
</ table >
< ? php
2008-04-23 09:33:54 +00:00
}
}
}
2009-09-24 06:11:39 +00:00
?>
< 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));?>)
</ td >
< td align = " right " >
< ? php
2010-01-03 15:46:14 +00:00
$aurl = new moodle_url ( 'show_entries_anonym.php' , array ( 'sesskey' => sesskey (), 'userid' => 0 , 'do_show' => 'showoneentry' , 'id' => $id ));
echo $OUTPUT -> single_button ( $aurl , get_string ( 'show_entries' , 'feedback' ));
2009-09-24 06:11:39 +00:00
?>
</ td >
</ tr >
</ table >
< ? php
2010-05-02 12:00:56 +00:00
echo '</td></tr></table>' ;
echo $OUTPUT -> box_end ();
2009-09-24 06:11:39 +00:00
echo $OUTPUT -> box_end ();
2008-04-23 09:33:54 +00:00
}
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
}
////////////////////////////////////////////////////////
/// Print the responses of the given user
////////////////////////////////////////////////////////
if ( $do_show == 'showoneentry' ) {
echo $OUTPUT -> heading ( format_text ( $feedback -> name ));
//print the items
if ( is_array ( $feedbackitems )){
2010-05-02 12:00:56 +00:00
$align = right_to_left () ? 'right' : 'left' ;
2010-04-30 10:36:23 +00:00
$usr = $DB -> get_record ( 'user' , array ( 'id' => $userid ));
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_start ( 'feedback_info' );
2009-09-24 06:11:39 +00:00
if ( $feedbackcompleted ) {
2010-05-02 12:00:56 +00:00
echo UserDate ( $feedbackcompleted -> timemodified ) . '<br />(' . fullname ( $usr ) . ')' ;
2009-09-24 06:11:39 +00:00
} else {
2010-05-02 12:00:56 +00:00
echo get_string ( 'not_completed_yet' , 'feedback' );
2009-09-24 06:11:39 +00:00
}
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_end ();
echo $OUTPUT -> box_start ( 'feedback_items' );
2009-09-24 06:11:39 +00:00
$itemnr = 0 ;
foreach ( $feedbackitems as $feedbackitem ){
//get the values
$value = $DB -> get_record ( 'feedback_value' , array ( 'completed' => $feedbackcompleted -> id , 'item' => $feedbackitem -> id ));
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_start ( 'feedback_item_box_' . $align );
2009-09-24 06:11:39 +00:00
if ( $feedbackitem -> hasvalue == 1 AND $feedback -> autonumbering ) {
$itemnr ++ ;
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_start ( 'feedback_item_number_' . $align );
echo $itemnr ;
echo $OUTPUT -> box_end ();
2008-04-23 09:33:54 +00:00
}
2009-08-10 04:59:26 +00:00
2009-09-24 06:11:39 +00:00
if ( $feedbackitem -> typ != 'pagebreak' ) {
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_start ( 'box generalbox boxalign_' . $align );
2009-09-24 06:11:39 +00:00
if ( isset ( $value -> value )) {
2010-04-21 11:48:49 +00:00
feedback_print_item_show_value ( $feedbackitem , $value -> value );
2008-04-23 09:33:54 +00:00
} else {
2010-04-21 11:48:49 +00:00
feedback_print_item_show_value ( $feedbackitem , false );
2008-04-23 09:33:54 +00:00
}
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_end ();
2008-04-23 09:33:54 +00:00
}
2010-05-02 12:00:56 +00:00
echo $OUTPUT -> box_end ();
2008-04-23 09:33:54 +00:00
}
2009-09-24 06:11:39 +00:00
echo $OUTPUT -> box_end ();
2008-04-23 09:33:54 +00:00
}
2010-03-28 15:29:49 +00:00
echo $OUTPUT -> continue_button ( new moodle_url ( $url , array ( 'do_show' => 'showentries' )));
2009-09-24 06:11:39 +00:00
}
/// Finish the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
echo $OUTPUT -> footer ();
2008-04-23 09:33:54 +00:00
2009-09-24 06:11:39 +00:00
?>