<commit_before>function DragAndDropBlock(runtime, element) {
    var dragAndDrop = (function($) {
        var _fn = {

            // DOM Elements
            $ul: $('.xblock--drag-and-drop .items', element),
            $target: $('.xblock--drag-and-drop .target-img', element),
            $feedback: $('.xblock--drag-and-drop .feedback .message', element),

            // Cannot set until items added to DOM
            $items: {}, // $('.xblock--drag-and-drop .items .option'),
            $zones: {}, // $('.xblock--drag-and-drop .target .zone'),

            // jQuery UI Draggable options
            options: {
                drag: {
                    containment: '.xblock--drag-and-drop .drag-container',
                    cursor: 'move',
                    stack: '.xblock--drag-and-drop .items .option'
                },
                drop: {
                    accept: '.xblock--drag-and-drop .items .option',
                    tolerance: 'pointer'
                }
            },

            // item template
            tpl: {
                item: function() {
                    return [
                        '<li class="option" data-value="<%= id %>"',
                            'style="width: <%= size.width %>; height: <%= size.height %>">',
                            '<%= displayName %>',
                        '</li>'
                    ].join('');
                },
                image_item: function() {
                    return [
                        '<li class="option" data-value="<%= id %>"',
                            'style="width: <%= size.width %>; height: <%= size.height %>">',
                            '<img src="<%= backgroundImage %>" />',
                        '</li>'
                    ].join('');
                },
                zoneElement: function() {
                    return [
                        '<div id="<%= id %>" class="zone" data-zone="<%= title %>" style="',
                            'top:<%= y %>px;',
                            'left:<%= x %>px;',
                            'width:<%= width %>px;',
                            'height:<%= height %>px;">',
                            '<p><%= title %></p>',
                        '</div>'
                    ].join('');
                }
            },

            init: function(data) {
                _fn.data = data;

                // Add the items to the page
                _fn.items.draw();
                _fn.zones.draw();

                // Init drag and drop plugin
                _fn.$items.draggable(_fn.options.drag);
                _fn.$zones.droppable(_fn.options.drop);

                // Init click handlers
                _fn.clickHandlers.init(_fn.$items, _fn.$zones);

                // Position the already correct items
                _fn.items.init();

                // Load welcome or final feedback
                if (_fn.data.feedback.finish)
                    _fn.finish(_fn.data.feedback.finish);
                else
                    _fn.feedback.set(_fn.data.feedback.start);

                // Set the target image
                if (_fn.data.targetImg)
                    _fn.$target.css('background', 'url(' + _fn.data.targetImg + ') no-repeat');
            },

            finish: function(final_feedback) {
                // Disable any decoy items
                _fn.$items.draggable('disable');

                // Show final feedback
                _fn.feedback.set(final_feedback);
            },

            clickHandlers: {
                init: function($drag, $dropzone) {
                    var clk = _fn.clickHandlers;

                    $drag.on('dragstart', clk.drag.start);
                    $drag.on('dragstop', clk.drag.stop);

                    $dropzone.on('drop', clk.drop.success);
                },
                drag: {
                    start: function(event, ui) {
                        $(event.currentTarget).removeClass('within-dropzone fade');
                    },

                    stop: function(event, ui) {
                        var $el = $(event.currentTarget),
                            val = $el.data('value'),
                            zone = $el.data('zone') || null;

                        if (!$el.hasClass('within-dropzone')) {
                            // Return to original position
                            _fn.clickHandlers.drag.reset($el);
                            return;
                        }

                        $.post(runtime.handlerUrl(element, 'do_attempt'),
                            JSON.stringify({
                                val: val,
                                zone: zone,
                                top: $el.css('top'),
                                left: $el.css('left')
                        })).done(function(data){
                            if (data.correct) {
                                $el.draggable('disable');

                                if (data.final_feedback) {
                                    _fn.finish(data.final_feedback);
                                }
                            } else {
                                // Return to original position
                                _fn.clickHandlers.drag.reset($el);
                            }

                            if (data.feedback) {
                                _fn.feedback.popup(data.feedback, data.correct);
                            }
                        });
                    },

                    set: function($el, top, left) {
                        $el.addClass('within-dropzone fade')
                            .css({
                                top: top,
                                left: left
                            })
                            .draggable('disable');
                    },

                    reset: function($el) {
                        $el.removeClass('within-dropzone fade')
                            .css({
                                top: '',
                                left: ''
                            });
                    }
                },
                drop: {
                    success: function(event, ui) {
                        ui.draggable.addClass('within-dropzone');
                    }
                }
            },

            items: {
                init: function() {
                    _fn.$items.each(function (){
                        var $el = $(this),
                            saved_entry = _fn.data.state[$el.data('value')];
                        if (saved_entry) {
                            _fn.clickHandlers.drag.set($el,
                                saved_entry[0], saved_entry[1]);
                        }
                    });
                },
                draw: function() {
                    var list = [],
                        items = _fn.data.items,
                        tpl = _fn.tpl.item(),
                        img_tpl = _fn.tpl.image_item();

                    items.forEach(function(item) {
                        if (item.backgroundImage.length > 0) {
                            list.push(_.template(img_tpl, item));
                        } else {
                            list.push(_.template(tpl, item));
                        }<commit_msg>Fix: removed a critical callback during refactor<commit_after>function DragAndDropBlock(runtime, element) {
    var dragAndDrop = (function($) {
        var _fn = {

            // DOM Elements
            $ul: $('.xblock--drag-and-drop .items', element),
            $target: $('.xblock--drag-and-drop .target-img', element),
            $feedback: $('.xblock--drag-and-drop .feedback .message', element),

            // Cannot set until items added to DOM
            $items: {}, // $('.xblock--drag-and-drop .items .option'),
            $zones: {}, // $('.xblock--drag-and-drop .target .zone'),

            // jQuery UI Draggable options
            options: {
                drag: {
                    containment: '.xblock--drag-and-drop .drag-container',
                    cursor: 'move',
                    stack: '.xblock--drag-and-drop .items .option'
                },
                drop: {
                    accept: '.xblock--drag-and-drop .items .option',
                    tolerance: 'pointer'
                }
            },

            // item template
            tpl: {
                item: function() {
                    return [
                        '<li class="option" data-value="<%= id %>"',
                            'style="width: <%= size.width %>; height: <%= size.height %>">',
                            '<%= displayName %>',
                        '</li>'
                    ].join('');
                },
                image_item: function() {
                    return [
                        '<li class="option" data-value="<%= id %>"',
                            'style="width: <%= size.width %>; height: <%= size.height %>">',
                            '<img src="<%= backgroundImage %>" />',
                        '</li>'
                    ].join('');
                },
                zoneElement: function() {
                    return [
                        '<div id="<%= id %>" class="zone" data-zone="<%= title %>" style="',
                            'top:<%= y %>px;',
                            'left:<%= x %>px;',
                            'width:<%= width %>px;',
                            'height:<%= height %>px;">',
                            '<p><%= title %></p>',
                        '</div>'
                    ].join('');
                }
            },

            init: function(data) {
                _fn.data = data;

                // Add the items to the page
                _fn.items.draw();
                _fn.zones.draw();

                // Init drag and drop plugin
                _fn.$items.draggable(_fn.options.drag);
                _fn.$zones.droppable(_fn.options.drop);

                // Init click handlers
                _fn.clickHandlers.init(_fn.$items, _fn.$zones);

                // Position the already correct items
                _fn.items.init();

                // Load welcome or final feedback
                if (_fn.data.feedback.finish)
                    _fn.finish(_fn.data.feedback.finish);
                else
                    _fn.feedback.set(_fn.data.feedback.start);

                // Set the target image
                if (_fn.data.targetImg)
                    _fn.$target.css('background', 'url(' + _fn.data.targetImg + ') no-repeat');
            },

            finish: function(final_feedback) {
                // Disable any decoy items
                _fn.$items.draggable('disable');

                // Show final feedback
                _fn.feedback.set(final_feedback);
            },

            clickHandlers: {
                init: function($drag, $dropzone) {
                    var clk = _fn.clickHandlers;

                    $drag.on('dragstart', clk.drag.start);
                    $drag.on('dragstop', clk.drag.stop);

                    $dropzone.on('drop', clk.drop.success);
                    $dropzone.on('dropover', clk.drop.hover);
                },
                drag: {
                    start: function(event, ui) {
                        $(event.currentTarget).removeClass('within-dropzone fade');
                    },

                    stop: function(event, ui) {
                        var $el = $(event.currentTarget),
                            val = $el.data('value'),
                            zone = $el.data('zone') || null;

                        if (!$el.hasClass('within-dropzone')) {
                            // Return to original position
                            _fn.clickHandlers.drag.reset($el);
                            return;
                        }

                        $.post(runtime.handlerUrl(element, 'do_attempt'),
                            JSON.stringify({
                                val: val,
                                zone: zone,
                                top: $el.css('top'),
                                left: $el.css('left')
                        })).done(function(data){
                            if (data.correct) {
                                $el.draggable('disable');

                                if (data.final_feedback) {
                                    _fn.finish(data.final_feedback);
                                }
                            } else {
                                // Return to original position
                                _fn.clickHandlers.drag.reset($el);
                            }

                            if (data.feedback) {
                                _fn.feedback.popup(data.feedback, data.correct);
                            }
                        });
                    },

                    set: function($el, top, left) {
                        $el.addClass('within-dropzone fade')
                            .css({
                                top: top,
                                left: left
                            })
                            .draggable('disable');
                    },

                    reset: function($el) {
                        $el.removeClass('within-dropzone fade')
                            .css({
                                top: '',
                                left: ''
                            });
                    }
                },
                drop: {
                    hover: function(event, ui) {
                        var zone = $(event.currentTarget).data('zone');
                        ui.draggable.data('zone', zone);
                    },
                    success: function(event, ui) {
                        ui.draggable.addClass('within-dropzone');
                    }
                }
            },

            items: {
                init: function() {
                    _fn.$items.each(function (){
                        var $el = $(this),
                            saved_entry = _fn.data.state[$el.data('value')];
                        if (saved_entry) {
                            _fn.clickHandlers.drag.set($el,
                                saved_entry[0], saved_entry[1]);
                        }
                    });
                },
                draw: function() {
                    var list = [],
                        items = _fn.data.items,
                        tpl = _fn.tpl.item(),
                        img_tpl = _fn.tpl.image_item();

                    items.forEach(function(item) {
                        if (item.backgroundImage.length > 0) {
                            list.push(_.template(img_tpl, item));
                        } else {
                            list.push(_.template(tpl, item));
                        }
{'fraction_non_alphanumeric': 0.12463440574315342, 'fraction_numerical': 0.0003988300983780909, 'mean_word_length': 0.800718132854578, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6976211', 'n_tokens_mistral': 3698, 'n_tokens_neox': 3347, 'n_words': 626}