<commit_before>Template.addSection.events({
    'click #add-section-button': function (event, instance) {
        /*
        / Add new section to the course
        */

        // Get current sections, before adding new section
        if (this.sectionIDs) {
            // If sections exists, use them
            var sectionIDs = this.sectionIDs;
        } else {
            // otherwise create empty sections array
            var sectionIDs = [];
        }

        // Get the title of new section
        var title = template.find('#section-title').value;

        // Set section title in new section object
        var newSection = {'title': title};

        // Insert new section into database
        var newSectionID = Sections.insert(newSection);

        // Add section ID to existing sections
        sectionIDs.push(newSectionID);

        // Update the course with new section
        Courses.update(this._id, {$set: {'sectionIDs': sectionIDs}});

        // Reset the value of section title field
        $("#section-title").val("");
    }
});<commit_msg>Save section to database.<commit_after>Template.addSection.events({
    'click #add-section-button': function (event, instance) {
        /*
        / Add new section to the course
        */
        var sectionIDs, // list of section IDs in current course
        sectionTitle, // Title of new section, from template
        newSection, // Object containing new section
        newSectionID; // ID of created section, returned from db insert

        // Get current sections, before adding new section
        if (this.sectionIDs) {
            // If sections exists, use them
            sectionIDs = this.sectionIDs;
        } else {
            // otherwise create empty sections array
            sectionIDs = [];
        }

        // Get the title of new section
        sectionTitle = instance.find('#section-title').value;

        // Set section title in new section object
        newSection = {'title': sectionTitle};

        // Insert new section into database
        newSectionID = Sections.insert(newSection);
        
        // Add section ID to existing sections
        sectionIDs.push(newSectionID);

        // Update the course with new section
        Courses.update(this._id, {$set: {'sectionIDs': sectionIDs}});

        // Reset the value of section title field
        $("#section-title").val("");
    }
});
{'fraction_non_alphanumeric': 0.10095554632322393, 'fraction_numerical': 0.0, 'mean_word_length': 1.9655172413793103, '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': '5034564', 'n_tokens_mistral': 580, 'n_tokens_neox': 567, 'n_words': 208}