Skip to content

Commit

Permalink
Merge pull request #1 from 28left/problemUX
Browse files Browse the repository at this point in the history
fixed problem display issues; qti convert feedback
  • Loading branch information
28left committed Jan 23, 2024
2 parents a28b16e + 3e65dc0 commit 915c70f
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 26 deletions.
Binary file added dist/cyllene-0.6.3-py3-none-any.whl
Binary file not shown.
Binary file added dist/cyllene-0.6.3.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions pyproject.toml
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "cyllene"
version = "0.6.2"
version = "0.6.3"
description = "IPython package for math problem authoring"
readme = "README.md"
authors = [{ name = "Jan Reimann", email = "jan.reimann@psu.edu" }]
Expand All @@ -15,7 +15,7 @@ classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
"text2qti >= 0.5.0",
"text2qti <= 0.6.0",
"ipython >= 8.4.0",
"ipywidgets >= 8.0.1",
"sympy >= 1.10.1",
Expand Down
4 changes: 2 additions & 2 deletions src/cyllene.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: cyllene
Version: 0.6.2
Version: 0.6.3
Summary: IPython package for math problem authoring
Author-email: Jan Reimann <jan.reimann@psu.edu>
License: MIT License
Expand Down Expand Up @@ -31,7 +31,7 @@ Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: text2qti>=0.5.0
Requires-Dist: text2qti<=0.6.0
Requires-Dist: ipython>=8.4.0
Requires-Dist: ipywidgets>=8.0.1
Requires-Dist: sympy>=1.10.1
Expand Down
2 changes: 1 addition & 1 deletion src/cyllene.egg-info/requires.txt
@@ -1,4 +1,4 @@
text2qti>=0.5.0
text2qti<=0.6.0
ipython>=8.4.0
ipywidgets>=8.0.1
sympy>=1.10.1
Expand Down
3 changes: 3 additions & 0 deletions src/cyllene/magics/problem_magics.py
Expand Up @@ -47,6 +47,9 @@ def makeqti(line):

ProbStack.update_user_funcs()
p = ProbStack.get(pname)
if p == None:
print("ERROR: No problem with name " + pname + "found")
return

make_qti(p, pnum, solution=with_solution, externals=ProbStack.user_funcs)

Expand Down
14 changes: 9 additions & 5 deletions src/cyllene/user/problem_cmds.py
Expand Up @@ -25,10 +25,10 @@ def make_problem(prob_string, externals=None, webassign=False):
init_dict = parse_webassign(prob_string)
else:
init_dict = parse(prob_string)

if 'parameters' in init_dict:
return MultipleChoiceParameterProblem(init_dict, externals)
else:
else:
return MultipleChoice(init_dict)


Expand Down Expand Up @@ -58,8 +58,12 @@ def make_qti(problem, num_questions: int, solution=False, externals=None):
qti_problem.make_text_quiz(
title=title_string, shuffle_answers=True)

# print all questions as txt (for debugging)
print(qti_problem.txt_quiz)
print("Generating " + str(num_questions) + "problems and saving as QTI")
if not solution:
print("(without solutions)")

# print all questions as txt (uncomment for debugging)
# print(qti_problem.txt_quiz)

# load text2qti config
config = t2q.Config()
Expand All @@ -76,7 +80,7 @@ def make_qti(problem, num_questions: int, solution=False, externals=None):
file_name = problem.problem_id+"_nosol.zip"

qti.save(file_name)
print("QTI file save as "+file_name)
print("QTI file saved as "+file_name)


def show_problem(problem):
Expand Down
6 changes: 4 additions & 2 deletions src/cyllene/widgets/widgets_aux.py
@@ -1,4 +1,4 @@
from IPython.display import display, clear_output
from IPython.display import display, clear_output, Markdown
import ipywidgets as widgets
import markdown
import random
Expand All @@ -8,7 +8,9 @@ def update_output_widget(widget: widgets.Output, content: str):

with widget:
clear_output()
display(widgets.HTMLMath(markdown.markdown(content)))
# display(widgets.HTMLMath(markdown.markdown(content)))
display(Markdown(content))
# display(widgets.HTMLMath(content))


def shuffle_answers(num_choices):
Expand Down
21 changes: 10 additions & 11 deletions src/cyllene/widgets/widgets_problem_basic.py
Expand Up @@ -26,15 +26,15 @@ def __init__(self, problem: Problem):
self.statement = widgets.Output()

self.has_solution = self.problem.has_solution

self.solution_text = widgets.Output()
with self.solution_text:
display(widgets.HTMLMath(markdown.markdown(self.problem.solution)))

self.solution_title = 'Show Solution'
if self.problem.solution_title != '':
self.solution_title = self.problem.solution_title

self.solution = widgets.Accordion(
children=[self.solution_text])
self.solution.selected_index = None
Expand Down Expand Up @@ -94,9 +94,9 @@ def show(self):
with self.choices:
clear_output()
for i in range(self.problem.num_choices):
display(widgets.HTMLMath('<b>( ' + str(i+1)
+ ' )</b> &nbsp;&nbsp; '
+ self.problem.choices[self.indices[i]]))
display(widgets.HTMLMath('<b>( ' + str(i+1)
+ ' )</b> &nbsp;&nbsp; '
+ self.problem.choices[self.indices[i]]))

display(widgets.VBox([self.choices, widgets.HBox(
self.choice_buttons), self.feedback]))
Expand All @@ -107,7 +107,7 @@ def show(self):

if self.has_solution:
display(self.solution)

def update_choices(self, choices: list):
"""
Update the choices widget
Expand All @@ -119,13 +119,12 @@ def update_choices(self, choices: list):
clear_output()
for i in range(self.problem.num_choices):
display(widgets.HTMLMath(markdown.markdown(
'**( ' + str(i+1) + ' )** &nbsp;&nbsp; '
'**( ' + str(i+1) + ' )** &nbsp;&nbsp; '
+ choices[self.indices[i]]))
)

)

def on_button_clicked(self, bt):

self.check_answer(bt.description[2:-2])

def check_answer(self, answer):
Expand Down
9 changes: 6 additions & 3 deletions src/cyllene/widgets/widgets_problem_param.py
Expand Up @@ -68,11 +68,14 @@ def update_problem_area(self):

with self.problem_area:
clear_output()
display(widgets.HTMLMath(markdown.markdown(self.problem.statement)))
# display(widgets.HTMLMath(markdown.markdown(self.problem.statement)))
display(Markdown(self.problem.statement))

for i in range(self.problem.num_choices):
display(widgets.HTMLMath(
value='<b>( ' + str(i+1) + ' )</b> &nbsp;&nbsp; ' + self.problem.choices[self.indices[i]] + "&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"))
# display(widgets.HTMLMath(
# value='<b>( ' + str(i+1) + ' )</b> &nbsp;&nbsp; ' + self.problem.choices[self.indices[i]] + "&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"))
display(Markdown(
'**( ' + str(i+1) + ' )** &nbsp;&nbsp; ' + self.problem.choices[self.indices[i]] + "&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;"))

def new_button_clicked(self, bt):

Expand Down

0 comments on commit 915c70f

Please sign in to comment.