From ca790e6da556783aa072a2b1d21eee01b100ec32 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 1 Apr 2019 21:07:31 +0000 Subject: webquiz (1apr19) git-svn-id: svn://tug.org/texlive/trunk@50694 c570f23f-e606-0410-a88d-b1316a301751 --- .../texk/texlive/linked_scripts/webquiz/webquiz.py | 177 ++++++++++++--------- Master/texmf-dist/doc/latex/webquiz/README.rst | 71 ++++----- .../doc/latex/webquiz/examples/README-examples | 4 +- .../doc/latex/webquiz/examples/answer-complex.png | Bin 99557 -> 99557 bytes .../doc/latex/webquiz/examples/answer-integer.png | Bin 62058 -> 62058 bytes .../latex/webquiz/examples/answer-lowercase.png | Bin 110351 -> 110351 bytes .../doc/latex/webquiz/examples/answer-number.png | Bin 95333 -> 95333 bytes .../doc/latex/webquiz/examples/answer-star.png | Bin 123364 -> 123364 bytes .../doc/latex/webquiz/examples/answer-string.png | Bin 68023 -> 68023 bytes .../doc/latex/webquiz/examples/breadcrumbs.png | Bin 37678 -> 37678 bytes .../doc/latex/webquiz/examples/choice-multiple.png | Bin 76590 -> 76590 bytes .../doc/latex/webquiz/examples/choice-single.png | Bin 65989 -> 65989 bytes .../doc/latex/webquiz/examples/ctanLion.png | Bin 103994 -> 103994 bytes .../doc/latex/webquiz/examples/discussion-Qref.png | Bin 34269 -> 34269 bytes .../doc/latex/webquiz/examples/discussion-ref.png | Bin 84118 -> 84118 bytes .../doc/latex/webquiz/examples/discussion.png | Bin 157520 -> 157520 bytes .../latex/webquiz/examples/display-as-image.png | Bin 92928 -> 92928 bytes .../doc/latex/webquiz/examples/french.png | Bin 90407 -> 90407 bytes .../doc/latex/webquiz/examples/index-cz.png | Bin 60597 -> 60597 bytes .../doc/latex/webquiz/examples/index-en.png | Bin 63504 -> 63504 bytes .../doc/latex/webquiz/examples/montypython.png | Bin 45495 -> 45495 bytes .../doc/latex/webquiz/examples/nounits.png | Bin 13972 -> 13972 bytes .../doc/latex/webquiz/examples/onepage.png | Bin 153578 -> 153578 bytes .../doc/latex/webquiz/examples/pst2pdf.png | Bin 152800 -> 45832 bytes .../doc/latex/webquiz/examples/pstricks-ex.png | Bin 119053 -> 119053 bytes .../doc/latex/webquiz/examples/quiz-page.png | Bin 151626 -> 144742 bytes .../doc/latex/webquiz/examples/quiz-page.tex | 3 +- .../latex/webquiz/examples/quizindex-dropdown.png | Bin 37678 -> 37678 bytes .../doc/latex/webquiz/examples/random.png | Bin 74129 -> 73601 bytes .../doc/latex/webquiz/examples/simple-html.png | Bin 98108 -> 98108 bytes .../doc/latex/webquiz/examples/simple-pdf.png | Bin 12342 -> 12342 bytes .../doc/latex/webquiz/examples/theme-blue.png | Bin 142758 -> 142758 bytes .../doc/latex/webquiz/examples/theme-darkblue.png | Bin 147537 -> 147537 bytes .../doc/latex/webquiz/examples/theme-darkred.png | Bin 145332 -> 145332 bytes .../doc/latex/webquiz/examples/theme-default.png | Bin 145410 -> 145410 bytes .../doc/latex/webquiz/examples/theme-earthy.png | Bin 148481 -> 148481 bytes .../doc/latex/webquiz/examples/theme-fresh.png | Bin 144392 -> 144392 bytes .../doc/latex/webquiz/examples/theme-light.png | Bin 143177 -> 143177 bytes .../doc/latex/webquiz/examples/theme-lively.png | Bin 136481 -> 136481 bytes .../doc/latex/webquiz/examples/theme-muted.png | Bin 142632 -> 142632 bytes .../doc/latex/webquiz/examples/theme-sleek.png | Bin 141155 -> 141155 bytes .../doc/latex/webquiz/examples/theme-spring.png | Bin 137510 -> 137510 bytes .../doc/latex/webquiz/examples/theme-vibrant.png | Bin 145965 -> 145965 bytes .../doc/latex/webquiz/examples/tikz-ex.png | Bin 68561 -> 68561 bytes .../doc/latex/webquiz/webquiz-online-manual.pdf | Bin 149401 -> 149401 bytes .../texmf-dist/doc/latex/webquiz/webquiz.languages | 2 +- Master/texmf-dist/doc/latex/webquiz/webquiz.pdf | Bin 3594920 -> 3534688 bytes .../texmf-dist/doc/latex/webquiz/webquiz.settings | 14 +- Master/texmf-dist/doc/latex/webquiz/webquiz.tex | 49 +++++- Master/texmf-dist/doc/latex/webquiz/webquiz.themes | 2 +- Master/texmf-dist/doc/latex/webquiz/webquiz.usage | 3 +- Master/texmf-dist/doc/man/man1/webquiz.1 | 65 ++++---- Master/texmf-dist/doc/man/man1/webquiz.man1.pdf | Bin 33116 -> 32763 bytes Master/texmf-dist/scripts/webquiz/CHANGES.rst | 4 + Master/texmf-dist/scripts/webquiz/webquiz | 177 ++++++++++++--------- Master/texmf-dist/scripts/webquiz/webquiz.bat | 26 ++- Master/texmf-dist/scripts/webquiz/webquiz.py | 177 ++++++++++++--------- .../texmf-dist/scripts/webquiz/webquiz_layout.py | 4 +- .../texmf-dist/scripts/webquiz/webquiz_makequiz.py | 8 +- .../scripts/webquiz/webquiz_templates.py | 43 +++-- Master/texmf-dist/scripts/webquiz/webquiz_util.py | 37 ++++- Master/texmf-dist/tex/latex/webquiz/webquiz.cfg | 4 +- Master/texmf-dist/tex/latex/webquiz/webquiz.ini | 2 +- 63 files changed, 529 insertions(+), 343 deletions(-) diff --git a/Build/source/texk/texlive/linked_scripts/webquiz/webquiz.py b/Build/source/texk/texlive/linked_scripts/webquiz/webquiz.py index 283f21d1321..de1e052fb7c 100755 --- a/Build/source/texk/texlive/linked_scripts/webquiz/webquiz.py +++ b/Build/source/texk/texlive/linked_scripts/webquiz/webquiz.py @@ -42,7 +42,7 @@ except subprocess.CalledProcessError: try: metadata = webquiz_util.MetaData(ini_file, debugging=False) except (FileNotFoundError, subprocess.CalledProcessError): - print('webquiz installation error: unable to find webquiz.ini -> {}'.format(ini_file)) + print(webquiz_templates.missing_webquiz_ini.format(ini_file)) sys.exit(1) # --------------------------------------------------------------------------------------- @@ -71,7 +71,8 @@ def preprocess_with_pst2pdf(options, quiz_file): # pst2pdf converts pspicture environments to svg images and makes a # new latex file quiz_file+'-pdf' that includes these cmd = 'pst2pdf --svg --imgdir={q_file} {q_file}.tex'.format(q_file=quiz_file) - options.run(cmd) + # pst2pdf is missing a #!-header so we need shell=True + options.run(cmd, shell=True) except OSError as err: if err.errno == errno.ENOENT: webquiz_util.webquiz_error(options.debugging, 'pst2pdf not found. You need to install pst2pdf to use the pst2pdf option', err) @@ -226,12 +227,16 @@ class WebQuizSettings: # define user and system rc file and load the ones that exist - self.system_rcfile = os.path.join(webquiz_util.kpsewhich('-var TEXMFLOCAL'), - 'tex', - 'latex', - 'webquiz', - 'webquizrc' - ) + TEXMFLOCAL='' + try: + TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFLOCAL') + except subprocess.CalledProcessError: + pass + + if TEXMFLOCAL == '': + TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFMAIN') + + self.system_rcfile = os.path.join(TEXMFLOCAL, 'tex', 'latex', 'webquiz', 'webquizrc') self.read_webquizrc(self.system_rcfile) # the user rc file defaults to: @@ -378,9 +383,8 @@ class WebQuizSettings: Print the non-default settings for webquiz from the webquizrc ''' if not hasattr(self, 'rcfile'): - print( - 'Please initialise WebQuiz using the command: webquiz --initialise\n' - ) + print(webquiz_templates.initialise_settings) + sys.exit(1) if setting not in ['all', 'verbose', 'help']: setting = setting.replace('-', '_') @@ -440,7 +444,7 @@ class WebQuizSettings: default_root = '/Library/WebServer/Documents/WebQuiz' platform = 'Mac OSX' elif sys.platform.startswith('win'): - default_root = ' c:\inetpub\wwwroot\WebQuiz' + default_root = 'c:\inetpub\wwwroot\WebQuiz' platform = 'Windows' else: default_root = '/var/www/html/WebQuiz' @@ -496,7 +500,7 @@ class WebQuizSettings: # if texdoc failed then try using TEXMFMAIN if webquiz_doc=='': try: - webquiz_doc = os.path.join(webquiz_util.kpsewhich('-var TEXMFMAIN'), 'doc','latex', 'webquiz') + webquiz_doc = os.path.join(webquiz_util.kpsewhich('-var-value TEXMFMAIN'), 'doc','latex', 'webquiz') except subprocess.CalledProcessError: pass @@ -648,7 +652,7 @@ class WebQuizSettings: Undocumented feature - useful for debugging initialisation routine ''' webquiz_top = os.path.abspath(webquiz_util.webquiz_file('..')) - texmf = webquiz_util.kpsewhich('-var TEXMFMAIN') + texmf = webquiz_util.kpsewhich('-var-value TEXMFMAIN') for (src, target) in [('scripts', 'scripts'), ('latex', 'tex/latex'), ('doc', 'doc/latex')]: @@ -665,8 +669,17 @@ class WebQuizSettings: try: # add a link to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - os.symlink(os.path.join(texmf,'scripts','webquiz','webquiz.py'), os.path.join(texbin, 'webquiz')) + texbin = os.path.dirname(shutil.which('pdflatex')) + if sys.platform.startswith('win'): + shutil.copyfile( + os.path.join(texmf,'scripts','webquiz','webquiz.bat'), + os.path.join(texbin, 'webquiz.bat') + ) + else: + os.symlink( + os.path.join(texmf,'scripts','webquiz','webquiz.py'), + os.path.join(texbin, 'webquiz') + ) subprocess.call('mktexlsr', shell=True) except (FileExistsError,FileNotFoundError): @@ -677,8 +690,7 @@ class WebQuizSettings: sys.exit(1) except subprocess.CalledProcessError as err: - print('There was a problem running mktexlsr') - sys.exit(1) + self.webquiz_error('There was a problem running mktexlsr', err) def tex_uninstall(self): r''' @@ -692,7 +704,7 @@ class WebQuizSettings: Undocumented feature - useful for debugging initialisation routine ''' webquiz_top = os.path.abspath(webquiz_util.webquiz_file('..')) - texmf = webquiz_util.kpsewhich('-var TEXMFMAIN') + texmf = webquiz_util.kpsewhich('-var-value TEXMFMAIN') for target in ['scripts', 'tex/latex', 'doc/latex']: try: shutil.rmtree(os.path.join(texmf, target, 'webquiz')) @@ -706,8 +718,11 @@ class WebQuizSettings: try: # remove link from texbin to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - os.remove(os.path.join(texbin, 'webquiz')) + texbin = os.path.dirname(shutil.which('pdflatex')) + if sys.platform.startswith('win'): + os.remove(os.path.join(texbin, 'webquiz.bat')) + else: + os.remove(os.path.join(texbin, 'webquiz')) except (FileExistsError,FileNotFoundError): pass @@ -729,12 +744,16 @@ class WebQuizSettings: sys.exit(1) # remove link to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - webquiz = os.path.join(texbin,'webquiz') + texbin = os.path.dirname(shutil.which('pdflatex')) try: - target = os.readlink(webquiz) - if target==os.path.join(texmf,'scripts','webquiz','webquiz.py'): + if sys.platform.startswith('win'): + webquiz = os.path.join(texbin, 'webquiz.bat') os.remove(webquiz) + else: + webquiz = os.path.join(texbin,'webquiz') + target = os.readlink(webquiz) + if target==os.path.join(texmf,'scripts','webquiz','webquiz.py'): + os.remove(webquiz) except (FileExistsError,FileNotFoundError): pass @@ -852,6 +871,7 @@ if __name__ == '__main__': settings_parser.add_argument( '-i', '--initialise', + '--initialize', action='store_true', default=False, help='Install web components of webquiz') @@ -1001,41 +1021,50 @@ if __name__ == '__main__': # - we need to use shell=True because otherwise pst2pdf gives an error # options.talk() is a shorthand for letting the user know what is happening if options.quiet == 0: - options.run = lambda cmd: subprocess.call(cmd, shell=True) + options.run = webquiz_util.run options.talk = lambda msg: print(msg) elif options.quiet == 1: - options.run = lambda cmd: subprocess.call(cmd, shell=True, stdout=open(os.devnull, 'wb')) + options.run = webquiz_util.quiet_run options.talk = lambda msg: print(msg) else: - options.run = lambda cmd: subprocess.call(cmd, shell=True, stdout=open(os.devnull, 'wb'), stderr=open(os.devnull, 'wb')) + options.run = webquiz_util.silent_run options.talk = lambda msg: None # run through the list of quizzes and make them for quiz_file in options.quiz_file: if len(options.quiz_file) > 1 and options.quiet < 3: print('Making web page for {}'.format(quiz_file)) + + quiz_name, ext = os.path.splitext(quiz_file) # extract filename and extension # quiz_file is assumed to be a tex file if no extension is given - if not '.' in quiz_file: - quiz_file += '.tex' + if ext=='': + ext = '.tex' + quiz_file += ext + + # windows likes adding a prefix of '.\\'to filename and this causes havoc with latex + if os.path.dirname(quiz_file)=='.': + quiz_file = os.path.basename(quiz_file) - if not os.path.isfile(quiz_file): - print('WebQuiz error: cannot read file {}'.format(quiz_file)) + if ext not in ['.tex', '.xml']: + webquiz_util.webquiz_error(True, 'unrecognised file extension {}'.format(ext)) - else: + if not os.path.isfile(quiz_file): + webquiz_util.webquiz+error(True, 'WebQuiz error: cannot read file {}'.format(quiz_file)) - # the quiz name and the quiz_file will be if pst2pdf is used - quiz_name = quiz_file - if options.quiet < 2: - print('WebQuiz generating web page for {}'.format(quiz_file)) + # the quiz name and the quiz_file will be different if pst2pdf is used + quiz_name = quiz_file + if options.quiet < 2: + print('WebQuiz generating web page for {}'.format(quiz_file)) - # If the pst2podf option is used then we need to preprocess + options.pst2pdf = False + if ext==".tex": + # If the pst2pdf option is used then we need to preprocess # the latex file BEFORE passing it to MakeWebQuiz. Set # options.pst2pdf = True if pst2pdf is given as an option to # the webquiz documentclass with codecs.open(quiz_file, 'r', encoding='utf8') as q_file: doc = q_file.read() - options.pst2pdf = False try: brac = doc.index(r'\documentclass[') + 15 # start of class options if 'pst2pdf' in [ @@ -1049,46 +1078,46 @@ if __name__ == '__main__': except ValueError: pass - # the file exists and is readable so make the quiz - webquiz_makequiz.MakeWebQuiz(quiz_name, quiz_file, options, settings, metadata) - - quiz_name = quiz_name[:quiz_name.index('.')] # remove the extension - - # move the css file into the directory for the quiz - css_file = os.path.join(quiz_name, quiz_name + '.css') - if os.path.isfile(quiz_name + '.css'): - if os.path.isfile(css_file): - os.remove(css_file) - shutil.move(quiz_name + '.css', css_file) - - # now clean up unless debugging - if not options.debugging: - for ext in ['4ct', '4tc', 'dvi', 'idv', 'lg', 'log', - 'ps', 'pdf', 'tmp', 'xml', 'xref' + # the file exists and is readable so make the quiz + webquiz_makequiz.MakeWebQuiz(quiz_name, quiz_file, options, settings, metadata) + + quiz_name, ext = os.path.splitext(quiz_name) # extract filename and extension + + # move the css file into the directory for the quiz + css_file = os.path.join(quiz_name, quiz_name + '.css') + if os.path.isfile(quiz_name + '.css'): + if os.path.isfile(css_file): + os.remove(css_file) + shutil.move(quiz_name + '.css', css_file) + + # now clean up unless debugging + if not options.debugging: + for ext in ['4ct', '4tc', 'dvi', 'idv', 'lg', 'log', + 'ps', 'pdf', 'tmp', 'xml', 'xref' + ]: + if os.path.isfile(quiz_name + '.' + ext): + os.remove(quiz_name + '.' + ext) + + # files created when using pst2pdf + if options.pst2pdf: + for file in glob.glob(quiz_name + '-pdf.*'): + os.remove(file) + for file in glob.glob(quiz_name + '-pdf-fixed.*'): + os.remove(file) + for extention in ['.preamble', '.plog', '-tmp.tex', + '-pst.tex', '-fig.tex' ]: - if os.path.isfile(quiz_name + '.' + ext): - os.remove(quiz_name + '.' + ext) - - # files created when using pst2pdf - if options.pst2pdf: - for file in glob.glob(quiz_name + '-pdf.*'): - os.remove(file) - for file in glob.glob(quiz_name + '-pdf-fixed.*'): - os.remove(file) - for extention in ['.preamble', '.plog', '-tmp.tex', - '-pst.tex', '-fig.tex' - ]: - if os.path.isfile(quiz_name + extention): - os.remove(quiz_name + extention) - if os.path.isdir(os.path.join(quiz_name, quiz_name)): - shutil.rmtree(os.path.join(quiz_name, quiz_name)) - - if settings.initialise_warning != '': + if os.path.isfile(quiz_name + extention): + os.remove(quiz_name + extention) + if os.path.isdir(os.path.join(quiz_name, quiz_name)): + shutil.rmtree(os.path.join(quiz_name, quiz_name)) + + if settings.initialise_warning != '' and not settings.have_initialised: print(webquiz_templates.text_initialise_warning) except Exception as err: - # there is a small chance that there is an error before we the + # there is a small chance that there is an error before the # settings.debugging flag has been set webquiz_util.webquiz_error(settings.debugging if 'settings' in globals() else True, 'unknown problem.\n\nIf you think this is a bug please report it by creating an issue at\n {}\n' diff --git a/Master/texmf-dist/doc/latex/webquiz/README.rst b/Master/texmf-dist/doc/latex/webquiz/README.rst index 60d0f52181f..dd8efda77e7 100644 --- a/Master/texmf-dist/doc/latex/webquiz/README.rst +++ b/Master/texmf-dist/doc/latex/webquiz/README.rst @@ -44,7 +44,8 @@ optional arguments: -x, --xelatex Use xelatex to compile the quiz -r RCFILE, --rcfile RCFILE Specify location of the webquiz rc-file - -i, --initialise Install web components of webquiz + -i, --initialise, --initialize + Install web components of webquiz -e, --edit-settings Edit default settings for webquiz --settings List default settings for webquiz @@ -61,40 +62,33 @@ If you want to install the web components of WebQuiz_ into a system directory th Please see the manual for more details about initialising and using WebQuiz_. -Installation from ctan ----------------------- -If you are installing WebQuiz using the zip file from ctan, as opposed to -installing the package from TeX distribution like TeXLive, then the following -steps are recommended: - -- Create a symbolic link, or equivalent, to the main WebQuiz executable, which - is the file webquiz.py in the scripts directory -- Copy the latex directory to somewhere in TeX search path, or set your - TEXINPUTS environment variable appropriately, and then run `mktexlsr` or - equivalent so that LaTeX and WebQuiz can find these files. -- Ideally the doc subdirectory should be copied into the doc/layetx subdirecory - of the main TeX distribution. - -If you are using a unix system, or macosx, there is an (undocumented) -command-line option `--tex-install` that installs the three different -components of WebQuiz_ into the standard locations in the TeXLive -tree: - -- $TEXMFMAIN/tex/latex/webquiz all LaTeX files -- $TEXMFMAIN/scripts/webquiz the python programs -- $TEXMFMAIN/doc/latex/webquiz the documentation and web components -- A symbolic link is made from the TeX bin directory to the main - WebQuiz executable $TEXMFMAIN/scripts/webquiz/webquiz.py - -To install these files in TEXMFMAIN you will almost certainly need -adminsistrator or root privledges, so on a unix-like system you will -need to use: - -> sudo webquiz/scripts/webquiz --tex-install - -In principle, this command may also work on a windows computer, -provided that the command `kpsewhich` is available, but this is -untested. +Installation from the ctan zipfile +---------------------------------- +On both unix-like systems (including macosx), and windows systems (using +either TeXLive or MiKTeX), you can install WebQuiz by downloading the +WebQuiz zip file from: + + http://mirrors.ctan.org/macros/latex/contrib/webquiz.zip + +To install the package, unzip this file and change directory to the +webquiz/scripts subdirectory run: + +> webquiz --tex-install + +(or webquiz.bat --text-install on windows). This commands unpacks the webquiz +files into their standard locations in the TeX install tree to it should be +run from an administrators account, or using sudo on a unix-like system. +Roughly what this command does is the following: + +- It creates a symbolic link, or equivalent, to the main WebQuiz executable, + which is the file webquiz.py in the scripts directory +- Copies the latex directory to somewhere in the TeX search path and then + runs `mktexlsr` so that LaTeX and WebQuiz can find these files. +- Copies the python code into the TeX scripts subdirectory +- Copies the WebQuiz doc subdirectory into the TeX doc/latex subdirectory. + +If you are using MiKTeX you may need to open the MiKTeX console, go to +the Tasks menu and then rebuild the TeX filename database. Once the files above are in place initialise WebQuiz by following the installation instructions above. @@ -135,7 +129,12 @@ system: Authors ------- -The LaTeX component of WebQuiz_ was written by Andrew Mathas and the python, css and javascript code was written by Andrew Mathas (and Don Taylor), based on an initial protype of Don Taylor's from 2001. Since 2004 the program has been maintained and developed by Andrew Mathas. Although the program has changed substantially since 2004 Don's idea of using TeX 4ht, and some of his code, is still very much in use. +The LaTeX component of WebQuiz_ was written by Andrew Mathas and the python, +css and javascript code was written by Andrew Mathas (and Don Taylor), based on +an initial protype of Don Taylor's from 2001. Since 2004 the program has been +maintained and developed by Andrew Mathas. Although the program has changed +substantially since 2004 Don's idea of using TeX4ht_, and some of his code, is +still very much in use. Copyright (C) 2004-2019 diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/README-examples b/Master/texmf-dist/doc/latex/webquiz/examples/README-examples index 42a73d3bf05..01e2455e279 100644 --- a/Master/texmf-dist/doc/latex/webquiz/examples/README-examples +++ b/Master/texmf-dist/doc/latex/webquiz/examples/README-examples @@ -1,2 +1,2 @@ -The tex and png files in this directory are used to build the WebQuiz manual. -Each tex file can be compiled using (pdf)latex and webquiz. +The TeX and png files in this directory are used to generate images in the +WebQuiz manual. Each TeX file can be compiled using (pdf)latex and webquiz. diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/answer-complex.png b/Master/texmf-dist/doc/latex/webquiz/examples/answer-complex.png index 12ae5938a08..841c81085f8 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/answer-complex.png and b/Master/texmf-dist/doc/latex/webquiz/examples/answer-complex.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/answer-integer.png b/Master/texmf-dist/doc/latex/webquiz/examples/answer-integer.png index d3da5be8e31..dc6113b9573 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/answer-integer.png and b/Master/texmf-dist/doc/latex/webquiz/examples/answer-integer.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/answer-lowercase.png b/Master/texmf-dist/doc/latex/webquiz/examples/answer-lowercase.png index 71a39e4cc42..a31d7049f3b 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/answer-lowercase.png and b/Master/texmf-dist/doc/latex/webquiz/examples/answer-lowercase.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/answer-number.png b/Master/texmf-dist/doc/latex/webquiz/examples/answer-number.png index 8dcbfd40988..14c3a9bed84 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/answer-number.png and b/Master/texmf-dist/doc/latex/webquiz/examples/answer-number.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/answer-star.png b/Master/texmf-dist/doc/latex/webquiz/examples/answer-star.png index af5936d3f7e..08528274087 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/answer-star.png and b/Master/texmf-dist/doc/latex/webquiz/examples/answer-star.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/answer-string.png b/Master/texmf-dist/doc/latex/webquiz/examples/answer-string.png index a88fa003072..affdf18f6f4 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/answer-string.png and b/Master/texmf-dist/doc/latex/webquiz/examples/answer-string.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/breadcrumbs.png b/Master/texmf-dist/doc/latex/webquiz/examples/breadcrumbs.png index 7ebf52b0d35..2c2a8175ea5 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/breadcrumbs.png and b/Master/texmf-dist/doc/latex/webquiz/examples/breadcrumbs.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/choice-multiple.png b/Master/texmf-dist/doc/latex/webquiz/examples/choice-multiple.png index 8f5cd6ca5f9..127f5d956cd 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/choice-multiple.png and b/Master/texmf-dist/doc/latex/webquiz/examples/choice-multiple.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/choice-single.png b/Master/texmf-dist/doc/latex/webquiz/examples/choice-single.png index e6828effa48..eda5fd9634e 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/choice-single.png and b/Master/texmf-dist/doc/latex/webquiz/examples/choice-single.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/ctanLion.png b/Master/texmf-dist/doc/latex/webquiz/examples/ctanLion.png index ab58f5e534d..0d711070149 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/ctanLion.png and b/Master/texmf-dist/doc/latex/webquiz/examples/ctanLion.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/discussion-Qref.png b/Master/texmf-dist/doc/latex/webquiz/examples/discussion-Qref.png index cd20eb79d2c..eafbab53ded 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/discussion-Qref.png and b/Master/texmf-dist/doc/latex/webquiz/examples/discussion-Qref.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/discussion-ref.png b/Master/texmf-dist/doc/latex/webquiz/examples/discussion-ref.png index d5b12cdc49f..a37f9526481 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/discussion-ref.png and b/Master/texmf-dist/doc/latex/webquiz/examples/discussion-ref.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/discussion.png b/Master/texmf-dist/doc/latex/webquiz/examples/discussion.png index 3e8bcd79f89..1b327072a3f 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/discussion.png and b/Master/texmf-dist/doc/latex/webquiz/examples/discussion.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/display-as-image.png b/Master/texmf-dist/doc/latex/webquiz/examples/display-as-image.png index 062a0f4edfa..ce76cb11193 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/display-as-image.png and b/Master/texmf-dist/doc/latex/webquiz/examples/display-as-image.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/french.png b/Master/texmf-dist/doc/latex/webquiz/examples/french.png index 0d038e7fbc1..42038b36939 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/french.png and b/Master/texmf-dist/doc/latex/webquiz/examples/french.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/index-cz.png b/Master/texmf-dist/doc/latex/webquiz/examples/index-cz.png index 874b857a9b0..e9d6a49ee05 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/index-cz.png and b/Master/texmf-dist/doc/latex/webquiz/examples/index-cz.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/index-en.png b/Master/texmf-dist/doc/latex/webquiz/examples/index-en.png index d3cc14ed55b..5d474581e0f 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/index-en.png and b/Master/texmf-dist/doc/latex/webquiz/examples/index-en.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/montypython.png b/Master/texmf-dist/doc/latex/webquiz/examples/montypython.png index 3352fb8c70a..e924e43d8c7 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/montypython.png and b/Master/texmf-dist/doc/latex/webquiz/examples/montypython.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/nounits.png b/Master/texmf-dist/doc/latex/webquiz/examples/nounits.png index 505e0fd6cd0..a504a247dfa 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/nounits.png and b/Master/texmf-dist/doc/latex/webquiz/examples/nounits.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/onepage.png b/Master/texmf-dist/doc/latex/webquiz/examples/onepage.png index 3609a37023d..880a1990ae7 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/onepage.png and b/Master/texmf-dist/doc/latex/webquiz/examples/onepage.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/pst2pdf.png b/Master/texmf-dist/doc/latex/webquiz/examples/pst2pdf.png index c678150ba18..b47fd703252 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/pst2pdf.png and b/Master/texmf-dist/doc/latex/webquiz/examples/pst2pdf.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/pstricks-ex.png b/Master/texmf-dist/doc/latex/webquiz/examples/pstricks-ex.png index 5f2709dc3be..1fe9bc19797 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/pstricks-ex.png and b/Master/texmf-dist/doc/latex/webquiz/examples/pstricks-ex.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.png b/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.png index 3bba2b8e6d6..82cb0dc9738 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.png and b/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.tex b/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.tex index d4436fc5fa4..9bc0740db1d 100644 --- a/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.tex +++ b/Master/texmf-dist/doc/latex/webquiz/examples/quiz-page.tex @@ -1,6 +1,5 @@ \documentclass[]{webquiz} -\usepackage[MATH1001]{sms-uos} -\BreadCrumbs{department | unitcode | quizindex | title} +\BreadCrumbs{quizindex | title} \DeclareMathOperator{\cis}{cis} \newcommand{\R}{\mathbb R} \newcommand{\C}{\mathbb C} diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/quizindex-dropdown.png b/Master/texmf-dist/doc/latex/webquiz/examples/quizindex-dropdown.png index 7fbfa8e699a..2207f3a54b3 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/quizindex-dropdown.png and b/Master/texmf-dist/doc/latex/webquiz/examples/quizindex-dropdown.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/random.png b/Master/texmf-dist/doc/latex/webquiz/examples/random.png index ca8157db498..592091f5a71 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/random.png and b/Master/texmf-dist/doc/latex/webquiz/examples/random.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/simple-html.png b/Master/texmf-dist/doc/latex/webquiz/examples/simple-html.png index 3d11b132175..f4c03dd0552 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/simple-html.png and b/Master/texmf-dist/doc/latex/webquiz/examples/simple-html.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/simple-pdf.png b/Master/texmf-dist/doc/latex/webquiz/examples/simple-pdf.png index f875e93c578..1d1a6090d79 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/simple-pdf.png and b/Master/texmf-dist/doc/latex/webquiz/examples/simple-pdf.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-blue.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-blue.png index deeff1ba3d2..cb36293d768 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-blue.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-blue.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkblue.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkblue.png index 681cfb99e31..57001cf4375 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkblue.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkblue.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkred.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkred.png index 76ea13e5184..d47c50c1b38 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkred.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-darkred.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-default.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-default.png index 7807ba8a18a..10ad1a00c39 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-default.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-default.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-earthy.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-earthy.png index 94607d0cdf8..f8e65c2b75e 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-earthy.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-earthy.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-fresh.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-fresh.png index 2c4d7d81b01..b3690d85498 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-fresh.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-fresh.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-light.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-light.png index 46cc7aa3e2f..3282223e063 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-light.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-light.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-lively.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-lively.png index 278f3eca4b1..c750615fe87 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-lively.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-lively.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-muted.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-muted.png index 88beac86865..9151228073e 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-muted.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-muted.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-sleek.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-sleek.png index 89a4226edfc..c2c3f1c153e 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-sleek.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-sleek.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-spring.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-spring.png index 57cc0aa6352..8efc7a99240 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-spring.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-spring.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/theme-vibrant.png b/Master/texmf-dist/doc/latex/webquiz/examples/theme-vibrant.png index 7ccc8888dbf..fa1cdb3367a 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/theme-vibrant.png and b/Master/texmf-dist/doc/latex/webquiz/examples/theme-vibrant.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/examples/tikz-ex.png b/Master/texmf-dist/doc/latex/webquiz/examples/tikz-ex.png index 87bc1c0a8ab..5b51c8b24a7 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/examples/tikz-ex.png and b/Master/texmf-dist/doc/latex/webquiz/examples/tikz-ex.png differ diff --git a/Master/texmf-dist/doc/latex/webquiz/webquiz-online-manual.pdf b/Master/texmf-dist/doc/latex/webquiz/webquiz-online-manual.pdf index 8d3a9d4815b..64dbf041864 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/webquiz-online-manual.pdf and b/Master/texmf-dist/doc/latex/webquiz/webquiz-online-manual.pdf differ diff --git a/Master/texmf-dist/doc/latex/webquiz/webquiz.languages b/Master/texmf-dist/doc/latex/webquiz/webquiz.languages index 9b188c48a92..ebfe2505330 100644 --- a/Master/texmf-dist/doc/latex/webquiz/webquiz.languages +++ b/Master/texmf-dist/doc/latex/webquiz/webquiz.languages @@ -1,3 +1,3 @@ % List of languages currently supported by WebQuiz -% Generated using 'makedoc --languages' on 2019-03-10 +% Generated using 'makedoc --languages' on 2019-04-01 \newcommand\WebQuizLanguages{Czech, English, French, German, Greek, Italian, Japanese, Mandarin, Russian, Spanish,, Swedish} diff --git a/Master/texmf-dist/doc/latex/webquiz/webquiz.pdf b/Master/texmf-dist/doc/latex/webquiz/webquiz.pdf index 10d7036c0b2..358637b1b0f 100644 Binary files a/Master/texmf-dist/doc/latex/webquiz/webquiz.pdf and b/Master/texmf-dist/doc/latex/webquiz/webquiz.pdf differ diff --git a/Master/texmf-dist/doc/latex/webquiz/webquiz.settings b/Master/texmf-dist/doc/latex/webquiz/webquiz.settings index bee51d3ccb7..47dee55754d 100644 --- a/Master/texmf-dist/doc/latex/webquiz/webquiz.settings +++ b/Master/texmf-dist/doc/latex/webquiz/webquiz.settings @@ -1,6 +1,6 @@ ---------------------------------------------------------- -WebQuiz rc-file: /Users/andrew/.dotfiles/config/webquizrc ---------------------------------------------------------- +--------------------------------------------------------------------------- +WebQuiz rc-file: /usr/local/texlive/texmf-local/tex/latex/webquiz/webquizrc +--------------------------------------------------------------------------- breadcrumbs = department = department-url = / @@ -12,10 +12,10 @@ language = english one-page = false random-order = false theme = default -version = 5.1 -webquiz-url = /~andrew/Webby -webquiz-www = /Users/andrew/Sites/Webby +version = 5.2 +webquiz-url = /WebQuiz +webquiz-www = /Library/WebServer/Documents/WebQuiz make4ht = mathjax = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js webquiz-layout = webquiz_layout ---------------------------------------------------------- +--------------------------------------------------------------------------- diff --git a/Master/texmf-dist/doc/latex/webquiz/webquiz.tex b/Master/texmf-dist/doc/latex/webquiz/webquiz.tex index f0b63b41a05..808c7f032a4 100644 --- a/Master/texmf-dist/doc/latex/webquiz/webquiz.tex +++ b/Master/texmf-dist/doc/latex/webquiz/webquiz.tex @@ -85,16 +85,16 @@ \renewcommand*\contentsname{\relax} % hyperref links to ctan -\newcommand\TeXLive{\ctan[/]{\TeX Live}\xspace} +\newcommand\TeXLive{\href{https://www.tug.org/texlive/}{\TeX Live}\xspace} \newcommand\Ctan{\ctan[]{ctan}\xspace} \newcommand\ddash{\texttt{\textemdash\textemdash}} \NewDocumentCommand\webquizrc{s}{\index{webquizrc}% \BashCode|webquizrc| file\IfBooleanF{#1}{ (\autoref{SS:rcfile})}\xspace% } - +\newcommand\MiKTeX{\href{https://miktex.org/}{MiK\TeX}\xspace} \NewDocumentCommand\OnlineManual{s}{% \href{http://www.maths.usyd.edu.au/u/mathas/WebQuiz/webquiz-online-manual.html}{Online manual}% - \IfBooleanF{#1}{ (\hyperref[S:online]{Appendix B})}\xspace% + \IfBooleanF{#1}{ (\hyperref[S:online]{Appendix~B})}\xspace% } \indexprologue{% @@ -423,7 +423,7 @@ are due to Thomas Cailleteau Michael Palmer and - Hendrik Suess, + Hendrik Suess for helpful feedback on the package. \section{The \WebQuiz document class --- \hologo{LaTeX}{} commands} @@ -1548,7 +1548,7 @@ In order to work \WebQuiz needs the following programs to be installed on your system: - \begin{itemize} + \begin{itemize}[nosep] \item An up-to-date \LaTeX{} distribution, such as that provided by \TeXLive. In particular, you need to have \TeXfht{} and \ctan{make4ht} installed. @@ -1569,6 +1569,39 @@ will need to install the web components of \WebQuiz. \end{itemize} + \subsection{Installing + \WebQuiz}\label{SS:Install}\index{install}\index{miktex@Mik\TeX}\index{texlive@\TeXLive} + \WebQuiz will be included as a package in \TeXLive 2019 and, once a + packaging issue is sorted out, it will be included in \MiKTeX. If + \WebQuiz is available as a package from either of these distributions + then it can be installed in the usual way. + + Alternatively, it is possible to download the + \href{http://mirrors.ctan.org/macros/latex/contrib/webquiz.zip}{WebQuiz zipfile} from \Ctan. + To install \WebQuiz from the zipfile you should: + \begin{enumerate}[nosep] + \item Download the + \href{http://mirrors.ctan.org/macros/latex/contrib/webquiz.zip}{WebQuiz zipfile} from \Ctan. + \item Unzip the file + \item Change directory of the \BashCode|webquiz/scripts| subdirectory from the zipfile + \item From an administrators account, or using \BashCode|sudo| on a + unix-like system, run he command: + \begin{bashcode} + > webquiz --tex-install + \end{bashcode} + On windows, use: + \begin{bashcode} + > webquiz.bat --tex-install + \end{bashcode} + \end{enumerate} + This will install the different components of \WebQuiz to their + ``standard'' locations in he \TeX\ search tree. If you are using + \MiKTeX you may need to open the \MiKTeX console, go to the Tasks menu + and then rebuild the TeX filename database. + + Once the \WebQuiz package is installed you should initialise thew + package, following the steps given in \autoref{SS:Initialise}. + \subsection{Initialising \WebQuiz}\label{SS:Initialise} \CrossIndex{command-line option}{initialise} \index{initialisation} @@ -1681,7 +1714,7 @@ \href{https://en.wikipedia.org/wiki/Scalable_Vector_Graphics}{Scalable Vector Graphics} (SVG). This is done using his is done using \ctan{dvisvgm}. At first sight this is OK because \ctan{dvisvgm} is - included in \TeXLive and Mik\TeX, however, \ctan{dvisvgm} uses + included in \TeXLive and \MiKTeX, however, \ctan{dvisvgm} uses \Ghostscript and this needs to be correctly configured and, as outlined in \href{http://dvisvgm.bplaced.net/FAQ}{FAQ}, \ctan{dvisvgm} needs to know where to find the \Ghostscript libraries. For example, @@ -1901,8 +1934,8 @@ exit (currently \webquiz{version}) \item[\ddash tex-install] Use this command-line option if - are are installing the \LaTeX{} components of - \WebQuiz from the \Ctan zip-file. It will install the different + you are installing the \LaTeX{} components of + \WebQuiz from the \Ctan zip-filei (see \autoref{SS:Install}). It will install the different \LaTeX{} components of \WebQuiz into \BashCode|TEXMFMAIN|. If you installed \WebQuiz as part of a \TeX{} distribution, such as \TeXLive, then you do not need to use this option. diff --git a/Master/texmf-dist/doc/latex/webquiz/webquiz.themes b/Master/texmf-dist/doc/latex/webquiz/webquiz.themes index 0a840a7e047..ef4329b8f9c 100644 --- a/Master/texmf-dist/doc/latex/webquiz/webquiz.themes +++ b/Master/texmf-dist/doc/latex/webquiz/webquiz.themes @@ -1,2 +1,2 @@ -% List of themes supported by WebQuiz -- generated 2019-03-10 +% List of themes supported by WebQuiz -- generated 2019-04-01 \newcommand\WebQuizThemes{blue, darkblue, darkred, default, earthy, fresh, light, lively, muted, sleek, spring,, vibrant} diff --git a/Master/texmf-dist/doc/latex/webquiz/webquiz.usage b/Master/texmf-dist/doc/latex/webquiz/webquiz.usage index 955740c95cb..76c28a4a6b4 100644 --- a/Master/texmf-dist/doc/latex/webquiz/webquiz.usage +++ b/Master/texmf-dist/doc/latex/webquiz/webquiz.usage @@ -17,7 +17,8 @@ optional arguments: -x, --xelatex Use xelatex to compile the quiz -r RCFILE, --rcfile RCFILE Specify location of the webquiz rc-file - -i, --initialise Install web components of webquiz + -i, --initialise, --initialize + Install web components of webquiz -e, --edit-settings Edit default settings for webquiz --settings [SETTINGS] List default settings for webquiz diff --git a/Master/texmf-dist/doc/man/man1/webquiz.1 b/Master/texmf-dist/doc/man/man1/webquiz.1 index 076b3c70c1b..4bf1587e60e 100644 --- a/Master/texmf-dist/doc/man/man1/webquiz.1 +++ b/Master/texmf-dist/doc/man/man1/webquiz.1 @@ -95,7 +95,7 @@ Use xelatex to compile the quiz .BI \-r \ RCFILE\fP,\fB \ \-\-rcfile \ RCFILE Specify location of the webquiz rc\-file .TP -.B \-i\fP,\fB \-\-initialise +.B \-i\fP,\fB \-\-initialise\fP,\fB \-\-initialize Install web components of webquiz .TP .B \-e\fP,\fB \-\-edit\-settings @@ -116,49 +116,41 @@ Once the TeX components of \fI\%WebQuiz\fP package have been installed you can i If you want to install the web components of \fI\%WebQuiz\fP into a system directory then you need to run this command from an administrators account, so using \fIsudo\fP on a unix\-like system. For more details about the installation and configuration of \fI\%WebQuiz\fP please see Section 3.2 of the \fI\%WebQuiz\fP manual. .sp Please see the manual for more details about initialising and using \fI\%WebQuiz\fP\&. -.SH INSTALLATION FROM CTAN +.SH INSTALLATION FROM THE CTAN ZIPFILE .sp -If you are installing WebQuiz using the zip file from ctan, as opposed to -installing the package from TeX distribution like TeXLive, then the following -steps are recommended: +On both unix\-like systems (including macosx), and windows systems (using +either TeXLive or MiKTeX), you can install WebQuiz by downloading the +WebQuiz zip file from: .INDENT 0.0 -.IP \(bu 2 -Create a symbolic link, or equivalent, to the main WebQuiz executable, which -is the file webquiz.py in the scripts directory -.IP \(bu 2 -Copy the latex directory to somewhere in TeX search path, or set your -TEXINPUTS environment variable appropriately, and then run \fImktexlsr\fP or -equivalent so that LaTeX and WebQuiz can find these files. -.IP \(bu 2 -Ideally the doc subdirectory should be copied into the doc/layetx subdirecory -of the main TeX distribution. +.INDENT 3.5 +\fI\%http://mirrors.ctan.org/macros/latex/contrib/webquiz.zip\fP +.UNINDENT .UNINDENT .sp -If you are using a unix system, or macosx, there is an (undocumented) -command\-line option \fI\-\-tex\-install\fP that installs the three different -components of \fI\%WebQuiz\fP into the standard locations in the TeXLive -tree: +To install the package, unzip this file and change directory to the +webquiz/scripts subdirectory run: +.sp +> webquiz \-\-tex\-install +.sp +(or webquiz.bat \-\-text\-install on windows). This commands unpacks the webquiz +files into their standard locations in the TeX install tree to it should be +run from an administrators account, or using sudo on a unix\-like system. +Roughly what this command does is the following: .INDENT 0.0 .IP \(bu 2 -$TEXMFMAIN/tex/latex/webquiz all LaTeX files +It creates a symbolic link, or equivalent, to the main WebQuiz executable, +which is the file webquiz.py in the scripts directory .IP \(bu 2 -$TEXMFMAIN/scripts/webquiz the python programs +Copies the latex directory to somewhere in the TeX search path and then +runs \fImktexlsr\fP so that LaTeX and WebQuiz can find these files. .IP \(bu 2 -$TEXMFMAIN/doc/latex/webquiz the documentation and web components +Copies the python code into the TeX scripts subdirectory .IP \(bu 2 -A symbolic link is made from the TeX bin directory to the main -WebQuiz executable $TEXMFMAIN/scripts/webquiz/webquiz.py +Copies the WebQuiz doc subdirectory into the TeX doc/latex subdirectory. .UNINDENT .sp -To install these files in TEXMFMAIN you will almost certainly need -adminsistrator or root privledges, so on a unix\-like system you will -need to use: -.sp -> sudo webquiz/scripts/webquiz \-\-tex\-install -.sp -In principle, this command may also work on a windows computer, -provided that the command \fIkpsewhich\fP is available, but this is -untested. +If you are using MiKTeX you may need to open the MiKTeX console, go to +the Tasks menu and then rebuild the TeX filename database. .sp Once the files above are in place initialise WebQuiz by following the installation instructions above. @@ -198,7 +190,12 @@ described in the \fBInstallation\fP section you will also need to copy of the .UNINDENT .SH AUTHORS .sp -The LaTeX component of \fI\%WebQuiz\fP was written by Andrew Mathas and the python, css and javascript code was written by Andrew Mathas (and Don Taylor), based on an initial protype of Don Taylor\(aqs from 2001. Since 2004 the program has been maintained and developed by Andrew Mathas. Although the program has changed substantially since 2004 Don\(aqs idea of using TeX 4ht, and some of his code, is still very much in use. +The LaTeX component of \fI\%WebQuiz\fP was written by Andrew Mathas and the python, +css and javascript code was written by Andrew Mathas (and Don Taylor), based on +an initial protype of Don Taylor\(aqs from 2001. Since 2004 the program has been +maintained and developed by Andrew Mathas. Although the program has changed +substantially since 2004 Don\(aqs idea of using \fI\%TeX4ht\fP, and some of his code, is +still very much in use. .sp Copyright (C) 2004\-2019 .SH LICENSE diff --git a/Master/texmf-dist/doc/man/man1/webquiz.man1.pdf b/Master/texmf-dist/doc/man/man1/webquiz.man1.pdf index b607faccad9..ec70d4a294c 100644 Binary files a/Master/texmf-dist/doc/man/man1/webquiz.man1.pdf and b/Master/texmf-dist/doc/man/man1/webquiz.man1.pdf differ diff --git a/Master/texmf-dist/scripts/webquiz/CHANGES.rst b/Master/texmf-dist/scripts/webquiz/CHANGES.rst index e29b7e5cfb2..4de4c5641c5 100755 --- a/Master/texmf-dist/scripts/webquiz/CHANGES.rst +++ b/Master/texmf-dist/scripts/webquiz/CHANGES.rst @@ -2,6 +2,10 @@ WebQuiz Changes =============== +Version 5.2: +------------ + - compatibility with both MikTeX and TeXLive under windows + Version 5.1: ------------ - code reorganised n zip file for TeXLive inclusion diff --git a/Master/texmf-dist/scripts/webquiz/webquiz b/Master/texmf-dist/scripts/webquiz/webquiz index 283f21d1321..de1e052fb7c 100755 --- a/Master/texmf-dist/scripts/webquiz/webquiz +++ b/Master/texmf-dist/scripts/webquiz/webquiz @@ -42,7 +42,7 @@ except subprocess.CalledProcessError: try: metadata = webquiz_util.MetaData(ini_file, debugging=False) except (FileNotFoundError, subprocess.CalledProcessError): - print('webquiz installation error: unable to find webquiz.ini -> {}'.format(ini_file)) + print(webquiz_templates.missing_webquiz_ini.format(ini_file)) sys.exit(1) # --------------------------------------------------------------------------------------- @@ -71,7 +71,8 @@ def preprocess_with_pst2pdf(options, quiz_file): # pst2pdf converts pspicture environments to svg images and makes a # new latex file quiz_file+'-pdf' that includes these cmd = 'pst2pdf --svg --imgdir={q_file} {q_file}.tex'.format(q_file=quiz_file) - options.run(cmd) + # pst2pdf is missing a #!-header so we need shell=True + options.run(cmd, shell=True) except OSError as err: if err.errno == errno.ENOENT: webquiz_util.webquiz_error(options.debugging, 'pst2pdf not found. You need to install pst2pdf to use the pst2pdf option', err) @@ -226,12 +227,16 @@ class WebQuizSettings: # define user and system rc file and load the ones that exist - self.system_rcfile = os.path.join(webquiz_util.kpsewhich('-var TEXMFLOCAL'), - 'tex', - 'latex', - 'webquiz', - 'webquizrc' - ) + TEXMFLOCAL='' + try: + TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFLOCAL') + except subprocess.CalledProcessError: + pass + + if TEXMFLOCAL == '': + TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFMAIN') + + self.system_rcfile = os.path.join(TEXMFLOCAL, 'tex', 'latex', 'webquiz', 'webquizrc') self.read_webquizrc(self.system_rcfile) # the user rc file defaults to: @@ -378,9 +383,8 @@ class WebQuizSettings: Print the non-default settings for webquiz from the webquizrc ''' if not hasattr(self, 'rcfile'): - print( - 'Please initialise WebQuiz using the command: webquiz --initialise\n' - ) + print(webquiz_templates.initialise_settings) + sys.exit(1) if setting not in ['all', 'verbose', 'help']: setting = setting.replace('-', '_') @@ -440,7 +444,7 @@ class WebQuizSettings: default_root = '/Library/WebServer/Documents/WebQuiz' platform = 'Mac OSX' elif sys.platform.startswith('win'): - default_root = ' c:\inetpub\wwwroot\WebQuiz' + default_root = 'c:\inetpub\wwwroot\WebQuiz' platform = 'Windows' else: default_root = '/var/www/html/WebQuiz' @@ -496,7 +500,7 @@ class WebQuizSettings: # if texdoc failed then try using TEXMFMAIN if webquiz_doc=='': try: - webquiz_doc = os.path.join(webquiz_util.kpsewhich('-var TEXMFMAIN'), 'doc','latex', 'webquiz') + webquiz_doc = os.path.join(webquiz_util.kpsewhich('-var-value TEXMFMAIN'), 'doc','latex', 'webquiz') except subprocess.CalledProcessError: pass @@ -648,7 +652,7 @@ class WebQuizSettings: Undocumented feature - useful for debugging initialisation routine ''' webquiz_top = os.path.abspath(webquiz_util.webquiz_file('..')) - texmf = webquiz_util.kpsewhich('-var TEXMFMAIN') + texmf = webquiz_util.kpsewhich('-var-value TEXMFMAIN') for (src, target) in [('scripts', 'scripts'), ('latex', 'tex/latex'), ('doc', 'doc/latex')]: @@ -665,8 +669,17 @@ class WebQuizSettings: try: # add a link to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - os.symlink(os.path.join(texmf,'scripts','webquiz','webquiz.py'), os.path.join(texbin, 'webquiz')) + texbin = os.path.dirname(shutil.which('pdflatex')) + if sys.platform.startswith('win'): + shutil.copyfile( + os.path.join(texmf,'scripts','webquiz','webquiz.bat'), + os.path.join(texbin, 'webquiz.bat') + ) + else: + os.symlink( + os.path.join(texmf,'scripts','webquiz','webquiz.py'), + os.path.join(texbin, 'webquiz') + ) subprocess.call('mktexlsr', shell=True) except (FileExistsError,FileNotFoundError): @@ -677,8 +690,7 @@ class WebQuizSettings: sys.exit(1) except subprocess.CalledProcessError as err: - print('There was a problem running mktexlsr') - sys.exit(1) + self.webquiz_error('There was a problem running mktexlsr', err) def tex_uninstall(self): r''' @@ -692,7 +704,7 @@ class WebQuizSettings: Undocumented feature - useful for debugging initialisation routine ''' webquiz_top = os.path.abspath(webquiz_util.webquiz_file('..')) - texmf = webquiz_util.kpsewhich('-var TEXMFMAIN') + texmf = webquiz_util.kpsewhich('-var-value TEXMFMAIN') for target in ['scripts', 'tex/latex', 'doc/latex']: try: shutil.rmtree(os.path.join(texmf, target, 'webquiz')) @@ -706,8 +718,11 @@ class WebQuizSettings: try: # remove link from texbin to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - os.remove(os.path.join(texbin, 'webquiz')) + texbin = os.path.dirname(shutil.which('pdflatex')) + if sys.platform.startswith('win'): + os.remove(os.path.join(texbin, 'webquiz.bat')) + else: + os.remove(os.path.join(texbin, 'webquiz')) except (FileExistsError,FileNotFoundError): pass @@ -729,12 +744,16 @@ class WebQuizSettings: sys.exit(1) # remove link to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - webquiz = os.path.join(texbin,'webquiz') + texbin = os.path.dirname(shutil.which('pdflatex')) try: - target = os.readlink(webquiz) - if target==os.path.join(texmf,'scripts','webquiz','webquiz.py'): + if sys.platform.startswith('win'): + webquiz = os.path.join(texbin, 'webquiz.bat') os.remove(webquiz) + else: + webquiz = os.path.join(texbin,'webquiz') + target = os.readlink(webquiz) + if target==os.path.join(texmf,'scripts','webquiz','webquiz.py'): + os.remove(webquiz) except (FileExistsError,FileNotFoundError): pass @@ -852,6 +871,7 @@ if __name__ == '__main__': settings_parser.add_argument( '-i', '--initialise', + '--initialize', action='store_true', default=False, help='Install web components of webquiz') @@ -1001,41 +1021,50 @@ if __name__ == '__main__': # - we need to use shell=True because otherwise pst2pdf gives an error # options.talk() is a shorthand for letting the user know what is happening if options.quiet == 0: - options.run = lambda cmd: subprocess.call(cmd, shell=True) + options.run = webquiz_util.run options.talk = lambda msg: print(msg) elif options.quiet == 1: - options.run = lambda cmd: subprocess.call(cmd, shell=True, stdout=open(os.devnull, 'wb')) + options.run = webquiz_util.quiet_run options.talk = lambda msg: print(msg) else: - options.run = lambda cmd: subprocess.call(cmd, shell=True, stdout=open(os.devnull, 'wb'), stderr=open(os.devnull, 'wb')) + options.run = webquiz_util.silent_run options.talk = lambda msg: None # run through the list of quizzes and make them for quiz_file in options.quiz_file: if len(options.quiz_file) > 1 and options.quiet < 3: print('Making web page for {}'.format(quiz_file)) + + quiz_name, ext = os.path.splitext(quiz_file) # extract filename and extension # quiz_file is assumed to be a tex file if no extension is given - if not '.' in quiz_file: - quiz_file += '.tex' + if ext=='': + ext = '.tex' + quiz_file += ext + + # windows likes adding a prefix of '.\\'to filename and this causes havoc with latex + if os.path.dirname(quiz_file)=='.': + quiz_file = os.path.basename(quiz_file) - if not os.path.isfile(quiz_file): - print('WebQuiz error: cannot read file {}'.format(quiz_file)) + if ext not in ['.tex', '.xml']: + webquiz_util.webquiz_error(True, 'unrecognised file extension {}'.format(ext)) - else: + if not os.path.isfile(quiz_file): + webquiz_util.webquiz+error(True, 'WebQuiz error: cannot read file {}'.format(quiz_file)) - # the quiz name and the quiz_file will be if pst2pdf is used - quiz_name = quiz_file - if options.quiet < 2: - print('WebQuiz generating web page for {}'.format(quiz_file)) + # the quiz name and the quiz_file will be different if pst2pdf is used + quiz_name = quiz_file + if options.quiet < 2: + print('WebQuiz generating web page for {}'.format(quiz_file)) - # If the pst2podf option is used then we need to preprocess + options.pst2pdf = False + if ext==".tex": + # If the pst2pdf option is used then we need to preprocess # the latex file BEFORE passing it to MakeWebQuiz. Set # options.pst2pdf = True if pst2pdf is given as an option to # the webquiz documentclass with codecs.open(quiz_file, 'r', encoding='utf8') as q_file: doc = q_file.read() - options.pst2pdf = False try: brac = doc.index(r'\documentclass[') + 15 # start of class options if 'pst2pdf' in [ @@ -1049,46 +1078,46 @@ if __name__ == '__main__': except ValueError: pass - # the file exists and is readable so make the quiz - webquiz_makequiz.MakeWebQuiz(quiz_name, quiz_file, options, settings, metadata) - - quiz_name = quiz_name[:quiz_name.index('.')] # remove the extension - - # move the css file into the directory for the quiz - css_file = os.path.join(quiz_name, quiz_name + '.css') - if os.path.isfile(quiz_name + '.css'): - if os.path.isfile(css_file): - os.remove(css_file) - shutil.move(quiz_name + '.css', css_file) - - # now clean up unless debugging - if not options.debugging: - for ext in ['4ct', '4tc', 'dvi', 'idv', 'lg', 'log', - 'ps', 'pdf', 'tmp', 'xml', 'xref' + # the file exists and is readable so make the quiz + webquiz_makequiz.MakeWebQuiz(quiz_name, quiz_file, options, settings, metadata) + + quiz_name, ext = os.path.splitext(quiz_name) # extract filename and extension + + # move the css file into the directory for the quiz + css_file = os.path.join(quiz_name, quiz_name + '.css') + if os.path.isfile(quiz_name + '.css'): + if os.path.isfile(css_file): + os.remove(css_file) + shutil.move(quiz_name + '.css', css_file) + + # now clean up unless debugging + if not options.debugging: + for ext in ['4ct', '4tc', 'dvi', 'idv', 'lg', 'log', + 'ps', 'pdf', 'tmp', 'xml', 'xref' + ]: + if os.path.isfile(quiz_name + '.' + ext): + os.remove(quiz_name + '.' + ext) + + # files created when using pst2pdf + if options.pst2pdf: + for file in glob.glob(quiz_name + '-pdf.*'): + os.remove(file) + for file in glob.glob(quiz_name + '-pdf-fixed.*'): + os.remove(file) + for extention in ['.preamble', '.plog', '-tmp.tex', + '-pst.tex', '-fig.tex' ]: - if os.path.isfile(quiz_name + '.' + ext): - os.remove(quiz_name + '.' + ext) - - # files created when using pst2pdf - if options.pst2pdf: - for file in glob.glob(quiz_name + '-pdf.*'): - os.remove(file) - for file in glob.glob(quiz_name + '-pdf-fixed.*'): - os.remove(file) - for extention in ['.preamble', '.plog', '-tmp.tex', - '-pst.tex', '-fig.tex' - ]: - if os.path.isfile(quiz_name + extention): - os.remove(quiz_name + extention) - if os.path.isdir(os.path.join(quiz_name, quiz_name)): - shutil.rmtree(os.path.join(quiz_name, quiz_name)) - - if settings.initialise_warning != '': + if os.path.isfile(quiz_name + extention): + os.remove(quiz_name + extention) + if os.path.isdir(os.path.join(quiz_name, quiz_name)): + shutil.rmtree(os.path.join(quiz_name, quiz_name)) + + if settings.initialise_warning != '' and not settings.have_initialised: print(webquiz_templates.text_initialise_warning) except Exception as err: - # there is a small chance that there is an error before we the + # there is a small chance that there is an error before the # settings.debugging flag has been set webquiz_util.webquiz_error(settings.debugging if 'settings' in globals() else True, 'unknown problem.\n\nIf you think this is a bug please report it by creating an issue at\n {}\n' diff --git a/Master/texmf-dist/scripts/webquiz/webquiz.bat b/Master/texmf-dist/scripts/webquiz/webquiz.bat index c92a60d3a29..89c05730fa4 100755 --- a/Master/texmf-dist/scripts/webquiz/webquiz.bat +++ b/Master/texmf-dist/scripts/webquiz/webquiz.bat @@ -1,14 +1,30 @@ @echo off +rem WebQuiz batch file to find and launch python executable + +rem Set TEXMF to root TeX directory and look for webquiz.py in scripts/webquiz setlocal enableextensions -rem assuming the main script is in the same directory -if not exist "%~dpn0.py" ( - echo %~nx0: main script "%~dpn0.py" not found>&2 +for /F "tokens=*" %%i in ('kpsewhich -var-value TEXMFMAIN') do (SET TEXMF=%%i) + +rem First look for webquiz.py in the current directory +set WebQuiz="webquiz.py" +if not exist %WebQuiz% ( + if exist "%TEXMF%/scripts/webquiz/webquiz.py" ( + set WebQuiz="%TEXMF%/scripts/webquiz/webquiz.py" + ) +) +rem +rem exit with an error if webquiz.py has not been found +if not exist %WebQuiz% ( + echo WebQuiz executable not found. Please check that WebQuiz is properly installed>&2 exit /b 1 ) -rem check if interpreter is on the PATH + +rem check for the python interpreter in the PATH for %%I in (python.exe) do set "PYTHONEXE=%%~$PATH:I" if not defined PYTHONEXE ( echo %~nx0: Python interpreter not installed or not on the PATH>&2 exit /b 1 ) -"%PYTHONEXE%" "%~dpn0.py" %* + +rem launch webquiz +"%PYTHONEXE%" %WebQuiz% %* diff --git a/Master/texmf-dist/scripts/webquiz/webquiz.py b/Master/texmf-dist/scripts/webquiz/webquiz.py index 283f21d1321..de1e052fb7c 100755 --- a/Master/texmf-dist/scripts/webquiz/webquiz.py +++ b/Master/texmf-dist/scripts/webquiz/webquiz.py @@ -42,7 +42,7 @@ except subprocess.CalledProcessError: try: metadata = webquiz_util.MetaData(ini_file, debugging=False) except (FileNotFoundError, subprocess.CalledProcessError): - print('webquiz installation error: unable to find webquiz.ini -> {}'.format(ini_file)) + print(webquiz_templates.missing_webquiz_ini.format(ini_file)) sys.exit(1) # --------------------------------------------------------------------------------------- @@ -71,7 +71,8 @@ def preprocess_with_pst2pdf(options, quiz_file): # pst2pdf converts pspicture environments to svg images and makes a # new latex file quiz_file+'-pdf' that includes these cmd = 'pst2pdf --svg --imgdir={q_file} {q_file}.tex'.format(q_file=quiz_file) - options.run(cmd) + # pst2pdf is missing a #!-header so we need shell=True + options.run(cmd, shell=True) except OSError as err: if err.errno == errno.ENOENT: webquiz_util.webquiz_error(options.debugging, 'pst2pdf not found. You need to install pst2pdf to use the pst2pdf option', err) @@ -226,12 +227,16 @@ class WebQuizSettings: # define user and system rc file and load the ones that exist - self.system_rcfile = os.path.join(webquiz_util.kpsewhich('-var TEXMFLOCAL'), - 'tex', - 'latex', - 'webquiz', - 'webquizrc' - ) + TEXMFLOCAL='' + try: + TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFLOCAL') + except subprocess.CalledProcessError: + pass + + if TEXMFLOCAL == '': + TEXMFLOCAL = webquiz_util.kpsewhich('-var-value TEXMFMAIN') + + self.system_rcfile = os.path.join(TEXMFLOCAL, 'tex', 'latex', 'webquiz', 'webquizrc') self.read_webquizrc(self.system_rcfile) # the user rc file defaults to: @@ -378,9 +383,8 @@ class WebQuizSettings: Print the non-default settings for webquiz from the webquizrc ''' if not hasattr(self, 'rcfile'): - print( - 'Please initialise WebQuiz using the command: webquiz --initialise\n' - ) + print(webquiz_templates.initialise_settings) + sys.exit(1) if setting not in ['all', 'verbose', 'help']: setting = setting.replace('-', '_') @@ -440,7 +444,7 @@ class WebQuizSettings: default_root = '/Library/WebServer/Documents/WebQuiz' platform = 'Mac OSX' elif sys.platform.startswith('win'): - default_root = ' c:\inetpub\wwwroot\WebQuiz' + default_root = 'c:\inetpub\wwwroot\WebQuiz' platform = 'Windows' else: default_root = '/var/www/html/WebQuiz' @@ -496,7 +500,7 @@ class WebQuizSettings: # if texdoc failed then try using TEXMFMAIN if webquiz_doc=='': try: - webquiz_doc = os.path.join(webquiz_util.kpsewhich('-var TEXMFMAIN'), 'doc','latex', 'webquiz') + webquiz_doc = os.path.join(webquiz_util.kpsewhich('-var-value TEXMFMAIN'), 'doc','latex', 'webquiz') except subprocess.CalledProcessError: pass @@ -648,7 +652,7 @@ class WebQuizSettings: Undocumented feature - useful for debugging initialisation routine ''' webquiz_top = os.path.abspath(webquiz_util.webquiz_file('..')) - texmf = webquiz_util.kpsewhich('-var TEXMFMAIN') + texmf = webquiz_util.kpsewhich('-var-value TEXMFMAIN') for (src, target) in [('scripts', 'scripts'), ('latex', 'tex/latex'), ('doc', 'doc/latex')]: @@ -665,8 +669,17 @@ class WebQuizSettings: try: # add a link to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - os.symlink(os.path.join(texmf,'scripts','webquiz','webquiz.py'), os.path.join(texbin, 'webquiz')) + texbin = os.path.dirname(shutil.which('pdflatex')) + if sys.platform.startswith('win'): + shutil.copyfile( + os.path.join(texmf,'scripts','webquiz','webquiz.bat'), + os.path.join(texbin, 'webquiz.bat') + ) + else: + os.symlink( + os.path.join(texmf,'scripts','webquiz','webquiz.py'), + os.path.join(texbin, 'webquiz') + ) subprocess.call('mktexlsr', shell=True) except (FileExistsError,FileNotFoundError): @@ -677,8 +690,7 @@ class WebQuizSettings: sys.exit(1) except subprocess.CalledProcessError as err: - print('There was a problem running mktexlsr') - sys.exit(1) + self.webquiz_error('There was a problem running mktexlsr', err) def tex_uninstall(self): r''' @@ -692,7 +704,7 @@ class WebQuizSettings: Undocumented feature - useful for debugging initialisation routine ''' webquiz_top = os.path.abspath(webquiz_util.webquiz_file('..')) - texmf = webquiz_util.kpsewhich('-var TEXMFMAIN') + texmf = webquiz_util.kpsewhich('-var-value TEXMFMAIN') for target in ['scripts', 'tex/latex', 'doc/latex']: try: shutil.rmtree(os.path.join(texmf, target, 'webquiz')) @@ -706,8 +718,11 @@ class WebQuizSettings: try: # remove link from texbin to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - os.remove(os.path.join(texbin, 'webquiz')) + texbin = os.path.dirname(shutil.which('pdflatex')) + if sys.platform.startswith('win'): + os.remove(os.path.join(texbin, 'webquiz.bat')) + else: + os.remove(os.path.join(texbin, 'webquiz')) except (FileExistsError,FileNotFoundError): pass @@ -729,12 +744,16 @@ class WebQuizSettings: sys.exit(1) # remove link to webquiz.py - texbin = os.path.dirname(webquiz_util.shell_command('which pdflatex').split()[-1]) - webquiz = os.path.join(texbin,'webquiz') + texbin = os.path.dirname(shutil.which('pdflatex')) try: - target = os.readlink(webquiz) - if target==os.path.join(texmf,'scripts','webquiz','webquiz.py'): + if sys.platform.startswith('win'): + webquiz = os.path.join(texbin, 'webquiz.bat') os.remove(webquiz) + else: + webquiz = os.path.join(texbin,'webquiz') + target = os.readlink(webquiz) + if target==os.path.join(texmf,'scripts','webquiz','webquiz.py'): + os.remove(webquiz) except (FileExistsError,FileNotFoundError): pass @@ -852,6 +871,7 @@ if __name__ == '__main__': settings_parser.add_argument( '-i', '--initialise', + '--initialize', action='store_true', default=False, help='Install web components of webquiz') @@ -1001,41 +1021,50 @@ if __name__ == '__main__': # - we need to use shell=True because otherwise pst2pdf gives an error # options.talk() is a shorthand for letting the user know what is happening if options.quiet == 0: - options.run = lambda cmd: subprocess.call(cmd, shell=True) + options.run = webquiz_util.run options.talk = lambda msg: print(msg) elif options.quiet == 1: - options.run = lambda cmd: subprocess.call(cmd, shell=True, stdout=open(os.devnull, 'wb')) + options.run = webquiz_util.quiet_run options.talk = lambda msg: print(msg) else: - options.run = lambda cmd: subprocess.call(cmd, shell=True, stdout=open(os.devnull, 'wb'), stderr=open(os.devnull, 'wb')) + options.run = webquiz_util.silent_run options.talk = lambda msg: None # run through the list of quizzes and make them for quiz_file in options.quiz_file: if len(options.quiz_file) > 1 and options.quiet < 3: print('Making web page for {}'.format(quiz_file)) + + quiz_name, ext = os.path.splitext(quiz_file) # extract filename and extension # quiz_file is assumed to be a tex file if no extension is given - if not '.' in quiz_file: - quiz_file += '.tex' + if ext=='': + ext = '.tex' + quiz_file += ext + + # windows likes adding a prefix of '.\\'to filename and this causes havoc with latex + if os.path.dirname(quiz_file)=='.': + quiz_file = os.path.basename(quiz_file) - if not os.path.isfile(quiz_file): - print('WebQuiz error: cannot read file {}'.format(quiz_file)) + if ext not in ['.tex', '.xml']: + webquiz_util.webquiz_error(True, 'unrecognised file extension {}'.format(ext)) - else: + if not os.path.isfile(quiz_file): + webquiz_util.webquiz+error(True, 'WebQuiz error: cannot read file {}'.format(quiz_file)) - # the quiz name and the quiz_file will be if pst2pdf is used - quiz_name = quiz_file - if options.quiet < 2: - print('WebQuiz generating web page for {}'.format(quiz_file)) + # the quiz name and the quiz_file will be different if pst2pdf is used + quiz_name = quiz_file + if options.quiet < 2: + print('WebQuiz generating web page for {}'.format(quiz_file)) - # If the pst2podf option is used then we need to preprocess + options.pst2pdf = False + if ext==".tex": + # If the pst2pdf option is used then we need to preprocess # the latex file BEFORE passing it to MakeWebQuiz. Set # options.pst2pdf = True if pst2pdf is given as an option to # the webquiz documentclass with codecs.open(quiz_file, 'r', encoding='utf8') as q_file: doc = q_file.read() - options.pst2pdf = False try: brac = doc.index(r'\documentclass[') + 15 # start of class options if 'pst2pdf' in [ @@ -1049,46 +1078,46 @@ if __name__ == '__main__': except ValueError: pass - # the file exists and is readable so make the quiz - webquiz_makequiz.MakeWebQuiz(quiz_name, quiz_file, options, settings, metadata) - - quiz_name = quiz_name[:quiz_name.index('.')] # remove the extension - - # move the css file into the directory for the quiz - css_file = os.path.join(quiz_name, quiz_name + '.css') - if os.path.isfile(quiz_name + '.css'): - if os.path.isfile(css_file): - os.remove(css_file) - shutil.move(quiz_name + '.css', css_file) - - # now clean up unless debugging - if not options.debugging: - for ext in ['4ct', '4tc', 'dvi', 'idv', 'lg', 'log', - 'ps', 'pdf', 'tmp', 'xml', 'xref' + # the file exists and is readable so make the quiz + webquiz_makequiz.MakeWebQuiz(quiz_name, quiz_file, options, settings, metadata) + + quiz_name, ext = os.path.splitext(quiz_name) # extract filename and extension + + # move the css file into the directory for the quiz + css_file = os.path.join(quiz_name, quiz_name + '.css') + if os.path.isfile(quiz_name + '.css'): + if os.path.isfile(css_file): + os.remove(css_file) + shutil.move(quiz_name + '.css', css_file) + + # now clean up unless debugging + if not options.debugging: + for ext in ['4ct', '4tc', 'dvi', 'idv', 'lg', 'log', + 'ps', 'pdf', 'tmp', 'xml', 'xref' + ]: + if os.path.isfile(quiz_name + '.' + ext): + os.remove(quiz_name + '.' + ext) + + # files created when using pst2pdf + if options.pst2pdf: + for file in glob.glob(quiz_name + '-pdf.*'): + os.remove(file) + for file in glob.glob(quiz_name + '-pdf-fixed.*'): + os.remove(file) + for extention in ['.preamble', '.plog', '-tmp.tex', + '-pst.tex', '-fig.tex' ]: - if os.path.isfile(quiz_name + '.' + ext): - os.remove(quiz_name + '.' + ext) - - # files created when using pst2pdf - if options.pst2pdf: - for file in glob.glob(quiz_name + '-pdf.*'): - os.remove(file) - for file in glob.glob(quiz_name + '-pdf-fixed.*'): - os.remove(file) - for extention in ['.preamble', '.plog', '-tmp.tex', - '-pst.tex', '-fig.tex' - ]: - if os.path.isfile(quiz_name + extention): - os.remove(quiz_name + extention) - if os.path.isdir(os.path.join(quiz_name, quiz_name)): - shutil.rmtree(os.path.join(quiz_name, quiz_name)) - - if settings.initialise_warning != '': + if os.path.isfile(quiz_name + extention): + os.remove(quiz_name + extention) + if os.path.isdir(os.path.join(quiz_name, quiz_name)): + shutil.rmtree(os.path.join(quiz_name, quiz_name)) + + if settings.initialise_warning != '' and not settings.have_initialised: print(webquiz_templates.text_initialise_warning) except Exception as err: - # there is a small chance that there is an error before we the + # there is a small chance that there is an error before the # settings.debugging flag has been set webquiz_util.webquiz_error(settings.debugging if 'settings' in globals() else True, 'unknown problem.\n\nIf you think this is a bug please report it by creating an issue at\n {}\n' diff --git a/Master/texmf-dist/scripts/webquiz/webquiz_layout.py b/Master/texmf-dist/scripts/webquiz/webquiz_layout.py index 89b5f3d94e4..19130b7afe6 100755 --- a/Master/texmf-dist/scripts/webquiz/webquiz_layout.py +++ b/Master/texmf-dist/scripts/webquiz/webquiz_layout.py @@ -36,8 +36,8 @@ from webquiz_templates import no_script # quiz.unit_code = unit code from \UnitCode # quiz.unit_name = unit name from \UnitName # quiz.unit_url = unit url from \UnitURL -# quiz.webquiz_init = javascript for initialising quiz page. -# This MUST appear towrds the end of HTML body +# quiz.webquiz_init = javascript for initialising quiz page +# MUST appear towards the end of HTML body def write_web_page(quiz): return quiz_page.format( diff --git a/Master/texmf-dist/scripts/webquiz/webquiz_makequiz.py b/Master/texmf-dist/scripts/webquiz/webquiz_makequiz.py index cca12a664f5..5f9e66f61bb 100755 --- a/Master/texmf-dist/scripts/webquiz/webquiz_makequiz.py +++ b/Master/texmf-dist/scripts/webquiz/webquiz_makequiz.py @@ -49,14 +49,14 @@ class MakeWebQuiz(object): self.options = options self.settings = settings self.metadata = metadata - self.quiz_name = quiz_name.split('.')[0] - self.quiz_file, extension = quiz_file.split('.') + self.quiz_file, extension = os.path.splitext(quiz_file) + self.quiz_name = os.path.basename(self.quiz_file) self.webquiz_url = settings['webquiz_url'] - if self.webquiz_url[-1] == '/': + if self.webquiz_url[-1] == '/': self.webquiz_url = self.webquiz_url[:len(self.webquiz_url)-1] # run htlatex only if quiz_file has a .tex extension - if extension == 'tex': + if extension == '.tex': self.htlatex_quiz_file() self.read_xml_file() diff --git a/Master/texmf-dist/scripts/webquiz/webquiz_templates.py b/Master/texmf-dist/scripts/webquiz/webquiz_templates.py index a3c8f849945..ea86df20391 100755 --- a/Master/texmf-dist/scripts/webquiz/webquiz_templates.py +++ b/Master/texmf-dist/scripts/webquiz/webquiz_templates.py @@ -195,12 +195,6 @@ multiple_feedback_correct = r''' ''' multiple_feedback_answer = '
  • {correct_answer} {reason}
  • ' -initialise_invite = r'''WebQuiz needs to be initialised. In order to display quiz web pages -WebQuiz needs to copy some css and javascript files into a directory -that is accessible from your webserver. - -Do you want to initialise WebQuiz now [Y/n]? ''' - # no script error when javascript is not enabled no_script = r'''''' +###################################################################### +# missing webquiz.ini file +###################################################################### + +missing_webquiz_ini = r''' +webquiz installation error: unable to find webquiz.ini -> {} + +If you believe that WebQuiz has been installed correctly then please try +rebuilding the TeX filename database. On TeXLive systems this can be done +using the command mktexlsl, or using the TeXLive gui. On MiKTEX you can +rebuild the database from the Tasks menu on the MiKTeX console. You may +need to run this command using an administrator account or sudo, on unix +systems. + +''' + ###################################################################### # the remaining templates prompt the user when initialising webquiz ###################################################################### +initialise_invite = r'''WebQuiz needs to be initialised. + +Before WebQuiz can display quiz web pages on your system it first needs to +copy some css and javascript files into a directory that is accessible from +your webserver. + +Do you want to initialise WebQuiz now [Y/n]? ''' + +initialise_before_settings = r''' +Before you can view the webquiz settings you need to initialise WebQuiz +using the command: + webquiz --initialise +''' + initialise_introduction = r''' WebQuiz Initialisation ====================== @@ -290,13 +314,6 @@ If you want to change the default webquiz settings please use: webquiz --edit-settings ''' -webquiz_url_warning = r''' -WebQuiz has not been initialised. To remove the warning message from -the web page please use - webquiz --initialise -to install the WebQuiz javascript and css files. -''' - text_initialise_warning = r''' WebQuiz has not yet been initialised. To remove this warning please use webquiz --initialise diff --git a/Master/texmf-dist/scripts/webquiz/webquiz_util.py b/Master/texmf-dist/scripts/webquiz/webquiz_util.py index 7a06108e1b0..ea2e6e7b179 100755 --- a/Master/texmf-dist/scripts/webquiz/webquiz_util.py +++ b/Master/texmf-dist/scripts/webquiz/webquiz_util.py @@ -33,9 +33,11 @@ def shell_command(cmd): def kpsewhich(search): r''' - Short-cut to access kpsewhich output. usage: kpsewhich('-var-value=TEXMFLOCAL') + Short-cut to access kpsewhich output. + + usage: kpsewhich('-var-value=TEXMFLOCAL') ''' - return subprocess.check_output('kpsewhich ' + search, stderr=subprocess.STDOUT, shell=True).decode('ascii').strip() + return subprocess.check_output('kpsewhich ' + search, shell=True).decode('ascii').strip() # --------------------------------------------------------------------------------------- class MetaData(dict): @@ -126,3 +128,34 @@ def copytree(src, dst, symlinks=False, ignore=None): copytree(s, d, symlinks, ignore) else: shutil.copy2(s, d) + +############################################################################### +## shortcuts for running commands +environ = os.environ.copy() + +def run(cmd, shell=False): + r''' + Run commands with output to stdout and errors to stderr + ''' + if shell: + subprocess.call(cmd, env=environ, shell=True) + else: + subprocess.call(cmd.split(), env=environ) + +def quiet_run(cmd, shell=False): + r''' + Run commands with ignoring and sending errors to stderr + ''' + if shell: + subprocess.call(cmd, env=environ, stdout=open(os.devnull, 'wb'), shell=True) + else: + subprocess.call(cmd.split(), env=environ, stdout=open(os.devnull, 'wb')) + +def silent_run(cmd, shell=False): + r''' + Run commands ignoring all output and errors + ''' + if shell: + subprocess.call(cmd, env=environ, stdout=open(os.devnull, 'wb'), stderr=open(os.devnull, 'wb'), shell=True) + else: + subprocess.call(cmd.split(), env=environ, stdout=open(os.devnull, 'wb'), stderr=open(os.devnull, 'wb')) diff --git a/Master/texmf-dist/tex/latex/webquiz/webquiz.cfg b/Master/texmf-dist/tex/latex/webquiz/webquiz.cfg index 0c503fc1c20..571fecd2fa7 100644 --- a/Master/texmf-dist/tex/latex/webquiz/webquiz.cfg +++ b/Master/texmf-dist/tex/latex/webquiz/webquiz.cfg @@ -27,8 +27,8 @@ \Configure{VERSION}{} % Output a WebQuiz doctype instead of the default for HTML5 -\Configure{DOCTYPE}{\HCode{\Hnewline -}} +\Configure{DOCTYPE}{\HCode{\Hnewline +}} \ifWQ@Debugging\def\WQ@debugging{true}\else\def\WQ@debugging{false}\fi diff --git a/Master/texmf-dist/tex/latex/webquiz/webquiz.ini b/Master/texmf-dist/tex/latex/webquiz/webquiz.ini index b5c9c58b717..b4bec751121 100644 --- a/Master/texmf-dist/tex/latex/webquiz/webquiz.ini +++ b/Master/texmf-dist/tex/latex/webquiz/webquiz.ini @@ -11,4 +11,4 @@ release date = 2019/02/08 repository = github.com/AndrewAtLarge/WebQuiz/issues requirements = Python3 and \LaTeX, including \TeX 4ht and make4ht url = www.maths.usyd.edu.au/u/mathas/WebQuiz/doc/webquiz-online-manual.html -version = 5.1 +version = 5.2 -- cgit v1.2.3