| @@ 527-564 (lines=38) @@ | ||
| 524 | * @param string Description title |
|
| 525 | * @param string Course description content |
|
| 526 | */ |
|
| 527 | public function EditCourseDescription($secret_key, $course_id_field_name, $course_id_value, $course_desc_id, $course_desc_title, $course_desc_content) { |
|
| 528 | $verifKey = $this->verifyKey($secret_key); |
|
| 529 | if ($verifKey instanceof WSError) { |
|
| 530 | $this->handleError($verifKey); |
|
| 531 | } else { |
|
| 532 | $course_id = $this->getCourseId($course_id_field_name, $course_id_value); |
|
| 533 | if ($course_id instanceof WSError) { |
|
| 534 | return $course_id; |
|
| 535 | } else { |
|
| 536 | // Create the new course description |
|
| 537 | $cd = new CourseDescription(); |
|
| 538 | $cd->set_description_type($course_desc_id); |
|
| 539 | $cd->set_title($course_desc_title); |
|
| 540 | $cd->set_content($course_desc_content); |
|
| 541 | $cd->set_session_id(0); |
|
| 542 | ||
| 543 | // Get course info |
|
| 544 | $course_info = CourseManager::get_course_information( |
|
| 545 | CourseManager::get_course_code_from_course_id($course_id) |
|
| 546 | ); |
|
| 547 | // Check if this course description exists |
|
| 548 | $descriptions = CourseDescription::get_descriptions($course_id); |
|
| 549 | $exists = false; |
|
| 550 | foreach ($descriptions as $description) { |
|
| 551 | if ($description->get_description_type() == $course_desc_id) { |
|
| 552 | $exists = true; |
|
| 553 | } |
|
| 554 | } |
|
| 555 | $cd->set_course_id($course_info['real_id']); |
|
| 556 | if (!$exists) { |
|
| 557 | $cd->set_progress(0); |
|
| 558 | $cd->insert(); |
|
| 559 | } else { |
|
| 560 | $cd->update(); |
|
| 561 | } |
|
| 562 | } |
|
| 563 | } |
|
| 564 | } |
|
| 565 | public function unreadMessage($username, $password) |
|
| 566 | { |
|
| 567 | if ($this->verifyUserPass($username, $password) == "valid") |
|
| @@ 674-708 (lines=35) @@ | ||
| 671 | * @param string Description title |
|
| 672 | * @param string Course description content |
|
| 673 | */ |
|
| 674 | public function EditCourseDescription( |
|
| 675 | $secret_key, |
|
| 676 | $course_id_field_name, |
|
| 677 | $course_id_value, |
|
| 678 | $course_desc_id, |
|
| 679 | $course_desc_title, |
|
| 680 | $course_desc_content |
|
| 681 | ) { |
|
| 682 | $verifKey = $this->verifyKey($secret_key); |
|
| 683 | if ($verifKey instanceof WSError) { |
|
| 684 | $this->handleError($verifKey); |
|
| 685 | } else { |
|
| 686 | $course_id = $this->getCourseId( |
|
| 687 | $course_id_field_name, |
|
| 688 | $course_id_value |
|
| 689 | ); |
|
| 690 | if ($course_id instanceof WSError) { |
|
| 691 | return $course_id; |
|
| 692 | } else { |
|
| 693 | // Create the new course description |
|
| 694 | $cd = new CourseDescription(); |
|
| 695 | $cd->set_description_type($course_desc_id); |
|
| 696 | $cd->set_title($course_desc_title); |
|
| 697 | $cd->set_content($course_desc_content); |
|
| 698 | $cd->set_session_id(0); |
|
| 699 | // Get course info |
|
| 700 | $course_info = CourseManager::get_course_information( |
|
| 701 | CourseManager::get_course_code_from_course_id($course_id) |
|
| 702 | ); |
|
| 703 | $cd->set_course_id($course_info['real_id']); |
|
| 704 | // Check if this course description exists |
|
| 705 | $descriptions = CourseDescription::get_descriptions($course_id); |
|
| 706 | $exists = false; |
|
| 707 | foreach ($descriptions as $description) { |
|
| 708 | if ($description->get_description_type( |
|
| 709 | ) == $course_desc_id |
|
| 710 | ) { |
|
| 711 | $exists = true; |
|