Skip to content

Commit

Permalink
Merge pull request #822 from Lunatic-Labs/SKIL-531
Browse files Browse the repository at this point in the history
SKIL-531
  • Loading branch information
aparriaran authored Jan 30, 2025
2 parents 5b0a408 + d51bf9d commit 98f9820
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def add_completed_assessment():
@jwt_required()
@bad_token_check()
@AuthCheck()
@admin_check()
def update_completed_assessment():
try:
assessment_data = request.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { CheckinsTracker } from './cat_utils.js';
* @property {Object|null} state.checkins - The CheckinsTracker object.
* @property {Object|null} state.checkinEventSource - The EventSource for checkin events.
* @property {Array|null} state.unitList - The list of units for the assessment task.
* @property {int|null} state.jumpId - What team or student to open first.
*/
class CompleteAssessmentTask extends Component {
constructor(props) {
Expand All @@ -62,6 +63,8 @@ class CompleteAssessmentTask extends Component {
// The loop happens due to server caching as per testing.
checkinEventSource: null,
unitList: null,

jumpId: this.props.navbar.state.jumpToSection // The desired jump location.
};
}

Expand Down Expand Up @@ -191,7 +194,7 @@ class CompleteAssessmentTask extends Component {
teamsUsers,
currentUserRole,
completedAssessments,
checkins
checkins,
} = this.state;

const navbar = this.props.navbar;
Expand Down Expand Up @@ -261,6 +264,8 @@ class CompleteAssessmentTask extends Component {
checkins={this.state.checkins}
assessmentTaskRubric={assessmentTaskRubric}
units={unitList}
usingTeams={this.state.usingTeams}
jumpId={this.state.jumpId}
/>
</Box>
);
Expand Down
27 changes: 22 additions & 5 deletions FrontEndReact/src/View/Admin/View/CompleteAssessmentTask/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import { getUnitCategoryStatus } from './cat_utils.js';
* @param {Array<ATUnit>} props.units - Array of `ATUnit` class objects.
* @param {Object} props.assessmentTaskRubric - The rubric for the assessment task.
* @param {Object} props.navbar - The navbar object.
*
* @property {int|null} props.jumpId - Id of what team or user to veiw first.
*
* @property {Array<ATUnit>} state.units - Array of `ATUnit` class objects taken from props.units.
* @property {number} state.currentUnitTabIndex - Index of the currently selected `ATUnit` from `units`.
* @property {Array<Category>} state.categoryList - Array of `Category` objects using the current rubric.
* @property {number} state.currentCategoryTabIndex - Index of the currently selected rubric `categoryList`.
* @property {Object} state.section - Section object of the category `currentCategoryTabIndex` from `categoryList`.
* @property {boolean} state.displaySavedNotification - Boolean indicating whether to display the pop-up window that confirms the assessment is saved.
*
* @property {Set<number>} unitsThatNeedSaving - A set of all the unit indexes that need saving for autosave.
*/
class Form extends Component {
Expand All @@ -42,6 +42,7 @@ class Form extends Component {
currentCategoryTabIndex: 0,
section: null,
displaySavedNotification: false,
jumpId: this.props.jumpId,
};

this.unitsThatNeedSaving = new Set();
Expand Down Expand Up @@ -130,7 +131,6 @@ class Form extends Component {

// We sort assessmentTaskRubric["category_json"] by the index of each entry, since the the data gets
// automatically sorted when it comes out of the backend

Object.entries(assessmentTaskRubric["category_json"])
.toSorted((a, b) => a[1].index - b[1].index)
.forEach(([category, _], index) => {
Expand Down Expand Up @@ -176,7 +176,7 @@ class Form extends Component {

this.setState({
categoryList: categoryList,
section: section
section: section,
});
}

Expand Down Expand Up @@ -293,7 +293,24 @@ class Form extends Component {
}

componentDidMount() {
this.generateCategoriesAndSection();
const {usingTeams, jumpId} = this.props;
const entity = usingTeams ? 'team': 'user';
const entityId = usingTeams ? 'team_id': 'user_id';
if(jumpId !== null){
for (let index = 0; index < this.state.units.length; index++){
const unit = this.state.units[index];
if(unit[entity][entityId] === jumpId){
this.setState({
currentUnitTabIndex : index,
}, () => {
this.generateCategoriesAndSection();
});
break;
}
}
}else{
this.generateCategoriesAndSection();
};
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,19 @@ class ViewCompleteIndividualAssessmentTasks extends Component {
sort: false,
setCellHeaderProps: () => { return { align:"center", className:"button-column-alignment"}},
setCellProps: () => { return { align:"center", className:"button-column-alignment"} },
customBodyRender: (completedAssessmentId) => {
customBodyRender: (completedAssessmentId, completeAssessmentTasks) => {
const rowIndex = completeAssessmentTasks.rowIndex;
const userId = this.props.completedAssessment[rowIndex].user_id;
if (completedAssessmentId) {
return (
<IconButton
<IconButton // problem : need to pass who im looking at
align="center"
onClick={() => {
navbar.setViewCompleteAssessmentTaskTabWithAssessmentTask(
completedAssessmentTasks,
completedAssessmentId,
chosenAssessmentTask
chosenAssessmentTask,
userId,
);
}}
aria-label="assessmentIndividualSeeMoreDetailsButtons"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,16 +250,19 @@ class ViewCompleteTeamAssessmentTasks extends Component {
sort: false,
setCellHeaderProps: () => { return { align:"center", className:"button-column-alignment"}},
setCellProps: () => { return { align:"center", className:"button-column-alignment"} },
customBodyRender: (completedAssessmentId) => {
if (completedAssessmentId) {
customBodyRender: (completedAssessmentId, completeAssessmentTasks) => {
const rowIndex = completeAssessmentTasks.rowIndex;
const teamId = this.props.completedAssessment[rowIndex].team_id;
if (completedAssessmentId) {
return (
<IconButton
align="center"
onClick={() => {
navbar.setViewCompleteAssessmentTaskTabWithAssessmentTask(
completedAssessmentTasks,
completedAssessmentId,
chosenAssessmentTask
chosenAssessmentTask,
teamId,
);
}}
aria-label="See more details"
Expand Down
30 changes: 25 additions & 5 deletions FrontEndReact/src/View/Navbar/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class AppState extends Component {
successMessageTimeout: undefined,

addCustomRubric: null,
jumpToSection: null,
}

this.setNewTab = (newTab) => {
Expand Down Expand Up @@ -246,21 +247,34 @@ class AppState extends Component {
})
}

// Use this as a callback Function to prevent jump data from being sticky.
this.resetJump = () => {
this.setState({
jumpToSection: null,
})
};

// The ===null section of the next line is not permanent.
// The only purpose was to test to see if we could see the "My Assessment Task"
// on the student dashboard
// When you click "complete" on the "TO DO" column the completed fields were null
// thus it would not display anything
// By adding === null as a test case, we were able to have it populate.
this.setViewCompleteAssessmentTaskTabWithAssessmentTask = (completedAssessmentTasks, completedAssessmentId, chosenAssessmentTask) => {
this.setViewCompleteAssessmentTaskTabWithAssessmentTask = (completedAssessmentTasks, completedAssessmentId, chosenAssessmentTask, jumpId=null) => {
if (completedAssessmentTasks === null && completedAssessmentId === null && chosenAssessmentTask === null) {
this.setState({
activeTab: "CompleteAssessment",
chosenAssessmentTask: null,
unitOfAssessment: null,
chosenCompleteAssessmentTask: null,
chosenCompleteAssessmentTaskIsReadOnly: false,
});
jumpToSection: jumpId,
}, () =>{
if(jumpId !== null){
this.resetJump();
}
}
);

} else {
var newCompletedAssessmentTask = null;
Expand All @@ -275,10 +289,16 @@ class AppState extends Component {
chosenCompleteAssessmentTask: newCompletedAssessmentTask,
chosenCompleteAssessmentTaskIsReadOnly: false,
chosenAssessmentTask: chosenAssessmentTask,
unitOfAssessment: chosenAssessmentTask["unit_of_assessment"]
});
unitOfAssessment: chosenAssessmentTask["unit_of_assessment"],
jumpToSection: jumpId,
}, () => {
if(jumpId !== null){
this.resetJump();
}
}
);
}
}
};

this.ViewCTwithAT = (assessmentTasks, atId) => {
var selectedAssessment = null;
Expand Down

0 comments on commit 98f9820

Please sign in to comment.