Skip to content

Commit

Permalink
add grader
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsm committed Nov 15, 2014
1 parent eae2a9d commit 8ee131e
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 116 deletions.
File renamed without changes.
File renamed without changes.
Binary file modified db.sqlite3
Binary file not shown.
1 change: 1 addition & 0 deletions p13.aux
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\relax
27 changes: 27 additions & 0 deletions p13.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
\documentclass[12pt,letterpaper,boxed]{hmcpset}
% set 1-inch margins in the document
\usepackage[margin=1in]{geometry}
\usepackage{marvosym}
\usepackage{MnSymbol,wasysym}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}
\usepackage{color}
\usepackage{enumerate}
\usepackage{tikz}
\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
% include this if you want to import graphics files with /includegraphics
\begin{document}
\begin{problem}[Shahriari 8.1.1][20]\\
\\
A coffee company was willing to pay \$1 for each person interviewed about his or her lieks and dislikes on types of cofee. Of the persons interviewed, 270 liked ground coffee, 200 liked instant coffee, 70 liked both, and 50 did not like either choice. What is the total amount of money the company had to pay?
\
\end{problem}
\begin{solution}

Sum all the people and subtract out the double counted people:
$$270+200+50-70 = \boxed{450}$$

\end{solution}
\end{document}
1 change: 1 addition & 0 deletions s13.aux
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\relax
22 changes: 22 additions & 0 deletions s13.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
\documentclass[12pt,letterpaper,boxed]{hmcpset}
% set 1-inch margins in the document
\usepackage[margin=1in]{geometry}
\usepackage{marvosym}
\usepackage{MnSymbol,wasysym}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}
\usepackage{color}
\usepackage{enumerate}
\usepackage{tikz}
\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
% include this if you want to import graphics files with /includegraphics
\begin{document}
\begin{solution}

Sum all the people and subtract out the double counted people:
$$270+200+50-70 = \boxed{450}$$

\end{solution}
\end{document}
8 changes: 2 additions & 6 deletions website/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=255)),
('due_date', models.DateTimeField()),
('points', models.IntegerField(null=True, blank=True)),
('received_submission', models.BooleanField(default=True)),
],
options={
},
Expand Down Expand Up @@ -59,12 +61,6 @@ class Migration(migrations.Migration):
},
bases=(models.Model,),
),
migrations.AddField(
model_name='submission',
name='student',
field=models.ForeignKey(to='website.UserProfile'),
preserve_default=True,
),
migrations.AddField(
model_name='problem',
name='graders',
Expand Down
26 changes: 0 additions & 26 deletions website/migrations/0002_auto_20141115_1202.py

This file was deleted.

20 changes: 0 additions & 20 deletions website/migrations/0003_auto_20141115_1229.py

This file was deleted.

18 changes: 0 additions & 18 deletions website/migrations/0004_remove_submission_student.py

This file was deleted.

48 changes: 17 additions & 31 deletions website/package_problems.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
from __future__ import print_function
from models import Assignment, Problem, Submission
import aggregator
import os

def problem_answer_pairings(asgt):
a_n = asgt.name
problem_pairings = {}

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}[" + asgt.problems[i].name + "][" + asgt.problems[i].points + r"]\\"
print(p_h, file=problem_file)
print(asgt.problems[i].content, file=problem_file)
print(r"\end{problem}", file=problem_file)

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

return problem_pairings


def problem_solution_file(problem):
name = problem.name
problem_file = open(name, 'a')
problem_file = open("p"+str(problem.pk) + aggregator.TEX_FILE, 'w')
aggregator.print_header(problem_file)
p_h = r"\begin{problem}[" + problem.name + "][" + problem.points + r"]\\"
print(r"\begin{document}",file=problem_file)
p_h = r"\begin{problem}[" + problem.name + "][" + str(problem.points) + r"]\\"
print(p_h, file=problem_file)
print(problem.content, file=problem_file)
print(problem.contents, file=problem_file)
print(r"\end{problem}", file=problem_file)
print(r"\begin{solution}", file=problem_file)
print(problem.solution, file=problem_file)
print(r"\end{solution}", file=problem_file)
print(r"\end{document}",file=problem_file)
print("pdflatex %s" % "p"+str(problem.pk) + aggregator.TEX_FILE)
problem_file.close()
os.system("pdflatex %s" % "p"+str(problem.pk) + aggregator.TEX_FILE)
os.system("mv p%s.pdf ./website/static/probs/" % problem.pk)


def submission_files(submission):
name = submission.problem.name
submission_file = open("SUBMISSION-" + name, 'a')
submission_file = open("s"+str(submission.pk) + aggregator.TEX_FILE, 'w')
aggregator.print_header(submission_file)
p_h = r"\begin{problem}[" + submission.problem.name + "][" + submission.problem.points + r"]\\"
print(p_h, file=submission_file)
print(submission.problem.content, file=submission_file)
print(r"\end{problem}", file=submission_file)
print(r"\begin{document}",file=submission_file)
print(r"\begin{solution}", file=submission_file)
print(submission.contents, file=submission_file)
print(r"\end{solution}", file=submission_file)
print(r"\end{solution}", file=submission_file)
print(r"\end{document}",file=submission_file)
submission_file.close()
os.system("pdflatex %s" % "s"+str(submission.pk) + aggregator.TEX_FILE)
os.system("mv s%s.pdf ./website/static/subs/" % submission.pk)
Binary file not shown.
Binary file added website/static/probs/p13.pdf
Binary file not shown.
Binary file added website/static/subs/s13.pdf
Binary file not shown.
6 changes: 2 additions & 4 deletions website/templates/grader.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
<div class = "row">
<div id = "picturecontainer">
<div class = "col-md-6" id="left">
<object data= {{problem_solution_pair_list_list[0][0][0]}}></object>
<object data= "/static/probs/p{{ problem }}.pdf"></object>
</div>
<div class = "col-md-6 " id="right">
<object data={{problem_solution_pair_list_list[0][0][1]}}></object>
<object data= "/static/subs/s{{ submission }}.pdf"></object>
</div>
</div>
</div>
Expand All @@ -56,8 +56,6 @@


</div>
{% endfor %}
{% endfor %}
{% endblock %}


17 changes: 6 additions & 11 deletions website/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,19 @@ def student(request):
if request.method == 'POST':
form = ProfessorUploadForm(request.POST, request.FILES)
if form.is_valid():
# process_student_file(request.FILES['file'])
process_student_file(request.FILES['file'])
return render(request, 'index.html', {'assignments': ass, 'form': form, 'success': "Submitted"})
else:
form = ProfessorUploadForm()

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

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)
sub = Submission.objects.all()[0]
package_problems.problem_solution_file(sub.problem)
package_problems.submission_files(sub)

return render(request, "grader.html", {'problem_solution_pair_list_list': list_of_list_of_problems})
return render(request, "grader.html", {'problem': sub.problem.pk, 'submission': sub.pk})


def process_prof_file(file):
Expand Down Expand Up @@ -96,7 +94,7 @@ def strip_solutions(asgt):

def process_student_file(file):
data = file.read()

print (data)
problem_locs = [m.end() for m in re.finditer("begin{problem}", data)]

for loc in problem_locs:
Expand All @@ -111,6 +109,3 @@ def process_student_file(file):
p = Problem.objects.get(name=s.name)
s.problem = p
s.save()

os.system("pdflatex %s" % asgt.pk + aggregator.TEX_FILE)
os.system("mv ./%s.pdf ./website/static/asgts/" % asgt.pk)

0 comments on commit 8ee131e

Please sign in to comment.