codecombat/app/schemas/models/level_session.coffee

322 lines
9.5 KiB
CoffeeScript
Raw Normal View History

c = require './../schemas'
2014-04-12 04:35:56 -04:00
LevelSessionPlayerSchema = c.object
id: c.objectId
links: [
{
rel: 'extra'
2014-06-30 22:16:26 -04:00
href: '/db/user/{($)}'
2014-04-12 04:35:56 -04:00
}
]
time:
type: 'Number'
changes:
type: 'Number'
LevelSessionLevelSchema = c.object {required: ['original', 'majorVersion'], links: [{rel: 'db', href: '/db/level/{(original)}/version/{(majorVersion)}'}]},
2014-04-12 04:35:56 -04:00
original: c.objectId({})
majorVersion:
type: 'integer'
minimum: 0
LevelSessionSchema = c.object
2014-06-30 22:16:26 -04:00
title: 'Session'
description: 'A single session for a given level.'
2014-08-23 19:06:41 -04:00
default:
codeLanguage: 'python'
submittedCodeLanguage: 'python'
2014-08-23 19:06:41 -04:00
playtime: 0
2014-04-12 04:35:56 -04:00
_.extend LevelSessionSchema.properties,
# denormalization
2015-01-30 17:45:34 -05:00
browser:
type: 'object'
2014-04-12 04:35:56 -04:00
creatorName:
type: 'string'
levelName:
type: 'string'
levelID:
type: 'string'
multiplayer:
type: 'boolean'
creator: c.objectId
links:
[
{
rel: 'extra'
2014-06-30 22:16:26 -04:00
href: '/db/user/{($)}'
2014-04-12 04:35:56 -04:00
}
]
created: c.date
title: 'Created'
readOnly: true
changed: c.date
title: 'Changed'
readOnly: true
Refactor and update teacher-dashboard This updates TeacherClassView and ActivateLicensesModal to use the new state-based rendering system, making it much snappier and less clunky feeling, and improving data consistency. Features also included in this: - Hover details for progress dots in TeacherClassView - ActivateLicensesModal has an "All Students" option and better handling when you switch classrooms in the dropdown - Unenrolled/Unassigned students are shown separately in Course Progress and can be enrolled/assigned from there. Add Back to Classes button on demo-request submitted view Delete temporary patch file Show unenrolled students separately in Course Progress (incomplete) Migrate TeacherClassView to use orchestrator-style events, add unassigned students section, replace bootstrap tabs with state-based tabs Convert missed instance variables to be in @state Fix merge errors (in progress) Convert a bunch of stuff to use state and events (removing student needs fixing) Fix up modal interactions, some bugs Switch state to be a Model, sync up course dropdowns Convert student sorting to use state model Add hover tooltips to TeacherClassView Students tab Don't keep tooltip open when you mouse into it Add dateFirstCompleted and Course Progress tooltips Course Overview progress tooltips Refactor ActivateLicensesModal Refactors: Uses state object for view state Passes back the updated users in 'redeem-users' event instead of modifying given collection Features: Add 'All Students' dropdown option Don't forget checked students if you change classroom from dropdown, but only enroll the ones visible when you click "Enroll (n) Students" Separate enrolled students; improve style Rearrange error text Disable enroll-students button when none are selected Remove console.logs Move style-flat variables to another file This prevents .style-flat from being copied in multiple times to the resulting CSS. Show Unarchive button when on the page for an archived class Move text to en.coffee Only sort students on first classroom sync Fix merge error Handle sessions missing completion date in view logic instead of migration script Listen to classroom sync more than once in case it gets unarchived
2016-04-19 16:44:48 -04:00
dateFirstCompleted: c.stringDate
title: 'Completed'
readOnly: true
2014-04-12 04:35:56 -04:00
team: c.shortString()
level: LevelSessionLevelSchema
screenshot:
type: 'string'
heroConfig: c.HeroConfigSchema
2014-04-12 04:35:56 -04:00
state: c.object {},
complete:
type: 'boolean'
scripts: c.object {},
ended:
type: 'object'
additionalProperties:
type: 'number'
currentScript:
type: [
'null'
'string'
]
currentScriptOffset:
type: 'number'
2015-11-10 18:22:09 -05:00
selected: # Not tracked any more, delete with old level types
2014-04-12 04:35:56 -04:00
type: [
'null'
'string'
]
playing:
2015-11-10 18:22:09 -05:00
type: 'boolean' # Not tracked any more, delete with old level types
2014-04-12 04:35:56 -04:00
frame:
2015-11-10 18:22:09 -05:00
type: 'number' # Not tracked any more, delete with old level types
thangs: # ... what is this? Is this used?
2014-04-12 04:35:56 -04:00
type: 'object'
additionalProperties:
title: 'Thang'
type: 'object'
properties:
methods:
type: 'object'
additionalProperties:
title: 'Thang Method'
type: 'object'
properties:
metrics:
type: 'object'
source:
type: 'string'
goalStates:
type: 'object'
description: 'Maps Goal ID on a goal state object'
additionalProperties:
title: 'Goal State'
type: 'object'
properties:
status: enum: ['failure', 'incomplete', 'success']
submissionCount:
description: 'How many times the session has been submitted for real-time playback (can affect the random seed).'
type: 'integer'
minimum: 0
difficulty:
description: 'The highest difficulty level beaten, for use in increasing-difficulty replayable levels.'
type: 'integer'
minimum: 0
lastUnsuccessfulSubmissionTime: c.date
description: 'The last time that real-time submission was started without resulting in a win.'
flagHistory:
description: 'The history of flag events during the last real-time playback submission.'
type: 'array'
items: c.object {required: ['player', 'color', 'time', 'active']},
player: {type: 'string'}
team: {type: 'string'}
color: {type: 'string', enum: ['green', 'black', 'violet']}
time: {type: 'number', minimum: 0}
active: {type: 'boolean'}
pos: c.object {required: ['x', 'y']},
x: {type: 'number'}
y: {type: 'number'}
source: {type: 'string', enum: ['click']} # Do not store 'code' flag events in the session.
2015-01-31 00:36:36 -05:00
topScores: c.array {},
c.object {},
type: c.shortString('enum': ['time', 'damage-taken', 'damage-dealt', 'gold-collected', 'difficulty'])
date: c.date
description: 'When the submission achieving this score happened.'
score: {type: 'number'} # Store 'time' and 'damage-taken' as negative numbers so the index works.
2014-04-12 04:35:56 -04:00
code:
type: 'object'
additionalProperties:
type: 'object'
additionalProperties:
type: 'string'
2014-08-30 16:43:56 -04:00
format: 'code'
2014-06-30 22:16:26 -04:00
codeLogs:
type: 'array'
2014-05-14 19:41:01 -04:00
codeLanguage:
type: 'string'
2014-06-30 22:16:26 -04:00
playtime:
type: 'number'
title: 'Playtime'
description: 'The total playtime on this session'
2014-06-30 22:16:26 -04:00
2014-04-12 04:35:56 -04:00
teamSpells:
type: 'object'
additionalProperties:
type: 'array'
players:
type: 'object'
chat:
type: 'array'
ladderAchievementDifficulty:
type: 'integer'
minimum: 0
description: 'What ogre AI difficulty, 0-4, this human session has beaten in a multiplayer arena.'
2014-04-12 04:35:56 -04:00
meanStrength:
type: 'number'
standardDeviation:
2014-06-30 22:16:26 -04:00
type: 'number'
2014-04-12 04:35:56 -04:00
minimum: 0
totalScore:
type: 'number'
submitted:
type: 'boolean'
submitDate: c.date
title: 'Submitted'
submittedCode:
type: 'object'
additionalProperties:
type: 'object'
additionalProperties:
type: 'string'
2014-08-30 16:43:56 -04:00
format: 'code'
2014-05-13 13:49:02 -04:00
submittedCodeLanguage:
type: 'string'
2014-06-30 22:16:26 -04:00
2014-05-13 13:49:02 -04:00
transpiledCode:
type: 'object'
additionalProperties:
type: 'object'
additionalProperties:
type: 'string'
2014-08-30 16:43:56 -04:00
format: 'code'
2014-04-12 04:35:56 -04:00
isRanking:
type: 'boolean'
description: 'Whether this session is still in the first ranking chain after being submitted.'
randomSimulationIndex:
type: 'number'
description: 'A random updated every time the game is randomly simulated for a uniform random distribution of simulations (see #2448).'
minimum: 0
maximum: 1
2014-04-12 04:35:56 -04:00
unsubscribed:
type: 'boolean'
description: 'Whether the player has opted out of receiving email updates about ladder rankings for this session.'
numberOfWinsAndTies:
type: 'number'
numberOfLosses:
type: 'number'
scoreHistory:
type: 'array'
title: 'Score History'
description: 'A list of objects representing the score history of a session'
items:
title: 'Score History Point'
description: 'An array with the format [unix timestamp, totalScore]'
type: 'array'
items:
type: 'number'
matches:
type: 'array'
title: 'Matches'
description: 'All of the matches a submitted session has played in its current state.'
items:
type: 'object'
properties:
date: c.date
title: 'Date computed'
description: 'The date a match was computed.'
playtime:
title: 'Playtime so far'
description: 'The total seconds of playtime on this session when the match was computed. Not currently tracked.'
type: 'number'
2014-04-12 04:35:56 -04:00
metrics:
type: 'object'
title: 'Metrics'
description: 'Various information about the outcome of a match.'
properties:
rank:
title: 'Rank'
description: 'A 0-indexed ranking representing the player\'s standing in the outcome of a match'
type: 'number'
opponents:
type: 'array'
title: 'Opponents'
description: 'An array containing information about the opponents\' sessions in a given match.'
items:
type: 'object'
properties:
sessionID:
title: 'Opponent Session ID'
description: 'The session ID of an opponent.'
2014-06-30 22:16:26 -04:00
type: ['object', 'string', 'null']
2014-04-12 04:35:56 -04:00
userID:
title: 'Opponent User ID'
description: 'The user ID of an opponent'
2014-06-30 22:16:26 -04:00
type: ['object', 'string', 'null']
name:
title: 'Opponent name'
description: 'The name of the opponent'
2014-06-30 22:16:26 -04:00
type: ['string', 'null']
totalScore:
title: 'Opponent total score'
description: 'The totalScore of a user when the match was computed'
2014-06-30 22:16:26 -04:00
type: ['number', 'string', 'null']
2014-04-12 04:35:56 -04:00
metrics:
type: 'object'
properties:
rank:
title: 'Opponent Rank'
description: 'The opponent\'s ranking in a given match'
type: 'number'
codeLanguage:
type: ['string', 'null'] # 'null' in case an opponent session got corrupted, don't care much here
description: 'What submittedCodeLanguage the opponent used during the match'
simulator: {type: 'object', description: 'Holds info on who simulated the match, and with what tools.'}
randomSeed: {description: 'Stores the random seed that was used during this match.'}
2014-04-12 04:35:56 -04:00
leagues:
c.array {description: 'Multiplayer data for the league corresponding to Clans and CourseInstances the player is a part of.'},
c.object {},
leagueID: {type: 'string', description: 'The _id of a Clan or CourseInstance the user belongs to.'}
stats: c.object {description: 'Multiplayer match statistics corresponding to this entry in the league.'}
lastOpponentSubmitDate: c.date {description: 'The submitDate of the last league session we selected to play against (for playing through league opponents in order).'}
LevelSessionSchema.properties.leagues.items.properties.stats.properties = _.pick LevelSessionSchema.properties, 'meanStrength', 'standardDeviation', 'totalScore', 'numberOfWinsAndTies', 'numberOfLosses', 'scoreHistory', 'matches'
2014-04-12 04:35:56 -04:00
c.extendBasicProperties LevelSessionSchema, 'level.session'
c.extendPermissionsProperties LevelSessionSchema, 'level.session'
module.exports = LevelSessionSchema