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}");
 }
 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('');
 }
Ejemplo n.º 5
0
 public function sendNewOfferingToSlack(Offering $offering)
 {
     try {
         $course = $offering->getCourse();
         $initiative = $offering->getInitiative();
         $providerInfo = PageHeaderFactory::get($initiative);
         $coursePageUrl = $this->scraper->getContainer()->getParameter('baseurl') . $this->scraper->getContainer()->get('router')->generate('ClassCentralSiteBundle_mooc', array('id' => $course->getId(), 'slug' => $course->getSlug()));
         $logo = $this->scraper->getContainer()->getParameter('rackspace_cdn_base_url') . $providerInfo->getImageUrl();
         $message = "[New Session] *{$course->getName()}* -  {$offering->getDisplayDate()}\n" . $coursePageUrl;
         $this->scraper->getContainer()->get('slack_client')->to('#cc-activity-data')->from($initiative->getName())->withIcon($logo)->send($message);
     } catch (\Exception $e) {
     }
 }