tourze / train-course-bundle
培训课程管理系统,提供课程创建、章节管理、学习进度跟踪等功能
Installs: 138
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/train-course-bundle
Requires
- php: ^8.1
- doctrine/collections: ^2.3
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- nesbot/carbon: ^2.72 || ^3
- psr/cache: ^1.0|^2.0|^3.0
- psr/log: ^3|^2|^1
- symfony/cache-contracts: ^3
- symfony/config: ^6.4
- symfony/console: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/doctrine-bridge: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-foundation: ^6.4
- symfony/http-kernel: ^6.4
- symfony/routing: ^6.4
- symfony/security-core: ^6.4
- symfony/serializer: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/aliyun-vod-bundle: 0.0.*
- tourze/arrayable: 0.0.*
- tourze/bundle-dependency: 0.0.*
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-snowflake-bundle: 0.1.*
- tourze/doctrine-track-bundle: 0.1.*
- tourze/doctrine-user-bundle: 0.0.*
- tourze/easy-admin-attribute: 0.1.*
- tourze/symfony-routing-auto-loader-bundle: 0.0.*
- tourze/train-category-bundle: 0.0.*
- tourze/weui-bundle: 0.0.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
- symfony/phpunit-bridge: ^6.4
This package is auto-updated.
Last update: 2025-11-03 16:12:36 UTC
README
Training course management bundle for safety production training course lifecycle management.
Table of Contents
- Features
- Installation
- Configuration
- Quick Start
- Available Commands
- Usage Examples
- Advanced Usage
- Dependencies
- Testing
- Security
- Contributing
- License
Features
- Course basic information management (title, description, cover, price, etc.)
- Course category association management
- Course chapter hierarchical structure management
- Multimedia content support (mainly videos)
- Alibaba Cloud VOD video integration and playback
- Course validity period management
- Credit hours statistics and management
- Teacher association management
- Course audit workflow management
- Video playback control (anti-fast-forward, speed limitation, watermark)
- Multi-device playback limitation
Installation
composer require tourze/train-course-bundle
Configuration
Basic Configuration
Configure Alibaba Cloud VOD related environment variables:
JOB_TRAINING_ALIYUN_VOD_ACCESS_KEY_ID=your_access_key_id JOB_TRAINING_ALIYUN_VOD_ACCESS_KEY_SECRET=your_access_key_secret
Bundle Configuration
Enable the bundle in your Symfony application:
// config/bundles.php return [ // ... Tourze\TrainCourseBundle\TrainCourseBundle::class => ['all' => true], ];
Quick Start
Creating a Course
<?php use Tourze\TrainCourseBundle\Entity\Course; use Tourze\TrainCourseBundle\Entity\Chapter; use Tourze\TrainCourseBundle\Entity\Video; // Create course $course = new Course(); $course->setTitle('Basic Knowledge of Safety Production'); $course->setDescription('This course introduces basic concepts and regulations of safety production'); $course->setPrice(99.00); $course->setValidDays(365); $course->setLearnHours(8); // Create chapter $chapter = new Chapter(); $chapter->setCourse($course); $chapter->setTitle('Chapter 1: Overview of Safety Production'); $chapter->setSort(1); // Create video $video = new Video(); $video->setChapter($chapter); $video->setTitle('1.1 Importance of Safety Production'); $video->setUrl('ali://xxxxx'); // Alibaba Cloud VOD video ID $video->setDuration(600); // 10 minutes
Getting Video Play URL
<?php use Tourze\TrainCourseBundle\Service\CourseService; // Inject service public function __construct(private CourseService $courseService) {} // Get video play URL from lesson $playUrl = $this->courseService->getLessonPlayUrl($lesson);
Available Commands
train-course:audit
Process course audit tasks with support for automatic approval and timeout detection.
php bin/console train-course:audit [options]
Options:
--dry-run- Dry run mode, only shows what would be processed without execution--auto-approve- Automatically approve qualified courses (requires configuration)
course:backup
Backup course data with support for full and incremental backups.
php bin/console course:backup [options]
Options:
--output- Backup file output path (default: var/backup/)--format- Backup format (json|sql, default: json)--incremental- Incremental backup mode
train-course:cleanup
Clean up expired course-related data and cache to maintain system performance.
php bin/console train-course:cleanup [options]
Options:
--dry-run- Dry run mode, only shows what would be cleaned--force- Force cleanup, skip confirmation prompt--days- Clean up data older than specified days (default: 30)
train-course:statistics
Generate course statistics reports including course count, evaluation statistics, and collection statistics.
php bin/console train-course:statistics [options]
Options:
--format- Output format (table|json|csv, default: table)--output- Output file path (optional)--period- Statistics period (day|week|month|year, default: month)
Usage Examples
Course Management
// Get course service $courseService = $this->get(CourseService::class); // Find course by ID $course = $courseService->findById($courseId); // Check if course is valid $isValid = $courseService->isCourseValid($course); // Get course total duration $totalDuration = $courseService->getCourseTotalDuration($course); // Get course progress for a user $progress = $courseService->getCourseProgress($course, $userId);
Video Playback Control
// Set up playback control $playControl = new CoursePlayControl(); $playControl->setCourse($course); $playControl->setAllowFastForward(false); $playControl->setAllowSpeedControl(true); $playControl->setWatermarkText('Training Course'); $playControl->setMaxDeviceCount(3); $entityManager->persist($playControl); $entityManager->flush();
Advanced Usage
Course Analytics Integration
// Get comprehensive course analytics report $courseAnalytics = $this->get(CourseAnalyticsService::class); // Get analytics report for a specific course $analyticsReport = $courseAnalytics->getCourseAnalyticsReport($course); // Get course rankings with criteria $rankings = $courseAnalytics->getCourseRankings([ 'category' => $categoryId, 'limit' => 10 ]);
Course Configuration Management
// Get course configuration service $configService = $this->get(CourseConfigService::class); // Get video cache time $cacheTime = $configService->getVideoPlayUrlCacheTime(); // Check if a feature is enabled $isEnabled = $configService->isFeatureEnabled('video_watermark'); // Get all configuration $allConfig = $configService->getAllConfig();
Dependencies
This bundle requires the following Symfony components and third-party packages:
Core Dependencies
symfony/framework-bundle: ^7.3doctrine/orm: ^3.0doctrine/doctrine-bundle: ^2.13nesbot/carbon: ^2.72 || ^3
Internal Dependencies
tourze/aliyun-vod-bundle: For Alibaba Cloud VOD integrationtourze/doctrine-snowflake-bundle: For unique ID generationtourze/doctrine-user-bundle: For user management integrationtourze/doctrine-track-bundle: For entity trackingtourze/train-category-bundle: For course category management
Additional Dependencies
tourze/enum-extra: For enhanced enum functionalitytourze/doctrine-helper: For Doctrine utilities
Testing
Run the test suite:
# Run all tests vendor/bin/phpunit packages/train-course-bundle/tests # Run specific test vendor/bin/phpunit packages/train-course-bundle/tests/Entity/CourseTest.php # Run with coverage vendor/bin/phpunit packages/train-course-bundle/tests --coverage-html coverage
Security
Security Considerations
- Video Access Control: Always verify user permissions before generating video play URLs
- Data Validation: All entity properties are protected with validation constraints
- Input Sanitization: User input is automatically sanitized through Symfony validation
Reporting Security Issues
If you discover a security vulnerability, please send an email to security@tourze.com. All security vulnerabilities will be promptly addressed.
Access Control
// Example: Check user access to course if (!$this->courseService->hasAccess($user, $course)) { throw new AccessDeniedException('User does not have access to this course'); }
Important Notes
- This bundle focuses on course content management and does not include learning management, user management, or evaluation management features
- Alibaba Cloud VOD functionality requires proper access key configuration
- It's recommended to use STS temporary credentials instead of fixed AccessKey in production environments
- For learning management features, please use other dedicated learning management bundles
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see License File for more information.