5 |
Posts in {{ category.name }}
6 |
← Back to Categories
7 |
8 | {% if user.is_authenticated %}
9 |
10 |
Create New Post
11 |
12 |
32 |
33 | {% endif %}
34 |
35 | {% for post in page_obj %}
36 |
37 |
38 |
39 |
{{ post.title }}
40 |
41 |
Votes: {{ post.total_votes|default:0 }}
42 |
43 |
44 | {% empty %}
45 |
No posts available in this category.
46 | {% endfor %}
47 |
48 |
49 |
50 | {% if page_obj.has_previous %}
51 |
<<
52 |
<
53 | {% endif %}
54 |
55 |
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
56 |
57 | {% if page_obj.has_next %}
58 |
>
59 |
>>
60 | {% endif %}
61 |
62 |
63 | {% endblock %}
64 |
--------------------------------------------------------------------------------
/Algolyzer/home/templates/home/onboarding.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 | /Algolyzer.git
13 | cd Algolyzer
14 | ```
15 | ## Setup project
16 | [Setup for Development](./setup_development.md)
17 |
18 | ## Creating a Feature Branch
19 |
20 | 1. Create and Switch to a New Branch
21 | - Name your branch based on the contribution, e.g., feature_authentication or fix_bug_123:
22 |
23 | ```bash
24 | git checkout -b feature_branch_name
25 | ```
26 |
27 | 2. Make Your Changes
28 | - Implement the feature, fix bugs, or update the documentation. Ensure your code adheres to the project's style and standards.
29 |
30 | # Contributing for Quiz Data
31 | 1. Goto `localhost:8000/admin` and login using your **superuser** credentials.
32 | 2. Add your Topics and Questions in the `Topics` & `Questions` models under the `Quiz` tab.
33 | 3. Open the terminal and run
34 | ```bash
35 | python manage.py dump_quiz
36 | ```
37 |
38 |
39 | ## Running Quality Checks
40 |
41 | 1. Format the Code
42 | - Run the provided script to ensure consistent formatting:
43 |
44 | ```bash
45 | ./run_qa_format
46 | ```
47 |
48 | 2. Run Tests
49 | - Navigate to the project directory and execute the test suite:
50 |
51 | ```bash
52 | python manage.py test
53 | ```
54 |
55 | ## Committing and Pushing Changes
56 |
57 | 1. Stage and Commit Changes
58 | - Add your changes and commit them with a descriptive message:
59 |
60 | ```bash
61 | git add .
62 | git commit -m "Add detailed commit message here"
63 | ```
64 | 2. Pre-Commit Hook
65 | - Note that a pre-commit hook will automatically run upon committing. If it fails, resolve the issues and commit again.
66 |
67 | 3. Push Your Branch
68 | - Push your branch to your forked repository:
69 |
70 | ```bash
71 | git push origin feature_branch_name
72 | ```
73 |
74 | ## Create an issue on GitHub
75 |
76 | 1. Before creating a pull request, create an issue on the [original repository](https://github.com/Priyanshu-Batham/Algolyzer/issues)
77 | 2. Remember to include as much information about your addition or fix.
78 | 3. Use appropriate labels for the issue.
79 | 4. Mention the maintainer for attention.
80 | 5. Patiently wait.
81 | 6. After maintainer approval, move on to open a pull request.
82 |
83 | ## Creating a Pull Request (PR)
84 | 1. Open a PR
85 | - Navigate to the original repository and open a PR from your branch.
86 | - Use a descriptive title and message, and reference any related issues (e.g., Fixes #issue_number).
87 | - Mention the Pull Request and
88 |
89 | 2. Address CI Pipeline Failures
90 | - If the PR fails the CI pipeline, review the logs, rectify the issues, and push the changes again.
91 |
92 | 3. Await Review
93 | - Be patient while the maintainers review your PR. Respond to feedback and make the required changes if needed.
94 |
95 | 4. Merge
96 | - Once approved, your PR will be merged into the main branch.
97 |
98 | ## Cleaning Up
99 |
100 | - After a successful merge, you can clean up your local repository:
101 |
102 | ```bash
103 | git branch -D feature_branch_name
104 | git fetch --prune
105 | ```
106 |
107 | ## Additional Tips
108 |
109 | - Modify the last commit if you need to make minor changes without creating a new commit.
110 |
111 | ```bash
112 | git commit --amend
113 | ```
114 |
115 | - Regularly sync your fork with the upstream repository:
116 |
117 | ```bash
118 | git fetch upstream
119 | git merge upstream/main
120 | ```
--------------------------------------------------------------------------------
/Algolyzer/study/templates/study/doodle_classifier.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 | A Beginner's Guide to Doodle Classification
7 |
8 |
9 |
Introduction
10 |
11 | Doodle classification is a type of image classification that predicts which number (0-9) was drawn by a user.
12 | This is done using a deep learning model trained on the MNIST dataset—a famous dataset of handwritten digits.
13 |
14 |
15 | In this project, we're using a pre-trained model from Hugging Face called farleyknight/mnist-digit-classification-2022-09-04,
16 | which is specifically trained to recognize digits from rough sketches or "doodles."
17 |
18 |
19 |
How Does It Work?
20 |
21 | The user draws a digit on a canvas in the browser.
22 | The drawing is converted to a base64 PNG image.
23 | This image is sent to the server and saved temporarily.
24 | The image is passed through a deep learning model.
25 | The model outputs the most likely digit with a confidence score.
26 |
27 |
28 |
Step-by-Step Breakdown
29 |
30 |
Step 1: Capture the Drawing
31 |
32 | We use an HTML canvas where users draw their digit. The drawing is captured as a base64-encoded image string.
33 |
34 |
35 |
36 |
image_data = request.POST.get("image_data")
37 |
38 |
39 |
Step 2: Save the Drawing as an Image
40 |
41 | The base64 string is decoded and saved as a PNG image, so that it can be read like a normal image file.
42 |
43 |
44 |
45 |
format, imgstr = image_data.split(";base64,")
46 | ext = format.split("/")[-1]
47 | image_file = ContentFile(base64.b64decode(imgstr), name=f"doodle.{ext}")
48 |
49 |
50 |
Step 3: Run the Image through the Classifier
51 |
52 | The image is passed into a pre-trained model that analyzes the pixel patterns and predicts which digit was drawn.
53 |
54 |
55 |
56 |
image = Image.open(task.input_image.path)
57 | result = mnist_classifier(image)
58 |
59 |
60 |
Step 4: Get the Best Prediction
61 |
62 | The model returns a list of possible digits with scores. We choose the one with the highest score.
63 |
64 |
65 |
66 |
best_prediction = max(result, key=lambda x: x["score"])
67 | best_label = best_prediction["label"]
68 |
69 |
70 |
Why This Model?
71 |
72 | ✅ Trained on real-world digit images from the MNIST dataset.
73 | ✅ Fast and lightweight — ideal for web apps and educational tools.
74 | ✅ Easy to integrate using Hugging Face’s pipeline interface.
75 |
76 |
77 |
Try Drawing!
78 |
79 | Head over to the classifier page and draw a number to see the magic happen in real-time! 🎨
80 |
81 |
82 | {% endblock %}
83 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | share/python-wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | MANIFEST
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .nox/
43 | .coverage
44 | .coverage.*
45 | .cache
46 | nosetests.xml
47 | coverage.xml
48 | *.cover
49 | *.py,cover
50 | .hypothesis/
51 | .pytest_cache/
52 | cover/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | .pybuilder/
76 | target/
77 |
78 | # Jupyter Notebook
79 | .ipynb_checkpoints
80 |
81 | # IPython
82 | profile_default/
83 | ipython_config.py
84 |
85 | # pyenv
86 | # For a library or package, you might want to ignore these files since the code is
87 | # intended to run in multiple environments; otherwise, check them in:
88 | # .python-version
89 |
90 | # pipenv
91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
94 | # install all needed dependencies.
95 | #Pipfile.lock
96 |
97 | # UV
98 | # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99 | # This is especially recommended for binary packages to ensure reproducibility, and is more
100 | # commonly ignored for libraries.
101 | #uv.lock
102 |
103 | # poetry
104 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105 | # This is especially recommended for binary packages to ensure reproducibility, and is more
106 | # commonly ignored for libraries.
107 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108 | #poetry.lock
109 |
110 | # pdm
111 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112 | #pdm.lock
113 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114 | # in version control.
115 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116 | .pdm.toml
117 | .pdm-python
118 | .pdm-build/
119 |
120 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121 | __pypackages__/
122 |
123 | # Celery stuff
124 | celerybeat-schedule
125 | celerybeat.pid
126 |
127 | # SageMath parsed files
128 | *.sage.py
129 |
130 | # Environments
131 | .env
132 | .venv
133 | env/
134 | venv/
135 | ENV/
136 | env.bak/
137 | venv.bak/
138 |
139 | # Spyder project settings
140 | .spyderproject
141 | .spyproject
142 |
143 | # Rope project settings
144 | .ropeproject
145 |
146 | # mkdocs documentation
147 | /site
148 |
149 | # mypy
150 | .mypy_cache/
151 | .dmypy.json
152 | dmypy.json
153 |
154 | # Pyre type checker
155 | .pyre/
156 |
157 | # pytype static type analyzer
158 | .pytype/
159 |
160 | # Cython debug symbols
161 | cython_debug/
162 |
163 | # PyCharm
164 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166 | # and can be added to the global gitignore or merged into this file. For a more nuclear
167 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168 | .idea/
169 |
170 | # For vscode users
171 | .vscode/
172 |
173 | # PyPI configuration file
174 | .pypirc
175 |
176 | # Node.js
177 | node_modules
178 |
179 | # TailwindCSS
180 | *output.css
181 |
182 | # productions static files
183 | staticfiles
184 |
185 | # algolyzer playground aiml models
186 | aiml_models
187 |
188 | doodles
--------------------------------------------------------------------------------
/Algolyzer/quiz/templates/quiz/home.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block content %}
4 |
5 |
Available Quiz Topics
6 |
7 |
99 |
100 |
101 | {% endblock content %}
--------------------------------------------------------------------------------
/Algolyzer/study/templates/study/k_means_clustering.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 | A Beginner's Guide to K-Means Clustering
7 |
8 |
9 |
Introduction
10 |
11 | K-Means clustering is an unsupervised learning algorithm that groups data into clusters based on similarity.
12 | It finds a set of "centroids" that best represent the data points in each cluster.
13 |
14 |
15 | In this tool, you enter a list of numbers, and the algorithm will group them into up to three clusters.
16 |
17 |
18 |
How Does It Work?
19 |
20 | You input several numbers (e.g., 2, 8, 3, 15, 6).
21 | The server reads and parses these numbers into a list.
22 | K-Means places cluster centers and assigns each number to the nearest center.
23 | The centers move to the average of their assigned points until stable.
24 | The final clusters and their labels are shown.
25 |
26 |
27 |
Step-by-Step Breakdown
28 |
29 |
Step 1: Read and Parse Input
30 |
31 | We get the raw JSON string of numbers from the form and convert it into a Python list.
32 |
33 |
34 |
import json
35 |
36 | values_json = request.POST.get("values", "[]")
37 | input_values = json.loads(values_json) # e.g., [2, 8, 3, 15, 6]
38 |
39 |
40 |
Step 2: Prepare Data for K-Means
41 |
42 | We convert the list of numbers into a NumPy array and reshape it so each number is its own data point.
43 |
44 |
45 |
import numpy as np
46 |
47 | X = np.array(input_values).reshape(-1, 1) # e.g., [[2], [8], [3], [15], [6]]
48 |
49 |
50 |
Step 3: Choose Number of Clusters
51 |
52 | We allow up to 3 clusters but never more than the number of points.
53 |
54 |
55 |
from sklearn.cluster import KMeans
56 |
57 | n_clusters = min(len(input_values), 3)
58 | kmeans = KMeans(n_clusters=n_clusters, random_state=42)
59 |
60 |
61 |
Step 4: Run K-Means
62 |
63 | We fit the model to our data and get a label for each point.
64 |
65 |
66 |
kmeans.fit(X)
67 | labels = kmeans.labels_.tolist() # e.g., [0, 1, 0, 2, 0]
68 |
69 |
70 |
Step 5: Pair Values with Cluster Labels
71 |
72 | We zip each original number with its cluster label for easy display.
73 |
74 |
75 |
classified_values = list(zip(input_values, labels))
76 | # e.g., [(2,0), (8,1), (3,0), (15,2), (6,0)]
77 |
78 |
79 |
Why K-Means?
80 |
81 | ✅ Easy to understand and implement.
82 | ✅ Fast and scales well with data size.
83 | ✅ Good for discovering hidden groupings in your data.
84 |
85 |
86 |
Try Clustering!
87 |
88 | Visit the K-Means Clustering page, input a few numbers separated by commas, and see how they group together! 🧩
89 |
90 |
91 | {% endblock %}
92 |
--------------------------------------------------------------------------------
/Algolyzer/community/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 5.1.4 on 2025-02-02 09:59
2 |
3 | import django.db.models.deletion
4 | from django.conf import settings
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 | initial = True
10 |
11 | dependencies = [
12 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
13 | ]
14 |
15 | operations = [
16 | migrations.CreateModel(
17 | name="Category",
18 | fields=[
19 | (
20 | "id",
21 | models.BigAutoField(
22 | auto_created=True,
23 | primary_key=True,
24 | serialize=False,
25 | verbose_name="ID",
26 | ),
27 | ),
28 | ("name", models.CharField(max_length=255, unique=True)),
29 | ("description", models.TextField(blank=True)),
30 | ],
31 | ),
32 | migrations.CreateModel(
33 | name="Post",
34 | fields=[
35 | (
36 | "id",
37 | models.BigAutoField(
38 | auto_created=True,
39 | primary_key=True,
40 | serialize=False,
41 | verbose_name="ID",
42 | ),
43 | ),
44 | ("title", models.CharField(max_length=255)),
45 | ("content", models.TextField()),
46 | ("created_at", models.DateTimeField(auto_now_add=True)),
47 | ("updated_at", models.DateTimeField(auto_now=True)),
48 | (
49 | "author",
50 | models.ForeignKey(
51 | on_delete=django.db.models.deletion.CASCADE,
52 | to=settings.AUTH_USER_MODEL,
53 | ),
54 | ),
55 | (
56 | "category",
57 | models.ForeignKey(
58 | on_delete=django.db.models.deletion.CASCADE,
59 | to="community.category",
60 | ),
61 | ),
62 | ],
63 | ),
64 | migrations.CreateModel(
65 | name="Comment",
66 | fields=[
67 | (
68 | "id",
69 | models.BigAutoField(
70 | auto_created=True,
71 | primary_key=True,
72 | serialize=False,
73 | verbose_name="ID",
74 | ),
75 | ),
76 | ("content", models.TextField()),
77 | ("created_at", models.DateTimeField(auto_now_add=True)),
78 | (
79 | "author",
80 | models.ForeignKey(
81 | on_delete=django.db.models.deletion.CASCADE,
82 | to=settings.AUTH_USER_MODEL,
83 | ),
84 | ),
85 | (
86 | "post",
87 | models.ForeignKey(
88 | on_delete=django.db.models.deletion.CASCADE,
89 | related_name="comments",
90 | to="community.post",
91 | ),
92 | ),
93 | ],
94 | ),
95 | migrations.CreateModel(
96 | name="Vote",
97 | fields=[
98 | (
99 | "id",
100 | models.BigAutoField(
101 | auto_created=True,
102 | primary_key=True,
103 | serialize=False,
104 | verbose_name="ID",
105 | ),
106 | ),
107 | (
108 | "vote_type",
109 | models.IntegerField(choices=[(1, "Upvote"), (-1, "Downvote")]),
110 | ),
111 | (
112 | "post",
113 | models.ForeignKey(
114 | on_delete=django.db.models.deletion.CASCADE,
115 | related_name="votes",
116 | to="community.post",
117 | ),
118 | ),
119 | (
120 | "user",
121 | models.ForeignKey(
122 | on_delete=django.db.models.deletion.CASCADE,
123 | to=settings.AUTH_USER_MODEL,
124 | ),
125 | ),
126 | ],
127 | options={
128 | "unique_together": {("post", "user")},
129 | },
130 | ),
131 | ]
132 |
--------------------------------------------------------------------------------
/Algolyzer/study/templates/study/linear_regression.html:
--------------------------------------------------------------------------------
1 |
2 | {% extends "base.html" %}
3 |
4 | {% block content %}
5 |
6 |
7 | A Beginner's Guide to Linear Regression
8 |
9 |
10 |
Introduction
11 |
12 | Linear regression is a basic machine learning method that finds a straight line (relationship) between input data and output values.
13 | In simple terms, it learns how one variable changes when another changes and uses that to make predictions.
14 |
15 |
16 | Here, we collect five numeric inputs from sliders (values 1–5) and predict a sixth value based on the trends in those inputs.
17 |
18 |
19 |
How Does It Work?
20 |
21 | User moves five sliders to choose numbers.
22 | Values are sent to the server when the form is submitted.
23 | A straight-line model is trained on the five numbers.
24 | The model predicts the value at position 6.
25 | We display the predicted value along with the line’s equation.
26 |
27 |
28 |
Step-by-Step Breakdown
29 |
30 |
Step 1: Collect Input Data
31 |
32 | We read the slider values from the form submission using Django’s request object.
33 |
34 |
35 |
values = [
36 | float(request.POST.get("value_1", 0)),
37 | float(request.POST.get("value_2", 0)),
38 | float(request.POST.get("value_3", 0)),
39 | float(request.POST.get("value_4", 0)),
40 | float(request.POST.get("value_5", 0)),
41 | ]
42 |
43 |
44 |
Step 2: Prepare Data for Training
45 |
46 | We create an array of positions (1–5) and another array of the slider values. This shapes the data for the model.
47 |
48 |
49 |
import numpy as np
50 |
51 | X = np.array(range(1, 6)).reshape(-1, 1) # Positions 1 to 5
52 | y = np.array(values) # The values from sliders
53 |
54 |
55 |
Step 3: Train the Model
56 |
57 | We use scikit-learn’s LinearRegression to learn the best-fit line through our data points.
58 |
59 |
60 |
from sklearn.linear_model import LinearRegression
61 |
62 | model = LinearRegression()
63 | model.fit(X, y)
64 |
65 |
66 |
Step 4: Predict the Next Value
67 |
68 | With the trained model, we predict what the value would be at position 6.
69 |
70 |
71 |
next_index = np.array([[6]])
72 | predicted_value = model.predict(next_index)[0]
73 |
74 |
75 |
Step 5: Get the Line Equation
76 |
77 | We extract the slope (change rate) and intercept (starting point) to show the line’s formula.
78 |
79 |
80 |
slope = model.coef_[0]
81 | intercept = model.intercept_
82 |
83 |
84 |
Why Linear Regression?
85 |
86 | ✅ Simple and interpretable — you see the actual equation.
87 | ✅ Fast to train and requires little data.
88 | ✅ Great starting point for understanding how prediction works.
89 |
90 |
91 |
Try It Yourself!
92 |
93 | Go to the Linear Regression page, move the sliders, and watch your predicted point update! 📈
94 |
95 |
96 | {% endblock %}
97 |
--------------------------------------------------------------------------------
/Algolyzer/community/views.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.decorators import login_required
2 | from django.core.paginator import Paginator
3 | from django.db.models import Sum
4 | from django.http import HttpResponseForbidden
5 | from django.shortcuts import get_object_or_404, redirect, render
6 | from home.decorators import profile_required
7 |
8 | from .models import Category, Comment, Post, Vote
9 |
10 |
11 | def category_list(request):
12 | """Show all categories."""
13 | categories = Category.objects.all()
14 | return render(request, "community/category_list.html", {"categories": categories})
15 |
16 |
17 | def post_list_by_category(request, category_id):
18 | """Show posts in a category and allow creating new posts."""
19 | category = get_object_or_404(Category, id=category_id)
20 |
21 | if request.method == "POST" and request.user.is_authenticated:
22 | title = request.POST.get("title")
23 | content = request.POST.get("content")
24 | if title and content:
25 | Post.objects.create(
26 | title=title, content=content, author=request.user, category=category
27 | )
28 | return redirect("post_list_by_category", category_id=category.id)
29 |
30 | # For normal get request
31 | category = get_object_or_404(Category, id=category_id)
32 | posts = (
33 | Post.objects.filter(category=category)
34 | .annotate(total_votes=Sum("votes__vote_type"))
35 | .order_by("-total_votes", "-created_at")
36 | )
37 |
38 | paginator = Paginator(posts, 5) # Show 5 posts per page
39 | page_number = request.GET.get("page")
40 | page_obj = paginator.get_page(page_number)
41 |
42 | return render(
43 | request,
44 | "community/post_list.html",
45 | {"category": category, "page_obj": page_obj},
46 | )
47 |
48 |
49 | def post_detail(request, post_id):
50 | post = get_object_or_404(Post, id=post_id)
51 |
52 | # Delete Post
53 | if (
54 | request.method == "POST"
55 | and request.POST.get("_method") == "DELETE"
56 | and request.user.is_authenticated
57 | ):
58 | if request.user == post.author:
59 | post.delete()
60 | return redirect("post_list_by_category", category_id=post.category.id)
61 | else:
62 | return HttpResponseForbidden("You can only delete your own posts.")
63 |
64 | # Update Post
65 | if request.method == "POST" and request.user.is_authenticated:
66 | if request.user == post.author:
67 | title = request.POST.get("title")
68 | content = request.POST.get("content")
69 | if title and content:
70 | post.title = title
71 | post.content = content
72 | post.save()
73 | return redirect("post_detail", post_id=post.id)
74 | else:
75 | return HttpResponseForbidden("You can only edit your own posts.")
76 |
77 | # Read posts
78 | """Show post details along with comments and voting functionality."""
79 | comments = post.comments.all()
80 | total_votes = post.votes.aggregate(Sum("vote_type"))["vote_type__sum"] or 0
81 |
82 | return render(
83 | request,
84 | "community/post_detail.html",
85 | {"post": post, "comments": comments, "total_votes": total_votes},
86 | )
87 |
88 |
89 | @login_required
90 | @profile_required
91 | def add_comment(request, post_id):
92 | """Allow users to add comments to a post."""
93 | post = get_object_or_404(Post, id=post_id)
94 |
95 | if request.method == "POST":
96 | content = request.POST.get("content")
97 | if content:
98 | Comment.objects.create(post=post, author=request.user, content=content)
99 |
100 | return redirect("post_detail", post_id=post.id)
101 |
102 |
103 | @login_required
104 | @profile_required
105 | def vote_post(request, post_id, vote_type):
106 | post = get_object_or_404(Post, id=post_id)
107 | vote_type = int(vote_type)
108 |
109 | # Ensure vote_type is either 1 (upvote) or -1 (downvote)
110 | if vote_type not in [1, -1]:
111 | return HttpResponseForbidden("Invalid vote type.")
112 |
113 | # Check if the user has already voted on this post
114 | existing_vote = Vote.objects.filter(post=post, user=request.user).first()
115 |
116 | if existing_vote:
117 | if existing_vote.vote_type == vote_type:
118 | # If the user clicks the same vote again, remove the vote (unvote)
119 | existing_vote.delete()
120 | else:
121 | # Otherwise, update the vote
122 | existing_vote.vote_type = vote_type
123 | existing_vote.save()
124 | else:
125 | # Create a new vote if none exists
126 | Vote.objects.create(post=post, user=request.user, vote_type=vote_type)
127 |
128 | return redirect("post_detail", post_id=post.id)
129 |
--------------------------------------------------------------------------------
/Algolyzer/quiz/templates/quiz/topic.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 | {% comment %} Stats Bar
7 |
8 |
9 |
10 |
23 |
Total Likes
24 |
25.6K
25 |
21% more than last month
26 |
27 |
28 |
29 |
42 |
Page Views
43 |
2.6M
44 |
21% more than last month
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
86%
56 |
Reach
57 |
Better than Before
58 |
59 |
60 |
{% endcomment %}
61 |
62 |
63 |
64 | {% comment %} Rules {% endcomment %}
65 |
66 |
67 |
Rules
68 |
69 | There are {{total}} No of questions in this Quiz.
70 | Each right answer gives 2 XP points.
71 | There is NO time limit so answer without hasting
72 | Your Score will be evaluated at the end of the Quiz
73 |
74 |
75 |
76 |
77 | {% comment %} Topic Overview {% endcomment %}
78 |
79 |
80 |
Overview
81 |
Artificial Intelligence (AI) and Machine Learning (ML) are transforming the way we interact with technology, enabling systems to learn from data and make intelligent decisions. This AI-ML quiz is designed to test your understanding of fundamental concepts such as supervised and unsupervised learning, neural networks, natural language processing, and deep learning. Whether you're a beginner exploring the basics or an advanced learner diving into complex algorithms, this quiz will challenge your knowledge and help you assess your grasp of key AI-ML principles. Get ready to sharpen your skills and see how well you understand the world of intelligent machines! 🚀
82 |
83 |
84 |
85 |
Start The Challenge
86 |
87 |
88 |
89 |
90 |
91 |
92 | {% endblock content %}
--------------------------------------------------------------------------------
/Algolyzer/templates/account/signup.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% load allauth i18n %}
3 | {% block head_title %}
4 | {% trans "Signup" %}
5 | {% endblock head_title %}
6 |
7 | {% block content %}
8 |
9 |
10 |
11 |
12 | {% trans "Sign Up" %}
13 |
14 |
15 | {% blocktranslate %}
16 | Already have an account? Then please
17 | sign in .
18 | {% endblocktranslate %}
19 |
20 |
21 | {% if not SOCIALACCOUNT_ONLY %}
22 |
23 | {% csrf_token %}
24 | {% for field in form %}
25 |
48 | {% for error in field.errors %}
49 | {{ error }}
50 | {% endfor %}
51 | {% endfor %}
52 | {{ redirect_field }}
53 |
54 |
55 | {% trans "Sign Up" %}
56 |
57 |
58 | {% endif %}
59 |
60 |
61 |
62 | {% endblock content %}
63 |
64 | {% block scripts %}
65 |
88 | {% endblock %}
89 |
--------------------------------------------------------------------------------
/Algolyzer/playground/templates/playground/doodle_classifier.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 |
Doodle Classifier
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | Clear
16 | Submit
17 |
18 |
19 |
20 |
21 | {% csrf_token %}
22 |
23 |
24 |
25 |
26 |
27 |
Previous Results
28 |
29 | {% for result in previous_results %}
30 |
31 |
32 |
33 | Submitted Doodle
34 |
35 |
36 |
37 |
38 |
39 |
Status
40 |
{{ result.status }}
41 |
Failed | Completed
42 |
43 |
44 |
45 |
Prediction
46 |
{{ result.result }}
47 |
Number 0 to 9
48 |
49 |
50 |
55 |
56 |
57 |
58 | {% empty %}
59 |
No previous results available.
60 | {% endfor %}
61 |
62 |
63 |
64 |
65 |
66 |
111 | {% endblock %}
--------------------------------------------------------------------------------
/Algolyzer/study/templates/study/svm_regression.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 | A Beginner's Guide to SVM Regression
7 |
8 |
9 |
Introduction
10 |
11 | Support Vector Machine (SVM) Regression is a method that finds a function
12 | to predict continuous values (like temperature or humidity) based on past data.
13 | It works well even when the relationship between inputs and outputs is complex.
14 |
15 |
16 | In this example, we use previous temperature and humidity readings
17 | to predict the next temperature and humidity values.
18 |
19 |
20 |
How Does It Work?
21 |
22 | You input a list of temperature-humidity pairs (e.g., [[22,55], [23,60], [24,65]]).
23 | The server converts this list into a format the model understands.
24 | We train two SVM models: one to predict temperature, another for humidity.
25 | The models use all but the last pair to learn patterns.
26 | We predict the next temperature and humidity for the final pair.
27 |
28 |
29 |
Step-by-Step Breakdown
30 |
31 |
Step 1: Read the Input Values
32 |
33 | We get the JSON string of pairs from the form and convert it into a Python list.
34 |
35 |
36 |
import json
37 |
38 | values_json = request.POST.get("values", "[]")
39 | input_values = json.loads(values_json) # e.g., [[22,55], [23,60], [24,65]]
40 |
41 |
42 |
Step 2: Prepare Data for SVM
43 |
44 | We convert the list to a NumPy array and split it into features and targets.
45 | Features (X) are all pairs except the last. Targets (y) are temperature and humidity separately.
46 |
47 |
48 |
import numpy as np
49 |
50 | data = np.array(input_values) # shape: (n, 2)
51 | X = data[:-1] # all but last for training
52 | y_temp = data[1:, 0] # target: next temperatures
53 | y_hum = data[1:, 1] # target: next humidities
54 |
55 |
56 |
Step 3: Train SVM Models
57 |
58 | We create two SVR (Support Vector Regression) models and fit them on our training data.
59 |
60 |
61 |
from sklearn.svm import SVR
62 |
63 | svr_temp = SVR(kernel="rbf", C=100, gamma="scale")
64 | svr_hum = SVR(kernel="rbf", C=100, gamma="scale")
65 | svr_temp.fit(X, y_temp)
66 | svr_hum.fit(X, y_hum)
67 |
68 |
69 |
Step 4: Predict the Next Values
70 |
71 | We take the last input pair and ask both models to predict the next temperature and humidity.
72 |
73 |
74 |
last_pair = data[-1].reshape(1, -1)
75 | predicted_temp = svr_temp.predict(last_pair)[0]
76 | predicted_hum = svr_hum.predict(last_pair)[0]
77 |
78 |
79 |
Step 5: Display the Predictions
80 |
81 | We round the predictions and send them back to the template for display.
82 |
83 |
84 |
pred_temp = round(predicted_temp, 2)
85 | pred_hum = round(predicted_hum, 2)
86 |
87 | Then render these in the Django template
88 |
89 |
90 |
91 |
Why SVM Regression?
92 |
93 | ✅ Works well with small to medium-sized datasets.
94 | ✅ Can model complex, non-linear relationships.
95 | ✅ More robust to outliers than simple linear regression.
96 |
97 |
98 |
Give It a Try!
99 |
100 | Visit the SVM Regression page, enter a JSON list of [temp, hum] pairs, and see your next prediction! 🌡️💧
101 |
102 |
103 | {% endblock %}
104 |
--------------------------------------------------------------------------------
/Algolyzer/quiz/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 5.1.4 on 2025-01-12 13:17
2 |
3 | import django.db.models.deletion
4 | from django.conf import settings
5 | from django.db import migrations, models
6 |
7 |
8 | class Migration(migrations.Migration):
9 | initial = True
10 |
11 | dependencies = [
12 | migrations.swappable_dependency(settings.AUTH_USER_MODEL),
13 | ]
14 |
15 | operations = [
16 | migrations.CreateModel(
17 | name="Topic",
18 | fields=[
19 | (
20 | "id",
21 | models.BigAutoField(
22 | auto_created=True,
23 | primary_key=True,
24 | serialize=False,
25 | verbose_name="ID",
26 | ),
27 | ),
28 | ("name", models.CharField(max_length=100)),
29 | ],
30 | ),
31 | migrations.CreateModel(
32 | name="QuizProgress",
33 | fields=[
34 | (
35 | "id",
36 | models.BigAutoField(
37 | auto_created=True,
38 | primary_key=True,
39 | serialize=False,
40 | verbose_name="ID",
41 | ),
42 | ),
43 | ("current_question", models.IntegerField(default=0)),
44 | ("completed", models.BooleanField(default=False)),
45 | (
46 | "user",
47 | models.ForeignKey(
48 | on_delete=django.db.models.deletion.CASCADE,
49 | to=settings.AUTH_USER_MODEL,
50 | ),
51 | ),
52 | (
53 | "topic",
54 | models.ForeignKey(
55 | on_delete=django.db.models.deletion.CASCADE, to="quiz.topic"
56 | ),
57 | ),
58 | ],
59 | ),
60 | migrations.CreateModel(
61 | name="Question",
62 | fields=[
63 | (
64 | "id",
65 | models.BigAutoField(
66 | auto_created=True,
67 | primary_key=True,
68 | serialize=False,
69 | verbose_name="ID",
70 | ),
71 | ),
72 | ("text", models.TextField()),
73 | ("option_a", models.CharField(max_length=200)),
74 | ("option_b", models.CharField(max_length=200)),
75 | ("option_c", models.CharField(max_length=200)),
76 | ("option_d", models.CharField(max_length=200)),
77 | (
78 | "correct_answer",
79 | models.CharField(
80 | choices=[
81 | ("a", "Option A"),
82 | ("b", "Option B"),
83 | ("c", "Option C"),
84 | ("d", "Option D"),
85 | ],
86 | help_text="Correct answer should be 'a', 'b', 'c', or 'd'",
87 | max_length=1,
88 | ),
89 | ),
90 | (
91 | "topic",
92 | models.ForeignKey(
93 | on_delete=django.db.models.deletion.CASCADE, to="quiz.topic"
94 | ),
95 | ),
96 | ],
97 | ),
98 | migrations.CreateModel(
99 | name="UserAnswer",
100 | fields=[
101 | (
102 | "id",
103 | models.BigAutoField(
104 | auto_created=True,
105 | primary_key=True,
106 | serialize=False,
107 | verbose_name="ID",
108 | ),
109 | ),
110 | (
111 | "selected_answer",
112 | models.CharField(
113 | choices=[
114 | ("a", "Option A"),
115 | ("b", "Option B"),
116 | ("c", "Option C"),
117 | ("d", "Option D"),
118 | ],
119 | help_text="Selected answer should be 'a', 'b', 'c', or 'd'",
120 | max_length=1,
121 | ),
122 | ),
123 | ("is_correct", models.BooleanField(default=False)),
124 | (
125 | "question",
126 | models.ForeignKey(
127 | on_delete=django.db.models.deletion.CASCADE, to="quiz.question"
128 | ),
129 | ),
130 | (
131 | "topic",
132 | models.OneToOneField(
133 | on_delete=django.db.models.deletion.CASCADE, to="quiz.topic"
134 | ),
135 | ),
136 | (
137 | "user",
138 | models.ForeignKey(
139 | on_delete=django.db.models.deletion.CASCADE,
140 | to=settings.AUTH_USER_MODEL,
141 | ),
142 | ),
143 | ],
144 | ),
145 | ]
146 |
--------------------------------------------------------------------------------
/Algolyzer/playground/templates/playground/linear_regression.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block extra_head %}
4 |
5 | {% endblock %}
6 |
7 | {% block content %}
8 |
9 |
10 |
Linear Regression
11 |
12 |
13 |
14 | {% csrf_token %}
15 | Enter values:
16 |
17 | {% for i in "12345" %}
18 |
19 |
20 | Value {{ forloop.counter }}
21 | 5
22 |
23 |
32 |
33 | {% endfor %}
34 |
35 | Submit
36 |
37 |
38 | {% if predicted_value %}
39 |
40 |
41 |
Input Values: {{ input_values|join:", " }}
42 |
Prediction: The next value is {{ predicted_value }}.
43 |
44 |
45 | {% endif %}
46 |
47 | {% if show_chart %}
48 |
49 |
50 |
51 |
Linear Regression Chart
52 |
53 |
54 |
55 |
56 |
57 | {% block scripts %}
58 |
123 | {% endblock %}
124 | {% endif %}
125 |
126 |
127 |
128 | {% endblock %}
--------------------------------------------------------------------------------
/Algolyzer/quiz/views.py:
--------------------------------------------------------------------------------
1 | from django.contrib.auth.decorators import login_required
2 | from django.shortcuts import get_object_or_404, redirect, render
3 | from home.decorators import profile_required
4 | from home.models import UserProfile
5 |
6 | from .forms import QuizForm
7 | from .models import Question, QuizProgress, Topic, UserAnswer
8 |
9 |
10 | @login_required
11 | @profile_required
12 | def quiz_home(request):
13 | """Main QUIZ Home Page"""
14 | data = []
15 | topics = Topic.objects.all()
16 | for topic in topics:
17 | score = 0
18 | total = Question.objects.filter(topic=topic).count()
19 | progress = QuizProgress.objects.filter(user=request.user, topic=topic).first()
20 | if progress is not None and progress.completed:
21 | answers = UserAnswer.objects.filter(user=request.user, topic=topic)
22 | score = answers.filter(is_correct=True).count()
23 | data.append(
24 | {
25 | "topic": topic,
26 | "score": score,
27 | "total": total,
28 | }
29 | )
30 |
31 | context = {"data": data}
32 | return render(request, "quiz/home.html", context=context)
33 |
34 |
35 | @login_required
36 | @profile_required
37 | def quiz_topic(request, topic_id):
38 | topic = get_object_or_404(Topic, id=topic_id)
39 | score = 0
40 | total = 0
41 | progress = QuizProgress.objects.filter(user=request.user, topic=topic).first()
42 | if progress is not None and progress.completed:
43 | answers = UserAnswer.objects.filter(user=request.user, topic=topic)
44 | score = answers.filter(is_correct=True).count()
45 | total = Question.objects.filter(topic=topic).count()
46 |
47 | context = {
48 | "topic": topic,
49 | "score": score,
50 | "total": total,
51 | }
52 | return render(request, "quiz/topic.html", context=context)
53 |
54 |
55 | @login_required
56 | @profile_required
57 | def quiz_start(request, topic_id):
58 | """
59 | Resets user progress to start a fresh quiz
60 | """
61 | topic = get_object_or_404(Topic, id=topic_id)
62 | questions = Question.objects.filter(topic=topic)
63 | if not questions.exists():
64 | return render(request, "quiz/no_questions.html")
65 |
66 | # Initialize or reset progress
67 | QuizProgress.objects.filter(user=request.user, topic=topic).delete()
68 | QuizProgress.objects.create(user=request.user, topic=topic, current_question=0)
69 | UserAnswer.objects.filter(user=request.user, topic=topic).delete()
70 | return redirect("quiz_question", topic_id=topic.id)
71 |
72 |
73 | @login_required
74 | @profile_required
75 | def quiz_question(request, topic_id):
76 | topic = get_object_or_404(Topic, id=topic_id)
77 | progress = get_object_or_404(QuizProgress, user=request.user, topic=topic)
78 |
79 | # Fetch the current question
80 | questions = Question.objects.filter(topic=topic)
81 | if progress.current_question >= len(questions):
82 | progress.completed = True
83 | progress.save()
84 | return redirect("quiz_results", topic_id=topic.id)
85 |
86 | question = questions[progress.current_question]
87 |
88 | if request.method == "POST":
89 | form = QuizForm(question, request.POST)
90 | if form.is_valid():
91 | selected_answer = form.cleaned_data["answer"]
92 |
93 | # Save user's answer, is_correct field is managed internally in model.
94 | UserAnswer.objects.create(
95 | topic=topic,
96 | user=request.user,
97 | question=question,
98 | selected_answer=selected_answer,
99 | )
100 |
101 | # Move to the next question
102 | progress.current_question += 1
103 | progress.save()
104 | return redirect("quiz_question", topic_id=topic.id)
105 | else:
106 | form = QuizForm(question)
107 |
108 | return render(
109 | request,
110 | "quiz/question.html",
111 | {"form": form, "progress": progress, "total_array": range(len(questions))},
112 | )
113 |
114 |
115 | def quiz_results(request, topic_id):
116 | topic = get_object_or_404(Topic, id=topic_id)
117 | quiz_progress = get_object_or_404(QuizProgress, topic=topic, user=request.user)
118 | if not quiz_progress.completed:
119 | return redirect("quiz_question", topic_id=topic.id)
120 |
121 | answers = UserAnswer.objects.filter(user=request.user, topic=topic)
122 | for answer in answers:
123 | # Add full option text to each answer
124 | answer.selected_option_text = answer.question.get_option_text(
125 | answer.selected_answer
126 | )
127 | answer.correct_option_text = answer.question.get_option_text(
128 | answer.question.correct_answer
129 | )
130 |
131 | score = answers.filter(is_correct=True).count()
132 | total = Question.objects.filter(topic=topic).count()
133 | XP_REWARDS = {
134 | "Easy": 2,
135 | "Medium": 5,
136 | "Hard": 10,
137 | "Veteran": 20,
138 | }
139 | # Add XP to the user's profile based on the topic difficulty
140 | user_profile = UserProfile.objects.get(user=request.user)
141 | xp_to_add = (
142 | XP_REWARDS.get(topic.difficulty, 0) * score
143 | ) # Default to 0 if difficulty is not found
144 | user_profile.add_xp(xp_to_add)
145 |
146 | context = {
147 | "topic": topic,
148 | "score": score,
149 | "total": total,
150 | "answers": answers,
151 | "xp": xp_to_add,
152 | }
153 |
154 | return render(request, "quiz/results.html", context=context)
155 |
--------------------------------------------------------------------------------
/Algolyzer/quiz/templates/quiz/results.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block content %}
4 |
5 |
6 |
🎊 Congratulations! 🎊
7 |
8 |
9 |
10 |
11 |
Your Score
12 |
13 |
14 |
15 |
16 |
17 |
Experience earned: +{{ xp }}
18 |
19 |
20 |
21 |
22 |
23 |
24 | {% for answer in answers %}
25 |
26 |
27 |
28 |
29 | {{ answer.question.text }}
30 |
31 |
32 | {% if answer.is_correct %}✅{% else %}❌{% endif %}
33 |
34 |
35 |
36 |
37 |
38 |
39 | Your Answer:
40 |
41 | {{ answer.get_selected_answer_display }} -
42 | {{ answer.selected_option_text }}
43 |
44 |
45 | {% if not answer.is_correct %}
46 |
47 | Correct Answer:
48 |
49 | {{ answer.question.get_correct_answer_display }} -
50 | {{ answer.correct_option_text }}
51 |
52 |
53 | {% endif %}
54 |
55 |
56 |
57 |
58 | {% endfor %}
59 |
60 |
61 |
62 |
63 | {% endblock %}
64 |
65 | {% block scripts %}
66 |
111 | {% endblock %}
--------------------------------------------------------------------------------
/Algolyzer/playground/templates/playground/kmeans_clustering.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block extra_head %}
4 |
5 | {% endblock %}
6 |
7 | {% block content %}
8 |
9 |
10 |
K-Means Clustering
11 |
12 |
13 |
14 | {% csrf_token %}
15 |
16 |
Enter values:
17 |
18 |
19 | Add
20 |
21 |
22 |
Added Values: None
23 |
24 |
25 |
26 |
27 | Submit
28 |
29 |
30 | {% if error %}
31 |
36 | {% endif %}
37 |
38 | {% if classified_values %}
39 |
40 |
41 |
Input Values: {{ input_values|join:", " }}
42 |
Clusters:
43 |
44 | {% for value, cluster in classified_values %}
45 | Value: {{ value }} → Cluster: {{ cluster }}
46 | {% endfor %}
47 |
48 |
49 |
50 | {% endif %}
51 |
52 | {% if show_chart %}
53 |
54 |
55 |
56 |
K-Means Clustering Chart
57 |
58 |
59 |
60 |
61 | {% endif %}
62 |
63 |
64 | {% endblock %}
65 |
66 | {% block scripts %}
67 |
173 | {% endblock %}
--------------------------------------------------------------------------------
/Algolyzer/data/quiz_data.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "model": "quiz.question",
4 | "pk": 1,
5 | "fields": {
6 | "topic": 1,
7 | "text": "What is Artificial Intelligence (AI)?",
8 | "option_a": "A branch of science focused on studying human psychology",
9 | "option_b": "The process of designing computer games",
10 | "option_c": "The simulation of human intelligence in machines",
11 | "option_d": "The development of physical robots only",
12 | "correct_answer": "c"
13 | }
14 | },
15 | {
16 | "model": "quiz.question",
17 | "pk": 2,
18 | "fields": {
19 | "topic": 1,
20 | "text": "Which of the following is NOT a type of machine learning?",
21 | "option_a": "Supervised learning",
22 | "option_b": "Unsupervised learning",
23 | "option_c": "Reinforcement learning",
24 | "option_d": "Data modeling",
25 | "correct_answer": "d"
26 | }
27 | },
28 | {
29 | "model": "quiz.question",
30 | "pk": 3,
31 | "fields": {
32 | "topic": 1,
33 | "text": "What distinguishes Machine Learning from traditional programming?",
34 | "option_a": "Machine Learning models rely on fixed rules defined by humans",
35 | "option_b": "Machine Learning models learn patterns from data",
36 | "option_c": "Machine Learning does not require any data",
37 | "option_d": "Traditional programming can handle image recognition better than Machine Learning",
38 | "correct_answer": "b"
39 | }
40 | },
41 | {
42 | "model": "quiz.question",
43 | "pk": 4,
44 | "fields": {
45 | "topic": 1,
46 | "text": "Which of the following is an example of supervised learning?",
47 | "option_a": "Grouping customers based on purchasing behavior",
48 | "option_b": "Predicting house prices based on features like area and number of rooms",
49 | "option_c": "Detecting unusual transactions without labeled data",
50 | "option_d": "Training a robot to learn from rewards in a game environment",
51 | "correct_answer": "b"
52 | }
53 | },
54 | {
55 | "model": "quiz.question",
56 | "pk": 5,
57 | "fields": {
58 | "topic": 1,
59 | "text": "What is the role of a dataset in Machine Learning?",
60 | "option_a": "To provide training and testing data for the model",
61 | "option_b": "To create a database of rules",
62 | "option_c": "To store the output of the model",
63 | "option_d": "To develop software applications",
64 | "correct_answer": "a"
65 | }
66 | },
67 | {
68 | "model": "quiz.question",
69 | "pk": 6,
70 | "fields": {
71 | "topic": 1,
72 | "text": "What is a common application of AI in daily life?",
73 | "option_a": "Weather forecasting using random guesses",
74 | "option_b": "Spam email filtering in mail services",
75 | "option_c": "Writing code for computer programs manually",
76 | "option_d": "Developing spreadsheets for data storage",
77 | "correct_answer": "b"
78 | }
79 | },
80 | {
81 | "model": "quiz.question",
82 | "pk": 7,
83 | "fields": {
84 | "topic": 1,
85 | "text": "What does \"unsupervised learning\" aim to do?",
86 | "option_a": "Predict a target variable using labeled data",
87 | "option_b": "Find hidden patterns in unlabeled data",
88 | "option_c": "Simulate human intelligence for logical tasks",
89 | "option_d": "Train robots to follow human instructions",
90 | "correct_answer": "b"
91 | }
92 | },
93 | {
94 | "model": "quiz.question",
95 | "pk": 8,
96 | "fields": {
97 | "topic": 1,
98 | "text": "Which of the following is an example of reinforcement learning?",
99 | "option_a": "Clustering news articles based on their content",
100 | "option_b": "Teaching a robot to walk by rewarding it for each successful step",
101 | "option_c": "Predicting stock prices using historical data",
102 | "option_d": "Identifying spam emails based on labeled examples",
103 | "correct_answer": "b"
104 | }
105 | },
106 | {
107 | "model": "quiz.question",
108 | "pk": 9,
109 | "fields": {
110 | "topic": 1,
111 | "text": "Which of these statements is true about deep learning?",
112 | "option_a": "It is a subset of reinforcement learning",
113 | "option_b": "It does not use neural networks",
114 | "option_c": "It requires large amounts of data to perform well",
115 | "option_d": "It is primarily used for clustering",
116 | "correct_answer": "c"
117 | }
118 | },
119 | {
120 | "model": "quiz.question",
121 | "pk": 10,
122 | "fields": {
123 | "topic": 1,
124 | "text": "What is the primary objective of Machine Learning?",
125 | "option_a": "To make machines conscious like humans",
126 | "option_b": "To build hardware that mimics the human brain",
127 | "option_c": "To write manual code for all decision-making processes",
128 | "option_d": "To enable machines to learn from data and make decisions",
129 | "correct_answer": "d"
130 | }
131 | },
132 | {
133 | "model": "quiz.topic",
134 | "pk": 1,
135 | "fields": {
136 | "name": "Introduction to Artificial Intelligence and Machine Learning"
137 | }
138 | },
139 | {
140 | "model": "quiz.topic",
141 | "pk": 2,
142 | "fields": {
143 | "name": "Mathematics and Statistics for AI/ML"
144 | }
145 | },
146 | {
147 | "model": "quiz.topic",
148 | "pk": 3,
149 | "fields": {
150 | "name": "Data Preprocessing and Feature Engineering"
151 | }
152 | },
153 | {
154 | "model": "quiz.topic",
155 | "pk": 4,
156 | "fields": {
157 | "name": "Supervised Learning"
158 | }
159 | },
160 | {
161 | "model": "quiz.topic",
162 | "pk": 5,
163 | "fields": {
164 | "name": "Unsupervised Learning"
165 | }
166 | },
167 | {
168 | "model": "quiz.topic",
169 | "pk": 6,
170 | "fields": {
171 | "name": "Neural Networks and Deep Learning"
172 | }
173 | },
174 | {
175 | "model": "quiz.topic",
176 | "pk": 7,
177 | "fields": {
178 | "name": "Reinforcement Learning"
179 | }
180 | },
181 | {
182 | "model": "quiz.topic",
183 | "pk": 8,
184 | "fields": {
185 | "name": "Natural Language Processing (NLP)"
186 | }
187 | },
188 | {
189 | "model": "quiz.topic",
190 | "pk": 9,
191 | "fields": {
192 | "name": "Model Deployment and Scalability"
193 | }
194 | },
195 | {
196 | "model": "quiz.topic",
197 | "pk": 10,
198 | "fields": {
199 | "name": "Ethical AI and Advanced Topics"
200 | }
201 | }
202 | ]
203 |
--------------------------------------------------------------------------------
/Algolyzer/home/templates/home/dashboard.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block content %}
4 |
5 |
6 | Welcome, {{ user_profile }}
7 |
8 | {% csrf_token %}
9 | Sign Out
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
Your XP
22 |
{{ user_profile.xp }} XP
23 |
Level {{ user_profile.level }}
24 |
25 |
{{ user_profile.get_next_level_xp }} XP to next level
26 |
27 |
28 |
29 |
30 |
35 |
Quizzes Completed
36 |
{{ completed_quizzes }}
37 |
Out of {{ total_quizzes }} topics
38 |
39 |
40 |
41 |
42 |
47 |
Tasks
48 |
{{ completed_tasks }} Done
49 |
{{ pending_tasks }} Pending
50 |
51 |
52 |
53 |
54 |
59 |
Forum Activity
60 |
{{ total_posts }} Posts
61 |
{{ total_comments }} Comments
62 |
63 |
64 |
65 |
66 |
67 |
Recent Activity
68 |
69 |
70 |
71 |
72 |
Recent Quizzes
73 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
Recent Tasks
88 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
Forum Activity
107 |
108 |
109 |
110 |
111 |
Recent Posts
112 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
Recent Comments
128 |
129 | {% for comment in recent_comments %}
130 |
131 | {{ comment.content|truncatechars:50 }}
132 | On {{ comment.post.title }}
133 | Posted on {{ comment.created_at|date:"M d, Y" }}
134 |
135 | {% endfor %}
136 |
137 |
138 |
139 |
140 |
141 |
142 | {% endblock %}
--------------------------------------------------------------------------------
/Algolyzer/community/templates/community/post_detail.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block content %}
4 |
5 |
6 |
← Back to Posts
7 |
8 | {% if user == post.author %}
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | {% csrf_token %}
18 | Edit Post
19 |
20 |
21 | Title
22 |
23 |
24 |
25 |
26 |
27 | Content
28 |
29 | {{ post.content }}
30 |
31 |
32 | Save Changes
33 | Close
34 |
35 |
36 |
37 | {% endif %}
38 |
39 | {% if user == post.author %}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | {% csrf_token %}
49 |
50 | Delete Post
51 | Are you sure you want to delete this post? This action cannot be undone.
52 |
53 | Delete
54 | Cancel
55 |
56 |
57 |
58 | {% endif %}
59 |
60 |
61 |
62 |
63 |
64 |
{{ post.title }}
65 |
By {{ post.author.username }} | {{ post.created_at|date:"F j, Y, g:i a" }}
66 |
67 | {% if post.image %}
68 |
69 | {% endif %}
70 |
71 |
72 |
73 |
{{ post.content|linebreaks }}
74 |
75 |
76 |
77 |
78 |
79 | {% csrf_token %}
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 | {% csrf_token %}
88 |
89 |
90 |
91 |
92 |
93 |
94 |
{{ total_votes }}
95 |
96 |
97 |
98 |
99 |
100 |
101 |
Comments
102 |
103 | {% for comment in comments %}
104 |
105 |
{{ comment.author.username }} : {{ comment.content }}
106 |
{{ comment.created_at|date:"F j, Y, g:i a" }}
107 |
108 | {% empty %}
109 |
No comments yet. Be the first to comment!
110 | {% endfor %}
111 |
112 |
113 | {% if user.is_authenticated %}
114 |
115 |
116 | {% csrf_token %}
117 |
118 | Post Comment
119 |
120 | {% else %}
121 |
You must be logged in to comment.
122 | {% endif %}
123 |
124 |
125 | {% endblock %}
126 |
--------------------------------------------------------------------------------
/Algolyzer/templates/account/login.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 | {% load allauth i18n %}
3 | {% block head_title %}
4 | {% trans "Sign In" %}
5 | {% endblock head_title %}
6 |
7 | {% block content %}
8 |
9 |
10 |
11 |
12 | {% trans "Sign In" %}
13 |
14 | {% if not SOCIALACCOUNT_ONLY %}
15 |
16 | {% blocktranslate %}
17 | If you don't have an account, please
18 | sign up first.
19 | {% endblocktranslate %}
20 |
21 | {% endif %}
22 |
23 |
24 | {% csrf_token %}
25 | {% if form.non_field_errors %}
26 |
27 | {% for error in form.non_field_errors %}
28 | {{ error }}
29 | {% endfor %}
30 |
31 | {% endif %}
32 |
33 |
34 | {% for field in form %}
35 | {% if field.label == 'Remember Me' %}
36 |
37 |
45 | {{ field.label }}
46 |
47 | {% else %}
48 |
71 | {% for error in field.errors %}
72 | {{ error }}
73 | {% endfor %}
74 | {% endif %}
75 | {% endfor %}
76 |
77 | {{ redirect_field }}
78 |
79 |
80 | {% trans "Sign In" %}
81 |
82 |
83 |
84 | {% if LOGIN_BY_CODE_ENABLED or PASSKEY_LOGIN_ENABLED %}
85 |
OR
86 |
98 | {% endif %}
99 |
100 | {% if SOCIALACCOUNT_ENABLED %}
101 |
Or Use a Third Party App
102 |
103 | {% include "socialaccount/snippets/login.html" with page_layout="entrance" %}
104 |
105 | {% endif %}
106 |
107 |
108 |
109 | {% endblock content %}
110 |
111 | {% block extra_body %}
112 | {{ block.super }}
113 | {% if PASSKEY_LOGIN_ENABLED %}
114 | {% include "mfa/webauthn/snippets/login_script.html" with button_id="passkey_login" %}
115 | {% endif %}
116 | {% endblock extra_body %}
117 |
118 | {% block scripts %}
119 |
120 |
121 |
144 | {% endblock %}
145 |
--------------------------------------------------------------------------------
/Algolyzer/home/templates/home/home.html:
--------------------------------------------------------------------------------
1 | {% extends 'base.html' %}
2 |
3 | {% block extra_head %}
4 | {% load static %}
5 |
13 | {% endblock %}
14 |
15 | {% block content %}
16 |
17 |
18 |
19 | {% comment %}
Welcome to
{% endcomment %}
20 |
Easiest way to
21 |
Learn AI-ML
22 |
Become the next Algo Expert with Algolyzer
23 |
24 |
28 |
29 |
30 | {% endblock %}
31 |
--------------------------------------------------------------------------------
/Algolyzer/templates/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | {% block title %}Algolyzer{% endblock %}
8 |
9 | {% load static %}
10 |
11 |
12 |
13 |
14 |
15 | {% block extra_head %}{% endblock %}
16 |
17 |
18 |
19 |
20 | {% comment %} Loading Url tags to activate tab-active class without bugs and errors {% endcomment %}
21 | {% url 'quiz_home' as quiz_url %}
22 | {% url 'playground_home' as playground_url %}
23 | {% url 'home' as home_url %}
24 | {% url 'category_list' as community_url %}
25 | {% url 'study_home' as study_url %}
26 |
27 |
28 |
29 |
30 |
35 |
36 | {% comment %} mobile navbar links {% endcomment %}
37 |
38 |
39 | Home
40 |
41 |
42 | Quiz
43 |
44 |
45 | Playground
46 |
47 |
48 | Study
49 |
50 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | {% comment %} pc navbar links {% endcomment %}
62 |
79 |
80 |
81 |
82 | {% if not user.is_authenticated %}
83 |
Login
84 |
Signup
85 | {% endif %}
86 | {% if user.is_authenticated %}
87 |
Dashboard
88 | {% endif %}
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | {% block content %}
97 | Welcome to my Django app!
98 | {% endblock %}
99 |
100 |
101 |
102 |
117 |
164 |
165 |
166 | {% block scripts %}{% endblock %}
167 |
168 |
169 |
--------------------------------------------------------------------------------