Skip to content

Commit

Permalink
Merge pull request #1182 from Aalto-LeTech/fix-again-has-submittable-…
Browse files Browse the repository at this point in the history
…files

Re-introduce the hack that solves the issue with hasSubmittableFiles
  • Loading branch information
jaakkonakaza authored Jan 8, 2025
2 parents 49ff591 + a0bc1c7 commit bb48208
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import io.ktor.client.request.parameter
import io.ktor.client.statement.bodyAsText
import io.ktor.http.*
import io.ktor.resources.*
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNamingStrategy
import org.jsoup.Jsoup
import java.time.ZonedDateTime
import kotlin.collections.component1
Expand Down Expand Up @@ -41,8 +43,12 @@ object APlusApi {
@Resource("exercises")

Check warning on line 43 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Hardcoded strings

Hardcoded string literal: "exercises"
class Exercises(val parent: Course) {

Check warning on line 44 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Missing KDoc comments for public declarations

Class "Exercises" is missing documentation

Check warning on line 44 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Missing KDoc comments for public declarations

Property "parent" is missing documentation
suspend fun get(project: Project): List<CourseModule> {

Check warning on line 45 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Missing KDoc comments for public declarations

Function "get" is missing documentation
return CoursesClient.getInstance(project)
.getBody<Exercises, CourseModuleResults>(this@Exercises).results
// TODO remove after hasSubmittableFiles fixed
// CoursesClient.getInstance(project).getBody<Exercises, CourseModuleResults>(this@Exercises).results
val res = CoursesClient.getInstance(project).get<Exercises>(this@Exercises)
return json.decodeFromString<CourseModuleResults>(
res.bodyAsText().replace("\"has_submittable_files\":[]", "\"has_submittable_files\":false")

Check warning on line 50 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Hardcoded strings

Hardcoded string literal: "\\"has_submittable_files\\":false"

Check warning on line 50 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Hardcoded strings

Hardcoded string literal: "\\"has_submittable_files\\":\[\]"
).results
}

@Serializable
Expand Down Expand Up @@ -71,8 +77,18 @@ object APlusApi {
val maxSubmissions: Int,

Check warning on line 77 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Missing KDoc comments for public declarations

Property "maxSubmissions" is missing documentation
val hierarchicalName: String,

Check warning on line 78 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Missing KDoc comments for public declarations

Property "hierarchicalName" is missing documentation
val difficulty: String,

Check warning on line 79 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Missing KDoc comments for public declarations

Property "difficulty" is missing documentation
val hasSubmittableFiles: Boolean
// val hasSubmittableFiles: Boolean // TODO should always be bool, currently boolean or null or array
val hasSubmittableFiles: Boolean?

Check warning on line 81 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Missing KDoc comments for public declarations

Property "hasSubmittableFiles" is missing documentation
)

companion object {
@OptIn(ExperimentalSerializationApi::class)
private val json = Json { // TODO remove after hasSubmittableFiles fixed
ignoreUnknownKeys = true
isLenient = true
namingStrategy = JsonNamingStrategy.SnakeCase
}
}
}

@Resource("points/me")

Check warning on line 94 in src/main/kotlin/fi/aalto/cs/apluscourses/api/APlusApi.kt

View workflow job for this annotation

GitHub Actions / Qodana Community for JVM

Hardcoded strings

Hardcoded string literal: "points/me"
Expand Down

0 comments on commit bb48208

Please sign in to comment.