Source for file abstractlink.class.php
Documentation is available at abstractlink.class.php
* Defines a gradebook AbstractLink object.
* To implement specific links,
* extend this class and define a type in LinkFactory.
* Use the methods in LinkFactory to create link objects.
* @package dokeos.gradebook
* Retrieve links and return them as an array of extensions of AbstractLink.
* To keep consistency, do not call this method but LinkFactory::load instead.
public function load ($id = null, $type = null, $ref_id = null, $user_id = null, $course_code = null, $category_id = null, $visible = null)
$sql= 'SELECT id,type,ref_id,user_id,course_code,category_id,date,weight,visible FROM '. $tbl_grade_links;
$sql.= ' WHERE id = '. $id;
if ($paramcount != 0) $sql .= ' AND';
$sql .= ' type = '. $type;
if ($paramcount != 0) $sql .= ' AND';
$sql .= ' ref_id = '. $ref_id;
if ($paramcount != 0) $sql .= ' AND';
$sql .= ' user_id = '. $user_id;
if (isset ($course_code))
if ($paramcount != 0) $sql .= ' AND';
$sql .= " course_code = '". $course_code. "'";
if (isset ($category_id))
if ($paramcount != 0) $sql .= ' AND';
$sql .= ' category_id = '. $category_id;
if ($paramcount != 0) $sql .= ' AND';
$sql .= ' visible = '. $visible;
$link->set_id($data['id']);
$link->set_type($data['type']);
$link->set_ref_id($data['ref_id']);
$link->set_user_id($data['user_id']);
$link->set_course_code($data['course_code']);
$link->set_category_id($data['category_id']);
$link->set_date($data['date']);
$link->set_weight($data['weight']);
$link->set_visible($data['visible']);
* Insert this link into the database
$sql = 'INSERT INTO '. $tbl_grade_links
. ' (type,ref_id,user_id,course_code,category_id,weight,visible';
if (isset ($this->link_date)) $sql .= ',date';
die('Error in AbstractLink add: required field empty');
* Update the properties of this link in the database
$sql = 'UPDATE '. $tbl_grade_links
. ' WHERE id = '. $this->id;
* Delete this link from the database
$sql = 'DELETE FROM '. $tbl_grade_links. ' WHERE id = '. $this->id;
* Generate an array of possible categories where this link can be moved to.
* Notice: its own parent will be included in the list: it's up to the frontend
* to disable this element.
* @return array 2-dimensional array - every element contains 3 subelements (id, name, level)
// links can only be moved to categories inside this course
foreach ($crscats as $cat)
$targets[] = array ($cat->get_id(), $cat->get_name(), $level+ 1);
* Internal function used by get_target_categories()
foreach ($subcats as $cat)
$targets[] = array ($cat->get_id(), $cat->get_name(), $level+ 1);
* Move this link to the given category.
* If this link moves to outside a course, delete it.
* To keep consistency, do not call this method but LinkFactory::find_links instead.
* @todo can be written more efficiently using a new (but very complex) sql query
public function find_links ($name_mask,$selectcat)
foreach ($links as $link)
// Other methods implementing GradebookItem
// ABSTRACT FUNCTIONS - to be implemented by subclass
// The following methods are already defined in GradebookItem,
// and must be implemented by the subclass as well !
// abstract function get_name();
// abstract function get_description();
// abstract function calc_score($stud_id = null);
// TRIVIAL FUNCTIONS - to be overwritten by subclass if needed
|