feat: activity details in class
This commit is contained in:
@@ -172,6 +172,7 @@ website_route_rules = [
|
||||
"to_route": "/classes/progress",
|
||||
},
|
||||
{"from_route": "/assignments/<assignment>", "to_route": "assignments/assignment"},
|
||||
{"from_route": "/quiz-result/<subname>", "to_route": "quiz_result/quiz_result"},
|
||||
]
|
||||
|
||||
website_redirects = [
|
||||
|
||||
@@ -77,14 +77,12 @@ def quiz_summary(quiz, results):
|
||||
result["question"] = frappe.db.get_value(
|
||||
"LMS Quiz Question", {"parent": quiz, "idx": result["question_index"]}, ["question"]
|
||||
)
|
||||
|
||||
print(result)
|
||||
for point in result["is_correct"]:
|
||||
correct = correct and point
|
||||
|
||||
result["result"] = "Right" if correct else "Wrong"
|
||||
result["is_correct"] = correct
|
||||
score += correct
|
||||
|
||||
del result["is_correct"]
|
||||
del result["question_index"]
|
||||
|
||||
frappe.get_doc(
|
||||
|
||||
@@ -7,33 +7,36 @@
|
||||
"field_order": [
|
||||
"question",
|
||||
"answer",
|
||||
"result"
|
||||
"is_correct"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "question",
|
||||
"fieldtype": "Text",
|
||||
"in_list_view": 1,
|
||||
"label": "Question"
|
||||
},
|
||||
{
|
||||
"fieldname": "result",
|
||||
"fieldtype": "Select",
|
||||
"in_list_view": 1,
|
||||
"label": "Result",
|
||||
"options": "Right\nWrong"
|
||||
"label": "Question",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "answer",
|
||||
"fieldtype": "Data",
|
||||
"in_list_view": 1,
|
||||
"label": "Users Response"
|
||||
"label": "Users Response",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"default": "0",
|
||||
"fieldname": "is_correct",
|
||||
"fieldtype": "Check",
|
||||
"in_list_view": 1,
|
||||
"label": "Is Correct",
|
||||
"read_only": 1
|
||||
}
|
||||
],
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2021-10-12 10:32:45.139121",
|
||||
"modified": "2022-11-24 11:15:45.931119",
|
||||
"modified_by": "Administrator",
|
||||
"module": "LMS",
|
||||
"name": "LMS Quiz Result",
|
||||
@@ -41,5 +44,6 @@
|
||||
"permissions": [],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
@@ -38,3 +38,4 @@ lms.patches.v0_0.set_member_in_progress #09-11-2022
|
||||
lms.patches.v0_0.convert_progress_to_float
|
||||
lms.patches.v0_0.add_pages_to_nav #11-11-2022
|
||||
lms.patches.v0_0.change_role_names
|
||||
lms.patches.v0_0.quiz_submission_result
|
||||
|
||||
10
lms/patches/v0_0/quiz_submission_result.py
Normal file
10
lms/patches/v0_0/quiz_submission_result.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("lms", "doctype", "lms_quiz_submission")
|
||||
frappe.reload_doc("lms", "doctype", "lms_quiz_result")
|
||||
results = frappe.get_all("LMS Quiz Result", fields=["name", "result"])
|
||||
|
||||
for result in results:
|
||||
value = 1 if result.result == "Right" else 0
|
||||
frappe.db.set_value("LMS Quiz Result", result.name, "is_correct", value)
|
||||
@@ -1874,6 +1874,7 @@ select {
|
||||
background-repeat: no-repeat;
|
||||
background-size: 0.75rem;
|
||||
padding-right: 2.5rem;
|
||||
text-align: left;
|
||||
-webkit-print-color-adjust: exact;
|
||||
}
|
||||
|
||||
|
||||
@@ -6012,7 +6012,7 @@
|
||||
if (isSelectElement(element)) {
|
||||
return new SelectElementContainer(context, element);
|
||||
}
|
||||
if (isTextareaElement(element)) {
|
||||
if (isElement(element)) {
|
||||
return new TextareaElementContainer(context, element);
|
||||
}
|
||||
if (isIFrameElement(element)) {
|
||||
|
||||
@@ -7,57 +7,69 @@
|
||||
{% block content %}
|
||||
<div class="common-page-style">
|
||||
<div class="container">
|
||||
<div class="common-card-style column-card">
|
||||
<div class="common-card-style column-card medium">
|
||||
<div class="course-home-headings"> {{ _("Assignment Grading") }} </div>
|
||||
<div class="medium w-50 mt-3">
|
||||
<a class="btn btn-secondary btn-sm" href="{{ assignment.assignment }}" target="_blank">
|
||||
{{ _("Open Attachment") }}
|
||||
</a>
|
||||
<select class="btn btn-secondary btn-sm ml-2 lms-menu" id="result" data-type="{{ assignment.status }}">
|
||||
<option selected> {{ _("Not Graded") }} </option>
|
||||
<option value="Pass"> {{ _("Pass") }} </option>
|
||||
<option value="Fail"> {{ _("Fail") }} </option>
|
||||
</select>
|
||||
{% set course_title = frappe.db.get_value("LMS Course", assignment.course, "title") %}
|
||||
{% set lesson_title = frappe.db.get_value("Course Lesson", assignment.lesson, "title") %}
|
||||
|
||||
<div class="mt-3">
|
||||
<span class="subheading">
|
||||
{{ _("Member") }}:
|
||||
</span>
|
||||
<span>
|
||||
{{ assignment.member_name }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
{% set course_title = frappe.db.get_value("LMS Course", assignment.course, "title") %}
|
||||
<span class="subheading">
|
||||
{{ _("Course") }}:
|
||||
</span>
|
||||
<span>
|
||||
{{ course_title }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
{% set lesson_title = frappe.db.get_value("Course Lesson", assignment.lesson, "title") %}
|
||||
<span class="subheading"> {{ _("Lesson") }}: </span>
|
||||
<span>
|
||||
{{ lesson_title }}
|
||||
</span>
|
||||
</div>
|
||||
<form class="register-form">
|
||||
|
||||
<div class="subheading mt-3"> {{ _("Comments") }}: </div>
|
||||
<div class="control-input-wrapper">
|
||||
<div class="control-input">
|
||||
<textarea type="text" class="input-with-feedback form-control" id="comments" spellcheck="false"
|
||||
autocomplete="off" placeholder="Comments">{% if assignment.comments %}{{ assignment.comments }}{% endif %}
|
||||
</textarea>
|
||||
<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 }}" readonly />
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label> {{ _("Course") }} </label>
|
||||
<input type="text" class="form-control" value="{{ course_title }}" 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 }}" 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" 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 assignment.comments %}{{ assignment.comments }}{% endif %}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="btn btn-primary btn-sm mt-3" id="save-assignment" data-assignment="{{ assignment.name }}">
|
||||
{{ _("Save") }}
|
||||
<div class="text-right form-padding">
|
||||
<a class="btn btn-secondary btn-md" href="{{ assignment.assignment }}" target="_blank">
|
||||
{{ _("Open Attachment") }}
|
||||
</a>
|
||||
<button class="btn btn-primary btn-md ml-2" id="save-assignment" data-assignment="{{ assignment.name }}">
|
||||
{{ _("Save") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -29,11 +29,17 @@ const set_result = () => {
|
||||
};
|
||||
|
||||
const save_assignment = (e) => {
|
||||
e.preventDefault();
|
||||
if (!["Pass", "Fail"].includes(this.result))
|
||||
frappe.throw({
|
||||
"title": __("Not Graded"),
|
||||
"message": __("Please grade the assignment.")
|
||||
})
|
||||
frappe.call({
|
||||
method: "lms.lms.doctype.lesson_assignment.lesson_assignment.grade_assignment",
|
||||
args: {
|
||||
name: $(e.currentTarget).data("assignment"),
|
||||
result: self.result,
|
||||
result: this.result,
|
||||
comments: $("#comments").val(),
|
||||
},
|
||||
callback: (data) => {
|
||||
@@ -41,6 +47,9 @@ const save_assignment = (e) => {
|
||||
message: __("Saved"),
|
||||
indicator: "green",
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.history.go(-2);
|
||||
}, 2000);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,7 +6,8 @@ from frappe import _
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
assignment = frappe.form_dict["assignment"]
|
||||
|
||||
print("assignment")
|
||||
print(assignment)
|
||||
if not has_course_moderator_role():
|
||||
message = "Only Moderators have access to this page."
|
||||
if frappe.session.user == "Guest":
|
||||
@@ -20,3 +21,4 @@ def get_context(context):
|
||||
["assignment", "comments", "status", "name", "member_name", "course", "lesson"],
|
||||
as_dict=True,
|
||||
)
|
||||
print("call twice")
|
||||
|
||||
@@ -247,6 +247,7 @@ const parse_options = () => {
|
||||
: add_icon(element, "minus-circle");
|
||||
}
|
||||
});
|
||||
console.log(answer, is_correct)
|
||||
return [answer, is_correct];
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ def get_context(context):
|
||||
["name", "title", "start_date", "end_date", "description"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
context.published_courses = frappe.get_all(
|
||||
"LMS Course", {"published": 1}, ["name", "title"]
|
||||
)
|
||||
|
||||
@@ -79,8 +79,8 @@
|
||||
{% set submission = frappe.db.get_value("LMS Quiz Submission", filters, ["score", "creation"], as_dict=True) %}
|
||||
{% set total_questions = frappe.db.count("LMS Quiz Question", {"parent": quiz.name}) %}
|
||||
|
||||
<tr class="">
|
||||
<td class="subheading vertically-center">
|
||||
<tr {% if has_submitted %} class="clickable-row" data-href="/quiz-submissions/{{ has_submitted }}" {% endif %}>
|
||||
<td class="{% if has_submitted %} subheading {% endif %} vertically-center">
|
||||
<svg class="icon icon-sm">
|
||||
<use href="#icon-quiz"></use>
|
||||
</svg>
|
||||
@@ -108,26 +108,28 @@
|
||||
{% set status = submission.status %}
|
||||
{% set color = "green" if status == "Pass" else "red" if status == "Fail" else "orange" %}
|
||||
|
||||
<tr>
|
||||
<td class="subheading vertically-center">
|
||||
<tr {% if has_submitted %} class="clickable-row" data-href="/assignments/{{ has_submitted }}" {% endif %}>
|
||||
<td class="{% if has_submitted %} subheading {% endif %} vertically-center">
|
||||
<svg class="icon icon-md">
|
||||
<use href="#icon-file"></use>
|
||||
</svg>
|
||||
{{ _("Assignment") }}</td>
|
||||
{{ _("Assignment") }}
|
||||
</td>
|
||||
|
||||
<td>{{ assignment.title }}</td>
|
||||
|
||||
{% if has_submitted %}
|
||||
<td>
|
||||
{% if status == "Not Graded" %}
|
||||
<a class="btn btn-secondary btn-sm" href="/assignments/{{ has_submitted }}"> {{ _("Grade") }} </a>
|
||||
{% else %}
|
||||
<div class="indicator-pill {{ color }}">
|
||||
{{ status }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
||||
<td>{{ frappe.utils.format_date(submission.creation, "medium") }}</td>
|
||||
|
||||
{% else %}
|
||||
<td>-</td>
|
||||
|
||||
<td>
|
||||
<div class="indicator-pill red">
|
||||
{{ _("Not Attempted") }}
|
||||
|
||||
33
lms/www/quiz_result/quiz_result.html
Normal file
33
lms/www/quiz_result/quiz_result.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{% extends "templates/base.html" %}
|
||||
{% block title %}
|
||||
{{ _("Quiz Submission") }}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="common-page-style">
|
||||
<div class="container">
|
||||
<div class="common-card-style column-card">
|
||||
<div class="course-home-headings">
|
||||
{{ _("Quiz Submission") }}
|
||||
</div>
|
||||
{% for question in questions %}
|
||||
<div>
|
||||
{{ question.question }}
|
||||
</div>
|
||||
{{ question.is_correct }}
|
||||
{{ question.answer }}
|
||||
{% for i in range(1,5) %}
|
||||
{% set num = frappe.utils.cstr(i) %}
|
||||
{% set option = question["option_" + num] %}
|
||||
{% if question["option_" + num] %}
|
||||
<div>
|
||||
{{ question["option_" + num] }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
17
lms/www/quiz_result/quiz_result.py
Normal file
17
lms/www/quiz_result/quiz_result.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import frappe
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
name = frappe.form_dict["subname"]
|
||||
|
||||
context.submission = frappe.db.get_value("LMS Quiz Submission", name, ["name", "quiz"], as_dict=1)
|
||||
|
||||
questions = frappe.get_all("LMS Quiz Result", {"parent": name}, ["question", "is_correct", "answer"])
|
||||
|
||||
for question in questions:
|
||||
options = frappe.db.get_value("LMS Quiz Question", {"question": question.question},
|
||||
["option_1", "option_2", "option_3", "option_4"], as_dict=1)
|
||||
question.update(options)
|
||||
question.answer = question.answer.split(",")
|
||||
|
||||
context.questions = questions
|
||||
Reference in New Issue
Block a user