ÿØÿà JFIF    ÿÛ „  ( %!1"%)+...383-7(-.+  -%%--------+------------/----------------------------ÿÀ  ¶" ÿÄ     ÿÄ @    !1AQaq‘¡"±ÁÑð2’BRráS‚ñ3b¢CT²Ò #cÿÄ    ÿÄ '   1!AQ2a"‘±#ÿÚ   ? ò(/p‘—–¢·,M|¯G»R£üešT. ôŸEoCFñ‡ 4ÔkåóxR|µÁ¨ÓDà!Ç´µ˜‡p ÍQ‹§!þž^õWsŒy  åÁ§$á«%ºq˜™JyyË0y«^Ϗ -3ÃÏËÈ£Æ\P’ä„s&•‹Üs üô'àWt¹pñCp$bÚF`·7.^)¾!)ÒÙ˜–ÅÏš^h¾ø³·ìe±ŒaeÖ—Í,e=B}Jéߦ$$½—šÙÜCC¯¶è8β–Åkèwx LÉngT±æ¹£Ócœ¿Í/©Éÿ ‰ÚCÒ­mq;Tt¶–}0"zÖPcd1š­¤tˆ„ÐÓâqú[™öUCŠ2޿د­É(¸ßúçšmW,Ò ºf‹Ån™ÄLêÁ8üÁkÁ€L¥ÍuJ1œôrÂSŒÓöt!7EUíïb)AËi¬â-ÙHk8òÁiXYwÅ)O^"ÇØriÛô{»wRUKÙÏÚlÓ¬€‚’שT ] ªb—ÊîKC^×M“xùäñz¬zJ× {4[¹M'IÆeH1LCWÕ]œûº WDæà°OÅ‚¹c²ÞuA–rL`HšpCez‡V’— Ž‚Ë„–ñ­'µR0ÕÖ=À:±G»C\nÆÉ5*¢ †3šhQ4ýÒi$Õ1"Ü]¢p-q3zcQ$ªö¨¥æf›‘»´ÝÚHá„e²JÇ–iÊ:·à¬Øc5Åk»Laª*wi [0Ówk ¦a¦0Õ²ÅÅ‚T¸’³q:Æ<¹ú Ò˜Æ}2VE•Ѐp¡Ô3Úº …h³^LJºçì¥Ánó|˜ÖˆÎˆ+« ¦dø‘Mº–d\ªDðÛ„Ì×LÝ——Ð9Ç|•FèçVm™¨€™3õS–9Äå¢<̉Ìm¢±`·º˜&Z²ž Ë®D«¶»6™‰©­HÈ Àá«h­i³04æ’hxœi3ï¨(ÓL·†‹¶ËpŒ ƒÜÒ? :õdsÀ –3æÓ·Üjâ¬9—]8n¼&]I F£¼…ì–—Œ0v°LǐÅfÛ2TÖ’aµ˜N@ÖBSÏ^à´4-±°b×nÈÈœÆD=KdŒø…ÄÈK,›ÖR§fjü$^ÔÎ!„6^ s:Üun\ôkCÞò÷<—Lúl Í›G¹ÀPá¼Nc¡šÒ…ÙWͳœ±vÊáЄ×9‹P‰cEØ‘™›µŸP<×g1 º©Ø¬wiÁ^l5× I/';Ë+´Z‡ÓÄFÕp[Èð’ HÄ ó 9¬Dl4“é±Ï”V=^Hð;žLädÉa‚°Ë,#/Ž~²BÔÛ QãñQtIeórVB,ÏÂf‹4#Μc‹É3ZIÖ Œ¢¥·üxa‡Ãçè„jŠ[5 Ä!U?,3žÎ×…ðdÓ÷háŠA‰ìÄ4÷ÃÜZÃE{‰®+W\ZÍE[‰»µk»MÝ­`¢©†˜ÃV‹-f¢¡†¢a«eŠ%«Y¨©q%jâd,Ôq`) ¤¦…šˆ ¦E>0Ùb²t–Ÿ  ÷jsςҒKÈcø(é›;k(’#ôŒQ ™C> õ³M9óºÆµ¤çâ;uÀ)5>RÔ¸fÓ~Ȧ—’-$fe«"FâUˆÊwµPÏu w+"åÉó¨6s™Û9(À¨ù©hE°½†n`m~“@©›p!Vkhµ Á1šbEqqÊ@ºèl›2 –Yã%‘‚hÛ{a¶‡ÅÞM²¬çL34®Çl]®‹ŽØŒm'RÜe35æöˆ­Á­ cP9šeÁköo´L³Ì=p8]”‡B¶,šº|ɏdzXˆØk*ÇÚ{#ñ‰pã(€¶‡9ý'šÜ³½¯kƒ†Â’ëSOƒ•Å®H6+a¢µˆ‹Y¨b˜b+XˆÖ!°u!¢"µˆˆn2ˆ Å0Ä`Å Ô®c(ÓÜGº•Ä»Œ âWî%q.áÐÄ÷î%umÍ£+ÜQ,Vn¦-GphU¸¢X­&,Gt ·K¢ÅÅ·¥RÄÊÉbKn N­R2g$VµÕó Qr#–ÓZUÏð0ÎtÙÀœz ëöo“Îk¯n„T°"SÞ+³/…€½"ižãO%Í%&Δâ‘ËØ´IˆÓ°Ë‰ÞM3.™yçÁzit›`4C`k¢¼á!álÄï sÂ[×!¤l¾æo"ƒIÔ'@ªu)3›ô®“@Z à¾] üœ'‡4¸PÞkÁ-qÄH‰ÓÍBd´ÿ —¹°ÄA&ÊUC„öz‚‚RæŠtf¬>˜ÑidšEçÑL÷áý¡V±h§­c¿¥¨ƒ@g¼…Ýö^ÞËc.ž„æ“I[ ª+·zÐÒÚ,½Ð»¶€C›7jk$๖€Ž¾ÅÙpp¶ÍþéΤ ½ØÎŒq ñpæžÅ¥#Øâ49ÃÂK^MYV“,¶Éz_òæ:…;Õ«¦I3âJ£¤û5$7Èxün\â]Êe¯(Ÿ&Ž‹¶2<6Ćf× æ¢ƱqWı[(ÙÂŽç‚T7¨@ÈÉÍß‚ïÙ"&3TYlGށ†)†#5ŠA©^T2ÆÁ†)©†©†¤yGXÁ†©"†)©¼ÅV WS†#©]R–r‹q5ÕbâWþBh¯u+ªÅÄ×ü„nÑ^êkªÁj‰jeœWˆÕÕ`µDµ2Ì+Ä µDµµ5Ô{¤Þ0RF’H÷AÛ<ÊÁ§ ƈæ0Ñ£ê4 öÚµ[¬/1²€â<-¬šö²r×0o×w ´xÐÒË„ g01¬„åEM蛇Ã\6µE›‘fÙO k÷CºnÓ1`iîÒ² áÂ!ÑLÄÿ ³¬\õ*:M=Ç»c‹2[‰ØsÕLò\ŒK L^™üÄN\¶#» Ç\……ßïIœÉ$¸ÎñÍ®ÔHÇ Ûí/´>Li”„†g^$ 7NÍÑÑ2M2ªNg=k½Ð}Ÿl6‡ —JWˆ”ÞéT·+µ¦üÂFè¢Vs6ýÆ4»2+2IÝ9ô9®ÇGÙÇ1+Ä8;*Õ§ž½D*îÑWÚçá3Ma¤·ˆ¥t}š²Ü…Q+Æüµ8HíS”üxGéÁˆ¦Ël„éÈ 5 µÄƒ6äÜ(kIš¯S†fÖ&¸®×v|Äyˆ*禌Éù@7-®Ä[]ÎÖ¿ê`º…=:…žJVnݳvðÖKE¼‚ »mà ÷f®:Ë ™–4rð¡4` ܹçž~‹C=œ…¾Ïj|VDtK.ƒ"9 Ï ­–éXá³6WÒïIL-Ї Ç home/smkb8269/public_html/lms.smk-almanshuriyah.sch.id/completion/data_object.php000064400000031725152266502040024014 0ustar00. /** * Course completion critieria aggregation * * @package core_completion * @category completion * @copyright 2009 Catalyst IT Ltd * @author Aaron Barnes * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Trigger for the new data_object api. * * See data_object::__constructor */ define('DATA_OBJECT_FETCH_BY_KEY', 2); /** * A data abstraction object that holds methods and attributes * * @package core_completion * @category completion * @copyright 2009 Catalyst IT Ltd * @author Aaron Barnes * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class data_object { /* @var string Table that the class maps to in the database */ public $table; /* @var array Array of required table fields, must start with 'id'. */ public $required_fields = array('id'); /** * Array of optional fields with default values - usually long text information that is not always needed. * If you want to create an instance without optional fields use: new data_object($only_required_fields, false); * @var array */ public $optional_fields = array(); /* @var Array of unique fields, used in where clauses and constructor */ public $unique_fields = array(); /* @var int The primary key */ public $id; /** @var int completed status. */ public $completedself; /** * Constructor. Optionally (and by default) attempts to fetch corresponding row from DB. * * If $fetch is not false, there are a few different things that can happen: * - true: * load corresponding row from the database, using $params as the WHERE clause * * - DATA_OBJECT_FETCH_BY_KEY: * load corresponding row from the database, using only the $id in the WHERE clause (if set), * otherwise using the columns listed in $this->unique_fields. * * - array(): * load corresponding row from the database, using the columns listed in this array * in the WHERE clause * * @param array $params required parameters and their values for this data object * @param mixed $fetch if false, do not attempt to fetch from the database, otherwise see notes */ public function __construct($params = null, $fetch = true) { if (is_object($params)) { throw new coding_exception('data_object params should be in the form of an array, not an object'); } // If no params given, apply defaults for optional fields if (empty($params) || !is_array($params)) { self::set_properties($this, $this->optional_fields); return; } // If fetch is false, do not load from database if ($fetch === false) { self::set_properties($this, $params); return; } // Compose where clause only from fields in unique_fields if ($fetch === DATA_OBJECT_FETCH_BY_KEY && !empty($this->unique_fields)) { if (empty($params['id'])) { $where = array_intersect_key($params, array_flip($this->unique_fields)); } else { $where = array('id' => $params['id']); } // Compose where clause from given field names } else if (is_array($fetch) && !empty($fetch)) { $where = array_intersect_key($params, array_flip($fetch)); // Use entire params array for where clause } else { $where = $params; } // Attempt to load from database if ($data = $this->fetch($where)) { // Apply data from database, then data sent to constructor self::set_properties($this, $data); self::set_properties($this, $params); } else { // Apply defaults for optional fields, then data from constructor self::set_properties($this, $this->optional_fields); self::set_properties($this, $params); } } /** * Makes sure all the optional fields are loaded. * * If id present (==instance exists in db) fetches data from db. * Defaults are used for new instances. */ public function load_optional_fields() { global $DB; foreach ($this->optional_fields as $field=>$default) { if (property_exists($this, $field)) { continue; } if (empty($this->id)) { $this->$field = $default; } else { $this->$field = $DB->get_field($this->table, $field, array('id', $this->id)); } } } /** * Finds and returns a data_object instance based on params. * * This function MUST be overridden by all deriving classes. * * @param array $params associative arrays varname => value * @throws coding_exception This function MUST be overridden * @return data_object instance of data_object or false if none found. */ public static function fetch($params) { throw new coding_exception('fetch() method needs to be overridden in each subclass of data_object'); } /** * Finds and returns all data_object instances based on params. * * This function MUST be overridden by all deriving classes. * * @param array $params associative arrays varname => value * @throws coding_exception This function MUST be overridden * @return array array of data_object instances or false if none found. */ public static function fetch_all($params) { throw new coding_exception('fetch_all() method needs to be overridden in each subclass of data_object'); } /** * Factory method - uses the parameters to retrieve matching instance from the DB. * * @final * @param string $table The table name to fetch from * @param string $classname The class that you want the result instantiated as * @param array $params Any params required to select the desired row * @return object Instance of $classname or false. */ protected static function fetch_helper($table, $classname, $params) { if ($instances = self::fetch_all_helper($table, $classname, $params)) { if (count($instances) > 1) { // we should not tolerate any errors here - problems might appear later throw new \moodle_exception('morethanonerecordinfetch', 'debug'); } return reset($instances); } else { return false; } } /** * Factory method - uses the parameters to retrieve all matching instances from the DB. * * @final * @param string $table The table name to fetch from * @param string $classname The class that you want the result instantiated as * @param array $params Any params required to select the desired row * @return mixed array of object instances or false if not found */ public static function fetch_all_helper($table, $classname, $params) { $instance = new $classname(); $classvars = (array)$instance; $params = (array)$params; $wheresql = array(); $dbparams = array(); foreach ($params as $var=>$value) { if (!in_array($var, $instance->required_fields) and !array_key_exists($var, $instance->optional_fields)) { continue; } if (is_null($value)) { $wheresql[] = " $var IS NULL "; } else { $wheresql[] = " $var = ? "; $dbparams[] = $value; } } if (empty($wheresql)) { $wheresql = ''; } else { $wheresql = implode("AND", $wheresql); } global $DB; if ($datas = $DB->get_records_select($table, $wheresql, $dbparams)) { $result = array(); foreach($datas as $data) { $instance = new $classname(); self::set_properties($instance, $data); $result[$instance->id] = $instance; } return $result; } else { return false; } } /** * Updates this object in the Database, based on its object variables. ID must be set. * * @return bool success */ public function update() { global $DB; if (empty($this->id)) { debugging('Can not update data object, no id!'); return false; } $data = $this->get_record_data(); $DB->update_record($this->table, $data); $this->notify_changed(false); return true; } /** * Deletes this object from the database. * * @return bool success */ public function delete() { global $DB; if (empty($this->id)) { debugging('Can not delete data object, no id!'); return false; } $data = $this->get_record_data(); if ($DB->delete_records($this->table, array('id'=>$this->id))) { $this->notify_changed(true); return true; } else { return false; } } /** * Returns object with fields and values that are defined in database * * @return stdClass */ public function get_record_data() { $data = new stdClass(); foreach ($this as $var=>$value) { if (in_array($var, $this->required_fields) or array_key_exists($var, $this->optional_fields)) { if (is_object($value) or is_array($value)) { debugging("Incorrect property '$var' found when inserting data object"); } else { $data->$var = $value; } } } return $data; } /** * Records this object in the Database, sets its id to the returned value, and returns that value. * If successful this function also fetches the new object data from database and stores it * in object properties. * * @return int PK ID if successful, false otherwise */ public function insert() { global $DB; if (!empty($this->id)) { debugging("Data object already exists!"); return false; } $data = $this->get_record_data(); $this->id = $DB->insert_record($this->table, $data); // set all object properties from real db data $this->update_from_db(); $this->notify_changed(false); return $this->id; } /** * Using this object's id field, fetches the matching record in the DB, and looks at * each variable in turn. If the DB has different data, the db's data is used to update * the object. This is different from the update() function, which acts on the DB record * based on the object. * * @return bool True for success, false otherwise. */ public function update_from_db() { if (empty($this->id)) { debugging("The object could not be used in its state to retrieve a matching record from the DB, because its id field is not set."); return false; } global $DB; if (!$params = $DB->get_record($this->table, array('id' => $this->id))) { debugging("Object with this id:{$this->id} does not exist in table:{$this->table}, can not update from db!"); return false; } self::set_properties($this, $params); return true; } /** * Given an associated array or object, cycles through each key/variable * and assigns the value to the corresponding variable in this object. * * @final * @param data_object $instance * @param array $params */ public static function set_properties(&$instance, $params) { $params = (array) $params; foreach ($params as $var => $value) { if (in_array($var, $instance->required_fields) or array_key_exists($var, $instance->optional_fields)) { $instance->$var = $value; } } } /** * Called immediately after the object data has been inserted, updated, or * deleted in the database. Default does nothing, can be overridden to * hook in special behaviour. * * @param bool $deleted Set this to true if it has been deleted. */ public function notify_changed($deleted) { } }