Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tjcsl/tin into quiz-sub-l…
Browse files Browse the repository at this point in the history
…imit
  • Loading branch information
JasonGrace2282 committed Jan 10, 2025
2 parents 5541c5e + c594194 commit 88895da
Show file tree
Hide file tree
Showing 14 changed files with 391 additions and 246 deletions.
4 changes: 4 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 2019-02-18: Theo Ouzhinski: format python
1291f79ca376eaf4c6b6c934c8667097879155b7
# 2019-09-20: 2020jbeutner: format python
09a6716cdcdf046221aa01a34dac66561e3c5329
# 2019-09-22: 2020jbeutner: format python
31d71391d615987c98cb98498988ca689676f945
# 2019-11-23: 2020jbeutner: format python and js
809a2a7f778f276354f48d8564b8771b32c36836
2d08db35b47e3d969b181b8ce69e60d8c7cffe74
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
build:
if: github.repository == 'tjcsl/tin'
runs-on: ubuntu-latest

strategy:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
default_stages: [commit, push]
default_stages: [pre-commit, pre-push]
fail_fast: false
exclude: ^tin/(static/.*vendor|.*migrations)

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
name: validate python
Expand All @@ -19,7 +19,7 @@ repos:
- id: codespell
files: ^.*\.(py|md|rst)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.8.6
hooks:
- id: ruff
args: [ "--fix", "--exit-non-zero-on-fix" ]
Expand Down
483 changes: 259 additions & 224 deletions Pipfile.lock

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions docs/source/contributing/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,22 @@ Now you're all set! Try running the development server
Head on over to `http://127.0.0.1:8000 <http://127.0.0.1:8000>`_, and login
as ``admin`` and the password you just entered.



NixOS Setup
-----------
A ``flake.nix`` file is provided for NixOS users. To use it, first enable the redis service globally.
Place the following in your ``/etc/nixos/configuration.nix``::

services.redis.server."".enable = true

This will start a systemd service called ``redis``. After that, you can start the flake with::

nix develop

You can then install dependencies, setup the database, and run the development server as described above.

.. tip::

You may also need to set ``nix.settings.experimental-features = ["nix-command" "flakes"];`` in your ``configuration.nix``.
62 changes: 62 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
description = "A flake for running Tin";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachSystem flake-utils.lib.allSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.pyenv
pkgs.pipenv
pkgs.python3
];
};
});
}
10 changes: 5 additions & 5 deletions tin/apps/assignments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def show_view(request, assignment_id):
if query:
active_period = "query"
student_list = course.students.filter(full_name__icontains=query).order_by(
"periods", "last_name"
"last_name", "first_name"
)
elif course.period_set.exists():
if period == "":
Expand All @@ -117,18 +117,18 @@ def show_view(request, assignment_id):

if period == "all":
active_period = "all"
student_list = course.students.all().order_by("periods", "last_name")
student_list = course.students.all().order_by("last_name", "first_name")
elif period == "none":
active_period = "none"
student_list = []
else:
active_period = get_object_or_404(
Period.objects.filter(course=course), id=int(period)
)
student_list = active_period.students.all().order_by("last_name")
student_list = active_period.students.all().order_by("last_name", "first_name")
elif period == "all":
active_period = "all"
student_list = course.students.all().order_by("last_name")
student_list = course.students.all().order_by("last_name", "first_name")
else:
active_period = "none"
student_list = []
Expand Down Expand Up @@ -950,7 +950,7 @@ def scores_csv_view(request, assignment_id):
writer = csv.writer(response)
writer.writerow(["Name", "Username", "Period", "Raw Score", "Final Score", "Formatted Grade"])

for student in students.order_by("periods", "last_name"):
for student in students.order_by("periods", "last_name", "first_name"):
row = [student.full_name, student.username]
periods = ", ".join([p.name for p in student.periods.filter(course=assignment.course)])
row.append(periods)
Expand Down
2 changes: 1 addition & 1 deletion tin/apps/submissions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def points_possible(self):

@property
def point_override(self):
return sum(c.point_override for c in self.comments.all())
return sum(c.point_override for c in self.comments.all() if c.point_override)

@property
def points(self):
Expand Down
7 changes: 3 additions & 4 deletions tin/apps/submissions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import psutil
from django import http
from django.db.models import F, Q
from django.db.models import F
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
from django.utils.http import url_has_allowed_host_and_scheme
Expand Down Expand Up @@ -99,10 +99,9 @@ def kill_view(request, submission_id):
request: The request
submission_id: An instance of the :class:`.Submission` model
"""
submissions_editable = Submission.objects.filter(
Q(assignment__course__teacher=request.user) | Q(student=request.user)
submission = get_object_or_404(
Submission.objects.filter_visible(request.user), id=submission_id
)
submission = get_object_or_404(submissions_editable, id=submission_id)

if request.method == "POST":
submission.kill_requested = True
Expand Down
4 changes: 4 additions & 0 deletions tin/templates/assignments/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ <h2 style="border-top:1px solid lightgray;padding-top:15px;">Filter Submissions<
{% if assignment.is_quiz %}
<table id="submission-list" class="has-border">
<tr>
<th style="min-width:20px"></th>
<th style="min-width:125px">Student</th>
{% if not active_period.name %}
<th style="min-width:65px;">Period</th>
Expand All @@ -134,6 +135,7 @@ <h2 style="border-top:1px solid lightgray;padding-top:15px;">Filter Submissions<
</tr>
{% for student, period, latest_submission, graded_submission, ended, quiz_issues in students_and_submissions %}
<tr>
<td style="text-align: center">{{ forloop.counter }}</td>
<td><a href="{% url 'assignments:student_submission' assignment.id student.id %}">{{ student.full_name }}
({{ student.username }})</a></td>
{% if not active_period.name %}
Expand Down Expand Up @@ -162,6 +164,7 @@ <h2 style="border-top:1px solid lightgray;padding-top:15px;">Filter Submissions<
{% else %}
<table id="submission-list" class="has-border">
<tr>
<th style="min-width:20px"></th>
<th style="min-width:125px">Student</th>
{% if not active_period.name %}
<th style="min-width:65px;">Period</th>
Expand All @@ -175,6 +178,7 @@ <h2 style="border-top:1px solid lightgray;padding-top:15px;">Filter Submissions<
</tr>
{% for student, period, latest_submission, graded_submission, new_login, new_24 in students_and_submissions %}
<tr>
<td style="text-align:center">{{ forloop.counter }}</td>
<td><a href="{% url 'assignments:student_submission' assignment.id student.id %}">{{ student.full_name }}
({{ student.username }})</a></td>
{% if not active_period.name %}
Expand Down
10 changes: 4 additions & 6 deletions tin/templates/submissions/repr.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
{% else %}
<b>{{ submission.points | floatformat:"-3" }}</b> / {{ submission.points_possible | floatformat:"-3" }} ({{ submission.grade_percent_num | floatformat:"-2" }}%)
{% if submission.is_published %}
{% if submission.comments.count <= 0 or request.user.is_teacher or request.user.is_superuser %}
{% if submission.is_latest_publish %}
<i class="fa fa-star" style="color: red" data-toggle="tooltip" title="Published {{ submission.published_submission.date }}"></i>
{% else %}
<i class="fa fa-star-o" style="color: red" data-toggle="tooltip" title="Published {{ submission.published_submission.date }}"></i>
{% endif %}
{% if submission.is_latest_publish %}
<i class="fa fa-star" style="color: red" data-toggle="tooltip" title="Published {{ submission.published_submission.date }}"></i>
{% else %}
<i class="fa fa-star-o" style="color: red" data-toggle="tooltip" title="Published {{ submission.published_submission.date }}"></i>
{% endif %}
{% endif %}
{% if submission.last_run %}
Expand Down
4 changes: 2 additions & 2 deletions tin/tests/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from django.http import HttpResponse, HttpResponseRedirect

__all__ = (
"is_redirect",
"not_redirect",
"is_login_redirect",
"is_redirect",
"not_login_redirect",
"not_redirect",
)


Expand Down
2 changes: 1 addition & 1 deletion tin/tests/create_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.contrib.auth import get_user_model

__all__ = ("user_data", "add_users_to_database")
__all__ = ("add_users_to_database", "user_data")

# fmt: off
user_data = [
Expand Down

0 comments on commit 88895da

Please sign in to comment.