Beispiel #1
0
 /**
  * Initialises table
  */
 protected function init()
 {
     $tablecolumns = array('userpic', 'fullname');
     $tableheaders = array(get_string('userpic'), get_string('fullnameuser'));
     $extrafields = get_extra_user_fields($this->get_context());
     $ufields = user_picture::fields('u', $extrafields, $this->useridfield);
     $fields = 'c.id, c.timemodified as completed_timemodified, c.courseid, ' . $ufields;
     $from = '{feedback_completed} c ' . 'JOIN {user} u ON u.id = c.userid AND u.deleted = :notdeleted';
     $where = 'c.anonymous_response = :anon
             AND c.feedback = :instance';
     if ($this->feedbackstructure->get_courseid()) {
         $where .= ' AND c.courseid = :courseid';
     }
     if ($this->is_downloading()) {
         // When downloading data:
         // Remove 'userpic' from downloaded data.
         array_shift($tablecolumns);
         array_shift($tableheaders);
         // Add all identity fields as separate columns.
         foreach ($extrafields as $field) {
             $fields .= ", u.{$field}";
             $tablecolumns[] = $field;
             $tableheaders[] = get_user_field_name($field);
         }
     }
     if ($this->feedbackstructure->get_feedback()->course == SITEID && !$this->feedbackstructure->get_courseid()) {
         $tablecolumns[] = 'courseid';
         $tableheaders[] = get_string('course');
     }
     $tablecolumns[] = 'completed_timemodified';
     $tableheaders[] = get_string('date');
     $this->define_columns($tablecolumns);
     $this->define_headers($tableheaders);
     $this->sortable(true, 'lastname', SORT_ASC);
     $this->collapsible(true);
     $this->set_attribute('id', 'showentrytable');
     $params = array();
     $params['anon'] = FEEDBACK_ANONYMOUS_NO;
     $params['instance'] = $this->feedbackstructure->get_feedback()->id;
     $params['notdeleted'] = 0;
     $params['courseid'] = $this->feedbackstructure->get_courseid();
     $group = groups_get_activity_group($this->feedbackstructure->get_cm(), true);
     if ($group) {
         $where .= ' AND c.userid IN (SELECT g.userid FROM {groups_members} g WHERE g.groupid = :group)';
         $params['group'] = $group;
     }
     $this->set_sql($fields, $from, $where, $params);
     $this->set_count_sql("SELECT COUNT(c.id) FROM {$from} WHERE {$where}", $params);
 }
Beispiel #2
0
            $shortname = format_string($c->shortname, true, array('context' => $coursecontext));
            echo '<tr>';
            echo '<td>' . $shortname . '</td>';
            echo '<td align="right">';
            echo format_float($c->sumvalue / $c->countvalue, 2);
            echo '</td>';
            echo '</tr>';
        }
        echo '</table>';
    } else {
        echo '<p>' . get_string('noresults') . '</p>';
    }
    echo '<p><a href="analysis_course.php?id=' . $id . '">';
    echo get_string('back');
    echo '</a></p>';
} else {
    // Print the items in an analysed form.
    foreach ($items as $item) {
        echo '<table class="analysis">';
        $itemobj = feedback_get_item_class($item->typ);
        $printnr = $feedback->autonumbering && $item->itemnr ? $item->itemnr . '.' : '';
        $itemobj->print_analysed($item, $printnr, $mygroupid, $feedbackstructure->get_courseid());
        if (preg_match('/rated$/i', $item->typ)) {
            $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 $OUTPUT->footer();
Beispiel #3
0
 /**
  * Returns the course where user was before taking the feedback.
  *
  * For feedbacks inside the course it will be the same as $this->get_feedback()->course.
  * For feedbacks on the frontpage it will be the same as $this->get_course_id()
  *
  * @return int
  */
 public function get_current_course_id()
 {
     return $this->structure->get_courseid() ?: $this->get_feedback()->course;
 }