コード例 #1
0
 public function notesFormSucceeded(Form $form, $values)
 {
     if (!$this->user->isAllowed('user', 'editNotes')) {
         throw new BadRequestException('You cannot edit user\'s notes.', 403);
     }
     $this->enrollment->notes = $values->notes;
     $this->enrollment->hiddenNotes = $values->hiddenNotes;
     $this->enrollment->scoreAdjustment = $this->calcScoreAdjustment($values->notes);
     $this->enrollmentRepository->persist($this->enrollment);
     $this->redirect('User:default#enrollment-' . $this->enrollment->id, $this->enrollment->user->id);
 }
コード例 #2
0
 public function setupCourseRole()
 {
     $roles = $this->user->identity->roles;
     foreach ($roles as $key => $role) {
         if (strpos($role, 'course-') === 0) {
             unset($roles[$key]);
         }
     }
     if (is_null($this->courseRegistry)) {
         throw new Exception('Course is not defined.');
         return;
     }
     if (is_null($this->userInfo)) {
         throw new Exception('User is not defined');
         return;
     }
     $courseRole = $this->enrollmentRepository->getRoleInCourse($this->userInfo, $this->courseRegistry->course);
     if (!is_null($courseRole) && $courseRole) {
         $roles[] = 'course-' . $courseRole;
     }
     $this->user->identity->roles = $roles;
 }