Commit cbd0895a by Vik Paruchuri

Add in single peer grading problem view

parent c9f75f8b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
class @PeerGrading class @PeerGrading
constructor: (element) -> constructor: (element) ->
@peer_grading_container = $('.peer-grading') @peer_grading_container = $('.peer-grading')
@use_single_location = @peer_grading_container.data('use-single-location')
@peer_grading_outer_container = $('.peer-grading-container') @peer_grading_outer_container = $('.peer-grading-container')
@ajax_url = @peer_grading_container.data('ajax-url') @ajax_url = @peer_grading_container.data('ajax-url')
@error_container = $('.error-container') @error_container = $('.error-container')
...@@ -19,6 +20,9 @@ class @PeerGrading ...@@ -19,6 +20,9 @@ class @PeerGrading
@problem_list = $('.problem-list') @problem_list = $('.problem-list')
@construct_progress_bar() @construct_progress_bar()
if @use_single_location
@activate_problem()
construct_progress_bar: () => construct_progress_bar: () =>
problems = @problem_list.find('tr').next() problems = @problem_list.find('tr').next()
problems.each( (index, element) => problems.each( (index, element) =>
...@@ -38,4 +42,8 @@ class @PeerGrading ...@@ -38,4 +42,8 @@ class @PeerGrading
backend = new PeerGradingProblemBackend(@ajax_url, false) backend = new PeerGradingProblemBackend(@ajax_url, false)
new PeerGradingProblem(backend) new PeerGradingProblem(backend)
else else
@gentle_alert response.error @gentle_alert response.error
\ No newline at end of file
activate_problem: () =>
backend = new PeerGradingProblemBackend(@ajax_url, false)
new PeerGradingProblem(backend)
\ No newline at end of file
...@@ -41,7 +41,7 @@ USE_FOR_SINGLE_LOCATION = False ...@@ -41,7 +41,7 @@ USE_FOR_SINGLE_LOCATION = False
LINK_TO_LOCATION = "" LINK_TO_LOCATION = ""
TRUE_DICT = [True, "True", "true", "TRUE"] TRUE_DICT = [True, "True", "true", "TRUE"]
MAX_SCORE = 1 MAX_SCORE = 1
IS_GRADED = True
class PeerGradingModule(XModule): class PeerGradingModule(XModule):
_VERSION = 1 _VERSION = 1
...@@ -71,10 +71,14 @@ class PeerGradingModule(XModule): ...@@ -71,10 +71,14 @@ class PeerGradingModule(XModule):
self.system = system self.system = system
self.peer_gs = peer_grading_service(self.system) self.peer_gs = peer_grading_service(self.system)
self.use_for_single_location = self.metadata.get('use_for_single_location', use_for_single_location) self.use_for_single_location = self.metadata.get('use_for_single_location', USE_FOR_SINGLE_LOCATION)
if isinstance(self.use_for_single_location, basestring): if isinstance(self.use_for_single_location, basestring):
self.use_for_single_location = (self.use_for_single_location in TRUE_DICT) self.use_for_single_location = (self.use_for_single_location in TRUE_DICT)
self.is_graded = self.metadata.get('is_graded', IS_GRADED)
if isinstance(self.is_graded, basestring):
self.is_graded = (self.is_graded in TRUE_DICT)
self.link_to_location = self.metadata.get('link_to_location', USE_FOR_SINGLE_LOCATION) self.link_to_location = self.metadata.get('link_to_location', USE_FOR_SINGLE_LOCATION)
if self.use_for_single_location ==True: if self.use_for_single_location ==True:
#This will raise an exception if the location is invalid #This will raise an exception if the location is invalid
...@@ -85,10 +89,10 @@ class PeerGradingModule(XModule): ...@@ -85,10 +89,10 @@ class PeerGradingModule(XModule):
self.ajax_url = self.ajax_url + "/" self.ajax_url = self.ajax_url + "/"
self.student_data_for_location = instance_state.get('student_data_for_location', {}) self.student_data_for_location = instance_state.get('student_data_for_location', {})
self.max_score = instance_state.get('max_score', MAX_SCORE) self.max_grade = instance_state.get('max_grade', MAX_SCORE)
if not isinstance(self.max_score, (int, long)): if not isinstance(self.max_grade, (int, long)):
#This could result in an exception, but not wrapping in a try catch block so it moves up the stack #This could result in an exception, but not wrapping in a try catch block so it moves up the stack
self.max_score = int(self.max_score) self.max_grade = int(self.max_grade)
def _err_response(self, msg): def _err_response(self, msg):
""" """
...@@ -112,7 +116,7 @@ class PeerGradingModule(XModule): ...@@ -112,7 +116,7 @@ class PeerGradingModule(XModule):
if not self.use_for_single_location: if not self.use_for_single_location:
return self.peer_grading() return self.peer_grading()
else: else:
return self.peer_grading_problem({'location' : self.link_to_location}) return self.peer_grading_problem({'location' : self.link_to_location})['html']
def handle_ajax(self, dispatch, get): def handle_ajax(self, dispatch, get):
""" """
...@@ -142,7 +146,7 @@ class PeerGradingModule(XModule): ...@@ -142,7 +146,7 @@ class PeerGradingModule(XModule):
response = {} response = {}
try: try:
response = self.peer_gs.get_data_for_location(location, grader_id) response = self.peer_gs.get_data_for_location(location, student_id)
count_graded = response['count_graded'] count_graded = response['count_graded']
count_required = response['count_required'] count_required = response['count_required']
success = True success = True
...@@ -156,7 +160,7 @@ class PeerGradingModule(XModule): ...@@ -156,7 +160,7 @@ class PeerGradingModule(XModule):
pass pass
def get_score(self): def get_score(self):
if not self.use_for_single_location: if not self.use_for_single_location or not self.is_graded:
return None return None
try: try:
...@@ -176,7 +180,7 @@ class PeerGradingModule(XModule): ...@@ -176,7 +180,7 @@ class PeerGradingModule(XModule):
score_dict = { score_dict = {
'score': int(count_graded>=count_required), 'score': int(count_graded>=count_required),
'total': self.max_score, 'total': self.max_grade,
} }
return score_dict return score_dict
...@@ -187,10 +191,10 @@ class PeerGradingModule(XModule): ...@@ -187,10 +191,10 @@ class PeerGradingModule(XModule):
* This is generic; in abstract, a problem could be 3/5 points on one * This is generic; in abstract, a problem could be 3/5 points on one
randomization, and 5/7 on another randomization, and 5/7 on another
''' '''
max_score = None max_grade = None
if self.use_for_single_location: if self.use_for_single_location and self.is_graded:
max_score = self.max_score max_grade = self.max_grade
return max_score return max_grade
def get_next_submission(self, get): def get_next_submission(self, get):
""" """
...@@ -430,7 +434,9 @@ class PeerGradingModule(XModule): ...@@ -430,7 +434,9 @@ class PeerGradingModule(XModule):
'problem_list': problem_list, 'problem_list': problem_list,
'error_text': error_text, 'error_text': error_text,
# Checked above # Checked above
'staff_access': False, }) 'staff_access': False,
'use_single_location' : self.use_for_single_location,
})
return html return html
...@@ -438,12 +444,14 @@ class PeerGradingModule(XModule): ...@@ -438,12 +444,14 @@ class PeerGradingModule(XModule):
''' '''
Show individual problem interface Show individual problem interface
''' '''
if get == None: if get == None or get.get('location')==None:
problem_location = self.system.location if not self.use_for_single_location:
#This is an error case, because it must be set to use a single location to be called without get parameters
return {'html' : "", 'success' : False}
problem_location = self.link_to_location
elif get.get('location') is not None: elif get.get('location') is not None:
problem_location = get.get('location') problem_location = get.get('location')
else:
problem_location = self.system.location
ajax_url = self.ajax_url ajax_url = self.ajax_url
html = self.system.render_template('peer_grading/peer_grading_problem.html', { html = self.system.render_template('peer_grading/peer_grading_problem.html', {
...@@ -452,7 +460,9 @@ class PeerGradingModule(XModule): ...@@ -452,7 +460,9 @@ class PeerGradingModule(XModule):
'course_id': self.system.course_id, 'course_id': self.system.course_id,
'ajax_url': ajax_url, 'ajax_url': ajax_url,
# Checked above # Checked above
'staff_access': False, }) 'staff_access': False,
'use_single_location' : self.use_for_single_location,
})
return {'html' : html, 'success' : True} return {'html' : html, 'success' : True}
......
<section class="container peer-grading-container"> <section class="container peer-grading-container">
<div class="peer-grading" data-ajax-url="${ajax_url}"> <div class="peer-grading" data-ajax-url="${ajax_url}" data-use-single-location="${use_single_location}">
<div class="error-container">${error_text}</div> <div class="error-container">${error_text}</div>
<h1>Peer Grading</h1> <h1>Peer Grading</h1>
<h2>Instructions</h2> <h2>Instructions</h2>
......
<section class="container peer-grading-container"> <section class="container peer-grading-container">
<div class="peer-grading" data-ajax-url="${ajax_url}" data-location="${problem_location}"> <div class="peer-grading" data-ajax-url="${ajax_url}" data-location="${problem_location}" data-use-single-location="${use_single_location}">
<div class="error-container"></div> <div class="error-container"></div>
<section class="content-panel"> <section class="content-panel">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment