static/js-parsons/parsons.js
function(options) {
	 // Contains line objects of the user-draggable code.
	 // The order is not meaningful (unchanged from the initial state) but
	 // indent property for each line object is updated as the user moves
	 // codelines around. (see parseCode for line object description)
     this.modified_lines = [];
     // contains line objects of distractors (see parseCode for line object description)
     this.extra_lines = [];
     // contains line objects (see parseCode for line object description)
     this.model_solution = [];
     
     //To collect statistics, feedback should not be based on this
     this.user_actions = [];
     
     //State history for feedback purposes
     this.state_path = [];
     this.states = {};
     
     var defaults = {
       'incorrectSound': false,
       'x_indent': 50,
       'can_indent': true,
       'feedback_cb': false,
       'first_error_only': true,
       'max_wrong_lines': 10,
       'lang': 'en',
       'toggleSeparator': '::'
     };
     
     this.options = jQuery.extend({}, defaults, options);
     this.feedback_exists = false;
     this.id_prefix = options['sortableId'] + 'codeline';
     if (translations.hasOwnProperty(this.options.lang)) {
       this.translations = translations[this.options.lang];
     } else {
       this.translations = translations['en'];
     }

     // translate trash_label and solution_label
     if (!this.options.hasOwnProperty("trash_label")) {
         this.options.trash_label = this.translations.trash_label;
     }
     if (!this.options.hasOwnProperty("solution_label")) {
         this.options.solution_label = this.translations.solution_label;
     }
     this.FEEDBACK_STYLES = { 'correctPosition' : 'correctPosition',
                              'incorrectPosition' : 'incorrectPosition',
                              'correctIndent' : 'correctIndent',
                              'incorrectIndent' : 'incorrectIndent'};

    // use grader passed as an option if defined and is a function
    if (this.options.grader && _.isFunction(this.options.grader)) {
      this.grader = new this.options.grader(this);
    } else {
      // initialize the grader
      if (typeof(this.options.unittests) !== "undefined") { /// unittests are specified
        this.grader = new UnitTestGrader(this);
      } else if (typeof(this.options.vartests) !== "undefined") { /// tests for variable values
        this.grader = new VariableCheckGrader(this);
      } else { // "traditional" parson feedback
        this.grader = new LineBasedGrader(this);
      }
    }
   }
function(options) {
	 // Contains line objects of the user-draggable code.
	 // The order is not meaningful (unchanged from the initial state) but
	 // indent property for each line object is updated as the user moves
	 // codelines around. (see parseCode for line object description)
     this.modified_lines = [];
     // contains line objects of distractors (see parseCode for line object description)
     this.extra_lines = [];
     // contains line objects (see parseCode for line object description)
     this.model_solution = [];
     
     //To collect statistics, feedback should not be based on this
     this.user_actions = [];
     
     //State history for feedback purposes
     this.state_path = [];
     this.states = {};
     
     var defaults = {
       'incorrectSound': false,
       'x_indent': 50,
       'can_indent': true,
       'feedback_cb': false,
       'first_error_only': true,
       'max_wrong_lines': 10,
       'lang': 'en',
       'toggleSeparator': '::'
     };
     
     this.options = jQuery.extend({}, defaults, options);
     this.feedback_exists = false;
     this.id_prefix = options['sortableId'] + 'codeline';
     if (translations.hasOwnProperty(this.options.lang)) {
       this.translations = translations[this.options.lang];
     } else {
       this.translations = translations['en'];
     }

     // translate trash_label and solution_label
     if (!this.options.hasOwnProperty("trash_label")) {
         this.options.trash_label = this.translations.trash_label;
     }
     if (!this.options.hasOwnProperty("solution_label")) {
         this.options.solution_label = this.translations.solution_label;
     }
     this.FEEDBACK_STYLES = { 'correctPosition' : 'correctPosition',
                              'incorrectPosition' : 'incorrectPosition',
                              'correctIndent' : 'correctIndent',
                              'incorrectIndent' : 'incorrectIndent'};

    // use grader passed as an option if defined and is a function
    if (this.options.grader && _.isFunction(this.options.grader)) {
      this.grader = new this.options.grader(this);
    } else {
      // initialize the grader
      if (typeof(this.options.unittests) !== "undefined") { /// unittests are specified
        this.grader = new UnitTestGrader(this);
      } else if (typeof(this.options.vartests) !== "undefined") { /// tests for variable values
        this.grader = new VariableCheckGrader(this);
      } else { // "traditional" parson feedback
        this.grader = new LineBasedGrader(this);
      }
    }
   }
function ( options ) { // Contains line objects of the user-draggable code. // The order is not meaningful (unchanged from the initial state) but // indent property for each line object is updated as the user moves // codelines around. (see parseCode for line object description) this . modified_lines = [ ] ; // contains line objects of distractors (see parseCode for line object description) this . extra_lines = [ ] ; // contains line objects (see parseCode for line object description) this . model_solution = [ ] ; //To collect statistics, feedback should not be based on this this . user_actions = [ ] ; //State history for feedback purposes this . state_path = [ ] ; this . states = { } ; var defaults = { 'incorrectSound' : false , 'x_indent' : 50 , 'can_indent' : true , 'feedback_cb' : false , 'first_error_only' : true , 'max_wrong_lines' : 10 , 'lang' : 'en' , 'toggleSeparator' : '::' } ; this . options = jQuery . extend ( { } , defaults , options ) ; this . feedback_exists = false ; this . id_prefix = options [ 'sortableId' ] + 'codeline' ; if ( translations . hasOwnProperty ( this . options . lang ) ) { this . translations = translations [ this . options . lang ] ; } else { this . translations = translations [ 'en' ] ; } // translate trash_label and solution_label if ( ! this . options . hasOwnProperty ( "trash_label" ) ) { this . options . trash_label = this . translations . trash_label ; } if ( ! this . options . hasOwnProperty ( "solution_label" ) ) { this . options . solution_label = this . translations . solution_label ; } this . FEEDBACK_STYLES = { 'correctPosition' : 'correctPosition' , 'incorrectPosition' : 'incorrectPosition' , 'correctIndent' : 'correctIndent' , 'incorrectIndent' : 'incorrectIndent' } ; // use grader passed as an option if defined and is a function if ( this . options . grader && _ . isFunction ( this . options . grader ) ) { this . grader = new this . options . grader ( this ) ; } else { // initialize the grader if ( typeof ( this . options . unittests ) !== "undefined" ) { /// unittests are specified this . grader = new UnitTestGrader ( this ) ; } else if ( typeof ( this . options . vartests ) !== "undefined" ) { /// tests for variable values this . grader = new VariableCheckGrader ( this ) ; } else { // "traditional" parson feedback this . grader = new LineBasedGrader ( this ) ; } } }
Creates a parsons widget. Init must be called after creating an object.
Creates a parsons widget . Init must be called after creating an object .