numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
207 stars 122 forks source link

Windows local setup can't test run question #695

Closed NewmanJ1987 closed 2 years ago

NewmanJ1987 commented 4 years ago

I followed the instruction from here. https://docs.numbas.org.uk/en/latest/server-installation/windows-local.html

I created a question looks like the questions is created.


    Directory: C:\Users\nthur\Documents\python_workspace\numbas_editor\static\previews\question-1-first-question

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2020-06-07  11:36 AM                resources
-a----       2020-06-07  11:36 AM          13138 index.html
-a----       2020-06-07  11:36 AM           1243 readme.txt
-a----       2020-06-07  11:36 AM        2296720 scripts.js
-a----       2020-06-07  11:36 AM           1531 source.exam
-a----       2020-06-07  11:36 AM         197411 styles.css

But when I try to preview the question I have the following problem, did somebody face this issue before ?

image

NewmanJ1987 commented 4 years ago

Ok I was able to figure it out. If you want to preview the question you need to serve the files that are generated in your PREVIEW_PATH. For me the simplest way to do this was to use he builtin in server that comes with python. These are the steps if anybody faces the same problem, these instruction assume you followed the steps here https://docs.numbas.org.uk/en/latest/server-installation/windows-local.html .

1) Execute this

cd .\static\
python -m http.server 8080

2) Go to you settings.py and modify the field PREVIEW_URL to http://127.0.0.1:8080/previews/.

You should be able to preview your questions after this.

Does it make sense to update the docs with this information ?

christianp commented 4 years ago

The django development server can serve these static files - you shouldn't need to run a separate server. Can you check the STATIC_URL setting in numbas/settings.py, and look at the Django documentation?

NewmanJ1987 commented 4 years ago

The STATIC_URL setting is set to /static/

This is how my configs look like

STATIC_URL = '/static/'
STATIC_ROOT = 'static/'
... 

GLOBAL_SETTINGS = {
    'NUMBAS_PATH': '../numbas_runtime',
    'PREVIEW_PATH': 'static/previews',
    'PREVIEW_URL': 'http://127.0.0.1:8080/previews/',  
christianp commented 2 years ago

There are some new instructions on setting up a development environment at https://docs.numbas.org.uk/en/latest/development/installation.html. The first_setup script now sets more of the settings for you when you choose development mode, and we tested with a couple of Windows machines.