/** * Constructor * * @param stdClass $feedback feedback object, in case of the template * this is the current feedback the template is accessed from * @param cm_info $cm course module object corresponding to the $feedback * @param int $courseid current course (for site feedbacks only) * @param bool $iscompleted has feedback been already completed? If yes either completedid or userid must be specified. * @param int $completedid id in the table feedback_completed, may be omitted if userid is specified * but it is highly recommended because the same user may have multiple responses to the same feedback * for different courses * @param int $userid id of the user - if specified only non-anonymous replies will be returned. If not * specified only anonymous replies will be returned and the $completedid is mandatory. */ public function __construct($feedback, $cm, $courseid, $iscompleted = false, $completedid = null, $userid = null) { global $DB; // Make sure courseid is always set for site feedback and never for course feedback. if ($feedback->course == SITEID) { $courseid = $courseid ?: SITEID; } else { $courseid = 0; } parent::__construct($feedback, $cm, $courseid, 0); if ($iscompleted) { // Retrieve information about the completion. $this->iscompleted = true; $params = array('feedback' => $feedback->id); if (!$userid && !$completedid) { throw new coding_exception('Either $completedid or $userid must be specified for completed feedbacks'); } if ($completedid) { $params['id'] = $completedid; } if ($userid) { // We must respect the anonymousity of the reply that the user saw when they were completing the feedback, // not the current state that may have been changed later by the teacher. $params['anonymous_response'] = FEEDBACK_ANONYMOUS_NO; $params['userid'] = $userid; } $this->completed = $DB->get_record('feedback_completed', $params, '*', MUST_EXIST); $this->courseid = $this->completed->courseid; } }
/** * Take the data returned from the db_query and go through all the rows * processing each col using either col_{columnname} method or other_cols * method or if other_cols returns NULL then put the data straight into the * table. * * This overwrites the parent method because full SQL query may fail on Mysql * because of the limit in the number of tables in the join. Therefore we only * join 59 tables in the main query and add the rest here. * * @return void */ public function build_table() { if ($this->rawdata instanceof \Traversable && !$this->rawdata->valid()) { return; } if (!$this->rawdata) { return; } $columnsgroups = []; if ($this->hasmorecolumns) { $items = $this->feedbackstructure->get_items(true); $notretrieveditems = array_slice($items, self::TABLEJOINLIMIT, $this->hasmorecolumns, true); $columnsgroups = array_chunk($notretrieveditems, self::TABLEJOINLIMIT, true); } $chunk = []; foreach ($this->rawdata as $row) { if ($this->hasmorecolumns) { $chunk[$row->id] = $row; if (count($chunk) >= self::ROWCHUNKSIZE) { $this->build_table_chunk($chunk, $columnsgroups); $chunk = []; } } else { $this->add_data_keyed($this->format_row($row), $this->get_row_class($row)); } } $this->build_table_chunk($chunk, $columnsgroups); $this->rawdata->close(); }
/** * Adds a dependency description to the question name * @param stdClass $item * @param HTML_QuickForm_element $element */ protected function add_item_dependencies($item, $element) { $allitems = $this->structure->get_items(); if ($item->dependitem && ($this->mode == self::MODE_EDIT || $this->mode == self::MODE_VIEW_TEMPLATE)) { if (isset($allitems[$item->dependitem])) { $dependitem = $allitems[$item->dependitem]; $name = $element->getLabel(); $name .= html_writer::span(' (' . format_string($dependitem->label) . '->' . $item->dependvalue . ')', 'feedback_depend'); $element->setLabel($name); } } }
/** * Displays the table */ public function display() { global $OUTPUT; groups_print_activity_menu($this->feedbackstructure->get_cm(), $this->baseurl->out()); $grandtotal = $this->get_total_responses_count(); if (!$grandtotal) { echo $OUTPUT->box(get_string('nothingtodisplay'), 'generalbox nothingtodisplay'); return; } $this->out($this->showall ? $grandtotal : FEEDBACK_DEFAULT_PAGE_COUNT, $grandtotal > FEEDBACK_DEFAULT_PAGE_COUNT); // Toggle 'Show all' link. if ($this->totalrows > FEEDBACK_DEFAULT_PAGE_COUNT) { if (!$this->use_pages) { echo html_writer::div(html_writer::link(new moodle_url($this->baseurl, [$this->showallparamname => 0]), get_string('showperpage', '', FEEDBACK_DEFAULT_PAGE_COUNT)), 'showall'); } else { echo html_writer::div(html_writer::link(new moodle_url($this->baseurl, [$this->showallparamname => 1]), get_string('showall', '', $this->totalrows)), 'showall'); } } }
} if ($courseitemfilter !== '0') { $url->param('courseitemfilter', $courseitemfilter); } if ($courseitemfiltertyp !== '0') { $url->param('courseitemfiltertyp', $courseitemfiltertyp); } $PAGE->set_url($url); list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback'); $context = context_module::instance($cm->id); require_course_login($course, true, $cm); $feedback = $PAGE->activityrecord; if (!($feedback->publish_stats or has_capability('mod/feedback:viewreports', $context))) { print_error('error'); } $feedbackstructure = new mod_feedback_structure($feedback, $PAGE->cm, $courseid); // Process course select form. $courseselectform = new mod_feedback_course_select_form($url, $feedbackstructure); if ($data = $courseselectform->get_data()) { redirect(new moodle_url($url, ['courseid' => $data->courseid])); } /// Print the page header $strfeedbacks = get_string("modulenameplural", "feedback"); $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'; //get the groupid
* * @copyright Andreas Grabs * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package mod_feedback */ require_once "../../config.php"; require_once "lib.php"; $current_tab = 'analysis'; $id = required_param('id', PARAM_INT); // Course module id. $url = new moodle_url('/mod/feedback/analysis.php', array('id' => $id)); $PAGE->set_url($url); list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback'); require_course_login($course, true, $cm); $feedback = $PAGE->activityrecord; $feedbackstructure = new mod_feedback_structure($feedback, $cm); $context = context_module::instance($cm->id); if (!$feedbackstructure->can_view_analysis()) { print_error('error'); } /// Print the page header $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'; //get the groupid $mygroupid = groups_get_activity_group($cm, true); groups_print_activity_menu($cm, $url); // Show the summary.
$feedback = $PAGE->activityrecord; require_capability('mod/feedback:viewreports', $context); if ($deleteid) { // This is a request to delete a reponse. require_capability('mod/feedback:deletesubmissions', $context); require_sesskey(); $feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $deleteid); feedback_delete_completed($feedbackstructure->get_completed(), $feedback, $cm); redirect($baseurl); } else { if ($showcompleted || $userid) { // Viewing individual response. $feedbackstructure = new mod_feedback_completion($feedback, $cm, 0, true, $showcompleted, $userid); } else { // Viewing list of reponses. $feedbackstructure = new mod_feedback_structure($feedback, $cm, $courseid); } } $responsestable = new mod_feedback_responses_table($feedbackstructure); $anonresponsestable = new mod_feedback_responses_anon_table($feedbackstructure); if ($responsestable->is_downloading()) { $responsestable->download(); } if ($anonresponsestable->is_downloading()) { $anonresponsestable->download(); } // Process course select form. $courseselectform = new mod_feedback_course_select_form($baseurl, $feedbackstructure, $feedback->course == SITEID); if ($data = $courseselectform->get_data()) { redirect(new moodle_url($baseurl, ['courseid' => $data->courseid])); }
feedback_init_feedback_session(); $id = required_param('id', PARAM_INT); if ($formdata = data_submitted() and !confirm_sesskey()) { print_error('invalidsesskey'); } $do_show = optional_param('do_show', 'edit', PARAM_ALPHA); $switchitemrequired = optional_param('switchitemrequired', false, PARAM_INT); $deleteitem = optional_param('deleteitem', false, PARAM_INT); $current_tab = $do_show; $url = new moodle_url('/mod/feedback/edit.php', array('id' => $id, 'do_show' => $do_show)); list($course, $cm) = get_course_and_cm_from_cmid($id, 'feedback'); $context = context_module::instance($cm->id); require_login($course, false, $cm); require_capability('mod/feedback:edititems', $context); $feedback = $PAGE->activityrecord; $feedbackstructure = new mod_feedback_structure($feedback, $cm); if ($switchitemrequired) { require_sesskey(); $items = $feedbackstructure->get_items(); if (isset($items[$switchitemrequired])) { feedback_switch_item_required($items[$switchitemrequired]); } redirect($url); } if ($deleteitem) { require_sesskey(); $items = $feedbackstructure->get_items(); if (isset($items[$deleteitem])) { feedback_delete_item($deleteitem); } redirect($url);