Code Monkey home page Code Monkey logo

chukaibejih / smart_learn Goto Github PK

View Code? Open in Web Editor NEW
25.0 3.0 18.0 1.38 MB

This is an API for a Smart Learning project built with Django Rest Framework (DRF). The API allows users to enroll in courses, complete lessons and quizzes, and track their progress. Instructors can create and manage courses, lessons, and quizzes, as well as view information about enrolled users.

Home Page: https://smart-learn.onrender.com

License: MIT License

Python 98.62% HTML 0.76% Shell 0.62%
django django-rest-framework education rest-api good-first-issue open-source python hacktoberfest hacktoberfest-accepted

smart_learn's Introduction

Smart Learning(Work In Progress)

This Smart Learning API is built with Django Rest Framework (DRF) and provides a powerful set of features for both users and instructors. With this API, users can enroll in courses, and complete modules, lessons and quizzes. Instructors can create and manage courses, modules, lessons, and quizzes, as well as view information about enrolled users.

This Smart Learning API is designed to be flexible and easy to use. Using Swagger/OpenAPI to provide you with a clean and intuitive API interface that makes it easy for developers to integrate with other systems. Whether you're building a mobile app, a web-based learning platform, or something else entirely.

System Architecture

service diagram drawio (2)

ER Diagram

Smart Learn (2)

link: https://dbdiagram.io/d/64087c2f296d97641d865ec8

Getting Started

To run the API locally, follow these steps:

  1. Clone the repository: git clone https://github.com/yourusername/smart-learning-api.git
  2. Create a virtual environment: python -m venv venv
  3. Activate the virtual environment: source venv/bin/activate
  4. Install dependencies: pip install -r requirements.txt
  5. Go to .settings.DATABASES section, deactivate #PRODUCTION mode and activate #Development mode, add PostgreSQL configuration to connect to your database to be the default database.
  6. Change .env.templates to .env and setup your environment variables.
  7. Set up the database: python manage.py migrate
  8. Create a superuser account: python manage.py createsuperuser
  9. Start the development server: python manage.py runserver

To run the API locally, with Docker and Docker Compose, follow these steps:

  1. Go to .settings.DATABASES section, deactivate #PRODUCTION mode and activate #Development mode, add PostgreSQL configuration to connect to your database to be the default database.
  2. Change .env.templates to .env and setup your environment variables.
  3. Start application and database integration: sudo docker compose -f docker-compose.yaml up --build
  4. Stop and clear integration: sudo docker compose -f docker-compose.yaml down

Running Tests

Tests are organized into different files within the app's tests directory. Here's how to run them:

  1. To run all the tests, use the following command:

    python manage.py test
    
  2. To run a single test file, you can use the following command (replacing <app_name> and <test_file> with the appropriate values):

    python manage.py test <app_name>.tests.<test_file>
    

Functional Requirements Definition

Functional requirements specify the actions that a software system or application should take to satisfy the user's needs and business objectives. They describe the system's functions, features, and capabilities, as well as how it should respond under different circumstances.

  • User Authentication: The API should provide a user registraion, log-in and email confimation functionality, including password recovery features. We’ll ensure that passwords are securely stored and hashed using Django’s built-in authentication system.

  • Profile Management: Users should be able to manage and update their profile information, including profile pictures.

  • Course Enrollment: The API should allow users to enroll in courses.

  • Instructor Course Creation: Instructors should be able to create new courses, add modules, lessons, and quizzes to them using the API.

  • Instructor Course Management: Instructors should be able to manage their courses, including editing or deleting course content, modules, lessons, and quizzes using the API.

  • Payment: Users should be able to make course payments through the API after enrolling.

Tech Stack

  • Language: Python 3.10
  • Framework: Django 4.0+
  • Database: PostgreSQL
  • API USED: Strip - Test mode
  • Testing: Django Test Framework
  • Test Coverage: 80%+
  • Development Methodology: TDD (Test Driven Development)

Authentication

Authentication is required for most endpoints in the API. To authenticate, include an access token in the Authorization header of your request. The access token can be obtained by logging in to your account or registering a new account.

API Endpoints

The following endpoints are available in the API:

Authentication Endpoints

  • /api/auth/register/ (POST): to allow users to register for an account.
  • /api/auth/login/ (POST): to allow users to log in to their account.
  • /api/auth/logout/ (POST): to allow users to log out of their account.
  • /api/auth/smscode/ (POST): to allow users verfiy SMS verfication code

User Profile Endpoints

  • /api/users/ (GET): to retrieve a list of all registered users.
  • /api/users/<user_id>/ (GET, PUT, PATCH, DELETE): to retrieve, update, partially update or delete a specific user's profile.

Course Endpoints

  • /api/courses/ (GET): to retrieve a list of all available courses.
  • /api/courses/<course_id>/ (GET): to retrieve information about a specific course.
  • /api/courses/<course_id>/enroll/ (POST): to allow a user to enroll in a specific course.

Lesson Endpoints

  • /api/courses/<course_id>/lessons/ (GET): to retrieve a list of all lessons in a specific course.
  • /api/courses/<course_id>/lessons/<lesson_id>/ (GET): to retrieve information about a specific lesson.
  • /api/courses/<course_id>/lessons/<lesson_id>/progress/ (POST): to update a user's progress in a specific lesson.

Quiz Endpoints

  • /api/courses/<course_id>/lessons/<lesson_id>/quizzes/ (GET): to retrieve a list of all quizzes in a specific lesson.
  • /api/courses/<course_id>/lessons/<lesson_id>/quizzes/<quiz_id>/ (GET): to retrieve information about a specific quiz.
  • /api/courses/<course_id>/lessons/<lesson_id>/quizzes/<quiz_id>/submit/ (POST): to allow a user to submit answers for a specific quiz.

Instructor Endpoints

  • /api/instructors/ (GET): to retrieve a list of all registered instructors.
  • /api/instructors/<instructor_id>/ (GET, PUT, PATCH, DELETE): to retrieve, update, partially update or delete a specific instructor's profile.
  • /api/courses/ (POST): to allow an instructor to create a new course.
  • /api/courses/<course_id>/ (PUT, PATCH, DELETE): to allow an instructor to update or delete a specific course.
  • /api/courses/<course_id>/lessons/ (POST): to allow an instructor to create a new lesson within a specific course.
  • /api/courses/<course_id>/lessons/<lesson_id>/ (PUT, PATCH, DELETE): to allow an instructor to update or delete a specific lesson within a course.
  • /api/courses/<course_id>/lessons/<lesson_id>/quizzes/ (POST): to allow an instructor to create a new quiz within a specific lesson.
  • /api/courses/<course_id>/lessons/<lesson_id>/quizzes/<quiz_id>/ (PUT, PATCH, DELETE): to allow an instructor to update or delete a specific quiz within a lesson.
  • /api/courses/<course_id>/enrollments/ (GET): to retrieve a list of all users

Limitations

While the Smart Learning API is designed to be a flexible and powerful tool for users and instructors alike, there are some limitations to consider when using this system:

  • Lack of support for multimedia content: At the moment, the API does not support multimedia content such as videos, images or audio files. This can limit the types of courses that can be offered through the platform.
  • Limited payment options: Currently, the only payment option available for users is through the Stripe API. This may not be ideal for some users who prefer to use other payment methods.
  • No support for multiple languages: The API currently only supports content in English. This may be a limitation for users who prefer to learn in other languages.
  • Limited reporting and analytics: While the API provides some basic reporting and analytics features, these may not be sufficient for more advanced reporting needs.
  • Limited customization options: The API provides a basic set of features and customization options, but may not be ideal for users who require a highly customized learning platform.

Contributing

Contributions to this project are welcome! Go through our GUIDELINES

License

This project is licensed under the MIT License - see the LICENSE file for details.

smart_learn's People

Contributors

chukaibejih avatar kerry407 avatar taskmasterernest avatar mayals avatar benji918 avatar easonliao1994 avatar lastuchiha avatar tholkappiar avatar vbello-tech avatar devsylva avatar akshayapujitha avatar

Stargazers

Pragnya Raj Errolla avatar  avatar  avatar GQ avatar  avatar Olaniyi George avatar Rahul Salgare avatar Joseph Miracle avatar David Audu avatar Pwaveino Clarkson avatar Onyedikachi Ibejih avatar  avatar  avatar Idris Olubisi avatar Abah Olotuche Gabriel avatar Usama Alzomor avatar  avatar  avatar Jason Jiménez Cruz avatar Oluseun Oladiipo avatar  avatar  avatar Samuel Ayano avatar  avatar Peter Ade-Ojo avatar

Watchers

GQ avatar  avatar JohnCarlS avatar

smart_learn's Issues

Add Support for Multimedia Content

Currently, the API does not support multimedia content such as videos, images, or audio files. It would be great to enhance the API to handle and serve multimedia content for a richer learning experience.

Add Contribution Guidelines

Include clear contribution guidelines in the project's documentation to provide guidance to potential contributors. This will encourage collaboration and streamline the process of accepting contributions.

Add Endpoint to Retrieve Enrolled Users

Currently, the API lacks an endpoint to retrieve information about users who have enrolled in a course. This functionality is important for instructors to track and manage their course enrollments effectively. We need to add an API endpoint that allows instructors to view the list of enrolled users for a specific course.

The new endpoint should provide instructors with essential details about each enrolled user, such as their username, email address, enrollment date, and progress within the course. This information will enable instructors to monitor the course's popularity, track user engagement, and tailor their teaching strategies accordingly.

It would be helpful to include filtering and pagination options in the endpoint to handle large numbers of enrolled users efficiently. Instructors should be able to filter users based on criteria such as enrollment date, completion status, or quiz scores.

Improving user data organization with separate profile models

To better organize user data, I suggest creating separate profile models for each user type.

Upon registration, the user would specify their role as a student or instructor using a Boolean field called "is_instructor". Then, using Django signals, the system can automatically create the appropriate profile model for the user.

I believe this change would make the project more user-friendly and efficient

Requirements.txt

Did you update requirements.txt file after creating the stripe payment?

Request to Add PageNumberPagination to UserViewSet API

I would like to request the addition of PageNumberPagination to the UserViewSet API in order to improve the pagination of user data.

Currently, the API returns all users in a single response, which may lead to performance issues when the number of users is large. By incorporating PageNumberPagination, we can limit the number of users returned per page and provide pagination links for easier navigation through the user data.

I propose the following changes to the UserViewSet:

from rest_framework.pagination import PageNumberPagination
class UserViewSet(AutoPrefetchViewSetMixin, viewsets.ModelViewSet):
    # ...

    # Set the pagination class and page_size
    pagination_class = PageNumberPagination
    page_size = 20
    
    # ...

By implementing pagination, we can enhance the API's performance and provide a more user-friendly experience when dealing with a large number of users.

I appreciate your consideration of this feature request. Please let me know if you have any questions or if there is any additional information I can provide to support this proposal.

Thank you!

No .env file example in project

No .env file example
Not have an example of what a typical developer should have in his/her .env file for this project in neither the repo or the readme file makes contributing to your work alot harder.
I applead to you to please fix this🤲

Expand Payment Options

While the API supports payment through the Stripe API, it would be beneficial to include additional payment options to accommodate users who prefer alternative payment methods.

Update ER diagram

Add field “average_rating” as float field in Course model in ER diagram

Add Celery for Background Task Processing

As the project grows and handles more complex tasks, it would be beneficial to incorporate Celery into the system for efficient and scalable background task processing. Celery is a powerful distributed task queue that will enable the API to handle asynchronous tasks, such as sending emails, processing large data uploads, or performing resource-intensive operations in the background.

By introducing Celery, we can improve the overall performance and responsiveness of the Smart Learning API. Tasks that may take longer to complete, such as generating reports or processing large datasets, can be offloaded to background workers, preventing delays or timeouts in the API's responses.

Some potential use cases for Celery integration include:

  • Asynchronous email sending: Instead of blocking the API's response while sending emails, we can utilize Celery to handle email sending asynchronously, ensuring a smooth user experience.
  • Background data processing: Celery can be used to process large data uploads, perform complex computations, or generate reports in the background without affecting the API's responsiveness.
  • Scheduled tasks: We can leverage Celery's scheduling capabilities to automate periodic tasks, such as sending reminders or updating course data.

Integrating Celery into the project will require configuring a message broker, such as RabbitMQ or Redis, and setting up worker processes to handle the tasks. The implementation should also consider error handling, task monitoring, and potential security implications.

No Review in ER Diagram

The Review field in Course which is int doesn't have a model in the ER diagram. We should create One.
{
"user": user__uuid,
"review_body": varchar,
"rating": int,
"course": course__uuid
}

Request for Chat/Messaging Feature

Requesting the addition of a chat/messaging feature to enhance the functionality of the Smart Learning API. The feature would enable users and instructors to communicate with each other within the platform, facilitating better collaboration and support.

Implementing a chat/messaging feature would provide the following benefits:

  • Improved User Engagement: Users and instructors can easily communicate and exchange information, fostering a more interactive learning experience.

  • Real-time Support: Users can seek assistance from instructors and receive prompt responses, enhancing their learning progress.

  • Seamless Collaboration: Instructors can efficiently interact with enrolled users, addressing questions, providing feedback, and facilitating discussions.

Implement Custom User Model for Better User Management

Hello everyone,

I want to implement a custom user model for better user management in our project. This will allow us more control over the user model and add additional fields and functionality as needed.

Currently, we are using the default Django user model, which can be limiting for our specific use case. By implementing a custom user model, we can have a more tailored one that meets our project requirements.

Confusion regarding URL structure for accessing specific Resources in the API

How do we find resources on the API? For example, every course has one or more modules, and each module has one or more lessons. That means if we're trying to access a particular lesson, the URL should be something like this: course/module/lesson/{id}/. However, when I look at our project setup, I'm confused about how to resolve this issue.

Suggestion to create a new endpoint that will be the details of a user but with only public details

The profile page is the personal page that viewed only by the request user (the owner of this page) because it might contain Personal and sensitive information about himself, so only this user has the full permission to view and partial update of his own data.
By the other hand, some information in this profile page might have considered as a public information of this user, so the idea of Suggestion is to create a new endpoint that will be the details of a user but with only public profile information,this endpoint can retrieve by(user_id).

Unable to pass tests - Missing dependencies?

I encountered an issue while running the tests. Unfortunately, the tests are not passing for me. I wanted to reach out to inquire if there are any missing dependencies or additional setup steps required to run the tests successfully.

File "/Users/eason/Desktop/github/smart_learn/user_service/serializers.py", line 74, in validate
    data = super().validate(attrs)
  File "/Users/eason/Desktop/github/smart_learn/venv/lib/python3.9/site-packages/rest_framework_simplejwt/serializers.py", line 72, in validate
    data["refresh"] = str(refresh)
  File "/Users/eason/Desktop/github/smart_learn/venv/lib/python3.9/site-packages/rest_framework_simplejwt/tokens.py", line 81, in __str__
    return self.get_token_backend().encode(self.payload)
  File "/Users/eason/Desktop/github/smart_learn/venv/lib/python3.9/site-packages/rest_framework_simplejwt/backends.py", line 113, in encode
    token = jwt.encode(
  File "/Users/eason/Desktop/github/smart_learn/venv/lib/python3.9/site-packages/jwt/api_jwt.py", line 67, in encode
    return api_jws.encode(json_payload, key, algorithm, headers, json_encoder)
  File "/Users/eason/Desktop/github/smart_learn/venv/lib/python3.9/site-packages/jwt/api_jws.py", line 153, in encode
    key = alg_obj.prepare_key(key)
  File "/Users/eason/Desktop/github/smart_learn/venv/lib/python3.9/site-packages/jwt/algorithms.py", line 186, in prepare_key
    key = force_bytes(key)
  File "/Users/eason/Desktop/github/smart_learn/venv/lib/python3.9/site-packages/jwt/utils.py", line 22, in force_bytes
    raise TypeError("Expected a string value")
TypeError: Expected a string value

Any assistance or suggestions would be greatly appreciated. Thank you for your time and support!

Move InstructorSkill and SkillCertification views to user_service app

I noticed that the views for creating, listing, updating, and deleting InstructorSkill and SkillCertification objects are currently located in the course_service.views module, but these objects are associated with user profiles and therefore should be managed by the user_service app instead.

I recommend moving the following views to the user_service.views module and its related URL :

  • InstructorSkillCreateView
  • InstructorSkillListView
  • InstructorSkillDetailView
  • SkillCertificationCreateView
  • SkillCertificationListView
  • SkillCertificationDetailView

By moving these views to the appropriate app, we can improve the organization and maintainability of the project. Additionally, this will ensure that user-related objects are managed in the correct place, which can prevent confusion and errors down the line.

Advanced Reporting and Analytics

Improve the reporting and analytics features of the API to provide more comprehensive and detailed insights into user progress, course performance, and other relevant metrics.

Multilingual Support

Extend the API's capabilities to support multiple languages, allowing users to access course content and interact with the platform in languages other than English.

Implement User Registration, Login/Logout, and Password Management Functionality

I would like to suggest implementing user registration, login, and password management functionality in our project. These features are essential for any web application that requires user authentication and will provide a better user experience for our users.

Specifically, I suggest implementing the following functionality:

  1. User registration with activation: This will enable new users to create an account and activate it via a confirmation email.
  2. Login/Logout: This will enable users to securely log into our application.
  3. Retrieve/Update the Django User model: This will allow users to view and edit their profile information.
  4. Password change: This will enable users to change their password within the application.
  5. Password reset via email: This will allow users to reset their password if they forget it by sending a password reset email.

Separate test files for course_service app

Currently, all of the tests for course_service app are in a single file. This is starting to become difficult to manage as the project grows in size and complexity. I would like to separate the test files into separate files for each module or feature. This would make it easier to find and modify tests, and would also make it easier to understand the test coverage for each module or feature.

I propose creating a new directory called "tests" inside the app directory and then creating separate Python files for each module or feature, with the tests for that module or feature contained within. This would allow us to organize tests more effectively and make them easier to manage.

Improve Test Coverage

Increase the test coverage of the API by writing additional test cases to ensure that all endpoints, models, and critical functionality are thoroughly tested. This will help maintain code quality and reduce the likelihood of introducing bugs in future development.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.