diff --git a/mod/data/lang/en/data.php b/mod/data/lang/en/data.php index 88d20507aa8df..9ccaf3a700d93 100755 --- a/mod/data/lang/en/data.php +++ b/mod/data/lang/en/data.php @@ -173,6 +173,7 @@ $string['chooseexportfields'] = 'Choose the fields you wish to export:'; $string['chooseexportformat'] = 'Choose the format you wish to export to:'; $string['chooseorupload'] = 'Choose file'; +$string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available'; $string['importsuccess'] = 'The preset has been successfully applied.'; $string['insufficiententries'] = 'more entries needed to view this database'; $string['intro'] = 'Introduction'; @@ -242,6 +243,7 @@ $string['nosingletemplate'] = 'Single template is not yet defined'; $string['notapproved'] = 'Entry is not approved yet.'; $string['notinjectivemap'] = 'Not an injective map'; +$string['notopenyet'] = 'Sorry, this activity is not available until {$a}'; $string['number'] = 'Number'; $string['numberrssarticles'] = 'RSS articles'; $string['numnotapproved'] = 'Pending'; diff --git a/mod/data/lib.php b/mod/data/lib.php index fa9ecb0216215..6ca7cdb4d7570 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1946,6 +1946,12 @@ function data_user_can_add_entry($data, $currentgroup, $groupmode) { return false; } + //if in the view only time window + $now = time(); + if ($now>$data->timeviewfrom && $now<$data->timeviewto) { + return false; + } + if (!$groupmode or has_capability('moodle/site:accessallgroups', $context)) { return true; } diff --git a/mod/data/view.php b/mod/data/view.php index 757405de17932..162ba899152ab 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -368,6 +368,15 @@ } +//if data activity closed dont let students in +if (!has_capability('mod/data:manageentries', $context)) { + $timenow = time(); + if (!empty($data->timeavailablefrom) && $data->timeavailablefrom > $timenow) { + print_error('notopenyet', 'data', null, userdate($data->timeavailablefrom)); + } else if (!empty($data->timeavailableto) && $timenow > $data->timeavailableto) { + print_error('expired', 'data', null, userdate($data->timeavailableto)); + } +} /// Print the tabs