Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix width problems in reading_tables_2

Summary:
Lint

Merge pull request #33787 from xymostech/fix-33675

Fix width problems in reading_tables_2

Remove the solution fallback

Fix fallbacks in answer types

Because `undefined + ""` produces the string `"undefined"`, fallbacks
did not accurately show that they were not available. This causes
some/all of the problems to inaccurately never report that an answer was
not entered. This should fix that.

Fix #33834 regression introduced by new answer-types.js

The multiple answer type wasn't properly tracking data-forms for each element

Restore acceptable format defaulting for multiple answer type

In the case where a "multiple" answer-type doesn't have any examples defined
and contains only one input element, inherit the acceptable formats from that
single input element.

Merge pull request #33803 from xymostech/fix-fallback

Fix fallbacks in answer types. fix #33883

Merge pull request #33804 from xymostech/fix-33780

Fix #33780

call attemptError on pageUnload

Test Plan:
Test http://localhost:8000/exercises/multiplying_mixed_numbers_1.html?debug&problem=0&seed=7 to verify that 23/3 is not accepted after this fix.

Verify acceptable answers show up for
    http://localhost:8000/exercises/one_step_equations.html

Reviewers: kamens

Differential Revision: http://phabricator.khanacademy.org/D925

Auditors: emily
  • Loading branch information...
commit 9bf46a5150a9fdc5c3d2ff6f43d181627b73e2c9 1 parent 6935430
@tzjames tzjames authored
Showing with 12 additions and 34 deletions.
  1. +12 −34 khan-exercise.js
View
46 khan-exercise.js
@@ -2111,57 +2111,25 @@ var Khan = (function() {
var data = buildAttemptData(pass, ++attempts, JSON.stringify(guess), curTime);
debugLog("attempt " + JSON.stringify(data));
- // Saving the current state of problems done before the attempt so
- // that it is stored in a closure and we can rely on resetting to
- // this current state if an error is thrown on page exit.
- var curTotalDone = pass === true ? problemNum : problemNum - 1;
-
request("problems/" + problemNum + "/attempt", data, function() {
// TODO: Save locally if offline
$(Khan).trigger("attemptSaved");
}, function(xhr) {
+ // Alert any listeners of the error before reload
+ $(Khan).trigger("attemptError", userExercise);
if (xhr && xhr.readyState == 0) {
// This path gets called when there is a broken pipe during
// page unload- browser navigating away during ajax request
// See http://stackoverflow.com/questions/1370322/jquery-ajax-fires-error-callback-on-window-unload
-
- if(requestQueue["attempt_hint_queue"].queue().length > 1) {
- // if there are other requests left in the request
- // queue then they will not ever execute and the user's
- // work is lost. In order to avoid problem out of order
- // when the page is reloaded we need to reset the
- // totalDone in the SessionStorage to what it would
- // have been when this request finishes executing.
- //
- // If we run into problems with resetting the cache
- // in the future we can instead do
- // $(Khan).trigger("attemptError", userExercise);
- // which will clear the cache. This would not fix the
- // case of users hitting the back button, which would
- // cause the cache to be reverted to what it was when
- // the page initially loaded and cause out of order
- // errors.
- //
- // If in the future people complain about problems
- // being lost we could consider doing a
- // window.onbeforeunload = function (e) {
- // return 'Problems are being saved. Are you sure?';
- // };
- userExercise.totalDone = curTotalDone;
- $(Khan).trigger("attemptAborted", userExercise);
- }
return;
}
// Error during submit. Disable the page and ask users to
// reload in an attempt to get updated data.
- // Alert any listeners of the error before reload
- $(Khan).trigger("attemptError", userExercise);
-
// Hide the page so users don't continue
$("#problem-and-answer").css("visibility", "hidden");
@@ -2909,6 +2877,16 @@ var Khan = (function() {
sendRequest();
}
+ // If there are any requests left in the queue when the window unloads
+ // then we will have permanently lost their answers and will need to
+ // clear the session cache, to make sure we don't override what is
+ // passed down from the servers
+ $(window).unload(function() {
+ if(requestQueue["attempt_hint_queue"].queue().length) {
+ $(Khan).trigger("attemptError", userExercise);
+ }
+ });
+
// Trigger an apiRequestStarted event here, and not in the inner sendRequest()
// function, because listeners should know an API request is waiting as
// soon as it gets queued up.
Please sign in to comment.
Something went wrong with that request. Please try again.