Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a student id check #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main/kotlin/org/tudalgo/algomate/AlgoMatePlugin.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.tudalgo.algomate

import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.JavaApplication
Expand All @@ -14,6 +15,7 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.withType
import org.sourcegrade.jagr.gradle.extension.JagrExtension
import org.sourcegrade.jagr.gradle.task.submission.SubmissionWriteInfoTask
import org.tudalgo.algomate.extension.ExerciseExtension
import org.tudalgo.algomate.extension.SubmissionExtension

Expand Down Expand Up @@ -92,6 +94,18 @@ class AlgoMatePlugin : Plugin<Project> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
withType<SubmissionWriteInfoTask> {
doFirst {
if (!studentId.get().matches(".*[a-zA-Z].*".toRegex())) {
w-lfchen marked this conversation as resolved.
Show resolved Hide resolved
throw GradleException(
"""
The student ID does not contain a letter.
Are you sure that you haven't entered your matriculation number instead of your student ID?
""".trimIndent()
)
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.gradle.kotlin.dsl.property
import javax.inject.Inject

abstract class SubmissionExtension @Inject constructor(
objectFactory: ObjectFactory,
objectFactory: ObjectFactory
w-lfchen marked this conversation as resolved.
Show resolved Hide resolved
) {
internal val studentIdProperty = objectFactory.property<String>()
internal val firstNameProperty = objectFactory.property<String>()
Expand Down