Commit 0f212cc8 by Vik Paruchuri

Fix course id passing, template rendering

parent 6b7ba379
...@@ -109,7 +109,7 @@ def _staff_grading(tab, user, course, active_page): ...@@ -109,7 +109,7 @@ def _staff_grading(tab, user, course, active_page):
link = reverse('staff_grading', args=[course.id]) link = reverse('staff_grading', args=[course.id])
tab_name = "Staff grading" tab_name = "Staff grading"
notifications = open_ended_notifications.staff_grading_notifications(course_id) notifications = open_ended_notifications.staff_grading_notifications(course)
pending_grading = notifications['pending_grading'] pending_grading = notifications['pending_grading']
img_path = notifications['img_path'] img_path = notifications['img_path']
...@@ -122,7 +122,7 @@ def _peer_grading(tab, user, course, active_page): ...@@ -122,7 +122,7 @@ def _peer_grading(tab, user, course, active_page):
link = reverse('peer_grading', args=[course.id]) link = reverse('peer_grading', args=[course.id])
tab_name = "Peer grading" tab_name = "Peer grading"
notifications = open_ended_notifications.peer_grading_notifications(course_id, user) notifications = open_ended_notifications.peer_grading_notifications(course, user)
pending_grading = notifications['pending_grading'] pending_grading = notifications['pending_grading']
img_path = notifications['img_path'] img_path = notifications['img_path']
...@@ -135,7 +135,7 @@ def _combined_open_ended_grading(tab, user, course, active_page): ...@@ -135,7 +135,7 @@ def _combined_open_ended_grading(tab, user, course, active_page):
link = reverse('open_ended_problems', args=[course.id]) link = reverse('open_ended_problems', args=[course.id])
tab_name = "Open Ended Questions" tab_name = "Open Ended Questions"
notifications = open_ended_notifications.combined_notifications(course_id, user) notifications = open_ended_notifications.combined_notifications(course, user)
pending_grading = notifications['pending_grading'] pending_grading = notifications['pending_grading']
img_path = notifications['img_path'] img_path = notifications['img_path']
......
...@@ -6,6 +6,10 @@ import json ...@@ -6,6 +6,10 @@ import json
from student.models import unique_id_for_user from student.models import unique_id_for_user
import open_ended_util import open_ended_util
from courseware.models import StudentModule from courseware.models import StudentModule
import logging
from courseware.access import has_access
log=logging.getLogger(__name__)
NOTIFICATION_TYPES = ( NOTIFICATION_TYPES = (
('student_needs_to_peer_grade', 'peer_grading', 'Peer Grading'), ('student_needs_to_peer_grade', 'peer_grading', 'Peer Grading'),
...@@ -13,10 +17,11 @@ NOTIFICATION_TYPES = ( ...@@ -13,10 +17,11 @@ NOTIFICATION_TYPES = (
('overall_need_to_check', 'open_ended_problems', 'Problems you have submitted') ('overall_need_to_check', 'open_ended_problems', 'Problems you have submitted')
) )
def staff_grading_notifications(course_id): def staff_grading_notifications(course):
staff_gs = StaffGradingService(settings.STAFF_GRADING_INTERFACE) staff_gs = StaffGradingService(settings.STAFF_GRADING_INTERFACE)
pending_grading=False pending_grading=False
img_path= "" img_path= ""
course_id = course.id
try: try:
notifications = json.loads(staff_gs.get_notifications(course_id)) notifications = json.loads(staff_gs.get_notifications(course_id))
if notifications['success']: if notifications['success']:
...@@ -24,6 +29,7 @@ def staff_grading_notifications(course_id): ...@@ -24,6 +29,7 @@ def staff_grading_notifications(course_id):
pending_grading=True pending_grading=True
except: except:
#Non catastrophic error, so no real action #Non catastrophic error, so no real action
notifications = {}
log.info("Problem with getting notifications from staff grading service.") log.info("Problem with getting notifications from staff grading service.")
if pending_grading: if pending_grading:
...@@ -31,10 +37,12 @@ def staff_grading_notifications(course_id): ...@@ -31,10 +37,12 @@ def staff_grading_notifications(course_id):
return {'pending_grading' : pending_grading, 'img_path' : img_path, 'response' : notifications} return {'pending_grading' : pending_grading, 'img_path' : img_path, 'response' : notifications}
def peer_grading_notifications(course_id, user): def peer_grading_notifications(course, user):
peer_gs = PeerGradingService(settings.PEER_GRADING_INTERFACE) peer_gs = PeerGradingService(settings.PEER_GRADING_INTERFACE)
pending_grading=False pending_grading=False
img_path= "" img_path= ""
course_id = course.id
try: try:
notifications = json.loads(peer_gs.get_notifications(course_id,unique_id_for_user(user))) notifications = json.loads(peer_gs.get_notifications(course_id,unique_id_for_user(user)))
if notifications['success']: if notifications['success']:
...@@ -42,6 +50,7 @@ def peer_grading_notifications(course_id, user): ...@@ -42,6 +50,7 @@ def peer_grading_notifications(course_id, user):
pending_grading=True pending_grading=True
except: except:
#Non catastrophic error, so no real action #Non catastrophic error, so no real action
notifications = {}
log.info("Problem with getting notifications from peer grading service.") log.info("Problem with getting notifications from peer grading service.")
if pending_grading: if pending_grading:
...@@ -49,14 +58,15 @@ def peer_grading_notifications(course_id, user): ...@@ -49,14 +58,15 @@ def peer_grading_notifications(course_id, user):
return {'pending_grading' : pending_grading, 'img_path' : img_path, 'response' : notifications} return {'pending_grading' : pending_grading, 'img_path' : img_path, 'response' : notifications}
def combined_notifications(course_id, user): def combined_notifications(course, user):
controller_url = open_ended_util.get_controller_url() controller_url = open_ended_util.get_controller_url()
controller_qs = ControllerQueryService(controller_url) controller_qs = ControllerQueryService(controller_url)
student_id = unique_id_for_user(user) student_id = unique_id_for_user(user)
user_is_staff = has_access(user, course, 'staff') user_is_staff = has_access(user, course, 'staff')
course_id = course.id
min_time_to_query = user.last_login min_time_to_query = user.last_login
last_module_seen = StudentModule.objects.all(student=user, course_id = course_id, modified__gt=min_time_to_query).values('modified').order_by('-modified')[0] last_module_seen = StudentModule.objects.filter(student=user, course_id = course_id, modified__gt=min_time_to_query).values('modified').order_by('-modified')[0]
last_time_viewed = last_module_seen['modified'] last_time_viewed = last_module_seen['modified']
pending_grading= False pending_grading= False
...@@ -69,6 +79,7 @@ def combined_notifications(course_id, user): ...@@ -69,6 +79,7 @@ def combined_notifications(course_id, user):
pending_grading=True pending_grading=True
except: except:
#Non catastrophic error, so no real action #Non catastrophic error, so no real action
notifications = {}
log.info("Problem with getting notifications from controller query service.") log.info("Problem with getting notifications from controller query service.")
if pending_grading: if pending_grading:
......
...@@ -165,10 +165,12 @@ def student_problem_list(request, course_id): ...@@ -165,10 +165,12 @@ def student_problem_list(request, course_id):
@cache_control(no_cache=True, no_store=True, must_revalidate=True) @cache_control(no_cache=True, no_store=True, must_revalidate=True)
def combined_notifications(request, course_id): def combined_notifications(request, course_id):
course = get_course_with_access(request.user, course_id, 'load')
user = request.user user = request.user
notifications = open_ended_notifications.combined_notifications(course_id, user) notifications = open_ended_notifications.combined_notifications(course, user)
response = notifications['response'] response = notifications['response']
notificaton_tuples=open_ended_notifications.NOTIFICATION_TYPES notification_tuples=open_ended_notifications.NOTIFICATION_TYPES
notification_list = [] notification_list = []
for response_num in xrange(0,len(notification_tuples)): for response_num in xrange(0,len(notification_tuples)):
...@@ -191,8 +193,11 @@ def combined_notifications(request, course_id): ...@@ -191,8 +193,11 @@ def combined_notifications(request, course_id):
combined_dict = { combined_dict = {
'error_text' : "", 'error_text' : "",
'notification_list' : notification_list, 'notification_list' : notification_list,
'course' : course,
} }
return combined_dict return render_to_response('open_ended_problems/combined_notifications.html',
combined_dict
)
...@@ -285,7 +285,7 @@ if settings.COURSEWARE_ENABLED: ...@@ -285,7 +285,7 @@ if settings.COURSEWARE_ENABLED:
# Open Ended problem list # Open Ended problem list
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/open_ended_problems$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/open_ended_problems$',
'open_ended_grading.views.student_problem_list', name='open_ended_problems'), 'open_ended_grading.views.student_problem_list', name='open_ended_problems'),
# Cohorts management # Cohorts management
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/cohorts$', url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/cohorts$',
'course_groups.views.list_cohorts', name="cohorts"), 'course_groups.views.list_cohorts', name="cohorts"),
...@@ -305,6 +305,9 @@ if settings.COURSEWARE_ENABLED: ...@@ -305,6 +305,9 @@ if settings.COURSEWARE_ENABLED:
'course_groups.views.debug_cohort_mgmt', 'course_groups.views.debug_cohort_mgmt',
name="debug_cohort_mgmt"), name="debug_cohort_mgmt"),
# Open Ended Notifications
url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/open_ended_notifications$',
'open_ended_grading.views.combined_notifications', name='open_ended_notifications'),
) )
# discussion forums live within courseware, so courseware must be enabled first # discussion forums live within courseware, so courseware must be enabled first
......
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