<commit_before>import React from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import _ from 'underscore';
import { deleteLesson, startLessonEdit } from '../../actions/lessons.js';
import lessonActions from '../../actions/lessons';
import Modal from '../modal/modal.jsx';
import C from '../../constants.js';
import EditLessonForm from './lessonForm.jsx';

const Lesson = React.createClass({
  questionsForLesson() {
    const { data, } = this.props.lessons,
      { lessonID, } = this.props.params;
    if (data[lessonID].questions) {
      return data[lessonID].questions.map((question) => {
        const questions = this.props[question.questionType].data;
        const qFromDB = Object.assign({}, questions[question.key]);
        qFromDB.questionType = question.questionType;
        qFromDB.key = question.key;
        return qFromDB;
      });
    }
  },

  renderQuestionsForLesson() {
    const questionsForLesson = this.questionsForLesson();
    if (questionsForLesson) {
      const listItems = questionsForLesson.map((question) => {
        const displayName = question.prompt || 'No question prompt';
        return (<li key={question.key}><Link to={`/admin/${question.questionType || 'questions'}/${question.key}`}>{displayName.replace(/(<([^>]+)>)/ig, '').replace(/&nbsp;/ig, '')}</Link></li>);
      });
      return (
        <ul>{listItems}</ul>
      );
    } else {
      return (
        <ul>No questions</ul>
      );
    }
  },

  deleteLesson() {
    const { lessonID, } = this.props.params;
    if (confirm('do you want to do this?')) {
      this.props.dispatch(deleteLesson(lessonID));
    }
  },

  cancelEditingLesson() {
    this.props.dispatch(lessonActions.cancelLessonEdit(this.props.params.lessonID));
  },

  saveLessonEdits(vals) {
    this.props.dispatch(lessonActions.submitLessonEdit(this.props.params.lessonID, vals));
  },
<commit_msg>added kebab case to String.prototype<commit_after>import React from 'react';
import { connect } from 'react-redux';
import { Link } from 'react-router';
import _ from 'underscore';
import { deleteLesson, startLessonEdit } from '../../actions/lessons.js';
import lessonActions from '../../actions/lessons';
import Modal from '../modal/modal.jsx';
import C from '../../constants.js';
import EditLessonForm from './lessonForm.jsx';

String.prototype.toKebab = function () {
  return this.replace(/([A-Z])/g, char => `-${char.toLowerCase()}`);
};

const Lesson = React.createClass({
  questionsForLesson() {
    const { data, } = this.props.lessons,
      { lessonID, } = this.props.params;
    if (data[lessonID].questions) {
      return data[lessonID].questions.map((question) => {
        const questions = this.props[question.questionType].data;
        const qFromDB = Object.assign({}, questions[question.key]);
        qFromDB.questionType = question.questionType;
        qFromDB.key = question.key;
        return qFromDB;
      });
    }
  },

  renderQuestionsForLesson() {
    const questionsForLesson = this.questionsForLesson();
    if (questionsForLesson) {
      const listItems = questionsForLesson.map((question) => {
        const displayName = question.prompt || 'No question prompt';
        return (<li key={question.key}><Link to={`/admin/${question.questionType.toKebab() || 'questions'}/${question.key}`}>{displayName.replace(/(<([^>]+)>)/ig, '').replace(/&nbsp;/ig, '')}</Link></li>);
      });
      return (
        <ul>{listItems}</ul>
      );
    } else {
      return (
        <ul>No questions</ul>
      );
    }
  },

  deleteLesson() {
    const { lessonID, } = this.props.params;
    if (confirm('do you want to do this?')) {
      this.props.dispatch(deleteLesson(lessonID));
    }
  },

  cancelEditingLesson() {
    this.props.dispatch(lessonActions.cancelLessonEdit(this.props.params.lessonID));
  },

  saveLessonEdits(vals) {
    this.props.dispatch(lessonActions.submitLessonEdit(this.props.params.lessonID, vals));
  },

{'fraction_non_alphanumeric': 0.16972592406336434, 'fraction_numerical': 0.0, 'mean_word_length': 3.2820236813778254, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 28, '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': '5374580', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1255, 'n_words': 224}