Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
address @spicyj's review comments for on-demand parsing of script + s…
Browse files Browse the repository at this point in the history
…tyle: always empty style tag for dynamically-loaded exercises in makeProblem
  • Loading branch information
divad12 committed Dec 14, 2011
1 parent 87c2c5c commit 188b2dc
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions khan-exercise.js
Expand Up @@ -770,12 +770,12 @@ var Khan = (function() {
.animate( { marginTop: 0 }, /* duration */ 365, next );
});

// Was this exercise's data and HTML loaded already?
// Was this exercise's data and HTML loaded by loadExercise already?
var isLoaded = exercises.filter(function() {
return jQuery.data( this, "name" ) === exid;
}).length;

// Load all unloaded exercises
// Load all non-loadExercise loaded exercises
if ( !isLoaded ) {
loadExercise.call( jQuery( '<div data-name="' + exid + '">' ) );

Expand Down Expand Up @@ -3003,9 +3003,7 @@ var Khan = (function() {
result.push( match[1] );
}

if ( result.length ) {
exerciseElem.data( tag, result );
}
exerciseElem.data( tag, result );
});

remoteCount--;
Expand Down

2 comments on commit 188b2dc

@sophiebits
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you store the style for the original exercise anywhere?

@divad12
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good observation. :)

For summatives, we always load all exercises with loadExercise, so that's fine. For review mode, it's a bit of a hack: we don't store the style for the original exercise, but we will call loadExercise to load it again anyway if it comes up, because the original exercise's element doesn't have .data('name'), which we use in maybeEnqueueReviewExercises to determine which exercises are loaded. Yeah, pretty gross implicit dependencies. :(

It's probably better to just always store the style and script tags for the original exercise, but I haven't bothered yet.

Please sign in to comment.