<commit_before>
/*  Lesson
====================================================== */

var Lesson = function (lesson) {
	this.lessonId 				= lesson.lessonId;
	this.lessonTitle 			= lesson.lessonTitle || "Lesson Title";
	this.lessonDescription 		= lesson.lessonDescription || "";
	this.lessonScreens 			= lesson.lessonScreens || [];
	this.lessonListId			= lesson.lessonListId;
	this.lessonSeq 				= lesson.lessonSeq;
	this.nextLessonId 			= lesson.nextLessonId;
	this.nextLessonTitle		= lesson.nextLessonTitle;
	this.nextLessonListName		= lesson.nextLessonListName;
	this.currentScreenIndex 	= 0;
	this.furthestScreenIndex 	= 0;
	
	this.currentLessonScreen = function () {
		var lessonScreen = this.lessonScreens[this.currentScreenIndex];
		lessonScreen.lessonTitle = this.lessonTitle; // TODO - Why is this here?
		return lessonScreen;
	}
	
	this.isLastScreen = function () {
		if (this.lessonScreens.length === Number(this.currentScreenIndex + 1)) {
			return true;	// TODO - This is redundant, and can be cleaned up (although, I do like its explicit-ness)
		} else {
			return false;
		}
	}
	
	var roundNumber = function (num, dec) {
		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}
	
	this.furthestPercentCompleteDecimal = function () {
		var screenIndex = this.furthestScreenIndex;
		var screenLength = this.lessonScreens.length;
		var percent = ( screenIndex / (screenLength - 1) ); 
		return roundNumber(percent, 2);
	}
	
	this.percentCompleteDecimal = function () {
		var screenIndex = this.currentScreenIndex;
		var screenLength = this.lessonScreens.length;
		var percent = ( screenIndex / (screenLength - 1) ); 
		return roundNumber(percent, 2);
	}
	
	this.percentComplete = function () {
		var screenIndex = this.currentScreenIndex;
		var screenLength = this.lessonScreens.length;
		var percent = (( screenIndex / (screenLength - 1) ) * 100); 
		return percent + '%';
	}
	
	this.getLessonScreen = function (screenIndex) {
		var lessonScreen = this.lessonScreens[screenIndex];
		lessonScreen.lessonTitle = this.lessonTitle; // TODO - Why is this here?
		// maintain screen index
		this.currentScreenIndex = screenIndex;
		var furthestIndex = this.furthestScreenIndex;
		if (screenIndex > furthestIndex) {
			this.furthestScreenIndex = screenIndex;
		}
		return lessonScreen;<commit_msg>lesson model code cleanup<commit_after>
/*  Lesson
====================================================== */

var Lesson = function (lesson) {
	this.lessonId 				= lesson.lessonId;
	this.lessonTitle 			= lesson.lessonTitle || "Lesson Title";
	this.lessonDescription 		= lesson.lessonDescription || "";
	this.lessonScreens 			= lesson.lessonScreens || [];
	this.lessonListId			= lesson.lessonListId;
	this.lessonSeq 				= lesson.lessonSeq;
	this.nextLessonId 			= lesson.nextLessonId;
	this.nextLessonTitle		= lesson.nextLessonTitle;
	this.nextLessonListName		= lesson.nextLessonListName;
	this.currentScreenIndex 	= 0;
	this.furthestScreenIndex 	= 0;
	
	this.currentLessonScreen = function () {
		return this.lessonScreens[this.currentScreenIndex];
	}
	
	this.isLastScreen = function () {
		return (this.lessonScreens.length === Number(this.currentScreenIndex + 1));
	}
	
	var roundNumber = function (num, dec) {
		var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
		return result;
	}
	
	this.furthestPercentCompleteDecimal = function () {
		var screenIndex = this.furthestScreenIndex;
		var screenLength = this.lessonScreens.length;
		var percent = ( screenIndex / (screenLength - 1) ); 
		return roundNumber(percent, 2);
	}
	
	this.percentCompleteDecimal = function () {
		var screenIndex = this.currentScreenIndex;
		var screenLength = this.lessonScreens.length;
		var percent = ( screenIndex / (screenLength - 1) ); 
		return roundNumber(percent, 2);
	}
	
	this.percentComplete = function () {
		var screenIndex = this.currentScreenIndex;
		var screenLength = this.lessonScreens.length;
		var percent = (( screenIndex / (screenLength - 1) ) * 100); 
		return percent + '%';
	}
	
	this.getLessonScreen = function (screenIndex) {
		var lessonScreen = this.lessonScreens[screenIndex];
		// maintain screen index
		this.currentScreenIndex = screenIndex;
		var furthestIndex = this.furthestScreenIndex;
		if (screenIndex > furthestIndex) {
			this.furthestScreenIndex = screenIndex;
		}
		return lessonScreen;
{'fraction_non_alphanumeric': 0.1339306225591546, 'fraction_numerical': 0.006891798759476223, 'mean_word_length': 4.233173076923077, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4607956', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1389, 'n_words': 277}