Skip to content

Commit

Permalink
Updated statements & views & composer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
lamoud committed Dec 31, 2023
1 parent d2a23e7 commit 144483e
Show file tree
Hide file tree
Showing 15 changed files with 1,206 additions and 35 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
],
"require": {
"guzzlehttp/guzzle": "^7.2 || ^7.8",
"php": "^7.4 || ^8.0"
"php": "^7.4 || ^8.0",
"jenssegers/agent": "^2.6"
},
"require-dev": {

Expand Down
199 changes: 198 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

167 changes: 156 additions & 11 deletions src/Controllers/LamoudNelcXapiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,164 @@ public function getIndex(Request $request)
public function postIndex(Request $request)
{

$request->validate([
'xapi_statement' => ['required', 'string', 'in:registered,initialized,watched,completed_lesson,completed_unit,progressed,attempted,completed_course,earned,rated']
]);

$xapi = new XapiIntegration();

$response = $xapi->Registered(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123', // Course Id OR url Or slug
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);

return redirect()->back()->with('success', $response);
switch ( $request->xapi_statement )
{
case "registered":
$response = $xapi->Registered(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123', // Course Id OR url Or slug
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
break;
case "initialized":
$response = $xapi->Initialized(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123', // Course Id OR url Or slug
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
break;
case "watched":
$response = $xapi->Watched(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'/url/to/lesson',
'Lesson title',
'Lesson description',
true, // is lesson completed
'PT15M', // watching duration
'123',
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email

);
break;
case "completed_lesson":
$response = $xapi->CompletedLesson(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'/url/to/lesson',
'Lesson title',
'Lesson description',
'123',
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
break;
case "completed_unit":
$response = $xapi->CompletedUnit(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'/url/to/unit',
'Unit title',
'Unit description',
'123',
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
break;
case "progressed":
$response = $xapi->Progressed(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123',
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
0.5,
true
);
break;
case "attempted":
$response = $xapi->Attempted(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'/path/to/quiz',
'Quiz title',
'Quiz description',
1, // attempt Number
'123',
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
0.5, // scaled
30, // raw
25, // min
50, // max
true,
true
);
break;
case "completed_course":
$response = $xapi->CompletedCourse(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123',
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
break;
case "earned":
$response = $xapi->Earned(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'path/to/cert',
'cert name',
'123',
'New Course',
'New Course description',
);
break;
case "rated":
$response = $xapi->Rated(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123',
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
0.8,
5,
'Thank you'
);
break;
default:
$response = $xapi->Registered(
'123456789', // Student National ID
'betalamoud@gmail.com', // Student Email
'123', // Course Id OR url Or slug
'New Course',
'New Course description',
'MR Hassan', // instructor Name
'mrhassan@mail.com', // instructor Email
);
}

return redirect()->back()->with(['success'=> $response, 'st'=> $request->xapi_statement]);
}

}
Loading

0 comments on commit 144483e

Please sign in to comment.