コード例 #1
0
ファイル: ReportRollover.php プロジェクト: stopfstedt/ilios
 /**
  * Rolls over (clones) a given curriculum inventory report and a subset of its associated data points.
  * @param CurriculumInventoryReportInterface $report The report to roll over.
  * @param string|null $newName Name override for the rolled-over report.
  * @param string|null $newDescription Description override for the rolled-over report.
  * @param int|null $newYear Academic year override for the rolled-over report.
  * @return CurriculumInventoryReportInterface The report created during rollover.
  */
 public function rollover(CurriculumInventoryReportInterface $report, $newName = null, $newDescription = null, $newYear = null)
 {
     /* @var CurriculumInventoryReportInterface $newReport */
     $newReport = $this->reportManager->create();
     $newReport->setStartDate($report->getStartDate());
     $newReport->setEndDate($report->getEndDate());
     $newReport->setProgram($report->getProgram());
     if (isset($newName)) {
         $newReport->setName($newName);
     } else {
         $newReport->setName($report->getName());
     }
     if (isset($newDescription)) {
         $newReport->setDescription($newDescription);
     } else {
         $newReport->setDescription($report->getDescription());
     }
     if (isset($newYear)) {
         $newReport->setYear($newYear);
     } else {
         $newReport->setYear($report->getYear());
     }
     $this->reportManager->update($newReport, false, false);
     $newLevels = [];
     $levels = $report->getAcademicLevels();
     foreach ($levels as $level) {
         /* @var CurriculumInventoryAcademicLevelInterface $newLevel */
         $newLevel = $this->academicLevelManager->create();
         $newLevel->setLevel($level->getLevel());
         $newLevel->setName($level->getName());
         $newLevel->setDescription($level->getDescription());
         $newReport->addAcademicLevel($newLevel);
         $newLevel->setReport($newReport);
         $this->academicLevelManager->update($newLevel, false, false);
         $newLevels[$newLevel->getLevel()] = $newLevel;
     }
     // recursively rollover sequence blocks.
     $topLevelBlocks = $report->getSequenceBlocks()->filter(function (CurriculumInventorySequenceBlockInterface $block) {
         return is_null($block->getParent());
     });
     foreach ($topLevelBlocks as $block) {
         $this->rolloverSequenceBlock($block, $newReport, $newLevels, null);
     }
     $sequence = $report->getSequence();
     /* @var  CurriculumInventorySequenceInterface $newSequence */
     $newSequence = $this->sequenceManager->create();
     $newSequence->setDescription($sequence->getDescription());
     $newReport->setSequence($newSequence);
     $newSequence->setReport($newReport);
     $this->sequenceManager->update($newSequence, true, false);
     // flush here.
     // generate token after the fact and persist report once more.
     $newReport->generateToken();
     $this->reportManager->update($newReport, true, true);
     return $newReport;
 }
コード例 #2
0
ファイル: Exporter.php プロジェクト: Okami-/ilios
 /**
  * Creates the competency framework node and child-nodes, and adds them to a given parent node (<Expectations>).
  *
  * @param \DomDocument $dom
  * @param \DomElement $parentNode
  * @param CurriculumInventoryReportInterface $report
  * @param string $reportId
  * @param array $expectations
  */
 protected function createCompetencyFrameworkNode(\DomDocument $dom, \DomElement $parentNode, CurriculumInventoryReportInterface $report, $reportId, array $expectations)
 {
     // competency framework
     $competencyFrameworkNode = $dom->createElement('CompetencyFramework');
     $parentNode->appendChild($competencyFrameworkNode);
     // lom
     $lomNode = $dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'lom');
     $competencyFrameworkNode->appendChild($lomNode);
     $lomGeneralNode = $dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'general');
     $lomNode->appendChild($lomGeneralNode);
     $lomIdentifierNode = $dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'identifier');
     $lomGeneralNode->appendChild($lomIdentifierNode);
     $lomCatalogNode = $dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'catalog', 'URI');
     $lomIdentifierNode->appendChild($lomCatalogNode);
     $frameworkUri = "http://{$this->institutionDomain}/competency_framework/{$reportId}";
     $lomEntryNode = $dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'entry', $frameworkUri);
     $lomIdentifierNode->appendChild($lomEntryNode);
     $lomTitleNode = $dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'title');
     $lomGeneralNode->appendChild($lomTitleNode);
     $lomStringNode = $dom->createElementNS('http://ltsc.ieee.org/xsd/LOM', 'string');
     $lomTitleNode->appendChild($lomStringNode);
     $title = 'Competency Framework for ' . $report->getName();
     $lomStringNode->appendChild($dom->createTextNode($title));
     // includes
     $competencyIds = $expectations['framework']['includes']['pcrs_ids'];
     for ($i = 0, $n = count($competencyIds); $i < $n; $i++) {
         $id = $competencyIds[$i];
         $uri = $this->createPcrsUri($id);
         $this->createCompetencyFrameworkIncludesNode($dom, $competencyFrameworkNode, $uri);
     }
     $competencyIds = $expectations['framework']['includes']['program_objective_ids'];
     for ($i = 0, $n = count($competencyIds); $i < $n; $i++) {
         $id = $competencyIds[$i];
         $uri = $this->createCompetencyObjectUri($id, 'program_objective');
         $this->createCompetencyFrameworkIncludesNode($dom, $competencyFrameworkNode, $uri);
     }
     $competencyIds = $expectations['framework']['includes']['course_objective_ids'];
     for ($i = 0, $n = count($competencyIds); $i < $n; $i++) {
         $id = $competencyIds[$i];
         $uri = $this->createCompetencyObjectUri($id, 'course_objective');
         $this->createCompetencyFrameworkIncludesNode($dom, $competencyFrameworkNode, $uri);
     }
     $competencyIds = $expectations['framework']['includes']['session_objective_ids'];
     for ($i = 0, $n = count($competencyIds); $i < $n; $i++) {
         $id = $competencyIds[$i];
         $uri = $this->createCompetencyObjectUri($id, 'session_objective');
         $this->createCompetencyFrameworkIncludesNode($dom, $competencyFrameworkNode, $uri);
     }
     // relations
     $relations = $expectations['framework']['relations']['program_objectives_to_pcrs'];
     for ($i = 0, $n = count($relations); $i < $n; $i++) {
         $relation = $relations[$i];
         $relUri1 = $this->createCompetencyObjectUri($relation['rel1'], 'program_objective');
         $relUri2 = $this->createPcrsUri($relation['rel2']);
         $relationshipUri = $this->createRelationshipUri('related');
         $this->createCompetencyFrameworkRelationNode($dom, $competencyFrameworkNode, $relUri2, $relUri1, $relationshipUri);
     }
     $relations = $expectations['framework']['relations']['course_objectives_to_program_objectives'];
     for ($i = 0, $n = count($relations); $i < $n; $i++) {
         $relation = $relations[$i];
         $relUri1 = $this->createCompetencyObjectUri($relation['rel1'], 'program_objective');
         $relUri2 = $this->createCompetencyObjectUri($relation['rel2'], 'course_objective');
         $relationshipUri = $this->createRelationshipUri('narrower');
         $this->createCompetencyFrameworkRelationNode($dom, $competencyFrameworkNode, $relUri1, $relUri2, $relationshipUri);
     }
     $relations = $expectations['framework']['relations']['session_objectives_to_course_objectives'];
     for ($i = 0, $n = count($relations); $i < $n; $i++) {
         $relation = $relations[$i];
         $relUri1 = $this->createCompetencyObjectUri($relation['rel1'], 'course_objective');
         $relUri2 = $this->createCompetencyObjectUri($relation['rel2'], 'session_objective');
         $relationshipUri = $this->createRelationshipUri('narrower');
         $this->createCompetencyFrameworkRelationNode($dom, $competencyFrameworkNode, $relUri1, $relUri2, $relationshipUri);
     }
 }
コード例 #3
0
 /**
  * @param CurriculumInventoryReportInterface $report
  * @param Router $router
  */
 public function __construct(CurriculumInventoryReportInterface $report, Router $router)
 {
     $this->absoluteFileUri = $router->generate('ilios_core_downloadcurriculuminventoryreport', ['token' => $report->getToken()], UrlGenerator::ABSOLUTE_URL);
     $this->id = $report->getId();
     $this->name = $report->getName();
     $this->description = $report->getDescription();
     $this->year = $report->getYear();
     $this->startDate = $report->getStartDate();
     $this->endDate = $report->getEndDate();
     $this->export = (string) $report->getExport();
     $this->sequence = (string) $report->getSequence();
     $this->program = (string) $report->getProgram();
     $sequenceBlockIds = $report->getSequenceBlocks()->map(function (CurriculumInventorySequenceBlockInterface $block) {
         return (string) $block;
     });
     $this->sequenceBlocks = $sequenceBlockIds->toArray();
     $academicLevelIds = $report->getAcademicLevels()->map(function (CurriculumInventoryAcademicLevelInterface $level) {
         return (string) $level;
     });
     $this->academicLevels = $academicLevelIds->toArray();
 }