Minor - format code

1.9.x
Julio Montoya 12 years ago
parent f0504a01ad
commit 45c6d9e537
  1. 14
      main/newscorm/learnpathItem.class.php
  2. 17
      main/newscorm/lp_ajax_save_item.php

@ -11,7 +11,8 @@
* lp_item defines items belonging to a learnpath. Each item has a name, a score, a use time and additional * lp_item defines items belonging to a learnpath. Each item has a name, a score, a use time and additional
* information that enables tracking a user's progress in a learning path * information that enables tracking a user's progress in a learning path
*/ */
class learnpathItem { class learnpathItem
{
public $attempt_id; // Also called "objectives" SCORM-wise. public $attempt_id; // Also called "objectives" SCORM-wise.
public $audio; // The path to an audio file (stored in document/audio/). public $audio; // The path to an audio file (stored in document/audio/).
public $children = array(); // Contains the ids of children items. public $children = array(); // Contains the ids of children items.
@ -1844,7 +1845,8 @@ class learnpathItem {
* @return void * @return void
* @todo //todo insert into lp_item_view if lp_view not exists * @todo //todo insert into lp_item_view if lp_view not exists
*/ */
public function set_lp_view($lp_view_id, $course_id = null) { public function set_lp_view($lp_view_id, $course_id = null)
{
if (empty($course_id)) { if (empty($course_id)) {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
} else { } else {
@ -1935,7 +1937,8 @@ class learnpathItem {
* @param float Score * @param float Score
* @return boolean True on success, false otherwise * @return boolean True on success, false otherwise
*/ */
public function set_score($score) { public function set_score($score)
{
//$possible_status = array('not attempted','incomplete','completed','passed','failed','browsed'); //$possible_status = array('not attempted','incomplete','completed','passed','failed','browsed');
$debug = self::debug; $debug = self::debug;
if ($debug > 0) { error_log('learnpathItem::set_score('.$score.')', 0); } if ($debug > 0) { error_log('learnpathItem::set_score('.$score.')', 0); }
@ -1944,7 +1947,7 @@ class learnpathItem {
$master = $this->get_mastery_score(); $master = $this->get_mastery_score();
$current_status = $this->get_status(false); $current_status = $this->get_status(false);
//Fixes bug when SCORM doesn't send a mastery score even if they sent a score! // Fixes bug when SCORM doesn't send a mastery score even if they sent a score!
if ($master == -1) { if ($master == -1) {
$master = $this->max_score; $master = $this->max_score;
} }
@ -1989,7 +1992,8 @@ class learnpathItem {
* @param string Status - must be one of the values defined in $this->possible_status * @param string Status - must be one of the values defined in $this->possible_status
* @return boolean True on success, false on error * @return boolean True on success, false on error
*/ */
public function set_status($status) { public function set_status($status)
{
if (self::debug > 0) { error_log('learnpathItem::set_status('.$status.')', 0); } if (self::debug > 0) { error_log('learnpathItem::set_status('.$status.')', 0); }
$found = false; $found = false;
foreach ($this->possible_status as $possible) { foreach ($this->possible_status as $possible) {

@ -44,7 +44,8 @@ require_once 'aiccItem.class.php';
* @param array Interactions array * @param array Interactions array
* @param string Core exit SCORM string * @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; $return = null;
if ($debug > 0) { 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); $prereq_check = $mylp->prerequisites_match($item_id);
/** @var learnpathItem $mylpi */
$mylpi = $mylp->items[$item_id]; $mylpi = $mylp->items[$item_id];
if (empty($mylpi)) { if (empty($mylpi)) {
@ -91,7 +94,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
return false; 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); $mylpi->set_lp_view($view_id);
if ($prereq_check === true) { if ($prereq_check === true) {
@ -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"); } 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 (isset($score) && $score != -1) {
if ($debug > 1) { error_log('Calling set_score('.$score.')', 0); } 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); } 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 { } else {
if ($debug > 1) { error_log("Score not updated"); } if ($debug > 1) { error_log("Score not updated"); }
//Default behaviour // Default behaviour
if (isset($status) && $status != '' && $status != 'undefined') { if (isset($status) && $status != '' && $status != 'undefined') {
if ($debug > 1) { error_log('Calling set_status('.$status.')', 0); } if ($debug > 1) { error_log('Calling set_status('.$status.')', 0); }
$mylpi->set_status($status); $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)); Session::write('lpobject', serialize($mylp));
if ($debug > 0) { error_log('---------------- lp_ajax_save_item.php : save_item end ----- '); } if ($debug > 0) { error_log('---------------- lp_ajax_save_item.php : save_item end ----- '); }
return $return; return $return;
} }
@ -274,7 +278,7 @@ if (isset($_REQUEST['interact'])) {
if (is_array($_REQUEST['interact'])) { if (is_array($_REQUEST['interact'])) {
foreach ($_REQUEST['interact'] as $idx => $interac) { foreach ($_REQUEST['interact'] as $idx => $interac) {
$interactions[$idx] = split(',', substr($interac, 1, -1)); $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] = ''; $interactions[$idx][7] = '';
} }
} }
@ -294,4 +298,5 @@ echo save_item(
(!empty($_REQUEST['suspend'])?$_REQUEST['suspend']:null), (!empty($_REQUEST['suspend'])?$_REQUEST['suspend']:null),
(!empty($_REQUEST['loc'])?$_REQUEST['loc']:null), (!empty($_REQUEST['loc'])?$_REQUEST['loc']:null),
$interactions, $interactions,
(!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:'')); (!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:'')
);

Loading…
Cancel
Save