/**
  * Retrieves the report document for a given curriculum inventory report.
  *
  * @param CurriculumInventoryReportInterface $report
  * @return string
  */
 protected function getExportedDocument(CurriculumInventoryReportInterface $report)
 {
     // check if the report has been exported.
     // if so, pull the document from the database.
     $export = $this->getCurriculumInventoryExportHandler()->findCurriculumInventoryExportBy(['report' => $report->getId()]);
     if ($export) {
         return $export->getDocument();
     }
     // otherwise, generate a document on the fly.
     return $this->generateReportDocument($report);
 }
 /**
  * Retrieves the report document for a given curriculum inventory report.
  *
  * @param CurriculumInventoryReportInterface $report
  * @return string
  */
 protected function getExportedDocument(CurriculumInventoryReportInterface $report)
 {
     // check if the report has been exported.
     // if so, pull the document from the database.
     $manager = $this->container->get('ilioscore.curriculuminventoryexport.manager');
     $export = $manager->findOneBy(['report' => $report->getId()]);
     if ($export) {
         return $export->getDocument();
     }
     // otherwise, generate a document on the fly.
     return $this->generateReportDocument($report);
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * 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);
     }
 }
 /**
  * @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();
 }
 /**
  * @param CurriculumInventoryReportInterface $report
  * @param UserInterface $user
  * @return bool
  */
 protected function isCreateGranted($report, $user)
 {
     // Only grant CREATE, permissions to users with at least one of
     // 'Course Director' and 'Developer' roles.
     // - and -
     // the user must be associated with the school owning the report's program
     // either by its primary school attribute
     //     - or - by WRITE rights for the school
     // via the permissions system.
     return $this->userHasRole($user, ['Course Director', 'Developer']) && ($this->schoolsAreIdentical($user->getSchool(), $report->getProgram()->getSchool()) || $this->permissionManager->userHasWritePermissionToSchool($user, $report->getProgram()->getSchool()));
 }
 /**
  * @return int
  */
 public function getId()
 {
     return $this->report->getId();
 }
    /**
     * Retrieves a list of events (derived from published sessions/offerings and independent learning sessions)
     * in a given curriculum inventory report.
     *
     * @param CurriculumInventoryReportInterface $report
     * @return array An assoc. array of assoc. arrays, each item representing an event, keyed off by event id.
     */
    protected function getEventsFromSessionOfferings(CurriculumInventoryReportInterface $report)
    {
        $rhett = [];
        $sql = <<<EOL
SELECT
  s.session_id AS 'event_id',
  s.title,
  sd.description,
  stxam.method_id,
  st.assessment AS is_assessment_method,
  ao.name AS assessment_option_name,
  sbs.count_offerings_once,
  o.start_date,
  o.end_date
FROM
  `session` s
  JOIN session_type st ON st.session_type_id = s.session_type_id
  JOIN course c ON c.course_id = s.course_id
  JOIN curriculum_inventory_sequence_block sb ON sb.course_id = c.course_id
  LEFT JOIN offering o ON o.session_id = s.session_id AND o.deleted = 0
  LEFT JOIN session_description sd ON sd.session_id = s.session_id
  LEFT JOIN session_type_x_aamc_method stxam ON stxam.session_type_id = st.session_type_id
  LEFT JOIN assessment_option ao ON ao.assessment_option_id = st.assessment_option_id
  LEFT JOIN ilm_session_facet sf ON sf.session_id = s.session_id
  LEFT JOIN curriculum_inventory_sequence_block_session sbs ON sbs.session_id = s.session_id
WHERE
  c.deleted = 0
  AND s.deleted = 0
  AND s.publish_event_id IS NOT NULL
  AND sf.ilm_session_facet_id IS NULL
  AND sb.report_id = :report_id
ORDER BY
  s.session_id
EOL;
        $conn = $this->getEntityManager()->getConnection();
        $stmt = $conn->prepare($sql);
        $stmt->bindValue("report_id", $report->getId());
        $stmt->execute();
        $rows = $stmt->fetchAll();
        foreach ($rows as $row) {
            $row['duration'] = 0;
            if ($row['start_date']) {
                $startDate = new \Datetime($row['start_date'], new \DateTimeZone('UTC'));
                $endDate = new \DateTime($row['end_date'], new \DateTimeZone('UTC'));
                $duration = floor(($endDate->getTimestamp() - $startDate->getTimestamp()) / 60);
                $row['duration'] = $duration;
            }
            if (!array_key_exists($row['event_id'], $rhett)) {
                $rhett[$row['event_id']] = $row;
            } else {
                if ($row['count_offerings_once']) {
                    if ($rhett[$row['event_id']]['duration'] < $row['duration']) {
                        $rhett[$row['event_id']]['duration'] = $row['duration'];
                    }
                } else {
                    $rhett[$row['event_id']]['duration'] += $row['duration'];
                }
            }
        }
        array_walk($rhett, function (&$row) {
            unset($row['count_offerings_once']);
            unset($row['start_date']);
            unset($row['end_date']);
        });
        $stmt->closeCursor();
        return $rhett;
    }