Added LMS Settings.

The `livecode_url` is now part of LMS settings and not hardcoded in the code.
This commit is contained in:
Anand Chitipothu
2021-03-09 09:04:39 +00:00
parent fc6f60c4d7
commit 862878462b
7 changed files with 76 additions and 2 deletions

View File

@@ -0,0 +1,8 @@
// Copyright (c) 2021, FOSS United and contributors
// For license information, please see license.txt
frappe.ui.form.on('LMS Settings', {
// refresh: function(frm) {
// }
});

View File

@@ -0,0 +1,41 @@
{
"actions": [],
"creation": "2021-03-09 14:30:15.807410",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"livecode_url"
],
"fields": [
{
"default": "https://livecode.dev.fossunited.org",
"fieldname": "livecode_url",
"fieldtype": "Data",
"label": "LiveCode URL"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2021-03-09 14:30:15.807410",
"modified_by": "Administrator",
"module": "LMS",
"name": "LMS Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}

View File

@@ -0,0 +1,10 @@
# -*- 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 LMSSettings(Document):
pass

View 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 TestLMSSettings(unittest.TestCase):
pass

View File

@@ -67,13 +67,13 @@
{%- block script %}
{{ super() }}
<script type="text/javascript" src="http://livecode.dev.fossunited.org/static/livecode.js"></script>
<script type="text/javascript" src="{{ livecode_url }}/static/livecode.js"></script>
<script type="text/javascript">
$(function() {
$(".canvas-editor").each((i, e) => {
var editor = new LiveCodeEditor(e, {
runtime: "python-canvas",
base_url: "http://livecode.dev.fossunited.org"
base_url: "{{ livecode_url }}"
})
})
})

View File

@@ -7,6 +7,11 @@ def get_context(context):
topic_name = get_queryparam("topic", '/courses?course=' + course_name)
context.topic = get_topic(course_name, topic_name)
context.livecode_url = get_livecode_url()
def get_livecode_url():
doc = frappe.get_doc("LMS Settings")
return doc.livecode_url
def get_queryparam(name, redirect_when_not_found):
try: