Skip to content

Commit

Permalink
Merge branch 'master' into chore/external-grader-local-async-await
Browse files Browse the repository at this point in the history
  • Loading branch information
nwalters512 committed Feb 8, 2022
2 parents e2cdbe1 + 345085a commit 64e7a51
Show file tree
Hide file tree
Showing 444 changed files with 11,214 additions and 3,675 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
!.editorconfig
!.eslintignore
!.eslintrc.js
!.htmlhintrc
!.prettierignore
!.prettierrc.json
!tsconfig.json
!pyrightconfig.json
!admin_queries/
!api/
!cron/
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
},
extends: ['eslint:recommended', 'plugin:import/recommended', 'prettier'],
parserOptions: {
ecmaVersion: 12,
ecmaVersion: 13,
},
rules: {
curly: ['error', 'multi-line', 'consistent'],
Expand Down
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Recommended way to use this file:
# git config blame.ignoreRevsFile .git-blame-ignore-revs
# See https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame

# Format all files with Prettier
2f3b359987bebf00d45a8c32d58e3b302d117c4a
5 changes: 5 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ jobs:
create-file-commit-message: Create signatures.json
signed-commit-message: '$contributorName signed the CLA in https://github.com/PrairieLearn/PrairieLearn/pull/$pullRequestNo'
custom-notsigned-prcomment: 'Thanks for your contribution! Like many open source projects, we ask that you sign our [Contributor License Agreement](https://github.com/PrairieLearn/cla/blob/main/CLA.md) before we can accept your contribution. You can sign the CLA by posting a comment with the below format:<br/>'
# We're willing to accept the risk of someone editing or deleting
# their comment after merging a PR. With locking enabled, it becomes
# impossible to link to the PR or add any additional comments that
# might be helpful to leave as breadcrumbs.
lock-pullrequest-aftermerge: false
14 changes: 13 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ jobs:
- uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- name: Set up QEMU
uses: docker/setup-qemu-action@v1 # https://github.com/marketplace/actions/docker-setup-qemu
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1 # https://github.com/marketplace/actions/docker-setup-buildx
- name: Build the plbase docker image if needed
run: sh ./tools/build-image-if-needed.sh images/plbase prairielearn/plbase
- name: Build the grader-c docker image if needed
Expand All @@ -31,10 +35,18 @@ jobs:
run: sh ./tools/build-image-if-needed.sh workspaces/xtermjs prairielearn/workspace-xtermjs
- name: Build the testing docker image
run: docker build -t pltest .
- name: Create a temporary directory for host files
run: mkdir -p /tmp/prairielearn
- name: Start the container
run: docker run -td --name=test_container pltest /bin/bash
# We have tests for external grading code, which relies on the Docker
# socket being available, as well as a specific volume mount and
# environment variable. See the docs for more details:
# https://prairielearn.readthedocs.io/en/latest/externalGrading/#running-locally-for-development
run: docker run -td -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/prairielearn:/jobs -e HOST_JOBS_DIR=/tmp/prairielearn --name=test_container pltest /bin/bash
- name: Run the JavaScript linter
run: docker exec test_container /PrairieLearn/docker/lint_js.sh
- name: Run the HTML linter
run: docker exec test_container /PrairieLearn/docker/lint_html.sh
- name: Run the Python linter
run: docker exec test_container /PrairieLearn/docker/lint_python.sh
- name: Run the JavaScript typechecker
Expand Down
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ docker-compose.override.yml
## Backup files

### vi
**/*.swp
**/*.swp
**/*.swo
**/*~

### emacs
**/[#]*[#]

### jupyter
.ipynb_checkpoints

## File explorers
**/.DS_Store # OSX Finder

Expand All @@ -42,7 +45,7 @@ node_modules
## Generated HTML

### mkdocs
/site/
/site/

### jsdoc
/docs/code-docs/
Expand Down
9 changes: 9 additions & 0 deletions .htmlhintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// Question files don't need to have a doctype declaration
"doctype-first": false,
"attr-lowercase": true,
"attr-no-duplication": true,
"attr-no-unnecessary-whitespace": true,
"space-tab-mixed-disabled": "space",
"tag-pair": true
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
coverage/

# The `public/localscripts/calculationQuestion` directory unfortunately
# contains a mixture of first-party and vendored third-party scripts. We want
Expand Down
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,21 @@ test-grader-host:
test-nocoverage: start-support
@mocha tests/index.js
test-python:
@python3 question-servers/freeformPythonLib/prairielearn_test.py
@python3 elements/pl-order-blocks/dag_checker_test.py

lint: lint-js lint-python
# `pl_unit_test.py` has an unfortunate file name - it matches the pattern that
# pytest uses to discover tests, but it isn't actually a test file itself. We
# explicitly exclude it here.
@python3 -m pytest --ignore graders/python/python_autograder/pl_unit_test.py

lint: lint-js lint-python lint-html lint-links
lint-js:
@eslint --ext js "**/*.js"
@prettier --check "**/*.{js,ts,md}"
lint-python:
@python3 -m flake8 ./
lint-html:
@htmlhint "testCourse/**/question.html" "exampleCourse/**/question.html"
lint-links:
@node tools/validate-links.mjs

format: format-js
format-js:
Expand All @@ -48,7 +54,7 @@ typecheck: typecheck-js typecheck-python
typecheck-js:
@tsc
typecheck-python:
@pyright elements/pl-order-blocks/dag*.py # TODO enable for all Python
@pyright

depcheck:
-depcheck --ignore-patterns=public/**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

PrairieLearn is an online problem-driven learning system for creating homeworks and tests. It allows questions to be written using arbitrary HTML/JavaScript, thus enabling very powerful questions that can randomize and autograde themselves, and can access client- and server-side libraries to handle tasks such as graphical drawing, symbolic algebra, and student code compilation and execution.

[![Latest version](https://img.shields.io/github/tag/PrairieLearn/PrairieLearn.svg?label=version)](https://github.com/PrairieLearn/PrairieLearn/blob/master/ChangeLog.md) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=PrairieLearn/PrairieLearn)](https://dependabot.com) [![Docker build status](https://img.shields.io/docker/automated/prairielearn/prairielearn.svg)](https://hub.docker.com/r/prairielearn/prairielearn/builds/) [![Build Status](https://img.shields.io/travis/PrairieLearn/PrairieLearn/master.svg)](https://travis-ci.org/PrairieLearn/PrairieLearn) [![Coverage Status](https://coveralls.io/repos/github/PrairieLearn/PrairieLearn/badge.svg?branch=master)](https://coveralls.io/github/PrairieLearn/PrairieLearn?branch=master) [![License](https://img.shields.io/github/license/PrairieLearn/PrairieLearn.svg)](https://github.com/PrairieLearn/PrairieLearn/blob/master/LICENSE.md)
[![Latest version](https://img.shields.io/github/tag/PrairieLearn/PrairieLearn.svg?label=version)](https://github.com/PrairieLearn/PrairieLearn/blob/master/ChangeLog.md) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=PrairieLearn/PrairieLearn)](https://dependabot.com) [![Docker build status](https://img.shields.io/docker/automated/prairielearn/prairielearn.svg)](https://hub.docker.com/r/prairielearn/prairielearn/builds/) [![Build Status](https://img.shields.io/travis/PrairieLearn/PrairieLearn/master.svg)](https://travis-ci.org/PrairieLearn/PrairieLearn) [![Coverage Status](https://coveralls.io/repos/github/PrairieLearn/PrairieLearn/badge.svg?branch=master)](https://coveralls.io/github/PrairieLearn/PrairieLearn?branch=master) [![License](https://img.shields.io/github/license/PrairieLearn/PrairieLearn.svg)](https://github.com/PrairieLearn/PrairieLearn/blob/master/LICENSE)

Documentation website: [http://prairielearn.readthedocs.io/](http://prairielearn.readthedocs.io/)
23 changes: 23 additions & 0 deletions api/v1/endpoints/courseInstanceInfo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const ERR = require('async-stacktrace');
const path = require('path');
const express = require('express');
const router = express.Router({
mergeParams: true,
});

const sqldb = require('../../../../prairielib/lib/sql-db');
const sqlLoader = require('../../../../prairielib/lib/sql-loader');

const sql = sqlLoader.load(path.join(__dirname, '..', 'queries.sql'));

router.get('/', (req, res, next) => {
const params = {
course_instance_id: res.locals.course_instance.id,
};
sqldb.queryOneRow(sql.select_course_instance_info, params, (err, result) => {
if (ERR(err, next)) return;
res.status(200).send(result.rows[0].item);
});
});

module.exports = router;
23 changes: 23 additions & 0 deletions api/v1/endpoints/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,29 @@ SELECT
FROM
object_data;

-- BLOCK select_course_instance_info
WITH object_data AS (
SELECT
ci.id AS course_instance_id,
ci.long_name AS course_instance_long_name,
ci.short_name AS course_instance_short_name,
ci.course_id AS course_instance_course_id,
ci.display_timezone,
format_date_iso8601(ci.deleted_at, ci.display_timezone) AS deleted_at,
ci.hide_in_enroll_page,
pl_c.title AS course_title,
pl_c.short_name AS course_short_name
FROM
course_instances AS ci
JOIN pl_courses AS pl_c ON (pl_c.id = ci.course_id)
WHERE
ci.id = $course_instance_id
)
SELECT
to_jsonb(object_data) AS item
FROM
object_data;

-- BLOCK select_course_instance_access_rules
WITH object_data AS (
SELECT
Expand Down
1 change: 1 addition & 0 deletions api/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ router.use(require('./prettyPrintJson'));
router.use('/course_instances/:course_instance_id', [
require('../../middlewares/authzCourseOrInstance'),
require('../../middlewares/authzHasCoursePreviewOrInstanceView'),
require('./endpoints/courseInstanceInfo'),
]);

// ROUTES
Expand Down
3 changes: 3 additions & 0 deletions docker/lint_html.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

make -s -C /PrairieLearn lint-html
5 changes: 5 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ at port 3000, the API is accessible via http://localhost:3000/pl/api/v1/.
In the endpoint list below, path components starting with a colon like
`:course_instance_id` should be replaced with the integer IDs.

- **Course instance info:**

- `/pl/api/v1/course_instances/:course_instance_id`
- Information about the course instance.

- **Gradebook:**

- `/pl/api/v1/course_instances/:course_instance_id/gradebook`
Expand Down
10 changes: 9 additions & 1 deletion docs/assessment.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,15 @@ By default, an assessment is only accessible to course staff. To allow students

## Adding text and links to assessments

See the [`clientFiles` and `serverFiles`](clientServerFiles.md) page for details, and [`exam1` in the example course](https://github.com/PrairieLearn/PrairieLearn/blob/master/exampleCourse/courseInstances/Sp15/assessments/exam1/) for an example.
You can add a `text` property to your `infoAssessment.json`, which can be used to provide additional instructions, formula sheets, etc. You can use EJS syntax to access `clientFilesCourse`, `clientFilesCourseInstance`, and `clientFilesAssessment`.

```json
{
"text": "<a href=\"<%= clientFilesAssessment %>/formulas.pdf\">Formula sheet</a>"
}
```

See the [`clientFiles` and `serverFiles`](clientServerFiles.md) page for details about making files available to users.

## Student-attached files

Expand Down
Loading

0 comments on commit 64e7a51

Please sign in to comment.