<commit_before>var viewModel;

$(document).ready(function() {
//indent every line in given string with n tab characters

    var Variable = Editor.Variable,
        Ruleset = Editor.Ruleset;

    function Question(data)
    {
        this.name = ko.observable(questionJSON.name);
        this.statement = ko.observable('');
        this.advice = ko.observable('');

        this.variables = ko.observableArray([]);

        this.parts = ko.observableArray([]);

        this.output = ko.computed(function() {
            return prettyData(this.export());
        },this);

        this.save = ko.computed(function() {
            var data = {};
            $('#edit-form').serializeArray().map(function(o){
                data[o.name] = o.value;
            });
            data.content = this.output();

            $.post($('#edit-form').attr('action'),data)
                .success(function(data){
                    var address = location.protocol+'//'+location.host+'/question/'+questionJSON.id+'/'+slugify(this.name())+'/';
                    history.replaceState({},this.name(),address);
                })
                .error(function(data) {
                    $('#preview-message').html(data);
                })
            ;
            return data;
        },this).extend({throttle:1000});


        if(data)
            this.load(data);
    }
    Question.prototype = {<commit_msg>fix question save method<commit_after>var viewModel;

$(document).ready(function() {
//indent every line in given string with n tab characters

    var Variable = Editor.Variable,
        Ruleset = Editor.Ruleset;

    function Question(data)
    {
        this.name = ko.observable(questionJSON.name);
        this.statement = ko.observable('');
        this.advice = ko.observable('');

        this.variables = ko.observableArray([]);

        this.parts = ko.observableArray([]);

        this.output = ko.computed(function() {
            return prettyData(this.export());
        },this);

        this.save = ko.computed(function() {
            var data = {};
            $('#edit-form').serializeArray().map(function(o){
                data[o.name] = o.value;
            });
            data.content = this.output();
            var q = this;

            $.post($('#edit-form').attr('action'),data)
                .success(function(data){
                    var address = location.protocol+'//'+location.host+'/question/'+questionJSON.id+'/'+slugify(q.name())+'/';
                    history.replaceState({},q.name(),address);
                })
                .error(function(data) {
                    $('#preview-message').html(data);
                })
            ;
            return data;
        },this).extend({throttle:1000});


        if(data)
            this.load(data);
    }
    Question.prototype = {
{'fraction_non_alphanumeric': 0.16002819880155095, 'fraction_numerical': 0.0028198801550934085, 'mean_word_length': 1.7878192534381139, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4421989', 'n_tokens_mistral': 789, 'n_tokens_neox': 754, 'n_words': 122}