-
+
+
{this.props.selectedInstance.name}
{createHeaders(this.props.courseData, this.props.studentInstance)}
diff --git a/labtool2.0/src/components/pages/CoursePage.js b/labtool2.0/src/components/pages/CoursePage.js
index 545930a40..1bd3f8275 100644
--- a/labtool2.0/src/components/pages/CoursePage.js
+++ b/labtool2.0/src/components/pages/CoursePage.js
@@ -21,6 +21,7 @@ import {
toggleCodeReview
} from '../../reducers/coursePageLogicReducer'
import { resetLoading } from '../../reducers/loadingReducer'
+import { trimDate } from '../../util/format'
export class CoursePage extends React.Component {
handleClick = (e, titleProps) => {
@@ -63,13 +64,6 @@ export class CoursePage extends React.Component {
})
}
- trimDate = date => {
- return new Date(date)
- .toLocaleString()
- .replace('/', '.')
- .replace('/', '.')
- }
-
changeHiddenAssistantDropdown = id => {
return () => {
this.props.showAssistantDropdown(this.props.coursePageLogic.showAssistantDropdown === id ? '' : id)
@@ -213,6 +207,10 @@ export class CoursePage extends React.Component {
const numberOfCodeReviews = Array.isArray(this.props.courseData.data) ? Math.max(...this.props.courseData.data.map(student => student.codeReviews.length)) : 0
const createIndents = (weeks, codeReviews, siId) => {
+ const cr = codeReviews &&
+ codeReviews.reduce((a, b) => {
+ return { ...a, [b.reviewNumber]: b.points }
+ }, {})
const indents = []
let i = 0
let finalPoints = undefined
@@ -236,19 +234,26 @@ export class CoursePage extends React.Component {
}
indents.push(pushattava)
}
+
let ii = 0
- codeReviews.forEach(cr => {
- indents.push(
{cr.points !== null ? {cr.points}
: -
} )
- ii++
- })
- while (ii < numberOfCodeReviews) {
- indents.push(
-
- -
-
- )
- ii++
+ const { amountOfCodeReviews } = this.props.selectedInstance
+ if (amountOfCodeReviews) {
+ for (let index = 1; index <= amountOfCodeReviews; index++) {
+ indents.push(
{cr[index] || cr[index] === 0 ? {cr[index]}
: -
} )
+ }
}
+ // codeReviews.forEach(cr => {
+ // indents.push(
{cr.points !== null ? {cr.points}
: -
} )
+ // ii++
+ // // })
+ // while (ii < numberOfCodeReviews) {
+ // indents.push(
+ //
+ // -
+ //
+ // )
+ // ii++
+ // }
if (this.props.selectedInstance.finalReview) {
let finalReviewPointsCell = (
@@ -271,7 +276,7 @@ export class CoursePage extends React.Component {
for (; i < this.props.selectedInstance.weekAmount; i++) {
headers.push(
Week {i + 1} )
}
- for (var ii = 1; ii <= numberOfCodeReviews; ii++) {
+ for (var ii = 1; ii <= this.props.selectedInstance.amountOfCodeReviews; ii++) {
headers.push(
Code Review {ii} )
}
if (this.props.selectedInstance.finalReview) {
@@ -344,7 +349,7 @@ export class CoursePage extends React.Component {
{comment.comment} {' '}
- {this.trimDate(comment.createdAt)}
+ {trimDate(comment.createdAt)}
@@ -357,7 +362,7 @@ export class CoursePage extends React.Component {
{comment.comment} {' '}
- {this.trimDate(comment.createdAt)}
+ {trimDate(comment.createdAt)}
{/* This hack compares user's name to comment.from and hides the email notification button when they don't match. */}
@@ -501,15 +506,15 @@ export class CoursePage extends React.Component {
let renderTeacherTopPart = () => {
return (
-
-
+
+
{this.props.selectedInstance.name}
{this.props.courseInstance && this.props.courseInstance.active === true ? (
this.props.courseData.data !== null ? (
) : (
-
+
You have not activated this course.
@@ -587,7 +592,7 @@ export class CoursePage extends React.Component {
)}
-
+
Student
@@ -749,7 +754,7 @@ export class CoursePage extends React.Component {
)
} else if (this.props.courseData.role === 'teacher') {
return (
-
+
{renderTeacherTopPart()}
{renderTeacherBottomPart()}
diff --git a/labtool2.0/src/components/pages/CreateChecklist.js b/labtool2.0/src/components/pages/CreateChecklist.js
index 08450c52e..caa077644 100644
--- a/labtool2.0/src/components/pages/CreateChecklist.js
+++ b/labtool2.0/src/components/pages/CreateChecklist.js
@@ -8,6 +8,8 @@ import { getOneCI, getAllCI } from '../../services/courseInstance'
import { resetChecklist, changeField, addTopic, addRow, removeTopic, removeRow, castPointsToNumber } from '../../reducers/checklistReducer'
import './CreateChecklist.css'
+import BackButton from '../BackButton'
+
export class CreateChecklist extends Component {
constructor(props) {
super(props)
@@ -328,6 +330,7 @@ export class CreateChecklist extends Component {
const { checklistJsx, maxPoints } = this.props.loading.loading ? { checklistJsx: null, maxPoints: null } : this.renderChecklist()
return (
+
{this.props.selectedInstance.name}
diff --git a/labtool2.0/src/components/pages/ModifyCourseInstanceCodeReviews.js b/labtool2.0/src/components/pages/ModifyCourseInstanceCodeReviews.js
index 9e15ddb89..4d52eec3f 100644
--- a/labtool2.0/src/components/pages/ModifyCourseInstanceCodeReviews.js
+++ b/labtool2.0/src/components/pages/ModifyCourseInstanceCodeReviews.js
@@ -1,5 +1,6 @@
import React from 'react'
import { connect } from 'react-redux'
+import { Link } from 'react-router-dom'
import { getOneCI } from '../../services/courseInstance'
import { coursePageInformation } from '../../services/courseInstance'
import { bulkinsertCodeReviews, removeOneCodeReview } from '../../services/codeReview'
@@ -22,6 +23,8 @@ import { Button, Table, Checkbox, Loader, Dropdown, Label, Popup, Modal, Icon }
import Notification from '../../components/pages/Notification'
import { resetLoading } from '../../reducers/loadingReducer'
+import BackButton from '../BackButton'
+
export class ModifyCourseInstanceReview extends React.Component {
state = {
open: {}
@@ -211,6 +214,23 @@ export class ModifyCourseInstanceReview extends React.Component {
!s[id] ? ((s[id] = true), this.setState({ open: s })) : ((s[id] = !s[id]), this.setState({ open: s }))
}
+ visibilityReminder = () =>
+ this.props.selectedInstance.currentCodeReview && this.props.codeReviewLogic.selectedDropdown ? (
+ this.props.selectedInstance.currentCodeReview.findIndex(cr => cr === this.props.codeReviewLogic.selectedDropdown) === -1 ? (
+
}
+ content={
+
+ This code review is currently not visible to students. You can make it visible on the
+ course editing page
+ .
+
+ }
+ hoverable
+ />
+ ) : null
+ ) : null
+
render() {
if (this.props.loading.loading) {
return
@@ -218,6 +238,7 @@ export class ModifyCourseInstanceReview extends React.Component {
return (
+
{this.props.selectedInstance.name}
@@ -270,15 +291,17 @@ export class ModifyCourseInstanceReview extends React.Component {
Reviewer
Project Info
- {' '}
- 0 ? 'Select code review' : 'No code reviews'}
- fluid
- options={this.props.dropdownCodeReviews}
- />
+
+
+ 0 ? 'Select code review' : 'No code reviews'}
+ fluid
+ options={this.props.dropdownCodeReviews}
+ />
+
{this.props.codeReviewLogic.showCreate ? (
diff --git a/labtool2.0/src/components/pages/ModifyCourseInstancePage.js b/labtool2.0/src/components/pages/ModifyCourseInstancePage.js
index 0e589347a..6e327d0f9 100644
--- a/labtool2.0/src/components/pages/ModifyCourseInstancePage.js
+++ b/labtool2.0/src/components/pages/ModifyCourseInstancePage.js
@@ -9,6 +9,8 @@ import { clearNotifications } from '../../reducers/notificationReducer'
import { changeCourseField } from '../../reducers/selectedInstanceReducer'
import { resetLoading, addRedirectHook } from '../../reducers/loadingReducer'
+import BackButton from '../BackButton'
+
/**
* Page used to modify a courseinstances information. Can only be accessed by teachers.
*/
@@ -87,124 +89,127 @@ export class ModifyCourseInstancePage extends Component {
}
const selectedInstance = { ...this.props.selectedInstance }
return (
-
-
-
-
- Edit course: {selectedInstance.name}
-
-
-
-
-
- Week amount
-
-
-
-
- Weekly maxpoints
-
-
-
-
- Current week
-
-
-
-
- Currently visible code reviews
- {this.props.selectedInstance.currentCodeReview
- ? this.props.selectedInstance.currentCodeReview
- .sort((a, b) => {
- return a - b
- })
- .map(
- cr =>
- this.state.toRemoveCr.includes(cr) ? (
-
- {cr}
-
- }
- content={'Click to not be removed on save'}
- />
- ) : (
-
- {cr}
-
- }
- content={'Click to be removed on save'}
- />
- )
- )
- : null}
-
-
- 0 ? 'Select code reviews to set visible' : 'No code reviews'}
- />
-
-
-
-
-
-
-
-
-
-
-
-
- Save
-
-
-
-
- Cancel
+
+
+
+
+
+
+ Edit course: {selectedInstance.name}
+
+
+
+
+
+ Week amount
+
+
+
+
+ Weekly maxpoints
+
+
+
+
+ Current week
+
+
+
+
+ Currently visible code reviews
+ {this.props.selectedInstance.currentCodeReview
+ ? this.props.selectedInstance.currentCodeReview
+ .sort((a, b) => {
+ return a - b
+ })
+ .map(
+ cr =>
+ this.state.toRemoveCr.includes(cr) ? (
+
+ {cr}
+
+ }
+ content={'This code review will be hidden on save'}
+ />
+ ) : (
+
+ {cr}
+
+ }
+ content={'Click to hide this code review on save'}
+ />
+ )
+ )
+ : null}
+
+
+ 0 ? 'Select code reviews to set visible' : 'No code reviews'}
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+ Save
-
-
-
-
-
-
-
-
- Add or remove assistant teachers
-
-
-
-
- Add or modify codereviews
-
-
-
-
- Create new checklist
-
-
-
-
- Edit tags
-
-
+
+
+
+ Cancel
+
+
+
+
+
+
+
+
+
+ Manage assistant teachers
+
+
+
+
+ Edit code reviews
+
+
+
+
+ Edit checklists
+
+
+
+
+ Edit tags
+
+
+
)
}
diff --git a/labtool2.0/src/components/pages/ModifyCourseInstanceStaff.js b/labtool2.0/src/components/pages/ModifyCourseInstanceStaff.js
index fb798aa53..7cf4b0b5f 100644
--- a/labtool2.0/src/components/pages/ModifyCourseInstanceStaff.js
+++ b/labtool2.0/src/components/pages/ModifyCourseInstanceStaff.js
@@ -8,6 +8,8 @@ import { Table, Container, Header, Button, Label, Form, Loader } from 'semantic-
import { resetLoading } from '../../reducers/loadingReducer'
import { sortUsersByAdminAssistantLastname } from '../../util/sort'
+import BackButton from '../BackButton'
+
export class ModifyCourseInstanceStaff extends React.Component {
componentWillMount = async () => {
await this.props.resetLoading()
@@ -56,6 +58,7 @@ export class ModifyCourseInstanceStaff extends React.Component {
}
return (
+
Add and remove assistants
{this.props.selectedInstance.name}
diff --git a/labtool2.0/src/components/pages/ReviewStudent.js b/labtool2.0/src/components/pages/ReviewStudent.js
index e0af11db3..5f72e850f 100644
--- a/labtool2.0/src/components/pages/ReviewStudent.js
+++ b/labtool2.0/src/components/pages/ReviewStudent.js
@@ -59,7 +59,7 @@ export class ReviewStudent extends Component {
copyChecklistOutput = async e => {
e.preventDefault()
- this.reviewPointsRef.current.inputRef.value = e.target.points.value
+ this.reviewPointsRef.current.inputRef.value = Number(e.target.points.value).toFixed(2)
/* The below line is as hacky as it is because functional elements cannot directly have refs.
* This abomination somehow accesses a textarea that is a child of a div that holds the ref.
*/
@@ -175,22 +175,23 @@ export class ReviewStudent extends Component {
{checkList.list[cl].map(row => (
-
- {row.name}
-
-
-
- {row.checkedPoints} p
-
-
-
- {row.uncheckedPoints} p
-
-
+
+
+
+
+
+
+ {row.name}
+
+
+ {`${row.checkedPoints} p / ${row.uncheckedPoints} p`}
+
+
+
))}
diff --git a/labtool2.0/src/reducers/notificationReducer.js b/labtool2.0/src/reducers/notificationReducer.js
index 8980f654f..14c67f338 100644
--- a/labtool2.0/src/reducers/notificationReducer.js
+++ b/labtool2.0/src/reducers/notificationReducer.js
@@ -188,9 +188,16 @@ const notificationReducer = (state = {}, action) => {
}
case 'CODE_REVIEW_REMOVE_ONE_SUCCESS':
- return {
+ return {
message: 'Code review removed succesfully!',
error: false
+ }
+ case 'STUDENT_PROJECT_INFO_UPDATE_FAILURE': {
+ const { message } = action.response.response.data
+ return {
+ message,
+ error: true
+ }
}
default:
return state
diff --git a/labtool2.0/src/tests/__snapshots__/BrowseReviews.test.js.snap b/labtool2.0/src/tests/__snapshots__/BrowseReviews.test.js.snap
index d84fd1a3e..a0ec52cdf 100644
--- a/labtool2.0/src/tests/__snapshots__/BrowseReviews.test.js.snap
+++ b/labtool2.0/src/tests/__snapshots__/BrowseReviews.test.js.snap
@@ -13,8 +13,16 @@ exports[`
BrowseReviews Component should render correctly 1`] =
active={false}
/>
+
diff --git a/labtool2.0/src/tests/__snapshots__/CoursePage.test.js.snap b/labtool2.0/src/tests/__snapshots__/CoursePage.test.js.snap
index 3db56b477..69ea3ae14 100644
--- a/labtool2.0/src/tests/__snapshots__/CoursePage.test.js.snap
+++ b/labtool2.0/src/tests/__snapshots__/CoursePage.test.js.snap
@@ -305,7 +305,13 @@ exports[` as student CoursePage Component should render correctly
`;
exports[` as teacher CoursePage Component should render correctly 1`] = `
-
+
as teacher CoursePage Component should render correctly
}
}
>
-
-
+
+
@@ -451,6 +453,8 @@ exports[`
as teacher CoursePage Component should render correctly
component should render correctly 1`] = `
+
Aineopintojen harjoitustyö: Tietorakenteet ja algoritmit
diff --git a/labtool2.0/src/tests/__snapshots__/ModifyCourseInstancePage.test.js.snap b/labtool2.0/src/tests/__snapshots__/ModifyCourseInstancePage.test.js.snap
index cde026b09..26e8a989d 100644
--- a/labtool2.0/src/tests/__snapshots__/ModifyCourseInstancePage.test.js.snap
+++ b/labtool2.0/src/tests/__snapshots__/ModifyCourseInstancePage.test.js.snap
@@ -1,339 +1,344 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`
Modify Instance Component should render correctly 1`] = `
-
-
+
-
-
-
- Edit course:
- Aineopintojen harjoitustyö: Tietokantasovellus (periodi IV)
-
-
-
-
-
-
-
+
+
+
- Add or remove assistant teachers
-
-
-
-
+ Manage assistant teachers
+
+
+
- Add or modify codereviews
-
-
-
-
+ Edit code reviews
+
+
+
- Create new checklist
-
-
-
-
+ Edit checklists
+
+
+
- Edit tags
-
-
+
+ Edit tags
+
+
+
`;
diff --git a/labtool2.0/src/tests/__snapshots__/ModifyCourseInstanceStaff.test.js.snap b/labtool2.0/src/tests/__snapshots__/ModifyCourseInstanceStaff.test.js.snap
index 2bf704f72..2db898db5 100644
--- a/labtool2.0/src/tests/__snapshots__/ModifyCourseInstanceStaff.test.js.snap
+++ b/labtool2.0/src/tests/__snapshots__/ModifyCourseInstanceStaff.test.js.snap
@@ -2,6 +2,9 @@
exports[` Components renders correctly 1`] = `
+
ReviewStudent Component should render correctly 1`] =
key="Koodin laatu"
>
-
-
- Koodin laatu
-
-
-
-
- p
-
-
-
- p
-
-
+
+
+
+
+
+
+
+ Koodin laatu
+
+
+
+
+ undefined p / undefined p
+
+
+
+
@@ -212,53 +199,40 @@ exports[` ReviewStudent Component should render correctly 1`] =
key="Algoritmin runko"
>
-
-
- Algoritmin runko
-
-
-
-
- p
-
-
-
- p
-
-
+
+
+
+
+
+
+
+ Algoritmin runko
+
+
+
+
+ undefined p / undefined p
+
+
+
+
ReviewStudent Component should render correctly 1`] =
key="Tietorakenteita luotu"
>
-
-
- Tietorakenteita luotu
-
-
-
-
- p
-
-
-
- p
-
-
+
+
+
+
+
+
+
+ Tietorakenteita luotu
+
+
+
+
+ undefined p / undefined p
+
+
+
+
@@ -330,53 +291,40 @@ exports[` ReviewStudent Component should render correctly 1`] =
key="Readme"
>
-
-
- Readme
-
-
-
-
- p
-
-
-
- p
-
-
+
+
+
+
+
+
+
+ Readme
+
+
+
+
+ undefined p / undefined p
+
+
+
+
ReviewStudent Component should render correctly 1`] =
key="Tuntikirjanpito"
>
-
-
- Tuntikirjanpito
-
-
-
-
- p
-
-
-
- p
-
-
+
+
+
+
+
+
+
+ Tuntikirjanpito
+
+
+
+
+ undefined p / undefined p
+
+
+
+
diff --git a/labtool2.0/src/util/format.js b/labtool2.0/src/util/format.js
new file mode 100644
index 000000000..d278d8867
--- /dev/null
+++ b/labtool2.0/src/util/format.js
@@ -0,0 +1,10 @@
+const zeros = number => {
+ const stringForm = number.toString()
+ return stringForm.length === 1 ? `0${stringForm}` : stringForm
+}
+
+export const trimDate = stringForm => {
+ const date = new Date(stringForm)
+ if (!date) return '--.--.----, --:--:--'
+ return `${zeros(date.getDate())}.${zeros(date.getMonth() + 1)}.${date.getFullYear()}, ${zeros(date.getHours())}:${zeros(date.getMinutes())}:${zeros(date.getSeconds())}`
+}