| Total Complexity | 101 |
| Total Lines | 1380 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Course often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Course, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 36 | class Course extends AbstractResource implements ResourceInterface |
||
| 37 | { |
||
| 38 | public const CLOSED = 0; |
||
| 39 | public const REGISTERED = 1; |
||
| 40 | public const OPEN_PLATFORM = 2; |
||
| 41 | public const OPEN_WORLD = 3; |
||
| 42 | public const HIDDEN = 4; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var int |
||
| 46 | * |
||
| 47 | * @ORM\Column(name="id", type="integer", nullable=false, unique=false) |
||
| 48 | * @ORM\Id |
||
| 49 | * @ORM\GeneratedValue(strategy="AUTO") |
||
| 50 | */ |
||
| 51 | protected $id; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * @var string |
||
| 55 | * |
||
| 56 | * @Assert\NotBlank() |
||
| 57 | * |
||
| 58 | * @ORM\Column(name="title", type="string", length=250, nullable=true, unique=false) |
||
| 59 | */ |
||
| 60 | protected $title; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * "orphanRemoval" is needed to delete the CourseRelUser relation |
||
| 64 | * in the CourseAdmin class. The setUsers, getUsers, removeUsers and |
||
| 65 | * addUsers methods need to be added. |
||
| 66 | * |
||
| 67 | * @ORM\OneToMany(targetEntity="CourseRelUser", mappedBy="course", cascade={"persist"}, orphanRemoval=true) |
||
| 68 | */ |
||
| 69 | protected $users; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @ORM\OneToMany(targetEntity="AccessUrlRelCourse", mappedBy="course", cascade={"persist", "remove"}, orphanRemoval=true) |
||
| 73 | */ |
||
| 74 | protected $urls; |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @ORM\OneToMany(targetEntity="SessionRelCourse", mappedBy="course", cascade={"persist", "remove"}) |
||
| 78 | */ |
||
| 79 | protected $sessions; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @ORM\OneToMany(targetEntity="SessionRelCourseRelUser", mappedBy="course", cascade={"persist", "remove"}) |
||
| 83 | */ |
||
| 84 | protected $sessionUserSubscriptions; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CGroupInfo", mappedBy="course", cascade={"persist", "remove"}) |
||
| 88 | */ |
||
| 89 | protected $groups; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="course") |
||
| 93 | */ |
||
| 94 | //protected $items; |
||
| 95 | |||
| 96 | /** |
||
| 97 | * @var ArrayCollection |
||
| 98 | * |
||
| 99 | * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CTool", mappedBy="course", cascade={"persist", "remove"}) |
||
| 100 | */ |
||
| 101 | protected $tools; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var Session |
||
| 105 | */ |
||
| 106 | protected $currentSession; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var AccessUrl |
||
| 110 | */ |
||
| 111 | protected $currentUrl; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @ORM\OneToMany(targetEntity="Chamilo\SkillBundle\Entity\SkillRelCourse", mappedBy="course", cascade={"persist", "remove"}) |
||
| 115 | */ |
||
| 116 | protected $skills; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", mappedBy="course", cascade={"persist", "remove"}) |
||
| 120 | */ |
||
| 121 | protected $issuedSkills; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookCategory", mappedBy="course", cascade={"persist", "remove"}) |
||
| 125 | */ |
||
| 126 | protected $gradebookCategories; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookEvaluation", mappedBy="course", cascade={"persist", "remove"}) |
||
| 130 | */ |
||
| 131 | protected $gradebookEvaluations; |
||
| 132 | |||
| 133 | /** |
||
| 134 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\GradebookLink", mappedBy="course", cascade={"persist", "remove"}) |
||
| 135 | */ |
||
| 136 | protected $gradebookLinks; |
||
| 137 | |||
| 138 | /** |
||
| 139 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\TrackEHotspot", mappedBy="course", cascade={"persist", "remove"}) |
||
| 140 | */ |
||
| 141 | protected $trackEHotspots; |
||
| 142 | |||
| 143 | /** |
||
| 144 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\TrackEAttempt", mappedBy="course", cascade={"persist", "remove"}) |
||
| 145 | */ |
||
| 146 | protected $trackEAttempts; |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SearchEngineRef", mappedBy="course", cascade={"persist", "remove"}) |
||
| 150 | */ |
||
| 151 | protected $searchEngineRefs; |
||
| 152 | |||
| 153 | /** |
||
| 154 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Templates", mappedBy="course", cascade={"persist", "remove"}) |
||
| 155 | */ |
||
| 156 | protected $templates; |
||
| 157 | |||
| 158 | /** |
||
| 159 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceLink", mappedBy="course", cascade={"remove"}, orphanRemoval=true) |
||
| 160 | */ |
||
| 161 | protected $resourceLinks; |
||
| 162 | |||
| 163 | /** |
||
| 164 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SpecificFieldValues", mappedBy="course") |
||
| 165 | */ |
||
| 166 | //protected $specificFieldValues; |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SharedSurvey", mappedBy="course") |
||
| 170 | */ |
||
| 171 | //protected $sharedSurveys; |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @var string |
||
| 175 | * |
||
| 176 | * @Gedmo\Slug( |
||
| 177 | * fields={"title"}, |
||
| 178 | * updatable = false, |
||
| 179 | * unique = true, |
||
| 180 | * style = "upper" |
||
| 181 | * ) |
||
| 182 | * @ORM\Column(name="code", type="string", length=40, nullable=false, unique=true) |
||
| 183 | */ |
||
| 184 | protected $code; |
||
| 185 | |||
| 186 | /** |
||
| 187 | * @var string |
||
| 188 | * |
||
| 189 | * @ORM\Column(name="directory", type="string", length=40, nullable=true, unique=false) |
||
| 190 | */ |
||
| 191 | protected $directory; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @var string |
||
| 195 | * |
||
| 196 | * @ORM\Column(name="course_language", type="string", length=20, nullable=true, unique=false) |
||
| 197 | */ |
||
| 198 | protected $courseLanguage; |
||
| 199 | |||
| 200 | /** |
||
| 201 | * @var string |
||
| 202 | * |
||
| 203 | * @ORM\Column(name="description", type="text", nullable=true, unique=false) |
||
| 204 | */ |
||
| 205 | protected $description; |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @var string |
||
| 209 | * |
||
| 210 | * @ORM\Column(name="category_code", type="string", length=40, nullable=true, unique=false) |
||
| 211 | */ |
||
| 212 | protected $categoryCode; |
||
| 213 | |||
| 214 | /** |
||
| 215 | * @var int |
||
| 216 | * |
||
| 217 | * @Assert\NotBlank() |
||
| 218 | * |
||
| 219 | * @ORM\Column(name="visibility", type="integer", nullable=true, unique=false) |
||
| 220 | */ |
||
| 221 | protected $visibility; |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @var int |
||
| 225 | * |
||
| 226 | * @ORM\Column(name="show_score", type="integer", nullable=true, unique=false) |
||
| 227 | */ |
||
| 228 | protected $showScore; |
||
| 229 | |||
| 230 | /** |
||
| 231 | * @var string |
||
| 232 | * |
||
| 233 | * @ORM\Column(name="tutor_name", type="string", length=200, nullable=true, unique=false) |
||
| 234 | */ |
||
| 235 | protected $tutorName; |
||
| 236 | |||
| 237 | /** |
||
| 238 | * @var string |
||
| 239 | * |
||
| 240 | * @ORM\Column(name="visual_code", type="string", length=40, nullable=true, unique=false) |
||
| 241 | */ |
||
| 242 | protected $visualCode; |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @var string |
||
| 246 | * |
||
| 247 | * @ORM\Column(name="department_name", type="string", length=30, nullable=true, unique=false) |
||
| 248 | */ |
||
| 249 | protected $departmentName; |
||
| 250 | |||
| 251 | /** |
||
| 252 | * @var string |
||
| 253 | * |
||
| 254 | * @Assert\Url() |
||
| 255 | * |
||
| 256 | * @ORM\Column(name="department_url", type="string", length=180, nullable=true, unique=false) |
||
| 257 | */ |
||
| 258 | protected $departmentUrl; |
||
| 259 | |||
| 260 | /** |
||
| 261 | * @var int |
||
| 262 | * |
||
| 263 | * @ORM\Column(name="disk_quota", type="bigint", nullable=true, unique=false) |
||
| 264 | */ |
||
| 265 | protected $diskQuota; |
||
| 266 | |||
| 267 | /** |
||
| 268 | * @var \DateTime |
||
| 269 | * |
||
| 270 | * @ORM\Column(name="last_visit", type="datetime", nullable=true, unique=false) |
||
| 271 | */ |
||
| 272 | protected $lastVisit; |
||
| 273 | |||
| 274 | /** |
||
| 275 | * @var \DateTime |
||
| 276 | * |
||
| 277 | * @ORM\Column(name="last_edit", type="datetime", nullable=true, unique=false) |
||
| 278 | */ |
||
| 279 | protected $lastEdit; |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @var \DateTime |
||
| 283 | * |
||
| 284 | * @ORM\Column(name="creation_date", type="datetime", nullable=true, unique=false) |
||
| 285 | */ |
||
| 286 | protected $creationDate; |
||
| 287 | |||
| 288 | /** |
||
| 289 | * @var \DateTime |
||
| 290 | * |
||
| 291 | * @ORM\Column(name="expiration_date", type="datetime", nullable=true, unique=false) |
||
| 292 | */ |
||
| 293 | protected $expirationDate; |
||
| 294 | |||
| 295 | /** |
||
| 296 | * @var bool |
||
| 297 | * |
||
| 298 | * @ORM\Column(name="subscribe", type="boolean", nullable=true, unique=false) |
||
| 299 | */ |
||
| 300 | protected $subscribe; |
||
| 301 | |||
| 302 | /** |
||
| 303 | * @var bool |
||
| 304 | * |
||
| 305 | * @ORM\Column(name="unsubscribe", type="boolean", nullable=true, unique=false) |
||
| 306 | */ |
||
| 307 | protected $unsubscribe; |
||
| 308 | |||
| 309 | /** |
||
| 310 | * @var string |
||
| 311 | * |
||
| 312 | * @ORM\Column(name="registration_code", type="string", length=255, nullable=true, unique=false) |
||
| 313 | */ |
||
| 314 | protected $registrationCode; |
||
| 315 | |||
| 316 | /** |
||
| 317 | * @var string |
||
| 318 | * |
||
| 319 | * @ORM\Column(name="legal", type="text", nullable=true, unique=false) |
||
| 320 | */ |
||
| 321 | protected $legal; |
||
| 322 | |||
| 323 | /** |
||
| 324 | * @var int |
||
| 325 | * |
||
| 326 | * @ORM\Column(name="activate_legal", type="integer", nullable=true, unique=false) |
||
| 327 | */ |
||
| 328 | protected $activateLegal; |
||
| 329 | |||
| 330 | /** |
||
| 331 | * @var bool |
||
| 332 | * |
||
| 333 | * @ORM\Column(name="add_teachers_to_sessions_courses", type="boolean", nullable=true) |
||
| 334 | */ |
||
| 335 | protected $addTeachersToSessionsCourses; |
||
| 336 | |||
| 337 | /** |
||
| 338 | * @var int |
||
| 339 | * |
||
| 340 | * @ORM\Column(name="course_type_id", type="integer", nullable=true, unique=false) |
||
| 341 | */ |
||
| 342 | protected $courseTypeId; |
||
| 343 | |||
| 344 | /** |
||
| 345 | * ORM\OneToMany(targetEntity="CurriculumCategory", mappedBy="course"). |
||
| 346 | */ |
||
| 347 | //protected $curriculumCategories; |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @var Room |
||
| 351 | * |
||
| 352 | * @ORM\ManyToOne(targetEntity="Room") |
||
| 353 | * @ORM\JoinColumn(name="room_id", referencedColumnName="id") |
||
| 354 | */ |
||
| 355 | protected $room; |
||
| 356 | |||
| 357 | /** |
||
| 358 | * Constructor. |
||
| 359 | */ |
||
| 360 | public function __construct() |
||
| 361 | { |
||
| 362 | $this->creationDate = new \DateTime(); |
||
| 363 | $this->lastVisit = new \DateTime(); |
||
| 364 | $this->lastEdit = new \DateTime(); |
||
| 365 | |||
| 366 | $this->users = new ArrayCollection(); |
||
| 367 | $this->urls = new ArrayCollection(); |
||
| 368 | $this->gradebookCategories = new ArrayCollection(); |
||
| 369 | $this->gradebookEvaluations = new ArrayCollection(); |
||
| 370 | $this->gradebookLinks = new ArrayCollection(); |
||
| 371 | $this->trackEHotspots = new ArrayCollection(); |
||
| 372 | $this->trackEAttempts = new ArrayCollection(); |
||
| 373 | $this->searchEngineRefs = new ArrayCollection(); |
||
| 374 | $this->templates = new ArrayCollection(); |
||
| 375 | $this->specificFieldValues = new ArrayCollection(); |
||
|
|
|||
| 376 | $this->sharedSurveys = new ArrayCollection(); |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * @return string |
||
| 381 | */ |
||
| 382 | public function __toString() |
||
| 383 | { |
||
| 384 | return (string) $this->getTitle(); |
||
| 385 | } |
||
| 386 | |||
| 387 | /** |
||
| 388 | * @return ArrayCollection |
||
| 389 | */ |
||
| 390 | public function getSessions() |
||
| 391 | { |
||
| 392 | return $this->sessions; |
||
| 393 | } |
||
| 394 | |||
| 395 | /** |
||
| 396 | * @param Session $session |
||
| 397 | * |
||
| 398 | * @return ArrayCollection |
||
| 399 | */ |
||
| 400 | public function getTools(Session $session = null) |
||
| 401 | { |
||
| 402 | $orWhere = Criteria::expr()->eq('sessionId', 0); |
||
| 403 | |||
| 404 | if ($session) { |
||
| 405 | $orWhere = Criteria::expr()->in('sessionId', [0, $session->getId()]); |
||
| 406 | } |
||
| 407 | |||
| 408 | $criteria = Criteria::create() |
||
| 409 | ->where(Criteria::expr()->isNull('sessionId')) |
||
| 410 | ->orWhere($orWhere); |
||
| 411 | |||
| 412 | return $this->tools->matching($criteria); |
||
| 413 | } |
||
| 414 | |||
| 415 | /** |
||
| 416 | * @param array $tools |
||
| 417 | */ |
||
| 418 | public function setTools($tools) |
||
| 419 | { |
||
| 420 | foreach ($tools as $tool) { |
||
| 421 | $this->addTools($tool); |
||
| 422 | } |
||
| 423 | } |
||
| 424 | |||
| 425 | /** |
||
| 426 | * @param CTool $tool |
||
| 427 | */ |
||
| 428 | public function addTools(CTool $tool) |
||
| 429 | { |
||
| 430 | $tool->setCourse($this); |
||
| 431 | $this->tools[] = $tool; |
||
| 432 | } |
||
| 433 | |||
| 434 | /** |
||
| 435 | * @return ArrayCollection |
||
| 436 | */ |
||
| 437 | public function getUrls() |
||
| 438 | { |
||
| 439 | return $this->urls; |
||
| 440 | } |
||
| 441 | |||
| 442 | /** |
||
| 443 | * @param $urls |
||
| 444 | */ |
||
| 445 | public function setUrls($urls) |
||
| 446 | { |
||
| 447 | $this->urls = new ArrayCollection(); |
||
| 448 | |||
| 449 | foreach ($urls as $url) { |
||
| 450 | $this->addUrls($url); |
||
| 451 | } |
||
| 452 | } |
||
| 453 | |||
| 454 | /** |
||
| 455 | * @param AccessUrlRelCourse $url |
||
| 456 | */ |
||
| 457 | public function addUrlRelCourse(AccessUrlRelCourse $url) |
||
| 458 | { |
||
| 459 | $url->setCourse($this); |
||
| 460 | $this->urls[] = $url; |
||
| 461 | } |
||
| 462 | |||
| 463 | /** |
||
| 464 | * @param AccessUrl $url |
||
| 465 | */ |
||
| 466 | public function addUrl(AccessUrl $url) |
||
| 467 | { |
||
| 468 | $urlRelCourse = new AccessUrlRelCourse(); |
||
| 469 | $urlRelCourse->setCourse($this); |
||
| 470 | $urlRelCourse->setUrl($url); |
||
| 471 | $this->addUrlRelCourse($urlRelCourse); |
||
| 472 | } |
||
| 473 | |||
| 474 | /** |
||
| 475 | * @return ArrayCollection |
||
| 476 | */ |
||
| 477 | public function getUsers() |
||
| 478 | { |
||
| 479 | return $this->users; |
||
| 480 | } |
||
| 481 | |||
| 482 | /** |
||
| 483 | * @return ArrayCollection |
||
| 484 | */ |
||
| 485 | public function getGroups() |
||
| 486 | { |
||
| 487 | return $this->groups; |
||
| 488 | } |
||
| 489 | |||
| 490 | /** |
||
| 491 | * @return ArrayCollection |
||
| 492 | */ |
||
| 493 | public function getTeachers() |
||
| 494 | { |
||
| 495 | $criteria = Criteria::create(); |
||
| 496 | $criteria->where(Criteria::expr()->eq('status', User::COURSE_MANAGER)); |
||
| 497 | |||
| 498 | return $this->users->matching($criteria); |
||
| 499 | } |
||
| 500 | |||
| 501 | /** |
||
| 502 | * @return ArrayCollection |
||
| 503 | */ |
||
| 504 | public function getStudents() |
||
| 505 | { |
||
| 506 | $criteria = Criteria::create(); |
||
| 507 | $criteria->where(Criteria::expr()->eq('status', User::STUDENT)); |
||
| 508 | |||
| 509 | return $this->users->matching($criteria); |
||
| 510 | } |
||
| 511 | |||
| 512 | /** |
||
| 513 | * @param ArrayCollection $users |
||
| 514 | */ |
||
| 515 | public function setUsers($users) |
||
| 516 | { |
||
| 517 | $this->users = new ArrayCollection(); |
||
| 518 | |||
| 519 | foreach ($users as $user) { |
||
| 520 | $this->addUsers($user); |
||
| 521 | } |
||
| 522 | } |
||
| 523 | |||
| 524 | /** |
||
| 525 | * @param CourseRelUser $courseRelUser |
||
| 526 | */ |
||
| 527 | public function addUsers(CourseRelUser $courseRelUser) |
||
| 528 | { |
||
| 529 | $courseRelUser->setCourse($this); |
||
| 530 | |||
| 531 | if (!$this->hasSubscription($courseRelUser)) { |
||
| 532 | $this->users[] = $courseRelUser; |
||
| 533 | } |
||
| 534 | } |
||
| 535 | |||
| 536 | /** |
||
| 537 | * @param User $user |
||
| 538 | * |
||
| 539 | * @return bool |
||
| 540 | */ |
||
| 541 | public function hasUser(User $user) |
||
| 542 | { |
||
| 543 | $criteria = Criteria::create()->where( |
||
| 544 | Criteria::expr()->eq('user', $user) |
||
| 545 | ); |
||
| 546 | |||
| 547 | return $this->getUsers()->matching($criteria)->count() > 0; |
||
| 548 | } |
||
| 549 | |||
| 550 | /** |
||
| 551 | * @param User $user |
||
| 552 | * |
||
| 553 | * @return bool |
||
| 554 | */ |
||
| 555 | public function hasStudent(User $user) |
||
| 556 | { |
||
| 557 | $criteria = Criteria::create()->where( |
||
| 558 | Criteria::expr()->eq('user', $user) |
||
| 559 | ); |
||
| 560 | |||
| 561 | return $this->getStudents()->matching($criteria)->count() > 0; |
||
| 562 | } |
||
| 563 | |||
| 564 | /** |
||
| 565 | * @param User $user |
||
| 566 | * |
||
| 567 | * @return bool |
||
| 568 | */ |
||
| 569 | public function hasTeacher(User $user) |
||
| 570 | { |
||
| 571 | $criteria = Criteria::create()->where( |
||
| 572 | Criteria::expr()->eq('user', $user) |
||
| 573 | ); |
||
| 574 | |||
| 575 | return $this->getTeachers()->matching($criteria)->count() > 0; |
||
| 576 | } |
||
| 577 | |||
| 578 | /** |
||
| 579 | * @param CGroupInfo $group |
||
| 580 | * |
||
| 581 | * @return bool |
||
| 582 | */ |
||
| 583 | public function hasGroup(CGroupInfo $group) |
||
| 584 | { |
||
| 585 | /*$criteria = Criteria::create()->where( |
||
| 586 | Criteria::expr()->eq('groups', $group) |
||
| 587 | );*/ |
||
| 588 | |||
| 589 | return $this->getGroups()->contains($group); |
||
| 590 | } |
||
| 591 | |||
| 592 | /** |
||
| 593 | * Remove $user. |
||
| 594 | * |
||
| 595 | * @param CourseRelUser $user |
||
| 596 | */ |
||
| 597 | public function removeUsers(CourseRelUser $user) |
||
| 598 | { |
||
| 599 | foreach ($this->users as $key => $value) { |
||
| 600 | if ($value->getId() == $user->getId()) { |
||
| 601 | unset($this->users[$key]); |
||
| 602 | } |
||
| 603 | } |
||
| 604 | } |
||
| 605 | |||
| 606 | /** |
||
| 607 | * @param User $user |
||
| 608 | */ |
||
| 609 | public function addTeacher(User $user) |
||
| 610 | { |
||
| 611 | $this->addUser($user, 0, "Trainer", User::COURSE_MANAGER); |
||
| 612 | } |
||
| 613 | |||
| 614 | /** |
||
| 615 | * @param User $user |
||
| 616 | */ |
||
| 617 | public function addStudent(User $user) |
||
| 618 | { |
||
| 619 | $this->addUser($user, 0, "", User::STUDENT); |
||
| 620 | } |
||
| 621 | |||
| 622 | /** |
||
| 623 | * Set id. |
||
| 624 | * |
||
| 625 | * @return int |
||
| 626 | */ |
||
| 627 | public function setId($id) |
||
| 628 | { |
||
| 629 | $this->id = $id; |
||
| 630 | } |
||
| 631 | |||
| 632 | /** |
||
| 633 | * Get id. |
||
| 634 | * |
||
| 635 | * @return int |
||
| 636 | */ |
||
| 637 | public function getId() |
||
| 638 | { |
||
| 639 | return $this->id; |
||
| 640 | } |
||
| 641 | |||
| 642 | /** |
||
| 643 | * Set code. |
||
| 644 | * |
||
| 645 | * @param string $code |
||
| 646 | * |
||
| 647 | * @return Course |
||
| 648 | */ |
||
| 649 | public function setCode($code) |
||
| 650 | { |
||
| 651 | $this->code = $code; |
||
| 652 | $this->visualCode = $code; |
||
| 653 | $this->directory = $code; |
||
| 654 | |||
| 655 | return $this; |
||
| 656 | } |
||
| 657 | |||
| 658 | /** |
||
| 659 | * Get code. |
||
| 660 | * |
||
| 661 | * @return string |
||
| 662 | */ |
||
| 663 | public function getCode() |
||
| 664 | { |
||
| 665 | return $this->code; |
||
| 666 | } |
||
| 667 | |||
| 668 | /** |
||
| 669 | * Set directory. |
||
| 670 | * |
||
| 671 | * @param string $directory |
||
| 672 | * |
||
| 673 | * @return Course |
||
| 674 | */ |
||
| 675 | public function setDirectory($directory) |
||
| 676 | { |
||
| 677 | $this->directory = $directory; |
||
| 678 | |||
| 679 | return $this; |
||
| 680 | } |
||
| 681 | |||
| 682 | /** |
||
| 683 | * Get directory. |
||
| 684 | * |
||
| 685 | * @return string |
||
| 686 | */ |
||
| 687 | public function getDirectory() |
||
| 688 | { |
||
| 689 | return $this->directory; |
||
| 690 | } |
||
| 691 | |||
| 692 | /** |
||
| 693 | * Set courseLanguage. |
||
| 694 | * |
||
| 695 | * @param string $courseLanguage |
||
| 696 | * |
||
| 697 | * @return Course |
||
| 698 | */ |
||
| 699 | public function setCourseLanguage($courseLanguage) |
||
| 700 | { |
||
| 701 | $this->courseLanguage = $courseLanguage; |
||
| 702 | |||
| 703 | return $this; |
||
| 704 | } |
||
| 705 | |||
| 706 | /** |
||
| 707 | * Get courseLanguage. |
||
| 708 | * |
||
| 709 | * @return string |
||
| 710 | */ |
||
| 711 | public function getCourseLanguage() |
||
| 712 | { |
||
| 713 | return $this->courseLanguage; |
||
| 714 | } |
||
| 715 | |||
| 716 | /** |
||
| 717 | * Set title. |
||
| 718 | * |
||
| 719 | * @param string $title |
||
| 720 | * |
||
| 721 | * @return Course |
||
| 722 | */ |
||
| 723 | public function setTitle($title) |
||
| 724 | { |
||
| 725 | $this->title = $title; |
||
| 726 | |||
| 727 | return $this; |
||
| 728 | } |
||
| 729 | |||
| 730 | /** |
||
| 731 | * Get title. |
||
| 732 | * |
||
| 733 | * @return string |
||
| 734 | */ |
||
| 735 | public function getTitle() |
||
| 736 | { |
||
| 737 | return $this->title; |
||
| 738 | } |
||
| 739 | |||
| 740 | /** |
||
| 741 | * @return string |
||
| 742 | */ |
||
| 743 | public function getTitleAndCode() |
||
| 744 | { |
||
| 745 | return $this->getTitle().' ('.$this->getCode().')'; |
||
| 746 | } |
||
| 747 | |||
| 748 | /** |
||
| 749 | * Set description. |
||
| 750 | * |
||
| 751 | * @param string $description |
||
| 752 | * |
||
| 753 | * @return Course |
||
| 754 | */ |
||
| 755 | public function setDescription($description) |
||
| 756 | { |
||
| 757 | $this->description = $description; |
||
| 758 | |||
| 759 | return $this; |
||
| 760 | } |
||
| 761 | |||
| 762 | /** |
||
| 763 | * Get description. |
||
| 764 | * |
||
| 765 | * @return string |
||
| 766 | */ |
||
| 767 | public function getDescription() |
||
| 768 | { |
||
| 769 | return $this->description; |
||
| 770 | } |
||
| 771 | |||
| 772 | /** |
||
| 773 | * Set categoryCode. |
||
| 774 | * |
||
| 775 | * @param string $categoryCode |
||
| 776 | * |
||
| 777 | * @return Course |
||
| 778 | */ |
||
| 779 | public function setCategoryCode($categoryCode) |
||
| 780 | { |
||
| 781 | $this->categoryCode = $categoryCode; |
||
| 782 | |||
| 783 | return $this; |
||
| 784 | } |
||
| 785 | |||
| 786 | /** |
||
| 787 | * Get categoryCode. |
||
| 788 | * |
||
| 789 | * @return string |
||
| 790 | */ |
||
| 791 | public function getCategoryCode() |
||
| 792 | { |
||
| 793 | return $this->categoryCode; |
||
| 794 | } |
||
| 795 | |||
| 796 | /** |
||
| 797 | * Set visibility. |
||
| 798 | * |
||
| 799 | * @param int $visibility |
||
| 800 | * |
||
| 801 | * @return Course |
||
| 802 | */ |
||
| 803 | public function setVisibility($visibility) |
||
| 804 | { |
||
| 805 | $this->visibility = $visibility; |
||
| 806 | |||
| 807 | return $this; |
||
| 808 | } |
||
| 809 | |||
| 810 | /** |
||
| 811 | * Get visibility. |
||
| 812 | * |
||
| 813 | * @return int |
||
| 814 | */ |
||
| 815 | public function getVisibility() |
||
| 816 | { |
||
| 817 | return (int) $this->visibility; |
||
| 818 | } |
||
| 819 | |||
| 820 | /** |
||
| 821 | * Set showScore. |
||
| 822 | * |
||
| 823 | * @param int $showScore |
||
| 824 | * |
||
| 825 | * @return Course |
||
| 826 | */ |
||
| 827 | public function setShowScore($showScore) |
||
| 828 | { |
||
| 829 | $this->showScore = $showScore; |
||
| 830 | |||
| 831 | return $this; |
||
| 832 | } |
||
| 833 | |||
| 834 | /** |
||
| 835 | * Get showScore. |
||
| 836 | * |
||
| 837 | * @return int |
||
| 838 | */ |
||
| 839 | public function getShowScore() |
||
| 842 | } |
||
| 843 | |||
| 844 | /** |
||
| 845 | * Set tutorName. |
||
| 846 | * |
||
| 847 | * @param string $tutorName |
||
| 848 | * |
||
| 849 | * @return Course |
||
| 850 | */ |
||
| 851 | public function setTutorName($tutorName) |
||
| 852 | { |
||
| 853 | $this->tutorName = $tutorName; |
||
| 854 | |||
| 855 | return $this; |
||
| 856 | } |
||
| 857 | |||
| 858 | /** |
||
| 859 | * Get tutorName. |
||
| 860 | * |
||
| 861 | * @return string |
||
| 862 | */ |
||
| 863 | public function getTutorName() |
||
| 864 | { |
||
| 865 | return $this->tutorName; |
||
| 866 | } |
||
| 867 | |||
| 868 | /** |
||
| 869 | * Set visualCode. |
||
| 870 | * |
||
| 871 | * @param string $visualCode |
||
| 872 | * |
||
| 873 | * @return Course |
||
| 874 | */ |
||
| 875 | public function setVisualCode($visualCode) |
||
| 876 | { |
||
| 877 | $this->visualCode = $visualCode; |
||
| 878 | |||
| 879 | return $this; |
||
| 880 | } |
||
| 881 | |||
| 882 | /** |
||
| 883 | * Get visualCode. |
||
| 884 | * |
||
| 885 | * @return string |
||
| 886 | */ |
||
| 887 | public function getVisualCode() |
||
| 888 | { |
||
| 889 | return $this->visualCode; |
||
| 890 | } |
||
| 891 | |||
| 892 | /** |
||
| 893 | * Set departmentName. |
||
| 894 | * |
||
| 895 | * @param string $departmentName |
||
| 896 | * |
||
| 897 | * @return Course |
||
| 898 | */ |
||
| 899 | public function setDepartmentName($departmentName) |
||
| 900 | { |
||
| 901 | $this->departmentName = $departmentName; |
||
| 902 | |||
| 903 | return $this; |
||
| 904 | } |
||
| 905 | |||
| 906 | /** |
||
| 907 | * Get departmentName. |
||
| 908 | * |
||
| 909 | * @return string |
||
| 910 | */ |
||
| 911 | public function getDepartmentName() |
||
| 912 | { |
||
| 913 | return $this->departmentName; |
||
| 914 | } |
||
| 915 | |||
| 916 | /** |
||
| 917 | * Set departmentUrl. |
||
| 918 | * |
||
| 919 | * @param string $departmentUrl |
||
| 920 | * |
||
| 921 | * @return Course |
||
| 922 | */ |
||
| 923 | public function setDepartmentUrl($departmentUrl) |
||
| 924 | { |
||
| 925 | $this->departmentUrl = $departmentUrl; |
||
| 926 | |||
| 927 | return $this; |
||
| 928 | } |
||
| 929 | |||
| 930 | /** |
||
| 931 | * Get departmentUrl. |
||
| 932 | * |
||
| 933 | * @return string |
||
| 934 | */ |
||
| 935 | public function getDepartmentUrl() |
||
| 936 | { |
||
| 937 | return $this->departmentUrl; |
||
| 938 | } |
||
| 939 | |||
| 940 | /** |
||
| 941 | * Set diskQuota. |
||
| 942 | * |
||
| 943 | * @param int $diskQuota |
||
| 944 | * |
||
| 945 | * @return Course |
||
| 946 | */ |
||
| 947 | public function setDiskQuota($diskQuota) |
||
| 948 | { |
||
| 949 | $this->diskQuota = intval($diskQuota); |
||
| 950 | |||
| 951 | return $this; |
||
| 952 | } |
||
| 953 | |||
| 954 | /** |
||
| 955 | * Get diskQuota. |
||
| 956 | * |
||
| 957 | * @return int |
||
| 958 | */ |
||
| 959 | public function getDiskQuota() |
||
| 960 | { |
||
| 961 | return $this->diskQuota; |
||
| 962 | } |
||
| 963 | |||
| 964 | /** |
||
| 965 | * Set lastVisit. |
||
| 966 | * |
||
| 967 | * @param \DateTime $lastVisit |
||
| 968 | * |
||
| 969 | * @return Course |
||
| 970 | */ |
||
| 971 | public function setLastVisit($lastVisit) |
||
| 972 | { |
||
| 973 | $this->lastVisit = $lastVisit; |
||
| 974 | |||
| 975 | return $this; |
||
| 976 | } |
||
| 977 | |||
| 978 | /** |
||
| 979 | * Get lastVisit. |
||
| 980 | * |
||
| 981 | * @return \DateTime |
||
| 982 | */ |
||
| 983 | public function getLastVisit() |
||
| 984 | { |
||
| 985 | return $this->lastVisit; |
||
| 986 | } |
||
| 987 | |||
| 988 | /** |
||
| 989 | * Set lastEdit. |
||
| 990 | * |
||
| 991 | * @param \DateTime $lastEdit |
||
| 992 | * |
||
| 993 | * @return Course |
||
| 994 | */ |
||
| 995 | public function setLastEdit($lastEdit) |
||
| 996 | { |
||
| 997 | $this->lastEdit = $lastEdit; |
||
| 998 | |||
| 999 | return $this; |
||
| 1000 | } |
||
| 1001 | |||
| 1002 | /** |
||
| 1003 | * Get lastEdit. |
||
| 1004 | * |
||
| 1005 | * @return \DateTime |
||
| 1006 | */ |
||
| 1007 | public function getLastEdit() |
||
| 1008 | { |
||
| 1009 | return $this->lastEdit; |
||
| 1010 | } |
||
| 1011 | |||
| 1012 | /** |
||
| 1013 | * Set creationDate. |
||
| 1014 | * |
||
| 1015 | * @param \DateTime $creationDate |
||
| 1016 | * |
||
| 1017 | * @return Course |
||
| 1018 | */ |
||
| 1019 | public function setCreationDate($creationDate) |
||
| 1020 | { |
||
| 1021 | $this->creationDate = $creationDate; |
||
| 1022 | |||
| 1023 | return $this; |
||
| 1024 | } |
||
| 1025 | |||
| 1026 | /** |
||
| 1027 | * Get creationDate. |
||
| 1028 | * |
||
| 1029 | * @return \DateTime |
||
| 1030 | */ |
||
| 1031 | public function getCreationDate() |
||
| 1032 | { |
||
| 1033 | return $this->creationDate; |
||
| 1034 | } |
||
| 1035 | |||
| 1036 | /** |
||
| 1037 | * Set expirationDate. |
||
| 1038 | * |
||
| 1039 | * @param \DateTime $expirationDate |
||
| 1040 | * |
||
| 1041 | * @return Course |
||
| 1042 | */ |
||
| 1043 | public function setExpirationDate($expirationDate) |
||
| 1044 | { |
||
| 1045 | $this->expirationDate = $expirationDate; |
||
| 1046 | |||
| 1047 | return $this; |
||
| 1048 | } |
||
| 1049 | |||
| 1050 | /** |
||
| 1051 | * Get expirationDate. |
||
| 1052 | * |
||
| 1053 | * @return \DateTime |
||
| 1054 | */ |
||
| 1055 | public function getExpirationDate() |
||
| 1058 | } |
||
| 1059 | |||
| 1060 | /** |
||
| 1061 | * Set subscribe. |
||
| 1062 | * |
||
| 1063 | * @param bool $subscribe |
||
| 1064 | * |
||
| 1065 | * @return Course |
||
| 1066 | */ |
||
| 1067 | public function setSubscribe($subscribe) |
||
| 1068 | { |
||
| 1069 | $this->subscribe = (bool) $subscribe; |
||
| 1070 | |||
| 1071 | return $this; |
||
| 1072 | } |
||
| 1073 | |||
| 1074 | /** |
||
| 1075 | * Get subscribe. |
||
| 1076 | * |
||
| 1077 | * @return bool |
||
| 1078 | */ |
||
| 1079 | public function getSubscribe() |
||
| 1080 | { |
||
| 1081 | return $this->subscribe; |
||
| 1082 | } |
||
| 1083 | |||
| 1084 | /** |
||
| 1085 | * Set unsubscribe. |
||
| 1086 | * |
||
| 1087 | * @param bool $unsubscribe |
||
| 1088 | * |
||
| 1089 | * @return Course |
||
| 1090 | */ |
||
| 1091 | public function setUnsubscribe($unsubscribe) |
||
| 1092 | { |
||
| 1093 | $this->unsubscribe = (bool) $unsubscribe; |
||
| 1094 | |||
| 1095 | return $this; |
||
| 1096 | } |
||
| 1097 | |||
| 1098 | /** |
||
| 1099 | * Get unsubscribe. |
||
| 1100 | * |
||
| 1101 | * @return bool |
||
| 1102 | */ |
||
| 1103 | public function getUnsubscribe() |
||
| 1104 | { |
||
| 1105 | return $this->unsubscribe; |
||
| 1106 | } |
||
| 1107 | |||
| 1108 | /** |
||
| 1109 | * Set registrationCode. |
||
| 1110 | * |
||
| 1111 | * @param string $registrationCode |
||
| 1112 | * |
||
| 1113 | * @return Course |
||
| 1114 | */ |
||
| 1115 | public function setRegistrationCode($registrationCode) |
||
| 1120 | } |
||
| 1121 | |||
| 1122 | /** |
||
| 1123 | * Get registrationCode. |
||
| 1124 | * |
||
| 1125 | * @return string |
||
| 1126 | */ |
||
| 1127 | public function getRegistrationCode() |
||
| 1128 | { |
||
| 1129 | return $this->registrationCode; |
||
| 1130 | } |
||
| 1131 | |||
| 1132 | /** |
||
| 1133 | * Set legal. |
||
| 1134 | * |
||
| 1135 | * @param string $legal |
||
| 1136 | * |
||
| 1137 | * @return Course |
||
| 1138 | */ |
||
| 1139 | public function setLegal($legal) |
||
| 1144 | } |
||
| 1145 | |||
| 1146 | /** |
||
| 1147 | * Get legal. |
||
| 1148 | * |
||
| 1149 | * @return string |
||
| 1150 | */ |
||
| 1151 | public function getLegal() |
||
| 1152 | { |
||
| 1153 | return $this->legal; |
||
| 1154 | } |
||
| 1155 | |||
| 1156 | /** |
||
| 1157 | * Set activateLegal. |
||
| 1158 | * |
||
| 1159 | * @param int $activateLegal |
||
| 1160 | * |
||
| 1161 | * @return Course |
||
| 1162 | */ |
||
| 1163 | public function setActivateLegal($activateLegal) |
||
| 1164 | { |
||
| 1165 | $this->activateLegal = $activateLegal; |
||
| 1166 | |||
| 1167 | return $this; |
||
| 1168 | } |
||
| 1169 | |||
| 1170 | /** |
||
| 1171 | * Get activateLegal. |
||
| 1172 | * |
||
| 1173 | * @return int |
||
| 1174 | */ |
||
| 1175 | public function getActivateLegal() |
||
| 1178 | } |
||
| 1179 | |||
| 1180 | /** |
||
| 1181 | * @return bool |
||
| 1182 | */ |
||
| 1183 | public function isAddTeachersToSessionsCourses() |
||
| 1184 | { |
||
| 1185 | return $this->addTeachersToSessionsCourses; |
||
| 1186 | } |
||
| 1187 | |||
| 1188 | /** |
||
| 1189 | * @param bool $addTeachersToSessionsCourses |
||
| 1190 | * |
||
| 1191 | * @return Course |
||
| 1192 | */ |
||
| 1193 | public function setAddTeachersToSessionsCourses($addTeachersToSessionsCourses): Course |
||
| 1194 | { |
||
| 1195 | $this->addTeachersToSessionsCourses = $addTeachersToSessionsCourses; |
||
| 1196 | |||
| 1197 | return $this; |
||
| 1198 | } |
||
| 1199 | |||
| 1200 | /** |
||
| 1201 | * Set courseTypeId. |
||
| 1202 | * |
||
| 1203 | * @param int $courseTypeId |
||
| 1204 | * |
||
| 1205 | * @return Course |
||
| 1206 | */ |
||
| 1207 | public function setCourseTypeId($courseTypeId) |
||
| 1208 | { |
||
| 1209 | $this->courseTypeId = $courseTypeId; |
||
| 1210 | |||
| 1211 | return $this; |
||
| 1212 | } |
||
| 1213 | |||
| 1214 | /** |
||
| 1215 | * Get courseTypeId. |
||
| 1216 | * |
||
| 1217 | * @return int |
||
| 1218 | */ |
||
| 1219 | public function getCourseTypeId() |
||
| 1220 | { |
||
| 1221 | return $this->courseTypeId; |
||
| 1222 | } |
||
| 1223 | |||
| 1224 | /** |
||
| 1225 | * @return Room |
||
| 1226 | */ |
||
| 1227 | public function getRoom() |
||
| 1228 | { |
||
| 1229 | return $this->room; |
||
| 1230 | } |
||
| 1231 | |||
| 1232 | /** |
||
| 1233 | * @param Room $room |
||
| 1234 | * |
||
| 1235 | * @return Course |
||
| 1236 | */ |
||
| 1237 | public function setRoom($room) |
||
| 1238 | { |
||
| 1239 | $this->room = $room; |
||
| 1240 | |||
| 1241 | return $this; |
||
| 1242 | } |
||
| 1243 | |||
| 1244 | /** |
||
| 1245 | * @return bool |
||
| 1246 | */ |
||
| 1247 | public function isActive() |
||
| 1248 | { |
||
| 1249 | $activeVisibilityList = [ |
||
| 1250 | self::REGISTERED, |
||
| 1251 | self::OPEN_PLATFORM, |
||
| 1252 | self::OPEN_WORLD, |
||
| 1253 | ]; |
||
| 1254 | |||
| 1255 | return in_array($this->visibility, $activeVisibilityList); |
||
| 1256 | } |
||
| 1257 | |||
| 1258 | /** |
||
| 1259 | * Anybody can see this course. |
||
| 1260 | * |
||
| 1261 | * @return bool |
||
| 1262 | */ |
||
| 1263 | public function isPublic() |
||
| 1264 | { |
||
| 1265 | return $this->visibility == self::OPEN_WORLD; |
||
| 1266 | } |
||
| 1267 | |||
| 1268 | /** |
||
| 1269 | * @return array |
||
| 1270 | */ |
||
| 1271 | public static function getStatusList() |
||
| 1272 | { |
||
| 1273 | return [ |
||
| 1274 | self::CLOSED => 'Closed', |
||
| 1275 | self::REGISTERED => 'Registered', |
||
| 1276 | self::OPEN_PLATFORM => 'Open platform', |
||
| 1277 | self::OPEN_WORLD => 'Open world', |
||
| 1278 | self::HIDDEN => 'Hidden', |
||
| 1279 | ]; |
||
| 1280 | } |
||
| 1281 | |||
| 1282 | /** |
||
| 1283 | * @return Session |
||
| 1284 | */ |
||
| 1285 | public function getCurrentSession() |
||
| 1288 | } |
||
| 1289 | |||
| 1290 | /** |
||
| 1291 | * @param Session $session |
||
| 1292 | * |
||
| 1293 | * @return $this |
||
| 1294 | */ |
||
| 1295 | public function setCurrentSession(Session $session) |
||
| 1296 | { |
||
| 1297 | // If the session is registered in the course session list. |
||
| 1298 | /*if ($this->getSessions()->contains($session->getId())) { |
||
| 1299 | $this->currentSession = $session; |
||
| 1300 | }*/ |
||
| 1301 | |||
| 1302 | $list = $this->getSessions(); |
||
| 1303 | /** @var SessionRelCourse $item */ |
||
| 1304 | foreach ($list as $item) { |
||
| 1305 | if ($item->getSession()->getId() == $session->getId()) { |
||
| 1306 | $this->currentSession = $session; |
||
| 1307 | break; |
||
| 1308 | } |
||
| 1309 | } |
||
| 1310 | |||
| 1311 | return $this; |
||
| 1312 | } |
||
| 1313 | |||
| 1314 | /** |
||
| 1315 | * @param AccessUrl $url |
||
| 1316 | * |
||
| 1317 | * @return $this |
||
| 1318 | */ |
||
| 1319 | public function setCurrentUrl(AccessUrl $url) |
||
| 1320 | { |
||
| 1321 | $urlList = $this->getUrls(); |
||
| 1322 | /** @var AccessUrlRelCourse $item */ |
||
| 1323 | foreach ($urlList as $item) { |
||
| 1324 | if ($item->getUrl()->getId() == $url->getId()) { |
||
| 1325 | $this->currentUrl = $url; |
||
| 1326 | break; |
||
| 1327 | } |
||
| 1328 | } |
||
| 1329 | |||
| 1330 | return $this; |
||
| 1331 | } |
||
| 1332 | |||
| 1333 | /** |
||
| 1334 | * @return AccessUrl |
||
| 1335 | */ |
||
| 1336 | public function getCurrentUrl() |
||
| 1337 | { |
||
| 1338 | return $this->currentUrl; |
||
| 1339 | } |
||
| 1340 | |||
| 1341 | /** |
||
| 1342 | * Get issuedSkills. |
||
| 1343 | * |
||
| 1344 | * @return ArrayCollection |
||
| 1345 | */ |
||
| 1346 | public function getIssuedSkills() |
||
| 1347 | { |
||
| 1348 | return $this->issuedSkills; |
||
| 1349 | } |
||
| 1350 | |||
| 1351 | /** |
||
| 1352 | * @param CourseRelUser $subscription |
||
| 1353 | * |
||
| 1354 | * @return bool |
||
| 1355 | */ |
||
| 1356 | public function hasSubscription(CourseRelUser $subscription) |
||
| 1373 | } |
||
| 1374 | |||
| 1375 | /** |
||
| 1376 | * @param User $user |
||
| 1377 | * @param string $relationType |
||
| 1378 | * @param string $role |
||
| 1379 | * @param string $status |
||
| 1380 | */ |
||
| 1381 | public function addUser(User $user, $relationType, $role, $status) |
||
| 1382 | { |
||
| 1383 | $courseRelUser = new CourseRelUser(); |
||
| 1384 | $courseRelUser->setCourse($this); |
||
| 1385 | $courseRelUser->setUser($user); |
||
| 1386 | $courseRelUser->setRelationType($relationType); |
||
| 1387 | $courseRelUser->setRole($role); |
||
| 1388 | $courseRelUser->setStatus($status); |
||
| 1389 | $this->addUsers($courseRelUser); |
||
| 1390 | } |
||
| 1391 | |||
| 1392 | /** |
||
| 1393 | * Resource identifier. |
||
| 1394 | * |
||
| 1395 | * @return int |
||
| 1396 | */ |
||
| 1397 | public function getResourceIdentifier(): int |
||
| 1398 | { |
||
| 1399 | return $this->getId(); |
||
| 1400 | } |
||
| 1401 | |||
| 1402 | /** |
||
| 1403 | * @return string |
||
| 1404 | */ |
||
| 1405 | public function getResourceName(): string |
||
| 1408 | } |
||
| 1409 | |||
| 1410 | /** |
||
| 1411 | * @return string |
||
| 1412 | */ |
||
| 1413 | public function getToolName(): string |
||
| 1414 | { |
||
| 1415 | return 'Course'; |
||
| 1416 | } |
||
| 1417 | } |
||
| 1418 |