mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Include transpiled code in submission process
This commit is contained in:
parent
9f9d651b3b
commit
a1360d6cb8
2 changed files with 34 additions and 3 deletions
|
@ -182,8 +182,15 @@ module.exports = class MyMatchesTabView extends CocoView
|
||||||
failure = (jqxhr, textStatus, errorThrown) =>
|
failure = (jqxhr, textStatus, errorThrown) =>
|
||||||
console.log jqxhr.responseText
|
console.log jqxhr.responseText
|
||||||
@setRankingButtonText(button, 'failed')
|
@setRankingButtonText(button, 'failed')
|
||||||
|
transpiledCode = @transpileSession session
|
||||||
|
|
||||||
|
ajaxData =
|
||||||
|
session: sessionID
|
||||||
|
levelID: @level.id
|
||||||
|
originalLevelID: @level.attributes.original
|
||||||
|
levelMajorVersion: @level.attributes.version.major
|
||||||
|
transpiledCode: transpiledCode
|
||||||
|
|
||||||
ajaxData = {session: sessionID, levelID: @level.id, originalLevelID: @level.attributes.original, levelMajorVersion: @level.attributes.version.major}
|
|
||||||
$.ajax '/queue/scoring', {
|
$.ajax '/queue/scoring', {
|
||||||
type: 'POST'
|
type: 'POST'
|
||||||
data: ajaxData
|
data: ajaxData
|
||||||
|
@ -191,6 +198,28 @@ module.exports = class MyMatchesTabView extends CocoView
|
||||||
error: failure
|
error: failure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transpileSession: (session) ->
|
||||||
|
submittedCode = session.get('code')
|
||||||
|
transpiledCode = {}
|
||||||
|
for thang, spells of submittedCode
|
||||||
|
transpiledCode[thang] = {}
|
||||||
|
for spellID, spell of spells
|
||||||
|
#DRY this
|
||||||
|
aetherOptions =
|
||||||
|
problems: {}
|
||||||
|
language: "javascript"
|
||||||
|
functionName: spellID
|
||||||
|
functionParameters: []
|
||||||
|
yieldConditionally: spellID is "plan"
|
||||||
|
globals: ['Vector', '_']
|
||||||
|
protectAPI: true
|
||||||
|
includeFlow: false
|
||||||
|
if spellID is "hear" then aetherOptions["functionParameters"] = ["speaker","message","data"]
|
||||||
|
|
||||||
|
aether = new Aether aetherOptions
|
||||||
|
transpiledCode[thang][spellID] = aether.transpile spell
|
||||||
|
transpiledCode
|
||||||
|
|
||||||
setRankingButtonText: (rankButton, spanClass) ->
|
setRankingButtonText: (rankButton, spanClass) ->
|
||||||
rankButton.find('span').addClass('hidden')
|
rankButton.find('span').addClass('hidden')
|
||||||
rankButton.find(".#{spanClass}").removeClass('hidden')
|
rankButton.find(".#{spanClass}").removeClass('hidden')
|
||||||
|
|
|
@ -104,13 +104,14 @@ module.exports.createNewTask = (req, res) ->
|
||||||
requestSessionID = req.body.session
|
requestSessionID = req.body.session
|
||||||
originalLevelID = req.body.originalLevelID
|
originalLevelID = req.body.originalLevelID
|
||||||
currentLevelID = req.body.levelID
|
currentLevelID = req.body.levelID
|
||||||
|
transpiledCode = req.body.transpiledCode
|
||||||
requestLevelMajorVersion = parseInt(req.body.levelMajorVersion)
|
requestLevelMajorVersion = parseInt(req.body.levelMajorVersion)
|
||||||
|
|
||||||
async.waterfall [
|
async.waterfall [
|
||||||
validatePermissions.bind(@,req,requestSessionID)
|
validatePermissions.bind(@,req,requestSessionID)
|
||||||
fetchAndVerifyLevelType.bind(@,currentLevelID)
|
fetchAndVerifyLevelType.bind(@,currentLevelID)
|
||||||
fetchSessionObjectToSubmit.bind(@, requestSessionID)
|
fetchSessionObjectToSubmit.bind(@, requestSessionID)
|
||||||
updateSessionToSubmit
|
updateSessionToSubmit.bind(@, transpiledCode)
|
||||||
fetchInitialSessionsToRankAgainst.bind(@, requestLevelMajorVersion, originalLevelID)
|
fetchInitialSessionsToRankAgainst.bind(@, requestLevelMajorVersion, originalLevelID)
|
||||||
generateAndSendTaskPairsToTheQueue
|
generateAndSendTaskPairsToTheQueue
|
||||||
], (err, successMessageObject) ->
|
], (err, successMessageObject) ->
|
||||||
|
@ -163,10 +164,11 @@ fetchSessionObjectToSubmit = (sessionID, callback) ->
|
||||||
query.exec (err, session) ->
|
query.exec (err, session) ->
|
||||||
callback err, session?.toObject()
|
callback err, session?.toObject()
|
||||||
|
|
||||||
updateSessionToSubmit = (sessionToUpdate, callback) ->
|
updateSessionToSubmit = (transpiledCode, sessionToUpdate, callback) ->
|
||||||
sessionUpdateObject =
|
sessionUpdateObject =
|
||||||
submitted: true
|
submitted: true
|
||||||
submittedCode: sessionToUpdate.code
|
submittedCode: sessionToUpdate.code
|
||||||
|
transpiledCode: transpiledCode
|
||||||
submitDate: new Date()
|
submitDate: new Date()
|
||||||
meanStrength: 25
|
meanStrength: 25
|
||||||
standardDeviation: 25/3
|
standardDeviation: 25/3
|
||||||
|
|
Loading…
Reference in a new issue