Index: mod/data/view.php
===================================================================
--- mod/data/view.php	(revision )
+++ mod/data/view.php	(revision )
@@ -308,6 +308,22 @@
         }
     }
 
+//if data activity closed do not let students in (nadavkav patch)
+if (!has_capability('mod/data:manageentries', $context)) {
+    $timenow = time();
+    if (!empty($data->timeavailablefrom) && $data->timeavailablefrom > $timenow) {
+        //print_error('notopenyet', 'data', null, userdate($data->timeavailablefrom));
+        notice(get_string('notopenyet','data',userdate($data->timeavailablefrom)),$CFG->wwwroot.'/course/view.php?id='.$course->id);
+        // Please add the following translation token to moodledata/lang/en_utf8_local/data.php
+        // $string['notopenyet'] = 'This activity is not open, yet.<br/> please come back on $a';
+    } else if (!empty($data->timeavailableto) && $timenow > $data->timeavailableto) {
+        //print_error('expired', 'data', null, userdate($data->timeavailableto));
+        notice(get_string('expired','data',userdate($data->timeavailableto)),$CFG->wwwroot.'/course/view.php?id='.$course->id);
+        // Please add the following translation token to moodledata/lang/en_utf8_local/data.php
+        // $string['expired'] = 'This activity is no longer available.<br/> It was open until $a';
+    }
+}
+
     print_heading(format_string($data->name));
 
     // Do we need to show a link to the RSS feed for the records?
