Merge branch 'wip-MDL-43470-master2' of https://github.com/marinaglancy/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2016-04-06 04:35:50 +02:00
15 changed files with 401 additions and 306 deletions
-5
View File
@@ -47,7 +47,6 @@ if (!feedback_can_view_analysis($feedback, $context)) {
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
$PAGE->navbar->add(get_string('analysis', 'feedback'));
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
@@ -57,9 +56,6 @@ echo $OUTPUT->heading(format_string($feedback->name));
require('tabs.php');
//print analysed items
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
//get the groupid
$myurl = $CFG->wwwroot.'/mod/feedback/analysis.php?id='.$cm->id.'&do_show=analysis';
$mygroupid = groups_get_activity_group($cm, true);
@@ -127,7 +123,6 @@ if ($check_anonymously) {
'feedback', '', '', 3);
}
echo '</div>';
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
+34 -49
View File
@@ -28,19 +28,16 @@ require_once("lib.php");
$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_RAW);
$courseid = optional_param('courseid', false, PARAM_INT);
$url = new moodle_url('/mod/feedback/analysis_course.php', array('id'=>$id));
navigation_node::override_active_url($url);
if ($courseid !== false) {
$url->param('courseid', $courseid);
}
if ($coursefilter !== '0') {
$url->param('coursefilter', $coursefilter);
}
if ($courseitemfilter !== '0') {
$url->param('courseitemfilter', $courseitemfilter);
}
@@ -52,10 +49,6 @@ if ($searchcourse !== '') {
}
$PAGE->set_url($url);
if (($searchcourse OR $courseitemfilter OR $coursefilter) AND !confirm_sesskey()) {
print_error('invalidsesskey');
}
if (! $cm = get_coursemodule_from_id('feedback', $id)) {
print_error('invalidcoursemodule');
}
@@ -83,21 +76,18 @@ $strfeedback = get_string("modulename", "feedback");
$PAGE->set_heading($course->fullname);
$PAGE->set_title($feedback->name);
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($feedback->name));
/// print the tabs
require('tabs.php');
//print the analysed items
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
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));
echo $OUTPUT->container_start('form-buttons');
$aurl = new moodle_url('analysis_to_excel.php', array('sesskey' => sesskey(), 'id' => $id,
'coursefilter' => $courseid));
echo $OUTPUT->single_button($aurl, get_string('export_to_excel', 'feedback'));
echo $OUTPUT->container_end();
}
@@ -106,7 +96,7 @@ if (has_capability('mod/feedback:viewreports', $context)) {
//lstgroupid is the choosen id
$mygroupid = false;
//get completed feedbacks
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $coursefilter);
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid, $courseid);
//show the count
echo '<b>'.get_string('completed_feedbacks', 'feedback').': '.$completedscount. '</b><br />';
@@ -117,15 +107,8 @@ $items = $DB->get_records('feedback_item', $params, 'position');
//show the count
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();
}
echo '<form name="report" method="post" id="analysis-form">';
echo '<div class="mdl-align"><table width="80%" cellpadding="10">';
if ($courseitemfilter > 0) {
$avgvalue = 'avg(value)';
if ($DB->get_dbfamily() == 'postgres') { // TODO: this should be moved to standard sql DML function ;-)
@@ -140,8 +123,9 @@ if ($courseitemfilter > 0) {
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">';
echo '<h4>'.$item->name.'</h4>';
echo '<div class="clearfix">';
echo '<table>';
echo '<tr><th>Course</th><th>Average</th></tr>';
$sep_dec = get_string('separator_decimal', 'feedback');
$sep_thous = get_string('separator_thousand', 'feedback');
@@ -157,21 +141,21 @@ if ($courseitemfilter > 0) {
echo '</td>';
echo '</tr>';
}
echo '</table></td></tr>';
echo '</table>';
} else {
echo '<tr><td>'.get_string('noresults').'</td></tr>';
echo '<p>'.get_string('noresults').'</p>';
}
echo '<p><a href="analysis_course.php?id=' . $id . '">';
echo get_string('back');
echo '</a></p>';
} else {
echo '<div class="mdl-align">';
echo '<form name="report" method="get" id="analysis-form">';
echo html_writer::label(get_string('search_course', 'feedback') . ': ', 'searchcourse');
echo '<input id="searchcourse" 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.'" />';
echo '<input type="hidden" name="courseitemfiltertyp" value="'.$courseitemfiltertyp.'" />';
echo '<input type="hidden" name="courseid" value="'.$courseid.'" />';
echo html_writer::script('', $CFG->wwwroot.'/mod/feedback/feedback.js');
$sql = 'select DISTINCT c.id, c.shortname from {course} c, '.
'{feedback_value} fv, {feedback_item} fi '.
'where c.id = fv.course_id and fv.item = fi.id '.
@@ -182,9 +166,11 @@ if ($courseitemfilter > 0) {
$params = array($feedback->id, "%$searchcourse%", "%$searchcourse%");
if ($courses = $DB->get_records_sql_menu($sql, $params)) {
echo ' '. html_writer::label(get_string('filter_by_course', 'feedback'), 'coursefilterid'). ': ';
echo html_writer::select($courses, 'coursefilter', $coursefilter,
if (!$courseid) {
$courses = array('' => get_string('choosedots')) + $courses;
}
echo ' '. html_writer::label(get_string('filter_by_course', 'feedback'). ': ', 'coursefilterid');
echo html_writer::select($courses, 'courseid', $courseid,
null, array('id'=>'coursefilterid', 'class' => 'autosubmit'));
$PAGE->requires->yui_module('moodle-core-formautosubmit',
@@ -192,15 +178,22 @@ if ($courseitemfilter > 0) {
array(array('selectid' => 'coursefilterid', 'nothing' => false))
);
}
if ($courseid) {
echo ' <a href="analysis_course.php?id=' . $id . '">';
echo get_string('show_all', 'feedback');
echo '</a>';
}
echo '</form>';
echo '</div>';
echo '<hr />';
$itemnr = 0;
//print the items in an analysed form
echo '<tr><td>';
foreach ($items as $item) {
if ($item->hasvalue == 0) {
continue;
}
echo '<table width="100%" class="generalbox">';
echo '<table>';
//get the class from item-typ
$itemobj = feedback_get_item_class($item->typ);
$itemnr++;
@@ -209,25 +202,17 @@ if ($courseitemfilter > 0) {
} else {
$printnr = '';
}
$itemobj->print_analysed($item, $printnr, $mygroupid, $coursefilter);
$itemobj->print_analysed($item, $printnr, $mygroupid, $courseid);
if (preg_match('/rated$/i', $item->typ)) {
$onclick = 'onclick="setcourseitemfilter'.
"(".$item->id.",'".$item->typ."');".
' return false;"';
$anker = '<a href="#" '.$onclick.'>'.
get_string('sort_by_course', 'feedback').
'</a>';
$url = new moodle_url('/mod/feedback/analysis_course.php', array('id' => $id,
'courseitemfilter' => $item->id, 'courseitemfiltertyp' => $item->typ));
$anker = html_writer::link($url, get_string('sort_by_course', 'feedback'));
echo '<tr><td colspan="2">'.$anker.'</td></tr>';
}
echo '</table>';
}
echo '</td></tr>';
}
echo '</table></div>';
echo '</form>';
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
+48
View File
@@ -0,0 +1,48 @@
<?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_course_map_form
*
* @package mod_feedback
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Form for mapping courses to the feedback
*
* @package mod_feedback
* @copyright 2016 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_feedback_course_map_form extends moodleform {
/**
* Definition of the form
*/
public function definition() {
$mform = $this->_form;
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$options = array('multiple' => true);
$mform->addElement('course', 'mappedcourses', get_string('courses'), $options);
$this->add_action_buttons();
}
}
-5
View File
@@ -137,11 +137,6 @@ if (isset($error)) {
}
$itemobj->show_editform();
if ($typ!='label') {
$PAGE->requires->js('/mod/feedback/feedback.js');
$PAGE->requires->js_function_call('set_item_focus', Array('id_itemname'));
}
/// Finish the page
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
-19
View File
@@ -1,22 +1,3 @@
function set_item_focus(itemid) {
var item = document.getElementById(itemid);
if(item){
item.focus();
}
}
function feedbackGo2delete(form) {
form.action = M.cfg.wwwroot+'/mod/feedback/delete_completed.php';
form.submit();
}
function setcourseitemfilter(item, item_typ) {
document.report.courseitemfilter.value = item;
document.report.courseitemfiltertyp.value = item_typ;
document.report.submit();
}
M.mod_feedback = {};
M.mod_feedback.init_sendmessage = function(Y) {
+1
View File
@@ -1 +1,2 @@
completed,mod_feedback
mapcourses_help,mod_feedback
+4 -2
View File
@@ -152,9 +152,8 @@ $string['mapcourse'] = 'Map feedback to courses';
$string['mapcourse_help'] = 'By default, feedback forms created on your homepage are available site-wide
and will appear in all courses using the feedback block. You can force the feedback form to appear by making it a sticky block or limit the courses in which a feedback form will appear by mapping it to specific courses.';
$string['mapcourses'] = 'Map feedback to courses';
$string['mapcourses_help'] = 'Once you have selected the relevant course(s) from your search,
you can associate them with this feedback using map course(s). Multiple courses may be selected by holding down the Apple or Ctrl key whilst clicking on the course names. A course may be disassociated from a feedback at any time.';
$string['mappedcourses'] = 'Mapped courses';
$string['mappingchanged'] = 'Course mapping has been changed';
$string['max_args_exceeded'] = 'Max 6 arguments can be handled, too many arguments for';
$string['minimal'] = 'minimum';
$string['maximal'] = 'maximum';
@@ -291,3 +290,6 @@ $string['viewcompleted_help'] = 'You may view completed feedback forms, searchab
Feedback responses may be exported to Excel.';
// Deprecated since Moodle 3.0.
$string['completed'] = 'completed';
// Deprecated since Moodle 3.1.
$string['mapcourses_help'] = 'Once you have selected the relevant course(s) from your search,
you can associate them with this feedback using map course(s). Multiple courses may be selected by holding down the Apple or Ctrl key whilst clicking on the course names. A course may be disassociated from a feedback at any time.';
+33 -11
View File
@@ -2851,16 +2851,15 @@ function feedback_get_feedbacks_from_sitecourse_map($courseid) {
}
/**
* gets the courses from table feedback_sitecourse_map.
* Gets the courses from table feedback_sitecourse_map
*
* @global object
* @param int $feedbackid
* @return array the course-records
*/
function feedback_get_courses_from_sitecourse_map($feedbackid) {
global $DB;
$sql = "SELECT f.id, f.courseid, c.fullname, c.shortname
$sql = "SELECT c.id, c.fullname, c.shortname
FROM {feedback_sitecourse_map} f, {course} c
WHERE c.id = f.courseid
AND f.feedbackid = ?
@@ -2870,6 +2869,27 @@ function feedback_get_courses_from_sitecourse_map($feedbackid) {
}
/**
* Updates the course mapping for the feedback
*
* @param stdClass $feedback
* @param array $courses array of course ids
*/
function feedback_update_sitecourse_map($feedback, $courses) {
global $DB;
if (empty($courses)) {
$courses = array();
}
$currentmapping = $DB->get_fieldset_select('feedback_sitecourse_map', 'courseid', 'feedbackid=?', array($feedback->id));
foreach (array_diff($courses, $currentmapping) as $courseid) {
$DB->insert_record('feedback_sitecourse_map', array('feedbackid' => $feedback->id, 'courseid' => $courseid));
}
foreach (array_diff($currentmapping, $courses) as $courseid) {
$DB->delete_records('feedback_sitecourse_map', array('feedbackid' => $feedback->id, 'courseid' => $courseid));
}
// TODO MDL-53574 add events.
}
/**
* removes non existing courses or feedbacks from sitecourse_map.
* it shouldn't be called all too often
@@ -3147,7 +3167,7 @@ function feedback_encode_target_url($url) {
function feedback_extend_settings_navigation(settings_navigation $settings,
navigation_node $feedbacknode) {
global $PAGE, $DB;
global $PAGE;
if (!$context = context_module::instance($PAGE->cm->id, IGNORE_MISSING)) {
print_error('badcontext');
@@ -3176,20 +3196,22 @@ function feedback_extend_settings_navigation(settings_navigation $settings,
'do_show' => 'templates')));
}
if (has_capability('mod/feedback:mapcourse', $context) && $PAGE->course->id == SITEID) {
$feedbacknode->add(get_string('mappedcourses', 'feedback'),
new moodle_url('/mod/feedback/mapcourse.php',
array('id' => $PAGE->cm->id)));
}
if (has_capability('mod/feedback:viewreports', $context)) {
$feedback = $DB->get_record('feedback', array('id'=>$PAGE->cm->instance));
$feedback = $PAGE->activityrecord;
if ($feedback->course == SITEID) {
$feedbacknode->add(get_string('analysis', 'feedback'),
new moodle_url('/mod/feedback/analysis_course.php',
array('id' => $PAGE->cm->id,
'course' => $PAGE->course->id,
'do_show' => 'analysis')));
array('id' => $PAGE->cm->id)));
} else {
$feedbacknode->add(get_string('analysis', 'feedback'),
new moodle_url('/mod/feedback/analysis.php',
array('id' => $PAGE->cm->id,
'course' => $PAGE->course->id,
'do_show' => 'analysis')));
array('id' => $PAGE->cm->id)));
}
$feedbacknode->add(get_string('show_entries', 'feedback'),
+18 -103
View File
@@ -22,65 +22,36 @@
* @package mod_feedback
*/
require_once("../../config.php");
require_once("lib.php");
require_once(__DIR__ . "/../../config.php");
require_once($CFG->dirroot . "/mod/feedback/lib.php");
require_once("$CFG->libdir/tablelib.php");
$id = required_param('id', PARAM_INT); // Course Module ID, or
$searchcourse = optional_param('searchcourse', '', PARAM_NOTAGS);
$coursefilter = optional_param('coursefilter', '', PARAM_INT);
$courseid = optional_param('courseid', false, PARAM_INT);
$id = required_param('id', PARAM_INT); // Course Module ID.
$url = new moodle_url('/mod/feedback/mapcourse.php', array('id'=>$id));
if ($searchcourse !== '') {
$url->param('searchcourse', $searchcourse);
}
if ($coursefilter !== '') {
$url->param('coursefilter', $coursefilter);
}
if ($courseid !== false) {
$url->param('courseid', $courseid);
}
$PAGE->set_url($url);
if (($formdata = data_submitted()) AND !confirm_sesskey()) {
print_error('invalidsesskey');
}
$current_tab = 'mapcourse';
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');
}
list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback');
require_login($course, true, $cm);
$feedback = $PAGE->activityrecord;
$context = context_module::instance($cm->id);
require_login($course, true, $cm);
require_capability('mod/feedback:mapcourse', $context);
if ($coursefilter) {
$map = new stdClass;
$map->feedbackid = $feedback->id;
$map->courseid = $coursefilter;
// insert a map only if it does exists yet
$sql = "SELECT id, feedbackid
FROM {feedback_sitecourse_map}
WHERE feedbackid = ? AND courseid = ?";
if (!$DB->get_records_sql($sql, array($map->feedbackid, $map->courseid))) {
$DB->insert_record('feedback_sitecourse_map', $map);
}
$coursemap = array_keys(feedback_get_courses_from_sitecourse_map($feedback->id));
$form = new mod_feedback_course_map_form();
$form->set_data(array('id' => $cm->id, 'mappedcourses' => $coursemap));
$mainurl = new moodle_url('/mod/feedback/view.php', ['id' => $id]);
if ($form->is_cancelled()) {
redirect($mainurl);
} else if ($data = $form->get_data()) {
feedback_update_sitecourse_map($feedback, $data->mappedcourses);
redirect($mainurl, get_string('mappingchanged', 'feedback'), null, \core\output\notification::NOTIFY_SUCCESS);
}
/// Print the page header
// Print the page header.
$strfeedbacks = get_string("modulenameplural", "feedback");
$strfeedback = get_string("modulename", "feedback");
@@ -91,64 +62,8 @@ echo $OUTPUT->heading(format_string($feedback->name));
require('tabs.php');
echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'), 'generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo '<form method="post">';
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo $OUTPUT->box(get_string('mapcourseinfo', 'feedback'));
$sql = "select c.id, c.shortname
from {course} c
where ".$DB->sql_like('c.shortname', '?', false)."
OR ".$DB->sql_like('c.fullname', '?', false);
$params = array("%{$searchcourse}%", "%{$searchcourse}%");
if (($courses = $DB->get_records_sql_menu($sql, $params)) && !empty($searchcourse)) {
echo ' '. html_writer::label(get_string('courses'), 'menucoursefilter', false). ': ';
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="hidden" name="searchcourse" value="'.s($searchcourse).'"/>';
echo '<input type="hidden" name="feedbackid" value="'.$feedback->id.'"/>';
echo $OUTPUT->help_icon('searchcourses', 'feedback');
} else {
echo '<input type="text" name="searchcourse" value="'.s($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)) {
$table = new flexible_table('coursemaps');
$table->baseurl = $url;
$table->define_columns( array('course'));
$table->define_headers( array(get_string('mappedcourses', 'feedback')));
$table->setup();
$unmapurl = new moodle_url('/mod/feedback/unmapcourse.php');
foreach ($coursemap as $cmap) {
$coursecontext = context_course::instance($cmap->courseid);
$cmapshortname = format_string($cmap->shortname, true, array('context' => $coursecontext));
$cmapfullname = format_string($cmap->fullname, true, array('context' => $coursecontext));
$unmapurl->params(array('id'=>$id, 'cmapid'=>$cmap->id));
$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();
} else {
echo $OUTPUT->heading(get_string('mapcoursenone', 'feedback'), 3);
}
echo $OUTPUT->box_end();
$form->display();
echo $OUTPUT->footer();
+8 -3
View File
@@ -43,7 +43,7 @@ if (!isset($current_tab)) {
$current_tab = '';
}
$viewurl = new moodle_url('/mod/feedback/view.php', array('id'=>$usedid, 'do_show'=>'view'));
$viewurl = new moodle_url('/mod/feedback/view.php', array('id' => $usedid));
$row[] = new tabobject('view', $viewurl->out(), get_string('overview', 'feedback'));
if (has_capability('mod/feedback:edititems', $context)) {
@@ -54,16 +54,21 @@ if (has_capability('mod/feedback:edititems', $context)) {
$row[] = new tabobject('templates', $templateurl->out(), get_string('templates', 'feedback'));
}
if ($feedback->course == SITEID && has_capability('mod/feedback:mapcourse', $context)) {
$mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id' => $usedid));
$row[] = new tabobject('mapcourse', $mapurl->out(), get_string('mappedcourses', 'feedback'));
}
if (has_capability('mod/feedback:viewreports', $context)) {
if ($feedback->course == SITEID) {
$url_params = array('id'=>$usedid, 'courseid'=>$courseid, 'do_show'=>'analysis');
$url_params = array('id' => $usedid, 'courseid' => $courseid);
$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');
$url_params = array('id' => $usedid);
$analysisurl = new moodle_url('/mod/feedback/analysis.php', $url_params);
$row[] = new tabobject('analysis',
$analysisurl->out(),
@@ -50,12 +50,6 @@ Feature: Anonymous feedback
And I press "Continue"
Scenario: Complete anonymous feedback on the front page as an authenticated user
And I log in as "admin"
And I set the following system permissions of "Authenticated user" role:
| capability | permission |
| mod/feedback:view | Allow |
| mod/feedback:complete | Allow |
And I log out
And I log in as "user1"
And I am on site homepage
When I follow "Site feedback"
@@ -74,8 +68,6 @@ Feature: Anonymous feedback
And I log in as "admin"
And I set the following system permissions of "Authenticated user on frontpage" role:
| capability | permission |
| mod/feedback:view | Allow |
| mod/feedback:complete | Allow |
| mod/feedback:viewanalysepage | Allow |
And I log out
And I log in as "user1"
@@ -0,0 +1,226 @@
@mod @mod_feedback
Feature: Mapping courses in a feedback
In order to collect the same feedback about multiple courses
As a manager
I need to be able to map site feedback to courses
Background:
Given the following "users" exist:
| username | firstname | lastname |
| user1 | Username | 1 |
| user2 | Username | 2 |
| user3 | Username | 3 |
| teacher | Teacher | 4 |
| manager | Manager | 5 |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
| Course 2 | C2 |
| Course 3 | C3 |
And the following "course enrolments" exist:
| user | course | role |
| user1 | C1 | student |
| user1 | C2 | student |
| user2 | C1 | student |
| user2 | C2 | student |
| user3 | C3 | student |
| teacher | C1 | editingteacher |
| teacher | C2 | editingteacher |
| teacher | C3 | editingteacher |
And the following "system role assigns" exist:
| user | course | role |
| manager | Acceptance test site | manager |
And I log in as "admin"
And I navigate to "Manage activities" node in "Site administration > Plugins > Activity modules"
And I click on "Show" "link" in the "Feedback" "table_row"
And I navigate to "Manage blocks" node in "Site administration > Plugins > Blocks"
And I click on "Show" "link" in the "Feedback" "table_row"
And I log out
And the following "activities" exist:
| activity | name | course | idnumber | anonymous | publish_stats |
| feedback | Course feedback | Acceptance test site | feedback0 | 1 | 1 |
| feedback | Another feedback | C1 | feedback1 | 1 | 1 |
When I log in as "manager"
And I am on site homepage
And I follow "Course feedback"
And I follow "Edit questions"
And I add a "Information" question to the feedback with:
| Question | this is an information question |
| Label | info |
| Information-Type | Course |
And I add a "Multiple choice (rated)" question to the feedback with:
| Question | this is a multiple choice rated |
| Label | multichoicerated |
| Multiple choice type | Multiple choice - single answer |
| Multiple choice values | 0/option a\n1/option b\n5/option c |
And I add a "Multiple choice" question to the feedback with:
| Question | this is a simple multiple choice |
| Label | multichoicesimple |
| Multiple choice type | Multiple choice - single answer allowed (dropdownlist) |
| Multiple choice values | option d\noption e\noption f |
And I log out
And I log in as "teacher"
And I follow "Course 1"
And I turn editing mode on
And I add the "Feedback" block
And I am on site homepage
And I follow "Course 2"
And I add the "Feedback" block
And I am on site homepage
And I follow "Course 3"
And I add the "Feedback" block
And I log out
Scenario: Course feedback can not be mapped
And I log in as "manager"
And I am on site homepage
And I follow "Course 1"
And I follow "Another feedback"
And I should not see "Mapped courses"
And I should not see "Map feedback to courses"
@javascript
Scenario: Site feedback is not mapped to any course
And I log in as "user1"
And I am on site homepage
And I follow "Course feedback"
And I follow "Answer the questions..."
And I should see "Acceptance test site" in the ".feedback_form" "css_element"
And I set the following fields to these values:
| option a | 1 |
| this is a simple multiple choice | option d |
And I press "Submit your answers"
And I press "Continue"
And I follow "Course 1"
And I click on "Course feedback" "link" in the "Feedback" "block"
And I follow "Answer the questions..."
And I should not see "Acceptance test site" in the ".feedback_form" "css_element"
And I should see "C1" in the ".feedback_form" "css_element"
And I set the following fields to these values:
| option b | 1 |
| this is a simple multiple choice | option e |
And I press "Submit your answers"
And I press "Continue"
And I click on "Course feedback" "link" in the "Feedback" "block"
And I should not see "Answer the questions..."
And I log out
And I log in as "user2"
And I follow "Course 1"
And I click on "Course feedback" "link" in the "Feedback" "block"
And I follow "Answer the questions..."
And I should not see "Acceptance test site" in the ".feedback_form" "css_element"
And I should see "C1" in the ".feedback_form" "css_element"
And I set the following fields to these values:
| option c | 1 |
| this is a simple multiple choice | option e |
And I press "Submit your answers"
And I press "Continue"
And I log out
And I log in as "manager"
And I am on site homepage
And I follow "Course feedback"
And I follow "Analysis"
And the field "Filter by course" matches value "Choose..."
And I should see "1 (33.33 %)" in the "option a" "table_row"
And I should see "1 (33.33 %)" in the "option b" "table_row"
And I should see "1 (33.33 %)" in the "option c" "table_row"
And I should see "Average: 2.00" in the "(multichoicerated)" "table"
And I click on "Sort by course" "link" in the "(multichoicerated)" "table"
And I should see "2.50" in the "C1" "table_row"
And I should see "1.00" in the "Acceptance test site" "table_row"
And I follow "Back"
And I set the field "Filter by course" to "C1"
And I should see "0" in the "option a" "table_row"
And I should see "1 (50.00 %)" in the "option b" "table_row"
And I should see "1 (50.00 %)" in the "option c" "table_row"
And I log out
@javascript
Scenario: Site feedback is mapped to courses
And I log in as "manager"
And I am on site homepage
And I follow "Course feedback"
And I follow "Map feedback to courses"
And I set the field "Courses" to "Course 2"
And I set the field "Courses" to "Course 3"
And I press "Save changes"
And I log out
And I log in as "user1"
And I am on site homepage
And I follow "Course feedback"
And I should see "You can only access this feedback from a course"
And I should not see "Answer the questions..."
And I am on site homepage
And I follow "Course 1"
And "Feedback" "block" should not exist
And I should not see "Course feedback"
And I am on site homepage
And I follow "Course 2"
And I click on "Course feedback" "link" in the "Feedback" "block"
And I follow "Answer the questions..."
And I should not see "Acceptance test site" in the ".feedback_form" "css_element"
And I should see "C2" in the ".feedback_form" "css_element"
And I set the following fields to these values:
| option b | 1 |
| this is a simple multiple choice | option e |
And I press "Submit your answers"
And I press "Continue"
And I click on "Course feedback" "link" in the "Feedback" "block"
And I should not see "Answer the questions..."
And I log out
And I log in as "user2"
And I follow "Course 2"
And I click on "Course feedback" "link" in the "Feedback" "block"
And I follow "Answer the questions..."
And I should not see "Acceptance test site" in the ".feedback_form" "css_element"
And I should see "C2" in the ".feedback_form" "css_element"
And I set the following fields to these values:
| option c | 1 |
| this is a simple multiple choice | option e |
And I press "Submit your answers"
And I press "Continue"
And I log out
And I log in as "user3"
And I follow "Course 3"
And I click on "Course feedback" "link" in the "Feedback" "block"
And I follow "Answer the questions..."
And I should not see "Acceptance test site" in the ".feedback_form" "css_element"
And I should see "C3" in the ".feedback_form" "css_element"
And I set the following fields to these values:
| option c | 1 |
| this is a simple multiple choice | option d |
And I press "Submit your answers"
And I press "Continue"
And I log out
And I log in as "manager"
And I am on site homepage
And I follow "Course feedback"
And I follow "Analysis"
And the field "Filter by course" matches value "Choose..."
And I should see "0" in the "option a" "table_row"
And I should see "1 (33.33 %)" in the "option b" "table_row"
And I should see "2 (66.67 %)" in the "option c" "table_row"
And I should see "Average: 3.67" in the "(multichoicerated)" "table"
And I click on "Sort by course" "link" in the "(multichoicerated)" "table"
And I should see "3.00" in the "C3" "table_row"
And I should see "2.50" in the "C2" "table_row"
And I follow "Back"
And I set the field "Filter by course" to "C2"
And I should see "0" in the "option a" "table_row"
And I should see "1 (50.00 %)" in the "option b" "table_row"
And I should see "1 (50.00 %)" in the "option c" "table_row"
And I should see "2 (100.00 %)" in the "option e" "table_row"
And I set the field "Filter by course" to "C3"
And I should see "0" in the "option a" "table_row"
And I should see "0" in the "option b" "table_row"
And I should see "1 (100.00 %)" in the "option c" "table_row"
And I should see "1 (100.00 %)" in the "option d" "table_row"
And I follow "Show all"
And I should see "1 (33.33 %)" in the "option d" "table_row"
And I should see "2 (66.67 %)" in the "option e" "table_row"
And I should see "0" in the "option f" "table_row"
And I log out
-62
View File
@@ -1,62 +0,0 @@
<?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
*
* @author Andreas Grabs
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package mod_feedback
*/
require_once("../../config.php");
require_once($CFG->dirroot.'/mod/feedback/lib.php');
$id = required_param('id', PARAM_INT);
$cmapid = required_param('cmapid', PARAM_INT);
$url = new moodle_url('/mod/feedback/unmapcourse.php', array('id'=>$id));
if ($cmapid !== '') {
$url->param('cmapid', $cmapid);
}
$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');
}
$context = context_module::instance($cm->id);
require_capability('mod/feedback:mapcourse', $context);
// cleanup all lost entries after deleting courses or feedbacks
feedback_clean_up_sitecourse_map();
if ($DB->delete_records('feedback_sitecourse_map', array('id'=>$cmapid))) {
$mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id'=>$id));
redirect ($mapurl->out(false));
} else {
print_error('cannotunmap', 'feedback');
}
+4
View File
@@ -1,3 +1,7 @@
=== 3.1 ===
* feedback_get_courses_from_sitecourse_map() now returns course id as 'id' attribute
=== 2.7 ===
* The validation of the following events is now stricter (see MDL-45445):
+25 -39
View File
@@ -69,7 +69,7 @@ if ($course->id == SITEID) {
$PAGE->set_cm($cm, $course);
$PAGE->set_pagelayout('incourse');
}
$PAGE->set_url('/mod/feedback/view.php', array('id'=>$cm->id, 'do_show'=>'view'));
$PAGE->set_url('/mod/feedback/view.php', array('id' => $cm->id));
$PAGE->set_title($feedback->name);
$PAGE->set_heading($course->fullname);
@@ -136,13 +136,22 @@ echo $OUTPUT->heading(format_string($feedback->name) . $preview);
// Print the tabs.
require('tabs.php');
// Show description.
echo $OUTPUT->box_start('generalbox feedback_description');
$options = (object)array('noclean' => true);
echo format_module_intro('feedback', $feedback, $cm->id);
echo $OUTPUT->box_end();
//show some infos to the feedback
if (has_capability('mod/feedback:edititems', $context)) {
echo $OUTPUT->heading(get_string('overview', 'feedback'), 3);
//get the groupid
$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 $OUTPUT->box_start('boxaligncenter');
echo $groupselect.'<div class="clearer">&nbsp;</div>';
$completedscount = feedback_get_completeds_group_count($feedback, $mygroupid);
echo $OUTPUT->box_start('feedback_info');
@@ -188,14 +197,6 @@ if (has_capability('mod/feedback:edititems', $context)) {
echo $OUTPUT->box_end();
}
if (has_capability('mod/feedback:edititems', $context)) {
echo $OUTPUT->heading(get_string('description', 'feedback'), 3);
}
echo $OUTPUT->box_start('generalbox boxwidthwide');
$options = (object)array('noclean'=>true);
echo format_module_intro('feedback', $feedback, $cm->id);
echo $OUTPUT->box_end();
if (has_capability('mod/feedback:edititems', $context)) {
require_once($CFG->libdir . '/filelib.php');
@@ -207,7 +208,7 @@ if (has_capability('mod/feedback:edititems', $context)) {
0);
echo $OUTPUT->heading(get_string("page_after_submit", "feedback"), 3);
echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide');
echo $OUTPUT->box_start('generalbox feedback_after_submit');
echo format_text($page_after_submit_output,
$feedback->page_after_submitformat,
array('overflowdiv'=>true));
@@ -215,37 +216,22 @@ if (has_capability('mod/feedback:edititems', $context)) {
echo $OUTPUT->box_end();
}
if ( (intval($feedback->publish_stats) == 1) AND
( has_capability('mod/feedback:viewanalysepage', $context)) AND
!( has_capability('mod/feedback:viewreports', $context)) ) {
$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>';
}
if (!has_capability('mod/feedback:viewreports', $context) &&
feedback_can_view_analysis($feedback, $context, $courseid)) {
$analysisurl = new moodle_url('/mod/feedback/analysis.php', array('id' => $id));
echo '<div class="mdl-align"><a href="'.$analysisurl->out().'">';
echo get_string('completed_feedbacks', 'feedback').'</a>';
echo '</div>';
}
//####### mapcourse-start
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">';
echo '<fieldset>';
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<button type="submit">'.get_string('mapcourses', 'feedback').'</button>';
echo $OUTPUT->help_icon('mapcourse', 'feedback');
echo '</fieldset>';
echo '</form>';
echo '<br />';
echo '</div>';
echo $OUTPUT->box_end();
}
if (has_capability('mod/feedback:mapcourse', $context) && $feedback->course == SITEID) {
echo $OUTPUT->box_start('generalbox feedback_mapped_courses');
echo $OUTPUT->heading(get_string("mappedcourses", "feedback"), 3);
echo '<p>' . get_string('mapcourse_help', 'feedback') . '</p>';
$mapurl = new moodle_url('/mod/feedback/mapcourse.php', array('id' => $id));
echo '<p class="mdl-align">' . html_writer::link($mapurl, get_string('mapcourses', 'feedback')) . '</p>';
echo $OUTPUT->box_end();
}
//####### mapcourse-end