Skip to content

Commit

Permalink
feat: add basic lms chat
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 committed Jan 15, 2025
1 parent 00e9b31 commit faeedd0
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/ol_openedx_chat/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from xblock.fields import Boolean, Scope, String
from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW

from xmodule.video_block.transcripts_utils import get_transcript_from_contentstore


def get_resource_bytes(path):
"""
Expand Down Expand Up @@ -78,8 +80,16 @@ def student_view_aside(self, block, context=None):
if getattr(self.runtime, "is_author_mode", False):
return self.author_view_aside(block, context)

# if getattr(block, "category", None) == "video":
# content, filename, mimetype = get_transcript_from_contentstore(block, 'en', 'txt', block.get_transcripts_info())

print("\n\n\n IN ASIDE\n\n\n")
fragment = Fragment("")
fragment.add_content(render_template("static/html/student_view.html"))
fragment.add_content(render_template("static/html/student_view.html", {"block_key": self.scope_ids.usage_id.usage_key.block_id}))
fragment.add_css(get_resource_bytes("static/css/ai_chat.css"))
fragment.add_javascript(get_resource_bytes("static/js/ai_chat.js"))
fragment.add_javascript(get_resource_bytes("static/js/aiChat.umd.js"))
fragment.initialize_js("AiChatAsideView", json_args={"test_arg": "test_value"})
return fragment

@XBlockAside.aside_for(AUTHOR_VIEW)
Expand Down
14 changes: 14 additions & 0 deletions src/ol_openedx_chat/static/css/ai_chat.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, sans-serif;
}



#app-root {
width: 450px;
height: 600px;
}
2 changes: 1 addition & 1 deletion src/ol_openedx_chat/static/html/student_view.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div>
<button type="button" onclick="alert('Hello World!')">Hello World!</button>
<div id="app-root">Hello</div>
</div>
Loading

0 comments on commit faeedd0

Please sign in to comment.