Permalink
Browse files

MDL-53449 mod_feedback: reponses page clean up and behat

  • Loading branch information...
danpoltawski committed Apr 5, 2016
1 parent f164cab commit 9bb87baf18894b874450a29c348727e4d466ceb9
View
@@ -62,14 +62,10 @@
//get the groupid
$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);
$mygroupid = groups_get_activity_group($cm, true);
groups_print_activity_menu($cm, $myurl);
if ( has_capability('mod/feedback:viewreports', $context) ) {
echo isset($groupselect) ? $groupselect : '';
echo '<div class="clearer"></div>';
//button "export to excel"
echo $OUTPUT->container_start('form-buttons');
$aurl = new moodle_url('analysis_to_excel.php', array('sesskey'=>sesskey(), 'id'=>$id));
@@ -80,23 +76,22 @@
//get completed feedbacks
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid);
//show the group, if available
if ($mygroupid and $group = $DB->get_record('groups', array('id'=>$mygroupid))) {
echo '<b>'.get_string('group').': '.$group->name. '</b><br />';
}
//show the count
echo '<div class="analysis_header">';
// Show the submissions 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');
//show the count
// Show the items count.
if (is_array($items)) {
echo '<b>'.get_string('questions', 'feedback').': ' .count($items). ' </b><hr />';
} else {
$items=array();
}
echo '</div>';
$check_anonymously = true;
if ($mygroupid > 0 AND $feedback->anonymous == FEEDBACK_ANONYMOUS_YES) {
if ($completedscount < FEEDBACK_MIN_ANONYMOUS_COUNT_IN_GROUP) {
@@ -72,21 +72,21 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created feedback for the user with id '$this->relateduserid' " .
"for the feedback activity with course module id '$this->contextinstanceid'.";
return "The user with id '$this->userid' submitted response for 'feedback' activity with "
. "course module id '$this->contextinstanceid'.";
}
/**
* Returns relevant URL based on the anonymous mode of the response.
* @return \moodle_url
*/
public function get_url() {
if ($this->other['anonymous'] == FEEDBACK_ANONYMOUS_YES) {
return new \moodle_url('/mod/feedback/show_entries.php' , array('id' => $this->other['cmid'],
'do_show' => 'showoneentry' , 'userid' => $this->relateduserid));
if ($this->anonymous) {
return new \moodle_url('/mod/feedback/show_entries.php', array('id' => $this->other['cmid'],
'showcompleted' => $this->objectid));
} else {
return new \moodle_url('/mod/feedback/show_entries_anonym.php', array('id' => $this->other['cmid'],
'do_show' => 'showoneentry', 'showall' => 1, 'showcompleted' => $this->objectid));
return new \moodle_url('/mod/feedback/show_entries.php' , array('id' => $this->other['cmid'],
'userid' => $this->userid, 'showcompleted' => $this->objectid));
}
}
@@ -0,0 +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/>.
/**
* Contains class mod_feedback_responses_anon_table
*
* @package mod_feedback
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Class mod_feedback_responses_anon_table
*
* @package mod_feedback
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_feedback_responses_anon_table extends mod_feedback_responses_table {
/** @var string */
protected $showallparamname = 'ashowall';
/**
* Initialises table
*/
public function init() {
$this->uniqueid = 'feedback-showentry-anon-list-' . $this->cm->instance;
// There potentially can be both tables with anonymouns and non-anonymous responses on
// the same page (for example when feedback anonymity was changed after some people
// already responded). In this case we need to distinguish tables' pagination parameters.
$this->request[TABLE_VAR_PAGE] = 'apage';
$tablecolumns = array('random_response', 'showresponse');
$tableheaders = array('', '');
$context = context_module::instance($this->cm->id);
if (has_capability('mod/feedback:deletesubmissions', $context)) {
$tablecolumns[] = 'deleteentry';
$tableheaders[] = '';
}
$this->define_columns($tablecolumns);
$this->define_headers($tableheaders);
$this->sortable(false, 'random_response');
$this->collapsible(false);
$this->set_attribute('id', 'showentryanonymtable');
$params = ['instance' => $this->cm->instance, 'anon' => FEEDBACK_ANONYMOUS_YES];
$fields = 'DISTINCT c.id, c.random_response';
$from = '{feedback_completed} c';
$where = 'c.anonymous_response = :anon AND c.feedback = :instance';
$group = groups_get_activity_group($this->cm, true);
if ($group) {
$from .= ' JOIN {groups_members} g ON g.groupid = :group AND g.userid = c.userid';
$params['group'] = $group;
}
$this->set_sql($fields, $from, $where, $params);
$this->set_count_sql("SELECT COUNT(DISTINCT c.id) FROM $from WHERE $where", $params);
}
/**
* Returns a link for viewing a single response
* @param stdClass $row
* @return \moodle_url
*/
protected function get_link_single_entry($row) {
return new moodle_url($this->baseurl, ['showcompleted' => $row->id]);
}
/**
* Prepares column reponse for display
* @param stdClass $row
* @return string
*/
public function col_random_response($row) {
return get_string('response_nr', 'feedback').': '. $row->random_response;
}
/**
* Prepares column showresponse for display
* @param stdClass $row
* @return string
*/
public function col_showresponse($row) {
return html_writer::link($this->get_link_single_entry($row), get_string('show_entry', 'feedback'));
}
/**
* Generate the HTML for the table preferences reset button.
*/
protected function render_reset_button() {
return '';
}
}
Oops, something went wrong.

0 comments on commit 9bb87ba

Please sign in to comment.