Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/wrobe0709/list unenrolled submissions #1128

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions server/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def assignment_stats(cid, aid):
return abort(401)

stats = Assignment.assignment_stats(assign.id)

submissions = [d for d in stats.pop('raw_data')]

pie_chart = pygal.Pie(half_pie=True, disable_xml_declaration=True,
Expand Down Expand Up @@ -1203,7 +1203,7 @@ def enrollment(cid):
students = current_course.get_students()
staff = current_course.get_staff()
lab_assistants = current_course.get_participants([LAB_ASSISTANT_ROLE])

return render_template('staff/course/enrollment/enrollment.html',
enrollments=students, staff=staff,
lab_assistants=lab_assistants,
Expand Down Expand Up @@ -1312,6 +1312,28 @@ def client(client_id):
return redirect(url_for(".clients"))
return render_template('staff/edit_client.html', client=client, form=form, courses=courses)

@admin.route("/course/<int:cid>/unenrolled", methods=['GET'])
@is_staff(course_arg='cid')
def unenrolled(cid):
courses, current_course = get_courses(cid)

unenrolled_submitters = []
staff = set(s.user for s in current_course.get_staff())
lab_assistants = set(l.user for l in current_course.get_participants([LAB_ASSISTANT_ROLE]))
students = set(e.user for e in current_course.get_students())

submissions = Backup.query.join(Backup.assignment).filter(Assignment.course_id == cid).all()
submissions = set(User.query.get(b.submitter_id) for b in submissions)

for s in submissions:
if s not in students and s not in staff and s not in lab_assistants:
unenrolled_submitters.append(s)

return render_template('staff/course/enrollment/enrollment.unenrolled.html',
current_course=current_course,
unenrolled_submitters=unenrolled_submitters,
title="Submitter")

################
# Student View #
################
Expand Down
6 changes: 3 additions & 3 deletions server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def assignment_stats(assign_id, detailed=True):
'active_groups': active_groups,
'percent_groups_active': active_groups/(stats['groups'] or 1)
})

if detailed:
stats.update({
'raw_data': data
Expand Down Expand Up @@ -590,10 +590,10 @@ def course_submissions(self, include_empty=True):
current_db = db.engine.name
if current_db != 'mysql':
return self.course_submissions_slow(include_empty=include_empty)

# Can only run the fast query on MySQL
submissions = []

stats = self.mysql_course_submissions_query()
keys = stats.keys()
for r in stats:
Expand Down
6 changes: 6 additions & 0 deletions server/templates/staff/course/course.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ <h3 class="box-title">Quick Links</h3>
Enrollment
</a>
</li>
<li>
<a href="{{ url_for('.unenrolled', cid=current_course.id) }}">
<i class="fa fa-user-o"></i>
Un-Enrolled Submitters
</a>
</li>
<li>
<a href="{{ url_for('.list_extensions', cid=current_course.id) }}">
<i class="fa fa-calendar"></i>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{% extends "staff/base.html" %}
{% import 'staff/_formhelpers.html' as forms %}

{% block title %} Un-Enrolled Submitters - {{ current_course.display_name_with_semester }}{% endblock %}

{% block main %}
<section class="content-header">
<h1>
{{ current_course.display_name_with_semester }} Un-Enrolled Submitters
<small>{{ current_course.offering }}</small>
</h1>
<ol class="breadcrumb">
<li><a href="{{ url_for(".course", cid=current_course.id) }}">
<i class="fa fa-university"></i> {{ current_course.offering }}
</a></li>
<li class="active"><a href="{{ url_for('.unenrolled', cid=current_course.id) }}">
<i class="fa fa-user-o"></i> Un-Enrolled Submitters</a>
</li>
</ol>
</section>
<section class="content">
{% include 'alerts.html' %}
<div class="row">
<div class="col-md-9 col-xs-12">
<div class="box">
<div class="box-header">
<h3 class="box-title"><span> {{ title }} </span></h3>
<div class="box-tools">
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fa fa-minus"></i>
</button>
</div>
</div>
</div>

<!-- /.box-header -->
<div class="box-body table-responsive no-padding table-loading" id="{{ title }}-list">
<table class="table table-hover">
<thead>
<th class="sort" data-sort="email">User</th>
<th class="sort" data-sort="sid">Name</th>
</thead>

<tbody class="list">
{% for unenrolled_submitter in unenrolled_submitters %}
<tr>
<td class="email">
<a href="{{ url_for('.student_view', cid=current_course.id, email=unenrolled_submitter.email) }}">
{{ unenrolled_submitter.email }}
</a>
</td>
<td class="sid">{{ unenrolled_submitter.name }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- /.box-body -->
<div class="box-footer">
<div class="pull-left">
<h5 class="box-title"><span> Total: {{ unenrolled_submitters | length }} </span></h5>
</div>
</div>

</div>
</div>
</div>

</section>
{% endblock %}
6 changes: 6 additions & 0 deletions tests/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,12 @@ def test_admin_enrollment(self):
self.assertTrue(self.course.offering in self.driver.page_source)
self.assertTrue('Export Roster' in self.driver.page_source)

def test_admin_enrollment_unenrolled(self):
self._login(role="admin")
self.page_load(self.get_server_url() + "/admin/course/1/unenrolled")
self.assertIn('Un-Enrolled', self.driver.title)
self.assertTrue(self.course.offering in self.driver.page_source)

def test_admin_student_overview(self):
self._login(role="admin")
self.page_load(self.get_server_url() + "/admin/course/1/{}".format(self.user1.email))
Expand Down