Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Latest commit

 

History

History
237 lines (209 loc) · 4.43 KB

variants.md

File metadata and controls

237 lines (209 loc) · 4.43 KB

Variant

A split variant

Relationships

  • Has many SplitUserVariants
  • Belongs to Split

Attributes

Attribute Type Description
name String A descriptive name
value JSON The content
weight Integer The likelihood of selecting (1 - 100)

Weighted sampling is optional. If variants have weights, they should sum to 100. If variants do not have weights, a random selection will be made.

Expected values for current split keys:

  • landing.text
    • value: { description: 'Some text' }
  • workflow.assignment
    • value: { description: 'Some text' }
  • workflow.advance
    • value: { accept: 'Some text', decline: 'Some text' }
  • mini-course.visible
    • value: { button: true, auto: true } (enabled/disabled)
  • subject.first-to-classify
    • value: { message: 'Some text' }
  • subject.first-to-classify.visible
    • value: { div: true } (enabled/disabled)

API

GET /variants
  • Scoped by project owner or collaborator roles
  • Site admins can access all variants
  • Filterable by project_id, key, and state
{
  "data": [{
    "id": "1",
    "type": "variants",
    "attributes": {
      "name": "Original",
      "value": {
        "description": "Original project description"
      },
      "weight": 50,
      "split_id": 1
    },
    "links": {
      "self": "/variants/1",
      "split": "/splits/1"
    }
  }],
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "/variants?page[number]=1&page[size]=1",
    "next": "/variants?page[number]=2&page[size]=1",
    "last": "/variants?page[number]=123&page[size]=1"
  }
}
GET /variants/:id
  • Publicly accessible
{
  "data": [{
    "id": "1",
    "type": "variants",
    "attributes": {
      "name": "Original",
      "value": {
        "description": "Original project description"
      },
      "weight": 50,
      "split_id": 1
    },
    "links": {
      "self": "/variants/1",
      "split": "/splits/1"
    }
  }],
  "jsonapi": {
    "version": "1.0"
  }
}
POST /variants
  • Accessible by project owners, collaborators, and site admins
Schema
{
  "properties": {
    "data": {
      "properties": {
        "split_id": {
          "oneOf": [{
            "type": "integer",
            "minimum": 1
          }, {
            "type": "string",
            "pattern": "^[1-9]\\d*$"
          }]
        },
        "name": {
          "type": "string"
        },
        "value": {
          "properties": {},
          "type": "object",
          "additionalProperties": true
        },
        "weight": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        }
      },
      "type": "object",
      "required": ["split_id", "name", "value"],
      "additionalProperties": false
    }
  },
  "type": "object",
  "required": ["data"]
}
Example
{
  "data": {
    "attributes": {
      "name": "Original",
      "value": {
        "description": "Original project description"
      }
    },
    "relationships": {
      "split": {
        "data": {
          "type": "splits",
          "id": "1"
        }
      }
    }
  }
}
PUT /variants/:id
  • Accessible by project owners, collaborators, and site admins
Schema
{
  "properties": {
    "data": {
      "properties": {
        "split_id": {
          "oneOf": [{
            "type": "integer",
            "minimum": 1
          }, {
            "type": "string",
            "pattern": "^[1-9]\\d*$"
          }]
        },
        "name": {
          "type": "string"
        },
        "value": {
          "properties": {},
          "type": "object",
          "additionalProperties": true
        },
        "weight": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        }
      },
      "type": "object",
      "additionalProperties": false
    }
  },
  "type": "object",
  "required": ["data"]
}
Example
{
  "data": {
    "attributes": {
      "value": {
        "description": "Better project description"
      }
    }
  }
}
DELETE /variants/:id
  • Accessible by project owners, collaborators, and site admins