コード例 #1
0
 /**
  * Creates fake Quiz and exercise in it
  * @param string $exerciseName Exercise's class name
  */
 public function createForPortalAction($exerciseName)
 {
     $quiz = new \_OurBrand_\Quiz\Domain\Model\Quiz();
     if (!$this->accessHelper->canUserCreateQuiz($this->currentUser, $quiz->getType())) {
         $this->throwStatus(403);
     }
     $quiz->setCreator($this->currentUser->getIdentifier());
     $quiz->setAuthor($this->currentUser->getName());
     $quiz->setPropertiesForPortalQuizWhenCreatesTheQuiz();
     $this->quizRepository->add($quiz);
     $exerciseType = null;
     $exerciseClassName = '\\_OurBrand_\\Quiz\\Domain\\Model\\Exercises\\' . $exerciseName;
     if (class_exists($exerciseClassName)) {
         $newExercise = $this->objectManager->get($exerciseClassName);
     } else {
         throw new \InvalidArgumentException('Model Class not defined: ' . $exerciseName);
     }
     $quiz->addExercise($newExercise);
     $quiz->touch();
     $newExercise->setType($exerciseType);
     $newExercise->setTitle('');
     $this->quizRepository->update($quiz);
     $this->persistenceManager->persistAll();
     $this->redirect('editForPortal', 'exercise', null, array('exercise' => $newExercise));
 }
コード例 #2
0
 /**
  * @param \_OurBrand_\Quiz\Domain\Model\Quiz $quiz
  */
 public function duplicateAction($quiz)
 {
     $newQuiz = $this->quizService->makeCopy($quiz);
     if ($newQuiz == null) {
         // TODO: User error handling.
     }
     $newQuiz->setCreator($this->currentUser->getIdentifier());
     $newQuiz->setIsDraft(true);
     $this->quizRepository->add($newQuiz);
     $this->persistenceManager->persistAll();
     $this->redirect('edit', null, null, array('quiz' => $newQuiz));
 }
コード例 #3
0
 /**
  * Generate testData
  *
  * This command inserts all the required data to start testing the student view of the Dictation exercise
  *
  * @return void
  */
 public function generateInsertCommand()
 {
     $quiz = new Quiz();
     $quiz->setTitle('Dictation Insert');
     $quiz->setAuthor('Test Instructor');
     $quiz->setCreator('instructor');
     $quiz->setIsDraft(false);
     $quiz->setType(0);
     $exercise = new InsertDictationExercise();
     $exercise->setTitle('Spelling and Grammer: Insert Dictation');
     $exercise->setDescription('Description');
     $snippet = new DictationSnippet();
     $snippet->setText('<span class="textShow">This is a very</span> <span class="textmark">marvellous</span> horse');
     $markedText = new MarkedText();
     $markedText->setText('marvellous');
     $snippet->addMarkedText($markedText);
     $exercise->addSnippet($snippet);
     $snippet = new DictationSnippet();
     $snippet->setText('<span class="textShow">This is another</span> <span class="textmark">sentence</span> horse');
     $markedText = new MarkedText();
     $markedText->setText('sentence');
     $snippet->addMarkedText($markedText);
     $exercise->addSnippet($snippet);
     $snippet = new DictationSnippet();
     $snippet->setText('<span class="textmark">Newest</span> <span class="textShow">more</span><span class="textmark">text</span>');
     $markedText = new MarkedText();
     $markedText->setText('Newest');
     $snippet->addMarkedText($markedText);
     $markedText = new MarkedText();
     $markedText->setText('text');
     $snippet->addMarkedText($markedText);
     $exercise->addSnippet($snippet);
     $quiz->addExercise($exercise);
     $this->quizRepository->add($quiz);
     //Create QuizSession
     $quizSession = new QuizSession();
     $quizSession->setQuiz($quiz);
     $quizSession->setInstructor('instructor');
     $quizSession->setStudentCanSeeSummaryAndReviewExercises(1);
     $quizSession->setShowGradeOnSummary(1);
     $this->quizSessionRepository->add($quizSession);
     //Create studentQuizSession
     $studentQuizSession = new StudentQuizSession();
     $studentQuizSession->setQuizSession($quizSession);
     $studentQuizSession->setStudent('student');
     $this->studentQuizSessionRepository->add($studentQuizSession);
 }
コード例 #4
0
 public function setUpQuiz()
 {
     $quiz = new \_OurBrand_\Quiz\Domain\Model\Quiz();
     $quiz->setAuthor('Tester');
     $quiz->setIsDraft(false);
     $quiz->setIsDeleted(false);
     $quiz->setCreator('tester');
     $quiz->setType(0);
     $quiz->setTitle('Test Quiz');
     $subject = $this->filterOptions['subjects']['Math'];
     $quiz->addSubject($subject);
     $level1 = $this->filterOptions['teamLevels']['4'];
     $quiz->addLevel($level1);
     $level2 = $this->filterOptions['teamLevels']['5'];
     $quiz->addLevel($level2);
     $category = $this->filterOptions['categories']['Geometry'];
     $quiz->setCategory($category);
     $quiz->addExercise($this->exercises['1']);
     $this->quizRepository->add($quiz);
     $quiz = new \_OurBrand_\Quiz\Domain\Model\Quiz();
     $quiz->setAuthor('Tester');
     $quiz->setIsDraft(false);
     $quiz->setIsDeleted(false);
     $quiz->setCreator('tester');
     $quiz->setType(0);
     $quiz->setTitle('Test Quiz2');
     $subject = $this->filterOptions['subjects']['Math'];
     $quiz->addSubject($subject);
     $level1 = $this->filterOptions['teamLevels']['4'];
     $quiz->addLevel($level1);
     $level2 = $this->filterOptions['teamLevels']['5'];
     $quiz->addLevel($level2);
     $category = $this->filterOptions['categories']['Geometry'];
     $quiz->setCategory($category);
     $this->quizRepository->add($quiz);
     $this->persistenceManager->persistAll();
 }