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 d2f05b5

Browse files
Rename
1 parent 15342d0 commit d2f05b5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
final class CourseStepsGetController
1010
{
11+
const VIDEO_DURATION_PAUSES_MULTIPLIER = 1.1;
1112
private Platform $platform;
1213

1314
public function __construct(Platform $platform)
@@ -31,23 +32,24 @@ public function get(string $courseId): string
3132
}
3233

3334
$type = $row[1];
34-
$duration = 0;
35+
$stepDuration = 0;
3536
$points = 0;
3637

38+
$videoDuration = $row[3];
3739
if ($type === 'video') {
38-
$duration = $row[3] * 1.1; // 1.1 = due to video pauses
40+
$stepDuration = $videoDuration * self::VIDEO_DURATION_PAUSES_MULTIPLIER;
3941
}
4042

4143
if ($type === 'quiz') {
42-
$duration = $row[2] * 0.5; // 0.5 = time in minutes per question
44+
$stepDuration = $row[2] * 0.5; // 0.5 = time in minutes per question
4345
}
4446

4547
if ($type !== 'video' && $type !== 'quiz') {
4648
continue;
4749
}
4850

4951
if ($type === 'video') {
50-
$points = $row[3] * 1.1 * 100;
52+
$points = $stepDuration * 100;
5153
}
5254

5355
if ($type === 'quiz') {
@@ -58,7 +60,7 @@ public function get(string $courseId): string
5860
[
5961
'id' => $row[0],
6062
'type' => $row[1],
61-
'duration' => $duration,
63+
'duration' => $stepDuration,
6264
'points' => $points
6365
],
6466
JSON_THROW_ON_ERROR

0 commit comments

Comments
(0)

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