Example #1
0
 /**
  * Retrieves a curriculum inventory in a data structure that lends itself for an easy transformation into
  * XML-formatted report.
  *
  * @param CurriculumInventoryReportInterface $invReport The report object.
  * @return array An associated array, containing the inventory.
  *     Data is keyed off by:
  *         'report' ... The inventory report entity.
  *         'institution' ... An object representing the curriculum inventory's owning institution
  *         'events' ... An array of events, keyed off by event id. Each event is represented as assoc. array.
  *         'expectations' ... An associative array of arrays, each sub-array containing a
  *                            list of a different type of "competency object" within the curriculum.
  *                            These types are program objectives, course objectives and session objectives.
  *                            The keys for these type-specific sub-arrays are:
  *             'program_objectives'
  *             'course_objectives'
  *             'session_objectives'
  *             'framework' ... The competency framework data set.
  *                 'includes' ... Identifiers of the various competency objects referenced in the framework.
  *                     'pcrs_ids'
  *                     'program_objective_ids'
  *                     'course_objective_ids'
  *                     'session_objective_ids'
  *                 'relations' ... Relations between the various competencies within the framework
  *                     'program_objectives_to_pcrs'
  *                     'course_objectives_to_program_objectives'
  *                     'session_objectives_to_course_objectives'
  *         'sequence_block_references' ...relationships maps between sequence blocks and other curricular entities.
  *             'events' ... maps sequence blocks to events
  *             'competency_objects' .. maps sequence blocks to competency objects
  *
  * @throws \Exception
  */
 public function getCurriculumInventory(CurriculumInventoryReportInterface $invReport)
 {
     // report validation
     $program = $invReport->getProgram();
     if (!$program) {
         throw new \Exception('No program found for report with id  ' . $invReport->getId() . '.');
     }
     $school = $program->getSchool();
     if (!$school) {
         throw new \Exception('No school found for program with id = ' . $program->getId() . '.');
     }
     /** @var CurriculumInventoryInstitutionInterface $institution */
     $institution = $this->institutionManager->findOneBy(['school' => $school->getId()]);
     if (!$institution) {
         throw new \Exception('No curriculum inventory institution found for school with id = ' . $school->getId() . '.');
     }
     $events = $this->reportManager->getEvents($invReport);
     $keywords = $this->reportManager->getEventKeywords($invReport);
     $resourceTypes = $this->reportManager->getEventResourceTypes($invReport);
     $eventRefsForSeqBlocks = $this->reportManager->getEventReferencesForSequenceBlocks($invReport);
     $programObjectives = $this->reportManager->getProgramObjectives($invReport);
     $sessionObjectives = $this->reportManager->getSessionObjectives($invReport);
     $courseObjectives = $this->reportManager->getCourseObjectives($invReport);
     $compObjRefsForSeqBlocks = $this->reportManager->getCompetencyObjectReferencesForSequenceBlocks($invReport);
     $compRefsForEvents = $this->reportManager->getCompetencyObjectReferencesForEvents($invReport);
     // The various objective type are all "Competency Objects" in the context of reporting the curriculum inventory.
     // The are grouped in the "Expectations" section of the report, lump 'em together here.
     $expectations = [];
     $expectations['program_objectives'] = $programObjectives;
     $expectations['session_objectives'] = $sessionObjectives;
     $expectations['course_objectives'] = $courseObjectives;
     // Build out the competency framework information and added to $expectations.
     $pcrs = $this->reportManager->getPcrs($invReport);
     $pcrsIds = array_keys($pcrs);
     $programObjectiveIds = array_keys($programObjectives);
     $courseObjectiveIds = array_keys($courseObjectives);
     $sessionObjectiveIds = array_keys($sessionObjectives);
     $includes = ['pcrs_ids' => [], 'program_objective_ids' => [], 'course_objective_ids' => [], 'session_objective_ids' => []];
     $relations = ['program_objectives_to_pcrs' => [], 'course_objectives_to_program_objectives' => [], 'session_objectives_to_course_objectives' => []];
     $rel = $this->reportManager->getProgramObjectivesToPcrsRelations($programObjectiveIds, $pcrsIds);
     $relations['program_objectives_to_pcrs'] = $rel['relations'];
     $includes['pcrs_ids'] = $rel['pcrs_ids'];
     $includes['program_objective_ids'] = $rel['program_objective_ids'];
     $rel = $this->reportManager->getCourseObjectivesToProgramObjectivesRelations($courseObjectiveIds, $programObjectiveIds);
     $relations['course_objectives_to_program_objectives'] = $rel['relations'];
     $includes['program_objective_ids'] = array_values(array_unique(array_merge($includes['program_objective_ids'], $rel['program_objective_ids'])));
     $includes['course_objective_ids'] = $rel['course_objective_ids'];
     $rel = $this->reportManager->getSessionObjectivesToCourseObjectivesRelations($sessionObjectiveIds, $courseObjectiveIds);
     $relations['session_objectives_to_course_objectives'] = $rel['relations'];
     $includes['course_objective_ids'] = array_values(array_unique(array_merge($includes['course_objective_ids'], $rel['course_objective_ids'])));
     $includes['session_objective_ids'] = $rel['session_objective_ids'];
     $expectations['framework'] = ['includes' => $includes, 'relations' => $relations];
     //
     // transmogrify inventory data for reporting and fill in the blanks
     //
     $events = $this->addKeywordsToEvents($events, $keywords);
     $events = $this->addResourceTypesToEvents($events, $resourceTypes);
     $events = $this->addCompetencyObjectReferencesToEvents($events, $compRefsForEvents);
     //
     // aggregate inventory into single return-array
     //
     $rhett = [];
     $rhett['report'] = $invReport;
     $rhett['expectations'] = $expectations;
     $rhett['institution'] = $institution;
     $rhett['events'] = $events;
     $rhett['sequence_block_references'] = ['events' => $eventRefsForSeqBlocks, 'competency_objects' => $compObjRefsForSeqBlocks];
     return $rhett;
 }