Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pushkar/peer
Browse files Browse the repository at this point in the history
  • Loading branch information
Pushkar Kolhe committed Sep 27, 2019
2 parents 03bb73b + 5caf808 commit b3d54ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
15 changes: 15 additions & 0 deletions assignment/iosolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

log = logging.getLogger(__name__)


def check_deadline(a):
''' Checks if the deadline has passed or not
:returns: True if deadline is not passed
Expand All @@ -20,6 +21,7 @@ def check_deadline(a):
else:
return False


def get(s, a, n):
''' Generates an IO pair for a student
For each student s and assignment a, create n examples of IO pairs.
Expand Down Expand Up @@ -53,6 +55,7 @@ def get(s, a, n):

return IOSolution.objects.filter(student=s, assignment=a)


def get_by_student(s, solutions=None):
''' Filters IOSolution objects for student s
:param s: Student
Expand All @@ -63,6 +66,7 @@ def get_by_student(s, solutions=None):

return IOSolution.objects.filter(student=s)


def get_by_assignment(a, solutions=None):
''' Filters IOSolution objects for assignment a
:param a: Assignment
Expand All @@ -73,6 +77,7 @@ def get_by_assignment(a, solutions=None):

return IOSolution.objects.filter(assignment=a)


def get_by_assignment_scores(a):
''' Filters IOSolution objects for assignment a
:param a: Assignment
Expand All @@ -87,6 +92,7 @@ def get_by_assignment_scores(a):
scores[sol.student] += sol.score
return scores


def sol_to_dict(sol):
d = {
'id': sol.id,
Expand All @@ -111,6 +117,7 @@ def sol_to_dict(sol):
}
return d


def get_by_assignment_all(a):
""" Filters IOSolution objects for assignment a
:param a: Assignment
Expand All @@ -128,19 +135,23 @@ def get_by_assignment_all(a):
def get_none():
return IOSolution.objects.none()


def get_by(s, a):
return IOSolution.objects.filter(student=s, assignment=a)


def get_by_id(pk):
solution = IOSolution.objects.filter(pk=pk)
if len(solution) > 1:
log.error("Found more than 1 solution")
return solution


def get_by_id_all(pk):
sol = IOSolution.objects.filter(pk=pk)
return sol_to_dict(sol[0])


def update(solution, output=None, submit_late="false"):
try:
solution = solution[0]
Expand All @@ -159,6 +170,7 @@ def update(solution, output=None, submit_late="false"):
except Exception as e:
return "Exception: %s" % (e)


def check(solutions):
for s in solutions:
a_name = s.assignment.short_name
Expand All @@ -172,9 +184,12 @@ def check(solutions):
hw_check.check_bar_brawl(s)
elif a_name == "game":
hw_check.check_game_theory(s)
elif a_name == "sarsa":
hw_check.check_bar_brawl(s)
else:
hw_check.check_floating_point_answer(s)


def get_stats(solutions):
stats = {}
stats['total'] = 0.0
Expand Down
9 changes: 0 additions & 9 deletions peer/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,11 @@
admin.autodiscover()

urlpatterns = [
# url(r'^student/', 'student', name='student'),

# url(r'^student/', include('student.urls', namespace="student")),
# url(r'^assignment/', include('assignment.urls', namespace="assignment")),



path('', views.index, name='index'),
path('student/', include('student.urls')),
path('assignment/', include('assignment.urls')),
path('api/', include('api.urls')),
path('admin/', admin.site.urls),
path('static/<slug:path>', static_views.serve),

# path('exam/', include('exam.urls')),

]
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Django==2.2.5
dj-database-url>=0.5.0
dj-static>=0.0.6
gunicorn==19.3.0
gunicorn==19.5.0
psycopg2-binary
static3
requests>=2.13.0
Expand Down

0 comments on commit b3d54ae

Please sign in to comment.