feat: enhance quiz schema with JsonList type and add quiz attempt fields

- Introduced a new 'JsonList' scalar type in the GraphQL schema to handle lists of JSON values, improving data structure flexibility.
- Updated the Quiz schema to replace 'Json' type with 'JsonList' for user input and questions, ensuring consistent data handling.
- Added new fields for retrieving quiz attempts, including individual and multiple attempts, with appropriate authorization checks for user roles.
- Enhanced error handling for quiz attempt retrieval to ensure proper access control and user feedback.

These changes improve the overall functionality and maintainability of the quiz feature, providing a more robust data model and user experience.
This commit is contained in:
2024-12-11 17:26:28 +07:00
parent c437022d41
commit 4168bff1e8
4 changed files with 98 additions and 5 deletions

View File

@@ -78,6 +78,10 @@ export interface SchemaBuilderOption {
Input: Delta
Output: Delta
}
JsonList: {
Input: JsonValue[]
Output: JsonValue[]
}
}
}
@@ -160,6 +164,12 @@ export class Builder extends SchemaBuilder<SchemaBuilderOption> {
parseLiteral: (ast: ValueNode) => ast as unknown as Delta,
})
this.scalarType('JsonList', {
serialize: (value) => JSON.stringify(value),
parseValue: (value: unknown) => JSON.parse(value as string) as JsonValue[],
parseLiteral: (ast: ValueNode) => ast as unknown as JsonValue[],
})
this.addScalarType('Json', JSONObjectResolver)
this.addScalarType('Upload', GraphQLUpload)