public function test_course_management_without_data() { global $CFG, $DB; $this->resetAfterTest(false); $open = EclassCourseManager::get_course_open($this->referenceobjects['course2']->id); $close = EclassCourseManager::get_course_close($this->referenceobjects['course2']->id); $this->assertEquals(false, $open); $this->assertEquals(false, $close); }
public function get_content() { global $COURSE; if ($this->content !== null) { return $this->content; } // Create empty content. $this->content = new stdClass(); $this->content->text = ''; // Use Strict as this block should only ever be in a course context. $context = context_course::instance($this->page->course->id); if (!has_capability('block/eclass_course_management:canseeblock', $context)) { return $this->content->text = ''; } $open = EclassCourseManager::get_course_open($context->instanceid); $close = EclassCourseManager::get_course_close($context->instanceid); if ($open) { $date = usergetdate($open); $this->content->text .= '<br/>' . get_string('open_label', 'block_eclass_course_management') . ' ' . "{$date['month']} {$date['mday']}, {$date['year']}"; } else { $this->content->text .= '<br/>' . get_string('nostartdate', 'block_eclass_course_management'); } if ($close) { $date = usergetdate($close); $this->content->text .= '<br/>' . get_string('close_label', 'block_eclass_course_management') . ' ' . "{$date['month']} {$date['mday']}, {$date['year']}"; } else { $this->content->text .= '<br/>' . get_string('noenddate', 'block_eclass_course_management'); } if ($COURSE->visible) { $this->content->text .= '<br/>' . get_string('status_label', 'block_eclass_course_management') . ' ' . get_string('visible', 'block_eclass_course_management'); } else { $this->content->text .= '<br/>' . get_string('status_label', 'block_eclass_course_management') . ' ' . get_string('notvisible', 'block_eclass_course_management'); } if (!empty($this->content->text)) { $this->content->text = get_string('blockpreamble', 'block_eclass_course_management') . '<br/>' . $this->content->text; } if (has_capability('moodle/course:update', $context)) { $this->content->text .= "<br/><a href='/blocks/eclass_course_management/configure.php?course={$COURSE->id}'>Edit</a>"; } return $this->content; }
/** * Tests that the library returns the correct start/end dates */ public function test_returns_correct_dates() { // Required if modifying database within the test. $this->resetAfterTest(true); $start = time() + 86400; $end = time() + 2 * 86400; // Course names are appended with Start, Now, and End, in chronological order. $course = $this->create_course_vis_start_end(0, $start, $end); $this->assertEquals($start, EclassCourseManager::get_course_open($course->id)); $this->assertEquals($end, EclassCourseManager::get_course_close($course->id)); }