-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #447 from concord-consortium/187021149-show-studen…
…t-answers-in-feedback feat: Show student answers in feedback [PT-187021149]
- Loading branch information
Showing
5 changed files
with
180 additions
and
1 deletion.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
css/portal-dashboard/feedback/show-student-answers.less
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
@import "../variables"; | ||
|
||
.showStudentAnswers { | ||
margin-top: 10px; | ||
|
||
.showToggle { | ||
font-family: lato; | ||
font-size: 14px; | ||
font-weight: bold; | ||
padding: 6px 9px 7px 35px; | ||
border-radius: 8px; | ||
border: solid 1.5px @cc-charcoal-light1; | ||
background-color: @feedback-green-light5; | ||
position: relative; | ||
cursor: pointer; | ||
|
||
&.showing { | ||
color: #fff; | ||
background-color: @feedback-green; | ||
|
||
&:before { | ||
background-color: #fff; | ||
transform: rotate(180deg); | ||
} | ||
&:hover::before { | ||
background-color: @feedback-green-light5; | ||
} | ||
} | ||
|
||
&:hover { | ||
background-color: #bddfc2; | ||
border: solid 1.5px #fff; | ||
box-shadow:0 0 0 2px @feedback-green-light4; | ||
} | ||
|
||
&:before { | ||
background-color: @feedback-green; | ||
content: ""; | ||
display: block; | ||
height: 24px; | ||
left: 2px; | ||
-webkit-mask-image: url("../../../img/svg-icons/expand-more-icon.svg"); | ||
mask-image: url("../../../img/svg-icons/expand-more-icon.svg"); | ||
position: absolute; | ||
top: 2px; | ||
width: 24px; | ||
} | ||
} | ||
|
||
.answers { | ||
border-radius: 8px; | ||
border: solid 1.5px @cc-charcoal-light1; | ||
margin-top: -16px; | ||
overflow: hidden; | ||
|
||
.row { | ||
background-color: #fff; | ||
display: flex; | ||
flex-direction: row; | ||
font-weight: 400; | ||
min-height: 55px; | ||
|
||
&:first-child { | ||
padding-top: 10px; | ||
} | ||
|
||
&:nth-child(even) { | ||
.questionWrapper { | ||
background-color: @cc-teal-light6; | ||
} | ||
.studentResponse { | ||
background-color: @cc-teal-light6; | ||
} | ||
} | ||
|
||
.questionWrapper { | ||
border-bottom: 1.5px solid @cc-charcoal-light2; | ||
display: flex; | ||
flex-direction: row; | ||
flex-shrink: 0; | ||
font-weight: normal; | ||
margin-right: 3px; | ||
padding-top: 15px; | ||
padding-bottom: 15px; | ||
width: 240px; | ||
|
||
.questionName { | ||
justify-content: center; | ||
margin: 2.5px 20px 0 10px; | ||
} | ||
} | ||
|
||
.studentResponse { | ||
background-color: #fff; | ||
border-bottom: 1.5px solid @cc-charcoal-light2; | ||
flex: 1 1 50%; | ||
font-weight: normal; | ||
margin-right: 3px; | ||
min-width: 349px; | ||
padding: 15px 20px; | ||
} | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
js/components/portal-dashboard/feedback/show-student-answers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React, { useState } from "react"; | ||
import classNames from "classnames"; | ||
import striptags from "striptags"; | ||
import { Map } from "immutable"; | ||
import Answer from "../../../containers/portal-dashboard/answer"; | ||
import { renderHTML } from "../../../util/render-html"; | ||
|
||
import css from "../../../../css/portal-dashboard/feedback/show-student-answers.less"; | ||
|
||
interface IProps { | ||
activityStarted: boolean; | ||
activity: Map<string, any>; | ||
student: any; | ||
} | ||
|
||
export const ShowStudentAnswers: React.FC<IProps> = (props) => { | ||
const {activityStarted, activity, student} = props; | ||
const [showing, setShowing] = useState(false); | ||
|
||
if (!activityStarted) { | ||
return null; | ||
} | ||
|
||
const handleToggleShowing = () => setShowing(prev => !prev); | ||
|
||
const renderStudentAnswers = () => { | ||
const questions = activity.get("questions"); | ||
const rows = questions.map((question: Map<any, any>) => { | ||
const currentQuestionId = question.get("id"); | ||
const blankRegEx = /\[([^)]+)\]/g; | ||
const promptText = question?.get("prompt")?.replace(blankRegEx, '__________'); | ||
|
||
return ( | ||
<div className={css.row} key={currentQuestionId} data-cy="question-row"> | ||
<div className={css.questionWrapper} data-cy="question-wrapper"> | ||
<div className={css.questionName} data-cy="student-name"> | ||
Q{question.get("questionNumber")}: {renderHTML(striptags(promptText))} | ||
</div> | ||
</div> | ||
<div className={css.studentResponse} data-cy="student-response"> | ||
<Answer question={question} student={student} responsive={false} /> | ||
</div> | ||
</div> | ||
); | ||
}); | ||
|
||
return ( | ||
<div className={css.answers}> | ||
{rows} | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className={css.showStudentAnswers}> | ||
<button className={classNames(css.showToggle, {[css.showing]: showing})} onClick={handleToggleShowing}>{showing ? "Hide Student Answers" : "Show Student Answers"}</button> | ||
{showing && renderStudentAnswers()} | ||
</div> | ||
); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters