Пример #1
0
/**
 * @param string $tool
 * @param int $ref
 * @return array|resource
 */
function api_get_track_item_property_history($tool, $ref)
{
    $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
    $course_id = api_get_real_course_id();
    //numeric
    $course_code = api_get_course_id();
    //alphanumeric
    $item_property_id = api_get_item_property_id($course_code, $tool, $ref);
    $sql = "SELECT * FROM {$tbl_stats_item_property}\n            WHERE item_property_id = {$item_property_id} AND course_id = {$course_id}\n            ORDER BY lastedit_date DESC";
    $result = Database::query($sql);
    $result = Database::store_result($result, 'ASSOC');
    return $result;
}
 /**
  * Insert a row like history inside track_e_item_property table
  * first you must set description_type, title, content, progress and
  * session_id properties with the object CourseDescription
  * @param    int    description type
  * @return  int        affected rows
  */
 public function insert_stats($description_type)
 {
     $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
     $description_id = $this->get_id_by_description_type($description_type);
     $course_id = api_get_real_course_id();
     $course_code = api_get_course_id();
     $item_property_id = api_get_item_property_id($course_code, TOOL_COURSE_DESCRIPTION, $description_id);
     $params = ['c_id' => api_get_course_int_id(), 'course_id' => $course_id, 'item_property_id' => $item_property_id, 'title' => $this->title, 'content' => $this->content, 'progress' => $this->progress, 'lastedit_date' => api_get_utc_datetime(), 'lastedit_user_id' => api_get_user_id(), 'session_id' => $this->session_id];
     Database::insert($tbl_stats_item_property, $params);
     return 1;
 }
 /**
  * Insert a row like history inside track_e_item_property table
  * first you must set description_type, title, content, progress and session_id properties with the object CourseDescription
  * @param 	int 	description type
  * @return  int		affected rows
  */
 public function insert_stats($description_type)
 {
     $tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
     $description_id = $this->get_id_by_description_type($description_type);
     $course_id = api_get_real_course_id();
     $course_code = api_get_course_id();
     $item_property_id = api_get_item_property_id($course_code, TOOL_COURSE_DESCRIPTION, $description_id);
     $sql = "INSERT IGNORE INTO {$tbl_stats_item_property} SET\n\t\t\t\tc_id\t\t\t\t= " . api_get_course_int_id() . ",\n\t\t\t\tcourse_id \t\t\t= '{$course_id}',\n\t\t\t \titem_property_id \t= '{$item_property_id}',\n\t\t\t \ttitle \t\t\t\t= '" . Database::escape_string($this->title) . "',\n\t\t\t \tcontent \t\t\t= '" . Database::escape_string($this->content) . "',\n\t\t\t \tprogress \t\t\t= '" . intval($this->progress) . "',\n\t\t\t \tlastedit_date \t\t= '" . date('Y-m-d H:i:s') . "',\n\t\t\t \tlastedit_user_id \t= '" . api_get_user_id() . "',\n\t\t\t \tsession_id\t\t\t= '" . intval($this->session_id) . "'";
     $result = Database::query($sql);
     $affected_rows = Database::affected_rows($result);
     return $affected_rows;
 }