diff --git a/server/controllers/admin.py b/server/controllers/admin.py index eb2bf4bba..c766d78bb 100644 --- a/server/controllers/admin.py +++ b/server/controllers/admin.py @@ -1437,9 +1437,22 @@ def client(client_id): # Student View # ################ -@admin.route("/course//") +@admin.route("/course//", methods=['GET', 'POST']) @is_staff(course_arg='cid') def student_view(cid, email): + + form = forms.EnrollmentForm() + if form.validate_on_submit(): + if form.email.data != email: + flash("You cannot change the user's email.", 'error') + else: + email, role = form.email.data, form.role.data + Enrollment.enroll_from_form(cid, form) + flash('Edited User Successfully', 'success') + else: + if form.is_submitted(): + flash('There is an issue with your request.', 'error') + courses, current_course = get_courses(cid) assignments = current_course.assignments @@ -1466,7 +1479,7 @@ def student_view(cid, email): return render_template('staff/student/overview.html', courses=courses, current_course=current_course, student=student, enrollment=enrollment, - assignments=assignments, moss_results=moss_results) + assignments=assignments, moss_results=moss_results, form=form) @admin.route("/course////timeline") @is_staff(course_arg='cid') diff --git a/server/templates/staff/student/overview.html b/server/templates/staff/student/overview.html index 109e93f5e..e170efaf7 100644 --- a/server/templates/staff/student/overview.html +++ b/server/templates/staff/student/overview.html @@ -1,5 +1,6 @@ {% extends "staff/base.html" %} {% import "_globalhelpers.html" as helpers %} +{% import 'staff/_formhelpers.html' as forms %} {% block title %} {{ student.identifier }} - {{ current_course.display_name_with_semester }}{% endblock %} @@ -96,6 +97,34 @@
{{ student.role | capitalize }}
{% endwith %} + + +
+
+

Edit Participant

+
+ +
+
+
+ + {% call forms.render_form(form, action_url=url_for('.student_view', cid=current_course.id, email=student.email), action_text='Submit', + class_='form') %} + {{ forms.render_field(form.name, label_visible=true, placeholder='Name', required="required", type='text', value=(student.name or "")) }} + {{ forms.render_field(form.email, label_visible=true, required="required", value=student.email, readonly="readonly") }} + {{ forms.render_field(form.sid, label_visible=true, placeholder='1234567', type='text', value=(enrollment.sid or "")) }} + {{ forms.render_field(form.secondary, label_visible=true, placeholder='cs61a-abc', type='text', value=(enrollment.class_account or "")) }} + {{ forms.render_field(form.section, label_visible=true, placeholder='', type='text', value=(enrollment.section or "")) }} + {{ forms.render_field(form.role, label_visible=true) }} + {% endcall %} +
+ + +
+ +