Package: courses
Generated from api/packages/courses
Source: api/packages/courses · imported version 0.4.45. The sections after the README are extracted from the code on every docs build.
README
Section titled “README”Courses and content package
What does it do
Section titled “What does it do”This package is used for creating Course for Ulams.
Installing
Section titled “Installing”composer require ulams/coursesphp artisan migratephp artisan db:seed --class="Ulams\Courses\Database\Seeders\CoursesPermissionSeeder"
Schedule
Section titled “Schedule”- Schedules are available in ScheduleServiceProvider
$schedule->job(CheckForDeadlines::class)->hourly()- executed every hours$schedule->job(ActivateCourseJob::class)->daily()- executed every days
Endpoints
Section titled “Endpoints”All the endpoints are defined in
Run ./vendor/bin/phpunit --filter 'Ulams\\Courses\\Tests' to run tests. See tests folder as it’s quite good staring point as documentation appendix.
Events
Section titled “Events”Ulams\Courses\Events\CourseAccessFinished=> Event is dispatched when users lost access to course.Ulams\Courses\Events\CourseAccessStarted=> Event is dispatched when users received access to course.Ulams\Courses\Events\CourseAssigned=> Event is dispatched when admin assigned access user.Ulams\Courses\Events\CourseDeadlineSoon=> Event is dispatched when course deadline is coming out.Ulams\Courses\Events\CoursedPublished=> Event is dispatched when course is published.Ulams\Courses\Events\CourseFinished=> Event is dispatched when course is ended.Ulams\Courses\Events\CourseStarted=> Event is dispatched when course is started.Ulams\Courses\Events\CourseStatusChanged=> Event is dispatched when course has a status change.Ulams\Courses\Events\CourseTutorAssigned=> Event is dispatched when tutor is assigned to course.Ulams\Courses\Events\CourseTutorUnassigned=> Event is dispatched when tutor is unassigned to course.Ulams\Courses\Events\CourseUnassigned=> Event is dispatched when user is unassigned to course.Ulams\Courses\Events\TopicFinished=> Event is dispatched when course topic is finished.
Permissions
Section titled “Permissions”Permissions are defined in seeder
Model relation
Section titled “Model relation”The model user must be extended with the class HasCourses :
class User extends Ulams\Core\Models\User{ use HasCourses;Database relation
Section titled “Database relation”There is simple relation. see docs for diagram
Coursegeneral category of the courseLessongrouped by CourseTopicgrouped by Lesson
Course 1 -> n LessonLesson 1 -> n TopicTopic 1 -> 1 TopicContentTopicContent is an abstract model, this package contains some sample implementatio eg, RichText, Audio, Video, H5P and Image
You create any of the Content model by post to the same Topic endponit (create and update), see docs examples
Note that /api/topics is using form-data - this is due to PHP nature of posting files
List of possible TopicContents is availabe in the endpoint /api/topics/types
Curriculum/Sylabus/Program
Section titled “Curriculum/Sylabus/Program”App user access the course by fetching GET /api/courses/{id}/program endpoint. This is after user purchase or has other access to the course. this endpoints renders tree of Course, Lessons, Topic with Contents essential to render whole course.
Adding new TopicContent type
Section titled “Adding new TopicContent type”In the ServiceProvider register your class like
use Illuminate\Support\ServiceProvider;use Ulams\Courses\Facades\Topic;
class CustomServiceProvider extends ServiceProvider{
//...
public function register() { Topic::registerContentClass(TopicContentCustom::class); // or Topic::registerContentClasses([TopicContentCustom::class, TopicAnotherContentCustom::class]);
// also register JSON Resource for a type Topic::registerResourceClasses(Audio::class, [ 'client' => ClientAudioResource::class, 'admin' => AdminAudioResource::class, 'export' => ExportAudioResource::class, ]);
}}see UlamsCourseServiceProvider.php as reference as well as Models/TopicContent
Content
Section titled “Content”Package comes with seeder that create course with lessons and topics
php artisan db:seed --class="\Ulams\Courses\Database\Seeders\CoursesSeeder"More documentation in the package
Section titled “More documentation in the package”API endpoints
Section titled “API endpoints”| Method | Path | Auth | Action |
|---|---|---|---|
GET |
/api/admin/courses/{course}/program |
yes | CourseAPIController@program |
POST |
/api/admin/courses/sort |
yes | CourseAPIController@sort |
POST |
/api/admin/courses/{course} |
yes | CourseAPIController@update |
GET |
/api/admin/courses |
yes | CourseAPIController@index |
GET |
/api/admin/courses/create |
yes | CourseAPIController@create |
POST |
/api/admin/courses |
yes | CourseAPIController@store |
GET |
/api/admin/courses/{id} |
yes | CourseAPIController@show |
GET |
/api/admin/courses/{id}/edit |
yes | CourseAPIController@edit |
PUT|PATCH |
/api/admin/courses/{id} |
yes | CourseAPIController@update |
DELETE |
/api/admin/courses/{id} |
yes | CourseAPIController@destroy |
GET |
/api/admin/lessons |
yes | LessonAPIController@index |
GET |
/api/admin/lessons/create |
yes | LessonAPIController@create |
POST |
/api/admin/lessons |
yes | LessonAPIController@store |
GET |
/api/admin/lessons/{id} |
yes | LessonAPIController@show |
GET |
/api/admin/lessons/{id}/edit |
yes | LessonAPIController@edit |
PUT|PATCH |
/api/admin/lessons/{id} |
yes | LessonAPIController@update |
DELETE |
/api/admin/lessons/{id} |
yes | LessonAPIController@destroy |
POST |
/api/admin/lessons/{id}/clone |
yes | LessonAPIController@clone |
GET |
/api/admin/topics/types |
yes | TopicAPIController@classes |
GET |
/api/admin/topics |
yes | TopicAPIController@index |
GET |
/api/admin/topics/create |
yes | TopicAPIController@create |
POST |
/api/admin/topics |
yes | TopicAPIController@store |
GET |
/api/admin/topics/{id} |
yes | TopicAPIController@show |
GET |
/api/admin/topics/{id}/edit |
yes | TopicAPIController@edit |
PUT|PATCH |
/api/admin/topics/{id} |
yes | TopicAPIController@update |
DELETE |
/api/admin/topics/{id} |
yes | TopicAPIController@destroy |
POST |
/api/admin/topics/{topic} |
yes | TopicAPIController@update |
POST |
/api/admin/topics/{id}/clone |
yes | TopicAPIController@clone |
GET |
/api/admin/topics/{topic_id}/resources |
yes | TopicResourcesAPIController@list |
POST |
/api/admin/topics/{topic_id}/resources |
yes | TopicResourcesAPIController@upload |
PATCH |
/api/admin/topics/{topic_id}/resources/{resource_id} |
yes | TopicResourcesAPIController@rename |
DELETE |
/api/admin/topics/{topic_id}/resources/{resource_id} |
yes | TopicResourcesAPIController@delete |
GET |
/api/admin/courses/search/tags |
yes | CourseAPIController@searchByTag |
GET |
/api/admin/courses/search/{category_id} |
yes | CourseAPIController@category |
GET |
/api/admin/courses/users/assignable |
yes | CourseAuthorsAPIController@assignableUsers |
POST |
/api/admin/tutors/{id}/assign/{course} |
yes | CourseAuthorsAPIController@assign |
POST |
/api/admin/tutors/{id}/unassign/{course} |
yes | CourseAuthorsAPIController@unassign |
GET |
/api/courses/{course}/program |
CourseAPIController@program |
|
GET |
/api/courses/{course}/preview/{topic_id} |
CourseAPIController@preview |
|
GET |
/api/courses/{course}/scorm |
yes | CourseAPIController@scorm |
GET |
/api/courses/progress/paginated |
yes | CourseProgressAPIController@indexPaginated |
GET |
/api/courses/progress |
yes | CourseProgressAPIController@index |
GET |
/api/courses/progress/{course_id} |
yes | CourseProgressAPIController@show |
PATCH |
/api/courses/progress/{course_id} |
yes | CourseProgressAPIController@store |
PUT |
/api/courses/progress/{topic_id}/ping |
yes | CourseProgressAPIController@ping |
POST |
/api/courses/progress/{topic_id}/h5p |
yes | CourseProgressAPIController@h5p |
GET |
/api/courses/authored |
yes | CourseAPIController@authoredCourses |
GET |
/api/courses |
CourseAPIController@index |
|
GET |
/api/courses/{course} |
CourseAPIController@show |
|
GET |
/api/tutors |
CourseAuthorsAPIController@index |
|
GET |
/api/tutors/{id} |
CourseAuthorsAPIController@show |
|
GET |
/api/tags/uniqueTags |
CourseAPIController@uniqueTags |
Permissions
Section titled “Permissions”| Permission | Seeded for roles | Constant |
|---|---|---|
course_list |
admin, tutor | CoursesPermissionsEnum::COURSE_LIST |
course_create |
admin, tutor | CoursesPermissionsEnum::COURSE_CREATE |
course_update |
admin | CoursesPermissionsEnum::COURSE_UPDATE |
course_delete |
admin | CoursesPermissionsEnum::COURSE_DELETE |
course_read |
admin | CoursesPermissionsEnum::COURSE_ATTEND |
course_update_authored |
admin, tutor | CoursesPermissionsEnum::COURSE_UPDATE_OWNED |
course_delete_authored |
admin, tutor | CoursesPermissionsEnum::COURSE_DELETE_OWNED |
course_read_authored |
admin, tutor | CoursesPermissionsEnum::COURSE_ATTEND_OWNED |
course_list_authored |
tutor | CoursesPermissionsEnum::COURSE_LIST_OWNED |
Settings
Section titled “Settings”Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).
| Key | Rules | Public | Read-only |
|---|---|---|---|
ulams_courses.platform_visibility |
required, string, in: . implode(,, PlatformVisibility::getValues()) | yes | |
ulams_courses.reminder_of_deadline_count_days |
integer, min: 1 | yes | |
ulams_courses.course_visibility |
required, string, in: . implode(,, CourseVisibilityEnum::getValues()) | yes |
Events
Section titled “Events”| Event | Description | Notification templates |
|---|---|---|
CourseAccessFinished |
||
CourseAccessStarted |
||
CourseAssigned |
||
CourseDeadlineSoon |
||
CourseFinished |
Email, Pdf | |
CourseStarted |
||
CourseStatusChanged |
||
CourseTutorAssigned |
||
CourseTutorUnassigned |
||
CourseUnassigned |
||
CoursedPublished |
||
LessonFinished |
||
TopicFinished |
Notification templates registered here
Section titled “Notification templates registered here”None.
Artisan commands
Section titled “Artisan commands”None.
Scheduled jobs
Section titled “Scheduled jobs”| Kind | Target | Frequency |
|---|---|---|
| job | CheckForDeadlines::class |
hourly() |
| job | ActivateCourseJob::class |
daily() |
Environment variables read
Section titled “Environment variables read”APP_DEBUG, AWS_ACCESS_KEY_ID, CACHE_BYPASS_HEADER_NAME, CACHE_BYPASS_HEADER_VALUE, RESPONSE_CACHE_DRIVER, RESPONSE_CACHE_ENABLED, RESPONSE_CACHE_LIFETIME, RESPONSE_CACHE_TAG, TOPIC_RESOURCE_FILES_MIMES