本文整理汇总了PHP中learnpath::get_type_static方法的典型用法代码示例。如果您正苦于以下问题:PHP learnpath::get_type_static方法的具体用法?PHP learnpath::get_type_static怎么用?PHP learnpath::get_type_static使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类learnpath
的用法示例。
在下文中一共展示了learnpath::get_type_static方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write_to_db
/**
* Writes the current data to the database
* @return boolean Query result
*/
function write_to_db()
{
if ($this->debug > 0) {
error_log('New LP - In learnpathItem::write_to_db()', 0);
}
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
$my_verified_status = $this->get_status(false);
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql_verified = 'SELECT status FROM ' . $item_view_table . ' WHERE lp_item_id="' . $this->db_id . '" AND lp_view_id="' . $this->view_id . '" AND view_count="' . $this->attempt_id . '" ;';
$rs_verified = Database::query($sql_verified, __FILE__, __LINE__);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = array('completed', 'passed', 'browsed', 'failed');
//added by isaac flores
if (in_array($sql_verified['status'], $my_case_completed)) {
$save = false;
} else {
$save = true;
}
if ($save === false && $this->type == 'sco' || $this->type == 'sco' && ($credit == 'no-credit' or $mode == 'review' or $mode == 'browse')) {
//this info shouldn't be saved as the credit or lesson mode info prevent it
if ($this->debug > 1) {
error_log('New LP - In learnpathItem::write_to_db() - credit(' . $credit . ') or lesson_mode(' . $mode . ') prevent recording!', 0);
}
} else {
//check the row exists
$inserted = false;
// this a special case for multiple attempts and Dokeos exercises
if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 && $this->get_status() == 'completed') {
// we force the item to be restarted
$this->restart();
$sql = "INSERT INTO {$item_view_table} " . "(total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "(" . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if ($this->debug > 2) {
error_log('New LP - In learnpathItem::write_to_db() - Inserting into item_view forced: ' . $sql, 0);
}
$res = Database::query($sql, __FILE__, __LINE__);
$this->db_item_view_id = Database::insert_id();
$inserted = true;
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$check = "SELECT * FROM {$item_view_table} " . "WHERE lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id;
if ($this->debug > 2) {
error_log('New LP - In learnpathItem::write_to_db() - Querying item_view: ' . $check, 0);
}
$check_res = Database::query($check);
//depending on what we want (really), we'll update or insert a new row
//now save into DB
$res = 0;
if ($inserted == false && Database::num_rows($check_res) < 1) {
/*$my_status = '';
if ($this->type!=TOOL_QUIZ) {
$my_status = $this->get_status(false);
}*/
$sql = "INSERT INTO {$item_view_table} " . "(total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "(" . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if ($this->debug > 2) {
error_log('New LP - In learnpathItem::write_to_db() - Inserting into item_view: ' . $sql, 0);
}
$res = Database::query($sql, __FILE__, __LINE__);
$this->db_item_view_id = Database::insert_id();
} else {
$sql = '';
if ($this->type == 'hotpotatoes') {
//make an exception for HotPotatoes, don't update the score
//because it has been saved outside of this tool
$sql = "UPDATE {$item_view_table} " . "SET total_time = " . $this->get_total_time() . ", " . " start_time = " . $this->get_current_start_time() . ", " . " score = " . $this->get_score() . ", " . " status = '" . $this->get_status(false) . "'," . " max_score = '" . $this->get_max() . "'," . " suspend_data = '" . Database::escape_string($this->current_data) . "'," . " lesson_location = '" . $this->lesson_location . "' " . "WHERE lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id;
} else {
//for all other content types...
if ($this->type == 'quiz') {
$my_status = ' ';
$total_time = ' ';
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$safe_exe_id = Database::escape_string($_REQUEST['exeId']);
$sql = 'SELECT start_date,exe_date FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = ' . (int) $safe_exe_id;
$res = Database::query($sql, __FILE__, __LINE__);
$row_dates = Database::fetch_array($res);
$time_start_date = convert_mysql_date($row_dates['start_date']);
$time_exe_date = convert_mysql_date($row_dates['exe_date']);
$mytime = (int) $time_exe_date - (int) $time_start_date;
$total_time = " total_time = " . $mytime . ", ";
}
} else {
$my_type_lp = learnpath::get_type_static($this->lp_id);
// this is a array containing values finished
$case_completed = array('completed', 'passed', 'browsed');
//is not multiple attempts
if ($this->get_prevent_reinit() == 1) {
// process of status verified into data base
$sql_verified = 'SELECT status FROM ' . $item_view_table . ' WHERE lp_item_id="' . $this->db_id . '" AND lp_view_id="' . $this->view_id . '" AND view_count="' . $this->attempt_id . '" ;';
$rs_verified = Database::query($sql_verified, __FILE__, __LINE__);
$row_verified = Database::fetch_array($rs_verified);
//get type lp: 1=lp dokeos and 2=scorm
// if not is completed or passed or browsed and learning path is scorm
if (!in_array($this->get_status(false), $case_completed) && $my_type_lp == 2) {
//&& $this->type!='dir'
$total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
//.........这里部分代码省略.........
示例2: write_to_db
/**
* Writes the current data to the database
* @return boolean Query result
*/
public function write_to_db()
{
if (self::debug > 0) {
error_log('learnpathItem::write_to_db()', 0);
}
// Check the session visibility.
if (!api_is_allowed_to_session_edit()) {
if (self::debug > 0) {
error_log('return false api_is_allowed_to_session_edit');
}
return false;
}
$course_id = api_get_course_int_id();
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql_verified = 'SELECT status FROM ' . $item_view_table . '
WHERE c_id = ' . $course_id . ' AND lp_item_id="' . $this->db_id . '" AND lp_view_id="' . $this->view_id . '" AND view_count="' . $this->get_attempt_id() . '" ;';
$rs_verified = Database::query($sql_verified);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = array('completed', 'passed', 'browsed', 'failed');
$save = true;
if (isset($row_verified) && isset($row_verified['status'])) {
if (in_array($row_verified['status'], $my_case_completed)) {
$save = false;
}
}
if (($save === false && $this->type == 'sco' || $this->type == 'sco' && ($credit == 'no-credit' or $mode == 'review' or $mode == 'browse')) && ($this->seriousgame_mode != 1 && $this->type == 'sco')) {
if (self::debug > 1) {
error_log("This info shouldn't be saved as the credit or lesson mode info prevent it");
error_log('learnpathItem::write_to_db() - credit(' . $credit . ') or lesson_mode(' . $mode . ') prevent recording!', 0);
}
} else {
// Check the row exists.
$inserted = false;
// This a special case for multiple attempts and Chamilo exercises.
if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 && $this->get_status() == 'completed') {
// We force the item to be restarted.
$this->restart();
$sql = "INSERT INTO {$item_view_table} " . "(c_id, total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "({$course_id}, " . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view forced: ' . $sql, 0);
}
$res = Database::query($sql);
$this->db_item_view_id = Database::insert_id();
$inserted = true;
}
$check_attempts = self::check_attempts($this->get_attempt_id());
if (!$check_attempts) {
return false;
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$check = "SELECT * FROM {$item_view_table}\n WHERE\n c_id = {$course_id} AND\n lp_item_id = " . $this->db_id . " AND\n lp_view_id = " . $this->view_id . " AND\n view_count = " . $this->get_attempt_id();
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Querying item_view: ' . $check, 0);
}
$check_res = Database::query($check);
// Depending on what we want (really), we'll update or insert a new row
// now save into DB.
$res = 0;
if (!$inserted && Database::num_rows($check_res) < 1) {
$sql = "INSERT INTO {$item_view_table} " . "(c_id, total_time, " . "start_time, " . "score, " . "status, " . "max_score, " . "lp_item_id, " . "lp_view_id, " . "view_count, " . "suspend_data, " . "lesson_location)" . "VALUES" . "({$course_id}, " . $this->get_total_time() . "," . "" . $this->current_start_time . "," . "" . $this->get_score() . "," . "'" . $this->get_status(false) . "'," . "'" . $this->get_max() . "'," . "" . $this->db_id . "," . "" . $this->view_id . "," . "" . $this->get_attempt_id() . "," . "'" . Database::escape_string($this->current_data) . "'," . "'" . $this->lesson_location . "')";
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view: ' . $sql, 0);
}
$res = Database::query($sql);
$this->db_item_view_id = Database::insert_id();
} else {
$sql = '';
if ($this->type == 'hotpotatoes') {
$sql = "UPDATE {$item_view_table} " . "SET total_time = " . $this->get_total_time() . ", " . " start_time = " . $this->get_current_start_time() . ", " . " score = " . $this->get_score() . ", " . " status = '" . $this->get_status(false) . "'," . " max_score = '" . $this->get_max() . "'," . " suspend_data = '" . Database::escape_string($this->current_data) . "'," . " lesson_location = '" . $this->lesson_location . "' " . "WHERE c_id = {$course_id} AND lp_item_id = " . $this->db_id . " " . "AND lp_view_id = " . $this->view_id . " " . "AND view_count = " . $this->get_attempt_id();
} else {
// For all other content types...
if ($this->type == 'quiz') {
$my_status = ' ';
$total_time = ' ';
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$safe_exe_id = Database::escape_string($_REQUEST['exeId']);
$sql = 'SELECT start_date,exe_date FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = ' . (int) $safe_exe_id;
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
$time_start_date = api_convert_sql_date($row_dates['start_date']);
$time_exe_date = api_convert_sql_date($row_dates['exe_date']);
$mytime = (int) $time_exe_date - (int) $time_start_date;
$total_time = " total_time = " . $mytime . ", ";
}
} else {
$my_type_lp = learnpath::get_type_static($this->lp_id);
// This is a array containing values finished
$case_completed = array('completed', 'passed', 'browsed', 'failed');
//is not multiple attempts
if ($this->seriousgame_mode == 1 && $this->type == 'sco') {
$total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
$my_status = " status = '" . $this->get_status(false) . "' ,";
} elseif ($this->get_prevent_reinit() == 1) {
//.........这里部分代码省略.........
示例3: write_to_db
/**
* Writes the current data to the database
* @return boolean Query result
*/
public function write_to_db()
{
if (self::debug > 0) {
error_log('learnpathItem::write_to_db()', 0);
}
// Check the session visibility.
if (!api_is_allowed_to_session_edit()) {
if (self::debug > 0) {
error_log('return false api_is_allowed_to_session_edit');
}
return false;
}
$course_id = api_get_course_int_id();
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = 'SELECT status FROM ' . $item_view_table . '
WHERE
c_id = ' . $course_id . ' AND
lp_item_id="' . $this->db_id . '" AND
lp_view_id="' . $this->view_id . '" AND
view_count="' . $this->get_attempt_id() . '" ';
$rs_verified = Database::query($sql);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = array('completed', 'passed', 'browsed', 'failed');
$save = true;
if (isset($row_verified) && isset($row_verified['status'])) {
if (in_array($row_verified['status'], $my_case_completed)) {
$save = false;
}
}
if (($save === false && $this->type == 'sco' || $this->type == 'sco' && ($credit == 'no-credit' || $mode == 'review' || $mode == 'browse')) && ($this->seriousgame_mode != 1 && $this->type == 'sco')) {
if (self::debug > 1) {
error_log("This info shouldn't be saved as the credit or lesson mode info prevent it");
error_log('learnpathItem::write_to_db() - credit(' . $credit . ') or' . ' lesson_mode(' . $mode . ') prevent recording!', 0);
}
} else {
// Check the row exists.
$inserted = false;
// This a special case for multiple attempts and Chamilo exercises.
if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 && $this->get_status() == 'completed') {
// We force the item to be restarted.
$this->restart();
$params = array("c_id" => $course_id, "total_time" => $this->get_total_time(), "start_time" => $this->current_start_time, "score" => $this->get_score(), "status" => $this->get_status(false), "max_score" => $this->get_max(), "lp_item_id" => $this->db_id, "lp_view_id" => $this->view_id, "view_count" => $this->get_attempt_id(), "suspend_data" => $this->current_data, "lesson_location" => $this->lesson_location);
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1), 0);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
if ($this->db_item_view_id) {
$sql = "UPDATE {$item_view_table} SET id = iid\n WHERE iid = " . $this->db_item_view_id;
Database::query($sql);
$inserted = true;
}
}
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT * FROM {$item_view_table}\n WHERE\n c_id = {$course_id} AND\n lp_item_id = " . $this->db_id . " AND\n lp_view_id = " . $this->view_id . " AND\n view_count = " . intval($this->get_attempt_id());
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Querying item_view: ' . $sql, 0);
}
$check_res = Database::query($sql);
// Depending on what we want (really), we'll update or insert a new row
// now save into DB.
if (!$inserted && Database::num_rows($check_res) < 1) {
$params = array("c_id" => $course_id, "total_time" => $this->get_total_time(), "start_time" => $this->current_start_time, "score" => $this->get_score(), "status" => $this->get_status(false), "max_score" => $this->get_max(), "lp_item_id" => $this->db_id, "lp_view_id" => $this->view_id, "view_count" => $this->get_attempt_id(), "suspend_data" => $this->current_data, "lesson_location" => $this->lesson_location);
if (self::debug > 2) {
error_log('learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1), 0);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
if ($this->db_item_view_id) {
$sql = "UPDATE {$item_view_table} SET id = iid\n WHERE iid = " . $this->db_item_view_id;
Database::query($sql);
}
} else {
if ($this->type == 'hotpotatoes') {
$params = array('total_time' => $this->get_total_time(), 'start_time' => $this->get_current_start_time(), 'score' => $this->get_score(), 'status' => $this->get_status(false), 'max_score' => $this->get_max(), 'suspend_data' => $this->current_data, 'lesson_location' => $this->lesson_location);
$where = array('c_id = ? AND lp_item_id = ? AND lp_view_id = ? AND view_count = ?' => array($course_id, $this->db_id, $this->view_id, $this->get_attempt_id()));
Database::update($item_view_table, $params, $where);
} else {
// For all other content types...
$my_status = ' ';
$total_time = ' ';
if ($this->type == 'quiz') {
if (!empty($_REQUEST['exeId'])) {
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$safe_exe_id = intval($_REQUEST['exeId']);
$sql = "SELECT start_date,exe_date\n FROM {$TBL_TRACK_EXERCICES}\n WHERE exe_id = {$safe_exe_id}";
$res = Database::query($sql);
$row_dates = Database::fetch_array($res);
$time_start_date = convert_sql_date($row_dates['start_date']);
$time_exe_date = convert_sql_date($row_dates['exe_date']);
$mytime = (int) $time_exe_date - (int) $time_start_date;
$total_time = " total_time = " . $mytime . ", ";
}
} else {
$my_type_lp = learnpath::get_type_static($this->lp_id);
// This is a array containing values finished
//.........这里部分代码省略.........