aboutsummaryrefslogtreecommitdiff
path: root/lib/models/Courseware/StructuralElement.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/models/Courseware/StructuralElement.php')
-rw-r--r--lib/models/Courseware/StructuralElement.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/models/Courseware/StructuralElement.php b/lib/models/Courseware/StructuralElement.php
index 58b01e2..50ba714 100644
--- a/lib/models/Courseware/StructuralElement.php
+++ b/lib/models/Courseware/StructuralElement.php
@@ -494,9 +494,23 @@ class StructuralElement extends \SimpleORMap implements \PrivacyObject, \Feedbac
return false;
}
- return
- (empty($this->visible_start_date) || $this->visible_start_date <= strtotime('today'))
- && (empty($this->visible_end_date) || $this->visible_end_date >= strtotime('today'));
+ $todayStart = strtotime('today');
+ $todayDateInt = (int) date('Ymd', $todayStart);
+
+ $isAfterStart = true;
+ if (!empty($this->visible_start_date)) {
+ $startDateInt = (int) date('Ymd', $this->visible_start_date);
+ $isAfterStart = $startDateInt <= $todayDateInt;
+ }
+
+ $isBeforeEnd = true;
+ if (!empty($this->visible_end_date)) {
+ $endDateString = date('Y-m-d', $this->visible_end_date) . ' 23:59:59';
+ $visibleEndOfDay = strtotime($endDateString);
+ $isBeforeEnd = $visibleEndOfDay >= $todayStart;
+ }
+
+ return $isAfterStart && $isBeforeEnd;
}
private function hasReadContentApproval($user): bool