コード例 #1
0
     $sourceName = $source['name'];
     /* clear settings that are provided form entry */
     unset($source['id']);
     unset($source['sis_course_id']);
     unset($source['integration_id']);
     unset($source['name']);
     unset($source['course_code']);
     unset($source['account_id']);
     unset($source['enrollment_term_id']);
     unset($source['start_at']);
     unset($source['end_at']);
     unset($source['enrollments']);
     /* why nest this, I mean... really? */
     $source = array('course' => $source);
 }
 $courses = DataUtilities::loadCsvToArray('csv');
 if ($step == STEP_CONFIRM) {
     if (empty($courses)) {
         $toolbox->smarty_addMessage('Courses', 'No courses found in uploaded list.', NotificationMessage::ERROR);
         $step = STEP_INSTRUCTIONS;
     } else {
         foreach ($courses as $course) {
             /* duplicate course settings */
             $course = $toolbox->api_put("/courses/sis_course_id:{$course['course_id']}", $source);
             // TODO  nice to figure out navigation settings copy
             /* duplicate course content */
             $migration = $toolbox->api_post("courses/{$course['id']}/content_migrations", array('migration_type' => 'course_copy_importer', 'settings[source_course_id]' => $template));
             $toolbox->smarty_addMessage("<a target=\"_parent\" href=\"{$_SESSION[CANVAS_INSTANCE_URL]}/courses/{$course['id']}\">{$course['name']}</a>", "has been templated as a clone of <a target=\"_parent\" href=\"{$_SESSION[CANVAS_INSTANCE_URL]}/courses/{$sourceId}\">{$sourceName}</a>. Course content is being <a target=\"_parent\" href=\"{$_SESSION[CANVAS_INSTANCE_URL]}/courses/{$course['id']}/content_migrations\">migrated</a> right now.", NotificationMessage::GOOD);
         }
     }
 }
コード例 #2
0
ファイル: book-list.php プロジェクト: smtech/printable-forms
<?php

require_once 'common.inc.php';
use Battis\DataUtilities;
use smtech\StMarksSmarty\StMarksSmarty;
$smarty->enable(StMarksSmarty::MODULE_DATEPICKER);
if (empty($_FILES['csv'])) {
    $smarty->display('book-list/upload.tpl');
    exit;
} else {
    $data = DataUtilities::loadCsvToArray('csv');
    if ($data == false) {
        $smarty->addMessage('Missing File', 'You need to upload a CSV file for this to work!', NotificationMessage::DANGER);
        $smarty->display('book-list/upload.tpl');
        exit;
    }
    $sections = array();
    $section['metadata']['id'] = false;
    foreach ($data as $d) {
        if ($d['CourseID'] != $section['metadata']['id']) {
            if ($section['metadata']['id']) {
                $section['metadata']['id'] = preg_replace('/[^a-z0-9\\-]+/i', '', $section['metadata']['id']);
                $sections[$section['metadata']['id']] = $section;
            }
            $section = array();
            $section['metadata']['id'] = $d['CourseID'];
            foreach ($d as $column => $value) {
                switch ($column) {
                    case 'ClassName':
                        $section['metadata']['name'] = DataUtilities::titleCase($value);
                        break;
コード例 #3
0
<?php

require_once 'common.inc.php';
use Battis\DataUtilities;
use Battis\BootstrapSmarty\NotificationMessage;
define('STEP_INSTRUCTIONS', 1);
define('STEP_CONFIRM', 2);
define('STEP_UPDATE', 3);
$step = empty($_REQUEST['step']) ? STEP_INSTRUCTIONS : $_REQUEST['step'];
$ignoreCourseId = empty($_REQUEST['ignore_course_id']) ? false : $_REQUEST['ignore_course_id'];
switch ($step) {
    case STEP_CONFIRM:
        $sections = DataUtilities::loadCsvToArray('csv');
        if (empty($sections)) {
            $step = STEP_INSTRUCTIONS;
            $toolbox->smarty_addMessage('Empty section list', 'The uploaded CSV file contained no sections.', NotificationMessage::WARNING);
        }
        if ($step == STEP_CONFIRM) {
            $toolbox->smarty_assign(['fields' => array_keys($sections[0]), 'sections' => $sections, 'formHidden' => ['step' => STEP_UPDATE, 'ignore_course_id' => $ignoreCourseId]]);
            $toolbox->smarty_display(basename(__FILE__, '.php') . '/confirm.tpl');
            break;
        }
        /* flows into STEP_UPDATE */
    /* flows into STEP_UPDATE */
    case STEP_UPDATE:
        if ($step == STEP_UPDATE) {
            $links = [];
            $crosslist = [];
            $crosslistFail = [];
            foreach ($_REQUEST['sections'] as $section) {
                if (isset($section['batch-include']) && $section['batch-include'] == 'include') {