예제 #1
0
 function testSetName()
 {
     $name = "Coding 101";
     $test_course = new Course($name);
     $test_course->setName("Advanced Coding");
     $result = $test_course->getName();
     $this->assertEquals("Advanced Coding", $result);
 }
 function testSetName()
 {
     $name = "Math";
     $test_course = new Course($name);
     $test_course->setName("Science");
     $result = $test_course->getName();
     $this->assertEquals("Science", $result);
 }
 function testSetName()
 {
     //Arrange
     $name = "Philosophy 101";
     $course_number = "PHIL101";
     $test_course = new Course($name, $course_number);
     //Act
     $test_course->setName('jack');
     $result = $test_course->getName();
     //Assert
     $this->assertEquals('jack', $result);
 }
예제 #4
0
 function testSetName()
 {
     //Arrange
     $name = "History";
     $number = 101;
     $test_course = new Course($name, $number);
     //Act
     $test_course->setName("Science");
     $result = $test_course->getName();
     //Assert
     $this->assertEquals("Science", $result);
 }
 function test_setName()
 {
     //Arrange
     $name = "History";
     $course_number = "HIST101";
     $test_course = new Course($name, $course_number);
     //Act
     $test_course->setName("English");
     $result = $test_course->getName();
     //Assert
     $this->assertEquals("English", $result);
 }
예제 #6
0
 function testSetName()
 {
     //Arrange
     $name = "Math";
     $course_num = "101";
     $id = 1;
     $test_course = new Course($name, $course_num, $id);
     //Act
     $test_course->setName("Science");
     $result = $test_course->getName();
     //Assert
     $this->assertEquals("Science", $result);
 }
 function testSetName()
 {
     //Arrange
     $id = null;
     $name = "Intro to Math";
     $number = "MATH100";
     $test_course = new Course($id, $name, $number);
     //Act
     $test_course->setName("Intro to Soc");
     $result = $test_course->getName();
     //Assert
     $this->assertEquals("Intro to Soc", $result);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $output->writeln("<info>Create a grade for uFutureDesk Server</info>\n");
     $name = $dialog->askAndValidate($output, "<question>Insert name:</question> ", function ($data) {
         if (strlen($data) == 0) {
             throw new \InvalidArgumentException("Should not be empty");
         }
         if (strlen($data) > 30) {
             throw new \InvalidArgumentException("Max length is 30 characters");
         }
         return $data;
     });
     $course = new Course();
     $course->setName($name);
     $em = $this->getContainer()->get("doctrine.orm.entity_manager");
     $em->persist($course);
     $em->flush();
     $output->writeln("\n<info>Grade created</info>");
 }
예제 #9
0
 public function course_sort($courseSections)
 {
     //First, we declare an array to hold subjects
     $result = array();
     //We get the name of the first element, then use that to re-sort each
     //section by subject
     while (count($courseSections) > 0) {
         $name = reset($courseSections)->getCourse()->getCourseName();
         $new_res = array_filter($courseSections, function ($elem) use($name) {
             return $elem->getCourse()->getCourseName() === $name;
         });
         $courseSections = array_filter($courseSections, function ($elem) use($name) {
             return $elem->getCourse()->getCourseName() != $name;
         });
         array_push($result, $new_res);
     }
     $copy = $result;
     $result = array();
     //Now that we have the subjects, we need to group sections into courses by course number
     foreach ($copy as $r) {
         $next = array();
         while (count($r) > 0) {
             $num = reset($r)->getCourse()->getCourseNumber();
             $new_res = array_filter($r, function ($elem) use($num) {
                 return $elem->getCourse()->getCourseNumber() === $num;
             });
             $r = array_filter($r, function ($elem) use($num) {
                 return $elem->getCourse()->getCourseNumber() != $num;
             });
             array_push($next, $new_res);
         }
         array_push($result, $next);
     }
     /*$result = array_filter($result, function($elem)
       {
           return count($elem) > 0;
       });*/
     $copy = $result;
     $result = array();
     foreach ($copy as $res) {
         foreach ($res as $r) {
             usort($r, function ($a, $b) {
                 return $a->getSectionName() < $b->getSectionName() ? 1 : -1;
             });
         }
         array_push($result, $res);
     }
     $copy = $result;
     $result = array();
     foreach ($copy as $r) {
         usort($r, function ($a, $b) {
             return reset($a)->getCourse()->getCourseNumber() > reset($b)->getCourse()->getCourseNumber() ? 1 : -1;
         });
         array_push($result, $r);
     }
     usort($result, function ($a, $b) {
         return reset(reset($a))->getCourse()->getCourseName() > reset(reset($b))->getCourse()->getCourseName() ? 1 : -1;
     });
     $copy = $result;
     $result = array();
     foreach ($copy as $subj) {
         $subject = new Subject();
         $subject->setName(reset(reset($subj))->getCourse()->getCourseName());
         $subject->setTitle(reset(reset($subj))->getCourse()->getCourseCategoryName());
         $courses = array();
         foreach ($subj as $crs) {
             $course = new Course();
             $course->setName(reset($crs)->getCourse()->getCourseNumber());
             $course->setTitle(reset($crs)->getCourse()->getCourseTitle());
             $course->setHours(reset($crs)->getHours());
             $course->setSections($crs);
             array_push($courses, $course);
         }
         $subject->setCourses($courses);
         array_push($result, $subject);
     }
     return $result;
 }
예제 #10
0
 /**
  * Display default page
  *
  * @return     void
  */
 public function testgroundTask()
 {
     if (0) {
         // CREATE COUPON
         include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'StorefrontModelCoupon.php';
         try {
             // Constructor take the coupon code
             $coupon = new Coupon('hui');
             // Coupon description (shows up in the cart)
             $coupon->setDescription('Test coupon, 10% off product with ID 3');
             // Expiration date
             $coupon->setExpiration('Feb 22, 2022');
             // Number of times coupon can be used (unlimited by default)
             $coupon->setUseLimit(1);
             // Product the coupon will be applied to:
             // first parameter: product ID
             // second parameter [optional, unlimited by default]: max quantity of products coupon will be applied to (if buying multiple)
             $coupon->addObject(3, 1);
             // Action, only 'discount' for now
             // second parameter either percentage ('10%') or absolute dollar value ('20')
             $coupon->setAction('discount', '10%');
             // Add coupon
             $coupon->add();
         } catch (\Exception $e) {
             echo 'ERROR: ' . $e->getMessage();
         }
         return;
     }
     if (0) {
         // DELETE COUPON
         $warehouse = new Warehouse();
         try {
             $warehouse->deleteCoupon('couponcode3');
         } catch (\Exception $e) {
             echo 'ERROR: ' . $e->getMessage();
         }
         return;
     }
     if (0) {
         // CREATE NEW COURSE
         include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'Course.php';
         $course = new Course();
         $course->setName('Name of the course');
         $course->setDescription('Short description');
         $course->setPrice(12.0);
         $course->addToCollection('courses');
         // Membership model: membership duration period (must me in MySQL date format: 1 DAY, 2 MONTH, 3 YEAR...)
         $course->setTimeToLive('1 YEAR');
         // Course alias id
         $course->setCourseId('nanoscaletransistors');
         try {
             // Returns object with values, pId is the new product ID to link to
             $info = $course->add();
             //print_r($info);
         } catch (\Exception $e) {
             echo 'ERROR: ' . $e->getMessage();
         }
         return;
     }
     if (0) {
         // GET EXISTING COURSE, modify it and save
         $warehouse = new Warehouse();
         try {
             // Get course by pID returned with $course->add() above
             $course = $warehouse->getCourse(1);
             $course->setName('Renamed');
             $course->setDescription('New description');
             $course->setPrice(55.22);
             $course->setTimeToLive('10 YEAR');
             $course->update();
         } catch (\Exception $e) {
             echo 'ERROR: ' . $e->getMessage();
         }
         return;
     }
     if (0) {
         // UPDATE COURSE by recreating it
         include_once JPATH_BASE . DS . 'components' . DS . 'com_storefront' . DS . 'models' . DS . 'StorefrontModelCourse.php';
         $course = new Course();
         $course->setName('Operations Management 104');
         $course->setDescription('Operations Management 104 is some kind of test course for now...');
         $course->setPrice(13.05);
         $course->setCourseId(5);
         // Existing course ID (pID returned with $course->add() when the course was created). Must be set to be able to update.
         $course->setId(1023);
         try {
             $info = $course->update();
             //print_r($info);
         } catch (\Exception $e) {
             echo 'ERROR: ' . $e->getMessage();
         }
         return;
     }
     if (0) {
         // DELETE COURSE
         $warehouse = new Warehouse();
         // Delete by existing course ID (pID returned with $course->add() when the course was created)
         $warehouse->deleteProduct(1023);
         return;
     }
 }
예제 #11
0
 public function createCourse($career_subject_school_year_id, PropelPDO $con = null)
 {
     $career_subject_school_year = CareerSubjectSchoolYearPeer::retrieveByPk($career_subject_school_year_id);
     $course = new Course();
     $course->setName($this->getName() . ' ' . $career_subject_school_year->getCareerSubject()->getSubjectName());
     $course->setDivision($this);
     $course->setSchoolYear($career_subject_school_year->getSchoolYear());
     $course->save($con);
     $career_subject_school_year->createCourseSubject($course, $con);
 }
예제 #12
0
파일: Course.php 프로젝트: nvidela/kimkelen
 public function createCopyForSchoolYear(PropelPDO $con = null, Division $division = null, CareerSchoolYear $career_school_year)
 {
     $copy_course = new Course();
     $copy_course->setDivision($division);
     $copy_course->setName($this->getName());
     $copy_course->setQuota($this->getQuota());
     $copy_course->setSchoolYear($career_school_year->getSchoolYear());
     $copy_course->save($con);
     $this->copyCourseSubjects($con, $division, $career_school_year, $copy_course);
     $copy_course->clearAllReferences(true);
     unset($copy_course);
     $this->clearAllReferences(true);
 }