mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-03 01:14:46 -04:00
A few poll fixes.
This commit is contained in:
parent
8c1de9dfa2
commit
9c99fc455a
6 changed files with 132 additions and 116 deletions
app
models
styles/play/modal
templates/play/modal
views/play/modal
server
|
@ -118,6 +118,7 @@ module.exports = class User extends CocoModel
|
|||
@announcesActionAudioGroup
|
||||
|
||||
# Signs and Portents was receiving updates after test started, and also had a big bug on March 4, so just look at test from March 5 on.
|
||||
# ... and stopped working well until another update on March 10, so maybe March 11+...
|
||||
getFourthLevelGroup: ->
|
||||
return @fourthLevelGroup if @fourthLevelGroup
|
||||
group = me.get('testGroupNumber') % 8
|
||||
|
|
|
@ -118,14 +118,16 @@
|
|||
|
||||
.progress-bar
|
||||
background-color: rgb(245, 170, 49)
|
||||
border-radius: 10px
|
||||
border: 3px solid rgb(45, 36, 29)
|
||||
@include transition(none)
|
||||
|
||||
&.votes-cell
|
||||
max-width: 34px
|
||||
|
||||
.vote-percentage.badge
|
||||
.badge
|
||||
background-color: rgb(245, 170, 49)
|
||||
text-shadow: -1px -1px 0px black, 1px 1px 0px black, -1px 1px 0px black, 1px -1px 0px black
|
||||
color: rgb(45, 36, 29)
|
||||
|
||||
table:not(.answered)
|
||||
tr
|
||||
|
|
|
@ -23,6 +23,9 @@ block modal-body-content
|
|||
.progress-bar
|
||||
td.votes-cell
|
||||
span.badge.vote-percentage
|
||||
if me.isAdmin()
|
||||
td.votes-cell
|
||||
span.badge.vote-count
|
||||
|
||||
.random-gems-container-wrapper
|
||||
.random-gems-container
|
||||
|
|
|
@ -66,6 +66,7 @@ module.exports = class PollModal extends ModalView
|
|||
votePercentage = Math.round(100 * votes / totalVotes) + '%'
|
||||
$answer.find('.progress-bar').css('width', '0%').animate({width: widthPercentage}, 'slow')
|
||||
$answer.find('.vote-percentage').text votePercentage
|
||||
$answer.find('.vote-count').text votes if me.isAdmin()
|
||||
|
||||
@trigger 'vote-updated'
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ Handler = require '../commons/Handler'
|
|||
LocalMongo = require '../../app/lib/LocalMongo'
|
||||
util = require '../../app/core/utils'
|
||||
LevelSession = require '../levels/sessions/LevelSession'
|
||||
UserPollsRecord = require '../polls/UserPollsRecord'
|
||||
|
||||
class EarnedAchievementHandler extends Handler
|
||||
modelClass: EarnedAchievement
|
||||
|
@ -191,8 +192,16 @@ class EarnedAchievementHandler extends Handler
|
|||
# Keep track of a user's already achieved in order to set the notified values correctly
|
||||
userID = user.get('_id').toHexString()
|
||||
|
||||
# Fetch a user's poll record so we can get the gems they should have from that.
|
||||
UserPollsRecord.findOne {user: userID}, (err, userPollsRecord) ->
|
||||
log.error err if err
|
||||
pollGems = 0
|
||||
for pollID, reward of userPollsRecord?.get('rewards') or {}
|
||||
pollGems += Math.ceil 2 * reward.random * reward.level
|
||||
|
||||
# Fetch all of a user's earned achievements
|
||||
EarnedAchievement.find {user: userID}, (err, alreadyEarned) ->
|
||||
log.error err if err
|
||||
alreadyEarnedIDs = []
|
||||
previousPoints = 0
|
||||
previousRewards = heroes: [], items: [], levels: [], gems: 0
|
||||
|
@ -275,7 +284,7 @@ class EarnedAchievementHandler extends Handler
|
|||
updateKey = "earned.#{rewardType}"
|
||||
if rewardType is 'gems'
|
||||
if recalculatingAll
|
||||
update.$set[updateKey] = rewards
|
||||
update.$set[updateKey] = rewards + pollGems
|
||||
else
|
||||
update.$inc[updateKey] = rewards - previousRewards.gems
|
||||
else
|
||||
|
|
|
@ -32,7 +32,7 @@ PollHandler = class PollHandler extends Handler
|
|||
@sendSuccess res, @formatEntity(req, poll)
|
||||
|
||||
findPollPriority: (lastPollID, callback) ->
|
||||
return callback null, -9001 #unless lastPollID
|
||||
return callback null, -9001 unless lastPollID
|
||||
Poll.findById mongoose.Types.ObjectId(lastPollID), 'priority', {lean: true}, (err, poll) ->
|
||||
callback err, poll?.priority
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue