<commit_before>import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { ProblemService } from '../problem.service';
import { UserService } from '../../user/user.service';
import { ToastrService } from 'ngx-toastr';
import { ActivatedRoute } from '@angular/router';
import { Router } from '@angular/router';
import { ModalDirective } from 'ng2-bootstrap';


@Component({
  moduleId: module.id,
  selector: 'display-problem',
  templateUrl: 'displayProblem.html'
})

export class DisplayProblemComponent implements OnInit, OnDestroy {
  @ViewChild('editProblemModal') public autoShownModal:ModalDirective;
  public isModalShown:boolean = false;
  /*
  Display problem works by showing "good" steps that are less than the current active step count. The
  logic beind the actual showing the step is in displayProblem.html

  If a step object contains a bad step it is immediately shown. When a bad step is shown a "badStepShown" property is added to
  the good step object it belongs to. Badstep paths are walked through in a similar way that the normal steps are walked through, all bad steps within the original step object that are less than the activeBadStepCount are shown.
  */

  private routeSub: any;
  isLoading = true;
  problemTree = null;
  problem = null;
  badStepProblem = null;
  activeStepCount = 0;
  activeBadStepCount = 0;
  badStepShown = false;
  problemIsComplete = false;

  correctionModel = {
    correction: '',
    stepToCorrect: ''
  }

  constructor(public problemService: ProblemService, public toastr: ToastrService, public router: Router, private activatedRoute: ActivatedRoute){
  }
  /* Modal Methods */
  public showCorrectionModal(problemStep: string):void {
    this.correctionModel.correction = '';
    this.correctionModel.stepToCorrect = problemStep;
    this.isModalShown = true;
  }

  public hideCorrectionModal():void {
    this.autoShownModal.hide();
  }

  public onHidden():void {
    this.isModalShown = false;
  }

  applyCorrection() {
    if (this.correctionModel.correction == this.problemTree[this.activeStepCount].correctStep) {
      this.toastr.success("Your correction got Mentii back on the right path", "Good Job");
      this.problemTree[this.activeStepCount]['badStepShown'] = false; // Close the bad step subtree
      this.hideCorrectionModal();
      this.showNextStep(); // Progress to the next step, after the correction
    } else {<commit_msg>Removing whitespace from correction comparison<commit_after>import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
import { ProblemService } from '../problem.service';
import { UserService } from '../../user/user.service';
import { ToastrService } from 'ngx-toastr';
import { ActivatedRoute } from '@angular/router';
import { Router } from '@angular/router';
import { ModalDirective } from 'ng2-bootstrap';


@Component({
  moduleId: module.id,
  selector: 'display-problem',
  templateUrl: 'displayProblem.html'
})

export class DisplayProblemComponent implements OnInit, OnDestroy {
  @ViewChild('editProblemModal') public autoShownModal:ModalDirective;
  public isModalShown:boolean = false;
  /*
  Display problem works by showing "good" steps that are less than the current active step count. The
  logic beind the actual showing the step is in displayProblem.html

  If a step object contains a bad step it is immediately shown. When a bad step is shown a "badStepShown" property is added to
  the good step object it belongs to. Badstep paths are walked through in a similar way that the normal steps are walked through, all bad steps within the original step object that are less than the activeBadStepCount are shown.
  */

  private routeSub: any;
  isLoading = true;
  problemTree = null;
  problem = null;
  badStepProblem = null;
  activeStepCount = 0;
  activeBadStepCount = 0;
  badStepShown = false;
  problemIsComplete = false;

  correctionModel = {
    correction: '',
    stepToCorrect: ''
  }

  constructor(public problemService: ProblemService, public toastr: ToastrService, public router: Router, private activatedRoute: ActivatedRoute){
  }
  /* Modal Methods */
  public showCorrectionModal(problemStep: string):void {
    this.correctionModel.correction = '';
    this.correctionModel.stepToCorrect = problemStep;
    this.isModalShown = true;
  }

  public hideCorrectionModal():void {
    this.autoShownModal.hide();
  }

  public onHidden():void {
    this.isModalShown = false;
  }

  applyCorrection() {
    let trimmedCorrection = this.correctionModel.correction.replace(/\s+/g, ''); // Removed all whitespace
    let trimmedActual = this.problemTree[this.activeStepCount].correctStep.replace(/\s+/g, ''); // Removed all whitespace
    if (trimmedCorrection == trimmedActual) {
      this.toastr.success("Your correction got Mentii back on the right path", "Good Job");
      this.problemTree[this.activeStepCount]['badStepShown'] = false; // Close the bad step subtree
      this.hideCorrectionModal();
      this.showNextStep(); // Progress to the next step, after the correction
    } else {
{'fraction_non_alphanumeric': 0.09765701909824769, 'fraction_numerical': 0.0011813349084465446, 'mean_word_length': 4.242518059855521, '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': '413076', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1407, 'n_words': 464}