A tool to bridge the gap between a CodeRunner quiz attempt and your IDE
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
CodeRunner is a hobby project to simplify the workflow of attemping a Moodle quiz that has CodeRunner questions. This project started as a way to reduce repetitive & error-prone tasks like manual copying and pasting code between IDEs and Web Browsers .
By using a MoodleSession cookie CodeSubmitter fetches a user token and uses the Moodle webservice API to replicate the flow of a browser based attempt inside your IDE. Users can automatically fetch questions for in-progress attemps, generate necessary setup code and automate submission & testing.
The project is developed as a learning experience for rust. It is intended to be used as a productivty tool and adheres to the permissions and functionally that is availably to a user in a standard browser.
This is how to build the CodeSubmitter CLI tool from source. (Alternatively, you can download the latest build from the workflow artifacts)
This is the list of required packages to build the project from source.
- Rust Toolchain (cargo, rustc)
- Git
Linux:
sudo apt update
sudo apt install -y build-essential curl git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shMac:
xcode-select --install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shWindows:
winget install --id Rustlang.Rustup- Clone the repo
git clone https://github.com/maxtyson123/CodeSubmitter.git
cd CodeSubmitter- Build the project in release mode
cargo build --release- Install the project
cargo install --path . CodeSubmitter is an independent tool developed for educational and productivity purposes. It is not affiliated with, endorsed by, or officially supported by Moodle™ or the CodeRunner project.
Users should be aware that:
- Terms of Service: Use of this tool is subject to the terms and conditions of your specific educational institution and their respective Moodle/CodeRunner implementation.
- Automated Interaction: By using this tool, you are interacting with Moodle web services via your own credentials. Ensure that you adhere to your institution's academic integrity policies and acceptable use guidelines.
- Testing: Submissions may count toward your total attempt limits or incur penalties if tests fail. Always verify the rules of your specific quiz before making submissions.
Using the above steps a CLI tool should be installed onto your systems path under: code_submitter. Simply run this command
in the directory where your question attempt exists and select the relevant course/quiz/attempt. The program expects a file
named {question_numer}.{ext} to exist,
and to contain your attempt, it will be created for you with the necessary setup and question information.
Please Note: Your own manual testing may interfere with automated testing both on CodeSubmitter and CodeRunner so make sure to remove that before you submit
On your first run you are promoted to enter some configuration options. This is persited at $HOME/.code_submitter/config.json
The options you are promted are explained below:
Should the quiz resume at the last known question for that attempt?
When a quiz is selected, the program remembers the last known question submmited for that attempt. If true and if
no question number is given it will automatically select the persisted.
Pick the first unfinished attempt if it exists?
When a quiz is first selected the program downloads all the attempts. If true and if
no attempt number is given it will automatically select the first attempt that is not marked as complete.
Load attempt at furthest completed question (if last unknown)?
When an attempt is first selected the program downloads all the questions. If true and if
no question number is given it will automatically select the first question that does not have a grade. Note, this means
an incorrect attempt that has partial marks may be skipped.
Load next question once current passes ALL tests?
A question must exist in its own file. If true and if the current question passes the submission tests, the program will
parse the next uncompleted question and create a new file for you.
Ask before submitting code?
Tests are ran sequentially and automatically. If true and if the current question passes the precheck tests, the program
will stop and prompt the user before starting submissions tests. Note: submission tests can incur a pentaly if they fail,
please check with your quiz first.
The program will ask for information to select the attempt by default, but this can be skipped or automated by passing the args below:
--course {number}
The Moodle course ID (note: different to number in selector menu)
--quiz {number}
The Moodle quiz ID (note: different to number in selector menu)
--attempt {number}
The Moodle attempt ID (note: different to number in selector menu)
--question {number}
The question number
--course_code {str}
The course shorcode, will match to the first course display name that contains this string (ie: OSDV101)
--week_number {number}
The week this quiz is done on. First time will prompt for a mapping to a quiz, which is then persisted for subsequent runs.
(This is week number per course)
--print
Will print the selected question and relevant information instead of interacting with code/server.
The main idea of the tool is to have it used as part of your IDE instead of manually entering each attempt each time or running a CLI tool. Below are the setups for various IDEs.
This plugin is for neovim and other simmilar IDEs.
Installation
- Coping the lua file
./plugins/nvim/submitter.luato your nvim config folder. - Reload nvim
Usage
- Create a root directory for your courses & open it
- Create a subdirectory with the course short code
- Create a subdirectory under that course code name
Week {number} - Create a empty file
{question_number}.{ext}, open it - Press
<leader>sf(s = submit, f = file) to load the question - Solve problem
- Press
<leader>sfto test/sumit
Please feel free to create a plugin for your IDE and add instructs here via a PR.
- Get access token
- Pull site info
- Pull courses
- Pull quizes for a given course
- Pull attempts for a given quiz
- Pull questions for a given attempt
- Rate limit and cache server requests
- Parse question text
- Parse question code
- Parse question examples tests
- Read user code
- Test user code with examples
- Submit/Precheck user code
- Parse Submit/Precheck test results
- Python code driver
- Print grade for submission
- Strip user manual testing code
- Persist know hidden (submission) tests that have been show from wrong attemp and locally test agaisnt them
- ItellJ plugin
- VSCode plugin
- Register link handler to grab token
- Token lifetime checking
- Alt server backend to use php calls as fall back for no WS
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you are wondering where to start have a look at the TODOs.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the BSD 3-Clause License. See LICENSE for more information.
