Code coverage report for src/components/performance-forecast/teacher-student.cjsx

Statements: 27.91% (12 / 43)      Branches: 0% (0 / 4)      Functions: 0% (0 / 9)      Lines: 27.91% (12 / 43)      Ignored: none     

All files » src/components/performance-forecast/ » teacher-student.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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153                                                                                                                                                                                                                                                                                          
var BS, BindStoreMixin, Guide, InfoLink, Name, PerformanceForecast, React, Router, ScoresStore, _;
 
React = require('react');
 
BS = require('react-bootstrap');
 
Router = require('react-router');
 
_ = require('underscore');
 
Name = require('../name');
 
BindStoreMixin = require('../bind-store-mixin');
 
PerformanceForecast = require('../../flux/performance-forecast');
 
ScoresStore = require('../../flux/scores').ScoresStore;
 
Guide = require('./guide');
 
InfoLink = require('./info-link');
 
module.exports = React.createClass({
  displayName: 'PerformanceForecastTeacherStudentDisplay',
  contextTypes: {
    router: React.PropTypes.func
  },
  mixins: [BindStoreMixin],
  propTypes: {
    courseId: React.PropTypes.string.isRequired,
    roleId: React.PropTypes.string.isRequired
  },
  getInitialState: function() {
    return {
      roleId: this.props.roleId
    };
  },
  componentWillMount: function() {
    return PerformanceForecast.TeacherStudent.actions.load(this.props.courseId, {
      roleId: this.props.roleId
    });
  },
  bindStore: PerformanceForecast.TeacherStudent.store,
  onSelectStudent: function(roleId) {
    var courseId;
    courseId = this.props.courseId;
    PerformanceForecast.TeacherStudent.actions.load(courseId, {
      roleId: roleId
    });
    this.setState({
      roleId: roleId
    });
    return this.context.router.transitionTo('viewStudentTeacherPerformanceForecast', {
      courseId: courseId,
      roleId: roleId
    });
  },
  renderHeading: function() {
    var name, selected, student, students;
    students = ScoresStore.getAllStudents(this.props.courseId);
    selected = ScoresStore.getStudent(this.props.courseId, this.state.roleId);
    if (!selected) {
      return null;
    }
    name = React.createElement(Name, React.__spread({}, selected));
    return React.createElement("div", {
      "className": 'guide-heading'
    }, React.createElement("div", {
      "className": 'guide-group-title'
    }, React.createElement("span", {
      "className": 'preamble'
    }, "Performance Forecast for:"), React.createElement(BS.DropdownButton, {
      "bzSize": 'large',
      "className": 'student-selection',
      "title": name,
      "bsStyle": 'link',
      "onSelect": this.onSelectStudent
    }, (function() {
      var i, len, ref, results;
      ref = _.sortBy(students, 'name');
      results = [];
      for (i = 0, len = ref.length; i < len; i++) {
        student = ref[i];
        if (student.role !== selected.role) {
          results.push(React.createElement(BS.MenuItem, {
            "key": student.role,
            "eventKey": student.role
          }, React.createElement(Name, React.__spread({}, student))));
        }
      }
      return results;
    })()), React.createElement(InfoLink, {
      "type": 'teacher_student'
    })), React.createElement(Router.Link, {
      "activeClassName": '',
      "to": 'viewScores',
      "className": 'btn btn-default back',
      "params": {
        courseId: this.props.courseId
      }
    }, "Return to Scores"));
  },
  renderWeakerExplanation: function() {
    return React.createElement("div", {
      "className": 'explanation'
    }, React.createElement("p", null, "Tutor shows the weakest topics for a student."), React.createElement("p", null, "Your help may be needed in these areas."));
  },
  returnToDashboard: function() {
    return this.context.router.transitionTo('viewTeacherDashBoard', {
      courseId: this.props.courseId
    });
  },
  renderEmptyMessage: function() {
    return React.createElement("div", {
      "className": "no-data-message"
    }, "No questions have been answered yet.");
  },
  render: function() {
    var courseId, isLoaded, isLoading, roleId;
    courseId = this.props.courseId;
    roleId = this.state.roleId;
    isLoaded = PerformanceForecast.TeacherStudent.store.isLoaded.bind(PerformanceForecast.TeacherStudent.store, courseId, {
      roleId: roleId
    });
    isLoading = PerformanceForecast.TeacherStudent.store.isLoading.bind(PerformanceForecast.TeacherStudent.store, courseId, {
      roleId: roleId
    });
    return React.createElement(BS.Panel, {
      "className": 'performance-forecast teacher-student'
    }, React.createElement(Guide, {
      "courseId": courseId,
      "roleId": roleId,
      "isLoaded": isLoaded,
      "isLoading": isLoading,
      "loadingMessage": "Loading...",
      "heading": this.renderHeading(),
      "weakerExplanation": this.renderWeakerExplanation(),
      "emptyMessage": this.renderEmptyMessage(),
      "weakerTitle": "Their weakest topics",
      "weakerEmptyMessage": "Your student hasn't worked enough problems for Tutor to predict their weakest topics.",
      "sampleSizeThreshold": 3.,
      "onReturn": this.returnToDashboard,
      "allSections": PerformanceForecast.TeacherStudent.store.getAllSections(courseId, {
        roleId: roleId
      }),
      "chapters": PerformanceForecast.TeacherStudent.store.getChapters(courseId, {
        roleId: roleId
      })
    }));
  }
});