oat-sa/oneroster-import

OneRoster PHP 导入

v1.1.0 2019-03-28 16:04 UTC

This package is auto-updated.

Last update: 2024-09-16 16:32:06 UTC


README

Codacy Badge Codacy Badge

使用 OneRoster V1.1 标准导入 CSV 文件

有关该标准的更多信息,请参阅以下链接

http://www.imsglobal.org/oneroster-v11-final-csv-tables

本仓库的范围是导入文件并根据 v1 标准验证字段。字段的 json 配置文件可在 /config/v1/ 文件夹中找到

设置 InMemoryStorage
$fileHandler = new FileHandler();
$importService = new ImportService($fileHandler);
$results = $importService->importMultiple(__DIR__ . '/../data/samples/oneRoster1.0/');

$storage = new InMemoryStorage($results);
设置 CsvStorage
$fileHandler = new FileHandler();
$importService = new ImportService($fileHandler);
$importService->setPathToFolder(__DIR__ . '/../../data/samples/OneRosterv1p1BaseCSV/');

$storage = new CsvStorage($importService);
导入后使用实体的示例。

1. 设置实体仓库

$entityRepository = new EntityRepository($storage, $relationConfig);

2. 获取实体

// get all organisation
$orgs = $entityRepository->getAll(Organisation::class);

// get one organisation
$org = $entityRepository->get('12345', Organisation::class);

$org->getId();
//return id of entity
$org->getData();
//return the data after format (array)

3. 获取相关实体

$oneOrg->getEnrollments();
// return all enrollments assign to organisation.

循环

$oneOrg === $oneOrg->getClasses()->first()->getOrg();

有关关系的更多信息,请参阅 config/v1/relations.json