|
@@ -44,7 +44,8 @@ require_once 'aiccItem.class.php';
|
|
|
* @param array Interactions array
|
|
|
* @param string Core exit SCORM string
|
|
|
*/
|
|
|
-function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $min = -1, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none') {
|
|
|
+function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $min = -1, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none')
|
|
|
+{
|
|
|
$return = null;
|
|
|
|
|
|
if ($debug > 0) {
|
|
@@ -82,6 +83,8 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
|
|
|
}
|
|
|
|
|
|
$prereq_check = $mylp->prerequisites_match($item_id);
|
|
|
+
|
|
|
+ /** @var learnpathItem $mylpi */
|
|
|
$mylpi = $mylp->items[$item_id];
|
|
|
|
|
|
if (empty($mylpi)) {
|
|
@@ -91,14 +94,14 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- //This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069
|
|
|
+ // This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069
|
|
|
$mylpi->set_lp_view($view_id);
|
|
|
|
|
|
if ($prereq_check === true) {
|
|
|
if ($debug > 1) { error_log('Prereq are check'); }
|
|
|
|
|
|
// Launch the prerequisites check and set error if needed
|
|
|
- if (isset($max) && $max != -1) {
|
|
|
+ if (isset($max) && $max != -1) {
|
|
|
$mylpi->max_score = $max;
|
|
|
$mylpi->set_max_score($max);
|
|
|
if ($debug > 1) { error_log("Setting max_score: $max"); }
|
|
@@ -109,7 +112,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
|
|
|
if ($debug > 1) { error_log("Setting min_score: $min"); }
|
|
|
}
|
|
|
|
|
|
- //set_score function already saves the status
|
|
|
+ // set_score function already saves the status
|
|
|
if (isset($score) && $score != -1) {
|
|
|
if ($debug > 1) { error_log('Calling set_score('.$score.')', 0); }
|
|
|
if ($debug > 1) { error_log('set_score changes the status to failed/passed if mastery score is provided', 0); }
|
|
@@ -118,7 +121,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
|
|
|
} else {
|
|
|
if ($debug > 1) { error_log("Score not updated"); }
|
|
|
|
|
|
- //Default behaviour
|
|
|
+ // Default behaviour
|
|
|
if (isset($status) && $status != '' && $status != 'undefined') {
|
|
|
if ($debug > 1) { error_log('Calling set_status('.$status.')', 0); }
|
|
|
$mylpi->set_status($status);
|
|
@@ -266,6 +269,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
|
|
|
|
|
|
Session::write('lpobject', serialize($mylp));
|
|
|
if ($debug > 0) { error_log('---------------- lp_ajax_save_item.php : save_item end ----- '); }
|
|
|
+
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
@@ -274,7 +278,7 @@ if (isset($_REQUEST['interact'])) {
|
|
|
if (is_array($_REQUEST['interact'])) {
|
|
|
foreach ($_REQUEST['interact'] as $idx => $interac) {
|
|
|
$interactions[$idx] = split(',', substr($interac, 1, -1));
|
|
|
- if(!isset($interactions[$idx][7])){ // Make sure there are 7 elements.
|
|
|
+ if (!isset($interactions[$idx][7])) { // Make sure there are 7 elements.
|
|
|
$interactions[$idx][7] = '';
|
|
|
}
|
|
|
}
|
|
@@ -282,16 +286,17 @@ if (isset($_REQUEST['interact'])) {
|
|
|
}
|
|
|
|
|
|
echo save_item(
|
|
|
- (!empty($_REQUEST['lid'])?$_REQUEST['lid']:null),
|
|
|
- (!empty($_REQUEST['uid'])?$_REQUEST['uid']:null),
|
|
|
- (!empty($_REQUEST['vid'])?$_REQUEST['vid']:null),
|
|
|
- (!empty($_REQUEST['iid'])?$_REQUEST['iid']:null),
|
|
|
- (!empty($_REQUEST['s'])?$_REQUEST['s']:null),
|
|
|
- (!empty($_REQUEST['max'])?$_REQUEST['max']:null),
|
|
|
- (!empty($_REQUEST['min'])?$_REQUEST['min']:null),
|
|
|
- (!empty($_REQUEST['status'])?$_REQUEST['status']:null),
|
|
|
- (!empty($_REQUEST['t'])?$_REQUEST['t']:null),
|
|
|
- (!empty($_REQUEST['suspend'])?$_REQUEST['suspend']:null),
|
|
|
- (!empty($_REQUEST['loc'])?$_REQUEST['loc']:null),
|
|
|
- $interactions,
|
|
|
- (!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:''));
|
|
|
+ (!empty($_REQUEST['lid'])?$_REQUEST['lid']:null),
|
|
|
+ (!empty($_REQUEST['uid'])?$_REQUEST['uid']:null),
|
|
|
+ (!empty($_REQUEST['vid'])?$_REQUEST['vid']:null),
|
|
|
+ (!empty($_REQUEST['iid'])?$_REQUEST['iid']:null),
|
|
|
+ (!empty($_REQUEST['s'])?$_REQUEST['s']:null),
|
|
|
+ (!empty($_REQUEST['max'])?$_REQUEST['max']:null),
|
|
|
+ (!empty($_REQUEST['min'])?$_REQUEST['min']:null),
|
|
|
+ (!empty($_REQUEST['status'])?$_REQUEST['status']:null),
|
|
|
+ (!empty($_REQUEST['t'])?$_REQUEST['t']:null),
|
|
|
+ (!empty($_REQUEST['suspend'])?$_REQUEST['suspend']:null),
|
|
|
+ (!empty($_REQUEST['loc'])?$_REQUEST['loc']:null),
|
|
|
+ $interactions,
|
|
|
+ (!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:'')
|
|
|
+);
|