<commit_before>/**
 * Created by c14hht on 2016-04-28.
 *
 * Class that when entering the studentid, assignmentid, courseid and submitting gets the feedback and view it.
 */

window.Feedback = React.createClass ({

    handleClick: function () {
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                var infoFromDb = JSON.parse(xmlHttp.responseText);
                return (
                    ReactDOM.render(
                        <NewFeedback feedbackResponse={infoFromDb}
                        sourceInfo={"https://" + window.globalURL + "/feedback/video?studentID=" + document.getElementById('student').value
            + "&assignmentID=" + document.getElementById('ass').value + "&courseID=" + document.getElementById('course').value}/>,
                        document.getElementById('courseContent')
                    )
                )
            }
        };
        xmlHttp.open("GET", "https://" + window.globalURL + "/feedback/get?studentID=" + document.getElementById('student').value
            + "&assignmentID=" + document.getElementById('ass').value + "&courseID=" + document.getElementById('course').value, true);
        xmlHttp.send();
    },
    render: function () {
        return (
            <div>
                <form>
                    StudentID: <br />
                    <input id="student"type="text" name="studentid"></input> <br />
                    AssID: <br />
                    <input id="ass" type="text" name="assid"></input> <br />
                    CourseID: <br />
                    <input id="course" type="text" name="courseid"></input>
                </form>
                <button style={{backgroundColor: 'black',color:'white'}} onClick={this.handleClick}>Submit</button>
            </div>
        )
    }
});

var NewFeedback = React.createClass ({

    render: function () {

        var feedbackResponse = this.props.feedbackResponse;
        console.log(this.props.sourceInfo);

        return (
            <div>
                Teacher: {feedbackResponse.teacher} <br />
                Grade: {feedbackResponse.grade} <br />
                Time: {feedbackResponse.time} <br />
                <video width="720" height="460" src={this.props.sourceInfo} preload="auto" controls></video>
            </div>
        )
    }
});

/*ReactDOM.render(
    <Feedback />,
    document.getElementById('courseContent')
);
*/
<commit_msg>Add error handling<commit_after>/**
 * Created by c14hht on 2016-04-28.
 *
 * Class that when entering the studentid, assignmentid, courseid and submitting gets the feedback and view it.
 */

window.Feedback = React.createClass ({

    handleClick: function () {
        var xmlHttp = new XMLHttpRequest();
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                var infoFromDb = JSON.parse(xmlHttp.responseText);
                return (
                ReactDOM.render(
                <NewFeedback feedbackResponse={infoFromDb}
                sourceInfo={window.globalURL + "/feedback/video?studentID=" + document.getElementById('student').value
                    + "&assignmentID=" + document.getElementById('ass').value + "&courseID=" + document.getElementById('course').value}/>,
                document.getElementById('courseContent')
            )
            )
            }
        };
        xmlHttp.open("GET",window.globalURL + "/feedback/get?studentID=" + document.getElementById('student').value
            + "&assignmentID=" + document.getElementById('ass').value + "&courseID=" + document.getElementById('course').value, true);
        xmlHttp.send();
    },
    render: function () {
        return (
            <div>
            <form>
            StudentID: <br />
        <input id="student"type="text" name="studentid"></input> <br />
            AssID: <br />
        <input id="ass" type="text" name="assid"></input> <br />
            CourseID: <br />
        <input id="course" type="text" name="courseid"></input>
            </form>
            <button style={{backgroundColor: 'black',color:'white'}} onClick={this.handleClick}>Submit</button>
        </div>
        )
    }
});

var NewFeedback = React.createClass ({

    render: function () {

        var feedbackResponse = this.props.feedbackResponse;
        console.log(this.props.sourceInfo);
        console.log(feedbackResponse.error + " feedback response");

        if(feedbackResponse.error === undefined) {
            return (
                <div>
                Teacher: {feedbackResponse.teacher} <br />
            Grade: {feedbackResponse.grade} <br />
            Time: {feedbackResponse.time} <br />
            <video width="720" height="460" src={this.props.sourceInfo} preload="auto" controls></video>
            </div>
        )
        } else {
            return (
                <div>
                Error: {feedbackResponse.error} <br />
            </div>
        )
        }
    }
});

/*ReactDOM.render(
 <Feedback />,
 document.getElementById('courseContent')
 );
 */

{'fraction_non_alphanumeric': 0.14453200076878725, 'fraction_numerical': 0.00768787238131847, 'mean_word_length': 1.9601820250284414, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 58, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, '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': '346695', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1347, 'n_words': 259}