Skip to content

Commit

Permalink
added grader view
Browse files Browse the repository at this point in the history
  • Loading branch information
nhurwitz committed Nov 15, 2014
1 parent 8305624 commit 2539f45
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
16 changes: 11 additions & 5 deletions website/package_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
def problem_answer_pairings(asgt):
a_n = asgt.name
problem_pairings = {}
for p in asgt.problems.all:
name = p.name

for i in range(0, asgt.problems.count()):
name = asgt.problems[i].name
problem_file = open(a_n + "-" + name, 'a')
aggregator.print_header(problem_file)
p_h = r"\begin{problem}[" + p.name + "][" + p.points + r"]\\"
p_h = r"\begin{problem}[" + asgt.problems[i].name + "][" + asgt.problems[i].points + r"]\\"
print(p_h, file=problem_file)
print(p.content, file=problem_file)
print(asgt.problems[i].content, file=problem_file)
print(r"\end{problem}", file=problem_file)
problem_pairings.append(problem_file)

solution_file = open("SOLUTIONS" + "-" + a_n + "-" + name, 'a')
print(r"\begin{solution}", file=solution_file)
print(asgt.problems[i].solution)
print(r"\end{solution}", file=solution_file)
problem_pairings.append(problem_file, solution_file)

return problem_pairings
29 changes: 8 additions & 21 deletions website/templates/grader.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DibTeX</title>
<!-- Bootstrap -->
<link href="../static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../static/css/grader.css" rel="stylesheet">
{% extends "base.html" %}

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
{% block title %}test{% endblock %}

{% block content %}

{% for assignment in assignments %}
<div class = "bg">
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
Expand Down Expand Up @@ -53,10 +41,10 @@
<div class = "row">
<div id = "picturecontainer">
<div class = "col-md-6" id="left">
<object data="../static/css/casgt01.pdf"></object>
<object data= {{solutions}}></object>
</div>
<div class = "col-md-6 " id="right">
<object data="../static/css/casgt09.pdf"></object>
<object data={{submission}}></object>
</div>
</div>
</div>
Expand All @@ -69,7 +57,6 @@


</div>
</body>
</html>
{% endblock %}


10 changes: 10 additions & 0 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import aggregator
from website.models import Assignment, Problem
import package_problems

def professor(request):
if request.method == 'POST':
Expand All @@ -29,6 +30,15 @@ def student(request):

return render(request, "index.html", {'assignments': ass})

def grader(request):
ass = Assignment.objects.all()
list_of_list_of_problems = {}
for a in ass:
problems = package_problems.problem_answer_pairings(a)
list_of_list_of_problems.append(problems)

return render(request, "grader.html", {'problem_solution_pair_list': list_of_list_of_problems})


def process_prof_file(file):
data = file.read()
Expand Down

0 comments on commit 2539f45

Please sign in to comment.