<commit_before>import React from 'react';
import Immutable from 'immutable';

export type PageTypes =
    'plain'
    | 'topic_title'
    | 'question'
    | 'welcome'
    | 'results'
    | 'talktous';

export const COURSE_DATA = 'COURSE_DATA';
export const CURRENT_PAGE = 'CURRENT_PAGE';
export const CURRENT_SCORE = 'CURRENT_SCORE';

export class TutoralStateType extends Immutable.Record(
    {
        COURSE_DATA: {
            title: '',
            pages: [],
        },
        CURRENT_PAGE: 0,
        CURRENT_SCORE: 0
    }
) {
    COURSE_DATA: ContextData
    CURRENT_PAGE: number
    CURRENT_SCORE: number
    CURRENT_TOPIC(){
        const page = this.COURSE_DATA.pages[CURRENT_PAGE].topic_id;
        if(page.type === 'topic_title' || page.type === 'plain') {
            return page.topic_id;
        }else{
            return -1;
        }
    }
    GET_TOPIC_WELCOME_PAGE(newPage: number){
        const topic_id = this.COURSE_DATA.pages[CURRENT_PAGE].topic_id;
        return this.COURSE_DATA.pages.findIndex(
            this.COURSE_DATA.pages.find((page) => {
                return (page.type === 'topic_title' || page.topic_id === topic_id);
            });
        );
    }
}

export interface ContextData {
    title: string;
    pages: Array<PageData>;
};

export interface PageData {
    type: PageTypes;
};

export interface TopicPageData extends PageData {
    type: PageTypes;
    topic_id: number;
};

export interface TopicTitlePageData extends TopicPageData {
    title: string;
};

export interface BasicPageData extends TopicPageData {
    __content: string;<commit_msg>Finished helper methods<commit_after>import React from 'react';
import Immutable from 'immutable';

export type PageTypes =
    'plain'
    | 'topic_title'
    | 'question'
    | 'welcome'
    | 'results'
    | 'talktous';

export const COURSE_DATA = 'COURSE_DATA';
export const CURRENT_PAGE = 'CURRENT_PAGE';
export const CURRENT_SCORE = 'CURRENT_SCORE';

export class TutoralStateType extends Immutable.Record(
    {
        COURSE_DATA: {
            title: '',
            pages: [],
        },
        CURRENT_PAGE: 0,
        CURRENT_SCORE: 0
    }
) {
    COURSE_DATA: ContextData
    CURRENT_PAGE: number
    CURRENT_SCORE: number
    CURRENT_TOPIC() {
        const page = this.COURSE_DATA.pages[CURRENT_PAGE].topic_id;
        if (page.type === 'topic_title' || page.type === 'plain') {
            return page.topic_id;
        } else {
            return -1;
        }
    }
    GET_TOPIC_TITLE_PAGE(newPage: number) {
        if(this.CURRENT_TOPIC() !== -1){
            return this.COURSE_DATA.pages.findIndex((page: TopicPageData) => {
                return (page.topic_id === this.CURRENT_TOPIC() || page.type === 'topic_title');
            });
        }else{
            return -1;
        }
    }
}

export interface ContextData {
    title: string;
    pages: Array<PageData>;
};

export interface PageData {
    type: PageTypes;
};

export interface TopicPageData extends PageData {
    type: PageTypes;
    topic_id: number;
};

export interface TopicTitlePageData extends TopicPageData {
    title: string;
};

export interface BasicPageData extends TopicPageData {
    __content: string;
{'fraction_non_alphanumeric': 0.11010886469673406, 'fraction_numerical': 0.002488335925349922, 'mean_word_length': 2.565410199556541, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3904391', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1009, 'n_words': 220}