Replace php4 constructor, remove return in __construct

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent b4ed8e9145
commit aaab36d56e
  1. 18
      main/lp/aiccBlock.class.php
  2. 56
      main/lp/aiccItem.class.php
  3. 18
      main/lp/aiccObjective.class.php
  4. 18
      main/lp/aiccResource.class.php
  5. 11
      main/lp/learnpath.class.php
  6. 8
      main/lp/learnpathItem.class.php

@ -6,9 +6,9 @@
* Class defining the Block elements in an AICC Course Structure file.
*
* Container for the aiccResource class that deals with elemens from AICC Course Structure file
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*/
class aiccBlock extends learnpathItem
{
@ -18,16 +18,16 @@ class aiccBlock extends learnpathItem
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
* @param string $type Type of construction needed ('db' or 'config', default = 'config')
* @param mixed $params Depending on the type given, DB id for the lp_item or parameters array
*/
function aiccBlock($type = 'config', $params)
public function __construct($type = 'config', $params)
{
if (isset($params)) {
switch ($type) {
case 'db':
//TODO: Implement this way of object creation.
return false;
break;
case 'config': // Do the same as the default.
default:
foreach ($params as $a => $value) {
@ -47,11 +47,7 @@ class aiccBlock extends learnpathItem
break;
}
}
return true;
}
}
return false;
}
}

@ -5,10 +5,10 @@
* Class aiccItem
* This class handles the elements from an AICC Descriptor file.
* Container for the aiccItem class that deals with AICC Assignable Units (AUs)
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
* @package chamilo.learnpath
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
* @package chamilo.learnpath
*/
class aiccItem extends learnpathItem
{
@ -35,7 +35,7 @@ class aiccItem extends learnpathItem
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
public function aiccItem($type = 'config', $params = array(), $course_id = null)
public function __construct($type = 'config', $params = array(), $course_id = null)
{
if (isset($params)) {
switch ($type) {
@ -43,53 +43,62 @@ class aiccItem extends learnpathItem
parent::__construct($params, api_get_user_id(), $course_id);
$this->aicc_contact = false;
//TODO: Implement this way of metadata object creation.
return false;
case 'config': // Do the same as the default.
default:
//if($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function
foreach ($params as $a => $value) {
switch ($a) {
//if($first_item->type == XML_ELEMENT_NODE) this is already check prior to the call to this function
foreach ($params as $a => $value) {
switch ($a) {
case 'system_id':
$this->identifier = Database::escape_string(strtolower($value));
$this->identifier = Database::escape_string(
strtolower($value)
);
break;
case 'type':
$this->au_type = Database::escape_string($value);
break;
case 'command_line':
$this->command_line = Database::escape_string($value);
$this->command_line = Database::escape_string(
$value
);
break;
case 'max_time_allowed':
$this->maxtimeallowed = Database::escape_string($value);
$this->maxtimeallowed = Database::escape_string(
$value
);
break;
case 'time_limit_action':
$this->timelimitaction = Database::escape_string($value);
$this->timelimitaction = Database::escape_string(
$value
);
break;
case 'max_score':
$this->max_score = Database::escape_string($value);
break;
case 'core_vendor':
$this->core_vendor = Database::escape_string($value);
$this->core_vendor = Database::escape_string(
$value
);
break;
case 'system_vendor':
$this->system_vendor = Database::escape_string($value);
$this->system_vendor = Database::escape_string(
$value
);
break;
case 'file_name':
$this->path = Database::escape_string($value);
break;
case 'mastery_score':
$this->masteryscore = Database::escape_string($value);
$this->masteryscore = Database::escape_string(
$value
);
break;
case 'web_launch':
$this->parameters = Database::escape_string($value);
break;
}
}
return true;
}
}
}
}
return false;
}
/**
@ -132,8 +141,5 @@ class aiccItem extends learnpathItem
parent::save($from_outside, $prereqs_complete = false);
// Under certain conditions, the scorm_contact should not be set, because no scorm signal was sent.
$this->aicc_contact = true;
if (!$this->aicc_contact) {
//error_log('New LP - was expecting SCORM message but none received', 0);
}
}
}

@ -7,9 +7,9 @@ require_once 'learnpathItem.class.php';
* Class aiccObjective
* Class defining the Block elements in an AICC Course Structure file.
* Container for the aiccResource class that deals with elemens from AICC Objectives file
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*/
class aiccObjective extends learnpathItem
{
@ -19,16 +19,16 @@ class aiccObjective extends learnpathItem
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
*/
function aiccObjective($type = 'config', $params)
public function __construct($type = 'config', $params)
{
if (isset($params)) {
switch ($type) {
case 'db':
// TODO: Implement this way of object creation.
return false;
break;
case 'config': // Do the same as the default.
default:
foreach ($params as $a => $value) {
@ -48,11 +48,7 @@ class aiccObjective extends learnpathItem
break;
}
}
return true;
}
}
return false;
}
}

@ -4,9 +4,9 @@
/**
* Class defining the elements from an AICC Descriptor file.
* Container for the aiccResource class that deals with elemens from AICC Descriptor file
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @license GNU/GPL
*/
class aiccResource
{
@ -18,16 +18,16 @@ class aiccResource
/**
* Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
* object from database records or from the array given as second param
* @param string Type of construction needed ('db' or 'config', default = 'config')
* @param mixed Depending on the type given, DB id for the lp_item or parameters array
* @param string $type Type of construction needed ('db' or 'config', default = 'config')
* @param mixed $params Depending on the type given, DB id for the lp_item or parameters array
*/
public function aiccResource($type = 'config', $params)
public function __construct($type = 'config', $params)
{
if (isset($params)) {
switch ($type) {
case 'db':
// TODO: Implement this way of object creation.
return false;
break;
case 'config': // Do the same as the default.
default:
foreach ($params as $a => $value) {
@ -45,11 +45,7 @@ class aiccResource
break;
}
}
return true;
}
}
return false;
}
}

@ -89,7 +89,6 @@ class learnpath
* @param string $course Course code
* @param integer $lp_id
* @param integer $user_id
* @return mixed True on success, false on error
*/
public function __construct($course, $lp_id, $user_id)
{
@ -99,7 +98,6 @@ class learnpath
}
if (empty($course)) {
$this->error = 'Course code is empty';
return false;
} else {
$course_info = api_get_course_info($course);
if (!empty($course_info)) {
@ -108,7 +106,6 @@ class learnpath
$course_id = $course_info['real_id'];
} else {
$this->error = 'Course code does not exist in database.';
return false;
}
}
@ -117,7 +114,6 @@ class learnpath
// Check learnpath ID.
if (empty($lp_id)) {
$this->error = 'Learnpath ID is empty';
return false;
} else {
// TODO: Make it flexible to use any course_code (still using env course code here).
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
@ -170,24 +166,18 @@ class learnpath
$this->mode = $row['default_view_mod'];
} else {
$this->error = 'Learnpath ID does not exist in database ('.$sql.')';
return false;
}
}
// Check user ID.
if (empty($user_id)) {
$this->error = 'User ID is empty';
return false;
} else {
$user_info = api_get_user_info($user_id);
if (!empty($user_info)) {
$this->user_id = $user_info['user_id'];
} else {
$this->error = 'User ID does not exist in database ('.$sql.')';
return false;
}
}
@ -432,7 +422,6 @@ class learnpath
if ($this->debug > 2) {
error_log('New LP - learnpath::__construct() ' . __LINE__ . ' - End of learnpath constructor for learnpath ' . $this->get_id(), 0);
}
return true;
}
/**

@ -12,7 +12,6 @@
class learnpathItem
{
const debug = 0; // Logging parameter.
public $attempt_id; // Also called "objectives" SCORM-wise.
public $audio; // The path to an audio file (stored in document/audio/).
public $children = array(); // Contains the ids of children items.
@ -86,7 +85,6 @@ class learnpathItem
* @param null|integer $user_id User ID
* @param null|integer $course_id Course int id
* @param null|array $item_content An array with the contents of the item
* @return bool True on success, false on failure
*/
public function __construct(
$id,
@ -119,9 +117,7 @@ class learnpathItem
WHERE c_id = $course_id AND id = $id";
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
$this->error =
'Could not find given learnpath item in learnpath_item table';
return false;
$this->error = 'Could not find given learnpath item in learnpath_item table';
}
$row = Database::fetch_array($res);
} else {
@ -209,8 +205,6 @@ class learnpathItem
0
);
}
return true;
}
/**

Loading…
Cancel
Save