PageRenderTime 25ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/php/lib/platform/dokeos185/data_class/dokeos185_assignment_submission.class.php

https://bitbucket.org/chamilo/chamilo-migration-dev/
PHP | 464 lines | 2 code | 2 blank | 460 comment | 0 complexity | 6db55ff775b73e92ef08581cf83c18b6 MD5 | raw file
  1. <?php
  2. //namespace migration;
  3. ///**
  4. // * $Id: dokeos185_assignment_submission.class.php 221 2009-11-13 14:36:41Z vanpouckesven $
  5. // * @package migration.lib.platform.dokeos185
  6. // */
  7. //
  8. //require_once dirname(__FILE__) . '/../../lib/import/import_assignment_submission.class.php';
  9. //require_once dirname(__FILE__) . '/../../../repository/lib/content_object/document/document.class.php';
  10. //require_once dirname(__FILE__) . '/../../../application/weblcms/php/content_object_publication.class.php';
  11. //require_once dirname(__FILE__) . '/../../../application/weblcms/php/content_object_publication_category.class.php';
  12. //
  13. ///**
  14. // * This class presents a Dokeos185 assignment_submission
  15. // *
  16. // * @author Sven Vanpoucke
  17. // */
  18. //class Dokeos185AssignmentSubmission extends Dokeos185MigrationDataClass
  19. //{
  20. // /**
  21. // * Dokeos185AssignmentSubmission properties
  22. // */
  23. // const PROPERTY_ID = 'id';
  24. // const PROPERTY_ASSIGNMENT_ID = 'assignment_id';
  25. // const PROPERTY_PARENT_ID = 'parent_id';
  26. // const PROPERTY_USER_ID = 'user_id';
  27. // const PROPERTY_GROUP_ID = 'group_id';
  28. // const PROPERTY_TITLE = 'title';
  29. // const PROPERTY_VISIBILITY = 'visibility';
  30. // const PROPERTY_CREATION_DATE = 'creation_date';
  31. // const PROPERTY_LAST_EDIT_DATE = 'last_edit_date';
  32. // const PROPERTY_AUTHORS = 'authors';
  33. // const PROPERTY_SUBMITTED_TEXT = 'submitted_text';
  34. // const PROPERTY_SUBMITTED_DOC_PATH = 'submitted_doc_path';
  35. // const PROPERTY_PRIVATE_FEEDBACK = 'private_feedback';
  36. // const PROPERTY_ORIGINAL_AUTH_ID = 'original_auth_id';
  37. // const PROPERTY_SCORE = 'score';
  38. //
  39. // private static $mgdm;
  40. //
  41. // /**
  42. // * Default properties stored in an associative array.
  43. // */
  44. // private $defaultProperties;
  45. //
  46. // /**
  47. // * Creates a new Dokeos185AssignmentSubmission object
  48. // * @param array $defaultProperties The default properties
  49. // */
  50. // function __construct($defaultProperties = array ())
  51. // {
  52. // $this->defaultProperties = $defaultProperties;
  53. // }
  54. //
  55. // /**
  56. // * Gets a default property by name.
  57. // * @param string $name The name of the property.
  58. // */
  59. // function get_default_property($name)
  60. // {
  61. // return $this->defaultProperties[$name];
  62. // }
  63. //
  64. // /**
  65. // * Gets the default properties
  66. // * @return array An associative array containing the properties.
  67. // */
  68. // function get_default_properties()
  69. // {
  70. // return $this->defaultProperties;
  71. // }
  72. //
  73. // /**
  74. // * Get the default properties
  75. // * @return array The property names.
  76. // */
  77. // static function get_default_property_names()
  78. // {
  79. // return array(self :: PROPERTY_ID, self :: PROPERTY_ASSIGNMENT_ID, self :: PROPERTY_PARENT_ID, self :: PROPERTY_USER_ID, self :: PROPERTY_GROUP_ID, self :: PROPERTY_TITLE, self :: PROPERTY_VISIBILITY, self :: PROPERTY_CREATION_DATE, self :: PROPERTY_LAST_EDIT_DATE, self :: PROPERTY_AUTHORS, self :: PROPERTY_SUBMITTED_TEXT, self :: PROPERTY_SUBMITTED_DOC_PATH, self :: PROPERTY_PRIVATE_FEEDBACK, self :: PROPERTY_ORIGINAL_AUTH_ID, self :: PROPERTY_SCORE);
  80. // }
  81. //
  82. // /**
  83. // * Sets a default property by name.
  84. // * @param string $name The name of the property.
  85. // * @param mixed $value The new value for the property.
  86. // */
  87. // function set_default_property($name, $value)
  88. // {
  89. // $this->defaultProperties[$name] = $value;
  90. // }
  91. //
  92. // /**
  93. // * Sets the default properties of this class
  94. // */
  95. // function set_default_properties($defaultProperties)
  96. // {
  97. // $this->defaultProperties = $defaultProperties;
  98. // }
  99. //
  100. // /**
  101. // * Returns the id of this Dokeos185AssignmentSubmission.
  102. // * @return the id.
  103. // */
  104. // function get_id()
  105. // {
  106. // return $this->get_default_property(self :: PROPERTY_ID);
  107. // }
  108. //
  109. // /**
  110. // * Returns the assignment_id of this Dokeos185AssignmentSubmission.
  111. // * @return the assignment_id.
  112. // */
  113. // function get_assignment_id()
  114. // {
  115. // return $this->get_default_property(self :: PROPERTY_ASSIGNMENT_ID);
  116. // }
  117. //
  118. // /**
  119. // * Returns the parent_id of this Dokeos185AssignmentSubmission.
  120. // * @return the parent_id.
  121. // */
  122. // function get_parent_id()
  123. // {
  124. // return $this->get_default_property(self :: PROPERTY_PARENT_ID);
  125. // }
  126. //
  127. // /**
  128. // * Returns the user_id of this Dokeos185AssignmentSubmission.
  129. // * @return the user_id.
  130. // */
  131. // function get_user_id()
  132. // {
  133. // return $this->get_default_property(self :: PROPERTY_USER_ID);
  134. // }
  135. //
  136. // /**
  137. // * Returns the group_id of this Dokeos185AssignmentSubmission.
  138. // * @return the group_id.
  139. // */
  140. // function get_group_id()
  141. // {
  142. // return $this->get_default_property(self :: PROPERTY_GROUP_ID);
  143. // }
  144. //
  145. // /**
  146. // * Returns the title of this Dokeos185AssignmentSubmission.
  147. // * @return the title.
  148. // */
  149. // function get_title()
  150. // {
  151. // return $this->get_default_property(self :: PROPERTY_TITLE);
  152. // }
  153. //
  154. // /**
  155. // * Returns the visibility of this Dokeos185AssignmentSubmission.
  156. // * @return the visibility.
  157. // */
  158. // function get_visibility()
  159. // {
  160. // return $this->get_default_property(self :: PROPERTY_VISIBILITY);
  161. // }
  162. //
  163. // /**
  164. // * Returns the creation_date of this Dokeos185AssignmentSubmission.
  165. // * @return the creation_date.
  166. // */
  167. // function get_creation_date()
  168. // {
  169. // return $this->get_default_property(self :: PROPERTY_CREATION_DATE);
  170. // }
  171. //
  172. // /**
  173. // * Returns the last_edit_date of this Dokeos185AssignmentSubmission.
  174. // * @return the last_edit_date.
  175. // */
  176. // function get_last_edit_date()
  177. // {
  178. // return $this->get_default_property(self :: PROPERTY_LAST_EDIT_DATE);
  179. // }
  180. //
  181. // /**
  182. // * Returns the authors of this Dokeos185AssignmentSubmission.
  183. // * @return the authors.
  184. // */
  185. // function get_authors()
  186. // {
  187. // return $this->get_default_property(self :: PROPERTY_AUTHORS);
  188. // }
  189. //
  190. // /**
  191. // * Returns the submitted_text of this Dokeos185AssignmentSubmission.
  192. // * @return the submitted_text.
  193. // */
  194. // function get_submitted_text()
  195. // {
  196. // return $this->get_default_property(self :: PROPERTY_SUBMITTED_TEXT);
  197. // }
  198. //
  199. // /**
  200. // * Returns the submitted_doc_path of this Dokeos185AssignmentSubmission.
  201. // * @return the submitted_doc_path.
  202. // */
  203. // function get_submitted_doc_path()
  204. // {
  205. // return $this->get_default_property(self :: PROPERTY_SUBMITTED_DOC_PATH);
  206. // }
  207. //
  208. // /**
  209. // * Returns the private_feedback of this Dokeos185AssignmentSubmission.
  210. // * @return the private_feedback.
  211. // */
  212. // function get_private_feedback()
  213. // {
  214. // return $this->get_default_property(self :: PROPERTY_PRIVATE_FEEDBACK);
  215. // }
  216. //
  217. // /**
  218. // * Returns the original_auth_id of this Dokeos185AssignmentSubmission.
  219. // * @return the original_auth_id.
  220. // */
  221. // function get_original_auth_id()
  222. // {
  223. // return $this->get_default_property(self :: PROPERTY_ORIGINAL_AUTH_ID);
  224. // }
  225. //
  226. // /**
  227. // * Returns the score of this Dokeos185AssignmentSubmission.
  228. // * @return the score.
  229. // */
  230. // function get_score()
  231. // {
  232. // return $this->get_default_property(self :: PROPERTY_SCORE);
  233. // }
  234. //
  235. // /**
  236. // * Check if the assignment submission is valid
  237. // * @param array $array the parameters for the validation
  238. // * @return true if the assignment submission is valid
  239. // */
  240. // function is_valid($array)
  241. // {
  242. // $old_mgdm = $array['old_mgdm'];
  243. //
  244. // $course = $array['course'];
  245. // $filename = $this->get_submitted_doc_path();
  246. // $old_rel_path = 'courses/' . $course->get_directory() . '/assignment/assig_' . $this->get_assignment_id() . '/';
  247. //
  248. // $filename = iconv("UTF-8", "ISO-8859-1", $filename);
  249. // $old_rel_path = iconv("UTF-8", "ISO-8859-1", $old_rel_path);
  250. //
  251. // if (! $this->get_assignment_id() || ! $this->get_submitted_doc_path() || ! file_exists($old_mgdm->append_full_path(false, $old_rel_path . $filename)))
  252. // {
  253. // $mgdm = MigrationDataManager :: get_instance();
  254. // $mgdm->add_failed_element($this->get_id(), $course->get_db_name() . '.assignment_submission');
  255. // return false;
  256. // }
  257. // return true;
  258. // }
  259. //
  260. // /**
  261. // * Convert to new assignment submission
  262. // * Create document
  263. // * @param array $array the parameters for the conversion
  264. // * @return the new assignment submission
  265. // */
  266. // function convert_data()
  267. //
  268. //{
  269. // $course = $array['course'];
  270. // $old_mgdm = $array['old_mgdm'];
  271. // $mgdm = MigrationDataManager :: get_instance();
  272. //
  273. // $new_course_code = $mgdm->get_id_reference($course->get_code(), 'weblcms_course');
  274. // $new_user_id = $mgdm->get_id_reference($this->get_user_id(), 'user_user');
  275. // if (! $new_user_id)
  276. // {
  277. // $new_user_id = $this->get_data_manager()->get_owner_id($new_course_code);
  278. // }
  279. //
  280. // $filename = $this->get_submitted_doc_path();
  281. // $new_path = $new_user_id . '/';
  282. // $old_rel_path = 'courses/' . $course->get_directory() . '/assignment/assig_' . $this->get_assignment_id() . '/';
  283. //
  284. // $new_rel_path = 'files/repository/' . $new_path;
  285. //
  286. // $lcms_document = null;
  287. //
  288. // $filename = iconv("UTF-8", "ISO-8859-1", $filename);
  289. // $old_rel_path = iconv("UTF-8", "ISO-8859-1", $old_rel_path);
  290. //
  291. // $document_md5 = md5_file($old_mgdm->append_full_path(false, $old_rel_path . $filename));
  292. // $document_id = $mgdm->get_document_from_md5($new_user_id, $document_md5);
  293. //
  294. // if (! $document_id)
  295. // {
  296. // $file = $old_mgdm->move_file($old_rel_path, $new_rel_path, $filename);
  297. //
  298. // if ($file)
  299. // {
  300. // //document parameters
  301. // $lcms_document = new Document();
  302. // if (! $this->get_title())
  303. // $lcms_document->set_title($filename);
  304. // else
  305. // $lcms_document->set_title($this->get_title());
  306. // if (! $this->get_submitted_text())
  307. // $lcms_document->set_description('...');
  308. // else
  309. // $lcms_document->set_description($this->get_submitted_text());
  310. //
  311. // $lcms_document->set_owner_id($new_user_id);
  312. //
  313. // $lcms_document->set_path($new_path . $file);
  314. // $lcms_document->set_filename($file);
  315. //
  316. // $lcms_document->set_creation_date(strtotime($this->get_creation_date()));
  317. // $lcms_document->set_modification_date(strtotime($this->get_last_edit_date()));
  318. //
  319. // //if($this->get_visibility() == 2)
  320. // // $lcms_document->set_state(1);
  321. //
  322. //
  323. // // Category for announcements already exists?
  324. // $lcms_category_id = $mgdm->get_parent_id($new_user_id, 'category', Translation :: get('assignment'));
  325. // if (! $lcms_category_id)
  326. // {
  327. // //Create category for tool in lcms
  328. // $lcms_repository_category = new Category();
  329. // $lcms_repository_category->set_owner_id($new_user_id);
  330. // $lcms_repository_category->set_title(Translation :: get('assignment'));
  331. // $lcms_repository_category->set_description('...');
  332. //
  333. // //Retrieve repository id from course
  334. // $repository_id = $mgdm->get_parent_id($new_user_id, 'category', Translation :: get('MyRepository'));
  335. // $lcms_repository_category->set_parent_id($repository_id);
  336. //
  337. // //Create category in database
  338. // $lcms_repository_category->create();
  339. //
  340. // $lcms_document->set_parent_id($lcms_repository_category->get_id());
  341. // }
  342. // else
  343. // {
  344. // $lcms_document->set_parent_id($lcms_category_id);
  345. // }
  346. //
  347. // //create document in database
  348. // $lcms_document->create();
  349. //
  350. // $mgdm->add_file_md5($new_user_id, $lcms_document->get_id(), $document_md5);
  351. // }
  352. // else
  353. // {
  354. // $document_id = $mgdm->get_document_id($new_rel_path . $filename, $new_user_id);
  355. // if ($document_id)
  356. // {
  357. // $lcms_document = new ContentObject();
  358. // $lcms_document->set_id($document_id);
  359. // }
  360. // }
  361. //
  362. // }
  363. // else
  364. // {
  365. // $lcms_document = new ContentObject();
  366. // }
  367. //
  368. // //publication
  369. // /*
  370. // if($this->item_property->get_visibility() <= 1 && $lcms_document)
  371. // {
  372. //
  373. // // Categories already exists?
  374. // $file_split = array();
  375. // $file_split = split('/', $old_path);
  376. //
  377. // array_shift($file_split);
  378. // array_pop($file_split);
  379. //
  380. // $parent = 0;
  381. //
  382. // foreach($file_split as $cat)
  383. // {
  384. // $lcms_category_id = self :: $mgdm->publication_category_exist($cat, $new_course_code,
  385. // 'assignment',$parent);
  386. //
  387. // if(!$lcms_category_id)
  388. // {
  389. // //Create category for tool in lcms
  390. // $lcms_category = new ContentObjectPublicationCategory();
  391. // $lcms_category->set_title($cat);
  392. // $lcms_category->set_course($new_course_code);
  393. // $lcms_category->set_tool('document');
  394. // $lcms_category->set_parent_category_id($parent);
  395. //
  396. // //Create category in database
  397. // $lcms_category->create();
  398. // $parent = $lcms_category->get_id();
  399. // }
  400. // else
  401. // {
  402. // $parent = $lcms_category_id;
  403. // }
  404. //
  405. // }
  406. //
  407. // $end_time_cat = Logger :: get_microtime();
  408. // $passedtime_categories = $end_time_cat - $start_time_cat;
  409. //
  410. // $publication = new ContentObjectPublication();
  411. //
  412. // $publication->set_content_object($lcms_document);
  413. // $publication->set_course_id($new_course_code);
  414. // $publication->set_publisher_id($new_user_id);
  415. // $publication->set_tool('document');
  416. // $publication->set_category_id($parent);
  417. // //$publication->set_from_date(self :: $mgdm->make_unix_time($this->item_property->get_start_visible()));
  418. // //$publication->set_to_date(self :: $mgdm->make_unix_time($this->item_property->get_end_visible()));
  419. // $publication->set_from_date(0);
  420. // $publication->set_to_date(0);
  421. // $publication->set_publication_date(self :: $mgdm->make_unix_time($this->item_property->get_insert_date()));
  422. // $publication->set_modified_date(self :: $mgdm->make_unix_time($this->item_property->get_lastedit_date()));
  423. // //$publication->set_modified_date(0);
  424. // //$publication->set_display_order_index($this->get_display_order());
  425. // $publication->set_display_order_index(0);
  426. // $publication->set_email_sent(0);
  427. //
  428. // $publication->set_hidden($this->item_property->get_visibility() == 1?0:1);
  429. //
  430. // //create publication in database
  431. // $publication->create();
  432. // }
  433. // */
  434. //
  435. // return $lcms_document;
  436. //}
  437. //
  438. // /**
  439. // * Retrieve all assignment submission from the database
  440. // * @param array $parameters parameters for the retrieval
  441. // * @return array of assignment submissions
  442. // */
  443. // static function retrieve_data($parameters)
  444. //{
  445. // $old_mgdm = $parameters['old_mgdm'];
  446. //
  447. // $coursedb = $parameters['course']->get_db_name();
  448. // $tablename = 'assignment_submission';
  449. // $classname = 'Dokeos185AssignmentSubmission';
  450. //
  451. // return $old_mgdm->get_all($coursedb, $tablename, $classname, $tool_name, $parameters['offset'], $parameters['limit']);
  452. //}
  453. //
  454. // static function get_database_table($parameters)
  455. //{
  456. // $array = array();
  457. // $array['database'] = $parameters['course']->get_db_name();
  458. // $array['table'] = 'assignment_submission';
  459. // return $array;
  460. //}
  461. //}
  462. ?>