/** * 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); } } }
/** * Adds common values to the table that do not change the number or order of entries and * are only needed when outputting or downloading data. */ protected function add_all_values_to_output() { $tablecolumns = array_keys($this->columns); $tableheaders = $this->headers; // Add all feedback response values. $items = $this->feedbackstructure->get_items(true); foreach ($items as $nr => $item) { $this->sql->fields .= ", v{$nr}.value AS val{$nr}"; $this->sql->from .= " LEFT OUTER JOIN {feedback_value} v{$nr} " . "ON v{$nr}.completed = c.id AND v{$nr}.item = :itemid{$nr}"; $this->sql->params["itemid{$nr}"] = $item->id; $tablecolumns[] = "val{$nr}"; $itemobj = feedback_get_item_class($item->typ); $tableheaders[] = $itemobj->get_display_name($item); } // Add 'Delete entry' column. if (!$this->is_downloading() && has_capability('mod/feedback:deletesubmissions', $this->get_context())) { $tablecolumns[] = 'deleteentry'; $tableheaders[] = ''; } $this->define_columns($tablecolumns); $this->define_headers($tableheaders); }
$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 //lstgroupid is the choosen id $mygroupid = false; $courseselectform->display(); // Show the summary. $summary = new mod_feedback\output\summary($feedbackstructure); echo $OUTPUT->render_from_template('mod_feedback/summary', $summary->export_for_template($OUTPUT)); // Get the items of the feedback. $items = $feedbackstructure->get_items(true); if ($courseitemfilter > 0) { $sumvalue = 'SUM(' . $DB->sql_cast_char2real('value', true) . ')'; $sql = "SELECT fv.course_id, c.shortname, {$sumvalue} AS sumvalue, COUNT(value) as countvalue\n FROM {feedback_value} fv, {course} c, {feedback_item} fi\n WHERE fv.course_id = c.id AND fi.id = fv.item AND fi.typ = ? AND fv.item = ?\n GROUP BY course_id, shortname\n ORDER BY sumvalue desc"; if ($courses = $DB->get_records_sql($sql, array($courseitemfiltertyp, $courseitemfilter))) { $item = $DB->get_record('feedback_item', array('id' => $courseitemfilter)); echo '<h4>' . $item->name . '</h4>'; echo '<div class="clearfix">'; echo '<table>'; echo '<tr><th>Course</th><th>Average</th></tr>'; foreach ($courses as $c) { $coursecontext = context_course::instance($c->course_id); $shortname = format_string($c->shortname, true, array('context' => $coursecontext)); echo '<tr>'; echo '<td>' . $shortname . '</td>'; echo '<td align="right">';
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); } // Process the create template form. $cancreatetemplates = has_capability('mod/feedback:createprivatetemplate', $context) || has_capability('mod/feedback:createpublictemplate', $context);