6
6
use Chamilo \CourseBundle \Component \CourseCopy \CourseBuilder ;
7
7
use Chamilo \CourseBundle \Component \CourseCopy \CourseRestorer ;
8
8
use Gedmo \Sortable \Entity \Repository \SortableRepository ;
9
+ use Symfony \Component \Filesystem \Filesystem ;
9
10
10
11
/**
11
12
* Class learnpath
@@ -237,7 +238,6 @@ public function __construct($course, $lp_id, $user_id)
237
238
238
239
$ sql = "UPDATE $ lp_table SET id = iid WHERE iid = " .$ this ->lp_view_id ;
239
240
Database::query ($ sql );
240
-
241
241
}
242
242
243
243
// Initialise items.
@@ -484,7 +484,7 @@ private static function get_level_for_item($in_tab_items, $in_current_item_id)
484
484
* @param int $parent
485
485
* @param int $previous
486
486
* @param string $type
487
- * @param int resource ID (ref)
487
+ * @param int $id resource ID (ref)
488
488
* @param string $title
489
489
* @param string $description
490
490
* @param int $prerequisites
@@ -770,9 +770,7 @@ public static function add_lp(
770
770
771
771
// Session id.
772
772
$ session_id = api_get_session_id ();
773
-
774
773
$ userId = empty ($ userId ) ? api_get_user_id () : $ userId ;
775
-
776
774
$ check_name = "SELECT * FROM $ tbl_lp
777
775
WHERE c_id = $ course_id AND name = ' $ name' " ;
778
776
@@ -1090,7 +1088,8 @@ public function delete($courseInfo = null, $id = null, $delete = 'keep')
1090
1088
$ sql = "SELECT id FROM $ lp
1091
1089
WHERE c_id = " .$ course_id ." AND path = ' $ path' AND id != " . $ this ->lp_id ;
1092
1090
$ res = Database::query ($ sql );
1093
- if (Database :: num_rows ($ res ) > 0 ) { // Another learning path uses this directory, so don't delete it.
1091
+ if (Database :: num_rows ($ res ) > 0 ) {
1092
+ // Another learning path uses this directory, so don't delete it.
1094
1093
if ($ this ->debug > 2 ) {
1095
1094
error_log ('New LP - In learnpath::delete(), found other LP using path ' . $ path . ', keeping directory ' , 0 );
1096
1095
}
@@ -9640,8 +9639,6 @@ public function scorm_export()
9640
9639
}
9641
9640
}
9642
9641
}*/
9643
-
9644
-
9645
9642
$ possible_parent = $ this ->get_scorm_xml_node ($ children , 'ITEM_ ' .$ item ->parent );
9646
9643
if ($ possible_parent ) {
9647
9644
if ($ possible_parent ->getAttribute ('identifier ' ) == 'ITEM_ ' .$ item ->parent ) {
@@ -9857,7 +9854,6 @@ public function scorm_export()
9857
9854
// TODO: Add a readme file here, with a short description and a link to the Reload player
9858
9855
// then add the file to the zip, then destroy the file (this is done automatically).
9859
9856
// http://www.reload.ac.uk/scormplayer.html - once done, don't forget to close FS#138
9860
-
9861
9857
foreach ($ zip_files as $ file_path ) {
9862
9858
if (empty ($ file_path )) {
9863
9859
continue ;
@@ -9988,7 +9984,7 @@ public function scorm_export()
9988
9984
// Add the extra files that go along with a SCORM package.
9989
9985
$ main_code_path = api_get_path (SYS_CODE_PATH ) . 'lp/packaging/ ' ;
9990
9986
9991
- $ fs = new \ Symfony \ Component \ Filesystem \ Filesystem ;
9987
+ $ fs = new Filesystem () ;
9992
9988
$ fs ->mirror ($ main_code_path , $ archive_path .$ temp_dir_short );
9993
9989
9994
9990
// Finalize the imsmanifest structure, add to the zip, then return the zip.
@@ -10118,12 +10114,9 @@ public function delete_lp_image()
10118
10114
*/
10119
10115
public function upload_image ($ image_array )
10120
10116
{
10121
- $ image_moved = false ;
10122
10117
if (!empty ($ image_array ['name ' ])) {
10123
10118
$ upload_ok = process_uploaded_file ($ image_array );
10124
10119
$ has_attachment = true ;
10125
- } else {
10126
- $ image_moved = true ;
10127
10120
}
10128
10121
10129
10122
if ($ upload_ok ) {
@@ -10135,8 +10128,7 @@ public function upload_image($image_array)
10135
10128
$ new_file_name = add_ext_on_mime (stripslashes ($ image_array ['name ' ]), $ image_array ['type ' ]);
10136
10129
10137
10130
if (!filter_extension ($ new_file_name )) {
10138
- //Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
10139
- $ image_moved = false ;
10131
+
10140
10132
} else {
10141
10133
$ file_extension = explode ('. ' , $ image_array ['name ' ]);
10142
10134
$ file_extension = strtolower ($ file_extension [sizeof ($ file_extension ) - 1 ]);
@@ -10151,7 +10143,6 @@ public function upload_image($image_array)
10151
10143
10152
10144
// Storing the image filename.
10153
10145
if ($ result ) {
10154
- $ image_moved = true ;
10155
10146
$ this ->set_preview_image ($ new_file_name );
10156
10147
10157
10148
//Resize to 64px to use on course homepage
@@ -10203,9 +10194,9 @@ public function select_previous_item_id()
10203
10194
$ table_lp_item = Database::get_course_table (TABLE_LP_ITEM );
10204
10195
10205
10196
// Get the max order of the items
10206
- $ sql_max_order = "SELECT max(display_order) AS display_order FROM $ table_lp_item
10207
- WHERE c_id = $ course_id AND lp_id = ' " . $ this ->lp_id . "' " ;
10208
- $ rs_max_order = Database::query ($ sql_max_order );
10197
+ $ sql = "SELECT max(display_order) AS display_order FROM $ table_lp_item
10198
+ WHERE c_id = $ course_id AND lp_id = ' " . $ this ->lp_id . "' " ;
10199
+ $ rs_max_order = Database::query ($ sql );
10209
10200
$ row_max_order = Database::fetch_object ($ rs_max_order );
10210
10201
$ max_order = $ row_max_order ->display_order ;
10211
10202
// Get the previous item ID
@@ -10223,9 +10214,7 @@ public function select_previous_item_id()
10223
10214
*/
10224
10215
public function copy ()
10225
10216
{
10226
- $ main_path = api_get_path (SYS_CODE_PATH );
10227
-
10228
- //Course builder
10217
+ // Course builder
10229
10218
$ cb = new CourseBuilder ();
10230
10219
10231
10220
//Setting tools that will be copied
@@ -10460,7 +10449,9 @@ public static function getCategory($id)
10460
10449
public static function getCategoryByCourse ($ courseId )
10461
10450
{
10462
10451
$ em = Database::getManager ();
10463
- $ items = $ em ->getRepository ('ChamiloCourseBundle:CLpCategory ' )->findBy (array ('cId ' => $ courseId ));
10452
+ $ items = $ em ->getRepository ('ChamiloCourseBundle:CLpCategory ' )->findBy (
10453
+ array ('cId ' => $ courseId )
10454
+ );
10464
10455
10465
10456
return $ items ;
10466
10457
}
@@ -10475,7 +10466,6 @@ public static function deleteCategory($id)
10475
10466
$ em = Database::getManager ();
10476
10467
$ item = $ em ->find ('ChamiloCourseBundle:CLpCategory ' , $ id );
10477
10468
if ($ item ) {
10478
-
10479
10469
$ courseId = $ item ->getCId ();
10480
10470
$ query = $ em ->createQuery ('SELECT u FROM ChamiloCourseBundle:CLp u WHERE u.cId = :id AND u.categoryId = :catId ' );
10481
10471
$ query ->setParameter ('id ' , $ courseId );
@@ -10501,7 +10491,7 @@ public static function deleteCategory($id)
10501
10491
*
10502
10492
* @return mixed
10503
10493
*/
10504
- static function getCategoryFromCourseIntoSelect ($ courseId , $ addSelectOption = false )
10494
+ public static function getCategoryFromCourseIntoSelect ($ courseId , $ addSelectOption = false )
10505
10495
{
10506
10496
$ items = self ::getCategoryByCourse ($ courseId );
10507
10497
$ cats = array ();
@@ -10737,7 +10727,6 @@ public function getExercisesItems()
10737
10727
public function getFinalEvaluationItem ()
10738
10728
{
10739
10729
$ exercises = [];
10740
-
10741
10730
foreach ($ this ->items as $ item ) {
10742
10731
if ($ item ->type != 'quiz ' ) {
10743
10732
continue ;
@@ -11123,10 +11112,9 @@ public function isFirstOrLastItem($currentItemId)
11123
11112
}
11124
11113
11125
11114
$ lpItemId = [];
11126
-
11127
11115
$ typeListNotToVerify = self ::getChapterTypes ();
11128
11116
11129
- // Using get_toc() function instead $this->items because returns the correct order of the items
11117
+ // Using get_toc() function instead $this->items because returns the correct order of the items
11130
11118
foreach ($ this ->get_toc () as $ item ) {
11131
11119
if (!in_array ($ item ['type ' ], $ typeListNotToVerify )) {
11132
11120
$ lpItemId [] = $ item ['id ' ];
@@ -11184,7 +11172,6 @@ public function setAccumulateScormTime($value)
11184
11172
return true ;
11185
11173
}
11186
11174
11187
-
11188
11175
/**
11189
11176
* Returns an HTML-formatted link to a resource, to incorporate directly into
11190
11177
* the new learning path tool.
@@ -11299,14 +11286,6 @@ public static function rl_get_resource_link_for_learnpath($course_id, $learningP
11299
11286
$ tbl_post = Database::get_course_table (TABLE_FORUM_POST );
11300
11287
$ result = Database::query ("SELECT * FROM $ tbl_post WHERE c_id = $ course_id AND post_id= $ id " );
11301
11288
$ myrow = Database::fetch_array ($ result );
11302
- $ title = $ myrow ['post_title ' ];
11303
- //$desc = $row_item['description'];
11304
- $ posternom = $ myrow ['poster_name ' ];
11305
- $ posttime = $ myrow ['post_date ' ];
11306
- $ posttext = $ myrow ['post_text ' ];
11307
- $ posttitle = $ title ;
11308
- $ posttext = str_replace ('" ' , "' " , $ posttext );
11309
-
11310
11289
$ link .= $ main_dir_path .'forum/viewthread.php?post= ' .$ id .'' .
11311
11290
'&thread= ' .$ myrow ['thread_id ' ].'&forum= ' .$ myrow ['forum_id ' ].'' .
11312
11291
'&lp=true ' ;
@@ -11468,11 +11447,9 @@ public static function rl_get_resource_name($course_code, $learningPathId, $id_i
11468
11447
$ pathname = explode ('/ ' , $ myrow ['path ' ]); // Making a correct name for the link.
11469
11448
$ last = count ($ pathname ) - 1 ; // Making a correct name for the link.
11470
11449
$ filename = $ pathname [$ last ]; // Making a correct name for the link.
11471
- $ image = choose_image ($ filename );
11472
11450
$ ext = explode ('. ' , $ filename );
11473
11451
$ ext = strtolower ($ ext [sizeof ($ ext ) - 1 ]);
11474
11452
$ myrow ['path ' ] = rawurlencode ($ myrow ['path ' ]);
11475
- $ in_frames = in_array ($ ext , array ('htm ' , 'html ' , 'gif ' , 'jpg ' , 'jpeg ' , 'png ' ));
11476
11453
$ output = $ filename ;
11477
11454
break ;
11478
11455
}
0 commit comments