Compare commits
92 Commits
less
...
gitignore-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
573019bbcc | ||
|
|
f1b3ee19b6 | ||
|
|
9cb9fad05c | ||
|
|
0859afdf34 | ||
|
|
6407b24324 | ||
|
|
34e993cf86 | ||
|
|
8c889ffb92 | ||
|
|
a67ad67be1 | ||
|
|
646a7b723f | ||
|
|
6f7011ca58 | ||
|
|
d61acb552a | ||
|
|
265c78e76e | ||
|
|
7d180e141c | ||
|
|
29f9141ad8 | ||
|
|
e6f58f56e0 | ||
|
|
9e0476fd00 | ||
|
|
d9ea02667d | ||
|
|
bdabf32124 | ||
|
|
8b657f2f40 | ||
|
|
49b41749e8 | ||
|
|
1cf57c4823 | ||
|
|
5cfb72a731 | ||
|
|
49d5ca4292 | ||
|
|
a3e53efcc1 | ||
|
|
be7814b4fe | ||
|
|
c40ab9a726 | ||
|
|
64cf14ed92 | ||
|
|
dbaa896fcc | ||
|
|
911c85bfc8 | ||
|
|
5edceb2562 | ||
|
|
5d14dce320 | ||
|
|
eec9e57dd2 | ||
|
|
503b922074 | ||
|
|
d4c19932d5 | ||
|
|
3c8cffc5ad | ||
|
|
b3c67a3f34 | ||
|
|
84b4833fed | ||
|
|
28ef7e5def | ||
|
|
9981baa13b | ||
|
|
c764aa6c20 | ||
|
|
bc11730697 | ||
|
|
92c4a86e8b | ||
|
|
358724bf1c | ||
|
|
bb80d988d7 | ||
|
|
0ad03a3fb5 | ||
|
|
3382de0ecb | ||
|
|
08bb7b4490 | ||
|
|
15203f6bcc | ||
|
|
cbfb0d6761 | ||
|
|
343aa50f78 | ||
|
|
5a70687067 | ||
|
|
a0921f7380 | ||
|
|
11cc03849d | ||
|
|
413aeaccb1 | ||
|
|
88457a82ac | ||
|
|
761f36519e | ||
|
|
dc5b637ada | ||
|
|
5e5395658e | ||
|
|
69b3f366f4 | ||
|
|
da902d23f7 | ||
|
|
c2be23a902 | ||
|
|
da771d7830 | ||
|
|
8a242a69fb | ||
|
|
041bed7e9d | ||
|
|
e330f45adc | ||
|
|
370d3a321b | ||
|
|
138fba66ae | ||
|
|
82faaed15d | ||
|
|
b58a685e7a | ||
|
|
45ec16d9e4 | ||
|
|
18c0fb0da5 | ||
|
|
b7d93c1b50 | ||
|
|
e931ead270 | ||
|
|
8933ca9ac9 | ||
|
|
1a06e2c0aa | ||
|
|
491b5c46ae | ||
|
|
2139bddf01 | ||
|
|
cf68d3127c | ||
|
|
f13bb494ef | ||
|
|
5e18cd2ef4 | ||
|
|
5fdecb708e | ||
|
|
0144ab60de | ||
|
|
565787eeb6 | ||
|
|
b9d94df4d8 | ||
|
|
9e103af8b5 | ||
|
|
5728714d71 | ||
|
|
62cfc0fb24 | ||
|
|
a52a01ef7f | ||
|
|
cd1d2067ad | ||
|
|
67d3ec75c8 | ||
|
|
52f16131af | ||
|
|
59dba7730f |
26
.github/workflows/ci.yml
vendored
26
.github/workflows/ci.yml
vendored
@@ -36,12 +36,27 @@ jobs:
|
|||||||
- name: setup node
|
- name: setup node
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '12'
|
node-version: '14'
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
- name: setup cache for bench
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: ~/bench-cache
|
||||||
|
key: ${{ runner.os }}
|
||||||
- name: install bench
|
- name: install bench
|
||||||
run: pip3 install frappe-bench
|
run: |
|
||||||
|
pip3 install frappe-bench
|
||||||
|
which bench
|
||||||
- name: bench init
|
- name: bench init
|
||||||
run: bench init ~/frappe-bench --skip-redis-config-generation
|
run: |
|
||||||
|
if [ -d ~/bench-cache/bench.tgz ]
|
||||||
|
then
|
||||||
|
(cd && tar xzf ~/bench-cache/bench.tgz)
|
||||||
|
else
|
||||||
|
bench init ~/frappe-bench --skip-redis-config-generation
|
||||||
|
mkdir -p ~/bench-cache
|
||||||
|
(cd && tar czf ~/bench-cache/bench.tgz frappe-bench)
|
||||||
|
fi
|
||||||
- name: add community app to bench
|
- name: add community app to bench
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench get-app community $GITHUB_WORKSPACE
|
run: bench get-app community $GITHUB_WORKSPACE
|
||||||
@@ -50,10 +65,13 @@ jobs:
|
|||||||
run: bench new-site --mariadb-root-password root --admin-password admin frappe.local
|
run: bench new-site --mariadb-root-password root --admin-password admin frappe.local
|
||||||
- name: install community app
|
- name: install community app
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench --site frappe.local install-app community
|
run: bench --verbose --site frappe.local install-app community
|
||||||
- name: allow tests
|
- name: allow tests
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench --site frappe.local set-config allow_tests true
|
run: bench --site frappe.local set-config allow_tests true
|
||||||
|
- name: bench build
|
||||||
|
working-directory: /home/runner/frappe-bench
|
||||||
|
run: bench --site frappe.local build
|
||||||
- name: run tests
|
- name: run tests
|
||||||
working-directory: /home/runner/frappe-bench
|
working-directory: /home/runner/frappe-bench
|
||||||
run: bench --site frappe.local run-tests --app community
|
run: bench --site frappe.local run-tests --app community
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,4 +3,5 @@
|
|||||||
*.egg-info
|
*.egg-info
|
||||||
*.swp
|
*.swp
|
||||||
tags
|
tags
|
||||||
community/docs/current
|
community/docs/current
|
||||||
|
community/public/dist
|
||||||
|
|||||||
@@ -50,18 +50,3 @@ class CommunityCourseMember(WebsiteGenerator):
|
|||||||
send_priority=0,
|
send_priority=0,
|
||||||
queue_separately=True,
|
queue_separately=True,
|
||||||
args=args)
|
args=args)
|
||||||
|
|
||||||
def create_user(self):
|
|
||||||
user = frappe.get_doc({
|
|
||||||
"doctype": "User",
|
|
||||||
"email": self.email,
|
|
||||||
"first_name": self.full_name.split(" ")[0],
|
|
||||||
"full_name": self.full_name,
|
|
||||||
"username": self.user_name,
|
|
||||||
"send_welcome_email": 0,
|
|
||||||
"user_type": 'Website User',
|
|
||||||
"redirect_url": self.name
|
|
||||||
})
|
|
||||||
user.save(ignore_permissions=True)
|
|
||||||
update_password_link = user.reset_password()
|
|
||||||
return user, update_password_link
|
|
||||||
|
|||||||
@@ -8,57 +8,97 @@ import re
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import random
|
import random
|
||||||
|
from frappe.utils import cint
|
||||||
|
import hashlib
|
||||||
|
|
||||||
class CommunityMember(Document):
|
class CommunityMember(Document):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.validate_username()
|
self.validate_username()
|
||||||
self.abbr = ("").join([ s[0] for s in self.full_name.split() ])
|
self.abbr = ("").join([ s[0] for s in self.full_name.split() ])
|
||||||
if self.route != self.username:
|
if self.route != self.username:
|
||||||
self.route = self.username
|
self.route = self.username
|
||||||
|
|
||||||
def validate_username(self):
|
|
||||||
if not self.username:
|
|
||||||
self.username = create_username_from_email(self.email)
|
|
||||||
|
|
||||||
if self.username:
|
def validate_username(self):
|
||||||
if len(self.username) < 4:
|
if not self.username:
|
||||||
frappe.throw(_("Username must be atleast 4 characters long."))
|
self.username = create_username_from_email(self.email)
|
||||||
if not re.match("^[A-Za-z0-9_]*$", self.username):
|
|
||||||
frappe.throw(_("Username can only contain alphabets, numbers and underscore."))
|
|
||||||
self.username = self.username.lower()
|
|
||||||
|
|
||||||
def __repr__(self):
|
if self.username:
|
||||||
return f"<CommunityMember: {self.email}>"
|
if len(self.username) < 4:
|
||||||
|
frappe.throw(_("Username must be atleast 4 characters long."))
|
||||||
|
if not re.match("^[A-Za-z0-9_]*$", self.username):
|
||||||
|
frappe.throw(_("Username can only contain alphabets, numbers and underscore."))
|
||||||
|
self.username = self.username.lower()
|
||||||
|
|
||||||
|
def get_course_count(self) -> int:
|
||||||
|
"""Returns the number of courses authored by this user.
|
||||||
|
"""
|
||||||
|
return frappe.db.count(
|
||||||
|
'LMS Course', {
|
||||||
|
'owner': self.email
|
||||||
|
})
|
||||||
|
|
||||||
|
def get_batch_count(self) -> int:
|
||||||
|
"""Returns the number of batches authored by this user.
|
||||||
|
"""
|
||||||
|
return frappe.db.count(
|
||||||
|
'LMS Batch Membership', {
|
||||||
|
'member': self.name,
|
||||||
|
'member_type': 'Mentor'
|
||||||
|
})
|
||||||
|
|
||||||
|
def get_photo_url(self):
|
||||||
|
return frappe.db.get_value("User", self.email, ["user_image"])
|
||||||
|
|
||||||
|
def get_palette(self):
|
||||||
|
palette = [
|
||||||
|
['--orange-avatar-bg', '--orange-avatar-color'],
|
||||||
|
['--pink-avatar-bg', '--pink-avatar-color'],
|
||||||
|
['--blue-avatar-bg', '--blue-avatar-color'],
|
||||||
|
['--green-avatar-bg', '--green-avatar-color'],
|
||||||
|
['--dark-green-avatar-bg', '--dark-green-avatar-color'],
|
||||||
|
['--red-avatar-bg', '--red-avatar-color'],
|
||||||
|
['--yellow-avatar-bg', '--yellow-avatar-color'],
|
||||||
|
['--purple-avatar-bg', '--purple-avatar-color'],
|
||||||
|
['--gray-avatar-bg', '--gray-avatar-color0']
|
||||||
|
]
|
||||||
|
|
||||||
|
encoded_name = str(self.full_name).encode("utf-8")
|
||||||
|
hash_name = hashlib.md5(encoded_name).hexdigest()
|
||||||
|
idx = cint((int(hash_name[4:6], 16) + 1) / 5.33)
|
||||||
|
return palette[idx % 8]
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<CommunityMember: {self.email}>"
|
||||||
|
|
||||||
def create_member_from_user(doc, method):
|
def create_member_from_user(doc, method):
|
||||||
username = doc.username
|
username = doc.username
|
||||||
|
|
||||||
if ( doc.username and username_exists(doc.username)) or not doc.username:
|
if ( doc.username and username_exists(doc.username)) or not doc.username:
|
||||||
username = create_username_from_email(doc.email)
|
username = create_username_from_email(doc.email)
|
||||||
|
|
||||||
elif len(doc.username) < 4:
|
elif len(doc.username) < 4 and doc.send_welcome_email == 1:
|
||||||
username = adjust_username(doc.username)
|
username = adjust_username(doc.username)
|
||||||
|
|
||||||
if username_exists(username):
|
if username_exists(username):
|
||||||
username = username + str(random.randint(0,9))
|
username = username + str(random.randint(0,9))
|
||||||
|
|
||||||
member = frappe.get_doc({
|
member = frappe.get_doc({
|
||||||
"doctype": "Community Member",
|
"doctype": "Community Member",
|
||||||
"full_name": doc.full_name,
|
"full_name": doc.full_name,
|
||||||
"username": username,
|
"username": username,
|
||||||
"email": doc.email,
|
"email": doc.email,
|
||||||
"route": doc.username,
|
"route": doc.username,
|
||||||
"owner": doc.email
|
"owner": doc.email
|
||||||
})
|
})
|
||||||
member.save(ignore_permissions=True)
|
member.save(ignore_permissions=True)
|
||||||
|
|
||||||
def username_exists(username):
|
def username_exists(username):
|
||||||
return frappe.db.exists("Community Member", dict(username=username))
|
return frappe.db.exists("Community Member", dict(username=username))
|
||||||
|
|
||||||
def create_username_from_email(email):
|
def create_username_from_email(email):
|
||||||
string = email.split("@")[0]
|
string = email.split("@")[0]
|
||||||
return ''.join(e for e in string if e.isalnum())
|
return ''.join(e for e in string if e.isalnum())
|
||||||
|
|
||||||
def adjust_username(username):
|
def adjust_username(username):
|
||||||
return username.ljust(4, str(random.randint(0,9)))
|
return username.ljust(4, str(random.randint(0,9)))
|
||||||
|
|||||||
14
community/community/widgets/Avatar.html
Normal file
14
community/community/widgets/Avatar.html
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{% set color = member.get_palette() %}
|
||||||
|
<a href="/{{member.username}}">
|
||||||
|
<span class="avatar {{ avatar_class }}" title="{{ member.full_name }}">
|
||||||
|
{% if member.get_photo_url() %}
|
||||||
|
<img class="avatar-frame standard-image" src="{{ member.get_photo_url() }}" title="{{ member.full_name }}">
|
||||||
|
</img>
|
||||||
|
{% else %}
|
||||||
|
<span class="avatar-frame standard-image" title="{{ member.full_name }}"
|
||||||
|
style="background-color: var({{color[0]}}); color: var({{color[1]}});">
|
||||||
|
{{ member.abbr }}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
@@ -10,15 +10,16 @@ app_icon = "octicon octicon-file-directory"
|
|||||||
app_color = "grey"
|
app_color = "grey"
|
||||||
app_email = "jannat@erpnext.com"
|
app_email = "jannat@erpnext.com"
|
||||||
app_license = "AGPL"
|
app_license = "AGPL"
|
||||||
|
|
||||||
# Includes in <head>
|
# Includes in <head>
|
||||||
# ------------------
|
# ------------------
|
||||||
|
|
||||||
# include js, css files in header of desk.html
|
# include js, css files in header of desk.html
|
||||||
app_include_css = "/assets/community/css/community.css"
|
# app_include_css = "/assets/community/css/community.css"
|
||||||
app_include_js = "/assets/community/js/community.js"
|
# app_include_js = "/assets/community/js/community.js"
|
||||||
|
|
||||||
# include js, css files in header of web template
|
# include js, css files in header of web template
|
||||||
web_include_css = "/assets/css/community.css"
|
web_include_css = "community.bundle.css"
|
||||||
# web_include_css = "/assets/community/css/community.css"
|
# web_include_css = "/assets/community/css/community.css"
|
||||||
# web_include_js = "/assets/community/js/community.js"
|
# web_include_js = "/assets/community/js/community.js"
|
||||||
|
|
||||||
@@ -136,12 +137,12 @@ primary_rules = [
|
|||||||
{"from_route": "/sketches/<sketch>", "to_route": "sketches/sketch"},
|
{"from_route": "/sketches/<sketch>", "to_route": "sketches/sketch"},
|
||||||
{"from_route": "/courses/<course>", "to_route": "courses/course"},
|
{"from_route": "/courses/<course>", "to_route": "courses/course"},
|
||||||
{"from_route": "/courses/<course>/<topic>", "to_route": "courses/topic"},
|
{"from_route": "/courses/<course>/<topic>", "to_route": "courses/topic"},
|
||||||
{"from_route": "/hackathons", "to_route": "hackathons"},
|
|
||||||
{"from_route": "/hackathons/<hackathon>", "to_route": "hackathons/hackathon"},
|
{"from_route": "/hackathons/<hackathon>", "to_route": "hackathons/hackathon"},
|
||||||
{"from_route": "/hackathons/<hackathon>/<project>", "to_route": "hackathons/project"},
|
{"from_route": "/hackathons/<hackathon>/<project>", "to_route": "hackathons/project"},
|
||||||
{"from_route": "/dashboard", "to_route": ""},
|
{"from_route": "/dashboard", "to_route": ""},
|
||||||
{"from_route": "/add-a-new-batch", "to_route": "add-a-new-batch"},
|
{"from_route": "/add-a-new-batch", "to_route": "add-a-new-batch"},
|
||||||
{"from_route": "/courses/<course>/<batch>/learn", "to_route": "courses/learn"},
|
{"from_route": "/courses/<course>/<batch>/learn", "to_route": "courses/learn"},
|
||||||
|
{"from_route": "/courses/<course>/<batch>/learn/<int:chapter>.<int:lesson>", "to_route": "courses/learn"},
|
||||||
{"from_route": "/courses/<course>/<batch>/schedule", "to_route": "courses/schedule"},
|
{"from_route": "/courses/<course>/<batch>/schedule", "to_route": "courses/schedule"},
|
||||||
{"from_route": "/courses/<course>/<batch>/members", "to_route": "courses/members"},
|
{"from_route": "/courses/<course>/<batch>/members", "to_route": "courses/members"},
|
||||||
{"from_route": "/courses/<course>/<batch>/discuss", "to_route": "courses/discuss"},
|
{"from_route": "/courses/<course>/<batch>/discuss", "to_route": "courses/discuss"},
|
||||||
@@ -163,7 +164,9 @@ whitelist = [
|
|||||||
"/hackathons",
|
"/hackathons",
|
||||||
"/dashboard",
|
"/dashboard",
|
||||||
"/join-request"
|
"/join-request"
|
||||||
"/add-a-new-batch"
|
"/add-a-new-batch",
|
||||||
|
"/new-sign-up",
|
||||||
|
"/message"
|
||||||
]
|
]
|
||||||
whitelist_rules = [{"from_route": p, "to_route": p[1:]} for p in whitelist]
|
whitelist_rules = [{"from_route": p, "to_route": p[1:]} for p in whitelist]
|
||||||
|
|
||||||
|
|||||||
@@ -21,3 +21,16 @@ def get_section(name):
|
|||||||
"""
|
"""
|
||||||
doc = frappe.get_doc("LMS Section", name)
|
doc = frappe.get_doc("LMS Section", name)
|
||||||
return doc and doc.as_dict()
|
return doc and doc.as_dict()
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def submit_solution(exercise, code):
|
||||||
|
"""Submits a solution.
|
||||||
|
|
||||||
|
@exerecise: name of the exercise to submit
|
||||||
|
@code: solution to the exercise
|
||||||
|
"""
|
||||||
|
ex = frappe.get_doc("Exercise", exercise)
|
||||||
|
if not ex:
|
||||||
|
return
|
||||||
|
doc = ex.submit(code)
|
||||||
|
return {"name": doc.name, "creation": doc.creation}
|
||||||
|
|||||||
8
community/lms/doctype/chapter/chapter.js
Normal file
8
community/lms/doctype/chapter/chapter.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Chapter', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
79
community/lms/doctype/chapter/chapter.json
Normal file
79
community/lms/doctype/chapter/chapter.json
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"autoname": "format:{####} {title}",
|
||||||
|
"creation": "2021-05-03 05:49:08.383057",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"course",
|
||||||
|
"title",
|
||||||
|
"description",
|
||||||
|
"locked",
|
||||||
|
"index_"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Title"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Markdown Editor",
|
||||||
|
"label": "Description"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "locked",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Locked"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "course",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Course",
|
||||||
|
"options": "LMS Course"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "index_",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Index"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [
|
||||||
|
{
|
||||||
|
"group": "Lessons",
|
||||||
|
"link_doctype": "Lesson",
|
||||||
|
"link_fieldname": "chapter"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"modified": "2021-05-13 21:05:20.531890",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "Chapter",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_fields": "title",
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"title_field": "title",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
15
community/lms/doctype/chapter/chapter.py
Normal file
15
community/lms/doctype/chapter/chapter.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, FOSS United and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class Chapter(Document):
|
||||||
|
def get_lessons(self):
|
||||||
|
rows = frappe.db.get_all("Lesson",
|
||||||
|
filters={"chapter": self.name},
|
||||||
|
fields='*',
|
||||||
|
order_by="index_")
|
||||||
|
return [frappe.get_doc(dict(row, doctype='Lesson')) for row in rows]
|
||||||
10
community/lms/doctype/chapter/test_chapter.py
Normal file
10
community/lms/doctype/chapter/test_chapter.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, FOSS United and Contributors
|
||||||
|
# See license.txt
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestChapter(unittest.TestCase):
|
||||||
|
pass
|
||||||
0
community/lms/doctype/exercise/__init__.py
Normal file
0
community/lms/doctype/exercise/__init__.py
Normal file
8
community/lms/doctype/exercise/exercise.js
Normal file
8
community/lms/doctype/exercise/exercise.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Exercise', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
106
community/lms/doctype/exercise/exercise.json
Normal file
106
community/lms/doctype/exercise/exercise.json
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"creation": "2021-05-19 17:43:39.923430",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"title",
|
||||||
|
"description",
|
||||||
|
"code",
|
||||||
|
"answer",
|
||||||
|
"column_break_4",
|
||||||
|
"course",
|
||||||
|
"hints",
|
||||||
|
"tests",
|
||||||
|
"image",
|
||||||
|
"lesson"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Title"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "course",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Course",
|
||||||
|
"options": "LMS Course"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 4,
|
||||||
|
"fieldname": "description",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Description"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 4,
|
||||||
|
"fieldname": "answer",
|
||||||
|
"fieldtype": "Code",
|
||||||
|
"label": "Answer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "tests",
|
||||||
|
"fieldtype": "Code",
|
||||||
|
"label": "Tests"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_4",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 4,
|
||||||
|
"fieldname": "hints",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Hints"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"columns": 4,
|
||||||
|
"fieldname": "code",
|
||||||
|
"fieldtype": "Code",
|
||||||
|
"label": "Code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "image",
|
||||||
|
"fieldtype": "Code",
|
||||||
|
"label": "Image",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lesson",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Lesson",
|
||||||
|
"options": "Lesson"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-20 13:23:12.340928",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "Exercise",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"search_fields": "title",
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"title_field": "title",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
54
community/lms/doctype/exercise/exercise.py
Normal file
54
community/lms/doctype/exercise/exercise.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# Copyright (c) 2021, FOSS United and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
from ..lms_sketch.livecode import livecode_to_svg
|
||||||
|
|
||||||
|
class Exercise(Document):
|
||||||
|
def before_save(self):
|
||||||
|
self.image = livecode_to_svg(None, self.answer)
|
||||||
|
|
||||||
|
def get_user_submission(self):
|
||||||
|
"""Returns the latest submission for this user.
|
||||||
|
"""
|
||||||
|
user = frappe.session.user
|
||||||
|
if not user or user == "Guest":
|
||||||
|
return
|
||||||
|
|
||||||
|
result = frappe.get_all('Exercise Submission',
|
||||||
|
fields="*",
|
||||||
|
filters={
|
||||||
|
"owner": user,
|
||||||
|
"exercise": self.name
|
||||||
|
},
|
||||||
|
order_by="creation desc",
|
||||||
|
page_length=1)
|
||||||
|
if result:
|
||||||
|
return result[0]
|
||||||
|
|
||||||
|
def submit(self, code):
|
||||||
|
"""Submits the given code as solution to exercise.
|
||||||
|
"""
|
||||||
|
user = frappe.session.user
|
||||||
|
if not user or user == "Guest":
|
||||||
|
return
|
||||||
|
|
||||||
|
old_submission = self.get_user_submission()
|
||||||
|
if old_submission and old_submission.solution == code:
|
||||||
|
return old_submission
|
||||||
|
|
||||||
|
course = frappe.get_doc("LMS Course", self.course)
|
||||||
|
batch = course.get_student_batch(user)
|
||||||
|
|
||||||
|
doc = frappe.get_doc(
|
||||||
|
doctype="Exercise Submission",
|
||||||
|
exercise=self.name,
|
||||||
|
exercise_title=self.title,
|
||||||
|
course=self.course,
|
||||||
|
lesson=self.lesson,
|
||||||
|
batch=batch and batch.name,
|
||||||
|
solution=code)
|
||||||
|
doc.insert()
|
||||||
|
return doc
|
||||||
|
|
||||||
47
community/lms/doctype/exercise/test_exercise.py
Normal file
47
community/lms/doctype/exercise/test_exercise.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
# Copyright (c) 2021, FOSS United and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestExercise(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
frappe.db.sql('delete from `tabExercise Submission`')
|
||||||
|
frappe.db.sql('delete from `tabExercise`')
|
||||||
|
frappe.db.sql('delete from `tabLMS Course`')
|
||||||
|
|
||||||
|
def new_exercise(self):
|
||||||
|
course = frappe.get_doc({
|
||||||
|
"doctype": "LMS Course",
|
||||||
|
"name": "test-course",
|
||||||
|
"title": "Test Course"
|
||||||
|
})
|
||||||
|
course.insert()
|
||||||
|
e = frappe.get_doc({
|
||||||
|
"doctype": "Exercise",
|
||||||
|
"name": "test-problem",
|
||||||
|
"course": course.name,
|
||||||
|
"title": "Test Problem",
|
||||||
|
"description": "draw a circle",
|
||||||
|
"code": "# draw a single cicle",
|
||||||
|
"answer": (
|
||||||
|
"# draw a single circle\n" +
|
||||||
|
"circle(100, 100, 50)")
|
||||||
|
})
|
||||||
|
e.insert()
|
||||||
|
return e
|
||||||
|
|
||||||
|
def test_exercise(self):
|
||||||
|
e = self.new_exercise()
|
||||||
|
assert e.get_user_submission() is None
|
||||||
|
|
||||||
|
def test_exercise_submission(self):
|
||||||
|
e = self.new_exercise()
|
||||||
|
submission = e.submit("circle(100, 100, 50)")
|
||||||
|
assert submission is not None
|
||||||
|
assert submission.exercise == e.name
|
||||||
|
assert submission.course == e.course
|
||||||
|
|
||||||
|
user_submission = e.get_user_submission()
|
||||||
|
assert user_submission is not None
|
||||||
|
assert user_submission.name == submission.name
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Exercise Submission', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-05-19 11:41:18.108316",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"exercise",
|
||||||
|
"solution",
|
||||||
|
"exercise_title",
|
||||||
|
"course",
|
||||||
|
"batch",
|
||||||
|
"lesson"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "exercise",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Exercise",
|
||||||
|
"options": "Exercise"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "solution",
|
||||||
|
"fieldtype": "Code",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Solution"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "exercise.title",
|
||||||
|
"fieldname": "exercise_title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Exercise Title",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "exercise.course",
|
||||||
|
"fieldname": "course",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Course",
|
||||||
|
"options": "LMS Course",
|
||||||
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "batch",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Batch",
|
||||||
|
"options": "LMS Batch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fetch_from": "exercise.lesson",
|
||||||
|
"fieldname": "lesson",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Lesson",
|
||||||
|
"options": "Lesson"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-20 13:30:16.349278",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "Exercise Submission",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, FOSS United and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class ExerciseSubmission(Document):
|
||||||
|
pass
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2021, FOSS United and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestExerciseSubmission(unittest.TestCase):
|
||||||
|
pass
|
||||||
0
community/lms/doctype/invite_request/__init__.py
Normal file
0
community/lms/doctype/invite_request/__init__.py
Normal file
8
community/lms/doctype/invite_request/invite_request.js
Normal file
8
community/lms/doctype/invite_request/invite_request.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Invite Request', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
88
community/lms/doctype/invite_request/invite_request.json
Normal file
88
community/lms/doctype/invite_request/invite_request.json
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"creation": "2021-04-29 16:29:56.857914",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"invite_email",
|
||||||
|
"signup_email",
|
||||||
|
"column_break_4",
|
||||||
|
"status",
|
||||||
|
"full_name",
|
||||||
|
"username",
|
||||||
|
"invite_code"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"allow_in_quick_entry": 1,
|
||||||
|
"fieldname": "invite_email",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Invite Email",
|
||||||
|
"options": "Email",
|
||||||
|
"unique": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "full_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Full Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_4",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "signup_email",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Signup Email",
|
||||||
|
"options": "Email"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "username",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Username"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "invite_code",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Invite Code"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Pending",
|
||||||
|
"fieldname": "status",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Status",
|
||||||
|
"options": "Pending\nApproved\nRejected\nRegistered"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-03 09:22:20.954921",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "Invite Request",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"quick_entry": 1,
|
||||||
|
"search_fields": "invite_email, signup_email",
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"title_field": "invite_email",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
86
community/lms/doctype/invite_request/invite_request.py
Normal file
86
community/lms/doctype/invite_request/invite_request.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, FOSS United and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe import _
|
||||||
|
from frappe.model.document import Document
|
||||||
|
import json
|
||||||
|
from frappe.utils.password import get_decrypted_password
|
||||||
|
|
||||||
|
class InviteRequest(Document):
|
||||||
|
def on_update(self):
|
||||||
|
if self.has_value_changed("status") and self.status == "Approved":
|
||||||
|
self.send_email()
|
||||||
|
|
||||||
|
def create_user(self, password):
|
||||||
|
full_name_split = self.full_name.split(" ")
|
||||||
|
user = frappe.get_doc({
|
||||||
|
"doctype": "User",
|
||||||
|
"email": self.signup_email,
|
||||||
|
"first_name": full_name_split[0],
|
||||||
|
"last_name": full_name_split[1] if len(full_name_split) > 1 else "",
|
||||||
|
"username": self.username,
|
||||||
|
"send_welcome_email": 0,
|
||||||
|
"user_type": "Website User",
|
||||||
|
"new_password": password
|
||||||
|
})
|
||||||
|
user.save(ignore_permissions=True)
|
||||||
|
return user
|
||||||
|
|
||||||
|
def send_email(self):
|
||||||
|
subject = _("Your request has been approved.")
|
||||||
|
args = {
|
||||||
|
"full_name": self.full_name,
|
||||||
|
"signup_form_link": "/new-sign-up?invite_code={0}".format(self.name),
|
||||||
|
"site_url": frappe.utils.get_url()
|
||||||
|
}
|
||||||
|
frappe.sendmail(
|
||||||
|
recipients=self.invite_email,
|
||||||
|
sender=frappe.db.get_single_value("LMS Settings", "email_sender"),
|
||||||
|
subject=subject,
|
||||||
|
header=[subject, "green"],
|
||||||
|
template = "lms_invite_request_approved",
|
||||||
|
args=args)
|
||||||
|
|
||||||
|
@frappe.whitelist(allow_guest=True)
|
||||||
|
def create_invite_request(invite_email):
|
||||||
|
|
||||||
|
if not frappe.utils.validate_email_address(invite_email):
|
||||||
|
return "invalid email"
|
||||||
|
|
||||||
|
if frappe.db.exists("User", invite_email):
|
||||||
|
return "user"
|
||||||
|
|
||||||
|
if frappe.db.exists("Invite Request", {"invite_email": invite_email}):
|
||||||
|
return "invite"
|
||||||
|
|
||||||
|
frappe.get_doc({
|
||||||
|
"doctype": "Invite Request",
|
||||||
|
"invite_email": invite_email
|
||||||
|
}).save(ignore_permissions=True)
|
||||||
|
return "OK"
|
||||||
|
|
||||||
|
|
||||||
|
@frappe.whitelist(allow_guest=True)
|
||||||
|
def update_invite(data):
|
||||||
|
data = frappe._dict(json.loads(data)) if type(data) == str else frappe._dict(data)
|
||||||
|
|
||||||
|
try:
|
||||||
|
doc = frappe.get_doc("Invite Request", data.invite_code)
|
||||||
|
except frappe.DoesNotExistError:
|
||||||
|
frappe.throw(_("Invalid Invite Code."))
|
||||||
|
|
||||||
|
doc.signup_email = data.signup_email
|
||||||
|
doc.username = data.username
|
||||||
|
doc.full_name = data.full_name
|
||||||
|
doc.invite_code = data.invite_code
|
||||||
|
doc.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
user = doc.create_user(data.password)
|
||||||
|
if user:
|
||||||
|
doc.status = "Registered"
|
||||||
|
doc.save(ignore_permissions=True)
|
||||||
|
|
||||||
|
return "OK"
|
||||||
69
community/lms/doctype/invite_request/test_invite_request.py
Normal file
69
community/lms/doctype/invite_request/test_invite_request.py
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, FOSS United and Contributors
|
||||||
|
# See license.txt
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
from community.lms.doctype.invite_request.invite_request import create_invite_request, update_invite
|
||||||
|
import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestInviteRequest(unittest.TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(self):
|
||||||
|
create_invite_request("test_invite@example.com")
|
||||||
|
|
||||||
|
def test_create_invite_request(self):
|
||||||
|
if frappe.db.exists("Invite Request", {"invite_email": "test_invite@example.com"}):
|
||||||
|
invite = frappe.db.get_value("Invite Request",
|
||||||
|
filters={"invite_email": "test_invite@example.com"},
|
||||||
|
fieldname=["invite_email", "status", "signup_email"],
|
||||||
|
as_dict=True)
|
||||||
|
self.assertEqual(invite.status, "Pending")
|
||||||
|
self.assertEqual(invite.signup_email, None)
|
||||||
|
|
||||||
|
def test_create_invite_request_update(self):
|
||||||
|
if frappe.db.exists("Invite Request", {"invite_email": "test_invite@example.com"}):
|
||||||
|
|
||||||
|
data = {
|
||||||
|
"signup_email": "test_invite@example.com",
|
||||||
|
"username": "test_invite",
|
||||||
|
"full_name": "Test Invite",
|
||||||
|
"password": "Test@invite",
|
||||||
|
"invite_code": frappe.db.get_value("Invite Request", {"invite_email": "test_invite@example.com"}, "name")
|
||||||
|
}
|
||||||
|
|
||||||
|
update_invite(data)
|
||||||
|
invite = frappe.db.get_value("Invite Request",
|
||||||
|
filters={"invite_email": "test_invite@example.com"},
|
||||||
|
fieldname=["invite_email", "status", "signup_email", "full_name", "username", "invite_code", "name"],
|
||||||
|
as_dict=True)
|
||||||
|
self.assertEqual(invite.signup_email, "test_invite@example.com")
|
||||||
|
self.assertEqual(invite.full_name, "Test Invite")
|
||||||
|
self.assertEqual(invite.username, "test_invite")
|
||||||
|
self.assertEqual(invite.invite_code, invite.name)
|
||||||
|
self.assertEqual(invite.status, "Registered")
|
||||||
|
|
||||||
|
user = frappe.db.get_value("User", "test_invite@example.com",
|
||||||
|
fieldname=["first_name", "username", "send_welcome_email", "user_type"],
|
||||||
|
as_dict=True)
|
||||||
|
self.assertTrue(user)
|
||||||
|
self.assertEqual(user.first_name, invite.full_name.split(" ")[0])
|
||||||
|
self.assertEqual(user.username, invite.username)
|
||||||
|
self.assertEqual(user.send_welcome_email, 0)
|
||||||
|
self.assertEqual(user.user_type, "Website User")
|
||||||
|
|
||||||
|
member = frappe.db.get_value("Community Member", {"email": "test_invite@example.com"})
|
||||||
|
self.assertTrue(member)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def tearDownClass(self):
|
||||||
|
|
||||||
|
if frappe.db.exists("Community Member", {"email": "test_invite@example.com"}):
|
||||||
|
frappe.delete_doc("Community Member", {"email": "test_invite@example.com"})
|
||||||
|
|
||||||
|
if frappe.db.exists("User", "test_invite@example.com"):
|
||||||
|
frappe.delete_doc("User", "test_invite@example.com")
|
||||||
|
|
||||||
|
invite_request = frappe.db.exists("Invite Request", {"invite_email": "test_invite@example.com"})
|
||||||
|
if invite_request:
|
||||||
|
frappe.delete_doc("Invite Request", invite_request)
|
||||||
0
community/lms/doctype/lesson/__init__.py
Normal file
0
community/lms/doctype/lesson/__init__.py
Normal file
8
community/lms/doctype/lesson/lesson.js
Normal file
8
community/lms/doctype/lesson/lesson.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2021, FOSS United and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('Lesson', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
||||||
80
community/lms/doctype/lesson/lesson.json
Normal file
80
community/lms/doctype/lesson/lesson.json
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"autoname": "format:{####} {title}",
|
||||||
|
"creation": "2021-05-03 06:21:12.995987",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"chapter",
|
||||||
|
"lesson_type",
|
||||||
|
"title",
|
||||||
|
"index_",
|
||||||
|
"body",
|
||||||
|
"sections"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "chapter",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Chapter",
|
||||||
|
"options": "Chapter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "Video",
|
||||||
|
"fieldname": "lesson_type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Lesson Type",
|
||||||
|
"options": "Video\nText\nQuiz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "title",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Title"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "1",
|
||||||
|
"fieldname": "index_",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Index"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "body",
|
||||||
|
"fieldtype": "Markdown Editor",
|
||||||
|
"label": "Body"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sections",
|
||||||
|
"fieldtype": "Table",
|
||||||
|
"label": "Sections",
|
||||||
|
"options": "LMS Section"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2021-05-13 20:03:51.510605",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "LMS",
|
||||||
|
"name": "Lesson",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC",
|
||||||
|
"track_changes": 1
|
||||||
|
}
|
||||||
45
community/lms/doctype/lesson/lesson.py
Normal file
45
community/lms/doctype/lesson/lesson.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, FOSS United and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
from ..lms_topic.section_parser import SectionParser
|
||||||
|
|
||||||
|
class Lesson(Document):
|
||||||
|
def before_save(self):
|
||||||
|
sections = SectionParser().parse(self.body or "")
|
||||||
|
self.sections = [self.make_lms_section(i, s) for i, s in enumerate(sections)]
|
||||||
|
for s in self.sections:
|
||||||
|
if s.type == "exercise":
|
||||||
|
e = s.get_exercise()
|
||||||
|
e.lesson = self.name
|
||||||
|
e.save()
|
||||||
|
|
||||||
|
def get_sections(self):
|
||||||
|
return sorted(self.get('sections'), key=lambda s: s.index)
|
||||||
|
|
||||||
|
def make_lms_section(self, index, section):
|
||||||
|
s = frappe.new_doc('LMS Section', parent_doc=self, parentfield='sections')
|
||||||
|
s.type = section.type
|
||||||
|
s.id = section.id
|
||||||
|
s.label = section.label
|
||||||
|
s.contents = section.contents
|
||||||
|
s.index = index
|
||||||
|
return s
|
||||||
|
|
||||||
|
def get_next(self):
|
||||||
|
"""Returns the number for the next lesson.
|
||||||
|
|
||||||
|
The return value would be like 1.2, 2.1 etc.
|
||||||
|
It will be None if there is no next lesson.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def get_prev(self):
|
||||||
|
"""Returns the number for the prev lesson.
|
||||||
|
|
||||||
|
The return value would be like 1.2, 2.1 etc.
|
||||||
|
It will be None if there is no next lesson.
|
||||||
|
"""
|
||||||
10
community/lms/doctype/lesson/test_lesson.py
Normal file
10
community/lms/doctype/lesson/test_lesson.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Copyright (c) 2021, FOSS United and Contributors
|
||||||
|
# See license.txt
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestLesson(unittest.TestCase):
|
||||||
|
pass
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"actions": [],
|
"actions": [],
|
||||||
"autoname": "field:title",
|
|
||||||
"creation": "2021-03-18 19:37:34.614796",
|
"creation": "2021-03-18 19:37:34.614796",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
@@ -27,6 +26,8 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "course",
|
"fieldname": "course",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"options": "LMS Course"
|
"options": "LMS Course"
|
||||||
},
|
},
|
||||||
@@ -49,10 +50,12 @@
|
|||||||
"label": "Description"
|
"label": "Description"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "Public",
|
||||||
"fieldname": "visibility",
|
"fieldname": "visibility",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Visibility",
|
"label": "Visibility",
|
||||||
"options": "\nPublic\nUnlisted\nPrivate"
|
"options": "Public\nUnlisted\nPrivate"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "membership",
|
"fieldname": "membership",
|
||||||
@@ -61,16 +64,19 @@
|
|||||||
"options": "\nOpen\nRestricted\nInvite Only\nClosed"
|
"options": "\nOpen\nRestricted\nInvite Only\nClosed"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "Active",
|
||||||
"fieldname": "status",
|
"fieldname": "status",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Status",
|
"label": "Status",
|
||||||
"options": "\nActive\nInactive"
|
"options": "Active\nInactive"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "Ready",
|
||||||
"fieldname": "stage",
|
"fieldname": "stage",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Stage",
|
"label": "Stage",
|
||||||
"options": "\nReady\nIn Progress\nCompleted\nCancelled"
|
"options": "Ready\nIn Progress\nCompleted\nCancelled"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
@@ -91,11 +97,13 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "start_date",
|
"fieldname": "start_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Start Date"
|
"label": "Start Date"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "start_time",
|
"fieldname": "start_time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Start Time"
|
"label": "Start Time"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -106,6 +114,7 @@
|
|||||||
{
|
{
|
||||||
"fieldname": "end_time",
|
"fieldname": "end_time",
|
||||||
"fieldtype": "Time",
|
"fieldtype": "Time",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "End Time"
|
"label": "End Time"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -117,7 +126,7 @@
|
|||||||
"link_fieldname": "batch"
|
"link_fieldname": "batch"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-04-21 12:45:21.144972",
|
"modified": "2021-05-06 05:46:38.469120",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Batch",
|
"name": "LMS Batch",
|
||||||
|
|||||||
@@ -6,16 +6,44 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from community.www.courses.utils import get_member_with_email
|
from community.www.courses.utils import get_member_with_email
|
||||||
|
from frappe import _
|
||||||
|
from community.lms.doctype.lms_batch_membership.lms_batch_membership import create_membership
|
||||||
|
from community.query import find, find_all
|
||||||
|
|
||||||
class LMSBatch(Document):
|
class LMSBatch(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if not self.code:
|
self.validate_if_mentor()
|
||||||
self.generate_code()
|
if not self.code:
|
||||||
|
self.generate_code()
|
||||||
|
|
||||||
def generate_code(self):
|
def validate_if_mentor(self):
|
||||||
short_code = frappe.db.get_value("LMS Course", self.course, "short_code")
|
course = frappe.get_doc("LMS Course", self.course)
|
||||||
course_batches = frappe.get_all("LMS Batch",{"course":self.course})
|
if not course.is_mentor(frappe.session.user):
|
||||||
self.code = short_code + str(len(course_batches) + 1)
|
frappe.throw(_("You are not a mentor of the course {0}").format(course.title))
|
||||||
|
|
||||||
|
def after_insert(self):
|
||||||
|
create_membership(batch=self.name, member_type="Mentor")
|
||||||
|
|
||||||
|
def generate_code(self):
|
||||||
|
short_code = frappe.db.get_value("LMS Course", self.course, "short_code")
|
||||||
|
course_batches = frappe.get_all("LMS Batch",{"course":self.course})
|
||||||
|
self.code = short_code + str(len(course_batches) + 1)
|
||||||
|
|
||||||
|
def get_mentors(self):
|
||||||
|
memberships = frappe.get_all(
|
||||||
|
"LMS Batch Membership",
|
||||||
|
{"batch": self.name, "member_type": "Mentor"},
|
||||||
|
["member"])
|
||||||
|
member_names = [m['member'] for m in memberships]
|
||||||
|
return find_all("Community Member", name=["IN", member_names])
|
||||||
|
|
||||||
|
def is_member(self, email):
|
||||||
|
"""Checks if a person is part of a batch.
|
||||||
|
"""
|
||||||
|
member = find("Community Member", email=email)
|
||||||
|
return member and frappe.db.exists(
|
||||||
|
"LMS Batch Membership",
|
||||||
|
{"batch": self.name, "member": member.name})
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_messages(batch):
|
def get_messages(batch):
|
||||||
@@ -36,4 +64,4 @@ def save_message(message, batch):
|
|||||||
"author": get_member_with_email(),
|
"author": get_member_with_email(),
|
||||||
"message": message
|
"message": message
|
||||||
})
|
})
|
||||||
doc.save(ignore_permissions=True)
|
doc.save(ignore_permissions=True)
|
||||||
|
|||||||
@@ -8,35 +8,34 @@ from frappe.model.document import Document
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
class LMSBatchMembership(Document):
|
class LMSBatchMembership(Document):
|
||||||
|
|
||||||
def validate(self):
|
|
||||||
self.validate_membership_in_same_batch()
|
|
||||||
self.validate_membership_in_different_batch_same_course()
|
|
||||||
|
|
||||||
def validate_membership_in_same_batch(self):
|
|
||||||
previous_membership = frappe.db.get_value("LMS Batch Membership", {"member": self.member, "batch": self.batch}, ["member_type","member"], as_dict=1)
|
|
||||||
if previous_membership:
|
|
||||||
member_name = frappe.db.get_value("Community Member", self.member, "full_name")
|
|
||||||
frappe.throw(_("{0} is already a {1} of {2}").format(member_name, previous_membership.member_type, self.batch))
|
|
||||||
|
|
||||||
def validate_membership_in_different_batch_same_course(self):
|
def validate(self):
|
||||||
course = frappe.db.get_value("LMS Batch", self.batch, "course")
|
self.validate_membership_in_same_batch()
|
||||||
previous_membership = frappe.get_all("LMS Batch Membership", {"member": self.member}, ["batch", "member_type"])
|
self.validate_membership_in_different_batch_same_course()
|
||||||
for membership in previous_membership:
|
|
||||||
batch_course = frappe.db.get_value("LMS Batch", membership.batch, "course")
|
def validate_membership_in_same_batch(self):
|
||||||
if batch_course == course and (membership.member_type == "Student" or self.member_type == "Student"):
|
previous_membership = frappe.db.get_value("LMS Batch Membership", {"member": self.member, "batch": self.batch, "name": ["!=", self.name]}, ["member_type","member"], as_dict=1)
|
||||||
member_name = frappe.db.get_value("Community Member", self.member, "full_name")
|
if previous_membership:
|
||||||
frappe.throw(_("{0} is already a {1} of {2} course through {3} batch").format(member_name, membership.member_type, course, membership.batch))
|
member_name = frappe.db.get_value("Community Member", self.member, "full_name")
|
||||||
|
frappe.throw(_("{0} is already a {1} of {2}").format(member_name, previous_membership.member_type, self.batch))
|
||||||
|
|
||||||
|
def validate_membership_in_different_batch_same_course(self):
|
||||||
|
course = frappe.db.get_value("LMS Batch", self.batch, "course")
|
||||||
|
previous_membership = frappe.get_all("LMS Batch Membership", {"member": self.member}, ["batch", "member_type"])
|
||||||
|
for membership in previous_membership:
|
||||||
|
batch_course = frappe.db.get_value("LMS Batch", membership.batch, "course")
|
||||||
|
if batch_course == course and (membership.member_type == "Student" or self.member_type == "Student"):
|
||||||
|
member_name = frappe.db.get_value("Community Member", self.member, "full_name")
|
||||||
|
frappe.throw(_("{0} is already a {1} of {2} course through {3} batch").format(member_name, membership.member_type, course, membership.batch))
|
||||||
|
|
||||||
@frappe.whitelist()
|
|
||||||
def create_membership(batch, member=None, member_type="Student", role="Member"):
|
def create_membership(batch, member=None, member_type="Student", role="Member"):
|
||||||
if not member:
|
if not member:
|
||||||
member = frappe.db.get_value("Community Member", {"email": frappe.session.user}, "name")
|
member = frappe.db.get_value("Community Member", {"email": frappe.session.user}, "name")
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype": "LMS Batch Membership",
|
"doctype": "LMS Batch Membership",
|
||||||
"batch": batch,
|
"batch": batch,
|
||||||
"role": role,
|
"role": role,
|
||||||
"member_type": member_type,
|
"member_type": member_type,
|
||||||
"member": member
|
"member": member
|
||||||
}).save(ignore_permissions=True)
|
}).save(ignore_permissions=True)
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|||||||
@@ -2,14 +2,12 @@
|
|||||||
"actions": [],
|
"actions": [],
|
||||||
"allow_guest_to_view": 1,
|
"allow_guest_to_view": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"autoname": "field:title",
|
|
||||||
"creation": "2021-03-01 16:49:33.622422",
|
"creation": "2021-03-01 16:49:33.622422",
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"title",
|
"title",
|
||||||
"slug",
|
|
||||||
"is_published",
|
"is_published",
|
||||||
"column_break_3",
|
"column_break_3",
|
||||||
"short_code",
|
"short_code",
|
||||||
@@ -43,14 +41,6 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Short Code"
|
"label": "Short Code"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "The slug of the course. Autogenerated from the title if not specified.",
|
|
||||||
"fieldname": "slug",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Slug",
|
|
||||||
"unique": 1
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "column_break_3",
|
"fieldname": "column_break_3",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
@@ -74,8 +64,8 @@
|
|||||||
"is_published_field": "is_published",
|
"is_published_field": "is_published",
|
||||||
"links": [
|
"links": [
|
||||||
{
|
{
|
||||||
"group": "Topics",
|
"group": "Chapters",
|
||||||
"link_doctype": "LMS Topic",
|
"link_doctype": "Chapter",
|
||||||
"link_fieldname": "course"
|
"link_fieldname": "course"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -87,9 +77,14 @@
|
|||||||
"group": "Mentors",
|
"group": "Mentors",
|
||||||
"link_doctype": "LMS Course Mentor Mapping",
|
"link_doctype": "LMS Course Mentor Mapping",
|
||||||
"link_fieldname": "course"
|
"link_fieldname": "course"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"group": "Mentors",
|
||||||
|
"link_doctype": "LMS Mentor Request",
|
||||||
|
"link_fieldname": "course"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-04-21 14:45:41.658056",
|
"modified": "2021-05-06 13:37:03.318829",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Course",
|
"name": "LMS Course",
|
||||||
@@ -108,7 +103,7 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"search_fields": "slug",
|
"search_fields": "title",
|
||||||
"sort_field": "creation",
|
"sort_field": "creation",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"title_field": "title",
|
"title_field": "title",
|
||||||
|
|||||||
@@ -6,21 +6,34 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from ...utils import slugify
|
from ...utils import slugify
|
||||||
|
from community.query import find, find_all
|
||||||
|
|
||||||
class LMSCourse(Document):
|
class LMSCourse(Document):
|
||||||
def before_save(self):
|
@staticmethod
|
||||||
if not self.slug:
|
def find(name):
|
||||||
self.slug = self.generate_slug(title=self.title)
|
"""Returns the course with specified name.
|
||||||
|
"""
|
||||||
|
return find("LMS Course", is_published=True, name=name)
|
||||||
|
|
||||||
|
def autoname(self):
|
||||||
|
if not self.name:
|
||||||
|
self.name = self.generate_slug(title=self.title)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def find_all():
|
||||||
|
"""Returns all published courses.
|
||||||
|
"""
|
||||||
|
return find_all("LMS Course", is_published=True)
|
||||||
|
|
||||||
def generate_slug(self, title):
|
def generate_slug(self, title):
|
||||||
result = frappe.get_all(
|
result = frappe.get_all(
|
||||||
'LMS Course',
|
'LMS Course',
|
||||||
fields=['slug'])
|
fields=['name'])
|
||||||
slugs = set([row['slug'] for row in result])
|
slugs = set([row['name'] for row in result])
|
||||||
return slugify(title, used_slugs=slugs)
|
return slugify(title, used_slugs=slugs)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Course#{self.name} {self.slug}>"
|
return f"<Course#{self.name}>"
|
||||||
|
|
||||||
def get_topic(self, slug):
|
def get_topic(self, slug):
|
||||||
"""Returns the topic with given slug in this course as a Document.
|
"""Returns the topic with given slug in this course as a Document.
|
||||||
@@ -50,7 +63,7 @@ class LMSCourse(Document):
|
|||||||
"""Returns the name of Community Member document for a give user.
|
"""Returns the name of Community Member document for a give user.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return frappe.db.get_value("Community Member", {"email": email}, ["name"])
|
return frappe.db.get_value("Community Member", {"email": email}, "name")
|
||||||
except frappe.DoesNotExistError:
|
except frappe.DoesNotExistError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -89,14 +102,134 @@ class LMSCourse(Document):
|
|||||||
course_mentors.append(member)
|
course_mentors.append(member)
|
||||||
return course_mentors
|
return course_mentors
|
||||||
|
|
||||||
def get_instructor(self):
|
def is_mentor(self, email):
|
||||||
return frappe.get_doc("User", self.owner)
|
"""Checks if given user is a mentor for this course.
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def find_all():
|
|
||||||
"""Returns all published courses.
|
|
||||||
"""
|
"""
|
||||||
rows = frappe.db.get_all("LMS Course",
|
if not email:
|
||||||
filters={"is_published": True},
|
return False
|
||||||
fields='*')
|
member = self.get_community_member(email)
|
||||||
return [frappe.get_doc(dict(row, doctype='LMS Course')) for row in rows]
|
return frappe.db.exists({
|
||||||
|
"doctype": "LMS Course Mentor Mapping",
|
||||||
|
"course": self.name,
|
||||||
|
"mentor": member
|
||||||
|
})
|
||||||
|
|
||||||
|
def get_student_batch(self, email):
|
||||||
|
"""Returns the batch the given student is part of.
|
||||||
|
|
||||||
|
Returns None if the student is not part of any batch.
|
||||||
|
"""
|
||||||
|
if not email:
|
||||||
|
return False
|
||||||
|
member = self.get_community_member(email)
|
||||||
|
result = frappe.db.get_all(
|
||||||
|
"LMS Batch Membership",
|
||||||
|
filters={
|
||||||
|
"member": member,
|
||||||
|
"member_type": "Student",
|
||||||
|
},
|
||||||
|
fields=['batch']
|
||||||
|
)
|
||||||
|
batches = [row['batch'] for row in result]
|
||||||
|
|
||||||
|
# filter the batches that are for this course
|
||||||
|
result = frappe.db.get_all(
|
||||||
|
"LMS Batch",
|
||||||
|
filters={
|
||||||
|
"course": self.name,
|
||||||
|
"name": ["IN", batches]
|
||||||
|
})
|
||||||
|
batches = [row['name'] for row in result]
|
||||||
|
if batches:
|
||||||
|
return frappe.get_doc("LMS Batch", batches[0])
|
||||||
|
|
||||||
|
def get_instructor(self):
|
||||||
|
member_name = self.get_community_member(self.owner)
|
||||||
|
return frappe.get_doc("Community Member", member_name)
|
||||||
|
|
||||||
|
def get_chapters(self):
|
||||||
|
"""Returns all chapters of this course.
|
||||||
|
"""
|
||||||
|
# TODO: chapters should have a way to specify the order
|
||||||
|
return find_all("Chapter", course=self.name, order_by="creation")
|
||||||
|
|
||||||
|
def get_batch(self, batch_name):
|
||||||
|
return find("LMS Batch", name=batch_name, course=self.name)
|
||||||
|
|
||||||
|
def get_batches(self, mentor=None):
|
||||||
|
batches = find_all("LMS Batch", course=self.name)
|
||||||
|
if mentor:
|
||||||
|
# TODO: optimize this
|
||||||
|
member = self.get_community_member(email=mentor)
|
||||||
|
memberships = frappe.db.get_all(
|
||||||
|
"LMS Batch Membership",
|
||||||
|
{"member": member},
|
||||||
|
["batch"])
|
||||||
|
batch_names = {m.batch for m in memberships}
|
||||||
|
return [b for b in batches if b.name in batch_names]
|
||||||
|
|
||||||
|
def get_upcoming_batches(self):
|
||||||
|
now = frappe.utils.nowdate()
|
||||||
|
batches = find_all("LMS Batch",
|
||||||
|
course=self.name,
|
||||||
|
start_date=[">", now],
|
||||||
|
status="Active",
|
||||||
|
visibility="Public")
|
||||||
|
return batches
|
||||||
|
|
||||||
|
def get_chapter(self, index):
|
||||||
|
return find("Chapter", course=self.name, index_=index)
|
||||||
|
|
||||||
|
def get_lesson(self, chapter_index, lesson_index):
|
||||||
|
chapter_name = frappe.get_value(
|
||||||
|
"Chapter",
|
||||||
|
{"course": self.name, "index_": chapter_index},
|
||||||
|
"name")
|
||||||
|
lesson_name = chapter_name and frappe.get_value(
|
||||||
|
"Lesson",
|
||||||
|
{"chapter": chapter_name, "index_": lesson_index},
|
||||||
|
"name")
|
||||||
|
return lesson_name and frappe.get_doc("Lesson", lesson_name)
|
||||||
|
|
||||||
|
def get_outline(self):
|
||||||
|
return CourseOutline(self)
|
||||||
|
|
||||||
|
class CourseOutline:
|
||||||
|
def __init__(self, course):
|
||||||
|
self.course = course
|
||||||
|
self.chapters = self.get_chapters()
|
||||||
|
self.lessons = self.get_lessons()
|
||||||
|
|
||||||
|
def get_next(self, current):
|
||||||
|
numbers = sorted(lesson['number'] for lesson in self.lessons)
|
||||||
|
try:
|
||||||
|
index = numbers.index(current)
|
||||||
|
return numbers[index+1]
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_prev(self, current):
|
||||||
|
numbers = sorted(lesson['number'] for lesson in self.lessons)
|
||||||
|
try:
|
||||||
|
index = numbers.index(current)
|
||||||
|
if index == 0:
|
||||||
|
return None
|
||||||
|
return numbers[index-1]
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_chapters(self):
|
||||||
|
return frappe.db.get_all("Chapter",
|
||||||
|
filters={"course": self.course.name},
|
||||||
|
fields=["name", "title", "index_"])
|
||||||
|
|
||||||
|
def get_lessons(self):
|
||||||
|
chapters = [c['name'] for c in self.chapters]
|
||||||
|
lessons = frappe.db.get_all("Lesson",
|
||||||
|
filters={"chapter": ["IN", chapters]},
|
||||||
|
fields=["name", "title", "chapter", "index_"])
|
||||||
|
|
||||||
|
chapter_numbers = {c['name']: c['index_'] for c in self.chapters}
|
||||||
|
for lesson in lessons:
|
||||||
|
lesson['number'] = "{}.{}".format(chapter_numbers[lesson['chapter']], lesson['index_'])
|
||||||
|
return lessons
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class TestLMSCourse(unittest.TestCase):
|
|||||||
def test_new_course(self):
|
def test_new_course(self):
|
||||||
course = self.new_course("Test Course")
|
course = self.new_course("Test Course")
|
||||||
assert course.title == "Test Course"
|
assert course.title == "Test Course"
|
||||||
assert course.slug == "test-course"
|
assert course.name == "test-course"
|
||||||
assert course.get_mentors() == []
|
assert course.get_mentors() == []
|
||||||
|
|
||||||
def test_find_all(self):
|
def test_find_all(self):
|
||||||
@@ -41,7 +41,7 @@ class TestLMSCourse(unittest.TestCase):
|
|||||||
|
|
||||||
# now we should find one course
|
# now we should find one course
|
||||||
courses = LMSCourse.find_all()
|
courses = LMSCourse.find_all()
|
||||||
assert [c.slug for c in courses] == [course.slug]
|
assert [c.name for c in courses] == [course.name]
|
||||||
|
|
||||||
# disabled this test as it is failing
|
# disabled this test as it is failing
|
||||||
def _test_add_mentors(self):
|
def _test_add_mentors(self):
|
||||||
|
|||||||
@@ -8,84 +8,119 @@ from frappe.model.document import Document
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
class LMSMentorRequest(Document):
|
class LMSMentorRequest(Document):
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
if self.has_value_changed('status'):
|
if self.has_value_changed('status'):
|
||||||
template = frappe.db.get_single_value('LMS Settings', 'mentor_request_status_update')
|
|
||||||
if not template:
|
|
||||||
return
|
|
||||||
|
|
||||||
email_template = frappe.get_doc('Email Template', template)
|
if self.status == "Approved":
|
||||||
message = frappe.render_template(email_template.response, {'member_name': self.member_name, 'status': self.status})
|
self.create_course_mentor_mapping()
|
||||||
subject = _('The status of your application has changed.')
|
|
||||||
member_email = frappe.db.get_value("Community Member", self.member, "email")
|
if self.status != "Pending":
|
||||||
|
self.send_status_change_email()
|
||||||
if self.status == 'Approved' or self.status == 'Rejected':
|
|
||||||
reviewed_by = frappe.db.get_value('Community Member', self.reviewed_by, 'email')
|
def create_course_mentor_mapping(self):
|
||||||
send_email(member_email, [get_course_author(self.course), reviewed_by], subject, message)
|
mapping = frappe.get_doc({
|
||||||
|
"doctype": "LMS Course Mentor Mapping",
|
||||||
elif self.status == 'Withdrawn':
|
"mentor": self.member,
|
||||||
send_email([member_email, get_course_author(self.course)], None, subject, message)
|
"course": self.course
|
||||||
|
})
|
||||||
|
mapping.save()
|
||||||
|
|
||||||
|
def send_creation_email(self, member):
|
||||||
|
email_template = self.get_email_template('mentor_request_creation')
|
||||||
|
if not email_template:
|
||||||
|
return
|
||||||
|
|
||||||
|
course_details = frappe.db.get_value("LMS Course", self.course, ["owner", "slug", "title"], as_dict=True)
|
||||||
|
message = frappe.render_template(email_template.response,
|
||||||
|
{
|
||||||
|
'member_name': member.full_name,
|
||||||
|
'course_url': '/courses/' + course_details.slug,
|
||||||
|
'course': course_details.title
|
||||||
|
})
|
||||||
|
|
||||||
|
email_args = {
|
||||||
|
"recipients": [frappe.session.user, course_details.owner],
|
||||||
|
"subject": email_template.subject,
|
||||||
|
"header": email_template.subject,
|
||||||
|
"message": message
|
||||||
|
}
|
||||||
|
frappe.enqueue(method=frappe.sendmail, queue="short", timeout=300, is_async=True, **email_args)
|
||||||
|
|
||||||
|
def send_status_change_email(self):
|
||||||
|
email_template = self.get_email_template('mentor_request_status_update')
|
||||||
|
if not email_template:
|
||||||
|
return
|
||||||
|
|
||||||
|
course_details = frappe.db.get_value("LMS Course", self.course, ["owner", "title"], as_dict=True)
|
||||||
|
message = frappe.render_template(email_template.response,
|
||||||
|
{
|
||||||
|
'member_name': self.member_name,
|
||||||
|
'status': self.status,
|
||||||
|
'course': course_details.title
|
||||||
|
})
|
||||||
|
|
||||||
|
member_email = frappe.db.get_value("Community Member", self.member, "email")
|
||||||
|
if self.status == 'Approved' or self.status == 'Rejected':
|
||||||
|
reviewed_by = frappe.db.get_value('Community Member', self.reviewed_by, 'email')
|
||||||
|
email_args = {
|
||||||
|
"recipients": member_email,
|
||||||
|
"cc": [course_details.owner, reviewed_by],
|
||||||
|
"subject": email_template.subject,
|
||||||
|
"header": email_template.subject,
|
||||||
|
"message": message
|
||||||
|
}
|
||||||
|
frappe.enqueue(method=frappe.sendmail, queue="short", timeout=300, is_async=True, **email_args)
|
||||||
|
|
||||||
|
elif self.status == 'Withdrawn':
|
||||||
|
email_args = {
|
||||||
|
"recipients": [member_email, course_details.owner],
|
||||||
|
"subject": email_template.subject,
|
||||||
|
"header": email_template.subject,
|
||||||
|
"message": message
|
||||||
|
}
|
||||||
|
frappe.enqueue(method=frappe.sendmail, queue="short", timeout=300, is_async=True, **email_args)
|
||||||
|
|
||||||
|
def get_email_template(self, template_name):
|
||||||
|
template = frappe.db.get_single_value('LMS Settings', template_name)
|
||||||
|
if template:
|
||||||
|
return frappe.get_doc('Email Template', template)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def has_requested(course):
|
def has_requested(course):
|
||||||
return len(frappe.get_all('LMS Mentor Request',
|
return frappe.db.count('LMS Mentor Request',
|
||||||
filters = {
|
filters = {
|
||||||
'member': get_member().name,
|
'member': get_member().name,
|
||||||
'course': course,
|
'course': course,
|
||||||
'status': ['in', ('Pending', 'Approved')]
|
'status': ['in', ('Pending', 'Approved')]
|
||||||
}
|
}
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_request(course):
|
def create_request(course):
|
||||||
if not has_requested(course):
|
if not has_requested(course):
|
||||||
member = get_member()
|
member = get_member()
|
||||||
frappe.get_doc({
|
request = frappe.get_doc({
|
||||||
'doctype': 'LMS Mentor Request',
|
'doctype': 'LMS Mentor Request',
|
||||||
'member': member.name,
|
'member': member.name,
|
||||||
'course': course,
|
'course': course,
|
||||||
'status': 'Pending'
|
'status': 'Pending'
|
||||||
}).save(ignore_permissions=True)
|
})
|
||||||
send_creation_email(course, member)
|
request.save(ignore_permissions=True)
|
||||||
return 'OK'
|
request.send_creation_email(member)
|
||||||
else:
|
return 'OK'
|
||||||
return 'Already Applied'
|
|
||||||
|
else:
|
||||||
|
return 'Already Applied'
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def cancel_request(course):
|
def cancel_request(course):
|
||||||
request = frappe.get_doc('LMS Mentor Request', {'member': get_member().name, 'course': course, 'status': ['in', ('Pending', 'Approved')]})
|
request = frappe.get_doc('LMS Mentor Request', {'member': get_member().name, 'course': course, 'status': ['in', ('Pending', 'Approved')]})
|
||||||
request.status = 'Withdrawn'
|
request.status = 'Withdrawn'
|
||||||
request.save(ignore_permissions=True)
|
request.save(ignore_permissions=True)
|
||||||
return 'OK'
|
return 'OK'
|
||||||
|
|
||||||
def get_member():
|
def get_member():
|
||||||
try:
|
try:
|
||||||
return frappe.get_doc('Community Member', {'email': frappe.session.user})
|
return frappe.get_doc('Community Member', {'email': frappe.session.user})
|
||||||
except frappe.DoesNotExistError:
|
except frappe.DoesNotExistError:
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_course_author(course):
|
|
||||||
return frappe.db.get_value('LMS Course', course, 'owner')
|
|
||||||
|
|
||||||
def send_creation_email(course, member):
|
|
||||||
template = frappe.db.get_single_value('LMS Settings', 'mentor_request_creation')
|
|
||||||
if not template:
|
|
||||||
return
|
|
||||||
|
|
||||||
email_template = frappe.get_doc('Email Template', template)
|
|
||||||
member_name = member.full_name
|
|
||||||
message = frappe.render_template(email_template.response, {'member_name': member_name})
|
|
||||||
subject = _('Request for Mentorship')
|
|
||||||
send_email([frappe.session.user, get_course_author(course)], None, subject, message)
|
|
||||||
|
|
||||||
def send_email(recipients, cc, subject, message):
|
|
||||||
frappe.sendmail(
|
|
||||||
recipients = recipients,
|
|
||||||
cc = cc,
|
|
||||||
sender = frappe.db.get_single_value('LMS Settings', 'email_sender'),
|
|
||||||
subject = subject,
|
|
||||||
send_priority = 0,
|
|
||||||
queue_separately = True,
|
|
||||||
message = message
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"contents",
|
"contents",
|
||||||
"code",
|
"code",
|
||||||
"attrs",
|
"attrs",
|
||||||
"index"
|
"index",
|
||||||
|
"id"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -43,12 +44,17 @@
|
|||||||
"fieldname": "index",
|
"fieldname": "index",
|
||||||
"fieldtype": "Int",
|
"fieldtype": "Int",
|
||||||
"label": "Index"
|
"label": "Index"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "id",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "id"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-03-12 17:56:23.118854",
|
"modified": "2021-05-19 18:55:26.019625",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Section",
|
"name": "LMS Section",
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ class LMSSection(Document):
|
|||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<LMSSection {self.label!r}>"
|
return f"<LMSSection {self.label!r}>"
|
||||||
|
|
||||||
|
def get_exercise(self):
|
||||||
|
if self.type == "exercise":
|
||||||
|
return frappe.get_doc("Exercise", self.id)
|
||||||
|
|
||||||
def get_latest_code_for_user(self):
|
def get_latest_code_for_user(self):
|
||||||
"""Returns the latest code for the logged in user.
|
"""Returns the latest code for the logged in user.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"livecode_url",
|
"livecode_url",
|
||||||
|
"column_break_2",
|
||||||
|
"email_sender",
|
||||||
"mentor_request_section",
|
"mentor_request_section",
|
||||||
"mentor_request_creation",
|
"mentor_request_creation",
|
||||||
"mentor_request_status_update",
|
"mentor_request_status_update"
|
||||||
"email_sender"
|
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
@@ -40,12 +41,16 @@
|
|||||||
"fieldname": "mentor_request_section",
|
"fieldname": "mentor_request_section",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"label": "Mentor Request"
|
"label": "Mentor Request"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_2",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"issingle": 1,
|
"issingle": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-04-21 13:28:35.783395",
|
"modified": "2021-04-29 17:14:43.589700",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "LMS Settings",
|
"name": "LMS Settings",
|
||||||
|
|||||||
@@ -3,26 +3,102 @@
|
|||||||
import websocket
|
import websocket
|
||||||
import json
|
import json
|
||||||
from .svg import SVG
|
from .svg import SVG
|
||||||
|
import frappe
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
def livecode_to_svg(livecode_ws_url, code, *, timeout=1):
|
# Files to pass to livecode server
|
||||||
|
# The same code is part of livecode-canvas.js
|
||||||
|
# TODO: generate livecode-canvas.js from this file
|
||||||
|
START = '''
|
||||||
|
import sketch
|
||||||
|
code = open("main.py").read()
|
||||||
|
env = dict(sketch.__dict__)
|
||||||
|
exec(code, env)
|
||||||
|
'''
|
||||||
|
|
||||||
|
SKETCH = '''
|
||||||
|
import json
|
||||||
|
|
||||||
|
def sendmsg(msgtype, function, args):
|
||||||
|
"""Sends a message to the frontend.
|
||||||
|
|
||||||
|
The frontend will receive the specified message whenever
|
||||||
|
this function is called. The frontend can decide to some
|
||||||
|
action on each of these messages.
|
||||||
|
"""
|
||||||
|
msg = dict(msgtype=msgtype, function=function, args=args)
|
||||||
|
print("--MSG--", json.dumps(msg))
|
||||||
|
|
||||||
|
def _draw(func, **kwargs):
|
||||||
|
sendmsg(msgtype="draw", function=func, args=kwargs)
|
||||||
|
|
||||||
|
def circle(x, y, d):
|
||||||
|
"""Draws a circle of diameter d with center (x, y).
|
||||||
|
"""
|
||||||
|
_draw("circle", x=x, y=y, d=d)
|
||||||
|
|
||||||
|
def line(x1, y1, x2, y2):
|
||||||
|
"""Draws a line from point (x1, y1) to point (x2, y2).
|
||||||
|
"""
|
||||||
|
_draw("line", x1=x1, y1=y1, x2=x2, y2=y2)
|
||||||
|
|
||||||
|
def rect(x, y, w, h):
|
||||||
|
"""Draws a rectangle on the canvas.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
x: x coordinate of the top-left corner of the rectangle
|
||||||
|
y: y coordinate of the top-left corner of the rectangle
|
||||||
|
w: width of the rectangle
|
||||||
|
h: height of the rectangle
|
||||||
|
"""
|
||||||
|
_draw("rect", x=x, y=y, w=w, h=h)
|
||||||
|
|
||||||
|
def clear():
|
||||||
|
_draw("clear")
|
||||||
|
|
||||||
|
# clear the canvas on start
|
||||||
|
clear()
|
||||||
|
'''
|
||||||
|
|
||||||
|
def get_livecode_url():
|
||||||
|
doc = frappe.get_cached_doc("LMS Settings")
|
||||||
|
return doc.livecode_url
|
||||||
|
|
||||||
|
def get_livecode_ws_url():
|
||||||
|
url = urlparse(get_livecode_url())
|
||||||
|
protocol = "wss" if url.scheme == "https" else "ws"
|
||||||
|
return protocol + "://" + url.netloc + "/livecode"
|
||||||
|
|
||||||
|
def livecode_to_svg(livecode_ws_url, code, *, timeout=3):
|
||||||
"""Renders the code as svg.
|
"""Renders the code as svg.
|
||||||
"""
|
"""
|
||||||
print("livecode_to_svg")
|
if livecode_ws_url is None:
|
||||||
ws = websocket.WebSocket()
|
livecode_ws_url = get_livecode_ws_url()
|
||||||
ws.settimeout(timeout)
|
|
||||||
ws.connect(livecode_ws_url)
|
|
||||||
|
|
||||||
msg = {
|
try:
|
||||||
"msgtype": "exec",
|
ws = websocket.WebSocket()
|
||||||
"runtime": "python-canvas",
|
ws.settimeout(timeout)
|
||||||
"code": code
|
ws.connect(livecode_ws_url)
|
||||||
}
|
|
||||||
ws.send(json.dumps(msg))
|
|
||||||
|
|
||||||
messages = _read_messages(ws)
|
msg = {
|
||||||
commands = [m['cmd'] for m in messages if m['msgtype'] == 'draw']
|
"msgtype": "exec",
|
||||||
img = draw_image(commands)
|
"runtime": "python",
|
||||||
return img.tostring()
|
"code": code,
|
||||||
|
"files": [
|
||||||
|
{"filename": "start.py", "contents": START},
|
||||||
|
{"filename": "sketch.py", "contents": SKETCH},
|
||||||
|
],
|
||||||
|
"command": ["python", "start.py"]
|
||||||
|
}
|
||||||
|
ws.send(json.dumps(msg))
|
||||||
|
|
||||||
|
messages = _read_messages(ws)
|
||||||
|
commands = [m for m in messages if m['msgtype'] == 'draw']
|
||||||
|
img = draw_image(commands)
|
||||||
|
return img.tostring()
|
||||||
|
except websocket.WebSocketException as e:
|
||||||
|
frappe.log_error(frappe.get_traceback(), 'livecode_to_svg failed')
|
||||||
|
|
||||||
def _read_messages(ws):
|
def _read_messages(ws):
|
||||||
messages = []
|
messages = []
|
||||||
@@ -32,17 +108,19 @@ def _read_messages(ws):
|
|||||||
if not msg:
|
if not msg:
|
||||||
break
|
break
|
||||||
messages.append(json.loads(msg))
|
messages.append(json.loads(msg))
|
||||||
except websocket.WebSocketTimeoutException:
|
except websocket.WebSocketTimeoutException as e:
|
||||||
|
print("Error:", e)
|
||||||
pass
|
pass
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
def draw_image(commands):
|
def draw_image(commands):
|
||||||
img = SVG(width=300, height=300, viewBox="0 0 300 300", fill='none', stroke='black')
|
img = SVG(width=300, height=300, viewBox="0 0 300 300", fill='none', stroke='black')
|
||||||
for c in commands:
|
for c in commands:
|
||||||
|
args = c['args']
|
||||||
if c['function'] == 'circle':
|
if c['function'] == 'circle':
|
||||||
img.circle(cx=c['x'], cy=c['y'], r=c['d']/2)
|
img.circle(cx=args['x'], cy=args['y'], r=args['d']/2)
|
||||||
elif c['function'] == 'line':
|
elif c['function'] == 'line':
|
||||||
img.line(x1=c['x1'], y1=c['y1'], x2=c['x2'], y2=c['y2'])
|
img.line(x1=args['x1'], y1=args['y1'], x2=args['x2'], y2=args['y2'])
|
||||||
elif c['function'] == 'rect':
|
elif c['function'] == 'rect':
|
||||||
img.rect(x=c['x'], y=c['y'], width=c['w'], height=c['h'])
|
img.rect(x=args['x'], y=args['y'], width=args['w'], height=args['h'])
|
||||||
return img
|
return img
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ import frappe
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
from . import livecode
|
from . import livecode
|
||||||
|
|
||||||
|
DEFAULT_IMAGE = """
|
||||||
|
<svg viewBox="0 0 300 300" width="300" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
</svg>
|
||||||
|
"""
|
||||||
|
|
||||||
class LMSSketch(Document):
|
class LMSSketch(Document):
|
||||||
@property
|
@property
|
||||||
def sketch_id(self):
|
def sketch_id(self):
|
||||||
@@ -48,15 +53,20 @@ class LMSSketch(Document):
|
|||||||
else:
|
else:
|
||||||
ws_url = self.get_livecode_ws_url()
|
ws_url = self.get_livecode_ws_url()
|
||||||
value = livecode.livecode_to_svg(ws_url, self.code)
|
value = livecode.livecode_to_svg(ws_url, self.code)
|
||||||
cache.set(key, value)
|
if value:
|
||||||
return value
|
cache.set(key, value)
|
||||||
|
return value or DEFAULT_IMAGE
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_recent_sketches(limit=100):
|
def get_recent_sketches(limit=100, owner=None):
|
||||||
"""Returns the recent sketches.
|
"""Returns the recent sketches.
|
||||||
"""
|
"""
|
||||||
|
filters = {}
|
||||||
|
if owner:
|
||||||
|
filters = {"owner": owner}
|
||||||
sketches = frappe.get_all(
|
sketches = frappe.get_all(
|
||||||
"LMS Sketch",
|
"LMS Sketch",
|
||||||
|
filters=filters,
|
||||||
fields='*',
|
fields='*',
|
||||||
order_by='modified desc',
|
order_by='modified desc',
|
||||||
page_length=limit
|
page_length=limit
|
||||||
@@ -73,7 +83,7 @@ def save_sketch(name, title, code):
|
|||||||
doc.title = title
|
doc.title = title
|
||||||
doc.code = code
|
doc.code = code
|
||||||
doc.runtime = 'python-canvas'
|
doc.runtime = 'python-canvas'
|
||||||
doc.insert()
|
doc.insert(ignore_permissions=True)
|
||||||
status = "created"
|
status = "created"
|
||||||
else:
|
else:
|
||||||
doc = frappe.get_doc("LMS Sketch", name)
|
doc = frappe.get_doc("LMS Sketch", name)
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
"""Utility to split the text in the topic into multiple sections.
|
"""Utility to split the text in the topic into multiple sections.
|
||||||
|
|
||||||
|
{{ section(type="example", id="foo") }}
|
||||||
|
circle(100, 100, 50)
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|||||||
@@ -1,35 +1,39 @@
|
|||||||
frappe.ready(function () {
|
frappe.ready(function () {
|
||||||
frappe.web_form.after_save = () => {
|
frappe.web_form.after_save = () => {
|
||||||
let data = frappe.web_form.get_values();
|
let data = frappe.web_form.get_values();
|
||||||
frappe.call({
|
let slug = new URLSearchParams(window.location.search).get("slug")
|
||||||
"method": "community.lms.doctype.lms_batch_membership.lms_batch_membership.create_membership",
|
frappe.msgprint({
|
||||||
"args": {
|
message: __("Batch {0} has been successfully created!", [data.title]),
|
||||||
"batch": data.title,
|
clear: true
|
||||||
"member_type": "Mentor"
|
});
|
||||||
},
|
setTimeout(function () {
|
||||||
"callback": (data) => {
|
window.location.href = `courses/${slug}`;
|
||||||
if (data.message == "OK") {
|
}, 2000);
|
||||||
window.location.href = "/courses"
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
frappe.web_form.validate = () => {
|
frappe.web_form.validate = () => {
|
||||||
let data = frappe.web_form.get_values();
|
let sysdefaults = frappe.boot.sysdefaults;
|
||||||
if (!frappe.datetime.validate(data.start_time) || !frappe.datetime.validate(data.end_time)) {
|
let time_format = sysdefaults && sysdefaults.time_format ? sysdefaults.time_format : 'HH:mm:ss';
|
||||||
frappe.msgprint(__('Invalid Start or End Time.'));
|
let data = frappe.web_form.get_values();
|
||||||
return false;
|
|
||||||
}
|
data.start_time = moment(data.start_time, time_format).format(time_format)
|
||||||
if (data.start_time > data.end_time) {
|
data.end_time = moment(data.end_time, time_format).format(time_format)
|
||||||
frappe.msgprint(__('Start Time should be less than End Time.'));
|
|
||||||
return false;
|
if (data.start_date < frappe.datetime.nowdate()) {
|
||||||
}
|
frappe.msgprint(__('Start date cannot be a past date.'))
|
||||||
console.log(data.start_date, date.nowdate())
|
return false;
|
||||||
if (data.start_date < date.nowdate()) {
|
}
|
||||||
frappe.msgprint(__('Start date cannot be a past date.'))
|
|
||||||
return false;
|
if (!frappe.datetime.validate(data.start_time) || !frappe.datetime.validate(data.end_time)) {
|
||||||
}
|
frappe.msgprint(__('Invalid Start or End Time.'));
|
||||||
return true;
|
return false;
|
||||||
};
|
}
|
||||||
})
|
|
||||||
|
if (data.start_time > data.end_time) {
|
||||||
|
frappe.msgprint(__('Start Time should be less than End Time.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
"apply_document_permissions": 0,
|
"apply_document_permissions": 0,
|
||||||
"button_label": "Save",
|
"button_label": "Save",
|
||||||
"creation": "2021-04-20 11:37:49.135114",
|
"creation": "2021-04-20 11:37:49.135114",
|
||||||
|
"custom_css": ".datepicker.active {\n background-color: white;\n}",
|
||||||
"doc_type": "LMS Batch",
|
"doc_type": "LMS Batch",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "Web Form",
|
"doctype": "Web Form",
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
"is_standard": 1,
|
"is_standard": 1,
|
||||||
"login_required": 1,
|
"login_required": 1,
|
||||||
"max_attachment_size": 0,
|
"max_attachment_size": 0,
|
||||||
"modified": "2021-04-26 11:08:00.026388",
|
"modified": "2021-04-30 11:22:18.188712",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "LMS",
|
"module": "LMS",
|
||||||
"name": "add-a-new-batch",
|
"name": "add-a-new-batch",
|
||||||
@@ -37,13 +38,13 @@
|
|||||||
{
|
{
|
||||||
"allow_read_on_all_link_options": 0,
|
"allow_read_on_all_link_options": 0,
|
||||||
"fieldname": "course",
|
"fieldname": "course",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Course",
|
"label": "Course",
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"options": "LMS Course",
|
"options": "",
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"show_in_filter": 0
|
"show_in_filter": 0
|
||||||
},
|
},
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
"fieldname": "start_time",
|
"fieldname": "start_time",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "Start Time (HH:MM:SS)",
|
"label": "Start Time",
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
@@ -102,7 +103,7 @@
|
|||||||
"fieldname": "end_time",
|
"fieldname": "end_time",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"label": "End Time (HH:MM:SS)",
|
"label": "End Time",
|
||||||
"max_length": 0,
|
"max_length": 0,
|
||||||
"max_value": 0,
|
"max_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 0,
|
||||||
@@ -110,4 +111,4 @@
|
|||||||
"show_in_filter": 0
|
"show_in_filter": 0
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
# do your magic here
|
# do your magic here
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
frappe.ready(function() {
|
|
||||||
// bind events here
|
|
||||||
frappe.web_form.after_load = () => {
|
|
||||||
frappe.web_form.set_value(["batch"], [frappe.utils.get_url_arg('batch')]);
|
|
||||||
frappe.web_form.set_value(["author"], [frappe.utils.get_url_arg('author')]);
|
|
||||||
}
|
|
||||||
frappe.web_form.success_url = `courses/course?course=${frappe.utils.get_url_arg('course')}`;
|
|
||||||
|
|
||||||
$('.breadcrumb-container')
|
|
||||||
.html(`<a href="${frappe.web_form.success_url}">Back to my course</a>`)
|
|
||||||
.addClass('py-4');
|
|
||||||
})
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
{
|
|
||||||
"accept_payment": 0,
|
|
||||||
"allow_comments": 0,
|
|
||||||
"allow_delete": 0,
|
|
||||||
"allow_edit": 0,
|
|
||||||
"allow_incomplete": 0,
|
|
||||||
"allow_multiple": 0,
|
|
||||||
"allow_print": 0,
|
|
||||||
"amount": 0.0,
|
|
||||||
"amount_based_on_field": 0,
|
|
||||||
"apply_document_permissions": 0,
|
|
||||||
"button_label": "Send",
|
|
||||||
"client_script": "",
|
|
||||||
"creation": "2021-03-23 13:10:16.814983",
|
|
||||||
"doc_type": "LMS Message",
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "Web Form",
|
|
||||||
"idx": 0,
|
|
||||||
"is_standard": 1,
|
|
||||||
"login_required": 1,
|
|
||||||
"max_attachment_size": 0,
|
|
||||||
"modified": "2021-03-23 19:25:54.984968",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"module": "LMS",
|
|
||||||
"name": "add-messages",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"payment_button_label": "Buy Now",
|
|
||||||
"published": 0,
|
|
||||||
"route": "add-messages",
|
|
||||||
"route_to_success_link": 0,
|
|
||||||
"show_attachments": 0,
|
|
||||||
"show_in_grid": 0,
|
|
||||||
"show_sidebar": 0,
|
|
||||||
"sidebar_items": [],
|
|
||||||
"success_url": "",
|
|
||||||
"title": "Add Messages",
|
|
||||||
"web_form_fields": [
|
|
||||||
{
|
|
||||||
"allow_read_on_all_link_options": 0,
|
|
||||||
"fieldname": "batch",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Batch",
|
|
||||||
"max_length": 0,
|
|
||||||
"max_value": 0,
|
|
||||||
"options": "LMS Batch",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 0,
|
|
||||||
"show_in_filter": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_read_on_all_link_options": 0,
|
|
||||||
"fieldname": "message",
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"hidden": 0,
|
|
||||||
"label": "Message",
|
|
||||||
"max_length": 0,
|
|
||||||
"max_value": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"reqd": 0,
|
|
||||||
"show_in_filter": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"allow_read_on_all_link_options": 0,
|
|
||||||
"fieldname": "author",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"hidden": 1,
|
|
||||||
"label": "Author",
|
|
||||||
"max_length": 0,
|
|
||||||
"max_value": 0,
|
|
||||||
"options": "Community Member",
|
|
||||||
"read_only": 1,
|
|
||||||
"reqd": 0,
|
|
||||||
"show_in_filter": 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import frappe
|
|
||||||
|
|
||||||
def get_context(context):
|
|
||||||
# do your magic here
|
|
||||||
pass
|
|
||||||
15
community/lms/widgets/ChapterTeaser.html
Normal file
15
community/lms/widgets/ChapterTeaser.html
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<div class="chapter-teaser">
|
||||||
|
<div class="teaser-body">
|
||||||
|
<h3 class="chapter-title"><span class="chapter-number">{{index}}</span> {{ chapter.title }}</h3>
|
||||||
|
<div class="chapter-description">
|
||||||
|
{{ chapter.description or "" }}
|
||||||
|
</div>
|
||||||
|
<div class="chapter-lessons">
|
||||||
|
{% for lesson in chapter.get_lessons() %}
|
||||||
|
<div class="lesson-teaser">
|
||||||
|
{{lesson.title}}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
<div class="course-teaser">
|
<div class="course-teaser">
|
||||||
<div class="course-body">
|
<div class="course-body">
|
||||||
<h3 class="course-title"><a href="/courses/{{ course.slug }}">{{ course.title }}</a></h3>
|
<h3 class="course-title"><a href="/courses/{{ course.name }}">{{ course.title }}</a></h3>
|
||||||
<div class="course-intro">
|
<div class="course-intro">
|
||||||
{{ course.short_introduction or "" }}
|
{{ course.short_introduction or "" }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="course-footer">
|
<div class="course-footer">
|
||||||
<div class="course-author">
|
<div class="course-author">
|
||||||
{{ course.get_instructor().full_name }}
|
{% with author = course.get_instructor() %}
|
||||||
|
{{ widgets.Avatar(member=author, avatar_class="avatar-medium") }} <a href="/{{author.username}}">{{ author.full_name }}</a>
|
||||||
|
{% endwith %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
18
community/lms/widgets/Exercise.html
Normal file
18
community/lms/widgets/Exercise.html
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %}
|
||||||
|
|
||||||
|
<div class="exercise">
|
||||||
|
<h2>{{ exercise.title }}</h2>
|
||||||
|
<div class="exercise-description">{{frappe.utils.md_to_html(exercise.description)}}</div>
|
||||||
|
|
||||||
|
{% if exercise.image %}
|
||||||
|
<div class="exercise-image">{{exercise.image}}</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% set submission = exercise.get_user_submission() %}
|
||||||
|
|
||||||
|
{{ LiveCodeEditor(exercise.name,
|
||||||
|
code=exercise.code,
|
||||||
|
reset_code=exercise.code,
|
||||||
|
is_exercise=True,
|
||||||
|
last_submitted=submission and submission.creation) }}
|
||||||
|
</div>
|
||||||
64
community/lms/widgets/RequestInvite.html
Normal file
64
community/lms/widgets/RequestInvite.html
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<form id="invite-request-form">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md">
|
||||||
|
<input class="form-control w-100 mr-5 mb-5 mt-2" id="invite_email" type="email" placeholder="Email Address">
|
||||||
|
</div>
|
||||||
|
<div class="col-md">
|
||||||
|
<a type="submit" id="submit-invite-request" class="btn btn-primary btn-lg" role="button">Request
|
||||||
|
Invite</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<script>
|
||||||
|
frappe.ready(() => {
|
||||||
|
$("#submit-invite-request").click(function () {
|
||||||
|
var invite_email = $("#invite_email").val()
|
||||||
|
frappe.call({
|
||||||
|
method: "community.lms.doctype.invite_request.invite_request.create_invite_request",
|
||||||
|
args: {
|
||||||
|
invite_email: invite_email
|
||||||
|
},
|
||||||
|
callback: (data) => {
|
||||||
|
if (data.message == "invalid email") {
|
||||||
|
$(".email-validation") && $(".email-validation").remove();
|
||||||
|
if (invite_email) {
|
||||||
|
var message = `<div>
|
||||||
|
<small class="email-validation" style="color: red;">${invite_email} is not a valid email address.</small>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var message = `<div>
|
||||||
|
<small class="email-validation" style="color: red;">Please enter an email address.</small>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#invite-request-form").append(message);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#invite-request-form").hide();
|
||||||
|
|
||||||
|
if (data.message == "OK") {
|
||||||
|
var message = `<div>
|
||||||
|
<p class="lead alert alert-secondary">Thanks for your interest in Mon School. We have recorded your interest and we will get back to you shortly.</p>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (data.message == "invite") {
|
||||||
|
var message = `<div>
|
||||||
|
<p class="lead alert alert-secondary">Email ${invite_email} has already been used to request an invitation.</p>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (data.message == "user") {
|
||||||
|
var message = `<div>
|
||||||
|
<p class="lead alert alert-secondary">Looks like there is already an account with email ${invite_email}. Would you like to <a href="/login">login</a>?</p>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".jumbotron").append(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
<a href="sketches/{{sketch.sketch_id}}">{{sketch.title}}</a>
|
<a href="sketches/{{sketch.sketch_id}}">{{sketch.title}}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="sketch-author">
|
<div class="sketch-author">
|
||||||
by {{sketch.get_owner().full_name}}
|
{% set owner = sketch.get_owner() %}
|
||||||
|
by <a href="/{{owner.username}}">{{owner.full_name}}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
community.patches.set_email_preferences
|
community.patches.set_email_preferences
|
||||||
community.patches.change_name_for_community_members
|
community.patches.change_name_for_community_members
|
||||||
community.patches.save_abbr_for_community_members
|
community.patches.save_abbr_for_community_members
|
||||||
|
community.patches.create_mentor_request_email_templates
|
||||||
|
|||||||
31
community/patches/create_mentor_request_email_templates.py
Normal file
31
community/patches/create_mentor_request_email_templates.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
import frappe, os
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
frappe.reload_doc("email", "doctype", "email_template")
|
||||||
|
base_path = frappe.get_app_path("community", "templates", "emails")
|
||||||
|
|
||||||
|
if not frappe.db.exists("Email Template", _('Mentor Request Creation Template')):
|
||||||
|
response = frappe.read_file(os.path.join(base_path, "mentor_request_creation_email.html"))
|
||||||
|
frappe.get_doc({
|
||||||
|
'doctype': 'Email Template',
|
||||||
|
'name': _("Mentor Request Creation Template"),
|
||||||
|
'response': response,
|
||||||
|
'subject': _('Request for Mentorship'),
|
||||||
|
'owner': frappe.session.user
|
||||||
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
frappe.db.set_value("LMS Settings", None, "mentor_request_creation", _('Mentor Request Creation Template'))
|
||||||
|
|
||||||
|
if not frappe.db.exists("Email Template", _('Mentor Request Status Update Template')):
|
||||||
|
response = frappe.read_file(os.path.join(base_path, "mentor_request_status_update_email.html"))
|
||||||
|
frappe.get_doc({
|
||||||
|
'doctype': 'Email Template',
|
||||||
|
'name': _("Mentor Request Status Update Template"),
|
||||||
|
'response': response,
|
||||||
|
'subject': _('The status of your application has changed.'),
|
||||||
|
'owner': frappe.session.user
|
||||||
|
}).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
frappe.db.set_value("LMS Settings", None, "mentor_request_status_update", _('Mentor Request Status Update Template'))
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"css/lms.css": [
|
|
||||||
"public/css/lms.css"
|
|
||||||
],
|
|
||||||
"css/community.css": [
|
|
||||||
"public/css/style.css"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
4
community/public/css/community.bundle.less
Normal file
4
community/public/css/community.bundle.less
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
@import "./style.css";
|
||||||
|
@import "./vars.css";
|
||||||
|
@import "./style.less";
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
|
|
||||||
.livecode-editor-large .canvas-wrapper {
|
|
||||||
position: relative;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-editor-large canvas {
|
|
||||||
position: relative;
|
|
||||||
z-index: 0;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
height: 300px;
|
|
||||||
width: 300px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-editor-large .code {
|
|
||||||
width: 100%;
|
|
||||||
padding: 5px;
|
|
||||||
min-height: 330px;
|
|
||||||
resize: none;
|
|
||||||
}
|
|
||||||
.livecode-editor-large .output {
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-editor-large .CodeMirror {
|
|
||||||
height: 320px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-editor canvas {
|
|
||||||
position: relative;
|
|
||||||
z-index: 0;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
.canvas-wrapper .output {
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
width: 100%;
|
|
||||||
left: 0px;
|
|
||||||
top: 0px;
|
|
||||||
background-color: rgba(255, 255, 255, 0);
|
|
||||||
margin: 15px;
|
|
||||||
max-height: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-editor .code {
|
|
||||||
width: 100%;
|
|
||||||
padding: 5px;
|
|
||||||
/* min-height: 330px; */
|
|
||||||
resize: none;
|
|
||||||
}
|
|
||||||
/* .canvas-editor .output {
|
|
||||||
padding: 5px;
|
|
||||||
} */
|
|
||||||
|
|
||||||
.heading {
|
|
||||||
background: #eee;
|
|
||||||
padding: 10px;
|
|
||||||
clear: both;
|
|
||||||
color: #212529;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-editor-large h2 {
|
|
||||||
font-size: 1.2em;
|
|
||||||
text-transform: uppercase;
|
|
||||||
margin: 0px;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-editor-large .run {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-editor-large .col-sm {
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sketch-header h1 {
|
|
||||||
font-size: 1.5em;
|
|
||||||
margin-bottom: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sketch-header {
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sketch-card .sketch-title a {
|
|
||||||
font-weight: bold;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.canvas-editor .CodeMirror {
|
|
||||||
background: #ffe;
|
|
||||||
border: 1px solid #eed;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
border-radius: 10px;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
canvas {
|
|
||||||
border: 2px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
|
||||||
.canvas-wrapper {
|
|
||||||
margin-bottom: -200px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.canvas-wrapper {
|
|
||||||
padding-top: 20px;
|
|
||||||
margin-left: 2em;
|
|
||||||
}
|
|
||||||
.canvas-wrapper .output {
|
|
||||||
left: 2em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-controls {
|
|
||||||
margin-left: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.livecode-controls a {
|
|
||||||
margin-left: 10px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvas-editor {
|
|
||||||
margin: 10px 0px;
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.4.1/font/bootstrap-icons.css");
|
|
||||||
@import url("https://use.fontawesome.com/releases/v5.13.0/css/all.css");
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--c1: #fefae0;
|
--c1: #fefae0;
|
||||||
@@ -26,84 +24,16 @@
|
|||||||
--send-message: var(--c7);
|
--send-message: var(--c7);
|
||||||
--received-message: var(--c8);
|
--received-message: var(--c8);
|
||||||
|
|
||||||
--primary-color: #08B74F;
|
--primary-color: #08B74F !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
background: white;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.course-header {
|
|
||||||
margin-top: 20px;
|
|
||||||
padding: 20px;
|
|
||||||
background: var(--header-bg);
|
|
||||||
color: var(--header-color);
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-header h1 {
|
/* .course-details {
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-type {
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-size: 1.0em;
|
|
||||||
color: var(--tag-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar {
|
|
||||||
background: var(--sidebar-bg);
|
|
||||||
margin: 20px 0px;
|
|
||||||
border-radius: 10px;
|
|
||||||
padding: 1px 20px 20px 20px;
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar h3 {
|
|
||||||
margin-top: 20px;
|
|
||||||
color: var(--c2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar-batch {
|
|
||||||
background: var(--sidebar-bg);
|
|
||||||
color: var(--text-color);
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar-batch a {
|
|
||||||
padding: 16px 8px 8px 16px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.instructor {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.instructor-title {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.instructor-subtitle {
|
|
||||||
font-size: 0.8em;
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar .notice {
|
|
||||||
padding: 10px;
|
|
||||||
border-radius: 10px;
|
|
||||||
border: 1px dashed var(--text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar .notice a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-details {
|
|
||||||
margin: 20px 0px;
|
margin: 20px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +42,7 @@ body {
|
|||||||
font-size: 1.4em;
|
font-size: 1.4em;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin: 20px 0px 10px 0px;
|
margin: 20px 0px 10px 0px;
|
||||||
}
|
} */
|
||||||
|
|
||||||
.chapter-plan {
|
.chapter-plan {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
@@ -127,7 +57,7 @@ body {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chapter-number {
|
/* .chapter-number {
|
||||||
background: var(--text-color);
|
background: var(--text-color);
|
||||||
color: white;
|
color: white;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@@ -140,12 +70,12 @@ body {
|
|||||||
|
|
||||||
.chapter-description {
|
.chapter-description {
|
||||||
margin: 20px 0px;
|
margin: 20px 0px;
|
||||||
}
|
} */
|
||||||
|
|
||||||
.lessons {
|
.lessons {
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
.lesson {
|
.lessons .lesson {
|
||||||
margin: 5px 0px;
|
margin: 5px 0px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@@ -235,7 +165,7 @@ img.profile-photo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.msger-inputarea {
|
.msger-inputarea {
|
||||||
position: fixed;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -287,73 +217,13 @@ img.profile-photo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.message-section {
|
.message-section {
|
||||||
margin-left: 5%;
|
margin-left: 3%;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
width: 95%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sketch-teaser {
|
.display-4 {
|
||||||
background: white;
|
color: #2D005A;
|
||||||
border-radius: 10px;
|
font-weight: 600;
|
||||||
border: 1px solid #ddd;
|
line-height: 51px;
|
||||||
width: 220px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sketch-teaser svg {
|
|
||||||
width: 200px;
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sketch-image {
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sketch-footer {
|
|
||||||
padding: 10px;
|
|
||||||
background: #eee;
|
|
||||||
border-radius: 0px 0px 10px 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-teaser {
|
|
||||||
background: white;
|
|
||||||
border-radius: 10px;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
color: #444;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-teaser h3, .course-teaser h4 {
|
|
||||||
color: black;
|
|
||||||
font-weight: bold;;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-teaser .course-body, .course-teaser .course-footer {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-body {
|
|
||||||
min-height: 8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-footer {
|
|
||||||
border-top: 1px solid #ddd;
|
|
||||||
}
|
|
||||||
|
|
||||||
.course-teaser a, .course-teaser a:hover {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
|
||||||
padding: 60px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
section h2 {
|
|
||||||
margin-bottom: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
section.lightgray {
|
|
||||||
background: #f8f8f8;
|
|
||||||
}
|
|
||||||
|
|
||||||
#hero .jumbotron {
|
|
||||||
background: inherit;
|
|
||||||
}
|
}
|
||||||
|
|||||||
314
community/public/css/style.less
Normal file
314
community/public/css/style.less
Normal file
@@ -0,0 +1,314 @@
|
|||||||
|
@primary-color: #08B74F;
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 20px 0px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.teaser {
|
||||||
|
background: white;
|
||||||
|
border-radius: 9px;
|
||||||
|
border: 1px solid #C4C4C4;
|
||||||
|
|
||||||
|
.teaser-body {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.teaser-footer {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sketch-teaser {
|
||||||
|
.teaser();
|
||||||
|
width: 220px;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
margin-top: 30px;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
.sketch-image {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
.sketch-footer {
|
||||||
|
border-top: 1px solid#C4C4C4;
|
||||||
|
padding: 10px;
|
||||||
|
background: #F6F6F6;
|
||||||
|
border-radius: 0px 0px 10px 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-teaser {
|
||||||
|
.teaser();
|
||||||
|
color: #444;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
|
||||||
|
h3, h4 {
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-body, .course-footer {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-body {
|
||||||
|
min-height: 8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-footer {
|
||||||
|
border-top: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
a, a:hover {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
section {
|
||||||
|
padding: 60px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
section h2 {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
font-size: 48px;
|
||||||
|
line-height: 58px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
section.lightgray {
|
||||||
|
background: #F6F6F6;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hero .jumbotron {
|
||||||
|
background: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chapter-teaser {
|
||||||
|
.teaser();
|
||||||
|
color: #444;
|
||||||
|
margin: 20px 0px;
|
||||||
|
|
||||||
|
h3, h4 {
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-width {
|
||||||
|
width: 40%;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-grouped-links {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-info {
|
||||||
|
border-top: 0px;
|
||||||
|
margin-top: 0px;
|
||||||
|
|
||||||
|
.footer-col-right {
|
||||||
|
padding-top: 1.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.web-footer {
|
||||||
|
border-top: 1px solid #E2E6E9;
|
||||||
|
padding: 0px;
|
||||||
|
padding: 2rem 0px;
|
||||||
|
margin-top: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-type {
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 1.0em;
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--tag-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-header {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
.course-header {
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
background: var(--header-bg);
|
||||||
|
color: var(--header-color);
|
||||||
|
border-radius: 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-author-avatar {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.course-header h1 {
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// .gray-section {
|
||||||
|
// background:#F6F6F6;
|
||||||
|
// border: 1px solid #C4C4C4;
|
||||||
|
// padding: 20px;
|
||||||
|
// margin: 20px 0px;
|
||||||
|
// }
|
||||||
|
|
||||||
|
.instructor-title {
|
||||||
|
font-weight: bold;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.instructor-subtitle {
|
||||||
|
font-size: 0.8em;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
// .mentors-wrapper {
|
||||||
|
// .gray-section();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
.chapter-number {
|
||||||
|
background: var(--text-color);
|
||||||
|
color: white;
|
||||||
|
border-radius: 50%;
|
||||||
|
height: 24px;
|
||||||
|
min-width: 24px;
|
||||||
|
align-items: center;
|
||||||
|
padding: 5px 8px 2px 8px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
background: var(--sidebar-bg);
|
||||||
|
border: 1px solid var(--sidebar-border);
|
||||||
|
margin: 20px 0px;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 1px 20px 20px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar h3 {
|
||||||
|
margin-top: 20px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-batch {
|
||||||
|
background: var(--sidebar-bg);
|
||||||
|
color: var(--text-color);
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar-batch a {
|
||||||
|
padding: 16px 8px 8px 16px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.sidebar .notice {
|
||||||
|
margin-top: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px dashed var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar .notice a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
// LiveCode editor
|
||||||
|
|
||||||
|
.livecode-editor {
|
||||||
|
|
||||||
|
.CodeMirror {
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
background: #ffe;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
.CodeMirror-scroll {
|
||||||
|
max-height: 310px;
|
||||||
|
min-height: 310px;
|
||||||
|
}
|
||||||
|
.controls {
|
||||||
|
padding: 10px 0px;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
border: 5px solid #ddd;
|
||||||
|
position: relative;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.output {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 1;
|
||||||
|
width: 300px;
|
||||||
|
left: 0px;
|
||||||
|
top: 0px;
|
||||||
|
background-color: rgba(255, 255, 255, 0);
|
||||||
|
max-height: 300px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
margin: 0px;
|
||||||
|
margin-left: 20px;
|
||||||
|
padding: 4px;
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.canvas-wrapper {
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
.code-wrapper {
|
||||||
|
min-height: 50px;
|
||||||
|
}
|
||||||
|
.CodeMirror {
|
||||||
|
min-height: 50px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sketch-header {
|
||||||
|
input#sketch-title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.chapter-description {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lesson-teaser {
|
||||||
|
font-weight: bold;
|
||||||
|
color: black;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hero h1 {
|
||||||
|
color: black !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lesson-page {
|
||||||
|
margin: 20px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lesson-pagination {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.exercise-image svg {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
7
community/public/css/vars.css
Normal file
7
community/public/css/vars.css
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/* Define all your css variables here. */
|
||||||
|
:root {
|
||||||
|
--primary-color: #08B74F;
|
||||||
|
--tag-color: #737373;
|
||||||
|
--sidebar-bg: #F6F6F6;
|
||||||
|
--sidebar-border: #C4C4C4;
|
||||||
|
}
|
||||||
106
community/public/js/livecode-canvas.js
Normal file
106
community/public/js/livecode-canvas.js
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
|
||||||
|
function getLiveCodeOptions() {
|
||||||
|
var START = `
|
||||||
|
import sketch
|
||||||
|
code = open("main.py").read()
|
||||||
|
env = dict(sketch.__dict__)
|
||||||
|
exec(code, env)
|
||||||
|
`
|
||||||
|
|
||||||
|
var SKETCH = `
|
||||||
|
import json
|
||||||
|
|
||||||
|
def sendmsg(msgtype, function, args):
|
||||||
|
"""Sends a message to the frontend.
|
||||||
|
|
||||||
|
The frontend will receive the specified message whenever
|
||||||
|
this function is called. The frontend can decide to some
|
||||||
|
action on each of these messages.
|
||||||
|
"""
|
||||||
|
msg = dict(msgtype=msgtype, function=function, args=args)
|
||||||
|
print("--MSG--", json.dumps(msg))
|
||||||
|
|
||||||
|
def _draw(func, **kwargs):
|
||||||
|
sendmsg(msgtype="draw", function=func, args=kwargs)
|
||||||
|
|
||||||
|
def circle(x, y, d):
|
||||||
|
"""Draws a circle of diameter d with center (x, y).
|
||||||
|
"""
|
||||||
|
_draw("circle", x=x, y=y, d=d)
|
||||||
|
|
||||||
|
def line(x1, y1, x2, y2):
|
||||||
|
"""Draws a line from point (x1, y1) to point (x2, y2).
|
||||||
|
"""
|
||||||
|
_draw("line", x1=x1, y1=y1, x2=x2, y2=y2)
|
||||||
|
|
||||||
|
def rect(x, y, w, h):
|
||||||
|
"""Draws a rectangle on the canvas.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
x: x coordinate of the top-left corner of the rectangle
|
||||||
|
y: y coordinate of the top-left corner of the rectangle
|
||||||
|
w: width of the rectangle
|
||||||
|
h: height of the rectangle
|
||||||
|
"""
|
||||||
|
_draw("rect", x=x, y=y, w=w, h=h)
|
||||||
|
|
||||||
|
def clear():
|
||||||
|
_draw("clear")
|
||||||
|
|
||||||
|
# clear the canvas on start
|
||||||
|
clear()
|
||||||
|
`
|
||||||
|
const CANVAS_FUNCTIONS = {
|
||||||
|
circle: function(ctx, args) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(args.x, args.y, args.d/2, 0, 2*Math.PI);
|
||||||
|
ctx.stroke();
|
||||||
|
},
|
||||||
|
line: function(ctx, args) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(args.x1, args.y1);
|
||||||
|
ctx.lineTo(args.x2, args.y2);
|
||||||
|
ctx.stroke();
|
||||||
|
},
|
||||||
|
rect: function(ctx, args) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.rect(args.x, args.y, args.w, args.h);
|
||||||
|
ctx.stroke();
|
||||||
|
},
|
||||||
|
clear: function(ctx, args) {
|
||||||
|
var width = 300;
|
||||||
|
var height = 300;
|
||||||
|
ctx.clearRect(0, 0, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawOnCanvas(canvasElement, funcName, args) {
|
||||||
|
var ctx = canvasElement.getContext('2d');
|
||||||
|
var func = CANVAS_FUNCTIONS[funcName];
|
||||||
|
|
||||||
|
var scalex = canvasElement.width/300;
|
||||||
|
var scaley = canvasElement.height/300;
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.scale(scalex, scaley);
|
||||||
|
func(ctx, args);
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
runtime: "python",
|
||||||
|
files: [
|
||||||
|
{filename: "start.py", contents: START},
|
||||||
|
{filename: "sketch.py", contents: SKETCH},
|
||||||
|
],
|
||||||
|
command: ["python", "start.py"],
|
||||||
|
codemirror: true,
|
||||||
|
onMessage: {
|
||||||
|
draw: function(editor, msg) {
|
||||||
|
const canvasElement = editor.parent.querySelector("canvas");
|
||||||
|
drawOnCanvas(canvasElement, msg.function, msg.args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
22
community/query.py
Normal file
22
community/query.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
"""Utilities to find docs.
|
||||||
|
"""
|
||||||
|
import frappe
|
||||||
|
|
||||||
|
def find_all(doctype, order_by=None, **filters):
|
||||||
|
"""Queries the database for documents of a doctype matching given filters.
|
||||||
|
"""
|
||||||
|
rows = frappe.db.get_all(doctype,
|
||||||
|
filters=filters,
|
||||||
|
fields='*',
|
||||||
|
order_by=order_by)
|
||||||
|
return [frappe.get_doc(dict(row, doctype=doctype)) for row in rows]
|
||||||
|
|
||||||
|
def find(doctype, **filters):
|
||||||
|
"""Queries the database for a document of given doctype matching given filters.
|
||||||
|
"""
|
||||||
|
rows = frappe.db.get_all(doctype,
|
||||||
|
filters=filters,
|
||||||
|
fields='*')
|
||||||
|
if rows:
|
||||||
|
row = rows[0]
|
||||||
|
return frappe.get_doc(dict(row, doctype=doctype))
|
||||||
18
community/templates/emails/lms_invite_request_approved.html
Normal file
18
community/templates/emails/lms_invite_request_approved.html
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<div>
|
||||||
|
{% set site_link = "<a href='" + site_url + "'>" + site_url + "</a>" %}
|
||||||
|
<p>{{_("Dear Community Member,")}}</p>
|
||||||
|
<p>{{_("Your Invite Request to be a part of {0} has
|
||||||
|
been approved.").format(site_link)}}</p>
|
||||||
|
<p>Click on the link below to complete your Sign up and set a new password</p>
|
||||||
|
<p style="margin: 15px 0px;">
|
||||||
|
<a href="{{ signup_form_link }}" rel="nofollow" class="btn btn-primary">{{ _("Complete Sign Up") }}</a>
|
||||||
|
</p>
|
||||||
|
<br>
|
||||||
|
<p>
|
||||||
|
{{_("You can also copy-paste following link in your browser")}}<br>
|
||||||
|
<a href="{{ signup_form_link }}">{{ site_url }}{{ signup_form_link }}</a>
|
||||||
|
</p>
|
||||||
|
<br>
|
||||||
|
<p>Thanks and Regards,</p>
|
||||||
|
<p>Your Community.</p>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<div>
|
||||||
|
<p>Dear {{ member_name }},</p>
|
||||||
|
<br>
|
||||||
|
<p>You've applied to become a mentor for this course. Your request is currently under review.</p>
|
||||||
|
<p>If you are not any more interested to mentor the course {{ course }}, you can <a href="{{ course_url }}">cancel your application</a>.</p>
|
||||||
|
<br>
|
||||||
|
<p>Thanks and Regards,</p>
|
||||||
|
<p>Team Community.</p>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<div>
|
||||||
|
<p>Dear {{ member_name }},</p>
|
||||||
|
<br>
|
||||||
|
<p>Your request to join us as a mentor for the course {{ course }} has been {{ status }}.</p>
|
||||||
|
<br>
|
||||||
|
<p>Thanks and Regards,</p>
|
||||||
|
<p>Team Community.</p>
|
||||||
|
</div>
|
||||||
@@ -14,7 +14,8 @@ from frappe.utils.jinja import get_jenv
|
|||||||
# When {{widgets.SomeWidget()}} is called, it looks for
|
# When {{widgets.SomeWidget()}} is called, it looks for
|
||||||
# widgets/SomeWidgets.html in each of these modules.
|
# widgets/SomeWidgets.html in each of these modules.
|
||||||
MODULES = [
|
MODULES = [
|
||||||
"lms"
|
"lms",
|
||||||
|
"community"
|
||||||
]
|
]
|
||||||
|
|
||||||
def update_website_context(context):
|
def update_website_context(context):
|
||||||
@@ -35,8 +36,9 @@ class Widgets:
|
|||||||
'<div>Hello, World!</div>'
|
'<div>Hello, World!</div>'
|
||||||
"""
|
"""
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
|
widget_globals = {"widgets": self}
|
||||||
if not name.startswith("__"):
|
if not name.startswith("__"):
|
||||||
return Widget(name)
|
return Widget(name, widget_globals)
|
||||||
else:
|
else:
|
||||||
raise AttributeError(name)
|
raise AttributeError(name)
|
||||||
|
|
||||||
@@ -50,11 +52,13 @@ class Widget:
|
|||||||
>>> w(name="World!")
|
>>> w(name="World!")
|
||||||
'<div>Hello, World!</div>'
|
'<div>Hello, World!</div>'
|
||||||
"""
|
"""
|
||||||
def __init__(self, name):
|
def __init__(self, name, widget_globals={}):
|
||||||
|
self.widget_globals = widget_globals
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def __call__(self, **kwargs):
|
def __call__(self, **kwargs):
|
||||||
# the widget could be in any of the modules
|
# the widget could be in any of the modules
|
||||||
paths = [f"{module}/widgets/{self.name}.html" for module in MODULES]
|
paths = [f"{module}/widgets/{self.name}.html" for module in MODULES]
|
||||||
env = get_jenv()
|
env = get_jenv()
|
||||||
|
kwargs.update(self.widget_globals)
|
||||||
return env.get_or_select_template(paths).render(kwargs)
|
return env.get_or_select_template(paths).render(kwargs)
|
||||||
|
|||||||
@@ -6,22 +6,21 @@
|
|||||||
{% block head_include %}
|
{% block head_include %}
|
||||||
<meta name="description" content="Courses" />
|
<meta name="description" content="Courses" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{{ Sidebar(course_slug, batch_code) }}
|
{{ Sidebar(course.name, batch.name) }}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
{{ CourseBasicDetail(course)}}
|
{{ CourseBasicDetail(course)}}
|
||||||
{{ InstructorsSection(instructor) }}
|
{{ InstructorsSection(course.get_instructor()) }}
|
||||||
{% if batch.description %}
|
{{ BatchDetails(batch)}}
|
||||||
{{ BatchDetails(batch.description) }}
|
|
||||||
{% endif %}
|
|
||||||
{{ MentorsSection(mentors, True) }}
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% macro CourseBasicDetail(course) %}
|
{% macro CourseBasicDetail(course) %}
|
||||||
<h2>{{course.name}}</h2>
|
<h2>{{course.title}}</h2>
|
||||||
<div class="course-description">
|
<div class="course-description">
|
||||||
{{course.short_introduction}}
|
{{course.short_introduction}}
|
||||||
</div>
|
</div>
|
||||||
@@ -36,11 +35,23 @@
|
|||||||
<div>{{frappe.utils.md_to_html(course.description)}}</div>
|
<div>{{frappe.utils.md_to_html(course.description)}}</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro BatchDetails(description) %}
|
{% macro BatchDetails(batch) %}
|
||||||
<div class="mt-5">
|
<h2>About the Batch</h2>
|
||||||
<h3>About the Batch</h3>
|
|
||||||
<div>
|
<div class="batch">
|
||||||
{{ frappe.utils.md_to_html(description) }}
|
<div class="batch-details">
|
||||||
</div>
|
<div>Session every {{batch.sessions_on}}</div>
|
||||||
|
<div>{{frappe.utils.format_time(batch.start_time, "short")}} -
|
||||||
|
{{frappe.utils.format_time(batch.end_time, "short")}}</div>
|
||||||
|
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
|
||||||
|
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
|
||||||
|
|
||||||
|
{% for m in batch.get_mentors() %}
|
||||||
|
<div>
|
||||||
|
{{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }}
|
||||||
|
<span class="instructor-title">{{m.full_name}}</span>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -1,23 +1,21 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from community.www.courses.utils import redirect_if_not_a_member, get_course, get_instructor, get_batch
|
from community.lms.models import Course
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
context.course_slug = frappe.form_dict["course"]
|
|
||||||
context.course = get_course(context.course_slug)
|
|
||||||
context.batch_code = frappe.form_dict["batch"]
|
|
||||||
redirect_if_not_a_member(context.course_slug, context.batch_code)
|
|
||||||
|
|
||||||
context.instructor = get_instructor(context.course.owner)
|
course_name = frappe.form_dict["course"]
|
||||||
context.batch = get_batch(context.batch_code)
|
batch_name = frappe.form_dict["batch"]
|
||||||
context.mentors = get_mentors(context.batch.name)
|
|
||||||
print(context.mentors)
|
|
||||||
|
|
||||||
def get_mentors(batch):
|
course = Course.find(course_name)
|
||||||
mentors = []
|
if not course:
|
||||||
memberships = frappe.get_all("LMS Batch Membership", {"batch": batch, "member_type": "Mentor"}, ["member"])
|
context.template = "www/404.html"
|
||||||
for membership in memberships:
|
return
|
||||||
member = frappe.db.get_value("Community Member", membership.member, ["name","full_name"], as_dict=True)
|
|
||||||
member.batch_count = len(frappe.get_all("LMS Batch Membership", {"member": member.name, "member_type": "Mentor"}))
|
batch = course.get_batch(batch_name)
|
||||||
mentors.append(member)
|
if not batch:
|
||||||
return mentors
|
frappe.local.flags.redirect_location = "/courses/" + course_name
|
||||||
|
raise frappe.Redirect
|
||||||
|
|
||||||
|
context.course = course
|
||||||
|
context.batch = batch
|
||||||
|
|||||||
@@ -10,39 +10,33 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="course-header">
|
<div class="course-header">
|
||||||
<div class="course-type">course</div>
|
<div class="course-type">course</div>
|
||||||
<h1>{{course.title}}</h1>
|
<h1 id="course-title" data-course="{{course.name}}">{{course.title}}</h1>
|
||||||
|
<div class="course-short-intro">{{ course.short_introduction }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-9 col-md-12">
|
<div class="col-lg-8 col-md-12">
|
||||||
<div class="course-details">
|
<div class="course-details">
|
||||||
|
{{ CourseVideo(course) }}
|
||||||
|
|
||||||
{{ CourseDescription(course) }}
|
{{ CourseDescription(course) }}
|
||||||
{{ BatchSection(course, is_mentor, upcoming_batches, mentor_batches) }}
|
{{ BatchSection(course) }}
|
||||||
{{ CourseOutline(course) }}
|
{{ CourseOutline(course) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-12">
|
||||||
<div class="col-lg-3 col-md-12">
|
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
{{ InstructorsSection(instructor) }}
|
{{ InstructorsSection(course.get_instructor()) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
{{ MentorsSection(mentors, is_mentor) }}
|
{{ MentorsSection(course.get_mentors(), course.is_mentor(frappe.session.user), course.name) }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro CourseVideo(course) %}
|
||||||
{% macro CourseDescription(course) %}
|
|
||||||
<h2>Course Description</h2>
|
|
||||||
|
|
||||||
<div class="course-description">
|
|
||||||
{{ course.short_introduction }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if course.video_link %}
|
{% if course.video_link %}
|
||||||
<div class="preview-video">
|
<div class="preview-video">
|
||||||
<iframe
|
<iframe
|
||||||
@@ -57,11 +51,19 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro BatchSection(course, is_mentor, upcoming_batches, mentor_batches) %}
|
{% macro CourseDescription(course) %}
|
||||||
{% if is_mentor %}
|
<h2>Course Description</h2>
|
||||||
{{ BatchSectionForMentors(course, mentor_batches) }}
|
|
||||||
|
<div class="course-description">
|
||||||
|
{{ frappe.utils.md_to_html(course.description) }}
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro BatchSection(course) %}
|
||||||
|
{% if course.is_mentor(frappe.session.user) %}
|
||||||
|
{{ BatchSectionForMentors(course, course.get_batches(mentor=frappe.session.user)) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ BatchSectionForStudents(course, upcoming_batches) }}
|
{{ BatchSectionForStudents(course, course.get_upcoming_batches()) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
@@ -74,11 +76,9 @@
|
|||||||
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
|
<div>Starting {{frappe.utils.format_date(batch.start_date, "medium")}}</div>
|
||||||
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
|
<div class="course-type" style="color: #888; padding: 10px 0px;">mentors</div>
|
||||||
|
|
||||||
{% for m in batch.mentors %}
|
{% for m in batch.get_mentors() %}
|
||||||
<div>
|
<div>
|
||||||
{% if m.photo_url %}
|
{{ widgets.Avatar(member=m, avatar_class="avatar-medium" ) }}
|
||||||
<img class="profile-photo" src="{{m.photo_url}}">
|
|
||||||
{% endif %}
|
|
||||||
<span class="instructor-title">{{m.full_name}}</span>
|
<span class="instructor-title">{{m.full_name}}</span>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -86,9 +86,10 @@
|
|||||||
<div class="cta">
|
<div class="cta">
|
||||||
<div class="">
|
<div class="">
|
||||||
{% if can_manage %}
|
{% if can_manage %}
|
||||||
<button type="button">Manage</button>
|
<a href="/courses/{{course.name}}/{{batch.name}}/about" class="btn btn-secondary">Manage</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<button type="button">Join this Batch</button>
|
<button class="join-batch" data-batch="{{ batch.name | urlencode }}"
|
||||||
|
data-course="{{ course.name | urlencode }}">Join this Batch</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -99,7 +100,7 @@
|
|||||||
<h2>Your Batches</h2>
|
<h2>Your Batches</h2>
|
||||||
|
|
||||||
{% if mentor_batches %}
|
{% if mentor_batches %}
|
||||||
<div class="message">
|
<div class="alert alert-secondary">
|
||||||
You are a mentor for this course. Manage your batches or create a new batch from here.
|
You are a mentor for this course. Manage your batches or create a new batch from here.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -111,11 +112,11 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="btn btn-primary add-batch margin-bottom" href="/add-a-new-batch?new=1&course={{course.name}}">Add a new batch</a>
|
<a class="btn btn-primary add-batch margin-bottom" href="/add-a-new-batch?new=1&course={{course.title}}&slug={{course.name}}">Add a new batch</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="mentor_message">
|
<div class="mentor_message">
|
||||||
<p> You are a mentor for this course. </p>
|
<p> You are a mentor for this course. </p>
|
||||||
<a class="btn btn-primary" href="/add-a-new-batch?new=1&course={{course.name}}" >Create your first batch</a>
|
<a class="btn btn-primary" href="/add-a-new-batch?new=1&course={{course.title}}&slug={{course.name}}" >Create your first batch</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
@@ -123,33 +124,19 @@
|
|||||||
{% macro BatchSectionForStudents(course, upcoming_batches) %}
|
{% macro BatchSectionForStudents(course, upcoming_batches) %}
|
||||||
<h2>Upcoming Batches</h2>
|
<h2>Upcoming Batches</h2>
|
||||||
|
|
||||||
{% for batch in upcoming_batches %}
|
<div class="row">
|
||||||
<div class="col-lg-4 col-md-6">
|
{% for batch in upcoming_batches %}
|
||||||
{{ RenderBatch(batch, can_manage=False) }}
|
<div class="col-lg-4 col-md-6">
|
||||||
|
{{ RenderBatch(batch, can_manage=False) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro CourseOutline(course) %}
|
{% macro CourseOutline(course) %}
|
||||||
<h2>Course Outline</h2>
|
<h2>Course Outline</h2>
|
||||||
|
|
||||||
{% for chapter in course.topics %}
|
{% for chapter in course.get_chapters() %}
|
||||||
<div class="chapter-plan">
|
{{ widgets.ChapterTeaser(index=loop.index, chapter=chapter)}}
|
||||||
<h3><span class="chapter-number">{{loop.index}}</span> {{chapter.title}}</h3>
|
{% endfor %}
|
||||||
<div class="chapter-description">
|
|
||||||
{{chapter.preview | markdown}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{#
|
|
||||||
<div class="lessons">
|
|
||||||
{% for lesson in chapter.lessons %}
|
|
||||||
<div class="lesson">
|
|
||||||
<span class="lesson-type"><i class="{{lesson.icon}}"></i></span>
|
|
||||||
<span class="lesson-title">{{lesson.title}}</span>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
#}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -3,20 +3,21 @@ frappe.ready(() => {
|
|||||||
frappe.call({
|
frappe.call({
|
||||||
'method': 'community.lms.doctype.lms_mentor_request.lms_mentor_request.has_requested',
|
'method': 'community.lms.doctype.lms_mentor_request.lms_mentor_request.has_requested',
|
||||||
'args': {
|
'args': {
|
||||||
course: decodeURIComponent($(".course-title").attr("data-course")),
|
course: decodeURIComponent($("#course-title").attr("data-course")),
|
||||||
},
|
},
|
||||||
'callback': (data) => {
|
'callback': (data) => {
|
||||||
if (data.message) {
|
if (data.message > 0) {
|
||||||
$(".mentor-request").addClass("hide");
|
$("#mentor-request").addClass("hide");
|
||||||
$(".already-applied").removeClass("hide")
|
$("#already-applied").removeClass("hide")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".apply-now").click((e) => {
|
$("#apply-now").click((e) => {
|
||||||
|
e.preventDefault();
|
||||||
if (frappe.session.user == "Guest") {
|
if (frappe.session.user == "Guest") {
|
||||||
window.location.href = "/login";
|
window.location.href = `/login?redirect-to=/courses/${$(e.currentTarget).attr("data-course")}`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
frappe.call({
|
frappe.call({
|
||||||
@@ -26,14 +27,15 @@ frappe.ready(() => {
|
|||||||
},
|
},
|
||||||
"callback": (data) => {
|
"callback": (data) => {
|
||||||
if (data.message == "OK") {
|
if (data.message == "OK") {
|
||||||
$(".mentor-request").addClass("hide");
|
$("#mentor-request").addClass("hide");
|
||||||
$(".already-applied").removeClass("hide")
|
$("#already-applied").removeClass("hide")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
$(".cancel-request").click((e) => {
|
$("#cancel-request").click((e) => {
|
||||||
|
e.preventDefault()
|
||||||
frappe.call({
|
frappe.call({
|
||||||
"method": "community.lms.doctype.lms_mentor_request.lms_mentor_request.cancel_request",
|
"method": "community.lms.doctype.lms_mentor_request.lms_mentor_request.cancel_request",
|
||||||
"args": {
|
"args": {
|
||||||
@@ -41,16 +43,17 @@ frappe.ready(() => {
|
|||||||
},
|
},
|
||||||
"callback": (data) => {
|
"callback": (data) => {
|
||||||
if (data.message == "OK") {
|
if (data.message == "OK") {
|
||||||
$(".mentor-request").removeClass("hide");
|
$("#mentor-request").removeClass("hide");
|
||||||
$(".already-applied").addClass("hide")
|
$("#already-applied").addClass("hide")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
$(".join-batch").click((e) => {
|
$(".join-batch").click((e) => {
|
||||||
|
e.preventDefault()
|
||||||
if (frappe.session.user == "Guest") {
|
if (frappe.session.user == "Guest") {
|
||||||
window.location.href = "/login";
|
window.location.href = `/login?redirect-to=/courses/${$(e.currentTarget).attr("data-course")}`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
batch = decodeURIComponent($(e.currentTarget).attr("data-batch"))
|
batch = decodeURIComponent($(e.currentTarget).attr("data-batch"))
|
||||||
@@ -62,10 +65,8 @@ frappe.ready(() => {
|
|||||||
"callback": (data) => {
|
"callback": (data) => {
|
||||||
if (data.message == "OK") {
|
if (data.message == "OK") {
|
||||||
frappe.msgprint(__("You are now a student of this course."))
|
frappe.msgprint(__("You are now a student of this course."))
|
||||||
$(".upcoming-batches").addClass("hide")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,101 +1,26 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from community.www.courses.utils import get_instructor
|
from community.www.courses.utils import get_instructor
|
||||||
from frappe.utils import nowdate, getdate
|
from frappe.utils import nowdate, getdate
|
||||||
|
from community.lms.models import Course
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
course_id = frappe.form_dict["course"]
|
course_name = frappe.form_dict["course"]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
frappe.local.flags.redirect_location = "/courses"
|
frappe.local.flags.redirect_location = "/courses"
|
||||||
raise frappe.Redirect
|
raise frappe.Redirect
|
||||||
|
|
||||||
context.course = get_course(course_id)
|
course = Course.find(course_name)
|
||||||
context.batches = get_course_batches(context.course.name)
|
if course is None:
|
||||||
context.is_mentor = is_mentor(context.course.name)
|
frappe.local.flags.redirect_location = "/courses"
|
||||||
context.memberships = get_membership(context.batches)
|
|
||||||
if len(context.memberships) and not context.is_mentor:
|
|
||||||
frappe.local.flags.redirect_location = "/courses/" + course_id + "/" + context.memberships[0].code + "/learn"
|
|
||||||
raise frappe.Redirect
|
raise frappe.Redirect
|
||||||
context.upcoming_batches = get_upcoming_batches(context.course.name)
|
|
||||||
context.instructor = get_instructor(context.course.owner)
|
|
||||||
context.mentors = get_mentors(context.course.name)
|
|
||||||
|
|
||||||
if context.is_mentor:
|
|
||||||
context.mentor_batches = get_mentor_batches(context.memberships) # Your Bacthes for mentor
|
|
||||||
|
|
||||||
def get_course(slug):
|
context.course = course
|
||||||
course = frappe.db.get_value("LMS Course", {"slug": slug},
|
|
||||||
["name", "slug", "title", "description", "short_introduction", "video_link", "owner"], as_dict=1)
|
|
||||||
|
|
||||||
course["topics"] = frappe.db.get_all("LMS Topic",
|
batch = course.get_student_batch(frappe.session.user)
|
||||||
filters={
|
if batch:
|
||||||
"course": course["name"]
|
frappe.local.flags.redirect_location = f"/courses/{course.name}/{batch.name}/learn"
|
||||||
},
|
raise frappe.Redirect
|
||||||
fields=["name", "slug", "title", "preview"],
|
|
||||||
order_by="creation"
|
|
||||||
)
|
|
||||||
return course
|
|
||||||
|
|
||||||
def get_upcoming_batches(course):
|
|
||||||
batches = frappe.get_all("LMS Batch", {"course": course, "start_date": [">", nowdate()]}, ["start_date", "start_time", "end_time", "sessions_on", "name"])
|
|
||||||
batches = get_batch_mentors(batches)
|
|
||||||
return batches
|
|
||||||
|
|
||||||
def get_batch_mentors(batches):
|
|
||||||
for batch in batches:
|
|
||||||
batch.mentors = []
|
|
||||||
mentors = frappe.get_all("LMS Batch Membership", {"batch": batch.name, "member_type": "Mentor"}, ["member"])
|
|
||||||
for mentor in mentors:
|
|
||||||
member = frappe.db.get_value("Community Member", mentor.member, ["full_name", "photo", "abbr"], as_dict=1)
|
|
||||||
batch.mentors.append(member)
|
|
||||||
return batches
|
|
||||||
|
|
||||||
def get_membership(batches):
|
|
||||||
memberships = []
|
|
||||||
member = frappe.db.get_value("Community Member", {"email": frappe.session.user}, "name")
|
|
||||||
for batch in batches:
|
|
||||||
membership = frappe.db.get_value("LMS Batch Membership", {"member": member, "batch": batch.name}, ["batch", "member", "member_type"], as_dict=1)
|
|
||||||
if membership:
|
|
||||||
membership.code = batch.code
|
|
||||||
memberships.append(membership)
|
|
||||||
return memberships
|
|
||||||
|
|
||||||
def get_mentors(course):
|
|
||||||
course_mentors = []
|
|
||||||
mentors = frappe.get_all("LMS Course Mentor Mapping", {"course": course}, ["mentor"])
|
|
||||||
for mentor in mentors:
|
|
||||||
member = frappe.get_doc("Community Member", mentor.mentor)
|
|
||||||
member.batch_count = len(frappe.get_all("LMS Batch Membership", {"member": member.name, "member_type": "Mentor"}))
|
|
||||||
course_mentors.append(member)
|
|
||||||
return course_mentors
|
|
||||||
|
|
||||||
def get_course_batches(course):
|
|
||||||
return frappe.get_all("LMS Batch", {"course": course}, ["name", "code"])
|
|
||||||
|
|
||||||
def get_mentor_batches(memberships):
|
|
||||||
mentor_batches = []
|
|
||||||
memberships_as_mentor = list(filter(lambda x: x.member_type == "Mentor", memberships))
|
|
||||||
for membership in memberships_as_mentor:
|
|
||||||
batch = frappe.get_doc("LMS Batch", membership.batch)
|
|
||||||
mentor_batches.append(batch)
|
|
||||||
for batch in mentor_batches:
|
|
||||||
if getdate(batch.start_date) < getdate():
|
|
||||||
batch.status = "active"
|
|
||||||
batch.badge_class = "green_badge"
|
|
||||||
else:
|
|
||||||
batch.status = "scheduled"
|
|
||||||
batch.badge_class = "yellow_badge"
|
|
||||||
mentor_batches = get_batch_mentors(mentor_batches)
|
|
||||||
return mentor_batches
|
|
||||||
|
|
||||||
def is_mentor(course):
|
|
||||||
try:
|
|
||||||
member = frappe.db.get_value("Community Member", {"email": frappe.session.user}, ["name"])
|
|
||||||
except frappe.DoesNotExistError:
|
|
||||||
return False
|
|
||||||
mapping = frappe.get_all("LMS Course Mentor Mapping", {"course": course, "mentor": member})
|
|
||||||
if len(mapping):
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
{% block head_include %}
|
{% block head_include %}
|
||||||
<meta name="description" content="Courses" />
|
<meta name="description" content="Courses" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@@ -14,10 +16,12 @@
|
|||||||
<div class="batch-header">
|
<div class="batch-header">
|
||||||
{{ BatchHearder(course.name, member_count) }}
|
{{ BatchHearder(course.name, member_count) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="message-section">
|
<div class="messages">
|
||||||
{{ Messages(messages) }}
|
<div class="message-section">
|
||||||
|
{{ Messages(messages) }}
|
||||||
|
</div>
|
||||||
|
{{ TextArea() }}
|
||||||
</div>
|
</div>
|
||||||
{{ TextArea() }}
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
@@ -44,4 +48,4 @@
|
|||||||
<input type="text" class="msger-input" placeholder="Write your message...">
|
<input type="text" class="msger-input" placeholder="Write your message...">
|
||||||
<button type="submit" class="msger-send-btn" data-batch="{{batch.name | urlencode }}">Send</button>
|
<button type="submit" class="msger-send-btn" data-batch="{{batch.name | urlencode }}">Send</button>
|
||||||
</form>
|
</form>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -26,11 +26,11 @@
|
|||||||
{% macro course_card(course) %}
|
{% macro course_card(course) %}
|
||||||
<div class="card mb-5 w-100">
|
<div class="card mb-5 w-100">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title"><a href="/courses/{{course.slug}}">{{course.title}}</a></h5>
|
<h5 class="card-title"><a href="/courses/{{course.name}}">{{course.title}}</a></h5>
|
||||||
{% if course.description %}
|
{% if course.description %}
|
||||||
<p class="card-text">{{ frappe.utils.md_to_html(course.description[:250]) }}</p>
|
<p class="card-text">{{ frappe.utils.md_to_html(course.description[:250]) }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="/courses/{{course.slug}}" class="card-link">See more →</a>
|
<a href="/courses/{{course.name}}" class="card-link">See more →</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ def get_context(context):
|
|||||||
def get_courses():
|
def get_courses():
|
||||||
courses = frappe.get_all(
|
courses = frappe.get_all(
|
||||||
"LMS Course",
|
"LMS Course",
|
||||||
fields=['name', 'slug', 'title', 'description']
|
fields=['name', 'title', 'description']
|
||||||
)
|
)
|
||||||
return courses
|
return courses
|
||||||
|
|||||||
@@ -1,13 +1,132 @@
|
|||||||
{% extends "templates/base.html" %}
|
{% extends "templates/base.html" %}
|
||||||
{% from "www/macros/sidebar.html" import Sidebar %}
|
{% from "www/macros/sidebar.html" import Sidebar %}
|
||||||
{% block title %}Learn{% endblock %}
|
{% from "www/macros/livecode.html" import LiveCodeEditorJS, LiveCodeEditor with context %}
|
||||||
|
{% block title %}{{ lesson.title }}{% endblock %}
|
||||||
|
|
||||||
{% block head_include %}
|
{% block head_include %}
|
||||||
<meta name="description" content="Courses" />
|
<meta name="description" content="{{lesson.title}} - {{course.title}}" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="{{lesson.title}} - {{course.title}}" />
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||||
|
<link rel="stylesheet" href="{{ livecode_url }}/static/codemirror/lib/codemirror.css">
|
||||||
|
<link rel="stylesheet" href="/assets/css/lms.css">
|
||||||
|
|
||||||
|
<script src="{{ livecode_url }}/static/codemirror/lib/codemirror.js"></script>
|
||||||
|
<script src="{{ livecode_url }}/static/codemirror/mode/python/python.js"></script>
|
||||||
|
<script src="{{ livecode_url }}/static/codemirror/keymap/sublime.js"></script>
|
||||||
|
|
||||||
|
<script src="{{ livecode_url }}/static/codemirror/addon/edit/matchbrackets.js"></script>
|
||||||
|
<script src="{{ livecode_url }}/static/codemirror/addon/comment/comment.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{{ Sidebar(course, batch_code) }}
|
{{ Sidebar(course.name, batch.name) }}
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
<div class="lesson-page">
|
||||||
|
{{ pagination(prev_url, next_url) }}
|
||||||
|
|
||||||
|
<h2>{{ lesson.title }}</h2>
|
||||||
|
|
||||||
|
{% for s in lesson.get_sections() %}
|
||||||
|
<div class="section section-{{ s.type }}">
|
||||||
|
{{ render_section(s) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{{ pagination(prev_url, next_url) }}
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
{% macro render_section(s) %}
|
||||||
|
{% if s.type == "text" %}
|
||||||
|
{{ render_section_text(s) }}
|
||||||
|
{% elif s.type == "example" or s.type == "code" %}
|
||||||
|
{{ LiveCodeEditor(s.name,
|
||||||
|
code=s.get_latest_code_for_user(),
|
||||||
|
reset_code=s.contents,
|
||||||
|
is_exercise=False)
|
||||||
|
}}
|
||||||
|
{% elif s.type == "exercise" %}
|
||||||
|
{{ widgets.Exercise(exercise=s.get_exercise())}}
|
||||||
|
{% else %}
|
||||||
|
<div>Unknown section type: {{s.type}}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro render_section_text(s) %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9">
|
||||||
|
{{ frappe.utils.md_to_html(s.contents) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{% macro pagination(prev_url, next_url) %}
|
||||||
|
<div class="lesson-pagination">
|
||||||
|
{% if prev_url %}
|
||||||
|
<a href="{{prev_url}}" class="btn">← Prev</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if next_url %}
|
||||||
|
<a href="{{next_url}}" class="btn pull-right">Next →</a>
|
||||||
|
{% endif %}
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
</div>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{%- block script %}
|
||||||
|
{{ super() }}
|
||||||
|
{{ LiveCodeEditorJS() }}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
var editorLookup = {};
|
||||||
|
|
||||||
|
$(".canvas-editor").each((i, e) => {
|
||||||
|
var data = $(e).data();
|
||||||
|
var editor = new LiveCodeEditor(e, {
|
||||||
|
runtime: "python-canvas",
|
||||||
|
base_url: "{{ livecode_url }}",
|
||||||
|
codemirror: true,
|
||||||
|
userdata: data,
|
||||||
|
autosave: function(editor, code) {
|
||||||
|
// can't autosave when user is Guest
|
||||||
|
if (frappe.session.user == "Guest") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = editor.options.userdata;
|
||||||
|
var code = editor.codemirror.doc.getValue();
|
||||||
|
// console.log("autosaving...")
|
||||||
|
frappe.call("community.lms.api.autosave_section", {
|
||||||
|
section: data.section,
|
||||||
|
code: code
|
||||||
|
}).then((r) => {
|
||||||
|
// TODO: verify
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
editorLookup[data.section] = editor;
|
||||||
|
})
|
||||||
|
|
||||||
|
$(".canvas-editor .reset").each((i, e) => {
|
||||||
|
$(e).on("click", function(event) {
|
||||||
|
var data = $(this).parents(".canvas-editor").data();
|
||||||
|
var section = data.section;
|
||||||
|
frappe.call("community.lms.api.get_section", {
|
||||||
|
name: section
|
||||||
|
}).then(r => {
|
||||||
|
var editor = editorLookup[data.section];
|
||||||
|
editor.codemirror.doc.setValue(r.message.contents);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script> -->
|
||||||
|
{%- endblock %}
|
||||||
|
|||||||
@@ -1,10 +1,46 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from community.www.courses.utils import redirect_if_not_a_member
|
from community.lms.models import Course
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
context.course = frappe.form_dict["course"]
|
|
||||||
context.batch_code = frappe.form_dict["batch"]
|
course_name = frappe.form_dict["course"]
|
||||||
redirect_if_not_a_member(context.course, context.batch_code)
|
batch_name = frappe.form_dict["batch"]
|
||||||
|
chapter_index = frappe.form_dict.get("chapter")
|
||||||
print(context)
|
lesson_index = frappe.form_dict.get("lesson")
|
||||||
|
lesson_number = f"{chapter_index}.{lesson_index}"
|
||||||
|
|
||||||
|
course = Course.find(course_name)
|
||||||
|
if not course:
|
||||||
|
context.template = "www/404.html"
|
||||||
|
return
|
||||||
|
|
||||||
|
batch = course.get_batch(batch_name)
|
||||||
|
if not batch:
|
||||||
|
frappe.local.flags.redirect_location = "/courses/" + course_name
|
||||||
|
raise frappe.Redirect
|
||||||
|
|
||||||
|
if not chapter_index or not lesson_index:
|
||||||
|
frappe.local.flags.redirect_location = f"/courses/{course_name}/{batch_name}/learn/1.1"
|
||||||
|
raise frappe.Redirect
|
||||||
|
|
||||||
|
context.course = course
|
||||||
|
context.batch = batch
|
||||||
|
context.lesson = course.get_lesson(chapter_index, lesson_index)
|
||||||
|
context.lesson_index = lesson_index
|
||||||
|
context.chapter_index = chapter_index
|
||||||
|
context.livecode_url = get_livecode_url()
|
||||||
|
|
||||||
|
outline = course.get_outline()
|
||||||
|
next_ = outline.get_next(lesson_number)
|
||||||
|
prev_ = outline.get_prev(lesson_number)
|
||||||
|
context.next_url = get_learn_url(course_name, batch_name, next_)
|
||||||
|
context.prev_url = get_learn_url(course_name, batch_name, prev_)
|
||||||
|
|
||||||
|
def get_learn_url(course_name, batch_name, lesson_number):
|
||||||
|
if not lesson_number:
|
||||||
|
return
|
||||||
|
return f"/courses/{course_name}/{batch_name}/learn/{lesson_number}"
|
||||||
|
|
||||||
|
def get_livecode_url():
|
||||||
|
return frappe.db.get_single_value("LMS Settings", "livecode_url")
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
{% block head_include %}
|
{% block head_include %}
|
||||||
<meta name="description" content="Courses" />
|
<meta name="description" content="Courses" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="" />
|
||||||
|
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
{% block head_include %}
|
{% block head_include %}
|
||||||
<meta name="description" content="Courses" />
|
<meta name="description" content="Courses" />
|
||||||
<meta name="keywords" content="" />
|
<meta name="keywords" content="" />
|
||||||
|
<link rel="stylesheet" href="/assets/frappe/css/font-awesome.css">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ def get_member_with_name(name):
|
|||||||
|
|
||||||
def get_batch(code):
|
def get_batch(code):
|
||||||
try:
|
try:
|
||||||
return frappe.db.get_value("LMS Batch", {"code": code}, ["name", "description"], as_dict=True)
|
print("get_batch", code)
|
||||||
|
return frappe.db.get_value("LMS Batch", {"name": code}, ["name", "description"], as_dict=True)
|
||||||
except frappe.DoesNotExistError:
|
except frappe.DoesNotExistError:
|
||||||
|
print("Error: notfound")
|
||||||
return
|
return
|
||||||
|
|
||||||
def is_member_of_batch(batch_code):
|
def is_member_of_batch(batch_code):
|
||||||
membership = frappe.get_all("LMS Batch Membership", {"batch": get_batch(batch_code).name, "member": get_member_with_email()})
|
membership = frappe.get_all("LMS Batch Membership", {"batch": batch_code, "member": get_member_with_email()})
|
||||||
if len(membership):
|
if len(membership):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@@ -29,9 +31,9 @@ def redirect_if_not_a_member(course,batch_code):
|
|||||||
frappe.local.flags.redirect_location = "/courses/" + course
|
frappe.local.flags.redirect_location = "/courses/" + course
|
||||||
raise frappe.Redirect
|
raise frappe.Redirect
|
||||||
|
|
||||||
def get_course(slug):
|
def get_course(name):
|
||||||
try:
|
try:
|
||||||
return frappe.get_doc("LMS Course", {"slug": slug})
|
return frappe.get_doc("LMS Course", {"name": name})
|
||||||
except frappe.DoesNotExistError:
|
except frappe.DoesNotExistError:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -54,4 +56,4 @@ def get_batch_members(batch):
|
|||||||
if membership.member_type == "Mentor":
|
if membership.member_type == "Mentor":
|
||||||
member.is_mentor = True
|
member.is_mentor = True
|
||||||
members.append(member)
|
members.append(member)
|
||||||
return members
|
return members
|
||||||
|
|||||||
@@ -182,8 +182,8 @@
|
|||||||
{% for course in courses %}
|
{% for course in courses %}
|
||||||
<div class="dashboard__course">
|
<div class="dashboard__course">
|
||||||
<div class="dashboard__courseHeader">
|
<div class="dashboard__courseHeader">
|
||||||
<a class="text-decoration-none" target="_blank" href="/courses/{{course.slug}}">
|
<a class="text-decoration-none" target="_blank" href="/courses/{{course.name}}">
|
||||||
<h5 class="w-75">{{ course.name }}</h5>
|
<h5 class="w-75">{{ course.title }}</h5>
|
||||||
</a>
|
</a>
|
||||||
{% if course.member_type %}
|
{% if course.member_type %}
|
||||||
<div class="dashboard__badge">
|
<div class="dashboard__badge">
|
||||||
|
|||||||
@@ -1,38 +1,42 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from ...lms.doctype.lms_sketch.lms_sketch import get_recent_sketches
|
from community.lms.models import Sketch
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
context.member = frappe.get_all("Community Member", {"email": frappe.session.user}, ["name", "email", "photo", "full_name", "abbr"])[0]
|
if frappe.session.user == "Guest":
|
||||||
context.memberships = get_memberships(context.member.name)
|
frappe.local.flags.redirect_location = "/login"
|
||||||
context.courses = get_courses(context.memberships)
|
raise frappe.Redirect
|
||||||
context.activity = get_activity(context.memberships)
|
context.member = frappe.get_all("Community Member", {"email": frappe.session.user}, ["name", "email", "photo", "full_name", "abbr"])[0]
|
||||||
context.sketches = list(filter(lambda x: x.owner == frappe.session.user, get_recent_sketches()))
|
context.memberships = get_memberships(context.member.name)
|
||||||
|
context.courses = get_courses(context.memberships)
|
||||||
|
context.activity = get_activity(context.memberships)
|
||||||
|
context.sketches = list(filter(lambda x: x.owner == frappe.session.user, Sketch.get_recent_sketches(owner=context.member.email)))
|
||||||
|
|
||||||
def get_memberships(member):
|
def get_memberships(member):
|
||||||
return frappe.get_all("LMS Batch Membership", {"member": member}, ["batch", "member_type", "creation"])
|
return frappe.get_all("LMS Batch Membership", {"member": member}, ["batch", "member_type", "creation"])
|
||||||
|
|
||||||
def get_courses(memberships):
|
def get_courses(memberships):
|
||||||
courses = []
|
courses = []
|
||||||
for membership in memberships:
|
for membership in memberships:
|
||||||
course = frappe.db.get_value("LMS Batch", membership.batch, "course")
|
course = frappe.db.get_value("LMS Batch", membership.batch, "course")
|
||||||
course_details = frappe.get_doc("LMS Course", course)
|
course_details = frappe.get_doc("LMS Course", course)
|
||||||
course_in_list = list(filter(lambda x: x.name == course_details.name, courses))
|
course_in_list = list(filter(lambda x: x.name == course_details.name, courses))
|
||||||
if not len(course_in_list):
|
if not len(course_in_list):
|
||||||
course_details.description = course_details.description[0:100] + "..."
|
course_details.description = course_details.description[0:100] + "..."
|
||||||
course_details.joining = membership.creation
|
course_details.joining = membership.creation
|
||||||
if membership.member_type != "Student":
|
if membership.member_type != "Student":
|
||||||
course_details.member_type = membership.member_type
|
course_details.member_type = membership.member_type
|
||||||
courses.append(course_details)
|
courses.append(course_details)
|
||||||
return courses
|
return courses
|
||||||
|
|
||||||
def get_activity(memberships):
|
def get_activity(memberships):
|
||||||
messages, courses = [], {}
|
messages, courses = [], {}
|
||||||
batches = [x.batch for x in memberships]
|
batches = [x.batch for x in memberships]
|
||||||
for batch in batches:
|
for batch in batches:
|
||||||
courses[batch] = frappe.db.get_value("LMS Batch", batch, "course")
|
courses[batch] = frappe.db.get_value("LMS Batch", batch, "course")
|
||||||
messages = frappe.get_all("LMS Message", {"batch": ["in", ",".join(batches)]}, ["message", "author", "creation", "batch"], order_by='creation desc')
|
messages = frappe.get_all("LMS Message", {"batch": ["in", ",".join(batches)]}, ["message", "author", "creation", "batch"], order_by='creation desc')
|
||||||
for message in messages:
|
for message in messages:
|
||||||
message.course = courses[message.batch]
|
message.course = courses[message.batch]
|
||||||
message.profile, message.full_name, message.abbr = frappe.db.get_value("Community Member", message.author, ["photo", "full_name", "abbr"])
|
message.profile, message.full_name, message.abbr = frappe.db.get_value("Community Member", message.author, ["photo", "full_name", "abbr"])
|
||||||
return messages
|
return messages
|
||||||
|
|||||||
@@ -10,11 +10,9 @@
|
|||||||
<section id="hero">
|
<section id="hero">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<h1 class="display-4">Guided online courses, with a mentor at your back.</h1>
|
<h1 class="display-4">Guided online courses, with a <br />mentor at your back.</h1>
|
||||||
<p class="lead">Hands-on online courses designed by experts, delivered by passionate mentors.</p>
|
<p class="lead">Hands-on online courses designed by experts, delivered by passionate mentors.</p>
|
||||||
<p class="lead">
|
{{ widgets.RequestInvite() }}
|
||||||
<a class="btn btn-primary btn-lg" href="#" role="button">Request Invite</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,32 +1,37 @@
|
|||||||
{% macro InstructorsSection(instructor) %}
|
{% macro InstructorsSection(instructor) %}
|
||||||
<h3>Instructor</h3>
|
<h3>Instructor</h3>
|
||||||
<div class="instructor">
|
<div class="instructor">
|
||||||
<div class="instructor-title">{{instructor.full_name}}</div>
|
<div class="instructor-title">{{instructor.full_name}}</div>
|
||||||
<div class="instructor-subtitle">Created {{instructor.course_count}} courses</div>
|
<div class="instructor-subtitle">Created {{instructor.get_course_count()}} courses</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro MentorsSection(mentors, is_mentor) %}
|
{% macro MentorsSection(mentors, is_mentor, course_name) %}
|
||||||
<h3>Mentors</h3>
|
<h3>Mentors</h3>
|
||||||
{% for m in mentors %}
|
{% for m in mentors %}
|
||||||
<div class="instructor">
|
<div class="instructor">
|
||||||
<div class="instructor-title">{{m.full_name}}</div>
|
<div class="instructor-title">{{m.full_name}}</div>
|
||||||
<div class="instructor-subtitle">Mentored {{m.batch_count}} batches</div>
|
<div class="instructor-subtitle">Mentored {{m.get_batch_count()}} batches</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if not is_mentor %}
|
{% if not is_mentor %}
|
||||||
<div class="notice">
|
<div id="mentor-request" class="notice">
|
||||||
Interested to become a mentor?
|
Interested to become a mentor?
|
||||||
|
|
||||||
<div><a href="#">Apply Now!</a></div>
|
<div><a id="apply-now" data-course="{{course_name | urlencode}}" href="">Apply Now!</a></div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
<div id="already-applied" class="notice hide">
|
||||||
|
You've applied to become a mentor for this course. Your request is currently under review.
|
||||||
|
|
||||||
|
If you are not any more interested to mentor this course, you can <a id="cancel-request" data-course="{{course_name | urlencode}}" href="">cancel your application</a>.
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{% macro BatchHearder(course_name, member_count) %}
|
{% macro BatchHearder(course_name, member_count) %}
|
||||||
<div class="border p-3">
|
<div class="border p-3">
|
||||||
<h3>{{course_name}}</h3>
|
<h3>{{course_name}}</h3>
|
||||||
<div class="text-muted">{{member_count}} members</div>
|
<div class="text-muted">{{member_count}} members</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -1,66 +1,128 @@
|
|||||||
|
|
||||||
{% macro LiveCodeEditorLarge(name, code) %}
|
{% macro LiveCodeEditorLarge(name, code) %}
|
||||||
<div class="livecode-editor livecode-editor-large row no-gutters" id="editor-{{name}}">
|
<div class="livecode-editor livecode-editor-large" id="editor-{{name}}">
|
||||||
<div class="col-sm">
|
<div class="row">
|
||||||
<div class="heading">
|
<div class="col-lg-8 col-md-6">
|
||||||
<button class="run">Run</button>
|
<div class="controls">
|
||||||
<h2>Editor</h2>
|
<button class="run">Run</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<textarea class="code">{{code}}</textarea>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm">
|
<div class="code-editor">
|
||||||
<div class="heading">
|
<div class="row">
|
||||||
<h2>Output</h2>
|
<div class="col-lg-8 col-md-6">
|
||||||
</div>
|
<div class="code-wrapper">
|
||||||
<div class="canvas-wrapper">
|
<textarea class="code">{{code}}</textarea>
|
||||||
<canvas class="canvas" width="300" height="300"></canvas>
|
</div>
|
||||||
<pre class="output"></pre>
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-6 canvas-wrapper">
|
||||||
|
<canvas width="300" height="300"></canvas>
|
||||||
|
<pre class="output"></pre>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro LiveCodeEditor(name, code) %}
|
{% macro LiveCodeEditor(name, code, reset_code, is_exercise=False, last_submitted=None) %}
|
||||||
<div class="livecode-editor canvas-editor" id="editor-{{name}}"
|
<div class="livecode-editor livecode-editor-inline" id="editor-{{name}}">
|
||||||
data-section="{{name}}">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-9">
|
<div class="col-lg-8 col-md-6">
|
||||||
<div>
|
<div class="controls">
|
||||||
<textarea class="code">{{code}}</textarea>
|
<button class="run">Run</button>
|
||||||
<div class="livecode-controls">
|
<button class="reset">Reset</button>
|
||||||
<button type="button" class="run">Run</button>
|
{% if is_exercise %}
|
||||||
<a href="javascript:;" class="reset">Reset</a>
|
<button class="submit pull-right btn-primary">Submit</button>
|
||||||
<a href="javascript:;" class="clear">Clear</a>
|
{% if last_submitted %}
|
||||||
|
<span class="pull-right" style="padding-right: 10px;"><span class="human-time" data-timestamp="{{last_submitted}}"></span></span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div style="display: none">
|
||||||
|
<pre class="reset-code">{{reset_code}}</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="code-editor">
|
||||||
<div class="canvas-wrapper">
|
<div class="row">
|
||||||
<canvas class="canvas" width="150" height="150"></canvas>
|
<div class="col-lg-8 col-md-6">
|
||||||
<pre class="output"></pre>
|
<div class="code-wrapper">
|
||||||
|
<textarea class="code">{{code}}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-6 canvas-wrapper">
|
||||||
|
<canvas width="300" height="300"></canvas>
|
||||||
|
<pre class="output"></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% macro LiveCodeEditorJS(name, code) %}
|
{% macro LiveCodeEditorJS(name, code) %}
|
||||||
|
|
||||||
|
<script type="text/javascript" src="/assets/frappe/node_modules/moment/min/moment-with-locales.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/assets/frappe/node_modules/moment-timezone/builds/moment-timezone-with-data.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/assets/frappe/js/frappe/utils/datetime.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
// comment_when is failing because of this
|
||||||
|
if (!frappe.sys_defaults) {
|
||||||
|
frappe.sys_defaults = {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" src="{{ livecode_url }}/static/livecode.js"></script>
|
<script type="text/javascript" src="{{ livecode_url }}/static/livecode.js"></script>
|
||||||
|
<script type="text/javascript" src="/assets/community/js/livecode-canvas.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var livecodeEditors = [];
|
var livecodeEditors = [];
|
||||||
|
var livecodeEditorsMap = {};
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$(".livecode-editor").each((i, e) => {
|
$(".livecode-editor").each((i, e) => {
|
||||||
|
var name = e.id.replace("editor-", "");
|
||||||
var editor = new LiveCodeEditor(e, {
|
var editor = new LiveCodeEditor(e, {
|
||||||
runtime: "python-canvas",
|
|
||||||
base_url: "{{ livecode_url }}",
|
base_url: "{{ livecode_url }}",
|
||||||
codemirror: true
|
...getLiveCodeOptions()
|
||||||
})
|
})
|
||||||
livecodeEditors.push(editor);
|
livecodeEditors.push(editor);
|
||||||
})
|
livecodeEditorsMap[e.id] = editor;
|
||||||
})
|
|
||||||
|
$(e).find(".reset").on('click', function() {
|
||||||
|
let code = $(e).find(".reset-code").html();
|
||||||
|
editor.codemirror.doc.setValue(code);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(e).find(".submit").on('click', function() {
|
||||||
|
let code = editor.codemirror.doc.getValue();
|
||||||
|
console.log("submit", name, code);
|
||||||
|
frappe.call("community.lms.api.submit_solution", {
|
||||||
|
"exercise": name,
|
||||||
|
"code": code
|
||||||
|
}).then(r => {
|
||||||
|
if (r.message.name) {
|
||||||
|
frappe.msgprint("Submitted successfully!");
|
||||||
|
|
||||||
|
let d = r.message.creation;
|
||||||
|
$(e).find(".human-time").html(__("Submitted {0}", [comment_when(d)]));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateSubmitTimes() {
|
||||||
|
$(".human-time").each(function(i, e) {
|
||||||
|
var d = $(e).data().timestamp;
|
||||||
|
$(e).html(__("Submitted {0}", [comment_when(d)]));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSubmitTimes();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{% macro Sidebar(course, batch_code) %}
|
{% macro Sidebar(course, batch_code) %}
|
||||||
<div class="sidebar-batch">
|
<div class="sidebar-batch">
|
||||||
<a href=""><i class="fas fa-bars fa-lg"></i></a>
|
<a href=""><i class="fa fa-bars fa-lg"></i></a>
|
||||||
<br>
|
<br>
|
||||||
<a href="/courses/{{course}}/{{batch_code}}/learn"><i class="fas fa-book fa-lg"></i></a>
|
<a href="/courses/{{course}}/{{batch_code}}/learn"><i class="fa fa-book fa-lg"></i></a>
|
||||||
<a href="/courses/{{course}}/{{batch_code}}/schedule"><i class="fas fa-calendar-alt fa-lg"></i></a>
|
<a href="/courses/{{course}}/{{batch_code}}/schedule"><i class="fa fa-calendar fa-lg"></i></a>
|
||||||
<a href="/courses/{{course}}/{{batch_code}}/members"><i class="fas fa-users fa-lg"></i></a>
|
<a href="/courses/{{course}}/{{batch_code}}/members"><i class="fa fa-users fa-lg"></i></a>
|
||||||
<a href="/courses/{{course}}/{{batch_code}}/discuss"><i class="fas fa-comments fa-lg"></i></a>
|
<a href="/courses/{{course}}/{{batch_code}}/discuss"><i class="fa fa-comments fa-lg"></i></a>
|
||||||
<a href="/courses/{{course}}/{{batch_code}}/about"><i class="fas fa-info-circle fa-lg"></i></a>
|
<a href="/courses/{{course}}/{{batch_code}}/about"><i class="fa fa-info-circle fa-lg"></i></a>
|
||||||
<!-- <a href="#contact"><i class="fas fa-home fa-lg"></i></a> -->
|
<!-- <a href="#contact"><i class="fas fa-home fa-lg"></i></a> -->
|
||||||
</div>
|
</div>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|||||||
70
community/www/new-sign-up.html
Normal file
70
community/www/new-sign-up.html
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
{% extends "templates/web.html" %}
|
||||||
|
|
||||||
|
{% block title %} {{_("New Sign Up")}} {% endblock %}
|
||||||
|
|
||||||
|
{% block page_content %}
|
||||||
|
|
||||||
|
<form id="new-sign-up">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="full_name">Full Name:</label>
|
||||||
|
<input id="full_name" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="signup_email">Email:</label>
|
||||||
|
<input id="signup_email" type="email" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="username">Username:</label>
|
||||||
|
<input id="username" type="text" class="form-control" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="password">Password:</label>
|
||||||
|
<input id="password" type="password" class="form-control" required>
|
||||||
|
<span class="password-strength-indicator indicator"></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class='password-strength-message text-muted small hidden'></p>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="invite_code">Invite Code:</label>
|
||||||
|
<input id="invite_code" type="text" class="form-control" readonly required
|
||||||
|
value="{{ frappe.form_dict['invite_code'] }}">
|
||||||
|
</div>
|
||||||
|
<button type="submit" id="submit" class="btn btn-primary">{{_("Submit")}}</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
frappe.ready(() => {
|
||||||
|
$("#submit").click(function () {
|
||||||
|
var data = {
|
||||||
|
full_name: $("#full_name").val(),
|
||||||
|
signup_email: $("#signup_email").val(),
|
||||||
|
username: $("#username").val(),
|
||||||
|
password: $("#password").val(),
|
||||||
|
invite_code: $("#invite_code").val(),
|
||||||
|
};
|
||||||
|
|
||||||
|
frappe.call({
|
||||||
|
type: "POST",
|
||||||
|
method: "community.lms.doctype.invite_request.invite_request.update_invite",
|
||||||
|
args: {
|
||||||
|
"data": data
|
||||||
|
},
|
||||||
|
callback: (data) => {
|
||||||
|
$("input").val("");
|
||||||
|
if (data.message == "OK") {
|
||||||
|
frappe.msgprint({
|
||||||
|
message: __("Your Account has been successfully created!"),
|
||||||
|
clear: true
|
||||||
|
});
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location.href = "/login";
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -55,7 +55,6 @@
|
|||||||
|
|
||||||
.dashboard__details {
|
.dashboard__details {
|
||||||
padding-top: 2rem;
|
padding-top: 2rem;
|
||||||
width: 80%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dashboard__course {
|
.dashboard__course {
|
||||||
@@ -83,12 +82,18 @@
|
|||||||
.dashboard__description {
|
.dashboard__description {
|
||||||
height: 100px;
|
height: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.dashboard__parent {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block page_content %}
|
{% block page_content %}
|
||||||
<section>
|
|
||||||
<div class="dashboard__parent">
|
<div class="dashboard__parent">
|
||||||
<div>
|
<div class="dashboard__photo">
|
||||||
{{ Profile(member.photo, member.full_name, member.abbr, "large")}}
|
{{ Profile(member.photo, member.full_name, member.abbr, "large")}}
|
||||||
</div>
|
</div>
|
||||||
<div class="dashboard__details">
|
<div class="dashboard__details">
|
||||||
@@ -106,40 +111,23 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane fade py-4 show active" role="tabpanel" id="home">
|
<div class="tab-pane fade py-4 show active" role="tabpanel" id="home">
|
||||||
<div class='container'>
|
<div class="row">
|
||||||
<div class="row row-cols-1 row-cols-xl-5 row-cols-lg-4 row-cols-md-3 row-cols-sm-2">
|
{% if sketches %}
|
||||||
{% if sketches %}
|
{% for sketch in sketches %}
|
||||||
{% for sketch in sketches %}
|
<div class="col-md-4 col-sm-6">
|
||||||
<div class="col m-4">
|
{{ widgets.SketchTeaser(sketch=sketch) }}
|
||||||
<div class="card sketch-card" style="width: 200px;">
|
|
||||||
<div class="card-img-top">
|
|
||||||
<a href="/sketches/{{sketch.sketch_id}}">
|
|
||||||
{{ sketch.to_svg() }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<div class="sketch-title">
|
|
||||||
<a href="sketches/{{sketch.sketch_id}}">{{sketch.title}}</a>
|
|
||||||
</div>
|
|
||||||
<div class="sketch-author">
|
|
||||||
by {{sketch.get_owner_name()}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
{% if not sketches %}
|
{% endfor %}
|
||||||
<p class="text-center">{{member.full_name}} has not created any skecth yet.</p>
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
{% if not sketches %}
|
||||||
|
<p class="text-center">{{member.full_name}} has not created any skecth yet.</p>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
<!-- this is a sample default web page template -->
|
<!-- this is a sample default web page template -->
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from ...lms.doctype.lms_sketch.lms_sketch import get_recent_sketches
|
from community.lms.models import Sketch
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
context.no_cache = 1
|
context.no_cache = 1
|
||||||
@@ -8,7 +8,7 @@ def get_context(context):
|
|||||||
if not context.member:
|
if not context.member:
|
||||||
context.template = "www/404.html"
|
context.template = "www/404.html"
|
||||||
else:
|
else:
|
||||||
context.sketches = list(filter(lambda x: x.owner == context.member.email, get_recent_sketches()))
|
context.sketches = Sketch.get_recent_sketches(owner=context.member.email)
|
||||||
|
|
||||||
def get_member(username):
|
def get_member(username):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
<div class='container pb-5'>
|
<div class='container pb-5'>
|
||||||
<h1>Recent Sketches</h1>
|
<h1>Recent Sketches</h1>
|
||||||
|
|
||||||
<a href="/sketches/new">Create a New Sketch</a>
|
<a href="/sketches/new" class="btn btn-primary">Create a New Sketch</a>
|
||||||
</div>
|
</div>
|
||||||
<div class='container'>
|
<div class='container'>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -30,14 +30,18 @@
|
|||||||
|
|
||||||
<div class="sketch-header">
|
<div class="sketch-header">
|
||||||
{% if editable %}
|
{% if editable %}
|
||||||
<input type="button" class="pull-right" id="sketch-save" value="Save"/>
|
<div class="form-row">
|
||||||
<h1 class="sketch-title">
|
<div class="col-lg-8 col-md-6">
|
||||||
<input type="text" name="title" id="sketch-title" value="{{ sketch.title }}" />
|
<input type="text" id="sketch-title" name="title" class="form-control" value="{{ sketch.title }}">
|
||||||
</h1>
|
</div>
|
||||||
|
<div class="col-lg-4 col-md-6">
|
||||||
|
<button type="submit" id="sketch-save" class="btn-save btn btn-primary">Save</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1 class="sketch-title">{{sketch.title}}</h1>
|
<h1 class="sketch-title">{{sketch.title}}</h1>
|
||||||
|
<div class="sketch-owner-wrapper">By <span class="sketch-owner">{{sketch.get_owner_name()}}</span></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="sketch-owner-wrapper">By <span class="sketch-owner">{{sketch.get_owner_name()}}</span></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if sketch.is_new() and not editable %}
|
{% if sketch.is_new() and not editable %}
|
||||||
@@ -49,7 +53,6 @@
|
|||||||
<div class="sketch-editor">
|
<div class="sketch-editor">
|
||||||
{{LiveCodeEditorLarge(sketch.name, sketch.code) }}
|
{{LiveCodeEditorLarge(sketch.name, sketch.code) }}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{%- block script %}
|
{%- block script %}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
License: MIT
|
License: AGPL
|
||||||
|
|||||||
Reference in New Issue
Block a user