Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Stephen Gillon
11,996 PointsHelp with code plz! Value for drag and drop only counts as 1 instead of values given. No issues with my multiple choice.
I believe the problem could lie with the .change function because research tells me that it only works on input, select, and textarea. My values for my drag and drop question are draggable links. Is this the only problem? Take a look. >> https://w.trhou.se/goefsrmy92
1 Answer
Steven Parker
243,658 PointsYou can just modify the code that tallies on "next".
That code I gave you before that counts up the correct answers when you click the "next" button can be modified to give 3 points per correct answer but limit the total to 20:
if (currentQuestion == 0) {
answers.question1 = $("#routed, #routing").find("a").filter(function() {
return $(this).css('background-color') == 'rgb(0, 128, 0)';
}).length * 3;
if (answers.question1 > 20) answers.question1 = 20;
}
Unless you really want a specific one of them to be worth less, this might be an expedient solution. Also, I don't think you can assign a value attribute to an anchor (a) element.
Steven Parker
243,658 PointsSteven Parker
243,658 PointsThis is the same code as before, but with "
* 3" added to multiply the one point from before and make it 3. Then there's an added test to see if the total went over 20 and put it back to 20.I guarantee that this code does work, as long as you use it to replace lines 19 through 24 of your snapshot code.
Stephen Gillon
11,996 PointsStephen Gillon
11,996 PointsThanks again Steven Parker ! It does indeed! I got a few things to add to my test , but will be sure to let you see the final! Happy Friday!