Skip to content

Commit

Permalink
Merge pull request #4 from jheinzel/feature/review-chooser
Browse files Browse the repository at this point in the history
Automatic feedback selection, config cleanup
  • Loading branch information
jheinzel authored Dec 9, 2022
2 parents aa8b1cd + d092e6f commit 39da7d4
Show file tree
Hide file tree
Showing 38 changed files with 1,084 additions and 194 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Setup JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
java-version: '11'
- name: Restore Gradle wrapper from cache
uses: actions/cache@v1
with:
Expand All @@ -29,4 +30,4 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-caches-
- name: Test
run: ./gradlew test
run: ./gradlew test --stacktrace
112 changes: 65 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,81 @@
Tutorbot is a simple command line tool that helps programming tutors at the University of Applied Sciences in Hagenberg
by automating repetitive tasks.

### Features
## Download

https://github.com/jheinzel/tutorbot/releases

## Features

Tutorbot comes with a range of different features, it can support you by:

* downloading (and extracting) all submissions for a certain exercise
* checking submissions for plagiarism
* downloading all reviews for a certain exercise
* sending feedback emails to students
* choosing reviews to give feedback to
* saving amount of feedbacks each student has received

### Configuration
## Configuration

Tutorbot requires different user inputs, some of them are likely repetitive. To avoid repeating them every time, these
inputs can be stored in a configuration file. Currently the configuration file supports the following values:
inputs can be stored in a configuration file. The following example contains the most commonly used settings:

```properties
# Moodle username (only works for local accounts since mandatory 2FA)
# Moodle username and base url
moodle.username=ha20210005
# Set the password for ease of use
moodle.password=XXXXXX
moodle.url=https://elearning.fh-ooe.at/
# Uncomment to authorize with the MoodleSessionlmsfhooe cookie
# Instead of local username and password
# moodle.auth.method=cookie
# Uncomment to authorize with the moodle cookie instead of local username and password
# moodle.auth.method=cookie
# Email address and username of person who sends feedback emails
email.address=sXXXXXXXXXX@fhooe.at
email.username=sXXXXXXXXXX
email.password=XXXXXX
# <students-id>@<email.students.suffix> => for receivers of emails
email.students.suffix=fhooe.at
# Base directory where exercise folders will be stored
# Base directory where downloaded files will be stored
location.basedir=../
# Subdirectory for current exercise
# it's better to not set this property, you do not want to edit the config whenever you download something
# just type it when the command asks you
# location.exercise.subdir = e1
# Subdirectory where submissions and reviews will be stored
location.submissions.subdir=submissions
location.reviews.subdir=reviews
# This current setup directory would be like this would look like this
# ./basedir/exercise.subdir/submissions
# ./basedir/exercise.subdir/reviews
# The exercise.subdir would be replaced by whatever target dir you put into the command when it asks you
# Java language version used by JPlag for plagiarism detection (default is Java 1.9)
# remove / comment line below for java
plagiarism.language.java.version=c/c++
# Templates for Email use %s for template parameters, Umlaute i.e ü, ö, ä are not supported by the encoding
# CSV where count of feedbacks will be saved at. For multiple tutors, a fileshare like OneDrive or network drive is recommended.
# Ex. C:/Users/Tutor/OneDrive/SWO3/Tutorbot/feedback-count.csv
feedback.csv=../feedback-count.csv
# Templates for Email use %s for template parameters, Umlaute i.e ä, ö, ü are not supported by the encoding
email.template.subject=Feedback zur Uebung %s
email.template.body=Hallo,\n\nanbei euer Feedback zur Uebung %s.\nBei Fragen koennt ihr mir gerne auf diese E-Mail antworten.\n\nLG\n XXX.
```

For Tutorbot to detect this file, it should be located in the same directory as the `tutorbot.jar` and should be
called `tutorbot.properties`. It is also possible to configure those parameters using environment variables:

| Environment variable | Description |
|---------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| `TUTORBOT_MOODLE_USERNAME` | Moodle username (only works for local accounts since mandatory 2FA) |
| `TUTORBOT_MOODLE_PASSWORD` | Moodle password |
| `TUTORBOT_MOODLE_URL` | Moodle base url (default https://elearning.fh-ooe.at/) |
| `TUTORBOT_MOODLE_AUTH_METHOD` | Moodle authorization method used for downloading. Can optionally be set to "cookie". Default authorization uses username and password. |
| `TUTORBOT_EMAIL_ADDRESS` | E-Mail address the feedback will be sent from |
| `TUTORBOT_EMAIL_USERNAME` | Username for the E-Mail service |
| `TUTORBOT_EMAIL_PASSWORD` | Password for the E-Mail service |
| `TUTORBOT_EMAIL_TEMPLATE_SUBJECT` | Template string for the subject of E-Mails sent to students. %s is used as placeholder. |
| `TUTORBOT_EMAIL_TEMPLATE_BODY` | Template string for the body of E-Mails sent to students. %s is used as placeholder. |
| `TUTORBOT_EMAIL_STUDENTS_SUFFIX` | Suffix of E-Mail addresses of students (default fhooe.at) |
| `TUTORBOT_LOCATION_BASEDIR` | Base-location where Tutorbot will create other folders |
| `TUTORBOT_LOCATION_EXERCISE_SUBDIR` | Subfolder of basedir for the exercise |
| `TUTORBOT_LOCATION_SUBMISSIONS_SUBDIR` | Subfolder of exercise as download location for submissions |
| `TUTORBOT_LOCATION_REVIEWS_SUBDIR` | Subfolder of exercise as download location for reviews |
| `TUTORBOT_PLAGIARISM_LANGUAGE_JAVA_VERSION` | Java language version used by JPlag for plagiarism detection (default is Java 1.9). Also supports C/C++. |
called `tutorbot.properties`. It is also possible to configure those parameters using environment variables (properties
have '.' instead of '_'):

| Environment variable | Description |
|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `TUTORBOT_MOODLE_USERNAME` | Moodle username (only works for local accounts since mandatory 2FA). |
| `TUTORBOT_MOODLE_PASSWORD` | Moodle password. |
| `TUTORBOT_MOODLE_URL` | Moodle base url (default https://elearning.fh-ooe.at/) |
| `TUTORBOT_MOODLE_AUTH_METHOD` | Moodle authorization method used for downloading. Can optionally be set to "cookie". Default authorization uses username and password. |
| `TUTORBOT_MOODLE_COOKIE_NAME` | Name of the Moodle cookie for cookie authorization (default is MoodleSessionlmsfhooe). |
| `TUTORBOT_EMAIL_ADDRESS` | E-Mail address the feedback will be sent from. |
| `TUTORBOT_EMAIL_USERNAME` | Username for the E-Mail service. |
| `TUTORBOT_EMAIL_PASSWORD` | Password for the E-Mail service. |
| `TUTORBOT_EMAIL_TEMPLATE_SUBJECT` | Template string for the subject of E-Mails sent to students. %s is used as placeholder. |
| `TUTORBOT_EMAIL_TEMPLATE_BODY` | Template string for the body of E-Mails sent to students. %s is used as placeholder. |
| `TUTORBOT_EMAIL_STUDENTS_SUFFIX` | Suffix of E-Mail addresses of students (default fhooe.at). |
| `TUTORBOT_LOCATION_BASEDIR` | Base-location where Tutorbot will create other folders. |
| `TUTORBOT_LOCATION_EXERCISE_SUBDIR` | Subfolder of basedir for the exercise. |
| `TUTORBOT_LOCATION_SUBMISSIONS_SUBDIR` | Subfolder of exercise as download location for submissions. |
| `TUTORBOT_LOCATION_REVIEWS_SUBDIR` | Subfolder of exercise as download location for reviews. |
| `TUTORBOT_FEEDBACK_AMOUNT` | Amount of reviews that will be chosen by choose-feedback. |
| `TUTORBOT_FEEDBACK_RANDOM_AMOUNT` | Amount of reviews that will be randomly chosen in choose-feedback. Independent of feedback count received, may only be <= feedback count. |
| `TUTORBOT_FEEDBACK_CSV` | Location of the feedback count CSV file. Absolute or relative path independent of other variables. |
| `TUTORBOT_PLAGIARISM_LANGUAGE_JAVA_VERSION` | Java language version used by JPlag for plagiarism detection (default is Java 1.9). Also supports C/C++. |

Values from the properties file will take precedence over values from environment variables if both are specified.

### Using the tutorbot
## Using the tutorbot

The folder "tutorbot" contains everything needed to run the cli tool.
If it is your first time using the Tutorbot, the command `tutorbot instructions` helps you get an overview of the steps to take.

On Windows use the powershell script `tutorbot.ps1` followed by the command you want to execute. The following image
show how to execute the `reviews` command. This uses the default `tutotrbot.properties` and creates the
Expand All @@ -96,21 +95,40 @@ enabled. If you are on Windows, this can be fixed by using the `Windows Terminal
the `tutorbotWithoutWT.ps1` script (instead of `tutorbot.ps1`) which opens a powershell session with ANSI color codes
enabled.

#### Authorization with cookie
Since moodle has a strict OIDC authorization for students' accounts, a simple login with username and password is not possible anymore.
### Authorization with cookie

Since moodle has a strict OIDC authorization for students' accounts, a simple login with username and password is not
possible anymore.
Current workarounds include:

* Using a local moodle account, which is added to the courses.
* Authorizing with a student account using a copied cookie from a browser.

To perform the latter a few steps have to be taken:

* Enabling `moodle.auth.method=cookie` in the properties.
* Logging in moodle using any browser.
* Copying the value of the `MoodleSessionlmsfhooe` Cookie after successful login.

After this, any download command of tutorbot can be performed using the cookie value. If this did not work,
check if the cookie value changed after a browser refresh.

### Buildling this project
### Sharing a feedback-count.csv with multiple tutors
Every tutor should use the same `feedback-count.csv` file when using the `choose-feedback` command.
This is why a fileshare or network drive should be used to synchronize the file state.

For example OneDrive works well for sharing the feedback count ([Tutorial from Microsoft](https://support.microsoft.com/en-us/office/add-and-sync-shared-folders-to-onedrive-for-home-8a63cd47-1526-4cd8-bd09-ee3f9bfc1504)):
1. To setup a shared folder create it in your OneDrive.
2. Using the share menu, give the other tutors edit access to your folder.

or

1. To use a shared folder, login to the OneDrive web interface.
2. On the left navigation pane, select 'Shared'.
3. Select the shared folder, and then press the 'Add shortcut to My files' button on the top.
4. Now the folder can also be accessed in your local OneDrive.

## Buildling this project

Tutorbot is built using Gradle. You don't need to install anything, as the Gradle wrapper is included in the repository.
To build the project, simply execute `./gradlew jar`, the resulting JAR file will be located
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "at.fhooe.hagenberg"
version = "1.3.0"
version = "1.4.0"

repositories {
mavenCentral()
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/at/fhooe/hagenberg/tutorbot/Tutorbot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import kotlin.system.exitProcess
ReviewsCommand::class,
MailCommand::class,
PlagiarismCommand::class,
ChooseFeedbackCommand::class,
SaveFeedbackCommand::class,
InstructionsCommand::class,
VersionCommand::class
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class CredentialStore @Inject constructor(configHandler: ConfigHandler) {
class CredentialStore @Inject constructor(private val configHandler: ConfigHandler) {
private var moodleUsername: String? = null
private var moodlePassword: String? = null
private var moodleCookie: String? = null
Expand Down Expand Up @@ -38,12 +38,16 @@ class CredentialStore @Inject constructor(configHandler: ConfigHandler) {

fun getMoodlePassword(): String {
// return moodlePassword ?: promptTextInput("Enter moodle password ($moodleUsername):").also { moodlePassword = it }
return moodlePassword ?: promptPasswordInput("Enter moodle password ($moodleUsername):").also { moodlePassword = it }
return moodlePassword ?: promptPasswordInput("Enter moodle password ($moodleUsername):").also {
moodlePassword = it
}
}

fun getMoodleCookie(): String {
return moodleCookie
?: promptTextInput("Enter authorization cookie value ($COOKIE_AUTH_NAME):").also { moodleCookie = it }
?: promptTextInput("Enter authorization cookie value (${configHandler.getMoodleCookieName()}):").also {
moodleCookie = it
}
}

fun getEmailPassword(): String {
Expand All @@ -52,10 +56,6 @@ class CredentialStore @Inject constructor(configHandler: ConfigHandler) {
}

fun setEmailPassword(value: String?) {
emailPassword = value;
}

companion object {
const val COOKIE_AUTH_NAME = "MoodleSessionlmsfhooe"
emailPassword = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MoodleAuthenticator @Inject constructor(
return Cookie.Builder()
.hostOnlyDomain(domain)
.path("/")
.name(CredentialStore.COOKIE_AUTH_NAME)
.name(configHandler.getMoodleCookieName())
.value(value)
.secure()
.build()
Expand Down
Loading

0 comments on commit 39da7d4

Please sign in to comment.