# `Ltix.GradeService.Result`
[🔗](https://github.com/DecoyLex/ltix/blob/main/lib/ltix/grade_service/result.ex#L1)

A result record from the platform's gradebook.

Results are read-only. The platform provides them via the result
service. Each result represents the current grade for a specific
line item and user.

When `result_maximum` is `nil`, consumers should treat it as 1
per the spec default.

## Examples

    {:ok, result} = Ltix.GradeService.Result.from_json(%{
      "userId" => "5323497",
      "resultScore" => 0.83,
      "resultMaximum" => 1
    })

    result.result_score
    #=> 0.83

# `t`

```elixir
@type t() :: %Ltix.GradeService.Result{
  comment: String.t() | nil,
  extensions: %{optional(String.t()) =&gt; term()} | nil,
  id: String.t() | nil,
  result_maximum: number() | nil,
  result_score: number() | nil,
  score_of: String.t() | nil,
  scoring_user_id: String.t() | nil,
  user_id: String.t() | nil
}
```

# `from_json`

```elixir
@spec from_json(map()) :: {:ok, t()} | {:error, Exception.t()}
```

Parse a result from a decoded JSON map.

Accepts any map and extracts known fields. Fields with the wrong type are
`nil`. Unrecognized keys are kept in `extensions`.

## Examples

    iex> {:ok, result} = Ltix.GradeService.Result.from_json(%{"userId" => "123", "resultScore" => 0.5})
    iex> {result.user_id, result.result_score}
    {"123", 0.5}

# `to_map`

```elixir
@spec to_map(t()) :: map()
```

Serialize a result to a map with camelCase string keys.

## Examples

    iex> result = %Ltix.GradeService.Result{user_id: "123", result_score: 0.5}
    iex> Ltix.GradeService.Result.to_map(result)
    %{"userId" => "123", "resultScore" => 0.5}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
