Code coverage report for src/components/task/viewing-as-student-name.cjsx

Statements: 23.33% (7 / 30)      Branches: 0% (0 / 8)      Functions: 0% (0 / 6)      Lines: 23.33% (7 / 30)      Ignored: none     

All files » src/components/task/ » viewing-as-student-name.cjsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66                                                                                                                      
var LoadableItem, Name, React, ScoresActions, ScoresStore, ViewingAsStudentName, ref;
 
React = require('react');
 
LoadableItem = require('../loadable-item');
 
Name = require('../name');
 
ref = require('../../flux/scores'), ScoresStore = ref.ScoresStore, ScoresActions = ref.ScoresActions;
 
ViewingAsStudentName = React.createClass({
  displayName: 'ViewingAsStudentName',
  propTypes: {
    courseId: React.PropTypes.string.isRequired,
    taskId: React.PropTypes.string.isRequired,
    className: React.PropTypes.string
  },
  getInitialState: function() {
    return this.getStudentState();
  },
  getStudentState: function(props) {
    var courseId, ref1, student, taskId;
    ref1 = props || this.props, courseId = ref1.courseId, taskId = ref1.taskId;
    student = ScoresStore.getStudentOfTask(courseId, taskId);
    return {
      student: student
    };
  },
  updateStudent: function(props) {
    if (props == null) {
      props = this.props;
    }
    return this.setState(this.getStudentState(props));
  },
  componentWillMount: function() {
    var courseId, ref1, student, taskId;
    ref1 = this.props, courseId = ref1.courseId, taskId = ref1.taskId;
    student = this.state.student;
    if (student == null) {
      ScoresStore.once('change', this.updateStudent);
      return ScoresActions.load(courseId);
    }
  },
  componentWillReceiveProps: function(nextProps) {
    return this.updateStudent(nextProps);
  },
  render: function() {
    var className, student, studentName;
    className = this.props.className;
    studentName = null;
    className += ' task-student';
    student = this.state.student;
    if (student != null) {
      studentName = React.createElement("div", {
        "className": className
      }, React.createElement(Name, React.__spread({}, student)));
    }
    return studentName;
  }
});
 
module.exports = {
  ViewingAsStudentName: ViewingAsStudentName
};