11import React , { Component } from 'react' ;
22import PropTypes from 'prop-types' ;
33import ImmutablePropTypes from 'react-immutable-proptypes' ;
4- import { Row , Col , Grid } from 'react-bootstrap' ;
4+ import { Row , Col } from 'react-bootstrap' ;
55import { connect } from 'react-redux' ;
66import { injectIntl , FormattedMessage , FormattedNumber } from 'react-intl' ;
77import { LinkContainer } from 'react-router-bootstrap' ;
@@ -172,11 +172,11 @@ const prepareTableColumnDescriptors = defaultMemoize((loggedUserId, assignmentId
172172 return columns ;
173173} ) ;
174174
175- const prepareTableData = defaultMemoize ( ( assigmentSolutions , users , runtimeEnvironments ) => {
175+ const prepareTableData = defaultMemoize ( ( assigmentSolutions , users , runtimeEnvironments , onlyBestSolutionsCheckbox ) => {
176176 return assigmentSolutions
177177 . toArray ( )
178178 . map ( getJsData )
179- . filter ( identity )
179+ . filter ( onlyBestSolutionsCheckbox ? solution => solution && solution . isBestSolution : identity )
180180 . map (
181181 ( {
182182 id,
@@ -335,36 +335,27 @@ class AssignmentStats extends Component {
335335 < ResubmitAllSolutionsContainer assignmentId = { assignment . id } />
336336 </ p >
337337 </ Col >
338- < Col md = { 12 } lg = { 5 } >
339- < Grid fluid >
340- < Row >
341- < Col xs = { 12 } sm = { 12 } className = "text-right" >
342- < OnOffCheckbox
343- checked = { this . state . groupByUsersCheckbox }
344- disabled = { this . state . onlyBestSolutionsCheckbox }
345- name = "groupByUsersCheckbox"
346- onChange = { this . checkboxClickHandler } >
347- < FormattedMessage
348- id = "app.assignmentStats.groupByUsersCheckbox"
349- defaultMessage = "Group by users"
350- />
351- </ OnOffCheckbox >
352- </ Col >
353- { false /* TODO -- when implemented changes in API */ && (
354- < Col xs = { 12 } sm = { 6 } >
355- < OnOffCheckbox
356- checked = { this . state . onlyBestSolutionsCheckbox }
357- name = "onlyBestSolutionsCheckbox"
358- onChange = { this . checkboxClickHandler } >
359- < FormattedMessage
360- id = "app.assignmentStats.onlyBestSolutionsCheckbox"
361- defaultMessage = "Best solutions only"
362- />
363- </ OnOffCheckbox >
364- </ Col >
365- ) }
366- </ Row >
367- </ Grid >
338+ < Col md = { 12 } lg = { 5 } className = "text-right text-nowrap" >
339+ < OnOffCheckbox
340+ checked = { this . state . groupByUsersCheckbox }
341+ disabled = { this . state . onlyBestSolutionsCheckbox }
342+ name = "groupByUsersCheckbox"
343+ onChange = { this . checkboxClickHandler } >
344+ < span className = "em-padding-right" >
345+ < FormattedMessage id = "app.assignmentStats.groupByUsersCheckbox" defaultMessage = "Group by users" />
346+ </ span >
347+ </ OnOffCheckbox >
348+ < OnOffCheckbox
349+ checked = { this . state . onlyBestSolutionsCheckbox }
350+ name = "onlyBestSolutionsCheckbox"
351+ onChange = { this . checkboxClickHandler } >
352+ < span className = "em-padding-right" >
353+ < FormattedMessage
354+ id = "app.assignmentStats.onlyBestSolutionsCheckbox"
355+ defaultMessage = "Best solutions only"
356+ />
357+ </ span >
358+ </ OnOffCheckbox >
368359 </ Col >
369360 </ Row >
370361
@@ -375,7 +366,7 @@ class AssignmentStats extends Component {
375366 loading = { < LoadingSolutionsTable /> }
376367 failed = { < FailedLoadingSolutionsTable /> } >
377368 { ( ) =>
378- this . state . groupByUsersCheckbox ? (
369+ this . state . groupByUsersCheckbox && ! this . state . onlyBestSolutionsCheckbox ? (
379370 < div >
380371 { getStudents ( group . id )
381372 . sort (
@@ -411,7 +402,12 @@ class AssignmentStats extends Component {
411402 hover
412403 columns = { prepareTableColumnDescriptors ( loggedUserId , assignmentId , locale , links ) }
413404 defaultOrder = "date"
414- data = { prepareTableData ( assigmentSolutions , getStudents ( group . id ) , runtimes ) }
405+ data = { prepareTableData (
406+ assigmentSolutions ,
407+ getStudents ( group . id ) ,
408+ runtimes ,
409+ this . state . onlyBestSolutionsCheckbox
410+ ) }
415411 empty = {
416412 < div className = "text-center text-muted" >
417413 < FormattedMessage
0 commit comments