{% extends "templates/base.html" %}
{% block title %}
	{{ _("Assignments") }}
{% endblock %}


{% block content %}
<div class="common-page-style">
	<div class="container">
		<div class="common-card-style column-card medium">
			<div class="course-home-headings"> {{ _("Assignment Grading") }} </div>
			{{ AssignmentForm(assignment) }}
		</div>
	</div>
</div>

{% endblock %}


{% macro AssignmentForm(assignment) %}
{% set course_title = frappe.db.get_value("LMS Course", assignment.course, "title") %}
{% set lesson_title = frappe.db.get_value("Course Lesson", assignment.lesson, "title") %}

<form class="register-form">

	<div class="form-padding">
		<div class="form-row">
			<div class="form-group col-md-6">
				<label> {{ _("Member") }} </label>
				<input type="text" class="form-control" value="{{ assignment.member_name }}" disabled readonly />
			</div>
			<div class="form-group col-md-6">
				<label> {{ _("Course") }} </label>
				<input type="text" class="form-control" value="{{ course_title }}" disabled readonly />
			</div>
		</div>

		<div class="form-row">
			<div class="col-md-6">
				<div class="form-group">
					<label> {{ _("Lesson") }} </label>
					<input type="text" class="form-control" value="{{ lesson_title }}" disabled readonly />
				</div>

				<div class="form-group">
					<label> {{ _("Result") }} </label>
					<div class="control-input flex align-center form-control">
						<select class="input-with-feedback form-control pl-0" id="result"
						{% if not is_moderator %} disabled {% endif %} data-type="{{ assignment.status }}">
							<option selected> {{ _("Not Graded") }} </option>
							<option value="Pass"> {{ _("Pass") }} </option>
							<option value="Fail"> {{ _("Fail") }} </option>
						</select>
						<div class="select-icon">
							<svg class="icon icon-sm">
								<use class="" href="#icon-select"></use>
							</svg>
						</div>
					</div>
				</div>
			</div>

			<div class="form-group col-md-6">
				<label>{{ _("Comments") }}</label>
				<textarea class="form-control" id="comments" {% if not is_moderator %} disabled readonly {% endif %}
				>{% if assignment.comments %}{{ assignment.comments }}{% endif %}</textarea>
			</div>
		</div>
	</div>

	<div class="text-right form-padding">
		<a class="btn btn-secondary btn-sm"	href="{{ assignment.assignment }}" target="_blank">
			{{ _("Open Attachment") }}
		</a>
		  <button class="btn btn-primary btn-sm ml-2" id="save-assignment" data-assignment="{{ assignment.name }}">
			{{ _("Save") }}
		</button>
	</div>
</form>
{% endmacro %}
