From 480d53beaa8f01d572317a61485068d1777b3d6f Mon Sep 17 00:00:00 2001 From: Geoffrey Challen Date: Mon, 24 Jan 2022 16:59:04 -0600 Subject: [PATCH] Fix line count issue. --- build.gradle.kts | 2 +- lib/src/main/kotlin/Question.kt | 2 +- lib/src/main/kotlin/QuestionHelpers.kt | 6 +----- plugin/src/main/kotlin/save/SaveQuestions.kt | 3 ++- .../edu.illinois.cs.cs125.questioner.server.version | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 994ad00..712c121 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } subprojects { group = "com.github.cs125-illinois.questioner" - version = "2022.1.3" + version = "2022.1.4" tasks.withType { kotlinOptions { jvmTarget = JavaVersion.VERSION_16.toString() diff --git a/lib/src/main/kotlin/Question.kt b/lib/src/main/kotlin/Question.kt index 3a554c1..33308b1 100644 --- a/lib/src/main/kotlin/Question.kt +++ b/lib/src/main/kotlin/Question.kt @@ -49,7 +49,7 @@ data class Question( val importWhitelist: Set, val importBlacklist: Set, val slug: String, - val kotlinSolution: FlatFile? = alternativeSolutions.find { it.language == Language.kotlin }, + val kotlinSolution: FlatFile?, val detemplatedJavaStarter: String? = incorrect.find { it.language == Language.java && it.starter }?.contents, val detemplatedKotlinStarter: String? = incorrect.find { it.language == Language.kotlin && it.starter }?.contents, val hasKotlin: Boolean = diff --git a/lib/src/main/kotlin/QuestionHelpers.kt b/lib/src/main/kotlin/QuestionHelpers.kt index 12b997d..2b0a80e 100644 --- a/lib/src/main/kotlin/QuestionHelpers.kt +++ b/lib/src/main/kotlin/QuestionHelpers.kt @@ -299,11 +299,7 @@ fun Question.computeComplexity(contents: String, language: Question.Language): T } fun Question.computeLineCounts(contents: String, language: Question.Language): TestResults.LineCountComparison { - val solutionLineCount = if (language == Question.Language.java) { - correct.lineCount - } else { - alternativeSolutions.filter { it.language == language }.mapNotNull { it.lineCount }.minByOrNull { it.source } - } + val solutionLineCount = published.lineCounts[language] check(solutionLineCount != null) { "Solution line count not available" } val type = when (language) { Question.Language.java -> Source.FileType.JAVA diff --git a/plugin/src/main/kotlin/save/SaveQuestions.kt b/plugin/src/main/kotlin/save/SaveQuestions.kt index 49d2541..2d4fad8 100644 --- a/plugin/src/main/kotlin/save/SaveQuestions.kt +++ b/plugin/src/main/kotlin/save/SaveQuestions.kt @@ -429,7 +429,8 @@ fun List.findQuestions( kotlinTemplate, solution.whitelist.toSet(), solution.blacklist.toSet(), - solution.correct.path ?: slugify.slugify(solution.correct.name) + solution.correct.path ?: slugify.slugify(solution.correct.name), + kotlinSolution?.toAlternateFile(kotlinCleanSpec) ) } catch (e: Exception) { throw Exception("Process ${solution.path} failed: $e", e) diff --git a/server/src/main/resources/edu.illinois.cs.cs125.questioner.server.version b/server/src/main/resources/edu.illinois.cs.cs125.questioner.server.version index 30459df..d0308ac 100644 --- a/server/src/main/resources/edu.illinois.cs.cs125.questioner.server.version +++ b/server/src/main/resources/edu.illinois.cs.cs125.questioner.server.version @@ -1 +1 @@ -version=2022.1.3 \ No newline at end of file +version=2022.1.4 \ No newline at end of file