/** * Invalidate the cache for the given paper * @param integer $paper_id ID of paper for which the cache should be invalidated */ protected function invalidate_paper_cache($paper_id) { $properties = new PaperProperties($this->_mysqli); $properties->set_property_id($paper_id); $properties->load(); $properties->set_recache_marks(1); $properties->save(); }
static function get_paper_properties_by_lab($lab_object, $db) { $sql = "SELECT\n \t\t\tproperties.property_id,\n \t\t\tpaper_title,\n \t\t\tUNIX_TIMESTAMP(start_date) AS start_date,\n UNIX_TIMESTAMP(end_date) AS end_date,\n \t\t\texam_duration,\n \t\t\tcalendar_year,\n \t\t\tpassword,\n \t\t\ttimezone,\n rubric\n \t\tFROM\n \t\t\tproperties\n \t\tWHERE\n \t\t\tpaper_type = '2' AND\n \t\t\tlabs REGEXP ? AND\n \t\t\tstart_date < DATE_ADD( NOW(), interval 30 minute ) AND\n \t\t\tend_date > NOW() AND\n \t\t\tdeleted IS NULL"; $paper_results = $db->prepare($sql); // TODO get_lab_based_on_client only fetches the first lab that populates $lab_object // If an ip address is on many labs we only use with the first we come across $lab_regexp = "(^|,)(" . $lab_object->get_id() . ")(,|\$)"; $paper_results->bind_param('s', $lab_regexp); $paper_results->execute(); $paper_results->store_result(); $paper_results->bind_result($property_id, $paper_title, $start_date, $end_date, $exam_duration, $calendar_year, $password, $timezone, $rubric); if ($paper_results->num_rows <= 0) { $paper_results->close(); return false; } $properties = array(); while ($paper_results->fetch()) { $property_object = new PaperProperties($db); $property_object->set_property_id($property_id); $property_object->set_paper_title($paper_title); $property_object->set_start_date($start_date); $property_object->set_end_date($end_date); $property_object->set_exam_duration($exam_duration); $property_object->set_calendar_year($calendar_year); $property_object->set_calendar_year($calendar_year); $property_object->set_password($password); $property_object->set_timezone($timezone); $property_object->set_display_start_date(); $property_object->set_display_start_time(); $property_object->set_display_end_date(); $property_object->set_display_end_time(); $property_object->set_rubric($rubric); $properties[] = $property_object; } $paper_results->close(); return $properties; }