Ejemplo n.º 1
0
 public function outOffering(Offering $offering)
 {
     $rs = $this->container->get('review');
     $name = '[' . $offering->getCourse()->getName() . ']' . '(' . $offering->getUrl() . ')';
     if ($offering->getInitiative() == null) {
         $initiative = 'Others';
     } else {
         $initiative = $offering->getInitiative()->getName();
     }
     $startDate = $offering->getDisplayDate();
     $length = 'NA';
     if ($offering->getCourse()->getLength() != 0) {
         $length = $offering->getCourse()->getLength();
     }
     // Rating
     $courseRating = round($rs->getRatings($offering->getCourse()->getId()), 1);
     $courseReviews = $rs->getReviewsArray($offering->getCourse()->getId());
     $reviewText = '';
     if ($courseRating == 0) {
         $courseRating = 'NA';
     } else {
         $reviewText = sprintf("(%d %s)", $courseReviews['count'], $courseReviews['count'] == 1 ? 'review' : 'reviews');
     }
     $url = 'https://www.class-central.com' . $this->router->generate('ClassCentralSiteBundle_mooc', array('id' => $offering->getCourse()->getId(), 'slug' => $offering->getCourse()->getSlug()));
     $url .= '#reviews';
     $ratingStars = ReviewUtility::getRatingStars($courseRating);
     $rating = "{$ratingStars} [{$reviewText}]({$url})";
     $this->output->writeln("{$name}|{$startDate}|{$length}|{$initiative}|{$rating}");
 }
Ejemplo n.º 2
0
 public function outOffering(Offering $offering)
 {
     $rs = $this->container->get('review');
     $name = '[' . $offering->getCourse()->getName() . ']' . '(' . $offering->getUrl() . ')';
     if ($offering->getInitiative() == null) {
         $initiative = 'Others';
     } else {
         $initiative = $offering->getInitiative()->getName();
     }
     $startDate = $offering->getDisplayDate();
     $startDate = array_shift(explode(',', $startDate));
     // Do not show the year to save characters
     $length = 'NA';
     if ($offering->getCourse()->getLength() != 0) {
         $length = $offering->getCourse()->getLength();
     }
     // Rating
     $courseRating = round($rs->getRatings($offering->getCourse()->getId()), 1);
     $courseReviews = $rs->getReviewsArray($offering->getCourse()->getId());
     $reviewText = '';
     if ($courseRating == 0) {
         $courseRating = 'NA';
     } else {
         $reviewText = sprintf("(%d)", $courseReviews['count']);
     }
     $url = 'https://www.class-central.com' . $this->router->generate('reviews_short_url', array('courseId' => $offering->getCourse()->getId()));
     $url .= '#reviews';
     $ratingStars = ReviewUtility::getRatingStars($courseRating);
     if ($courseRating > 0) {
         $rating = "{$ratingStars} [{$reviewText}]({$url})";
     } else {
         $rating = "{$ratingStars}";
     }
     $this->output->writeln("{$name} via **{$initiative}**|{$startDate}|{$length}|{$rating}");
 }
Ejemplo n.º 3
0
 public function outOffering(Offering $offering)
 {
     $course = $offering->getCourse();
     $rs = $this->container->get('review');
     // Figure out whether the course is new
     $oneMonthAgo = new \DateTime();
     $oneMonthAgo->sub(new \DateInterval("P30D"));
     $newCourse = false;
     if ($course->getCreated() >= $oneMonthAgo) {
         $newCourse = true;
     }
     // Is it being offered for he first time
     if (count($course->getOfferings()) == 1 and $offering->getCreated() > $oneMonthAgo) {
         $newCourse = true;
     }
     if (count($course->getOfferings()) == 1 and $offering->getStatus() != Offering::COURSE_OPEN) {
         $newCourse = true;
     }
     $name = '[' . $offering->getCourse()->getName() . ']' . '(' . $offering->getUrl() . ')';
     if ($offering->getInitiative() == null) {
         $initiative = 'Others';
     } else {
         $initiative = $offering->getInitiative()->getName();
     }
     $startDate = $offering->getDisplayDate();
     $startDate = array_shift(explode(',', $startDate));
     // Do not show the year to save characters
     $length = 'NA';
     if ($offering->getCourse()->getLength() != 0) {
         $length = $offering->getCourse()->getLength();
     }
     // Rating
     $courseRating = round($rs->getRatings($offering->getCourse()->getId()), 1);
     $courseReviews = $rs->getReviewsArray($offering->getCourse()->getId());
     $reviewText = '';
     if ($courseRating == 0) {
         $courseRating = 'NA';
     } else {
         $reviewText = sprintf("(%d)", $courseReviews['count']);
     }
     $url = 'https://www.class-central.com' . $this->router->generate('reviews_short_url', array('courseId' => $offering->getCourse()->getId()));
     //$url .= '#reviews';
     $ratingStars = ReviewUtility::getRatingStars($courseRating);
     if ($courseRating > 0) {
         $rating = "{$ratingStars} [{$reviewText}]({$url})";
     } else {
         $rating = "{$ratingStars}";
     }
     $new = '';
     if ($newCourse) {
         $new = "[NEW]";
     }
     $this->output->writeln("{$new} {$name} via **{$initiative}**|{$startDate}|{$length}|{$rating}");
 }
Ejemplo n.º 4
0
 public function outOffering(Offering $offering)
 {
     // Print the title line
     $titleLine = $offering->getName();
     if ($offering->getStatus() == Offering::START_DATES_KNOWN) {
         $titleLine .= ' - ' . $offering->getStartDate()->format('M jS');
     }
     $this->output->writeln($titleLine);
     $this->output->writeln($offering->getUrl());
     $this->output->writeln(' ');
 }
 public function outOffering(Offering $offering)
 {
     // Print the title line
     $titleLine = $this->getItalics($offering->getName());
     if ($offering->getStatus() == Offering::START_DATES_KNOWN) {
         $titleLine .= ' - ' . $offering->getStartDate()->format('M jS');
     }
     $this->output->writeln($titleLine);
     // Print out the course length. Exclude Udacity because course length is same
     if ($offering->getInitiative()->getCode() != 'UDACITY' && $offering->getLength() != 0) {
         $this->output->writeln($this->getItalics($offering->getLength() . " weeks long"));
     }
     // Output the URL
     $this->output->writeln($offering->getUrl());
     // Output an empty line
     $this->output->writeln('');
 }
 /**
  * Returns an array of values for a particular display
  * @param \ClassCentral\SiteBundle\Entity\Offering $offering
  * @return Array
  */
 public function getOfferingArray(Offering $offering)
 {
     $offeringArray = array();
     $course = $offering->getCourse();
     $offeringArray['id'] = $offering->getId();
     $offeringArray['name'] = $offering->getName();
     $offeringArray['url'] = $offering->getUrl();
     $offeringArray['videoIntro'] = $course->getVideoIntro();
     $offeringArray['length'] = $course->getLength();
     $offeringArray['startTimeStamp'] = $offering->getStartTimestamp();
     $offeringArray['displayDate'] = $offering->getDisplayDate();
     $offeringArray['startDate'] = $offering->getStartDate()->format('d-m-Y');
     $offeringArray['microdataDate'] = $offering->getMicrodataDate();
     $offeringArray['status'] = $offering->getStatus();
     // Stream
     $stream = $course->getStream();
     $offeringArray['stream']['name'] = $stream->getName();
     $offeringArray['stream']['slug'] = $stream->getSlug();
     $offeringArray['stream']['showInNav'] = $stream->getShowInNav();
     $initiative = $course->getInitiative();
     $offeringArray['initiative']['name'] = '';
     if ($initiative != null) {
         $offeringArray['initiative']['name'] = $initiative->getName();
         $offeringArray['initiative']['url'] = $initiative->getUrl();
         $offeringArray['initiative']['tooltip'] = $initiative->getTooltip();
         $offeringArray['initiative']['code'] = strtolower($initiative->getCode());
     }
     // Language
     $language = $course->getLanguage();
     $offeringArray['language']['name'] = '';
     if ($language) {
         $offeringArray['language']['name'] = $language->getName();
     }
     // Add Institutions
     $offeringArray['institutions'] = array();
     foreach ($course->getInstitutions() as $institution) {
         $offeringArray['institutions'][] = array('name' => $institution->getName(), 'url' => $institution->getUrl(), 'slug' => $institution->getSlug(), 'isUniversity' => $institution->getIsUniversity());
     }
     $offeringArray['instructors'] = array();
     foreach ($course->getInstructors() as $instructor) {
         $offeringArray['instructors'][] = $instructor->getName();
     }
     // Generate the course url
     $offeringArray['courseSlug'] = $course->getSlug();
     $offeringArray['courseId'] = $course->getId();
     return $offeringArray;
 }