示例#1
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;
 }
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $reportId = $input->getArgument('reportId');
     $name = $input->getOption('name');
     $description = $input->getOption('description');
     $year = $input->getOption('year');
     /* @var CurriculumInventoryReportInterface $report */
     $report = $this->reportManager->findOneBy(['id' => $reportId]);
     if (!$report) {
         throw new \Exception("No curriculum inventory report with id #{$reportId} was found.");
     }
     $newReport = $this->service->rollover($report, $name, $description, $year);
     //output message with the new courseId on success
     $output->writeln("The given report has been rolled over. The new report id is {$newReport->getId()}.");
 }
 /**
  * @param Registry $em
  * @param string $class
  * @param FormFactoryInterface $formFactory
  */
 public function __construct(Registry $em, $class, FormFactoryInterface $formFactory)
 {
     $this->formFactory = $formFactory;
     parent::__construct($em, $class);
 }
示例#4
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;
 }