{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Assessment info",
    "description": "Configuration data for an assessment.",
    "type": "object",
    "additionalProperties": false,
    "required": [
        "uuid",
        "type",
        "title",
        "set",
        "number"
    ],
    "properties": {
        "uuid": {
            "description": "Unique identifier (UUID v4).",
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
        },
        "type": {
            "description": "Type of the assessment.",
            "enum": [
                "Homework",
                "Exam"
            ]
        },
        "title": {
            "description": "The title of the assessment (e.g., 'Derivatives and anti-derivatives').",
            "type": "string"
        },
        "set": {
            "description": "Which assessmentSet this one belongs to (e.g., 'Homework', 'Practice Quiz').",
            "type": "string"
        },
        "number": {
            "description": "The number of this assessment within the set (e.g., '1', '2R', '3B').",
            "type": "string"
        },
        "allowIssueReporting": {
            "description": "Whether to allow students to report issues for assessment questions",
            "type": "boolean",
            "default": true
        },
        "multipleInstance": {
            "description": "Whether to allow students to create additional instances of the assessment",
            "type": "boolean",
            "default": false
        },
        "shuffleQuestions": {
            "description": "Whether the questions will be shuffled in the student view of an assessment (Homework only)",
            "type": "boolean",
            "default": false
        },
        "allowAccess": {
            "description": "List of access rules for the assessment. Access is permitted if any access rule is satisfied.",
            "type": "array",
            "items": {
                "$ref": "#/definitions/accessRule"
            }
        },
        "text": {
            "description": "HTML text shown on the assessment overview page.",
            "type": "string"
        },
        "maxPoints": {
            "description": "The maximum number of points that can be earned for this assessment.",
            "type": "number"
        },
        "autoClose": {
            "description": "Whether to automatically close the assessment after a period of inactivity.",
            "type": "boolean",
            "default": true
        },
        "zones": {
            "description": "Array of \"zones\" in the assessment, each containing questions that can be randomized within the zone.",
            "type": "array",
            "items": {
                "$ref": "#/definitions/zone"
            }
        },
        "constantQuestionValue": {
            "description": "Whether to keep the value of a question constant after a student solves it correctly.",
            "type": "boolean",
            "default": false
        },
        "allowRealTimeGrading": {
            "description": "Removes the student \"Grade\" buttons to prevent real-time grading while the assessment is being taken.",
            "type": "boolean",
            "default": true
        },
        "requireHonorCode": {
            "description": "Requires the student to accept an honor code before starting exam assessments.",
            "type": "boolean",
            "default": true
        }
    },
    "definitions": {
        "accessRule": {
            "description": "An access rule that permits people to access this assessment. All restrictions in the rule must be satisfied for the rule to allow access.",
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "mode": {
                    "description": "The server mode required for access.",
                    "enum": [
                        "Public",
                        "Exam",
                        "SEB"
                    ]
                },
                "examUuid": {
                    "description": "The scheduler exam UUID for which a student must be registered.",
                    "type": "string",
                    "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"
                },
                "role": {
                    "description": "The minimum user role required for access.",
                    "enum": [
                        "Student",
                        "TA",
                        "Instructor"
                    ]
                },
                "uids": {
                    "description": "A list of UIDs (like 'username@example.com', one of which is required for access",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "credit": {
                    "description": "How much credit is awarded for doing the homework, as a percentage (100 means full credit).",
                    "type": "integer",
                    "minimum": 0
                },
                "startDate": {
                    "description": "The earliest date on which access is permitted.",
                    "type": "string"
                },
                "endDate": {
                    "description": "The latest date on which access is permitted.",
                    "type": "string"
                },
                "timeLimitMin": {
                    "description": "The time limit to complete the assessment, in minutes (only for Exams).",
                    "type": "integer",
                    "minimum": 0
                },
                "password": {
                    "description": "Password to begin the assessment (only for Exams).",
                    "type": "string"
                },
                "SEBConfig": {
                    "description": "Configuration related to Safe Exam Browser",
                    "type": "object",
                    "properties": {
                        "password": {
                            "description": "Password protect the SEB exam and config file",
                            "type": "string"
                        },
                        "quitPassword": {
                            "description": "If set, requires password to quit SEB other than visiting the quitURL page",
                            "type": "string"
                        },
                        "allowPrograms": {
                            "description": "Keyword array for allowed programs in SEB",
                            "type": "array",
                            "minItems": 0,
                            "items": {
                                "type": "string"
                            }
                        }
                    }
                },
                "showClosedAssessment": {
                    "description": "Whether the student can view the assessment after it has been closed",
                    "type": "boolean",
                    "default": true
                }
            }
        },
        "zone": {
            "type": "object",
            "properties": {
                "title": {
                    "description": "Zone title, displayed to the students at the top of the question list for the zone.",
                    "type": "string"
                },
                "maxPoints": {
                    "description": "Only this many of the points that are awarded for answering questions in this zone will count toward the total points.",
                    "type": "number"
                },
                "numberChoose": {
                    "description": "Number of questions to choose from this zone.",
                    "type": "integer",
                    "minimum": 0
                },
                "bestQuestions": {
                    "description": "Only this many of the questions in this zone, with the highest number of awarded points, will count toward the total points.",
                    "type": "integer",
                    "minimum": 0
                },
                "questions": {
                    "description": "Array of questions in the zone.",
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "$ref": "#/definitions/zoneQuestion"
                    }
                }
            },
            "required": [
                "questions"
            ]
        },
        "zoneQuestion": {
            "type": "object",
            "properties": {
                "points": {
                    "$ref": "#/definitions/points"
                },
                "maxPoints": {
                    "$ref": "#/definitions/pointsSingle"
                },
                "id": {
                    "$ref": "#/definitions/questionId"
                },
                "forceMaxPoints": {
                    "$ref": "#/definitions/forceMaxPoints"
                },
                "alternatives": {
                    "description": "Array of question alternatives to choose from.",
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "$ref": "#/definitions/questionAlternative"
                    }
                },
                "numberChoose": {
                    "description": "Number of questions to choose from this group.",
                    "type": "integer",
                    "minimum": 0,
                    "default": 1
                },
                "triesPerVariant": {
                    "description": "The maximum number of graded submissions allowed for each question instance.",
                    "type": "number",
                    "default": 1
                }
            }
        },
        "questionAlternative": {
            "type": "object",
            "properties": {
                "points": {
                    "$ref": "#/definitions/points"
                },
                "maxPoints": {
                    "$ref": "#/definitions/pointsSingle"
                },
                "id": {
                    "$ref": "#/definitions/questionId"
                },
                "forceMaxPoints": {
                    "$ref": "#/definitions/forceMaxPoints"
                },
                "triesPerVariant": {
                    "description": "The maximum number of graded submissions allowed for each question instance.",
                    "type": "number",
                    "default": 1
                }
            }
        },
        "points": {
            "oneOf": [
                {
                    "$ref": "#/definitions/pointsSingle"
                },
                {
                    "$ref": "#/definitions/pointsList"
                }
            ]
        },
        "pointsSingle": {
            "description": "A single point value.",
            "type": "number",
            "minimum": 0,
            "default": 1
        },
        "pointsList": {
            "description": "An array of point values.",
            "type": "array",
            "minItems": 1,
            "items": {
                "$ref": "#/definitions/points"
            }
        },
        "questionId": {
            "description": "Question ID (directory name of the question).",
            "type": "string"
        },
        "forceMaxPoints": {
            "description": "Whether to force this question to be awarded maximum points on a regrade.",
            "type": "boolean",
            "default": false
        }
    }
}