Code Duplication    Length = 10-11 lines in 3 locations

main/inc/lib/thematic.lib.php 3 locations

@@ 1140-1149 (lines=10) @@
1137
        $user_id       = api_get_user_id();
1138
1139
        $all = array();
1140
        if (!empty($thematic_data)) {
1141
            foreach ($thematic_data as $thematic) {
1142
                $thematic_id = $thematic['id'];
1143
                if (!empty($thematic_advance_data[$thematic['id']])) {
1144
                    foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
1145
                        $all[] = $thematic_advance['id'];
1146
                    }
1147
                }
1148
            }
1149
        }
1150
        $error = null;
1151
        $a_thematic_advance_ids = array();
1152
        $course_id = api_get_course_int_id();
@@ 1252-1262 (lines=11) @@
1249
1250
        $a_thematic_advance_ids = array();
1251
        $last_done_advance_id = 0;
1252
        if (!empty($thematic_data)) {
1253
            foreach ($thematic_data as $thematic) {
1254
                if (!empty($thematic_advance_data[$thematic['id']])) {
1255
                    foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
1256
                        if ($thematic_advance['done_advance'] == 1) {
1257
                            $a_thematic_advance_ids[] = $thematic_advance['id'];
1258
                        }
1259
                    }
1260
                }
1261
            }
1262
        }
1263
        if (!empty($a_thematic_advance_ids)) {
1264
            $last_done_advance_id = array_pop($a_thematic_advance_ids);
1265
            $last_done_advance_id = intval($last_done_advance_id);
@@ 1282-1292 (lines=11) @@
1279
        $thematic_advance_data = $this->get_thematic_advance_list();
1280
        $a_thematic_advance_ids = array();
1281
        $next_advance_not_done = 0;
1282
        if (!empty($thematic_data)) {
1283
            foreach ($thematic_data as $thematic) {
1284
                if (!empty($thematic_advance_data[$thematic['id']])) {
1285
                    foreach ($thematic_advance_data[$thematic['id']] as $thematic_advance) {
1286
                        if ($thematic_advance['done_advance'] == 0) {
1287
                            $a_thematic_advance_ids[] = $thematic_advance['id'];
1288
                        }
1289
                    }
1290
                }
1291
            }
1292
        }
1293
1294
        if (!empty($a_thematic_advance_ids)) {
1295
            for ($i = 0; $i < $offset; $i++) {