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