function CourseObjectAccessConditional::take in Course 6
Same name and namespace in other branches
- 7.2 plugins/course_object_access/conditional.inc \CourseObjectAccessConditional::take()
- 7 plugins/course_object_access/conditional.inc \CourseObjectAccessConditional::take()
Overrides CourseObjectAccess::take
1 call to CourseObjectAccessConditional::take()
- CourseObjectAccessConditional::view in plugins/
course/ access/ conditional.inc
File
- plugins/
course/ access/ conditional.inc, line 23
Class
Code
function take() {
$type = $this
->getOption('conditional_type');
$offset = $this
->getOption('conditional_time');
$time = time();
$access = TRUE;
if ($type) {
foreach ($this
->getCourseObject()
->getCourse()
->getObjects() as $courseObject) {
if ($courseObject
->getId() == $this
->getOption('conditional_object')) {
switch ($type) {
case 'completed':
$completed = $courseObject
->getFulfillment()
->getOption('date_completed');
if (!$completed) {
$access = FALSE;
}
else {
$access = $time >= $completed + $offset;
}
break;
case 'started':
$started = $courseObject
->getFulfillment()
->getOption('date_started');
if (!$started) {
$access = FALSE;
}
else {
$access = $time >= $started + $offset;
}
break;
}
}
}
}
return $access;
}