diff --git a/README.md b/README.md index d5059be8..7dc59b27 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ Autograder for [BYU CS 240 Chess project](https://github.com/softwareconstruction240/softwareconstruction/blob/main/chess/chess.md#readme) +## Development and Contributing + +This project relies on TAs like you to maintain and adapt the program! Come join the team! +Check out the [Contribution Guide](https://github.com/orgs/softwareconstruction240/projects/1/views/1?pane=issue&itemId=84732654&issue=softwareconstruction240%7Cautograder%7C448) to learn how to effectively contribute as a part of the Autograder Development Team! + +Read the [Getting Started Guide](docs/getting-started/getting-started.md) to get the project set up on your machine for development. + ## Important folders ``` @@ -41,267 +48,6 @@ docker compose --profile with-db up -d docker compose up -d ``` -Note, if you are using the docker MySQL database, ensure that in `src/main/resources/db.properties` the -property `db.url` is set to `db:3306` - -## Development - -### Pre-requisites - -##### Dev Container (recommended for Windows) - -You can run all of IntelliJ inside a docker container, which would allow debugging the code on Windows -machines. This requires having docker installed and running on your machine. -To do this, navigate to `.devcontainer/devcontainer.json` in IntelliJ. There should be an icon that pops up next to -the opening curly brace. Click the icon, then select `Create Dev Container and Clone Sources...`. This should pop up -a dialog box that allows you to change a few options about the container. Look through them and change what you need, -then hit the `Build Container and Continue` button. Wait for IntelliJ and Docker to build everything. You may need to -click a few buttons along the way. Eventually a new IntelliJ window will pop up from the dev container. Follow the -[Yarn](#nodeyarn) instructions and [Getting Started](#getting-started) steps below with the new window. -Use `host.docker.internal` as your db-host argument. - -To reopen the container after you've closed it, navigate to the `.devcontainer/devcontainer.json` file again, -click the icon, and select `Show Dev Containers`. Select the container and it should reopen the second IntelliJ. -If nothing appears, make sure the docker engine is running (perhaps by opening Docker Desktop). - -##### Other Notes for Windows Development - -The autograder unfortunately won't work directly from Windows, so you must use Docker or WSL for your database. - -If you run the autograder from WSL, you can use your normal Windows MySQL for the database. (Or you can install MySQL -for Linux from within WSL, but having both Windows and Linux MySQL servers can cause weird issues.) You can't simply -use `localhost` as the database hostname, however, since that refers to the WSL instance. Running `echo $(hostname)` -from a WSL terminal will tell you what your computer's host name is (ex. `LAPTOP-ABC123`). Appending `.local` to that ( -ex. `LAPTOP-ABC123.local`) gives you the hostname that WSL uses to refer to the Windows machine. Use this as -the `--db-host` program argument. - -By default, MySQL users have "Limit to Host Matching" set to `localhost`, which does not allow requests coming from the -WSL virtual machine. In MySQL Workbench, you will have to expand this. The easiest way is to change it to `%`, which allows all hostnames (but it is -highly recommended that you do only do this for a new user with restricted privileges rather than using root). Another option is to -use `wsl hostname -I` to determine the WSL instance's IP address and use that, but this IP may change whenever WSL restarts. - -#### Node/Yarn - -The frontend is built using Vue.js. To run the frontend, you will need to have `yarn`. -After installing `Node`, run the following to enable `yarn` globally: - -```bash -corepack enable -``` - -note: `sudo` may be required - -(see [installing `yarn`](https://yarnpkg.com/getting-started/install)) - -#### Backend - -The backend of the app can be run with either `maven`, or by running your own MySQL server. - -##### Maven - -Go fish🐟 These instructions are not included in this file. - -#### Database - -You can run the database inside a Docker container, or locally with your own MySQL server. - -##### Docker MySQL Server - -Run the following in the root of the project to start the db container: - -```bash -docker compose up db -d -``` - -##### Manual MySQL Server - -Go fish🐟 These instructions are not included in this file. - -### Getting Started - -NOTE: These instructions will help you set up this project in IntelliJ. -If there are any holes or gaps in the instructions, please submit a new pull request -to preserve the learned knowledge for future generations. - -1. Clone the repo onto your local machine. -2. Ensure that you are using the latest version of JVM. The system currently requires version 21+. -3. Use `yarn` to install all dependencies. This must be done from the _front end_ root folder. (If using WSL, run this - from an actual WSL terminal. Windows-based shells, even POSIX ones, won't install the correct files.) - ```bash - cd src/main/resources/frontend - yarn - ``` -4. Setup "Server" _Run Configuration_ - - Navigate to the server file: `src/main/java/edu/byu/cs/server/Server.java` - - Click the "Run" button to run `Server.main()` - - This will give you a _Run Configuration_ that you can modify in the following steps. -5. Set up [program arguments](#program-arguments) - - Reference the [subtitle below](#program-arguments) for the list of required arguments - - Prepare the values you will use for each argument - - Put them all onto a single line, with each argument name followed by its value - - Ex. `--arg-1 arg1Val --arg-2 arg2Val` - - Edit the "Server" run configuration - - Paste in the single line of parameters to the line titled "Program arguments" - - Save & apply the changes -6. **Run the Autograder Locally** - - Run your "Server" run configuration - - Run the frontend by referencing the code below. In the case you are running on the - Autograder inside a dev container, you may need to add the `--host` option at the - end of the `yarn dev` command (`yarn dev --host`). - ```bash - cd src/main/resources/frontend - yarn dev - ``` - - Load the configuration related tables by referencing the [section below](#loading-the-configuration-related-tables) - -#### Program Arguments - -For both deployment and development, the following program arguments are required to be set. Some typical -values for development are provided; notice that the URLs all reference localhost, but the port numbers have -been filled in with default values. Update these as needed to match your environment. - -``` ---db-user ---db-pass ---db-host localhost ---db-port 3306 ---db-name autograder ---frontend-url http://localhost:5173 ---cas-callback-url http://localhost:8080/auth/callback ---canvas-token -``` - -While you can use any root user credentials to access the MySQL database, you may be interested in creating -a special login for this project with restricted privileges (DELETE and CREATE USER administrator privileges are -required). That decision is left to you. - -A Canvas Authorization Key is required to run the project. The Autograder currently relies on information from Canvas -to give you admin access to the app (see [#164](https://github.com/softwareconstruction240/autograder/issues/164)). -To generate a Canvas API key: - -1. Login to [Canvas](https://byu.instructure.com/) -2. Visit your [Profile Settings](https://byu.instructure.com/profile/settings) - - Navigate here manually as "Account > Settings" -3. Scroll down to the **Approved Integrations** section -4. Click "+ New Access Token" -5. Provide the requested information in the modal box -6. Copy the generated access token -7. Use it as the value of the `--canvas-token` program argument above - -#### Loading the Configuration Related Tables - -As of right now, you will need to manually insert the correct values into the `rubric_config` table before being -able to run the actual autograding on the autograder. Down below is an `INSERT` statement to do that. - -UPDATED AS OF 'SUMMER 2024'. Note that the primary thing that needs to be updated here is the `rubric_id` column. -```mysql -INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) VALUES -('GitHub', 'GITHUB_REPO', 'GitHub Repository', 'Two Git commits: one for creating the repository and another for `notes.md`.', 15, '_6829'), -('Phase0', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_649'), -('Phase0', 'PASSOFF_TESTS', 'Functionality', 'All pass off test cases succeed', 125, '_1958'), -('Phase1', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_7800'), -('Phase1', 'PASSOFF_TESTS', 'Functionality', 'All pass off test cases succeed', 125, '_1958'), -('Phase3', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90344_2520'), -('Phase3', 'PASSOFF_TESTS', 'Web API Works', 'All pass off test cases in StandardAPITests.java succeed', 125, '_5202'), -('Phase3', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '_3003'), -('Phase3', 'UNIT_TESTS', 'Unit Tests', 'All test cases pass\nEach public method on your Service classes has two test cases, one positive test and one negative test\nEvery test case includes an Assert statement of some type', 25, '90344_776'), -('Phase4', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90346_6245'), -('Phase4', 'PASSOFF_TESTS', 'Functionality', 'All pass off test cases succeed', 100, '_2614'), -('Phase4', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '90346_8398'), -('Phase4', 'UNIT_TESTS', 'Unit Tests', 'All test cases pass\nEach public method on DAO classes has two test cases, one positive test and one negative test\nEvery test case includes an Assert statement of some type', 25, '90346_5755'), -('Phase5', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90347_8497'), -('Phase5', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '90347_9378'), -('Phase5', 'UNIT_TESTS', 'Unit Tests', 'All test cases pass\nEach public method on the Server Facade class has two test cases, one positive test and one negative test\nEvery test case includes an Assert statement of some type', 25, '90347_2215'), -('Phase6', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90348_9048'), -('Phase6', 'PASSOFF_TESTS', 'Automated Pass Off Test Cases', 'Each provided test case passed is worth a proportional number of points ((passed / total) * 50).', 50, '90348_899'), -('Phase6', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '90348_3792'), -('Quality', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, NULL); -``` - -Now you need to get the correct Canvas course ID. Go to Canvas and select the current CS 240 course. The URL should -change to something like `https://byu.instructure.com/courses/` where `` is the number -you need to use inside the `configuration` table. You can set this by logging into the autograder and using the -`Update Manually` button in the `Config` tab. Click that button and modify the `Course Number` input and then -click `Submit`. - -As of 'SUMMER 2024', the course number is `26822`. - -To ensure that the assignment IDs and rubric IDs/points are synced with Canvas, go -to the `config` tab, select the button `Update using Canvas`, and select `Yes`. If there's a slight -issue, you may need to explore updating the course IDs manually, whether that be directly though the database or by -clicking the `Update Manually` in the `config` tab. - ---- - -Additionally, if you want (not required), you can insert values into the `configuration` table manually -(although the step above should do it automatically). - -UPDATED AS OF 'SUMMER 2024'. Note that the primary thing that needs to be updated is the value of the `COURSE_NUMBER` -and each of the assignment numbers. - -```mysql -INSERT INTO configuration (config_key, value) VALUES -('BANNER_MESSAGE', ''), -('GITHUB_ASSIGNMENT_NUMBER', 941080), -('PHASE0_ASSIGNMENT_NUMBER', 941084), -('PHASE1_ASSIGNMENT_NUMBER', 941085), -('PHASE3_ASSIGNMENT_NUMBER', 941087), -('PHASE4_ASSIGNMENT_NUMBER', 941088), -('PHASE5_ASSIGNMENT_NUMBER', 941089), -('PHASE6_ASSIGNMENT_NUMBER', 941090), -('COURSE_NUMBER', 26822), -('STUDENT_SUBMISSIONS_ENABLED', '[Phase0, Phase1, Phase3, Phase4, Phase5, Phase6, Quality, GitHub]'); -``` - -#### Environment Variables - -If you are running Loki locally (not required), then you must set the following environment variable: -``` -LOKI_URL= -``` - -The value can be either `localhost:3100` (if you are NOT using docker to develop the app) or `loki:3100` -(if you are using docker to develop the app). - -##### Updating from the Old Rubric Config Table. - -If you have the autograder prior to 'SUMMER 2024', the following SQL should do the job of updating -the `rubric_config` table: - -UPDATED AS OF 'SUMMER 2024' -```mysql -ALTER TABLE rubric_config ADD rubric_id VARCHAR(15); --- could be ten as no rubric ids so far are longer than 10, but just in case --- we need extra space. It's up to you if you want to change it. I don't mind. -UPDATE rubric_config SET rubric_id = '_6829' WHERE phase = 'GitHub'; - -UPDATE rubric_config SET rubric_id = '_1958' WHERE phase = 'Phase0' AND type = 'PASSOFF_TESTS'; -INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) - VALUES ('Phase0', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_649'); - -UPDATE rubric_config SET rubric_id = '_1958' WHERE phase = 'Phase1'; -INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) - VALUES ('Phase1', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_7800'); - -UPDATE rubric_config SET rubric_id = '_5202' WHERE phase = 'Phase3' and type = 'PASSOFF_TESTS'; -UPDATE rubric_config SET rubric_id = '90344_776' WHERE phase = 'Phase3' and type = 'UNIT_TESTS'; -UPDATE rubric_config SET rubric_id = '_3003' WHERE phase = 'Phase3' and type = 'QUALITY'; -INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) - VALUES ('Phase3', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90344_2520'); - -UPDATE rubric_config SET rubric_id = '_2614' WHERE phase = 'Phase4' and type = 'PASSOFF_TESTS'; -UPDATE rubric_config SET rubric_id = '90346_5755' WHERE phase = 'Phase4' and type = 'UNIT_TESTS'; -UPDATE rubric_config SET rubric_id = '90346_8398' WHERE phase = 'Phase4' and type = 'QUALITY'; -INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) - VALUES ('Phase4', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90346_6245'); - -UPDATE rubric_config SET rubric_id = '90347_2215' WHERE phase = 'Phase5' and type = 'UNIT_TESTS'; -UPDATE rubric_config SET rubric_id = '90347_9378' WHERE phase = 'Phase5' and type = 'QUALITY'; -INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) - VALUES ('Phase5', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90347_8497'); - -UPDATE rubric_config SET rubric_id = '90348_899' WHERE phase = 'Phase6' and type = 'PASSOFF_TESTS'; -UPDATE rubric_config SET rubric_id = '90348_3792' WHERE phase = 'Phase6' and type = 'QUALITY'; -INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) - VALUES ('Phase6', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90348_9048'); -``` +> [!NOTE] +> If you are using the docker MySQL database, ensure that in +> `src/main/resources/db.properties` the property `db.url` is set to `db:3306`. diff --git a/docs/getting-started/db-insert-statements/insert-config-database.md b/docs/getting-started/db-insert-statements/insert-config-database.md new file mode 100644 index 00000000..f45e91b1 --- /dev/null +++ b/docs/getting-started/db-insert-statements/insert-config-database.md @@ -0,0 +1,33 @@ +# Insert `config` SQL Statements + +This guide is primarily responsible for initializing the `configuration` table, +assuming that the table begins in an empty state. + +> [!TIP] +> The configuration table can _more easily_ be configured with programmatic tools built in to the AutoGrader. +> Find these tools in AutoGrader > Config > Update using Canvas. + +## Updating Guide + +The primary things that needs to be updated on an ongoing basis are: +1. The value of the `COURSE_NUMBER` +2. Each of the assignment numbers + + +## Statements +> [!NOTE] +> Updated as of **SUMMER 2024** + +```mysql +INSERT INTO configuration (config_key, value) VALUES +('BANNER_MESSAGE', ''), +('GITHUB_ASSIGNMENT_NUMBER', 941080), +('PHASE0_ASSIGNMENT_NUMBER', 941084), +('PHASE1_ASSIGNMENT_NUMBER', 941085), +('PHASE3_ASSIGNMENT_NUMBER', 941087), +('PHASE4_ASSIGNMENT_NUMBER', 941088), +('PHASE5_ASSIGNMENT_NUMBER', 941089), +('PHASE6_ASSIGNMENT_NUMBER', 941090), +('COURSE_NUMBER', 26822), +('STUDENT_SUBMISSIONS_ENABLED', '[Phase0, Phase1, Phase3, Phase4, Phase5, Phase6, Quality, GitHub]'); +``` diff --git a/docs/getting-started/db-insert-statements/insert-rubric-database.md b/docs/getting-started/db-insert-statements/insert-rubric-database.md new file mode 100644 index 00000000..0a04c58d --- /dev/null +++ b/docs/getting-started/db-insert-statements/insert-rubric-database.md @@ -0,0 +1,37 @@ +# Insert `rubric` SQL Statements + +This guide is primarily responsible for initializing the `rubric_config` table, +assuming that the table begins in an empty state. + +## Updating Guide + +The primary things that needs to be updated on an ongoing basis are: +1. Values in the `rubric_id` column + +## Statements +> [!NOTE] +> Updated as of **SUMMER 2024** + +```mysql +INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) VALUES +('GitHub', 'GITHUB_REPO', 'GitHub Repository', 'Two Git commits: one for creating the repository and another for `notes.md`.', 15, '_6829'), +('Phase0', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_649'), +('Phase0', 'PASSOFF_TESTS', 'Functionality', 'All pass off test cases succeed', 125, '_1958'), +('Phase1', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_7800'), +('Phase1', 'PASSOFF_TESTS', 'Functionality', 'All pass off test cases succeed', 125, '_1958'), +('Phase3', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90344_2520'), +('Phase3', 'PASSOFF_TESTS', 'Web API Works', 'All pass off test cases in StandardAPITests.java succeed', 125, '_5202'), +('Phase3', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '_3003'), +('Phase3', 'UNIT_TESTS', 'Unit Tests', 'All test cases pass\nEach public method on your Service classes has two test cases, one positive test and one negative test\nEvery test case includes an Assert statement of some type', 25, '90344_776'), +('Phase4', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90346_6245'), +('Phase4', 'PASSOFF_TESTS', 'Functionality', 'All pass off test cases succeed', 100, '_2614'), +('Phase4', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '90346_8398'), +('Phase4', 'UNIT_TESTS', 'Unit Tests', 'All test cases pass\nEach public method on DAO classes has two test cases, one positive test and one negative test\nEvery test case includes an Assert statement of some type', 25, '90346_5755'), +('Phase5', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90347_8497'), +('Phase5', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '90347_9378'), +('Phase5', 'UNIT_TESTS', 'Unit Tests', 'All test cases pass\nEach public method on the Server Facade class has two test cases, one positive test and one negative test\nEvery test case includes an Assert statement of some type', 25, '90347_2215'), +('Phase6', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90348_9048'), +('Phase6', 'PASSOFF_TESTS', 'Automated Pass Off Test Cases', 'Each provided test case passed is worth a proportional number of points ((passed / total) * 50).', 50, '90348_899'), +('Phase6', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, '90348_3792'), +('Quality', 'QUALITY', 'Code Quality', 'Chess Code Quality Rubric (see GitHub)', 30, NULL); +``` diff --git a/docs/getting-started/db-insert-statements/update-rubric-database.md b/docs/getting-started/db-insert-statements/update-rubric-database.md new file mode 100644 index 00000000..a48a819f --- /dev/null +++ b/docs/getting-started/db-insert-statements/update-rubric-database.md @@ -0,0 +1,53 @@ +# Updating `rubric` SQL Statements + +This guide is primarily responsible for updating the `rubric_config` table +when it has already been initialized from [Inserting Rubric SQL Statements](./insert-rubric-database.md). + +These statements only apply to you if you had set up the AutoGrader prior to the +"last updated" date of this guide. + +## Updating Guide + +The primary things that needs to be updated on an ongoing basis are: +1. _Depends on any changes to the `rubric_config` schema_ + +## Statements +> [!NOTE] +> Updated as of **SUMMER 2024** + +```mysql +ALTER TABLE rubric_config ADD rubric_id VARCHAR(15); +-- could be ten as no rubric ids so far are longer than 10, but just in case +-- we need extra space. It's up to you if you want to change it. I don't mind. +UPDATE rubric_config SET rubric_id = '_6829' WHERE phase = 'GitHub'; + +UPDATE rubric_config SET rubric_id = '_1958' WHERE phase = 'Phase0' AND type = 'PASSOFF_TESTS'; +INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) +VALUES ('Phase0', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_649'); + +UPDATE rubric_config SET rubric_id = '_1958' WHERE phase = 'Phase1'; +INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) +VALUES ('Phase1', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90342_7800'); + +UPDATE rubric_config SET rubric_id = '_5202' WHERE phase = 'Phase3' and type = 'PASSOFF_TESTS'; +UPDATE rubric_config SET rubric_id = '90344_776' WHERE phase = 'Phase3' and type = 'UNIT_TESTS'; +UPDATE rubric_config SET rubric_id = '_3003' WHERE phase = 'Phase3' and type = 'QUALITY'; +INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) +VALUES ('Phase3', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90344_2520'); + +UPDATE rubric_config SET rubric_id = '_2614' WHERE phase = 'Phase4' and type = 'PASSOFF_TESTS'; +UPDATE rubric_config SET rubric_id = '90346_5755' WHERE phase = 'Phase4' and type = 'UNIT_TESTS'; +UPDATE rubric_config SET rubric_id = '90346_8398' WHERE phase = 'Phase4' and type = 'QUALITY'; +INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) +VALUES ('Phase4', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90346_6245'); + +UPDATE rubric_config SET rubric_id = '90347_2215' WHERE phase = 'Phase5' and type = 'UNIT_TESTS'; +UPDATE rubric_config SET rubric_id = '90347_9378' WHERE phase = 'Phase5' and type = 'QUALITY'; +INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) +VALUES ('Phase5', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90347_8497'); + +UPDATE rubric_config SET rubric_id = '90348_899' WHERE phase = 'Phase6' and type = 'PASSOFF_TESTS'; +UPDATE rubric_config SET rubric_id = '90348_3792' WHERE phase = 'Phase6' and type = 'QUALITY'; +INSERT INTO rubric_config (phase, type, category, criteria, points, rubric_id) +VALUES ('Phase6', 'GIT_COMMITS', 'Git Commits', 'Necessary commit amount', 0, '90348_9048'); +``` diff --git a/docs/getting-started/getting-started.md b/docs/getting-started/getting-started.md new file mode 100644 index 00000000..3276d8a1 --- /dev/null +++ b/docs/getting-started/getting-started.md @@ -0,0 +1,199 @@ +# Getting Started + +## Pre-requisites + +> [!IMPORTANT] +> The autograder unfortunately requires special setup instructions +> in order to operate on **Windows machines**. +> +> Read [Getting Started on Windows](windows.md) before continuing. + +### Node/Yarn + +The frontend is built using Vue.js. To run the frontend, you will need to have `yarn` (see +[installing yarn](https://yarnpkg.com/getting-started/install)). +After installing `Node` if necessary, run the following to enable `yarn` globally (sudo may be required): + +```shell +corepack enable +``` + +### Backend Database + +You can run the database either locally with your own MySQL server or inside a Docker container. To run the database +inside its own Docker container, run the following in the root of the project: + +```shell +docker compose up db -d +``` + +While you can use any root user credentials to access the MySQL database, you may be interested in creating +a special login for this project. That decision is left to you. If you do create a different user, however, it will +need nearly root-level permissions in any case (enough to be able to create a new database, then create a "student" +user and `GRANT ALL` privileges to them for that database). The exact requirements are not listed here. + +## Quickstart Instructions + +> [!NOTE] +> These instructions will help you set up this project in IntelliJ.\ +> If there are any holes or gaps in the instructions, please submit a new pull request\ +> to preserve the learned knowledge for future generations. + +### 1. Clone the Repo onto your local machine + +Any variation of the following will work. +```shell +git clone https://github.com/softwareconstruction240/autograder.git +``` + +Additionally, you can also leverage Intelli-J's "File > New > New Project from Version Control" +feature which will do it for you given a GitHub link. + +### 2. Use the latest version of the JVM +The system currently requires version **21+**. + +Go fish🐟 Specific instructions to update are not included here. + +### 3. Install front end dependencies + +> [!CAUTION] +> **Windows** If using WSL, run this from an actual WSL terminal.\ +> Windows-based shells, even POSIX ones, won't install the correct files. + +Use `yarn` to install all dependencies. This must be done from the _front end_ root folder. +```shell +cd src/main/resources/frontend +yarn +``` + +### 4. Setup "Server" _Run Configuration_ + +Do the following steps: +1. Navigate to the server file: `src/main/java/edu/byu/cs/server/Server.java` +2. Click the "Run" button to run `Server.main()` +3. This will give you a _Run Configuration_ that you can modify in the following steps. + + +### 5. Set up Program Arguments + +For both deployment and development, the following program arguments are required to be set. Some typical +values for development are provided; notice that the URLs all reference localhost, but the port numbers have +been filled in with default values. Update these as needed to match your environment. + +Do the following actions: +1. Refer to the required arguments below +2. Fill in the appropriate values for each of the +3. Prepare the arguments by reformatting them onto a single line + - Ex. `--arg-1 arg1Val --arg-2 arg2Val` +4. Edit the "Server" _run configuration_ +5. Save & apply the changes + +#### Required Program Arguments + +> [!CAUTION] +> **Windows** users cannot simply use these arguments like users of other platforms can.\ +> See [Windows Setup Instructions](./windows.md#setup) for more details. + +```shell +--db-user +--db-pass +--db-host localhost +--db-port 3306 +--db-name autograder +--frontend-url http://localhost:5173 +--cas-callback-url http://localhost:8080/auth/callback + +# Use one of the following, but not both +--canvas-token +--use-canvas false +``` + +### 6. Run the Autograder Locally + +Do the following steps: +1. Run your "Server" run configuration +2. Run the frontend with the following shell commands + +> [!NOTE] +> **Windows** In the case you are running on the Autograder inside a dev container,\ +> you may need to add the `--host` option at the end of the `yarn dev` command (`yarn dev --host`). + +```shell +cd src/main/resources/frontend +yarn dev +``` + +### 7. (Optional) Setup Canvas Integration + +> [!TIP] +> This is only required if you hope to transfer data to Canvas during your workflow;\ +> otherwise, use the `--use-canvas false` program argument and skip this step. + +To link the autograder with Canvas, you will need to generate a Canvas API key and set the autograder to the current +Course and Assignment ID numbers on Canvas. + +If you don't need Canvas integration, `--canvas-token ` can be replaced with `--use-canvas false`, +which mocks Canvas calls. Then, you can skip this section. + +#### Canvas API Key +A Canvas Authorization Key is required to link the project to Canvas. + +To generate a Canvas API key: + +1. Login to [Canvas](https://byu.instructure.com/) +2. Visit your [Profile Settings](https://byu.instructure.com/profile/settings) + - Navigate here manually as "Account > Settings" +3. Scroll down to the **Approved Integrations** section +4. Click "+ New Access Token" +5. Provide the requested information in the modal box +6. Copy the generated access token +7. Add the token along side your other program arguments from [step #5](#required-program-arguments) + - Add the argument `--canvas-token ` + +#### Canvas Data + +To update Canvas course ID: +1. Go to Canvas and select the current CS 240 course +2. The URL should change to something like `https://byu.instructure.com/courses/` +3. Extract `` from the url + - This is the number that needs to end up in the configuration table +4. You can set this by logging into the autograder and using the `Update Manually` button in the `Config` tab + 1. Click that button and modify the `Course Number` input + 2. Click `Submit` + +To ensure that the assignment IDs and rubric IDs/points are synced with Canvas: +1. Go to the `config` tab of the AutoGrader +2. Select the button `Update using Canvas` +3. Select `Yes` + +> [!NOTE] +> If there's an issue with the process, you may need to explore updating the course IDs manually.\ +> This can be done directly though the database's `configuration` table or +> by clicking `Update Manually` in the `config` tab. + +Additionally, if you want (not required), you can insert values into the `configuration` table manually +(although the step above should do it automatically). See [Insert `config` SQL Statements](db-insert-statements/insert-config-database.md). + +### 8. (Optional) Environment Variables + +> [!TIP] +> This is only required when running `Loki` locally;\ +> otherwise, simply skip this step. + +If you are running Loki locally (not required), then you must set the `LOKI_URL` environment variable. The value can be +either `localhost:3100` (if you are NOT using docker to develop the app) or `loki:3100` (if you are using docker to +develop the app). + +### 9. Loading the Configuration Related Tables + +> [!IMPORTANT] +> If you had the autograder prior to 'SUMMER 2024', there is a separate "update" set of SQL commands to use.\ +> See [Update `rubric_config` SQL Statements](db-insert-statements/update-rubric-database.md). + +This is required. + +As of right now, you will need to manually insert the correct values into the `rubric_config` table before being +able to run the actual grading on the autograder. See [Insert `rubric_config` SQL Statements](db-insert-statements/insert-rubric-database.md). + +Insert the commands using a [SQL client](https://github.com/softwareconstruction240/softwareconstruction/blob/main/instruction/mysql/mysql.md#sql-clients) +of your choice on your machine (MySql Shell, SQLWorkbench, or Intelli-J's built in tools). diff --git a/docs/getting-started/windows.md b/docs/getting-started/windows.md new file mode 100644 index 00000000..81ef9bcc --- /dev/null +++ b/docs/getting-started/windows.md @@ -0,0 +1,99 @@ +# Special "Getting Started" instructions on Windows Machines + +The autograder unfortunately won't work directly from Windows, so it must be run inside a Docker container +(recommended) or inside WSL, the Windows Subsystem for Linux (not recommended unless you're already familiar with WSL). +When running the autograder inside a Docker container, you will need to use a _Dev Container_ if you want to use +IntelliJ's debugging tools. + +Either way, running your MySQL server locally on your Windows machine should work for the database. + +## Development inside a Dev Container (recommended) + +The easiest way to debug a program running inside a Docker container is via a "Dev Container," which is essentially +just a fancy term for a Docker container that's linked to an IDE. It essentially allows you to run your IDE inside the +container, which enables debugging the autograder code on Windows machines. How it works is IDE-specific; this document +provides instructions for the autograder using IntelliJ. Further reading can be +found [here](https://www.jetbrains.com/help/idea/connect-to-devcontainer.html). + +This requires having Docker installed and running on your machine. It also requires the full +professional version of IntelliJ (or a student license of it). + +### Setup + +#### Initially Creating the Dev Container + +To set up your dev container for the first time: +1. Navigate to `.devcontainer/devcontainer.json` +2. There should be an icon that pops up next to the opening curly brace +3. Click the icon, then select `Create Dev Container and Clone Sources...`. (Not to be confused +with `Mount Sources`, which doesn't quite work.) + - This should pop up a dialog box that allows you to change a few options about the container. + - If the "Clone Sources" option does not appear, see [No Clone Sources](#no-clone-sources). + - Look through them and change what you need, then hit the `Build Container and Continue` button. +4. Wait for IntelliJ and Docker to build everything + - You may need to click a few buttons along the way. + - Eventually a new IntelliJ window will pop up from the dev container. +5. Follow the [Getting Started](getting-started.md) steps with the new window, with the following notes: + - Use `host.docker.internal` as your db-host argument; this tells docker to look for the + database on your local Windows machine rather than inside the container. + +#### Reopening the Dev Container + +To reopen the container after you've closed it: +1. Navigate to the `.devcontainer/devcontainer.json` file again, and click the icon +2. Select `Show Dev Containers` +3. Select the container + - It should reopen the second IntelliJ. + - If nothing appears, make sure the docker engine is running (perhaps by opening Docker Desktop). + +#### Alternative Path To Create A Dev Container + +> [!NOTE] +> If you follow these instructions to create your Dev Container, you will also need +> an alternative path to reopen the dev container.\ +> Reopen your Dev Container by starting in the Gateway tool. + +If you don't see an option to `Clone Sources`, you can do the same thing via JetBrains Gateway. +1. Download and install JetBrains Gateway if you haven't already. + - Installing via JetBrains Toolbox is probably the easiest way. +2. Open Gateway, +3. Select `Dev Containers` +4. Click `New Dev Container` +5. Choose `From VCS Project` +6. Select "Intellij IDEA" from the dropdown +7. Paste a link to the autograder GitHub repo (or your fork of it) +8. Continue setting up the Dev Container with steps 4 and 5 above + +## Development inside WSL + +> [!CAUTION] +> WSL isn't the recommended option, and these instructions might not be maintained. + +> [!WARNING] +> Everything in these instructions (including everything in `getting-started.md`) +> should be done via a WSL terminal _and_ inside a WSL directory. +> +> "Unix-like" shells, such as Git Bash, will not work: it needs to be a true WSL terminal. +> Similarly, all your autograder files should be cloned into WSL's own dedicated file system. +> Yes, WSL can access your Windows files (via the `\mnt\c\` path), but with the use of a Windows +> directory like `C:\Desktop\chess`, you might face file permissions errors. + +WSL 2 (Windows Subsystem for Linux 2) is essentially a Linux kernel that's built into Windows, which means you'll be +able to simply clone and run the autograder as if you were running Linux. Development is fairly simple once set up, but +getting it set up for the autograder can be a bit finicky. + +### Setup + +Install and configure WSL if needed. Instructions can be found +[here](https://learn.microsoft.com/en-us/windows/wsl/install). + +For the `--db-host` program argument, you can't simply use `localhost` (assuming your database is running on Windows), +since that will refer to the WSL instance. Running `echo $(hostname)` from a WSL terminal will tell you what your +computer's true hostname is (ex. `LAPTOP-ABC123`). Appending `.local` to that (ex. `LAPTOP-ABC123.local`) gives you +the hostname that WSL uses to refer to the Windows machine. Use this as the `--db-host` program argument. + +By default, MySQL users have "Limit to Host Matching" set to `localhost`, which does not allow requests coming from the +WSL virtual machine. You will have to expand this in MySQLWorkbench (under Server, click "Users and Privileges"). The +easiest way is to change it to `%`, which allows all hostnames (but it is highly recommended that you only do this for a +new user with restricted privileges, rather than using root). Another option is to run `wsl hostname -I` in PowerShell +to determine the WSL instance's IP address, then simply hardcode that, but this IP may change when WSL restarts.