feat: assignment comments display

This commit is contained in:
Jannat Patel
2022-11-21 12:08:17 +05:30
parent 74210245cf
commit ed2fababff
8 changed files with 569 additions and 523 deletions

View File

@@ -44,7 +44,7 @@ def get_assignment(lesson):
assignment = frappe.db.get_value( assignment = frappe.db.get_value(
"Lesson Assignment", "Lesson Assignment",
{"lesson": lesson, "member": frappe.session.user}, {"lesson": lesson, "member": frappe.session.user},
["lesson", "member", "assignment"], ["lesson", "member", "assignment", "comments", "status"],
as_dict=True, as_dict=True,
) )
assignment.file_name = frappe.db.get_value( assignment.file_name = frappe.db.get_value(

View File

@@ -28,7 +28,8 @@
{ {
"fieldname": "end_date", "fieldname": "end_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "End Date" "label": "End Date",
"reqd": 1
}, },
{ {
"fieldname": "column_break_4", "fieldname": "column_break_4",
@@ -58,12 +59,13 @@
{ {
"fieldname": "start_date", "fieldname": "start_date",
"fieldtype": "Date", "fieldtype": "Date",
"label": "Start Date" "label": "Start Date",
"reqd": 1
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2022-11-14 17:08:03.206840", "modified": "2022-11-21 10:55:50.067225",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "LMS Class", "name": "LMS Class",

View File

@@ -20,7 +20,7 @@
"list_columns": [], "list_columns": [],
"login_required": 0, "login_required": 0,
"max_attachment_size": 0, "max_attachment_size": 0,
"modified": "2022-11-11 12:23:14.664297", "modified": "2022-11-21 10:56:01.627821",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "LMS", "module": "LMS",
"name": "class", "name": "class",
@@ -56,7 +56,7 @@
"max_length": 0, "max_length": 0,
"max_value": 0, "max_value": 0,
"read_only": 0, "read_only": 0,
"reqd": 0, "reqd": 1,
"show_in_filter": 0 "show_in_filter": 0
}, },
{ {
@@ -68,7 +68,7 @@
"max_length": 0, "max_length": 0,
"max_value": 0, "max_value": 0,
"read_only": 0, "read_only": 0,
"reqd": 0, "reqd": 1,
"show_in_filter": 0 "show_in_filter": 0
}, },
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,22 @@
<div class="form-group"> <div class="form-group">
<div class=""> <div class="">
<h3> {{ _("Assignment") }} </h3> <h2 class="mt-5 mb-8"> {{ _("Assignment") }} </h2>
<div class="my-3"> {{ _(question) }} </div> <div class="my-3"> {{ _(question) }} </div>
<div class="alert alert-info small"> <div class="alert alert-info small">
{{ _("Only files of type {0} will be accepted").format(file_type) }} {{ _("Only files of type {0} will be accepted.").format(file_type) }}
</div> </div>
<input class="btn btn-default btn-sm border attach-file" type="file" accept="{{ accept }}" /> <input class="btn btn-default btn-sm border attach-file" type="file" accept="{{ accept }}" />
<div class="btn btn-secondary ml-2 submit-work">{{ _("Submit") }}</div> <div class="btn btn-secondary ml-2 submit-work">{{ _("Submit") }}</div>
<div class="preview-work hide"> <div class="preview-work hide">
<a target="_blank"></a> <a target="_blank"></a>
<div class="assignment-status indicator-pill ml-3"></div>
<div class="btn btn-secondary btn-sm ml-2 clear-work">{{ _("Change") }}</div> <div class="btn btn-secondary btn-sm ml-2 clear-work">{{ _("Change") }}</div>
</div> </div>
<div class="comments mt-3 hide">
<span class="subheading">
{{ _("Instructors Comments") }}:
</span>
<span class="comment"></span>
</div>
</div> </div>
</div> </div>

View File

@@ -1,114 +1,117 @@
{% if attempts_exceeded %} {% if attempts_exceeded %}
<div class=""> <div class="">
<div class="font-weight-bold mb-4" style="font-size: var(--text-lg);">{{ quiz.title }}</div> <h2 class="mt-3">
<div class="alert alert-info medium mb-0"> {{ quiz.title }}
{{ _("You have already exceeded the maximum number of attempts allowed for this quiz.") }} </h2>
{{ _("Your latest score is {0}.").format(last_attempt_score) }} <div class="alert alert-info medium mb-0">
</div> {{ _("You have already exceeded the maximum number of attempts allowed for this quiz.") }}
{{ _("Your latest score is {0}.").format(last_attempt_score) }}
</div>
</div> </div>
{% else %} {% else %}
<div id="quiz-title" class="hide" data-name="{{ quiz.name }}" data-max-attempts="{{ quiz.max_attempts }}">
{{ quiz.title }}
</div>
<div class=""> <div class="">
<div id="start-banner"> <div id="start-banner">
<button class="btn btn-secondary btn-sm btn-start-quiz pull-right"> {{ _("Start the Quiz") }} </button> <button class="btn btn-secondary btn-sm btn-start-quiz pull-right">
{{ _("Start the Quiz") }}
</button>
<div class="font-weight-bold mb-5" style="font-size: var(--text-lg);"> {{ quiz.title }} </div> <h2 class="mt-3" id="quiz-title" data-name="{{ quiz.name }}" data-max-attempts="{{ quiz.max_attempts }}">
{{ quiz.title }}
</h2>
<div class="alert alert-info medium"> <div class="alert alert-info medium">
{{ _("This quiz consists of {0} questions.").format(quiz.questions | length) }} {{ _("This quiz consists of {0} questions.").format(quiz.questions | length) }}
</div> </div>
{% if quiz.max_attempts %} {% if quiz.max_attempts %}
{% set suffix = "times" if quiz.max_attempts > 1 else "time" %} {% set suffix = "times" if quiz.max_attempts > 1 else "time" %}
<div class="alert alert-info medium"> <div class="alert alert-info medium">
{{ _("This quiz can only be taken {0} {1}. If you attempt the quiz but leave the page before submitting, {{ _("This quiz can only be taken {0} {1}. If you attempt the quiz but leave the page before submitting,
the quiz will be automatically submitted.").format(quiz.max_attempts, suffix) }} the quiz will be automatically submitted.").format(quiz.max_attempts, suffix) }}
</div> </div>
{% endif %} {% endif %}
{% if quiz.time %} {% if quiz.time %}
<div class="alert alert-info medium"> <div class="alert alert-info medium">
{{ _("The quiz has a time limit. For each question you will be given {0} seconds.").format(quiz.time) }} {{ _("The quiz has a time limit. For each question you will be given {0} seconds.").format(quiz.time) }}
</div> </div>
{% endif %} {% endif %}
</div> </div>
<form id="quiz-form" class="hide"> <form id="quiz-form" class="hide">
<div class="questions"> <div class="questions">
{% for question in quiz.questions %} {% for question in quiz.questions %}
{% set instruction = _("Choose all answers that apply") if question.multiple else _("Choose 1 answer") %} {% set instruction = _("Choose all answers that apply") if question.multiple else _("Choose 1 answer") %}
<div class="question hide" <div class="question hide"
data-question="{{ question.question }}" data-multi="{{ question.multiple }}" data-qt-index="{{ loop.index }}"> data-question="{{ question.question }}" data-multi="{{ question.multiple }}" data-qt-index="{{ loop.index }}">
<div class="question-header"> <div class="question-header">
<div class="question-number">{{ loop.index }}. </div> <div class="question-number">{{ loop.index }}. </div>
<div class="question-text"> <div class="question-text">
{{ frappe.utils.md_to_html(question.question) }} {{ frappe.utils.md_to_html(question.question) }}
</div> </div>
<div class="small"> {{ instruction }} </div> <div class="small"> {{ instruction }} </div>
</div> </div>
{% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %} {% set options = [question.option_1, question.option_2, question.option_3, question.option_4] %}
{% for option in options %} {% for option in options %}
{% if option %} {% if option %}
<div class="mb-2"> <div class="mb-2">
<div class="custom-checkbox"> <div class="custom-checkbox">
<label class="quiz-label"> <label class="quiz-label">
<div class="course-meta font-weight-bold"> {{ convert_number_to_character(loop.index - 1) }}</div> <div class="course-meta font-weight-bold"> {{ convert_number_to_character(loop.index - 1) }}</div>
<input class="option" value="{{ option | urlencode }}" <input class="option" value="{{ option | urlencode }}"
data-correct="{{ question['is_correct_' + loop.index | string] }}" {% if question.multiple %} data-correct="{{ question['is_correct_' + loop.index | string] }}" {% if question.multiple %}
type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}> type="checkbox" {% else %} type="radio" name="{{ question.question | urlencode }}" {% endif %}>
<div class="option-text">{{ frappe.utils.md_to_html(option) }}</div> <div class="option-text">{{ frappe.utils.md_to_html(option) }}</div>
</label> </label>
</div> </div>
{% set explanation = question['explanation_' + loop.index | string] %} {% set explanation = question['explanation_' + loop.index | string] %}
{% if explanation %} {% if explanation %}
<small class="explanation ml-10 hide">{{ explanation }}</small> <small class="explanation ml-10 hide">{{ explanation }}</small>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<div class="quiz-footer"> <div class="quiz-footer">
<span class="font-weight-bold"> <span class="current-question">1</span> of {{ quiz.questions | length }}</span> <span class="font-weight-bold"> <span class="current-question">1</span> of {{ quiz.questions | length }}</span>
{% if quiz.time %} {% if quiz.time %}
<div class="progress timer w-75" data-time="{{ quiz.time }}"> <div class="progress timer w-75" data-time="{{ quiz.time }}">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" <div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0"
aria-valuemax="100"style="width:100%"> aria-valuemax="100"style="width:100%">
</div> </div>
</div> </div>
{% endif %} {% endif %}
<button class="button pull-right is-default" id="check" disabled> <button class="button pull-right is-default" id="check" disabled>
{{ _("Check") }} {{ _("Check") }}
</button> </button>
<div class="button is-secondary hide" id="next"> <div class="button is-secondary hide" id="next">
{{ _("Next Question") }} {{ _("Next Question") }}
</div> </div>
<div class="button is-secondary is-default hide" id="summary"> <div class="button is-secondary is-default hide" id="summary">
{{ _("Submit") }} {{ _("Submit") }}
</div> </div>
<small id="submission-message" class="font-weight-bold hide"> <small id="submission-message" class="font-weight-bold hide">
{{ _("Please join the course to submit the Quiz.") }} {{ _("Please join the course to submit the Quiz.") }}
</small> </small>
<div class="button is-secondary hide" id="try-again"> <div class="button is-secondary hide" id="try-again">
{{ _("Try Again") }} {{ _("Try Again") }}
</div> </div>
</div> </div>
</form> </form>
</div> </div>
{% endif %} {% endif %}

View File

@@ -412,10 +412,24 @@ const fetch_assignments = () => {
callback: (data) => { callback: (data) => {
if (data.message) { if (data.message) {
const assignment = data.message; const assignment = data.message;
const status = assignment.status
let target = $(".attach-file"); let target = $(".attach-file");
target.addClass("hide"); target.addClass("hide");
target.siblings(".submit-work").addClass("hide"); target.siblings(".submit-work").addClass("hide");
target.siblings(".preview-work").removeClass("hide"); target.siblings(".preview-work").removeClass("hide");
if(status != "Not Graded") {
let color = status == "Pass" ? "green": "red";
$(".assignment-status")
.removeClass("hide")
.addClass(color)
.text(data.message.status)
target.siblings(".alert").addClass("hide");
$(".clear-work").addClass("hide");
if (assignment.comments) {
$(".comments").removeClass("hide");
$(".comment").text(assignment.comments)
}
}
target target
.siblings(".preview-work") .siblings(".preview-work")
.find("a") .find("a")

View File

@@ -11,28 +11,7 @@
</a> </a>
<div class="course-home-headings"> {{ _("All Classes") }} </div> <div class="course-home-headings"> {{ _("All Classes") }} </div>
{% if classes %} {% if classes %}
<div class="cards-parent"> {{ ClassCards(classes) }}
{% for class in classes %}
<div class="common-card-style column-card">
<div class="course-card-title">
{{ class.title }}
</div>
<div class="medium">
{% if class.start_date %}
<span>
{{ frappe.utils.format_date(class.start_date, "medium") }} -
</span>
{% endif %}
{% if class.end_date %}
<span>
{{ frappe.utils.format_date(class.end_date, "medium") }}
</span>
{% endif %}
</div>
<a class="stretched-link" href="/classes/{{ class.name }}"></a>
</div>
{% endfor %}
</div>
{% else %} {% else %}
<div class="empty-state"> <div class="empty-state">
<img class="icon icon-xl" src="/assets/lms/icons/comment.svg"> <img class="icon icon-xl" src="/assets/lms/icons/comment.svg">
@@ -45,3 +24,43 @@
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% macro ClassCards(classes) %}
<div class="cards-parent">
{% for class in classes %}
{% set course_count = frappe.db.count("Class Course", {"parent": class.name}) %}
{% set student_count = frappe.db.count("Class Student", {"parent": class.name}) %}
<div class="common-card-style column-card">
<div class="text-muted small">
{% if course_count %}
<span>
{{ course_count }} {{ _("Courses") }}
</span>
{% endif %}
{% if student_count %}
<span class="ml-3">
{{ student_count }} {{ _("Students") }}
</span>
{% endif %}
</div>
<div class="course-card-title mb-4">
{{ class.title }}
</div>
<div class="">
<span>
{{ frappe.utils.format_date(class.start_date, "medium") }} -
</span>
<span>
{{ frappe.utils.format_date(class.end_date, "medium") }}
</span>
</div>
<a class="stretched-link" href="/classes/{{ class.name }}"></a>
</div>
{% endfor %}
</div>
{% endmacro %}