A couple mirror match ladder tweaks. Made programmableMethods other code languages use proper code formatting.

This commit is contained in:
Nick Winter 2015-09-07 18:00:48 -07:00
parent 0549994693
commit 0d2d1ddad0
3 changed files with 10 additions and 13 deletions
app
server/queues/scoring

View file

@ -256,12 +256,7 @@ class CodeTreema extends TreemaNode.nodeMap.ace
constructor: -> constructor: ->
super(arguments...) super(arguments...)
@workingSchema.aceTabSize = 4 @workingSchema.aceTabSize = 4
@workingSchema.aceMode ?= mode if mode = codeLanguages[@keyForParent]
buildValueForEditing: (valEl, data) ->
super(valEl, data)
if not @workingSchema.aceMode and mode = codeLanguages[@keyForParent]
@editor.getSession().setMode mode
valEl
class CoffeeTreema extends CodeTreema class CoffeeTreema extends CodeTreema
constructor: -> constructor: ->

View file

@ -74,7 +74,7 @@ module.exports = class LadderSubmissionView extends CocoView
data: ajaxData data: ajaxData
success: success success: success
error: failure error: failure
if @mirrorSession if @mirrorSession and @mirrorSession.get('submittedCode')
# Also submit the mirrorSession after the main session submits successfully. # Also submit the mirrorSession after the main session submits successfully.
mirrorAjaxData = _.clone ajaxData mirrorAjaxData = _.clone ajaxData
mirrorAjaxData.session = @mirrorSession.id mirrorAjaxData.session = @mirrorSession.id

View file

@ -26,16 +26,18 @@ module.exports = createNewTask = (req, res) ->
validatePermissions = (req, sessionID, callback) -> validatePermissions = (req, sessionID, callback) ->
return callback 'You are unauthorized to submit that game to the simulator' unless req.user?.get('email') return callback 'You are unauthorized to submit that game to the simulator.' unless req.user?.get('email')
return callback null if req.user?.isAdmin() return callback null if req.user?.isAdmin()
findParameters = _id: sessionID findParameters = _id: sessionID
selectString = 'creator submittedCode code' selectString = 'creator submittedCode code'
LevelSession.findOne(findParameters).select(selectString).lean().exec (err, retrievedSession) -> LevelSession.findOne(findParameters).select(selectString).lean().exec (err, retrievedSession) =>
if err? then return callback err if err? then return callback err
userHasPermissionToSubmitCode = retrievedSession.creator is req.user?.id and userHasPermissionToSubmitCode = retrievedSession.creator is req.user?.id
not _.isEqual(retrievedSession.code, retrievedSession.submittedCode) unless userHasPermissionToSubmitCode then return callback 'You are unauthorized to submit that game to the simulator.'
unless userHasPermissionToSubmitCode then return callback 'You are unauthorized to submit that game to the simulator' # Disabling this for now, since mirror matches submit different transpiled code for the same source code.
#alreadySubmitted = _.isEqual(retrievedSession.code, retrievedSession.submittedCode)
#unless alreadySubmitted then return callback 'You have already submitted that exact code for simulation.'
callback null callback null