Beispiel #1
0
        if (!$existing) {
            error('Incorrect blog post id');
        }
        $post->id = $existing->id;
        $post->subject = $existing->subject;
        $post->summary = $existing->summary;
        $post->publishstate = $existing->publishstate;
        $post->format = $existing->format;
        $post->action = $action;
        $strformheading = get_string('updateentrywithid', 'blog');
        if ($ptags = records_to_menu(get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'default'), 'id', 'rawname')) {
            $post->ptags = implode(', ', $ptags);
        } else {
            $post->ptags = '';
        }
        if ($otags = records_to_menu(get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'official'), 'id', 'rawname')) {
            $post->otags = array_keys($otags);
        }
        break;
    default:
        error('Unknown action!');
}
// done here in order to allow deleting of posts with wrong user id above
if (!($user = get_record('user', 'id', $userid))) {
    error('Incorrect user id');
}
$navlinks = array();
$navlinks[] = array('name' => fullname($user), 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strblogs, 'link' => "{$CFG->wwwroot}/blog/index.php?userid={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strformheading, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
Beispiel #2
0
        $post->id = $existing->id;
        $post->subject = $existing->subject;
        $post->summary = $existing->summary;
        $post->publishstate = $existing->publishstate;
        $post->format = $existing->format;
        $post->action = $action;
        $strformheading = get_string('updateentrywithid', 'blog');
        if ($itemptags = get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'default')) {
            if ($ptags = records_to_menu($itemptags, 'id', 'rawname')) {
                $post->ptags = implode(', ', $ptags);
            } else {
                $post->ptags = '';
            }
        }
        if ($itemotags = get_item_tags('blog', $post->id, 'ti.ordering ASC', 'id,rawname', '', '', 'official')) {
            if ($otags = records_to_menu($itemotags, 'id', 'rawname')) {
                $post->otags = array_keys($otags);
            }
        }
        break;
    default:
        error('Unknown action!');
}
// done here in order to allow deleting of posts with wrong user id above
if (!($user = get_record('user', 'id', $userid))) {
    error('Incorrect user id');
}
$navlinks = array();
$navlinks[] = array('name' => fullname($user), 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strblogs, 'link' => "{$CFG->wwwroot}/blog/index.php?userid={$userid}", 'type' => 'misc');
$navlinks[] = array('name' => $strformheading, 'link' => null, 'type' => 'misc');
Beispiel #3
0
/**
 * Returns a CPD Metadata item as a list of id=>name pairs
 *
 * @param string $name	CPD Metadata item name
 * @return array
 */
function get_cpd_menu($name)
{
    $cpd_menu = null;
    switch ($name) {
        case 'years':
            $cpd_years = get_records('cpd_year', null, null, 'startdate asc, enddate asc');
            if ($cpd_years) {
                foreach ($cpd_years as $year) {
                    $cpd_menu[$year->id] = date("d/m/Y", $year->startdate) . " - " . date("d/m/Y", $year->enddate);
                }
            }
            break;
        case 'activity_types':
            $cpd_activity_types = get_records('cpd_activity_type', null, null, 'name asc');
            if ($cpd_activity_types) {
                $cpd_menu = records_to_menu($cpd_activity_types, 'id', 'name');
            }
            break;
        case 'statuses':
            $cpd_statuses = get_records('cpd_status', null, null, 'display_order asc');
            if ($cpd_statuses) {
                $cpd_menu = records_to_menu($cpd_statuses, 'id', 'name');
            }
            break;
    }
    return $cpd_menu;
}
function get_percent_adaptive($userid, $course)
{
    global $CFG;
    $logs = get_records_sql("\n            SELECT l.id, l.statusid, l.statusset\n            FROM {$CFG->prefix}attendance_log l\n            JOIN {$CFG->prefix}attendance_sessions s\n            ON l.sessionid = s.id\n            WHERE l.studentid = {$userid}\n            AND s.courseid  = {$course->id}\n            AND s.sessdate >= {$course->startdate}");
    $result = 0;
    if ($logs) {
        $stat_grades = records_to_menu(get_records('attendance_statuses', 'courseid', $course->id), 'id', 'grade');
        $percent = 0;
        foreach ($logs as $log) {
            $ids = array_flip(explode(',', $log->statusset));
            $grades = array_intersect_key($stat_grades, $ids);
            $delta = max($grades) - min($grades);
            $percent += $stat_grades[$log->statusid] / $delta;
        }
        $result = $percent / count($logs) * 100;
    }
    if (!($dp = grade_get_setting($course->id, 'decimalpoints'))) {
        $dp = $CFG->grade_decimalpoints;
    }
    return sprintf("%0.{$dp}f", $result);
}