/** * Generate new subjects * * This command inserts new Subject records into the database. */ public function subjectsCommand() { $subjects = $this->generateSubjectsData(); if (is_array($subjects) && count($subjects) > 0) { $oldSubjects = $this->subjectRepository->findAll(); $oldNotInNew = array(); foreach ($oldSubjects as $oldSubject) { $i = 0; foreach ($subjects as $subject) { if (trim(strtolower($subject['title'])) == trim(strtolower($oldSubject->getTitle()))) { $i++; } } if ($i === 0) { $oldNotInNew[] = $oldSubject; } } if (is_array($oldNotInNew) && count($oldNotInNew) > 0) { foreach ($oldNotInNew as $oldSubject) { $this->outputLine('Subject with name "%s" is in database, but is NOT in the generate list', array($oldSubject->getTitle())); } } foreach ($subjects as $subject) { if (isset($subject['title']) == false) { continue; } $title = trim($subject['title']); if ($title !== '' && $this->subjectRepository->countByTitle($title) == 0) { $isLanguage = intval($subject['isLanguage']); $subject = new Subject(); $subject->setTitle($title); $subject->setIsLanguage($isLanguage); // @TODO : translations? $this->subjectRepository->add($subject); $this->outputLine('Subject with name "%s" added to the database.', array($title)); } else { $this->outputLine('Subject with name "%s" found, skipping..', array($title)); } } } }
/** * Updates Quiz before updating Exercise. This function is needed when user saves Exercise for Portal * @param \_OurBrand_\Quiz\Domain\Model\Quiz $quiz * @param array $quizArguments */ public function updateQuizBeforeUpdatingExercise($quiz, $quizArguments) { $quizArguments['subject'] = $this->subjectRepository->findByIdentifier($quizArguments['subject']); $quiz->setPropertiesForPortalQuizWhenEditsTheExercise($quizArguments); $this->quizRepository->update($quiz); }
/** * A place where the editors can type in data so we dont have to. * */ public function editExerciseSkillCategoryAction(\_OurBrand_\Quiz\Domain\Model\ExerciseSkillCategory $exerciseSkillCategory) { $subjects = $this->subjectRepository->findAll(); $this->view->assign('subjects', $subjects); $this->view->assign('exerciseSkillCategory', $exerciseSkillCategory); }