Пример #1
0
 /**
  * Is the section passed in the current section?
  *
  * @param stdClass $section The course_section entry from the DB
  * @return bool true if the section is current
  */
 public function is_section_current($section)
 {
     $tcsettings = $this->get_settings();
     if ($tcsettings['layoutstructure'] == 2 || $tcsettings['layoutstructure'] == 3) {
         if ($section->section < 1) {
             return false;
         }
         $timenow = time();
         $dates = $this->format_collblct_get_section_dates($section, $this->get_course());
         return $timenow >= $dates->start && $timenow < $dates->end;
     } else {
         if ($tcsettings['layoutstructure'] == 5) {
             if ($section->section < 1) {
                 return false;
             }
             $timenow = time();
             $day = $this->format_collblct_get_section_day($section, $this->get_course());
             $onedayseconds = 86400;
             return $timenow >= $day && $timenow < $day + $onedayseconds;
         } else {
             return parent::is_section_current($section);
         }
     }
 }
Пример #2
0
    /**
     * Is the section passed in the current section?
     *
     * @param stdClass $section The course_section entry from the DB
     * @return bool true if the section is current
     */
    public function is_section_current($section) {
        $tcsettings = $this->get_settings();
        if (($tcsettings['layoutstructure'] == 2) || ($tcsettings['layoutstructure'] == 3)) {
            if ($section->section < 1) {
                return false;
            }

            $timenow = time();
            $dates = $this->format_topcoll_get_section_dates($section, $this->get_course());

            return (($timenow >= $dates->start) && ($timenow < $dates->end));
        } else if ($tcsettings['layoutstructure'] == 5) {
            if ($section->section < 1) {
                return false;
            }

            $timenow = time();
            $day = $this->format_topcoll_get_section_day($section, $this->get_course());
            $onedayseconds = 86400;
            return (($timenow >= $day) && ($timenow < ($day + $onedayseconds)));
        } else {
            return parent::is_section_current($section);
        }
    }
Пример #3
0
 protected function set_chapters()
 {
     $this->chapters = (object) [];
     $this->chapters->listlarge = $this->course->numsections > 9 ? 'list-large' : '';
     $this->chapters->chapters = [];
     $canviewhidden = has_capability('moodle/course:viewhiddensections', context_course::instance($this->course->id));
     $modinfo = get_fast_modinfo($this->course);
     foreach ($modinfo->get_section_info_all() as $section => $thissection) {
         if ($section > $this->course->numsections) {
             continue;
         }
         // Students - If course hidden sections completely invisible & section is hidden, and you cannot
         // see hidden things, bale out.
         if ($this->course->hiddensections && !$thissection->visible && !$canviewhidden) {
             continue;
         }
         $conditional = $this->is_section_conditional($thissection);
         $chapter = new course_toc_chapter();
         $chapter->outputlink = true;
         if ($canviewhidden) {
             // Teachers.
             if ($conditional) {
                 $chapter->availabilityclass = 'text-danger';
                 $chapter->availabilitystatus = get_string('conditional', 'theme_snap');
             }
             if (!$thissection->visible) {
                 $chapter->availabilityclass = 'text-warning';
                 $chapter->availabilitystatus = get_string('notpublished', 'theme_snap');
             }
         } else {
             // Students.
             if ($conditional && !$thissection->uservisible && !$thissection->availableinfo) {
                 // Conditional section, totally hidden from user so skip.
                 continue;
             }
             if ($conditional && $thissection->availableinfo) {
                 $chapter->availabilityclass = 'text-danger';
                 $chapter->availabilitystatus = get_string('conditional', 'theme_snap');
             }
             if (!$conditional && !$thissection->visible) {
                 // Hidden section collapsed, so show as text in TOC.
                 $chapter->outputlink = false;
                 $chapter->availabilityclass = 'text-warning';
                 $chapter->availabilitystatus = get_string('notavailable');
             }
         }
         $chapter->title = get_section_name($this->course, $section);
         if ($chapter->title == get_string('general')) {
             $chapter->title = get_string('introduction', 'theme_snap');
         }
         if ($this->format->is_section_current($section)) {
             $chapter->iscurrent = true;
         }
         if ($chapter->outputlink) {
             $singlepage = $this->course->format !== 'folderview';
             if ($singlepage) {
                 $chapter->url = '#section-' . $section;
             } else {
                 if ($section > 0) {
                     $chapter->url = course_get_url($this->course, $section, ['navigation' => true, 'sr' => $section]);
                 } else {
                     // We need to create the url for section 0, or a hash will get returned.
                     $chapter->url = new moodle_url('/course/view.php', ['id' => $this->course->id, 'section' => $section]);
                 }
             }
         }
         $chapter->progress = new course_toc_progress($this->course, $thissection);
         $this->chapters->chapters[] = $chapter;
     }
 }