<commit_before>Template.sectionLesson.created = function () {
  // Create new reactive variable for course edit state
  this.editingCourseVar = new ReactiveVar(false);

  // Save lesson ID as instance variable
  this.lessonID = this.data;

  // Subscribe to single section lesson
  this.subscribe('singleLesson', this.lessonID);

  // Get the current router
  controller = Router.current();

  // Get current course from router
  currentCourseId = controller.params._id;

  /*
  * when user is editing the active course,
  * set the value of a reactive variable (true/false)
  * Used to show/hide wysiwyg editor.
  */
  this.autorun(function () {
    var instance = Template.instance();

    // Update course edit variable when editing course
    if (currentCourseId === Session.get('editingCourseID')) {
      instance.editingCourseVar.set(true);
    } else {
      instance.editingCourseVar.set(false);
    };
  });
};

Template.sectionLesson.helpers({
  'editingCourse': function () {
    // Get template instance
    var instance = Template.instance();

    // Keep track of whether user is editing course
    return instance.editingCourseVar.get();
  },
  'lesson': function () {
    // Get template instance as variable
    var instance = Template.instance();

    // Get lesson ID from template instance
    var lessonID = instance.lessonID;

    // Get lesson object from database
    var lessonObject = Lessons.findOne(lessonID);

    return lessonObject;
  }
});

Template.sectionLesson.events({
  'click .sidebar-lesson-link': function (event) {
    event.preventDefault();

    // Get lesson ID variable from data context
    var lessonID = String(this);

    // Check if user is editing lesson text
    if (editingLessonText.get()) {
      // if so, alert them that changes might be lost
      if (window.confirm("Changes may be lost! Proceed?")) {
        // Remove rich text and set edit mode to false
        lessonEditCleanup();

        // set active lesson ID reactive variable
        // to the value of clicked lesson
        activeLessonID.set(lessonID);
      }
    } else {
      // set active lesson ID reactive variable
      // to the value of clicked lesson
      activeLessonID.set(lessonID);
    }
  }
});
<commit_msg>Switched to editing this course reactive variable.<commit_after>Template.sectionLesson.created = function () {
  // Save lesson ID as instance variable
  this.lessonID = this.data;

  // Subscribe to single section lesson
  this.subscribe('singleLesson', this.lessonID);
};

Template.sectionLesson.helpers({
  'editingCourse': function () {
    // Return the boolean value of editing this course reactive variable
    return editingThisCourseVar.get();
  },
  'lesson': function () {
    // Get template instance as variable
    var instance = Template.instance();

    // Get lesson ID from template instance
    var lessonID = instance.lessonID;

    // Get lesson object from database
    var lessonObject = Lessons.findOne(lessonID);

    return lessonObject;
  }
});

Template.sectionLesson.events({
  'click .sidebar-lesson-link': function (event) {
    event.preventDefault();

    // Get lesson ID variable from data context
    var lessonID = String(this);

    // set active lesson ID reactive variable
    // to the value of clicked lesson
    activeLessonID.set(lessonID);
  }
});

{'fraction_non_alphanumeric': 0.10176593834181383, 'fraction_numerical': 0.0, 'mean_word_length': 3.0023952095808384, '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': '4623797', 'n_tokens_mistral': 937, 'n_tokens_neox': 906, 'n_words': 299}