Skip to content
Snippets Groups Projects
Commit 28e8774d authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

Minor changes and typos. Can now upload multiple scripts at once

parent f95cf215
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ replace requests with the native urllib3 - you are welcome to help.
### TODO
* Add a more description / documentation.
* Add more functionality (numeric gap, multiple answers per gap, alignment)
* Add more functionality (multiple answers per gap, alignment)
* Make parsers more robust.
* Create whole test object with questions for direct import. Create two
versions (one for internal use and one for the test.)
......
......@@ -2,6 +2,7 @@ import xml.etree.ElementTree as et
from . import multi, single, gap
def create_xml_tree(item_list):
root = et.Element('questestinterop')
tree = et.ElementTree(root)
......
......@@ -8,12 +8,13 @@ import xml.etree.ElementTree as et
#
##########################################################################
##########################################################################
def xml_print(element, **kwargs):
import xml.dom.minidom
xml = xml.dom.minidom.parseString(et.tostring(element, encoding='utf8', method='xml')) # or xml.dom.minidom.parseString(xml_string)
# or xml.dom.minidom.parseString(xml_string)
xml = xml.dom.minidom.parseString(
et.tostring(element, encoding='utf8', method='xml'))
print(xml.toprettyxml(), **kwargs)
......@@ -47,8 +48,6 @@ def response_label(content, count):
response_label.append(material(content))
return response_label
def displayfeedback(gap=False):
pass
def respcondition(points, respident, count, correct=True):
root = et.Element('respcondition', attrib={'continue': 'Yes'})
......@@ -83,6 +82,7 @@ def respcondition(points, respident, count, correct=True):
root.append(displayfeedback)
return root
def itemfeedback(ident, content='NONE'):
root = et.Element(
'itemfeedback',
......@@ -94,6 +94,8 @@ def itemfeedback(ident, content='NONE'):
return root
### gap specific #########################################################
def respcondition_gap(points, resp_count, answer, count=0):
root = et.Element('respcondition', attrib={'continue': 'Yes'})
conditionvar = et.Element('conditionvar')
......@@ -129,12 +131,15 @@ def material_raw(content):
))
return material
def response_str(ident, columns):
response_str = et.Element('response_str', attrib={'ident': ident, 'rcardinality': 'Single'})
render_fib = et.Element('render_fib', attrib={'columns': str(columns), 'fibtype': "String", 'prompt': "Box"})
response_str = et.Element(
'response_str', attrib={'ident': ident, 'rcardinality': 'Single'})
render_fib = et.Element('render_fib', attrib={'columns': str(columns), 'fibtype': "String", 'prompt': "Box"})
response_str.append(render_fib)
return response_str
def response_choice(ident, answers):
response_str = et.Element('response_str', attrib={'ident': str(ident), 'rcardinality': 'Single'})
render_choice = et.Element('render_choice', attrib={'shuffle': 'Yes'})
......@@ -145,6 +150,7 @@ def response_choice(ident, answers):
render_choice.append(response_label)
return response_str
def response_num(ident, columns, _min, _max, numtype='Decimal'):
response_num = et.Element('response_num', attrib={'ident': ident, 'numtype': numtype, 'rcardinality': 'Single'})
render_fib = et.Element('render_fib', attrib={'columns': str(columns), 'fibtype': numtype, 'maxnumber': _max, 'minnumber': _min, 'prompt': "Box"})
......
......@@ -20,7 +20,6 @@
import importlib.util
import argparse
import os
import sys
import configparser
# local import
......@@ -140,8 +139,9 @@ def parseme():
parser_gen = subparsers.add_parser(
"upload", help="Subcommand to upload created xml instances.")
parser_gen.add_argument(
'script',
help='The script that should be uploaded',
'script_list',
help='The scripts that should be uploaded',
nargs='+',
type=file_exists,
metavar='FILE')
......@@ -151,7 +151,7 @@ def parseme():
look_for_output()
delegator(args.out, args.input, args.instances)
if args.command == 'upload':
handle_upload(args.script, config)
handle_upload(args.script_list, config)
if args.command == 'new':
handle_new_script(args.name, args.type, args.author, args.points)
if args.command == None:
......@@ -277,7 +277,7 @@ def handle_new_script(name, qtype, author, points):
info('Generated new script "{}."'.format(new_script.name))
def handle_upload(script_path, config):
def handle_upload(script_list, config):
""" Passes data to the upload script.
The status code should be 500, since ILIAS always replies with that error
......@@ -288,12 +288,13 @@ def handle_upload(script_path, config):
script_path {str} -- path to the file that should be uploaded
config {config object} -- the loaded configuration
"""
r = send_script(
script_path,
config['UPLAODER']['host'],
config['UPLAODER']['user'],
config['UPLAODER']['pass'],
config['UPLAODER']['rtoken'],
)
info("Uploaded %s. Status code looks %s." %
(script_path, "good" if r else "bad"))
for script in script_list:
r = send_script(
script,
config['UPLAODER']['host'],
config['UPLAODER']['user'],
config['UPLAODER']['pass'],
config['UPLAODER']['rtoken'],
)
info("Uploaded %s. Status code looks %s." %
(script, "good" if r else "bad"))
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from setuptools import setup
with open('README.md') as f:
readme = f.read()
with open('LICENSE') as f:
license = f.read()
setup(
name='hallgrim',
version='0.1',
......@@ -17,7 +13,7 @@ setup(
author='Jan Maximilian Michal',
author_email='mail-github@jmx.io',
url='https://gitlab.gwdg.de/j.michal/ilias-generator',
license=license,
license='MIT',
scripts=['hallgrim/bin/hallgrim'],
install_requires=['mistune', 'pygments', 'requests', 'requests_toolbelt'],
packages=['hallgrim']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment