Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added cadmin/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions cadmin/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions cadmin/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class CadminConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'cadmin'
Empty file added cadmin/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions cadmin/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
174 changes: 174 additions & 0 deletions cadmin/templates/cadmin/course_admin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
{% extends 'base.html' %}

{% load custom_filters %}

{% block breadcrumbs %}
<li><a href="{% url 'cadmin_course_list' %}">Course Admin</a></li>
<li><a href="{% url 'cadmin_course' course.slug %}">{{ course.title }}</a></li>
{% endblock %}

{% block content %}
<h2>{{ course.title }} - Admin Panel</h2>

<div class="mb-3">
<a href="{% url 'course' course.slug %}" class="btn btn-secondary">View Course Page</a>
<a href="{% url 'dashboard' course.slug %}" class="btn btn-info">Course Dashboard</a>
<a href="{% url 'leaderboard' course.slug %}" class="btn btn-primary">Leaderboard</a>
</div>

<div class="alert alert-info" role="alert">
<strong>Total Enrollments:</strong> {{ total_enrollments }}
</div>

<!-- Homework Section -->
<div class="card mb-4">
<div class="card-header">
<h3>Homework</h3>
</div>
<div class="card-body">
{% if homeworks %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Title</th>
<th>Due Date</th>
<th>State</th>
<th>Submissions</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for hw in homeworks %}
<tr>
<td>
<a href="{% url 'homework' course.slug hw.slug %}">{{ hw.title }}</a>
</td>
<td>{{ hw.due_date|date:"Y-m-d H:i" }}</td>
<td>
{% if hw.state == 'OP' %}
<span class="badge badge-success">Open</span>
{% elif hw.state == 'CL' %}
<span class="badge badge-secondary">Closed</span>
{% elif hw.state == 'SC' %}
<span class="badge badge-primary">Scored</span>
{% else %}
<span class="badge badge-warning">{{ hw.get_state_display }}</span>
{% endif %}
</td>
<td>
<a href="{% url 'cadmin_homework_submissions' course.slug hw.slug %}">
{{ hw.submissions_count }}
</a>
</td>
<td>
<div class="btn-group" role="group">
<a href="{% url 'cadmin_homework_set_correct_answers' course.slug hw.slug %}"
class="btn btn-sm btn-warning"
onclick="return confirm('Set correct answers to most popular for {{ hw.title }}?')">
Set Correct
</a>
<a href="{% url 'cadmin_homework_score' course.slug hw.slug %}"
class="btn btn-sm btn-primary"
onclick="return confirm('Score homework {{ hw.title }}?')">
Score
</a>
<a href="{% url 'homework_statistics' course.slug hw.slug %}"
class="btn btn-sm btn-info">
Stats
</a>
<a href="{% url 'cadmin_homework_submissions' course.slug hw.slug %}"
class="btn btn-sm btn-secondary">
Submissions
</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>No homework found for this course.</p>
{% endif %}
</div>
</div>

<!-- Project Section -->
<div class="card mb-4">
<div class="card-header">
<h3>Projects</h3>
</div>
<div class="card-body">
{% if projects %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Title</th>
<th>Submission Due</th>
<th>Review Due</th>
<th>State</th>
<th>Submissions</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for proj in projects %}
<tr>
<td>
<a href="{% url 'project' course.slug proj.slug %}">{{ proj.title }}</a>
</td>
<td>{{ proj.submission_due_date|date:"Y-m-d H:i" }}</td>
<td>{{ proj.peer_review_due_date|date:"Y-m-d H:i" }}</td>
<td>
{% if proj.state == 'CL' %}
<span class="badge badge-secondary">Closed</span>
{% elif proj.state == 'CS' %}
<span class="badge badge-success">Collecting</span>
{% elif proj.state == 'PR' %}
<span class="badge badge-warning">Peer Review</span>
{% elif proj.state == 'CO' %}
<span class="badge badge-primary">Completed</span>
{% else %}
<span class="badge badge-info">{{ proj.get_state_display }}</span>
{% endif %}
</td>
<td>
<a href="{% url 'cadmin_project_submissions' course.slug proj.slug %}">
{{ proj.submissions_count }}
</a>
</td>
<td>
<div class="btn-group" role="group">
<a href="{% url 'cadmin_project_assign_reviews' course.slug proj.slug %}"
class="btn btn-sm btn-warning"
onclick="return confirm('Assign peer reviews for {{ proj.title }}?')">
Assign Reviews
</a>
<a href="{% url 'cadmin_project_score' course.slug proj.slug %}"
class="btn btn-sm btn-primary"
onclick="return confirm('Score project {{ proj.title }}?')">
Score
</a>
<a href="{% url 'project_statistics' course.slug proj.slug %}"
class="btn btn-sm btn-info">
Stats
</a>
<a href="{% url 'cadmin_project_submissions' course.slug proj.slug %}"
class="btn btn-sm btn-secondary">
Submissions
</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>No projects found for this course.</p>
{% endif %}
</div>
</div>
{% endblock %}
61 changes: 61 additions & 0 deletions cadmin/templates/cadmin/course_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{% extends 'base.html' %}

{% block breadcrumbs %}
<li><a href="{% url 'cadmin_course_list' %}">Course Admin</a></li>
{% endblock %}

{% block content %}
<h2>Course Administration</h2>

<div class="alert alert-info" role="alert">
This is the admin panel for managing courses. Only staff members can access this area.
</div>

<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Course</th>
<th>Visible</th>
<th>Finished</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for course in courses %}
<tr>
<td>
<a href="{% url 'cadmin_course' course.slug %}">{{ course.title }}</a>
</td>
<td>
{% if course.visible %}
<span class="badge badge-success">Yes</span>
{% else %}
<span class="badge badge-secondary">No</span>
{% endif %}
</td>
<td>
{% if course.finished %}
<span class="badge badge-info">Yes</span>
{% else %}
<span class="badge badge-warning">No</span>
{% endif %}
</td>
<td>
<a href="{% url 'cadmin_course' course.slug %}" class="btn btn-sm btn-primary">
Manage
</a>
<a href="{% url 'course' course.slug %}" class="btn btn-sm btn-secondary">
View
</a>
</td>
</tr>
{% empty %}
<tr>
<td colspan="4" class="text-center">No courses found</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
69 changes: 69 additions & 0 deletions cadmin/templates/cadmin/homework_submissions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{% extends 'base.html' %}

{% load custom_filters %}

{% block breadcrumbs %}
<li><a href="{% url 'cadmin_course_list' %}">Course Admin</a></li>
<li><a href="{% url 'cadmin_course' course.slug %}">{{ course.title }}</a></li>
<li><a href="{% url 'cadmin_homework_submissions' course.slug homework.slug %}">{{ homework.title }} Submissions</a></li>
{% endblock %}

{% block content %}
<h2>{{ homework.title }} - Submissions</h2>

<div class="mb-3">
<a href="{% url 'cadmin_course' course.slug %}" class="btn btn-secondary">Back to Course Admin</a>
<a href="{% url 'homework' course.slug homework.slug %}" class="btn btn-info">View Homework</a>
</div>

<div class="alert alert-info" role="alert">
<strong>Total Submissions:</strong> {{ submissions_data|length }}
</div>

{% if submissions_data %}
<div class="table-responsive">
<table class="table table-striped table-sm">
<thead>
<tr>
<th>Student</th>
<th>Email</th>
<th>Submitted At</th>
<th>Score</th>
{% for question in questions %}
<th>Q{{ forloop.counter }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for data in submissions_data %}
<tr>
<td>{{ data.submission.student.username }}</td>
<td>{{ data.submission.student.email }}</td>
<td>{{ data.submission.submitted_at|date:"Y-m-d H:i" }}</td>
<td>
{% if data.submission.total_score is not None %}
{{ data.submission.total_score }}
{% else %}
-
{% endif %}
</td>
{% for answer in data.answers %}
<td>
<span title="{{ answer }}">
{% if answer|length > 20 %}
{{ answer|slice:":20" }}...
{% else %}
{{ answer }}
{% endif %}
</span>
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p>No submissions yet.</p>
{% endif %}
{% endblock %}
Loading