function CourseObjectAccessTiming::take in Course 7.2
Same name and namespace in other branches
- 6 plugins/course/access/timing.inc \CourseObjectAccessTiming::take()
- 7 plugins/course_object_access/timing.inc \CourseObjectAccessTiming::take()
Can the user take the object?
Parameters
type $account:
Return value
boolean
Overrides CourseObjectAccess::take
1 call to CourseObjectAccessTiming::take()
- CourseObjectAccessTiming::view in plugins/
course_object_access/ timing.inc - Can the user view the object but not interact?
File
- plugins/
course_object_access/ timing.inc, line 27
Class
Code
function take($account) {
$time = REQUEST_TIME;
if ($this
->getOption('duration')) {
if ($this
->getCourseObject()
->getFulfillment($account)
->getOption('date_started')) {
$duration_end = $this
->getCourseObject()
->getFulfillment($account)
->getOption('date_started') + $this
->getOption('duration');
if ($time > $duration_end) {
$duration_end_h = format_date($duration_end, 'long');
$this
->getCourseObject()
->setAccessMessage('duration-expired', t('Your enrollment in this activity expired on %date.', array(
'%date' => $duration_end_h,
)));
return FALSE;
}
}
}
$released = $this
->isReleased();
$expired = $this
->isExpired();
return $released && !$expired;
}