Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/rubric/src/__tests__/rubric.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,7 @@ describe('Rubric', () => {

describe('draggable', () => {
it('renders 3 draggable items when excludeZero is true', () => {
const { container } = renderComponent({ excludeZero: true });

// When excludeZero is true, the last point (0 pts) should not be rendered
// So we should have 3 draggable items
const draggableItems = container.querySelectorAll('[data-draggable-index]');
expect(draggableItems.length).toEqual(3);

// Verify the 0 pt label is not rendered
expect(screen.queryByText('0 pt')).not.toBeInTheDocument();
});

Expand All @@ -99,6 +92,7 @@ describe('Rubric', () => {
// When excludeZero is false, all points including 0 should be rendered
const draggableItems = container.querySelectorAll('[data-draggable-index]');
expect(draggableItems.length).toEqual(4);
expect(screen.getByText('0 pt')).toBeInTheDocument();

// Verify all point labels are rendered
expect(screen.getByText('3 pts')).toBeInTheDocument();
Expand Down
24 changes: 11 additions & 13 deletions packages/rubric/src/authoring.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,16 @@ export class RawAuthoring extends React.Component {
onChange({ ...value, excludeZero: !value.excludeZero });
};

shouldRenderPoint = (index, value) => {
if (!value.excludeZero) {
return true;
} else {
if (index < value.points.length - 1) {
return true;
} else if (index === value.points.length - 1) {
return false;
}
getPointForIndex = (index, value) => {
const maxPoint = value.excludeZero ? value.points.length - 1 + 1 : value.points.length - 1;
return maxPoint - index;
};

return true;
}
getMaxPoint = (value) => (value.excludeZero ? value.points.length : value.points.length - 1);

shouldRenderPoint = (index, value) => {
const point = this.getPointForIndex(index, value);
return point > 0 || !value.excludeZero;
};

onPointMenuChange = (index, clickedItem) => {
Expand Down Expand Up @@ -280,7 +278,7 @@ export class RawAuthoring extends React.Component {
}

// for rubric value is computed based on points
const maxPointsValue = !rubricless ? value.points.length - 1 : maxPoints;
const maxPointsValue = rubricless ? maxPoints : value.excludeZero ? value.points.length : value.points.length - 1;

return (
<div>
Expand Down Expand Up @@ -338,7 +336,7 @@ export class RawAuthoring extends React.Component {
{...provided.dragHandleProps}
>
<PointConfig
points={value.points.length - 1 - index}
points={this.getPointForIndex(index, value)}
content={p}
error={
pointsDescriptorsErrors &&
Expand Down
Loading