Fixed new bug introduced by cleanup of constructors -> __construct

skala
Yannick Warnier 15 years ago
parent 034f539232
commit dae8643a46
  1. 2
      main/newscorm/aicc.class.php
  2. 2
      main/newscorm/aiccItem.class.php
  3. 30
      main/newscorm/learnpath.class.php
  4. 16
      main/newscorm/learnpathList.class.php
  5. 2
      main/newscorm/openoffice_document.class.php
  6. 2
      main/newscorm/scorm.class.php
  7. 4
      main/newscorm/scormItem.class.php
  8. 2
      tests/main/newscorm/learnpath.class.test.php

@ -50,7 +50,7 @@ class aicc extends learnpath {
if($this->debug>0){error_log('In aicc::aicc()',0);}
if(!empty($course_code) and !empty($resource_id) and !empty($user_id))
{
parent::learnpath($course_code, $resource_id, $user_id);
parent::__construct($course_code, $resource_id, $user_id);
}else{
//do nothing but still build the aicc object
}

@ -39,7 +39,7 @@ class aiccItem extends learnpathItem{
{
switch($type){
case 'db':
parent::learnpathItem($params,api_get_user_id());
parent::__construct($params,api_get_user_id());
$this->aicc_contact = false;
//TODO implement this way of metadata object creation
return false;

@ -81,7 +81,7 @@ class learnpath {
public function __construct($course, $lp_id, $user_id) {
//check params
//check course code
if ($this->debug>0){error_log('New LP - In learnpath::learnpath('.$course.','.$lp_id.','.$user_id.')',0);}
if ($this->debug>0){error_log('New LP - In learnpath::__construct('.$course.','.$lp_id.','.$user_id.')',0);}
if (empty($course)) {
$this->error = 'Course code is empty';
return false;
@ -90,7 +90,7 @@ class learnpath {
//$course = Database::escape_string($course);
$course = $this->escape_string($course);
$sql = "SELECT * FROM $main_table WHERE code = '$course'";
if($this->debug>2){error_log('New LP - learnpath::learnpath() '.__LINE__.' - Querying course: '.$sql,0);}
if($this->debug>2){error_log('New LP - learnpath::__construct() '.__LINE__.' - Querying course: '.$sql,0);}
//$res = Database::query($sql);
$res = Database::query($sql);
if(Database::num_rows($res)>0)
@ -114,7 +114,7 @@ class learnpath {
//$id = Database::escape_integer($id);
$lp_id = $this->escape_string($lp_id);
$sql = "SELECT * FROM $lp_table WHERE id = '$lp_id'";
if($this->debug>2){error_log('New LP - learnpath::learnpath() '.__LINE__.' - Querying lp: '.$sql,0);}
if($this->debug>2){error_log('New LP - learnpath::__construct() '.__LINE__.' - Querying lp: '.$sql,0);}
//$res = Database::query($sql);
$res = Database::query($sql);
if (Database::num_rows($res)>0) {
@ -156,7 +156,7 @@ class learnpath {
//$user_id = Database::escape_integer($user_id);
$user_id = $this->escape_string($user_id);
$sql = "SELECT * FROM $main_table WHERE user_id = '$user_id'";
if($this->debug>2){error_log('New LP - learnpath::learnpath() '.__LINE__.' - Querying user: '.$sql,0);}
if($this->debug>2){error_log('New LP - learnpath::__construct() '.__LINE__.' - Querying user: '.$sql,0);}
//$res = Database::query($sql);
$res = Database::query($sql);
if (Database::num_rows($res)>0) {
@ -173,14 +173,14 @@ class learnpath {
//selecting by view_count descending allows to get the highest view_count first
$sql = "SELECT * FROM $lp_table WHERE lp_id = '$lp_id' AND user_id = '$user_id' ORDER BY view_count DESC";
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - querying lp_view: ' . $sql, 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - querying lp_view: ' . $sql, 0);
}
//$res = Database::query($sql);
$res = Database::query($sql);
$view_id = 0; //used later to query lp_item_view
if (Database :: num_rows($res) > 0) {
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - Found previous view', 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Found previous view', 0);
}
$row = Database :: fetch_array($res);
$this->attempt = $row['view_count'];
@ -189,14 +189,14 @@ class learnpath {
$this->progress_db = $row['progress'];
} else {
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - NOT Found previous view', 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - NOT Found previous view', 0);
}
$this->attempt = 1;
$sql_ins = "INSERT INTO $lp_table (lp_id,user_id,view_count) VALUES ($lp_id,$user_id,1)";
$res_ins = Database::query($sql_ins);
$this->lp_view_id = Database :: insert_id();
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - inserting new lp_view: ' . $sql_ins, 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - inserting new lp_view: ' . $sql_ins, 0);
}
}
@ -220,7 +220,7 @@ class learnpath {
$this->items[$my_item_id] = $oItem;
$this->refs_list[$oItem->ref] = $my_item_id;
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() - aicc object with id ' . $my_item_id . ' set in items[]', 0);
error_log('New LP - learnpath::__construct() - aicc object with id ' . $my_item_id . ' set in items[]', 0);
}
}
break;
@ -255,7 +255,7 @@ class learnpath {
$this->items[$my_item_id] = $oItem;
$this->refs_list[$my_item_id] = $my_item_id;
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - object with id ' . $my_item_id . ' set in items[]', 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - object with id ' . $my_item_id . ' set in items[]', 0);
}
}
break;
@ -272,7 +272,7 @@ class learnpath {
$this->items[$row['parent_item_id']]->add_child($row['id']);
} else {
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - The parent item (' . $row['parent_item_id'] . ') of item ' . $row['id'] . ' could not be found', 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - The parent item (' . $row['parent_item_id'] . ') of item ' . $row['id'] . ' could not be found', 0);
}
}
}
@ -285,7 +285,7 @@ class learnpath {
"WHERE lp_view_id = " . $this->lp_view_id . " " .
"AND lp_item_id = " . $row['id'] . " ORDER BY view_count DESC ";
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() - Selecting item_views: ' . $sql, 0);
error_log('New LP - learnpath::__construct() - Selecting item_views: ' . $sql, 0);
}
//get the item status
$res2 = Database::query($sql);
@ -295,7 +295,7 @@ class learnpath {
//$max = 0;
$row2 = Database :: fetch_array($res2);
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() - Got item_view: ' . print_r($row2, true), 0);
error_log('New LP - learnpath::__construct() - Got item_view: ' . print_r($row2, true), 0);
}
$this->items[$row['id']]->set_status($row2['status']);
if (empty ($row2['status'])) {
@ -315,7 +315,7 @@ class learnpath {
"(lp_item_id, lp_view_id, view_count, status) VALUES " .
"(" . $row['id'] . "," . $this->lp_view_id . ",1,'not attempted')";
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - Inserting blank item_view : ' . $sql_ins, 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - Inserting blank item_view : ' . $sql_ins, 0);
}
$res_ins = Database::query($sql_ins);
}
@ -332,7 +332,7 @@ class learnpath {
//TODO define the current item better
$this->first();
if ($this->debug > 2) {
error_log('New LP - learnpath::learnpath() ' . __LINE__ . ' - End of learnpath constructor for learnpath ' . $this->get_id(), 0);
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - End of learnpath constructor for learnpath ' . $this->get_id(), 0);
}
}

@ -12,12 +12,12 @@
* @uses learnpath.class.php to generate learnpath objects to get in the list
*/
class learnpathList {
var $list = array(); //holds a flat list of learnpaths data from the database
var $ref_list = array(); //holds a list of references to the learnpaths objects (only filled by get_refs())
var $alpha_list = array(); //holds a flat list of learnpaths sorted by alphabetical name order
var $course_code;
var $user_id;
var $refs_active = false;
public $list = array(); //holds a flat list of learnpaths data from the database
public $ref_list = array(); //holds a list of references to the learnpaths objects (only filled by get_refs())
public $alpha_list = array(); //holds a flat list of learnpaths sorted by alphabetical name order
public $course_code;
public $user_id;
public $refs_active = false;
/**
* This method is the constructor for the learnpathList. It gets a list of available learning paths from
@ -28,7 +28,7 @@ class learnpathList {
* @param int Optional session id (otherwise we use api_get_session_id())
* @return void
*/
function learnpathList($user_id, $course_code='', $session_id = null) {
function __construct($user_id, $course_code='', $session_id = null) {
if (!empty($course_code)){
$course_info = api_get_course_info($course_code);
@ -62,7 +62,7 @@ class learnpathList {
$myname = domesticate($row['name']);
$mylink = 'newscorm/lp_controller.php?action=view&lp_id='.$row['id'];
$sql2="SELECT * FROM $tbl_tool where (name='$myname' and image='scormbuilder.gif' and link LIKE '$mylink%')";
//error_log('New LP - learnpathList::learnpathList - getting visibility - '.$sql2,0);
//error_log('New LP - learnpathList::__construct - getting visibility - '.$sql2,0);
$res2 = Database::query($sql2);
if(Database::num_rows($res2)>0){
$row2 = Database::fetch_array($res2);

@ -27,7 +27,7 @@ abstract class OpenofficeDocument extends learnpath {
if($this->debug>0){error_log('In OpenofficeDocument::OpenofficeDocument()',0);}
if(!empty($course_code) and !empty($resource_id) and !empty($user_id))
{
parent::learnpath($course_code, $resource_id, $user_id);
parent::__construct($course_code, $resource_id, $user_id);
}else{
//do nothing but still build the presentation object
}

@ -41,7 +41,7 @@ class scorm extends learnpath {
if($this->debug>0){error_log('New LP - scorm::scorm('.$course_code.','.$resource_id.','.$user_id.') - In scorm constructor',0);}
if(!empty($course_code) and !empty($resource_id) and !empty($user_id))
{
parent::learnpath($course_code, $resource_id, $user_id);
parent::__construct($course_code, $resource_id, $user_id);
}else{
//do nothing but still build the scorm object
}

@ -41,7 +41,7 @@ class scormItem extends learnpathItem{
if($v == 4){
switch($type){
case 'db':
parent::learnpathItem($element,api_get_user_id());
parent::__construct($element,api_get_user_id());
$this->scorm_contact = false;
//TODO implement this way of metadata object creation
return false;
@ -141,7 +141,7 @@ class scormItem extends learnpathItem{
//parsing using PHP5 DOMXML methods
switch($type){
case 'db':
parent::learnpathItem($element,api_get_user_id());
parent::__construct($element,api_get_user_id());
$this->scorm_contact = false;
//TODO implement this way of metadata object creation
return false;

@ -1027,7 +1027,7 @@ class TestLearnpath extends UnitTestCase {
$course = '';
$lp_id = '';
$user_id = '';
$res = learnpath::learnpath($course, $lp_id, $user_id);
$res = learnpath::__construct($course, $lp_id, $user_id);
$this->assertTrue(is_bool($res));
//ob_end_clean();
//var_dump($res);

Loading…
Cancel
Save