Refactor tab logic, start adding in combined notifications view
This commit is contained in:
@@ -21,13 +21,7 @@ from fs.errors import ResourceNotFoundError
|
||||
from courseware.access import has_access
|
||||
from static_replace import replace_urls
|
||||
|
||||
from open_ended_grading.peer_grading_service import PeerGradingService
|
||||
from open_ended_grading.staff_grading_service import StaffGradingService
|
||||
from open_ended_grading.controller_query_service import ControllerQueryService
|
||||
from open_ended_grading import open_ended_util
|
||||
from student.models import unique_id_for_user
|
||||
from models import StudentModule
|
||||
import datetime
|
||||
from open_ended_grading import open_ended_notifications
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -113,21 +107,8 @@ def _textbooks(tab, user, course, active_page):
|
||||
def _staff_grading(tab, user, course, active_page):
|
||||
if has_access(user, course, 'staff'):
|
||||
link = reverse('staff_grading', args=[course.id])
|
||||
staff_gs = StaffGradingService(settings.STAFF_GRADING_INTERFACE)
|
||||
pending_grading=False
|
||||
tab_name = "Staff grading"
|
||||
img_path= ""
|
||||
try:
|
||||
notifications = json.loads(staff_gs.get_notifications(course.id))
|
||||
if notifications['success']:
|
||||
if notifications['staff_needs_to_grade']:
|
||||
pending_grading=True
|
||||
except:
|
||||
#Non catastrophic error, so no real action
|
||||
log.info("Problem with getting notifications from staff grading service.")
|
||||
|
||||
if pending_grading:
|
||||
img_path = "/static/images/slider-handle.png"
|
||||
pending_grading, img_path = open_ended_notifications.staff_grading_notifications(course)
|
||||
|
||||
tab = [CourseTab(tab_name, link, active_page == "staff_grading", pending_grading, img_path)]
|
||||
return tab
|
||||
@@ -136,21 +117,8 @@ def _staff_grading(tab, user, course, active_page):
|
||||
def _peer_grading(tab, user, course, active_page):
|
||||
if user.is_authenticated():
|
||||
link = reverse('peer_grading', args=[course.id])
|
||||
peer_gs = PeerGradingService(settings.PEER_GRADING_INTERFACE)
|
||||
pending_grading=False
|
||||
tab_name = "Peer grading"
|
||||
img_path= ""
|
||||
try:
|
||||
notifications = json.loads(peer_gs.get_notifications(course.id,unique_id_for_user(user)))
|
||||
if notifications['success']:
|
||||
if notifications['student_needs_to_peer_grade']:
|
||||
pending_grading=True
|
||||
except:
|
||||
#Non catastrophic error, so no real action
|
||||
log.info("Problem with getting notifications from peer grading service.")
|
||||
|
||||
if pending_grading:
|
||||
img_path = "/static/images/slider-handle.png"
|
||||
pending_grading, img_path = open_ended_notifications.peer_grading_notifications(course, user)
|
||||
|
||||
tab = [CourseTab(tab_name, link, active_page == "peer_grading", pending_grading, img_path)]
|
||||
return tab
|
||||
@@ -159,31 +127,9 @@ def _peer_grading(tab, user, course, active_page):
|
||||
def _combined_open_ended_grading(tab, user, course, active_page):
|
||||
if user.is_authenticated:
|
||||
link = reverse('open_ended_problems', args=[course.id])
|
||||
|
||||
controller_url = open_ended_util.get_controller_url()
|
||||
controller_qs = ControllerQueryService(controller_url)
|
||||
student_id = unique_id_for_user(user)
|
||||
course_id = course.id
|
||||
user_is_staff = has_access(user, course, 'staff')
|
||||
|
||||
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_time_viewed = last_module_seen['modified']
|
||||
pending_grading= False
|
||||
tab_name = "Open Ended Questions"
|
||||
img_path= ""
|
||||
try:
|
||||
notifications = json.loads(controller_qs.get_notifications(course.id,student_id, user_is_staff, last_time_viewed))
|
||||
if notifications['success']:
|
||||
if notifications['overall_need_to_check']:
|
||||
pending_grading=True
|
||||
except:
|
||||
#Non catastrophic error, so no real action
|
||||
log.info("Problem with getting notifications from controller query service.")
|
||||
|
||||
if pending_grading:
|
||||
img_path = "/static/images/slider-handle.png"
|
||||
|
||||
pending_grading, img_path = open_ended_notifications.combined_notifications(course, user)
|
||||
|
||||
tab = [CourseTab(tab_name, link, active_page == "controller_query", pending_grading, img_path)]
|
||||
return tab
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
from django.conf import settings
|
||||
from staff_grading_service import StaffGradingService
|
||||
from peer_grading_service import PeerGradingService
|
||||
from open_ended_grading.controller_query_service import ControllerQueryService
|
||||
import json
|
||||
from student.models import unique_id_for_user
|
||||
import open_ended_util
|
||||
from courseware.models import StudentModule
|
||||
|
||||
def staff_grading_notifications(course):
|
||||
staff_gs = StaffGradingService(settings.STAFF_GRADING_INTERFACE)
|
||||
pending_grading=False
|
||||
img_path= ""
|
||||
try:
|
||||
notifications = json.loads(staff_gs.get_notifications(course.id))
|
||||
if notifications['success']:
|
||||
if notifications['staff_needs_to_grade']:
|
||||
pending_grading=True
|
||||
except:
|
||||
#Non catastrophic error, so no real action
|
||||
log.info("Problem with getting notifications from staff grading service.")
|
||||
|
||||
if pending_grading:
|
||||
img_path = "/static/images/slider-handle.png"
|
||||
|
||||
return pending_grading, img_path
|
||||
|
||||
def peer_grading_notifications(course, user):
|
||||
peer_gs = PeerGradingService(settings.PEER_GRADING_INTERFACE)
|
||||
pending_grading=False
|
||||
img_path= ""
|
||||
try:
|
||||
notifications = json.loads(peer_gs.get_notifications(course.id,unique_id_for_user(user)))
|
||||
if notifications['success']:
|
||||
if notifications['student_needs_to_peer_grade']:
|
||||
pending_grading=True
|
||||
except:
|
||||
#Non catastrophic error, so no real action
|
||||
log.info("Problem with getting notifications from peer grading service.")
|
||||
|
||||
if pending_grading:
|
||||
img_path = "/static/images/slider-handle.png"
|
||||
|
||||
return pending_grading, img_path
|
||||
|
||||
def combined_notifications(course, user):
|
||||
controller_url = open_ended_util.get_controller_url()
|
||||
controller_qs = ControllerQueryService(controller_url)
|
||||
student_id = unique_id_for_user(user)
|
||||
course_id = course.id
|
||||
user_is_staff = has_access(user, course, 'staff')
|
||||
|
||||
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_time_viewed = last_module_seen['modified']
|
||||
pending_grading= False
|
||||
|
||||
img_path= ""
|
||||
try:
|
||||
notifications = json.loads(controller_qs.get_notifications(course.id,student_id, user_is_staff, last_time_viewed))
|
||||
if notifications['success']:
|
||||
if notifications['overall_need_to_check']:
|
||||
pending_grading=True
|
||||
except:
|
||||
#Non catastrophic error, so no real action
|
||||
log.info("Problem with getting notifications from controller query service.")
|
||||
|
||||
if pending_grading:
|
||||
img_path = "/static/images/slider-handle.png"
|
||||
|
||||
return pending_grading, img_path
|
||||
@@ -21,7 +21,6 @@ from student.models import unique_id_for_user
|
||||
|
||||
import open_ended_util
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
template_imports = {'urllib': urllib}
|
||||
@@ -162,5 +161,8 @@ def student_problem_list(request, course_id):
|
||||
'error_text': error_text,
|
||||
# Checked above
|
||||
'staff_access': False, })
|
||||
|
||||
def combined_notifications(request, course_id):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<%inherit file="/main.html" />
|
||||
<%block name="bodyclass">${course.css_class}</%block>
|
||||
<%namespace name='static' file='/static_content.html'/>
|
||||
|
||||
<%block name="headextra">
|
||||
<%static:css group='course'/>
|
||||
</%block>
|
||||
|
||||
<%block name="title"><title>${course.number} Combined Notifications</title></%block>
|
||||
|
||||
<%include file="/courseware/course_navigation.html" args="active_page='combined_notifications'" />
|
||||
|
||||
|
||||
<section class="container">
|
||||
<div class="combined-notifications" data-ajax_url="${ajax_url}">
|
||||
<div class="error-container">${error_text}</div>
|
||||
<h1>Open Ended Console</h1>
|
||||
<h2>Instructions</h2>
|
||||
<p>Here are items that could potentially need your attention.</p>
|
||||
% if success:
|
||||
% if len(item_list) == 0:
|
||||
<div class="message-container">
|
||||
No items require attention at the moment.
|
||||
</div>
|
||||
%else:
|
||||
<ul class="notification-list">
|
||||
%for notification in notification_list:
|
||||
<li>
|
||||
<a href="${notification['url']}">
|
||||
{notification['name']}
|
||||
% if notification.has_img == True:
|
||||
<img src="${notification.img}"/>
|
||||
%endif
|
||||
</a>
|
||||
</li>
|
||||
%endfor
|
||||
</ul>
|
||||
%endif
|
||||
%endif
|
||||
</div>
|
||||
</section>
|
||||
Reference in New Issue
Block a user