# Resource Locker Overview
## **Purpose**
The Resource Locker module is designed to serve as a centralized repository for managing downloadable educational resources tied to specific courses or sessions. Its primary goal is to streamline the storage, organization, and distribution of these materials while ensuring secure access based on user permissions.
## **Benefits**
1. **Secure Access Control:** Ensures that only authorized users, such as enrolled students or session participants, can access specific resources, enhancing data security.
2. **Version Management:** Tracks different versions of files, allowing updates without disrupting current access and providing historical records for reference.
3. **Integration Capability:** Seamlessly integrates with Learning Management Systems (LMS), enabling direct linking of course materials from the LMS platform.
4. **Efficient Distribution:** Automates the delivery process, making it easy for users to download resources directly, thereby reducing manual effort and potential errors.
5. **Usage Tracking:** Logs access and download activities, offering insights into resource usage for monitoring and reporting purposes.
6. **Compliance Assurance:** Helps maintain regulatory compliance by controlling access to sensitive materials and tracking their distribution history.
## **Usage Scenarios**
1. **Course Material Management:** Instructors can upload and organize course syllabi, lecture notes, assignments, and supplementary materials within the Resource Locker, which are then linked to specific courses in the LMS.
2. **Session Files Handling:** Session-specific files such as presentation decks, meeting recordings, or handouts are stored and accessed by participants through their session enrollment details.
3. **User Downloads:** Students and participants can access course materials or session resources directly from the Resource Locker via login, ensuring they have necessary files for their studies.
4. **Regular Updates:** Facilitates easy updates of existing resources to correct errors, add new information, or replace outdated content without affecting current users' access.
5. **Audit and Compliance:** Institutions can audit resource usage to ensure compliance with internal policies and external regulations regarding data access and distribution.
6. **Team Collaboration:**structors and administrative staff can collaborate on managing resources, with role-based permissions ensuring appropriate access levels for each user.
7. **Offline Access Options:** Resources can be downloaded for offline use, benefiting users without consistent internet access or preferring offline work.
8. **Customizable Permissions:** Offers granular control over resource access, allowing tailored permissions based on user roles, courses, or specific sessions.
## **Key Features**
- Centralized storage and organization of educational resources.
- Role-based access control with customizable permissions.
- Versioning system for file updates and historical tracking.
- Integration APIs for seamless LMS integration.
- Logging and reporting tools for usage tracking and auditing.
- Secure file download options with optional offline access.
- User-friendly interface for easy navigation and resource retrieval.
This overview highlights the essential aspects of the Resource Locker module, detailing its purpose, benefits, and various usage scenarios to provide a comprehensive understanding of its functionality and value within an educational framework.
Resource Locker Module Documentation
1. Role-Based Access Control
The Resource Locker module enforces role-based access control, allowing only authorized users (e.g., instructors, students, or admins) to view, download, or manage resources based on predefined permissions.
- Explanation: Users are assigned roles that determine their level of access to resources. For example, instructors can upload and modify resources, while students can only view and download them.
2. Resource Management
Manages downloadable files, videos, PDFs, and other media types tied to specific courses or sessions.
- Explanation: Resources are stored in a centralized repository and can be organized by categories, tags, or metadata for easy retrieval.
3. Session-Based Access Control
Enforces time-bound access to resources based on course schedules or session availability.
- Explanation: Certain resources may only be accessible during specific periods (e.g., within the duration of a course or session). This ensures that sensitive materials are not available indefinitely.
4. Audit Logging
Tracks user activity and resource access for auditing purposes.
- Explanation: Every interaction with a resource (viewing, downloading) is logged, including timestamps, user IDs, and resource details. This helps in monitoring usage patterns and detecting unauthorized access.
5. Download Limits
Enforces download limits on resources to prevent overuse or misuse.
- Explanation: Administrators can set maximum allowed downloads for each resource. Once the limit is reached, the resource becomes unavailable unless reset.
6. Integration with External Storage
Supports integration with third-party storage solutions (e.g., AWS S3, Google Cloud Storage) for scalable and reliable resource hosting.
- Explanation: Resources can be stored in external cloud storage systems to handle high traffic and ensure redundancy. The module abstracts the complexity of storage management.
7. Cleanup Policy
Automatically removes unused or expired resources based on predefined rules (e.g., last accessed time, file size, or version).
- Explanation: This feature helps maintain disk space efficiency by periodically deleting obsolete resources according to configurable policies.
8. Version Control
Manages different versions of the same resource to allow users to access historical or updated content.
- Explanation: Instructors can upload new versions of resources, and older versions remain available for reference or download if enabled.
Resource Locker Module Documentation
The Resource Locker module provides functionality to manage downloadable resources tied to specific courses or sessions. Below is a breakdown of the implementation details, including an API endpoint, React UI snippet, and data schema.
1. FastAPI Endpoint (Resource Upload)
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security import OAuth2PasswordBearer
import os
from typing import Optional
from pydantic import BaseModel
router = APIRouter()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
class Resource(BaseModel):
title: str
description: str
resource_type: str # e.g., 'PDF', 'IMAGE', 'VIDEO'
file_size: int
upload_date: str
# Mock database storage (replace with actual DB)
resources = {}
async def get_current_user(token: str = Depends(oauth2_scheme)):
# Implement user authentication logic here
return {"username": "current-user"} # Replace with actual user retrieval
@router.post("/api/resources/upload", dependencies=[Depends(get_current_user)])
async def upload_resource(
file,
title: str,
description: Optional[str] = "",
resource_type: str = "PDF"
):
if not file:
raise HTTPException(status_code=400, detail="File is required")
# Validate resource type
allowed_types = ['PDF', 'IMAGE', 'VIDEO']
if resource_type not in allowed_types:
raise HTTPException(
status_code=400,
detail=f"Invalid resource type. Allowed types: {allowed_types}"
)
# Save file to storage
filename = os.path.join("uploads", file.filename)
with open(filename, "wb") as f:
f.write(await file.read())
resource_data = {
"title": title,
"description": description,
"resource_type": resource_type,
"file_size": file.size,
"upload_date": str(datetime.now())
}
resources[filename] = Resource(**resource_data)
return {"message": f"Resource '{title}' uploaded successfully"}
2. React UI (Resource Upload Form)
import React, { useState } from 'react';
import { useDropzone } from 'react-dropzone';
function ResourceUpload() {
const [selectedFile, setSelectedFile] = useState(null);
const [formData, setFormData] = useState({
title: '',
description: ''
});
const onDrop = (acceptedFiles) => {
setSelectedFile(acceptedFiles[0]);
};
const { getRootProps, getInputValue } = useDropzone({
onDrop,
accept: {
'image/*': ['.png', '.jpg', '.jpeg'],
'application/pdf': ['.pdf']
}
});
const handleSubmit = async (e) => {
e.preventDefault();
// Implement API call here
try {
// Replace with actual API endpoint and file upload logic
console.log('Uploading resource:', formData);
} catch (error) {
console.error('Upload failed:', error);
}
};
return (
<form onSubmit={handleSubmit}>
<div {...getRootProps()}>
<input {...getInputValue()} type="file" />
{selectedFile && (
<div>
Selected File: {selectedFile.name}
</div>
)}
</div>
<input
type="text"
placeholder="Resource Title"
value={formData.title}
onChange={(e) => setFormData({ ...formData, title: e.target.value })}
/>
<textarea
placeholder="Description"
value={formData.description}
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
/>
<select
name="resourceType"
value={formData.resource_type || 'PDF'}
onChange={(e) => setFormData({ ...formData, resource_type: e.target.value })}
>
<option value="PDF">PDF</option>
<option value="IMAGE">IMAGE</option>
<option value="VIDEO">VIDEO</option>
</select>
<button type="submit">Upload Resource</button>
</form>
);
}
export default ResourceUpload;
3. Pydantic Data Schema (Resource Model)
from pydantic import BaseModel
from datetime import datetime
class Resource(BaseModel):
id: str
title: str
description: Optional[str] = None
resource_type: Literal['PDF', 'IMAGE', 'VIDEO']
file_size: int
upload_date: datetime
file_path: str
class Config:
json_schema_extra = {
"example": {
"id": "64a3f2d8-7c0e-454e-b9c9-123abcde4567",
"title": "Sample Resource",
"description": "This is a sample resource for demonstration purposes.",
"resource_type": "PDF",
"file_size": 123456,
"upload_date": "2023-10-05T12:34:56Z",
"file_path": "/uploads/sample-resource.pdf"
}
}
Notes
- The FastAPI endpoint implements a basic resource upload functionality with authentication and validation.
- The React component provides a file upload form with drag-and-drop functionality using
react-dropzone
. - The Pydantic schema defines the structure of a resource, including an example for reference.
Resource Locker Module Documentation
Overview
The Resource Locker module provides functionality for managing downloadable resources tied to specific courses or sessions. It allows users to upload, manage, and access course materials securely.
Related Modules
- Course Management: Manages the creation, update, and deletion of courses.
- Session Management: Handles user session tracking and management.
- User Authentication: Provides authentication mechanisms for secure resource access.
- Content Delivery: Manages the distribution of digital content to users.
- Reporting Analytics: Tracks usage metrics for resources.
Use Cases
- Instructor Resource Upload: Instructors can upload course materials (PDFs, videos, etc.) directly or via a user interface.
- Student Resource Access: Students can download assigned resources based on their enrolled courses and permissions.
- Administrator Resource Management: Administrators can manage resource access rights across multiple courses.
- External Storage Integration: Supports integration with external storage solutions (e.g., AWS S3) for large-scale resource hosting.
- Resource Versioning: Allows instructors to upload multiple versions of the same resource and track changes.
Integration Tips
- Secure Credential Management:
- If using external storage (e.g., S3), store credentials securely in environment variables or a secret manager.
- Session-Based Access:
- Use session tokens to control access to resources during active sessions.
- Resource Validation:
- Implement checks for file types and sizes to prevent misuse.
- Cache Optimization:
- Cache frequently accessed resources to reduce server load and improve performance.
- Audit Logging:
- Log resource download attempts, including user IDs and timestamps, for auditing purposes.
Configuration Options
Option Name | Description | Default Value | Possible Values |
---|---|---|---|
enable_anonymous_access | Allow anonymous users to access resources? | false | true , false |
max_download_attempts | Maximum number of failed download attempts before blocking the user | 5 | Any non-negative integer |
resource_expiry_duration | Duration (in hours) after which a resource expires | 24 | Any positive integer |
file_format_restrictions | List of allowed file formats for upload and download | ['pdf', 'docx'] | Array of file extensions (e.g., [‘pdf’, ‘zip’]) |
storage_backend | Storage backend to use (local, s3, gcs) | 'local' | 'local' , 's3' , 'gcs' |
download_chunk_size | Size of chunks for streaming large files | 1024 | Any positive integer |
Conclusion
The Resource Locker module is a critical component for managing course materials and ensuring secure access. By integrating with related modules like Course Management and User Authentication, it provides a robust solution for educational platforms.