Пример #1
0
$navigation = array(array('name' => $blockname, 'link' => '', 'type' => 'title'), array('name' => $heading_main, 'link' => '', 'type' => 'title'));
// Some javascript
require_js($CFG->wwwroot . '/blocks/student_gradeviewer/functions.js');
// Start of the form output
print_header_simple($heading_main, '', build_navigation($navigation));
// An empty prequery and no admin means that they have no association
list($table, $prequery) = get_pre_query($USER->id);
if (empty($prequery) && !has_capability('block/student_gradeviewer:academicadmin', $context) && !has_capability('block/student_gradeviewer:sportsadmin', $context)) {
    echo '<div class="results">' . get_string('no_mentees', 'block_student_gradeviewer') . '<div>';
    print_footer();
    die;
}
// Used for paging the results
$per_page = optional_param('per_page', 10, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$components = cps_user_component::build_components();
if ($viewsports) {
    $components->components[] = new sports_drop_down(cps_transform_filter('sports'));
}
// Per page selector
$components->components[] = new results_drop_down($per_page);
$components->display_as_table($heading_main);
$where = $components->where_clause();
// Do a prequery to figure out if the table doesn't just print out
$threshold = get_config('', 'block_student_gradeviewer_threshold');
//Running a count on the pre query info
if (!empty($prequery) && empty($where)) {
    $sql = "SELECT COUNT(u.id) FROM {$CFG->prefix}block_courseprefs_users u {$table} WHERE " . $prequery;
    $count = count_records_sql($sql);
} else {
    $count = $threshold;
Пример #2
0
 public static function build_components($filter = null)
 {
     $inputs = $filter ? array_filter(cps_user_component::inputs(), $filter) : cps_user_component::inputs();
     $dropdowns = $filter ? array_filter(cps_user_component::drop_downs(), $filter) : cps_user_component::drop_downs();
     $components = array_merge(array_map(create_function('$input', '
         return new input_box($input, cps_transform_filter($input));
     '), $inputs), array_map(create_function('$drop_down', '
         $class = $drop_down . "_drop_down";
         return new $class(cps_transform_filter($drop_down));
     '), $dropdowns));
     return new cps_user_component_collection($components);
 }
Пример #3
0
 function __construct($course, $key, $id = null, $page = 0, $per_page = 50, $export = false)
 {
     if (!$id and $course) {
         $id = $course->id;
     }
     if ($course) {
         $this->courseid = $course->id;
     }
     $this->course = $course;
     $this->id = $id;
     $this->obj = $this->create_obj($id);
     $this->key = $key;
     $this->define_cps_user();
     $this->page = $page;
     $this->per_page = $per_page;
     $params = array('key' => $this->key, 'keyid' => $this->id, 'per_page' => $this->per_page);
     if ($this->courseid) {
         $params['id'] = $this->courseid;
     }
     $this->filters = cps_user_component::build_filters_from_array('', array_filter(array('section', 'source', 'date_referred', 'firstname', 'lastname'), array($this, 'prune_filters')), $params, array('section' => array('user' => $this->cps_user, 'course' => $course) + $this->section_params()));
     $this->baseurl = $this->filters->flatten_params();
     $this->perform_prune();
     $this->refresh_function_map();
     $this->mentor = $this->master_caps();
     $this->exporting = $export;
     if (!$this->is_capable()) {
         error(get_string('no_permission', 'block_student_gradeviewer'));
     }
 }
Пример #4
0
require_once $CFG->libdir . '/grade/grade_grade.php';
require_once $CFG->libdir . '/gradelib.php';
require_once $CFG->dirroot . '/grade/report/simple_grader/lib/simple_gradelib.php';
require_login();
// Course id required
$courseid = required_param('id', PARAM_INT);
$course = has_reporting_permission($courseid);
// I need Jquery for nice things
require_js(array($CFG->wwwroot . '/blocks/student_reporting/jquery.min.js', $CFG->wwwroot . '/blocks/student_reporting/functions.js'));
// Print the header and heading
$blockname = get_string('blockname', 'block_student_reporting');
$heading = get_string('select', 'block_student_reporting');
$navigation = array(array('name' => $course->shortname, 'link' => $CFG->wwwroot . '/course/view.php?id=' . $courseid, 'type' => 'title'), array('name' => $blockname, 'link' => '', 'type' => 'title'), array('name' => $heading, 'link' => '', 'type' => 'title'));
print_header_simple($heading, '', build_navigation($navigation));
print_heading_with_help($heading, 'select', 'block_student_reporting');
$filters = cps_user_component::build_filters('select.php', array('id' => $courseid), array('section' => array('course' => $course)));
$filters->display();
// Permission and dependencies aside, let's get to the logic
// Obtain CPS sections tied to this course idnumber
$user = CoursePrefsUser::findByUnique($USER->username);
$where = $filters->where_clause(create_function('$k,$w', '
            switch($k) {
                case "section": return "s." . $w;
                default: return "cpsu." . $w;
            }
'));
if (is_siteadmin($USER->id)) {
    $sections = cps_sections($course, $where['section']);
} else {
    if ($user) {
        $sections = $user->getSectionsForMoodleCourse($course);