Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 792d65d

Browse files
ESTE ES UN STEP TEMPORAL
1 parent e7b9e6c commit 792d65d

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

‎examples/php/php-divergent_change-01_base/src/Controller/CourseStepsGetController.php‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88

99
final 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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /