Overview

Packages

  • ClipIt
    • clipit
      • api
    • urjc
      • backend
  • Elgg
    • Core
      • Access
      • Authentication
      • Cache
      • Caches
      • Core
      • DataMode
        • Site
      • DataModel
        • Annotations
        • Entities
        • Extender
        • File
        • Importable
        • Loggable
        • Notable
        • Object
        • User
      • DataStorage
      • Exception
      • Exceptions
        • Stub
      • FileStore
        • Disk
      • Groups
      • Helpers
      • HMAC
      • Memcache
      • Metadata
      • Navigation
      • ODD
      • Output
      • Plugins
        • Settings
      • Sessions
      • SocialModel
        • Friendable
        • Locatable
      • WebServicesAPI
      • Widgets
      • XML
      • XMLRPC
    • Exceptions
      • Stub
  • None
  • PHP

Classes

  • ClipitActivity
  • ClipitChat
  • ClipitComment
  • ClipitEvent
  • ClipitExample
  • ClipitFile
  • ClipitGroup
  • ClipitLA
  • ClipitLabel
  • ClipitPerformanceItem
  • ClipitPerformanceRating
  • ClipitPost
  • ClipitQuiz
  • ClipitQuizQuestion
  • ClipitQuizResult
  • ClipitRating
  • ClipitRemoteTrickyTopic
  • ClipitRemoteVideo
  • ClipitResource
  • ClipitSite
  • ClipitStoryboard
  • ClipitTag
  • ClipitTagRating
  • ClipitTask
  • ClipitTrickyTopic
  • ClipitUser
  • ClipitVideo
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * ClipIt - JuxtaLearn Web Space
  4:  * PHP version:     >= 5.2
  5:  * Creation date:   2013-10-10
  6:  * Last update:     $Date$
  7:  * @author          Pablo LlinĂ¡s Arnaiz <pebs74@gmail.com>, URJC JuxtaLearn Team
  8:  * @version         $Version$
  9:  * @link            http://www.juxtalearn.eu
 10:  * @license         GNU Affero General Public License v3
 11:  * @package         ClipIt
 12:  * @subpackage      clipit_api
 13:  */
 14: 
 15: /**
 16:  * A main topic to explain through videos, which can be decomposed into tags (Stumbling Blocks).
 17:  */
 18: class ClipitTrickyTopic extends UBItem {
 19:     /**
 20:      * @const string Elgg entity SUBTYPE for this class
 21:      */
 22:     const SUBTYPE = "ClipitTrickyTopic";
 23:     const REL_TRICKYTOPIC_TAG = "ClipitTrickyTopic-ClipitTag";
 24:     const REL_TRICKYTOPIC_FILE = "ClipitTrickyTopic-ClipitFile";
 25:     const REL_TRICKYTOPIC_STORYBOARD = "ClipitTrickyTopic-ClipitStoryboard";
 26:     const REL_TRICKYTOPIC_VIDEO = "ClipitTrickyTopic-ClipitVideo";
 27:     const REL_TRICKYTOPIC_EXAMPLE = "ClipitTrickyTopic-ClipitExample";
 28:     const EDUCATION_LEVEL_PRIMARY = "primary";
 29:     const EDUCATION_LEVEL_GCSE = "gcse";
 30:     const EDUCATION_LEVEL_ALEVEL = "alevel";
 31:     const EDUCATION_LEVEL_VOCATIONAL = "vocational";
 32:     const EDUCATION_LEVEL_UNIVERSITY = "university";
 33:     public $tag_array = array();
 34:     public $subject = "";
 35:     public $education_level = ""; // one of the EDUCATION_LEVEL_* constants
 36:     // Linked Teacher Material
 37:     public $storyboard_array = array();
 38:     public $video_array = array();
 39:     public $file_array = array();
 40:     // Linked Student Problem Examples
 41:     public $example_array = array();
 42: 
 43:     // Linked Ontology Reference
 44:     public $ontologylink = "";
 45: 
 46: 
 47:     /**
 48:      * Loads object parameters stored in Elgg
 49:      *
 50:      * @param ElggEntity $elgg_entity Elgg Object to load parameters from.
 51:      */
 52:     protected function copy_from_elgg($elgg_entity) {
 53:         parent::copy_from_elgg($elgg_entity);
 54:         $this->subject = (string)$elgg_entity->get("subject");
 55:         $this->education_level = (string)$elgg_entity->get("education_level");
 56:         $this->tag_array = (array)static::get_tags((int)$this->id);
 57:         $this->file_array = (array)static::get_files((int)$this->id);
 58:         $this->storyboard_array = (array)static::get_storyboards((int)$this->id);
 59:         $this->video_array = (array)static::get_videos((int)$this->id);
 60:         $this->example_array = (array)static::get_examples((int)$this->id);
 61: 
 62:         $this->ontologylink = (string)$elgg_entity->get("ontologylink");
 63:     }
 64: 
 65:     /**
 66:      * Copy $this object parameters into an Elgg entity.
 67:      *
 68:      * @param ElggEntity $elgg_entity Elgg object instance to save $this to
 69:      */
 70:     protected function copy_to_elgg($elgg_entity) {
 71:         parent::copy_to_elgg($elgg_entity);
 72:         $elgg_entity->set("subject", (string)$this->subject);
 73:         $elgg_entity->set("education_level", (string)$this->education_level);
 74: 
 75: 
 76:         if (!empty($this->ontologylink)) {
 77:             $elgg_entity->set("ontologylink", (string)$this->ontologylink);
 78:         } else {
 79:             $elgg_entity->set("ontologylink", "");
 80:         }
 81:     }
 82: 
 83:     /**
 84:      * Saves this instance to the system.
 85:      * @param  bool $double_save if $double_save is true, this object is saved twice to ensure that all properties are updated properly. E.g. the time created property can only beset on ElggObjects during an update. Defaults to false!
 86:      * @return bool|int Returns the Id of the saved instance, or false if error
 87:      */
 88:     public function save($double_save=false) {
 89:         parent::save($double_save);
 90:         static::set_tags((int)$this->id, (array)$this->tag_array);
 91:         static::set_files((int)$this->id, (array)$this->file_array);
 92:         static::set_storyboards((int)$this->id, (array)$this->storyboard_array);
 93:         static::set_videos((int)$this->id, (array)$this->video_array);
 94:         static::set_examples((int)$this->id, (array)$this->example_array);
 95:         return (int)$this->id;
 96:     }
 97: 
 98:     /**
 99:      * Clones a Tricky Topic, including the contained Stumbling Blocks, teacher Material and Examples
100:      *
101:      * @param int $id ID of Tricky Topic to clone
102:      * @param bool $linked Whether the clone will be linked to the parent object
103:      * @param bool $keep_owner Selects whether the clone will keep the parent item's owner (default: no)
104:      * @return bool|int ID of new cloned object
105:      * @throws InvalidParameterException if error
106:      */
107:     static function create_clone($id, $linked = true, $keep_owner = false) {
108:         $prop_value_array = static::get_properties($id);
109:         if($keep_owner === false){
110:             $prop_value_array["owner_id"] = elgg_get_logged_in_user_guid();
111:         }
112:         $example_array = $prop_value_array["example_array"];
113:         if(!empty($example_array)){
114:             $new_example_array = array();
115:             foreach($example_array as $example_id){
116:                 $new_example_array[] = ClipitExample::create_clone($example_id);
117:             }
118:             $prop_value_array["example_array"] = $new_example_array;
119:         }
120:         $clone_id = static::create($prop_value_array);
121:         if($linked) {
122:             static::link_parent_clone($id, $clone_id);
123:         }
124:         return $clone_id;
125:     }
126: 
127:     /**
128:      * Adds Tags to a Tricky Topic, referenced by Id.
129:      *
130:      * @param int   $id        Id from the Tricky Topic to add Tags to
131:      * @param array $tag_array Array of Tag Ids to be added to the Tricky Topic
132:      *
133:      * @return bool Returns true if success, false if error
134:      */
135:     static function add_tags($id, $tag_array) {
136:         return UBCollection::add_items($id, $tag_array, static::REL_TRICKYTOPIC_TAG);
137:     }
138: 
139:     /**
140:      * Sets Tags to a Tricky Topic, referenced by Id.
141:      *
142:      * @param int   $id        Id from the Tricky Topic to set Tags to
143:      * @param array $tag_array Array of Tag Ids to be set to the Tricky Topic
144:      *
145:      * @return bool Returns true if success, false if error
146:      */
147:     static function set_tags($id, $tag_array) {
148:         return UBCollection::set_items($id, $tag_array, static::REL_TRICKYTOPIC_TAG);
149:     }
150: 
151:     /**
152:      * Remove Tags from a Tricky Topic.
153:      *
154:      * @param int   $id        Id from Tricky Topic to remove Tags from
155:      * @param array $tag_array Array of Tag Ids to remove from Tricky Topic
156:      *
157:      * @return bool Returns true if success, false if error
158:      */
159:     static function remove_tags($id, $tag_array) {
160:         return UBCollection::remove_items($id, $tag_array, static::REL_TRICKYTOPIC_TAG);
161:     }
162: 
163:     /**
164:      * Get all Tags from a Tricky Topic
165:      *
166:      * @param int $id Id of the Tricky Topic to get Tags from
167:      *
168:      * @return array|bool Returns an array of Tag IDs, or false if error
169:      */
170:     static function get_tags($id) {
171:         return UBCollection::get_items($id, static::REL_TRICKYTOPIC_TAG);
172:     }
173: 
174:     // TEACHER RESOURCES: STORYBOARDS
175:     static function add_storyboards($id, $storyboard_array) {
176:         return UBCollection::add_items($id, $storyboard_array, static::REL_TRICKYTOPIC_STORYBOARD);
177:     }
178: 
179:     static function set_storyboards($id, $storyboard_array) {
180:         return UBCollection::set_items($id, $storyboard_array, static::REL_TRICKYTOPIC_STORYBOARD);
181:     }
182: 
183:     static function remove_storyboards($id, $storyboard_array) {
184:         return UBCollection::remove_items($id, $storyboard_array, static::REL_TRICKYTOPIC_STORYBOARD);
185:     }
186: 
187:     static function get_storyboards($id) {
188:         return UBCollection::get_items($id, static::REL_TRICKYTOPIC_STORYBOARD);
189:     }
190: 
191:     // TEACHER RESOURCES: VIDEOS
192:     static function add_videos($id, $video_array) {
193:         return UBCollection::add_items($id, $video_array, static::REL_TRICKYTOPIC_VIDEO);
194:     }
195: 
196:     static function set_videos($id, $video_array) {
197:         return UBCollection::set_items($id, $video_array, static::REL_TRICKYTOPIC_VIDEO);
198:     }
199: 
200:     static function remove_videos($id, $video_array) {
201:         return UBCollection::remove_items($id, $video_array, static::REL_TRICKYTOPIC_VIDEO);
202:     }
203: 
204:     static function get_videos($id) {
205:         return UBCollection::get_items($id, static::REL_TRICKYTOPIC_VIDEO);
206:     }
207: 
208:     // TEACHER RESOURCES: FILES
209:     static function add_files($id, $file_array) {
210:         return UBCollection::add_items($id, $file_array, static::REL_TRICKYTOPIC_FILE);
211:     }
212: 
213:     static function set_files($id, $file_array) {
214:         return UBCollection::set_items($id, $file_array, static::REL_TRICKYTOPIC_FILE);
215:     }
216: 
217:     static function remove_files($id, $file_array) {
218:         return UBCollection::remove_items($id, $file_array, static::REL_TRICKYTOPIC_FILE);
219:     }
220: 
221:     static function get_files($id) {
222:         return UBCollection::get_items($id, static::REL_TRICKYTOPIC_FILE);
223:     }
224: 
225:     // Student Problem Examples
226:     static function add_examples($id, $example_array) {
227:         return UBCollection::add_items($id, $example_array, static::REL_TRICKYTOPIC_EXAMPLE, true);
228:     }
229: 
230:     static function set_examples($id, $example_array) {
231:         return UBCollection::set_items($id, $example_array, static::REL_TRICKYTOPIC_EXAMPLE, true);
232:     }
233: 
234:     static function remove_examples($id, $example_array) {
235:         return UBCollection::remove_items($id, $example_array, static::REL_TRICKYTOPIC_EXAMPLE);
236:     }
237: 
238:     static function get_examples($id) {
239:         return UBCollection::get_items($id, static::REL_TRICKYTOPIC_EXAMPLE);
240:     }
241: }
API documentation generated by ApiGen 2.8.0