Пример #1
0
<?php

require_once 'common.inc.php';
header('Location: assignments-overview.php?account=academics&start=2015-12-14&end=2015-12-19');
exit;
$cache = new Battis\HierarchicalSimpleCache($sql, basename(__FILE__, '.php'));
$courseId = $_SESSION['toolProvider']->user->getResourceLink()->settings['custom_canvas_course_id'];
/* get the list of students in this course */
$sections = $cache->getCache($courseId);
if ($sections === false) {
    $sections = $api->get("courses/{$courseId}/sections", array('include' => array('students')));
    $cache->setCache($courseId, $sections);
}
/* query all the assessments affecting those students */
$students = array();
foreach ($sections as $section) {
    foreach ($section['students'] as $student) {
        $students[] = $student['id'];
    }
}
$response = $sql->query("\n\tSELECT *\n\t\tFROM `due_dates` as `d`\n\t\t\tLEFT JOIN `assessments` as `a` ON `d`.`assignment` = `a`.`id`\n\t\tWHERE\n\t\t\t(`d`.`student` = '" . implode("' OR `d`.`student` = '", $students) . "')\n\t\t\tAND (`a`.`course` != '{$courseId}'\n\t\tORDER BY\n\t\t\t`d`.`due` ASC\n");
$assessments = array();
$dueDates = array();
while ($dueDate = $response->fetch_assoc()) {
    if (empty($assessments[$dueDate['assignment']])) {
        $assessments[$dueDate['assignment']] = unserialize($dueDate['a.data']);
    }
    $dueDates[] = array('student' => $dueDate['student']);
}
/* build a month grid */
$month = empty($_REQUEST['month']) ? date('m') : $_REQUEST['month'];
<?php

require_once 'common.inc.php';
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
$cache = new \Battis\HierarchicalSimpleCache($sql, $pluginMetadata['PLUGIN_ID']);
$cache->setLifetime(\Battis\HierarchicalSimpleCache::IMMORTAL_LIFETIME);
$rubrics = $cache->getCache($_REQUEST['assignment']);
if (!empty($rubrics)) {
    echo $rubrics;
}
exit;
use Battis\BootstrapSmarty\NotificationMessage;
$cache = new \Battis\HierarchicalSimpleCache($sql, basename(__DIR__));
$cache->pushKey(basename(__FILE__, '.php'));
define('STEP_INSTRUCTIONS', 1);
define('STEP_DOWNLOAD', 2);
$step = isset($_REQUEST['step']) ? $_REQUEST['step'] : STEP_INSTRUCTIONS;
$accounts = $toolbox->getAccountList();
$terms = $toolbox->getTermList();
switch ($step) {
    case STEP_DOWNLOAD:
        try {
            if (!empty($_REQUEST['term'])) {
                if (!empty($_REQUEST['account'])) {
                    $cache->pushKey($_REQUEST['account']);
                    $cache->pushKey($_REQUEST['term']);
                    $data = $cache->getCache('enrollments');
                    if (empty($data)) {
                        $courses = $toolbox->api_get("accounts/{$_REQUEST['account']}/courses", array('with_enrollments' => true, 'enrollment_term_id' => $_REQUEST['term']));
                        foreach ($courses as $course) {
                            $enrollments = $toolbox->api_get("courses/{$course['id']}/enrollments");
                            foreach ($enrollments as $enrollment) {
                                $data[] = array('user_id' => $enrollment['user_id'], 'sis_user_id' => $enrollment['user']['sis_user_id'], 'user[name]' => $enrollment['user']['name'], 'user[sortable_name]' => $enrollment['user']['sortable_name'], 'course_id' => $course['id'], 'sis_course_id' => $course['sis_course_id'], 'sis_section_id' => $enrollment['sis_section_id'], 'course[name]' => $course['name'], 'enrollment[role]' => $enrollment['role']);
                            }
                        }
                        $cache->setCache('enrollments', $data, 15 * 60);
                    }
                    $toolbox->smarty_assign('account', $_REQUEST['account']);
                    $toolbox->smarty_assign('term', $_REQUEST['term']);
                    $toolbox->smarty_assign('filename', date('Y-m-d_H-i-s') . '_' . preg_replace('/\\s/', '_', $accounts[$_REQUEST['account']]['name'] . '_' . $terms[$_REQUEST['term']]['name']) . '_enrollments');
                    $toolbox->smarty_assign('csv', $cache->getHierarchicalKey('enrollments'));
                } else {