<commit_before>(function ($) {
        // hijack IPython's methods of all CodeCells with the required metadata
    if (!window.Homework) {
        var get_text = IPython.CodeCell.prototype.get_text
        IPython.CodeCell.prototype.get_text = function () {
            if (this.metadata && typeof(this.metadata.question) !== "undefined") {
                // TODO: Include problem set number, user id
                var fn = (Homework.mode === "create") ? "new_question" : "attempt_prompt";
                return 'Homework.' + fn + '(' + [ JSON.stringify(JSON.stringify(Homework.config)),
                                         JSON.stringify(JSON.stringify(this.metadata)),
                                         JSON.stringify(document.cookie),
                                         "begin " + get_text.call(this) +" end"
                                       ].join(", ") + ")"
            } else {
                return get_text.call(this)
            }
        }

        var cell_to_json = IPython.CodeCell.prototype.toJSON
        IPython.CodeCell.prototype.toJSON = function () {
            if (this.metadata && typeof(this.metadata.question) !== "undefined") {
                data = cell_to_json.call(this)
                data.input = get_text.call(this)
                return data
            } else {
                return cell_to_json.call(this)
            }
        }

        var rename_keys = IPython.OutputArea.prototype.rename_keys;
        IPython.OutputArea.prototype.rename_keys = function (data, key_map) {
            data = rename_keys(data, key_map)

            if (data.metadata && data.metadata.reactive) {
                var cls = ".signal-" + data.metadata.comm_id
                data.html = $(cls).eq(0).html()
            }
            return data
        }

        var delete_cell = IPython.Notebook.prototype.delete_cell
        IPython.Notebook.prototype.delete_cell = function (index) {
            var i = this.index_or_selected(index);
            var cell = this.get_selected_cell();
            if (cell.metadata && typeof(cell.metadata.question) !== "undefined") {
                alert("Cannot delete this cell. You need to code the answer to Question " + 
                        cell.metadata.question + " here.")
            } else {
                // go on and delete
                delete_cell.call(this, i)
            }
        }

        function get_question(q) {
            var i = 0
            var cell = IPython.notebook.get_cell(i)
            while(cell !== null) {
                if (cell.metadata && cell.metadata.question === q) {
                    return cell
                }
                cell = IPython.notebook.get_cell(i)
                i+=1
            }
            return null
        }

        function mount_message(cell) {
            if (!cell) { return }
            var meta = cell.metadata,
                msg = meta.msg || "<span class='icon-terminal'></span> &nbsp; Code your answer above, hit &lt;Shift+Enter&gt;, then Submit. <span style='float: right'>",
                score = meta.score || 0,
                max_score = meta.max_score || 0,
                attempts = meta.attempts || 0,
                max_attempts = meta.max_attempts || 0

            msg += "<span style='float: right' class='label label-info'> Score: "
            if (Homework.mode === "answering") {
                msg += "<b>" + score + "</b> / <b>" + max_score + "</b>"
            } else if (Homework.mode === "create") {
                msg += "<b>" + max_score + "</b>"
            }

            msg += " &middot; Attempts: "
            if (Homework.mode === "answering") {
                msg += "<b>" + attempts + "</b>"
                if (max_attempts != 0) {
                    msg += " / <b>" + max_attempts + "</b>"
                }
            } else if (Homework.mode === "create") {
                msg += "<b>" + max_attempts + "</b>"
            }
            msg += "</span>"

            var level = meta.alert || "info"

            msg = "<div class='hw-msg alert alert-" + level + "' id='hw-msg-" + meta.question +
                   "' style='padding: 0.5em; margin: 0; border-radius: 0'>" +
                   msg + "</div>"

            $(cell.element).find(".hw-msg").remove()
            $(cell.element).find(".input_area").eq(0).append(msg)
            if (cell.metadata.finished) { $(cell.element).find(".widget_subarea").hide() }
        }

        function set_meta(question, extension) {
            console.log("set meta", question, extension)
            var cell = get_question(question)
            for (var key in extension) {
                if (extension.hasOwnProperty(key)) {
                    cell.metadata[key] = extension[key]
                }
            }
            mount_message(cell)
        }<commit_msg>Widget area, not subarea, and hyphen, not underscore -.-<commit_after>(function ($) {
        // hijack IPython's methods of all CodeCells with the required metadata
    if (!window.Homework) {
        var get_text = IPython.CodeCell.prototype.get_text
        IPython.CodeCell.prototype.get_text = function () {
            if (this.metadata && typeof(this.metadata.question) !== "undefined") {
                // TODO: Include problem set number, user id
                var fn = (Homework.mode === "create") ? "new_question" : "attempt_prompt";
                return 'Homework.' + fn + '(' + [ JSON.stringify(JSON.stringify(Homework.config)),
                                         JSON.stringify(JSON.stringify(this.metadata)),
                                         JSON.stringify(document.cookie),
                                         "begin " + get_text.call(this) +" end"
                                       ].join(", ") + ")"
            } else {
                return get_text.call(this)
            }
        }

        var cell_to_json = IPython.CodeCell.prototype.toJSON
        IPython.CodeCell.prototype.toJSON = function () {
            if (this.metadata && typeof(this.metadata.question) !== "undefined") {
                data = cell_to_json.call(this)
                data.input = get_text.call(this)
                return data
            } else {
                return cell_to_json.call(this)
            }
        }

        var rename_keys = IPython.OutputArea.prototype.rename_keys;
        IPython.OutputArea.prototype.rename_keys = function (data, key_map) {
            data = rename_keys(data, key_map)

            if (data.metadata && data.metadata.reactive) {
                var cls = ".signal-" + data.metadata.comm_id
                data.html = $(cls).eq(0).html()
            }
            return data
        }

        var delete_cell = IPython.Notebook.prototype.delete_cell
        IPython.Notebook.prototype.delete_cell = function (index) {
            var i = this.index_or_selected(index);
            var cell = this.get_selected_cell();
            if (cell.metadata && typeof(cell.metadata.question) !== "undefined") {
                alert("Cannot delete this cell. You need to code the answer to Question " + 
                        cell.metadata.question + " here.")
            } else {
                // go on and delete
                delete_cell.call(this, i)
            }
        }

        function get_question(q) {
            var i = 0
            var cell = IPython.notebook.get_cell(i)
            while(cell !== null) {
                if (cell.metadata && cell.metadata.question === q) {
                    return cell
                }
                cell = IPython.notebook.get_cell(i)
                i+=1
            }
            return null
        }

        function mount_message(cell) {
            if (!cell) { return }
            var meta = cell.metadata,
                msg = meta.msg || "<span class='icon-terminal'></span> &nbsp; Code your answer above, hit &lt;Shift+Enter&gt;, then Submit. <span style='float: right'>",
                score = meta.score || 0,
                max_score = meta.max_score || 0,
                attempts = meta.attempts || 0,
                max_attempts = meta.max_attempts || 0

            msg += "<span style='float: right' class='label label-info'> Score: "
            if (Homework.mode === "answering") {
                msg += "<b>" + score + "</b> / <b>" + max_score + "</b>"
            } else if (Homework.mode === "create") {
                msg += "<b>" + max_score + "</b>"
            }

            msg += " &middot; Attempts: "
            if (Homework.mode === "answering") {
                msg += "<b>" + attempts + "</b>"
                if (max_attempts != 0) {
                    msg += " / <b>" + max_attempts + "</b>"
                }
            } else if (Homework.mode === "create") {
                msg += "<b>" + max_attempts + "</b>"
            }
            msg += "</span>"

            var level = meta.alert || "info"

            msg = "<div class='hw-msg alert alert-" + level + "' id='hw-msg-" + meta.question +
                   "' style='padding: 0.5em; margin: 0; border-radius: 0'>" +
                   msg + "</div>"

            $(cell.element).find(".hw-msg").remove()
            $(cell.element).find(".input_area").eq(0).append(msg)
            if (cell.metadata.finished) { $(cell.element).find(".widget-area").hide() }
        }

        function set_meta(question, extension) {
            console.log("set meta", question, extension)
            var cell = get_question(question)
            for (var key in extension) {
                if (extension.hasOwnProperty(key)) {
                    cell.metadata[key] = extension[key]
                }
            }
            mount_message(cell)
        }
{'fraction_non_alphanumeric': 0.133258104226508, 'fraction_numerical': 0.002667213787443578, 'mean_word_length': 1.4354234324256807, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3549484', 'n_tokens_mistral': 2719, 'n_tokens_neox': 2571, 'n_words': 564}