-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #467 from NDLANO/quality-evaluation
draft-api: Quality evaluation
- Loading branch information
Showing
14 changed files
with
164 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
common/src/main/scala/no/ndla/common/model/domain/draft/Grade.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Part of NDLA common | ||
* Copyright (C) 2024 NDLA | ||
* | ||
* See LICENSE | ||
*/ | ||
|
||
package no.ndla.common.model.domain.draft | ||
|
||
import com.scalatsi.TypescriptType.{TSLiteralNumber, TSUnion} | ||
import com.scalatsi.{TSNamedType, TSType} | ||
import enumeratum.values.{IntCirceEnum, IntEnum, IntEnumEntry} | ||
import sttp.tapir.Schema | ||
import sttp.tapir.codec.enumeratum.* | ||
|
||
sealed abstract class Grade(val value: Int) extends IntEnumEntry | ||
|
||
object Grade extends IntEnum[Grade] with IntCirceEnum[Grade] { | ||
|
||
val values: IndexedSeq[Grade] = findValues | ||
implicit val schema: Schema[Grade] = schemaForIntEnumEntry[Grade] | ||
|
||
case object One extends Grade(1) | ||
case object Two extends Grade(2) | ||
case object Three extends Grade(3) | ||
case object Four extends Grade(4) | ||
case object Five extends Grade(5) | ||
|
||
implicit val enumTsType: TSNamedType[Grade] = TSType.alias[Grade]( | ||
"Grade", | ||
TSUnion(values.map(e => TSLiteralNumber(e.value))) | ||
) | ||
} |
21 changes: 21 additions & 0 deletions
21
common/src/main/scala/no/ndla/common/model/domain/draft/QualityEvaluation.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Part of NDLA common | ||
* Copyright (C) 2024 NDLA | ||
* | ||
* See LICENSE | ||
*/ | ||
|
||
package no.ndla.common.model.domain.draft | ||
|
||
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder} | ||
import io.circe.{Decoder, Encoder} | ||
|
||
case class QualityEvaluation( | ||
grade: Grade, | ||
note: String | ||
) | ||
|
||
object QualityEvaluation { | ||
implicit def encoder: Encoder[QualityEvaluation] = deriveEncoder | ||
implicit def decoder: Decoder[QualityEvaluation] = deriveDecoder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
draft-api/src/main/scala/no/ndla/draftapi/model/api/QualityEvaluation.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Part of NDLA draft-api | ||
* Copyright (C) 2024 NDLA | ||
* | ||
* See LICENSE | ||
*/ | ||
|
||
package no.ndla.draftapi.model.api | ||
|
||
import io.circe.{Decoder, Encoder} | ||
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder} | ||
import no.ndla.common.model.domain.draft.Grade | ||
import sttp.tapir.Schema.annotations.description | ||
|
||
@description("Quality evaluation of the article") | ||
case class QualityEvaluation( | ||
@description("The grade (1-5) of the article") grade: Grade, | ||
@description("Note explaining the score") note: String | ||
) | ||
|
||
object QualityEvaluation { | ||
implicit def encoder: Encoder[QualityEvaluation] = deriveEncoder | ||
implicit def decoder: Decoder[QualityEvaluation] = deriveDecoder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.