88
99final class CourseStepsGetController
1010{
11- const VIDEO_DURATION_PAUSES_MULTIPLIER = 1.1 ;
12- const QUIZ_TIME_PER_QUESTION_MULTIPLIER = 0.5 ;
13- const STEP_TYPE_VIDEO = 'video ' ;
14- const STEP_TYPE_QUIZ = 'quiz ' ;
15- const VIDEO_POINTS_PER_MINUTE = 100 ;
16- const QUIZ_POINTS_PER_MINUTE = 10 ;
11+ private const VIDEO_DURATION_PAUSES_MULTIPLIER = 1.1 ;
12+ private const QUIZ_TIME_PER_QUESTION_MULTIPLIER = 0.5 ;
13+ private const STEP_TYPE_VIDEO = 'video ' ;
14+ private const STEP_TYPE_QUIZ = 'quiz ' ;
15+ private const VIDEO_POINTS_PER_MINUTE = 100 ;
16+ private const QUIZ_POINTS_PER_MINUTE = 10 ;
17+ 1718 private Platform $ platform ;
1819
1920 public function __construct (Platform $ platform )
@@ -28,22 +29,15 @@ public function get(string $courseId): string
2829 return '[] ' ;
2930 }
3031
31- $ csvLines = explode (PHP_EOL , $ csv );
32- 33- $ parsedCsv = $ this ->parseCsv ($ csvLines );
32+ $ parsedCsv = $ this ->parseCsv ($ csv );
3433
3534 $ results = '[ ' ;
3635
37- $ csvLines = explode (PHP_EOL , $ csv );
38- 39- foreach ($ csvLines as $ index => $ row ) {
40- $ row = str_getcsv ($ row );
41- 42- if (empty ($ csv )) {
43- continue ;
44- }
45- 46- [$ stepId , $ type , $ quizTotalQuestions , $ videoDuration ] = $ row ;
36+ foreach ($ parsedCsv as $ index => $ row ) {
37+ $ stepId = $ row ['stepId ' ];
38+ $ type = $ row ['type ' ];
39+ $ quizTotalQuestions = $ row ['quizTotalQuestions ' ];
40+ $ videoDuration = $ row ['videoDuration ' ];
4741
4842 $ stepDurationInMinutes = 0 ;
4943 $ points = 0 ;
@@ -78,7 +72,7 @@ public function get(string $courseId): string
7872 JSON_THROW_ON_ERROR
7973 );
8074
81- $ hasMoreRows = $ index !== count ($ csvLines ) - 1 ;
75+ $ hasMoreRows = $ index !== count ($ parsedCsv ) - 1 ;
8276 if ($ hasMoreRows ) {
8377 $ results .= ', ' ;
8478 }
@@ -89,8 +83,10 @@ public function get(string $courseId): string
8983 return $ results ;
9084 }
9185
92- private function parseCsv (array $ csvLines ): array
86+ private function parseCsv (string $ csv ): array
9387 {
88+ $ csvLines = explode (PHP_EOL , $ csv );
89+ 9490 $ parsedCsv = [];
9591 foreach ($ csvLines as $ row ) {
9692 $ row = str_getcsv ($ row );
0 commit comments