Courses: Fix delete course

pull/3432/head
Julio Montoya 5 years ago
parent f00a6ad014
commit 2fd89d0045
  1. 6
      src/CoreBundle/Migrations/Schema/V200/Version20170904145500.php
  2. 2
      src/CoreBundle/Migrations/Schema/V200/Version20170904173000.php
  3. 1
      src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php
  4. 2
      src/CourseBundle/Entity/CGroupRelUser.php
  5. 28
      src/CourseBundle/Entity/CQuizQuestionCategory.php
  6. 4
      src/CourseBundle/Entity/CQuizRelQuestion.php
  7. 2
      tests/behat/features/sessionManagement.feature
  8. 3
      tests/behat/features/toolExercise.feature

@ -145,7 +145,7 @@ class Version20170904145500 extends AbstractMigrationChamilo
if (false === $table->hasForeignKey('FK_1414369D91D79BD3')) { if (false === $table->hasForeignKey('FK_1414369D91D79BD3')) {
$this->addSql( $this->addSql(
'ALTER TABLE c_quiz_question_category ADD CONSTRAINT FK_1414369D91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);' 'ALTER TABLE c_quiz_question_category ADD CONSTRAINT FK_1414369D91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE;'
); );
} }
@ -165,14 +165,14 @@ class Version20170904145500 extends AbstractMigrationChamilo
if ($table->hasColumn('question_id')) { if ($table->hasColumn('question_id')) {
$this->addSql(' ALTER TABLE c_quiz_rel_question CHANGE exercice_id quiz_id INT DEFAULT NULL;'); $this->addSql(' ALTER TABLE c_quiz_rel_question CHANGE exercice_id quiz_id INT DEFAULT NULL;');
$this->addSql( $this->addSql(
'ALTER TABLE c_quiz_rel_question ADD CONSTRAINT FK_485736AC853CD175 FOREIGN KEY (quiz_id) REFERENCES c_quiz (iid);' 'ALTER TABLE c_quiz_rel_question ADD CONSTRAINT FK_485736AC853CD175 FOREIGN KEY (quiz_id) REFERENCES c_quiz (iid) ON DELETE CASCADE;'
); );
$this->addSql('CREATE INDEX exercise ON c_quiz_rel_question (quiz_id);'); $this->addSql('CREATE INDEX exercise ON c_quiz_rel_question (quiz_id);');
} }
if (false === $table->hasForeignKey('FK_485736AC1E27F6BF')) { if (false === $table->hasForeignKey('FK_485736AC1E27F6BF')) {
$this->addSql( $this->addSql(
'ALTER TABLE c_quiz_rel_question ADD CONSTRAINT FK_485736AC1E27F6BF FOREIGN KEY (question_id) REFERENCES c_quiz_question (iid)' 'ALTER TABLE c_quiz_rel_question ADD CONSTRAINT FK_485736AC1E27F6BF FOREIGN KEY (question_id) REFERENCES c_quiz_question (iid) ON DELETE CASCADE;'
); );
} }

@ -53,7 +53,7 @@ class Version20170904173000 extends AbstractMigrationChamilo
if (false === $table->hasForeignKey('FK_C5D3D49FFE54D947')) { if (false === $table->hasForeignKey('FK_C5D3D49FFE54D947')) {
$this->addSql( $this->addSql(
'ALTER TABLE c_group_rel_user ADD CONSTRAINT FK_C5D3D49FFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid)' 'ALTER TABLE c_group_rel_user ADD CONSTRAINT FK_C5D3D49FFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid) ON DELETE CASCADE;'
); );
} }
if (false === $table->hasIndex('IDX_C5D3D49FA76ED395')) { if (false === $table->hasIndex('IDX_C5D3D49FA76ED395')) {

@ -240,7 +240,6 @@ class ResourceNodeVoter extends Voter
}*/ }*/
} }
var_dump($link->getId());
// No link was found or not available. // No link was found or not available.
if (false === $linkFound) { if (false === $linkFound) {
return false; return false;

@ -47,7 +47,7 @@ class CGroupRelUser
/** /**
* @ORM\ManyToOne(targetEntity="CGroup", inversedBy="members") * @ORM\ManyToOne(targetEntity="CGroup", inversedBy="members")
* @ORM\JoinColumn(name="group_id", referencedColumnName="iid", nullable=false) * @ORM\JoinColumn(name="group_id", referencedColumnName="iid", nullable=false, onDelete="CASCADE")
*/ */
protected CGroup $group; protected CGroup $group;

@ -5,6 +5,7 @@
namespace Chamilo\CourseBundle\Entity; namespace Chamilo\CourseBundle\Entity;
use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\AbstractResource;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\ResourceInterface; use Chamilo\CoreBundle\Entity\ResourceInterface;
use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CourseBundle\Traits\ShowCourseResourcesInSessionTrait; use Chamilo\CourseBundle\Traits\ShowCourseResourcesInSessionTrait;
@ -52,9 +53,9 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac
/** /**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course") * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false) * @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
*/ */
protected $course; protected Course $course;
/** /**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", cascade={"persist"}) * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", cascade={"persist"})
@ -136,15 +137,12 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac
return $this->description; return $this->description;
} }
public function getCourse() public function getCourse(): Course
{ {
return $this->course; return $this->course;
} }
/** public function setCourse(Course $course): self
* @return CQuizQuestionCategory
*/
public function setCourse($course)
{ {
$this->course = $course; $this->course = $course;
@ -158,20 +156,15 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac
/** /**
* @param Session $session * @param Session $session
*
* @return CQuizQuestionCategory
*/ */
public function setSession($session) public function setSession($session): self
{ {
$this->session = $session; $this->session = $session;
return $this; return $this;
} }
/** public function hasSession(): bool
* @return bool
*/
public function hasSession()
{ {
return null !== $this->session; return null !== $this->session;
} }
@ -197,19 +190,14 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac
/** /**
* @param CQuizQuestion[]|Collection $questions * @param CQuizQuestion[]|Collection $questions
*
* @return CQuizQuestionCategory
*/ */
public function setQuestions($questions) public function setQuestions($questions): self
{ {
$this->questions = $questions; $this->questions = $questions;
return $this; return $this;
} }
/**
* Resource identifier.
*/
public function getResourceIdentifier(): int public function getResourceIdentifier(): int
{ {
return $this->getIid(); return $this->getIid();

@ -46,14 +46,14 @@ class CQuizRelQuestion
/** /**
* @Assert\NotBlank() * @Assert\NotBlank()
* @ORM\ManyToOne(targetEntity="CQuizQuestion", inversedBy="relQuizzes", cascade={"persist"}) * @ORM\ManyToOne(targetEntity="CQuizQuestion", inversedBy="relQuizzes", cascade={"persist"})
* @ORM\JoinColumn(name="question_id", referencedColumnName="iid") * @ORM\JoinColumn(name="question_id", referencedColumnName="iid", onDelete="CASCADE")
*/ */
protected CQuizQuestion $question; protected CQuizQuestion $question;
/** /**
* @Assert\NotBlank() * @Assert\NotBlank()
* @ORM\ManyToOne(targetEntity="CQuiz", inversedBy="questions", cascade={"persist"}) * @ORM\ManyToOne(targetEntity="CQuiz", inversedBy="questions", cascade={"persist"})
* @ORM\JoinColumn(name="quiz_id", referencedColumnName="iid") * @ORM\JoinColumn(name="quiz_id", referencedColumnName="iid", onDelete="CASCADE")
*/ */
protected CQuiz $quiz; protected CQuiz $quiz;

@ -38,7 +38,7 @@ Feature: Session management tool
And wait for the page to be loaded And wait for the page to be loaded
And I fill in ckeditor field "description" with "Description for Temp Session" And I fill in ckeditor field "description" with "Description for Temp Session"
And I press "submit" And I press "submit"
Then wait the page to be loaded when ready Then wait for the page to be loaded
Then I should see "Add courses to this session (Temp Session)" Then I should see "Add courses to this session (Temp Session)"
Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]" Then I select "TEMP (TEMP)" from "NoSessionCoursesList[]"
And I press "add_course" And I press "add_course"

@ -375,7 +375,8 @@ Feature: Exercise tool
Then I should see "Update successful" Then I should see "Update successful"
Scenario: Try exercise with categorized questions as student Scenario: Try exercise with categorized questions as student
Given I am a student Given I am not logged
And I am a student
And I am on course "TEMP" homepage in session "Session Exercise" And I am on course "TEMP" homepage in session "Session Exercise"
Then I should see "TEMP (Session Exercise)" Then I should see "TEMP (Session Exercise)"
And I am on "/main/exercise/exercise.php?cid=1" And I am on "/main/exercise/exercise.php?cid=1"

Loading…
Cancel
Save