function testCreate_OneToMany()
 {
     $this->_createModelAndIncludeThem('lecture', 'Lecture');
     $this->_createModelAndIncludeThem('course', 'Course');
     $course = new Course();
     $course->setTitle($course_title = 'bar');
     $course->save();
     $lecture = new Lecture();
     $lecture->setTitle($lecture_title = 'foo');
     $lecture->setCourse($course);
     $lecture->save();
     $loaded_lecture = lmbActiveRecord::findById('Lecture', $lecture->getId());
     $this->assertEqual($loaded_lecture->getTitle(), $lecture_title);
     $this->assertEqual($loaded_lecture->getCourse()->getId(), $course->getId());
     $loaded_course = lmbActiveRecord::findById('Course', $course->getId());
     $this->assertEqual($loaded_course->getLectures()->at(0)->getId(), $lecture->getId());
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
     Message::register(new Message(Message::DANGER, i18n(array("en" => "country_id is required.", "zh" => "请填写country_id"))));
     $error_flag = true;
 }
 // validation for $content
 $content = isset($_POST["content"]) ? $_POST["content"] : null;
 if (empty($content)) {
     Message::register(new Message(Message::DANGER, i18n(array("en" => "content is required.", "zh" => "请填写content"))));
     $error_flag = true;
 }
 // validation for $url
 $url = isset($_POST["url"]) ? strip_tags($_POST["url"]) : null;
 // validation for $weight
 $weight = isset($_POST["weight"]) ? strip_tags($_POST["weight"]) : null;
 /// proceed submission
 // proceed for $title
 $object->setTitle($title);
 // proceed for $country_id
 if (!empty($country_id)) {
     $object->setCountryId($country_id);
 }
 // proceed for $content
 $object->setContent($content);
 // proceed for $url
 $object->setUrl($url);
 // proceed for $weight
 $object->setWeight($weight);
 if ($error_flag == false) {
     if ($object->save()) {
         Message::register(new Message(Message::SUCCESS, i18n(array("en" => "Record saved", "zh" => "记录保存成功"))));
         HTML::forwardBackToReferer();
     } else {
Esempio n. 4
0
 /**
  * A sample detail bean for use in rendering the template.
  * If a course is supplied, it will copy thevalues of the
  * given bean over the top of the demo bean.
  * @return
  */
 private function getDemoCourseDetail($crse)
 {
     require_once WEB_INF . '/beans/Performance.php';
     require_once WEB_INF . '/beans/Schedule.php';
     require_once WEB_INF . '/beans/Venue.php';
     global $logger;
     $logger->debug(get_class($this) . "::getDemoCourseDetail({$crse})");
     $bean = new Course();
     $bean->setTitle("Demo Course Detail Bean");
     $desc = "<p>This is a description of the course. Malian Grammy Award nominee Mamadou Diabate is a virtuoso kora player descended from a long line of Manding musician-storytellers. Dolor dignissim exerci feugiat. Lobortis ut, luptatum facilisis. Augue volutpat facilisis at, eum consequat adipiscing accumsan blandit molestie. </p>\n\t\t\t\t <p>Lobortis eros at hendrerit luptatum consequat feugiat ut facilisi commodo esse autem consequat at ex ullamcorper hendrerit wisi, commodo nostrud nisl wisi eum autem eu esse eu iriure. Tation, magna ad nibh at eum, ea praesent eum lorem eu erat enim commodo dolore?</p>\n \t\t\t\t <p>Crisare enim sed ex eros hendrerit blandit illum qui sciurus autem nulla enim luptatum. Quis enim eum feugait elit blandit, hendrerit consequat, velit ut luptatum nostrud wisi ea. Dignissim consequat dolore aliquam eum volutpat, wisi dolore et exerci nisl veniam luptatum ut ullamcorper consequatvel nulla delenit.</p>\n\t\t\t\t";
     $bean->setDescription($desc);
     $bean->setPrimaryGenre("Music");
     // Performances
     $perf = new Performance();
     $schd = new Schedule();
     $schd->setStartTime(time());
     $perf->setSchedule($schd);
     $logger->debug("Performance time: " . $perf->getSchedule()->getStartTime());
     $perf->setTicketCode("21");
     $bean->setChildren(array($perf));
     $logger->debug("Number of set performaces: " . count($bean->getChildren()));
     // Venues
     $v1 = new Venue();
     $v1->setName('Hurd Gallery');
     $bean->setDefaultVenue($v1);
     if (get_class($crse) == 'Course') {
         $crse->setPerformances(null);
         $option = new CopyBeanOption();
         $option->setIgnoreNullValues(true);
         BeanUtil::copyBean($crse, $bean, $option);
     }
     return $bean;
 }
Esempio n. 5
0
<li>雅思预备课程(读五周以上):<br />
A) 早班 : 星期一至星期四,  (8:45am – 2:30pm) ,每周学费$190
<br />
B) 晚班 : 星期一至星期五, (4:00pm – 8:30pm  ) ,每周学费$190
</li>
</ol>

<h3>院校介绍:</h3>
<p>
位于新南威尔士州悉尼市,是澳大利亚一所历史悠久的私立学院。学院提供英语方面的课程,包括通用英语,雅思预备英语课程,学术英语课程。同时,学院还提供商务三级证书,商务四级证书和商务文凭的职业教育商专课程。 
</p>
');
    $course->save();
    $course = new Course();
    $course->setTitle('证书和文凭课程, 每三个月学费仅A$1,300,半年仅$2300');
    $course->setCountryId(1);
    $course->setWeight(1);
    $course->setContent('
<p>三级证书,四级证书,管理文凭课程,每三个月仅$1300,六个月学费一次付清只需 $2,300</p>
<p>
A) 三级证书,Certificate III in Busines:
<br />
六个月学费分两次支付: $1,300 / 3 个月
<br />
六个月学费一次付清只需 $2,300 / 6 个月
<br />
早班 :星期三至星期四, (8:30am – 5:00pm)
<br />
晚班 :  星期一至星期三, (5:00pm – 10:00pm )
<br />