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(
"Lesson Assignment",
{"lesson": lesson, "member": frappe.session.user},
["lesson", "member", "assignment"],
["lesson", "member", "assignment", "comments", "status"],
as_dict=True,
)
assignment.file_name = frappe.db.get_value(

View File

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

View File

@@ -20,7 +20,7 @@
"list_columns": [],
"login_required": 0,
"max_attachment_size": 0,
"modified": "2022-11-11 12:23:14.664297",
"modified": "2022-11-21 10:56:01.627821",
"modified_by": "Administrator",
"module": "LMS",
"name": "class",
@@ -56,7 +56,7 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0,
"reqd": 1,
"show_in_filter": 0
},
{
@@ -68,7 +68,7 @@
"max_length": 0,
"max_value": 0,
"read_only": 0,
"reqd": 0,
"reqd": 1,
"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="">
<h3> {{ _("Assignment") }} </h3>
<h2 class="mt-5 mb-8"> {{ _("Assignment") }} </h2>
<div class="my-3"> {{ _(question) }} </div>
<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>
<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="preview-work hide">
<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>
<div class="comments mt-3 hide">
<span class="subheading">
{{ _("Instructors Comments") }}:
</span>
<span class="comment"></span>
</div>
</div>
</div>

View File

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

View File

@@ -412,10 +412,24 @@ const fetch_assignments = () => {
callback: (data) => {
if (data.message) {
const assignment = data.message;
const status = assignment.status
let target = $(".attach-file");
target.addClass("hide");
target.siblings(".submit-work").addClass("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
.siblings(".preview-work")
.find("a")

View File

@@ -11,28 +11,7 @@
</a>
<div class="course-home-headings"> {{ _("All Classes") }} </div>
{% if classes %}
<div class="cards-parent">
{% 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>
{{ ClassCards(classes) }}
{% else %}
<div class="empty-state">
<img class="icon icon-xl" src="/assets/lms/icons/comment.svg">
@@ -45,3 +24,43 @@
</div>
</div>
{% 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 %}