Path: blob/master/src/schemas/evaluation_schema.py
214 views
from src.schemas.constants import (1ARRAY_OF_STRINGS,2DEFAULT_SECTION_KEY,3FIELD_STRING_TYPE,4)56marking_score_regex = "-?(\\d+)(/(\\d+))?"78marking_score = {9"oneOf": [10{"type": "string", "pattern": marking_score_regex},11{"type": "number"},12]13}1415marking_object_properties = {16"additionalProperties": False,17"required": ["correct", "incorrect", "unmarked"],18"type": "object",19"properties": {20# TODO: can support streak marking if we allow array of marking_scores here21"correct": marking_score,22"incorrect": marking_score,23"unmarked": marking_score,24},25}2627EVALUATION_SCHEMA = {28"$schema": "https://json-schema.org/draft/2020-12/schema",29"$id": "https://github.com/Udayraj123/OMRChecker/tree/master/src/schemas/evaluation-schema.json",30"title": "Evaluation Schema",31"description": "OMRChecker evaluation schema i.e. the marking scheme",32"type": "object",33"additionalProperties": True,34"required": ["source_type", "options", "marking_schemes"],35"properties": {36"additionalProperties": False,37"source_type": {"type": "string", "enum": ["csv", "custom"]},38"options": {"type": "object"},39"marking_schemes": {40"type": "object",41"required": [DEFAULT_SECTION_KEY],42"patternProperties": {43f"^{DEFAULT_SECTION_KEY}$": marking_object_properties,44f"^(?!{DEFAULT_SECTION_KEY}$).*": {45"additionalProperties": False,46"required": ["marking", "questions"],47"type": "object",48"properties": {49"questions": {50"oneOf": [51FIELD_STRING_TYPE,52{53"type": "array",54"items": FIELD_STRING_TYPE,55},56]57},58"marking": marking_object_properties,59},60},61},62},63},64"allOf": [65{66"if": {"properties": {"source_type": {"const": "csv"}}},67"then": {68"properties": {69"options": {70"additionalProperties": False,71"required": ["answer_key_csv_path"],72"dependentRequired": {73"answer_key_image_path": [74"answer_key_csv_path",75"questions_in_order",76]77},78"type": "object",79"properties": {80"should_explain_scoring": {"type": "boolean"},81"answer_key_csv_path": {"type": "string"},82"answer_key_image_path": {"type": "string"},83"questions_in_order": ARRAY_OF_STRINGS,84},85}86}87},88},89{90"if": {"properties": {"source_type": {"const": "custom"}}},91"then": {92"properties": {93"options": {94"additionalProperties": False,95"required": ["answers_in_order", "questions_in_order"],96"type": "object",97"properties": {98"should_explain_scoring": {"type": "boolean"},99"answers_in_order": {100"oneOf": [101{102"type": "array",103"items": {104"oneOf": [105# "standard": single correct, multi-marked single-correct106# Example: "q1" --> '67'107{"type": "string"},108# "multiple-correct": multiple-correct (for ambiguous/bonus questions)109# Example: "q1" --> [ 'A', 'B' ]110{111"type": "array",112"items": {"type": "string"},113"minItems": 2,114},115# "multiple-correct-weighted": array of answer-wise weights (marking scheme not applicable)116# Example 1: "q1" --> [['A', 1], ['B', 2], ['C', 3]] or117# Example 2: "q2" --> [['A', 1], ['B', 1], ['AB', 2]]118{119"type": "array",120"items": {121"type": "array",122"items": False,123"minItems": 2,124"maxItems": 2,125"prefixItems": [126{"type": "string"},127marking_score,128],129},130},131# Multiple-correct with custom marking scheme132# ["A", ["1", "2", "3"]],133# [["A", "B", "AB"], ["1", "2", "3"]]134],135},136},137]138},139"questions_in_order": ARRAY_OF_STRINGS,140"enable_evaluation_table_to_csv": {141"type": "boolean",142"default": False,143},144},145}146}147},148},149],150}151152153