Skip to content

Commit

Permalink
Modularized file viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
nicole-brewer committed Apr 1, 2024
1 parent ac69d42 commit 669e611
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 26 deletions.
24 changes: 23 additions & 1 deletion jupyter_mentor/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,26 @@
'doc_host': 'https://Jupyter4Science.github.io',
'git_url': 'https://github.com/Jupyter4Science/jupyter-mentor',
'lib_path': 'jupyter_mentor'},
'syms': {'jupyter_mentor.core': {'jupyter_mentor.core.foo': ('core.html#foo', 'jupyter_mentor/core.py')}}}
'syms': { 'jupyter_mentor.chatbot': { 'jupyter_mentor.chatbot.ChatBot': ('chatbot.html#chatbot', 'jupyter_mentor/chatbot.py'),
'jupyter_mentor.chatbot.ChatBot.__init__': ( 'chatbot.html#chatbot.__init__',
'jupyter_mentor/chatbot.py')},
'jupyter_mentor.educator_course_overview': { 'jupyter_mentor.educator_course_overview.EducatorCourseOverview': ( 'educator_course_overview.html#educatorcourseoverview',
'jupyter_mentor/educator_course_overview.py'),
'jupyter_mentor.educator_course_overview.EducatorCourseOverview.__init__': ( 'educator_course_overview.html#educatorcourseoverview.__init__',
'jupyter_mentor/educator_course_overview.py')},
'jupyter_mentor.educator_model': { 'jupyter_mentor.educator_model.EducatorModel': ( 'educator_model.html#educatormodel',
'jupyter_mentor/educator_model.py'),
'jupyter_mentor.educator_model.EducatorModel.__init__': ( 'educator_model.html#educatormodel.__init__',
'jupyter_mentor/educator_model.py'),
'jupyter_mentor.educator_model.EducatorModel.invoke': ( 'educator_model.html#educatormodel.invoke',
'jupyter_mentor/educator_model.py')},
'jupyter_mentor.educator_profile': { 'jupyter_mentor.educator_profile.EducatorProfile': ( 'educator_profile.html#educatorprofile',
'jupyter_mentor/educator_profile.py'),
'jupyter_mentor.educator_profile.EducatorProfile.__init__': ( 'educator_profile.html#educatorprofile.__init__',
'jupyter_mentor/educator_profile.py')},
'jupyter_mentor.file_viewer': { 'jupyter_mentor.file_viewer.FileViewer': ( 'file_viewer.html#fileviewer',
'jupyter_mentor/file_viewer.py'),
'jupyter_mentor.file_viewer.FileViewer.__init__': ( 'file_viewer.html#fileviewer.__init__',
'jupyter_mentor/file_viewer.py')},
'jupyter_mentor.login': { 'jupyter_mentor.login.Login': ('login.html#login', 'jupyter_mentor/login.py'),
'jupyter_mentor.login.Login.__init__': ('login.html#login.__init__', 'jupyter_mentor/login.py')}}}
14 changes: 6 additions & 8 deletions jupyter_mentor/educator_course_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__all__ = ['EducatorCourseOverview']

# %% ../nbs/04_educator_course_overview.ipynb 1
from .file_viewer import FileViewer
import ipywidgets as widgets
from ipywidgets import VBox, HBox, HTML, Button, Label, Text, Checkbox, Accordion, FileUpload
from IPython.display import display, clear_output
Expand All @@ -13,17 +14,15 @@
# %% ../nbs/04_educator_course_overview.ipynb 2
class EducatorCourseOverview(VBox):

def __init__(self):
def __init__(self, file_viewer):
super().__init__()

# File Upload button
self.file_upload = FileUpload(accept='', multiple=False)
self.file_upload_button = Button(description='Upload')


# File viewer (hidden in accordion)
self.file_viewer_accordion = Accordion(children=[HTML('File viewer content')])
self.file_viewer_accordion.selected_index = None # Hide the accordion content initially
# global file viewer (that has model)
self.file_viewer = file_viewer

# Course overview text
self.course_overview_label = Label('Course Overview:')
Expand Down Expand Up @@ -51,12 +50,11 @@ def __init__(self):
self.children = [
HTML('<h2>Course Overview</h2>'), # Heading
HBox([self.file_upload, self.file_upload_button]), # File upload button
self.file_viewer_accordion, # File viewer (hidden initially)
self.file_viewer,
self.course_overview_label, self.course_overview_text, # Course overview
self.ai_guidelines_label, # AI Guidelines
VBox([self.step_by_step_checkbox, self.metaphor_checkbox,
self.hints_checkbox, self.ai_guided_questions_checkbox]), # Binary features checkboxes
self.open_ended_label, self.open_ended_text, # Open-ended response
HBox([self.next_button], layout={'justify_content': 'flex-end'}),
]

26 changes: 26 additions & 0 deletions jupyter_mentor/file_viewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/03_file_viewer.ipynb.

# %% auto 0
__all__ = ['FileViewer']

# %% ../nbs/03_file_viewer.ipynb 1
import ipywidgets as widgets
from ipywidgets import VBox, HBox, HTML, Button, Label, Text, Checkbox, Accordion, FileUpload
from IPython.display import display, clear_output
import ipyvuetify as v
from traitlets import observe

# %% ../nbs/03_file_viewer.ipynb 2
class FileViewer(VBox):

def __init__(self):
super().__init__()

# File viewer (hidden in accordion)
self.file_viewer_accordion = Accordion(children=[HTML('File viewer content')])
self.file_viewer_accordion.selected_index = None # Hide the accordion content initially

# Arrange widgets vertically
self.children = [
self.file_viewer_accordion, # File viewer (hidden initially)
]
65 changes: 57 additions & 8 deletions nbs/00_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bdd83822-655e-4a13-a9e5-557609cd3f0d",
"id": "89293f18-ab92-426e-abf4-249f3e17727d",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -30,7 +30,8 @@
"from jupyter_mentor.login import Login\n",
"from jupyter_mentor.educator_profile import EducatorProfile\n",
"from jupyter_mentor.educator_course_overview import EducatorCourseOverview\n",
"from jupyter_mentor.chatbot import ChatBot"
"from jupyter_mentor.chatbot import ChatBot\n",
"from jupyter_mentor.file_viewer import FileViewer"
]
},
{
Expand All @@ -41,7 +42,7 @@
"outputs": [],
"source": [
"#| export\n",
"class Main(widgets.Tab):\n",
"class EducatorMain(widgets.Tab):\n",
" \n",
" def __init__(self):\n",
" super().__init__()\n",
Expand All @@ -52,10 +53,9 @@
" # initialize views\n",
" self.first = Login()\n",
" self.second = EducatorProfile()\n",
" self.third = EducatorCourseOverview()\n",
" self.file_viewer = FileViewer()\n",
" self.third = EducatorCourseOverview(self.file_viewer)\n",
" self.fourth = ChatBot()\n",
"\n",
"\n",
" \n",
" # Add tabs to the Tab widget\n",
" self.children = (self.first, self.second, self.third, self.fourth)\n",
Expand Down Expand Up @@ -89,8 +89,57 @@
"metadata": {},
"outputs": [],
"source": [
"main = Main()\n",
"main"
"educator_main = EducatorMain()\n",
"educator_main"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7548d87a-94e3-4cdc-bb20-fe46ec366425",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"class EducatorMain(widgets.Tab):\n",
" \n",
" def __init__(self):\n",
" super().__init__()\n",
" \n",
" # initialize models\n",
" # self.model = EducatorModel(FILENAME)\n",
" \n",
" # initialize views\n",
" self.first = Login()\n",
" self.second = EducatorProfile()\n",
" self.file_viewer = FileViewer()\n",
"\n",
" self.third = EducatorCourseOverview(self.file_viewer)\n",
" self.fourth = ChatBot()\n",
"\n",
" \n",
" # Add tabs to the Tab widget\n",
" self.children = (self.first, self.second, self.third, self.fourth)\n",
"\n",
" self.set_title(0, 'LogIn')\n",
" self.set_title(1, 'User Profile')\n",
" self.set_title(2, 'Course Overview')\n",
" self.set_title(3, 'Test/Assn Generator')\n",
"\n",
"\n",
" # Add event handlers to \"Next\" buttons in each tab\n",
" self.first.login_button.on_click(self.switch_to_second)\n",
" self.second.next_button.on_click(self.switch_to_third)\n",
" self.third.next_button.on_click(self.switch_to_fourth)\n",
" \n",
" def switch_to_second(self, button):\n",
" self.selected_index = 1\n",
" \n",
" def switch_to_third(self, button):\n",
" self.selected_index = 2\n",
" \n",
" def switch_to_fourth(self, button):\n",
" self.selected_index = 3"
]
},
{
Expand Down
92 changes: 92 additions & 0 deletions nbs/03_file_viewer.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "d09b853a-3124-4232-9618-3b6761678bc5",
"metadata": {},
"outputs": [],
"source": [
"#| default_exp file_viewer"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8e6a32e-e248-4ec4-9763-7a18c8cd0b9b",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"import ipywidgets as widgets\n",
"from ipywidgets import VBox, HBox, HTML, Button, Label, Text, Checkbox, Accordion, FileUpload\n",
"from IPython.display import display, clear_output\n",
"import ipyvuetify as v\n",
"from traitlets import observe"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "07c50690-0a66-4b72-b819-6fd06b1c9016",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"\n",
"class FileViewer(VBox):\n",
" \n",
" def __init__(self):\n",
" super().__init__()\n",
" \n",
" # File viewer (hidden in accordion)\n",
" self.file_viewer_accordion = Accordion(children=[HTML('File viewer content')])\n",
" self.file_viewer_accordion.selected_index = None # Hide the accordion content initially\n",
"\n",
" # Arrange widgets vertically\n",
" self.children = [\n",
" self.file_viewer_accordion, # File viewer (hidden initially)\n",
" ]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ae7ac138-aa5d-4c47-ae8d-18deb24b5627",
"metadata": {},
"outputs": [],
"source": [
"file_viewer = FileViewer()\n",
"file_viewer"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7cd9b87a-4ce9-42b7-857d-037a7a0b3d44",
"metadata": {},
"outputs": [],
"source": [
"#| hide\n",
"import nbdev; nbdev.nbdev_export()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5a75be53-5c9c-43d2-9aaa-b4c3c2ecab8d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
18 changes: 9 additions & 9 deletions nbs/04_educator_course_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"outputs": [],
"source": [
"#| export\n",
"from jupyter_mentor.file_viewer import FileViewer\n",
"import ipywidgets as widgets\n",
"from ipywidgets import VBox, HBox, HTML, Button, Label, Text, Checkbox, Accordion, FileUpload\n",
"from IPython.display import display, clear_output\n",
Expand All @@ -36,17 +37,15 @@
"\n",
"class EducatorCourseOverview(VBox):\n",
" \n",
" def __init__(self):\n",
" def __init__(self, file_viewer):\n",
" super().__init__()\n",
" \n",
"\n",
" # File Upload button\n",
" self.file_upload = FileUpload(accept='', multiple=False)\n",
" self.file_upload_button = Button(description='Upload')\n",
"\n",
" \n",
" # File viewer (hidden in accordion)\n",
" self.file_viewer_accordion = Accordion(children=[HTML('File viewer content')])\n",
" self.file_viewer_accordion.selected_index = None # Hide the accordion content initially\n",
" # global file viewer (that has model)\n",
" self.file_viewer = file_viewer\n",
" \n",
" # Course overview text\n",
" self.course_overview_label = Label('Course Overview:')\n",
Expand Down Expand Up @@ -74,14 +73,14 @@
" self.children = [\n",
" HTML('<h2>Course Overview</h2>'), # Heading\n",
" HBox([self.file_upload, self.file_upload_button]), # File upload button\n",
" self.file_viewer_accordion, # File viewer (hidden initially)\n",
" self.file_viewer,\n",
" self.course_overview_label, self.course_overview_text, # Course overview\n",
" self.ai_guidelines_label, # AI Guidelines\n",
" VBox([self.step_by_step_checkbox, self.metaphor_checkbox,\n",
" self.hints_checkbox, self.ai_guided_questions_checkbox]), # Binary features checkboxes\n",
" self.open_ended_label, self.open_ended_text, # Open-ended response\n",
" HBox([self.next_button], layout={'justify_content': 'flex-end'}), \n",
" ]\n"
" ]"
]
},
{
Expand All @@ -91,7 +90,8 @@
"metadata": {},
"outputs": [],
"source": [
"main = EducatorCourseOverview()\n",
"file_viewer = FileViewer()\n",
"main = EducatorCourseOverview(file_viewer)\n",
"main"
]
},
Expand Down

0 comments on commit 669e611

Please sign in to comment.