Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 5d3ffab

Browse files
committed
Merge branch 'master' of github.com:RunestoneInteractive/RunestoneServer
2 parents b9d9e19 + b0b25ae commit 5d3ffab

File tree

10 files changed

+183
-1354
lines changed

10 files changed

+183
-1354
lines changed

controllers/ajax.py

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
# Local application imports
6262
# -------------------------
63-
from feedback import is_server_feedback, fitb_feedback, lp_feedback
63+
from feedback import is_server_feedback, fitb_feedback
6464
from rs_practice import _get_qualified_questions
6565

6666
logger = logging.getLogger(settings.logger)
@@ -341,40 +341,6 @@ def hsblog():
341341
percent=pct,
342342
)
343343

344-
elif event == "lp_build" and auth.user:
345-
ret, new_fields = db.lp_answers._validate_fields(
346-
dict(sid=sid, timestamp=ts, div_id=div_id, course_name=course)
347-
)
348-
if not ret.errors:
349-
do_server_feedback, feedback = is_server_feedback(div_id, course)
350-
if do_server_feedback:
351-
try:
352-
code_snippets = json.loads(request.vars.answer)["code_snippets"]
353-
except Exception:
354-
code_snippets = []
355-
result = lp_feedback(code_snippets, feedback)
356-
# If an error occurred or we're not testing, pass the answer through.
357-
res.update(result)
358-
359-
# Record the results in the database.
360-
correct = result.get("correct")
361-
answer = result.get("answer", {})
362-
answer["code_snippets"] = code_snippets
363-
ret = db.lp_answers.validate_and_insert(
364-
sid=sid,
365-
timestamp=ts,
366-
div_id=div_id,
367-
answer=json.dumps(answer),
368-
correct=correct,
369-
course_name=course,
370-
)
371-
if ret.errors:
372-
res.setdefault("errors", []).append(ret.errors.as_dict())
373-
else:
374-
res["errors"] = ["No feedback provided."]
375-
else:
376-
res.setdefault("errors", []).append(ret.errors.as_dict())
377-
378344
response.headers["content-type"] = "application/json"
379345
if setCookie:
380346
response.cookies["ipuser"] = sid
@@ -1405,28 +1371,6 @@ def getAssessResults():
14051371
res["comment"] = srow.comment
14061372

14071373
return json.dumps(res)
1408-
elif event == "lp_build":
1409-
rows = (
1410-
db(
1411-
(db.lp_answers.div_id == div_id)
1412-
& (db.lp_answers.course_name == course)
1413-
& (db.lp_answers.sid == sid)
1414-
)
1415-
.select(
1416-
db.lp_answers.answer,
1417-
db.lp_answers.timestamp,
1418-
db.lp_answers.correct,
1419-
orderby=~db.lp_answers.id,
1420-
)
1421-
.first()
1422-
)
1423-
if not rows:
1424-
return "" # server doesn't have it so we load from local storage instead
1425-
answer = json.loads(rows.answer)
1426-
correct = rows.correct
1427-
return json.dumps(
1428-
{"answer": answer, "timestamp": str(rows.timestamp), "correct": correct}
1429-
)
14301374

14311375

14321376
def tookTimedAssessment():

docker/README.rst

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Docker Deployment
33

44
.. TODO
55
6-
Docs to update:
6+
Is there some way to simplify these instructions? It's still a long, error-prone process! Do we need another setup script that follows these directions and prompts the user for input (do you want to run the server or do development? What is your github userid? Etc.)? Such a script would be able to take care of the first 7 steps, which would be good progress. But, we'd need os-dependent stuff for the first bits (install WSL/Ubuntu on Windows); can we assume Python 3 on Mac?
77
88
Enable the script to download and install the Docker Desktop if necessary.
99
@@ -60,6 +60,8 @@ If running on OS X, install then run the `Docker Desktop <https://www.docker.com
6060

6161
Expect to wait a few minutes the first time you start the Docker Desktop. Don't proceed until the Docker Desktop's initialization is complete.
6262

63+
Next, `install Python 3 <https://docs.python-guide.org/starting/install3/osx/>`_.
64+
6365
Windows
6466
^^^^^^^
6567
If running on Windows, either:
@@ -89,15 +91,55 @@ Next, install ``curl`` by opening an Ubuntu terminal then typing:
8991
9092
sudo apt-get install -y curl
9193
92-
2. Run the bootstrap script
93-
***************************
94+
2. Download the bootstrap script
95+
********************************
96+
To keep your filesystem tidy, create a directory before running the following commands, since these commands download several scripts and subdirectories. To do this:
97+
98+
.. code-block:: bash
99+
100+
mkdir rsdocker
101+
cd rsdocker
102+
103+
.. note::
104+
105+
On OS X, avoid placing your files in the Documents folder, since security features introduced in OS X 12.4 require you to give Docker `additional permissions <https://support.apple.com/guide/mac-help/control-access-to-files-and-folders-on-mac-mchld5a35146/mac>`_.
106+
94107
Next, download the bootstrap script. To do this, open a terminal in Ubuntu or OS X then type:
95108

96109
.. code-block:: bash
97110
98111
curl -fLO https://raw.githubusercontent.com/RunestoneInteractive/RunestoneServer/master/docker/docker_tools.py
99112
100-
This download the bootstrap script. The next step, which installs required dependencies for the remainder of the process, depends on the two mutually exclusive use cases below. **Remember which use case you select**; many of the following steps vary based on your use case.
113+
This downloads the bootstrap script.
114+
115+
116+
3. Create then activate a Python virtual environment
117+
****************************************************
118+
A Python virtual environment ensures that all the Python dependencies installed by this process don't interfere with your global / system Python installation.
119+
120+
#. `Create a Python virtual environment <https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment>`_ named ``rsvenv`` (RuneStone Virtual ENVironment):
121+
122+
.. code-block:: bash
123+
124+
python3 -m venv rsvenv
125+
126+
#. `Activate the virtual environment <https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#activating-a-virtual-environment>`_ you just created.
127+
128+
On Windows:
129+
130+
.. code-block:: bash
131+
132+
rsvenv\Scripts\activate
133+
134+
On Linux and OS X:
135+
136+
.. code-block:: bash
137+
138+
. rsvenv/bin/activate
139+
140+
4. Run the bootstrap script
141+
***************************
142+
The next step, which installs required dependencies for the remainder of the process, depends on the two mutually exclusive use cases below. **Remember which use case you select**; many of the following steps vary based on your use case.
101143

102144
Use case: running the server
103145
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -109,11 +151,11 @@ For the use case of running the server, execute:
109151
110152
**OR**
111153

112-
Use case: change the way Runestone works or change/add to the way `interactive exercises <https://pretextbook.org/doc/guide/html/topic-interactive-exercises.html>`_ behave
154+
Use case: in addition to running the server, change the way Runestone works or change/add to the way `interactive exercises <https://pretextbook.org/doc/guide/html/topic-interactive-exercises.html>`_ behave
113155
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114156
For the developer use case:
115157

116-
#. `Fork <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_ the `RunestoneServer <https://github.com/RunestoneInteractive/RunestoneServer.git>`_, `RunestoneComponents <https://github.com/RunestoneInteractive/RunestoneComponents.git>`_, and `BookServer <https://github.com/RunestoneInteractive/BookServer.git>`_ repositories.
158+
#. `Fork <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_ the `RunestoneServer <https://github.com/RunestoneInteractive/RunestoneServer.git>`_, `RunestoneComponents <https://github.com/RunestoneInteractive/RunestoneComponents.git>`_, and `BookServer <https://github.com/RunestoneInteractive/BookServer.git>`_ repositories. If you've already forked these repositories, `fetch the latest updates from these upstream repositories <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork>`_.
117159

118160
#. In the terminal, run:
119161

@@ -125,7 +167,7 @@ For the developer use case:
125167

126168
On Windows using Ubuntu under WSL2: if you see the error message "Docker Desktop not detected..." but you are running the Docker Desktop, then click the gear (settings) icon in Docker Desktop, select Resources then WSL Integration, and make sure the switch next to Ubuntu is turned on.
127169

128-
3. Build the necessary containers
170+
5. Build the necessary containers
129171
*********************************
130172
In the terminal, type:
131173

@@ -141,10 +183,6 @@ The next command depends on the use case you chose in the previous step.
141183

142184
Pre-build
143185
^^^^^^^^^
144-
.. warning::
145-
146-
On OS X, use ``python3 -m docker_tools`` instead of ``docker-tools`` in the following instructions. Likewise, use ``python3 -m rsmanage`` instead of ``rsmanage``.
147-
148186
For the use case of running the server, execute:
149187

150188
.. code-block:: bash
@@ -169,9 +207,11 @@ The build will take a **long** time (5-10 minutes in many cases). When this comp
169207

170208
#. **Reboot your computer** to update your group membership.
171209
#. Run the Docker Desktop if using WSL on Windows or using OS X.
172-
#. Open a terminal then ``cd RunestoneServer``.
210+
#. Open a terminal then ``cd rsvenv``.
211+
#. Activate your virtual environment -- see the second step of `create a virtual environment <Create then activate a Python virtual environment>`_.
212+
#. ``cd RunestoneServer``.
173213

174-
4. Configuration
214+
6. Configuration
175215
***********************
176216

177217
Most basic configuration can be done via two files you will need to create. These files
@@ -201,7 +241,7 @@ For the use case of running the server, you will need to modify these settings t
201241
You will NOT want to check either ``.env`` or ``models/1.py`` into source control, since these contain passwords. The ``.gitignore`` file is set to ignore both of them.
202242

203243

204-
5. Starting the containerized application
244+
7. Starting the containerized application
205245
*****************************************
206246

207247
Pre-start
@@ -229,7 +269,7 @@ For the developer use case, execute:
229269

230270
Post-start
231271
^^^^^^^^^^
232-
The first time you run the command will take a **lot** longer as it downloads containers then installs software into the various containers. You may ignore a red message about the Jobe container. After it is complete, you can go to http://localhost/ to see the application (if you configured a hostname, substitute it for localhost). If everything so far is set up correctly, you should see a welcome/login page. Continue in the instructions to add book(s), course(s) and a user account.
272+
The first time you run the command will take a **lot** longer as it downloads containers then installs software into the various containers. You may ignore the red message ``jobe error`` that appears during this process. After it is complete, you can go to http://localhost/ to see the application (if you configured a hostname, substitute it for localhost). If everything so far is set up correctly, you should see a welcome/login page. Continue in the instructions to add book(s), course(s) and a user account.
233273

234274
Introducing ``rsmanage``
235275
^^^^^^^^^^^^^^^^^^^^^^^^
@@ -244,7 +284,7 @@ The ``rsmanage`` command will run many useful commands inside the container for
244284
...and many other things. Just type ``rsmanage`` for a list of things it can do. For a list of options just type ``rsmanage`` and the subcommand you want followed by ``--help``; for example, ``rsmanage build --help``.
245285

246286

247-
6. Add books
287+
8. Add books
248288
**************************
249289

250290
No books are installed by default; you must add books using the following process. To add a book, you need to add its source code to the ``RunestoneServer/books/`` directory. Typically, that means cloning its source code. For example, to add
@@ -278,7 +318,7 @@ The following information applies only *authoring* books using the Runestone.
278318
If you are running docker on a remote host then make sure to set it to the name of the remote host.
279319

280320

281-
7. Add courses
321+
9. Add courses
282322
**************************
283323

284324
To add a course based on a book, run the ``rsmanage addcourse`` script. If you run it just like
@@ -311,7 +351,7 @@ You do not have to restart the server to make use of the course.
311351
a course with a name like ``thinkcspy`` you will be told that the course name is the same as the book.
312352

313353

314-
8. Add a user
354+
10. Add a user
315355
**************************
316356

317357
To add an initial instructor account to the course you have created, you can either create a new user or add
@@ -338,7 +378,7 @@ Once you have logged in as an instructor, you can bulk add students through the
338378
It is also possible to use a csv file to add multiple instructors or students as you start
339379
up the server. However, this process is brittle (any error loading the information results
340380
in the server entering a restart loop as it fails to load). To do so, make a file named either
341-
`instructors.csv` or `students.csv` in a folder called `configs` in the RunestoneServer folder.
381+
`instructors.csv` or `students.csv` in a folder called `configs` in the ``RunestoneServer/`` folder.
342382
The format of the csv files is to have one person per line with the format of each line as follows:
343383

344384
username,email,first_name,last_name,pw,course
@@ -351,6 +391,12 @@ Operation
351391
---------
352392
The containerized application is configured to automatically start as soon as Docker / the Docker Desktop is started. Therefore, on OS X or Windows (when using WSL2): after a reboot or after manually shutting down the Docker Desktop, **remember to start the Docker Desktop application**.
353393

394+
Before using ``docker-tools`` or ``rsmanage``:
395+
396+
#. Open a terminal then ``cd rsdocker``.
397+
#. Activate your virtual environment -- see the second step of `create a virtual environment <Create then activate a Python virtual environment>`_.
398+
#. ``cd RunestoneServer``.
399+
354400

355401
Other Tips & Tricks
356402
-------------------------------
@@ -381,14 +427,13 @@ Shelling Inside
381427
**********************************
382428

383429
You can shell into the container to look around, or otherwise test. When you enter,
384-
you'll be in the web2py folder, where runestone is an application under applications. From
385-
the RunestoneServer directory do:
430+
you'll be in the web2py folder, where ``runestone/`` is an application under ``applications/``. From the ``RunestoneServer/`` directory do:
386431

387432
.. code-block:: bash
388433
389434
docker-tools shell
390435
391-
Remember that the folder under web2py applications/runestone is bound to your host,
436+
Remember that the folder under ``web2py/applications/runestone`` is bound to your host,
392437
so **do not edit files from inside the container** otherwise they will have a change
393438
in permissions on the host.
394439

0 commit comments

Comments
 (0)