Compare commits
141 Commits
rir/header
...
kdmccormic
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7a13d58f2 | ||
|
|
6728242671 | ||
|
|
beb2c3cbae | ||
|
|
973c6e9a0a | ||
|
|
09cfee335f | ||
|
|
ee274a2fb0 | ||
|
|
baa26f3b20 | ||
|
|
0f7ffcbec1 | ||
|
|
f5616f77fd | ||
|
|
ecf5ef4664 | ||
|
|
480ea1915c | ||
|
|
a646b7b77c | ||
|
|
a2503d7067 | ||
|
|
7413c2100f | ||
|
|
8733ab5e1f | ||
|
|
8dc5836daa | ||
|
|
993809b5b0 | ||
|
|
9665859ea2 | ||
|
|
386bbea84b | ||
|
|
ee8e56a792 | ||
|
|
80aa4f10a0 | ||
|
|
2d0bf8c322 | ||
|
|
eaa2db5019 | ||
|
|
de6b2f1219 | ||
|
|
12db9448d8 | ||
|
|
52da367d18 | ||
|
|
e8cbc66e6f | ||
|
|
bc39443d94 | ||
|
|
15cdd7a256 | ||
|
|
81601ca6ea | ||
|
|
c773c35bbc | ||
|
|
b4e77b2b3f | ||
|
|
56b90cd223 | ||
|
|
7fa24969ac | ||
|
|
924dcda088 | ||
|
|
18f9ffcfde | ||
|
|
1e7871795c | ||
|
|
cd309c47e1 | ||
|
|
5d9d2af578 | ||
|
|
c5306296c9 | ||
|
|
49e3fd23d7 | ||
|
|
7bdd1533c3 | ||
|
|
22cf805960 | ||
|
|
be84c91981 | ||
|
|
4434857ada | ||
|
|
7764f78386 | ||
|
|
b4a5288b4b | ||
|
|
caea72b92e | ||
|
|
93128ac728 | ||
|
|
05bd0d740c | ||
|
|
f041d6b16d | ||
|
|
b90df949b9 | ||
|
|
9c1f5ed239 | ||
|
|
f38cd91fb1 | ||
|
|
588528abf6 | ||
|
|
d62b9ca520 | ||
|
|
ec08ef4bcb | ||
|
|
d5b3edc850 | ||
|
|
4f7d764d20 | ||
|
|
2dacc2c037 | ||
|
|
88fa2e60f4 | ||
|
|
2822e36b7b | ||
|
|
f46fe3f8ee | ||
|
|
e787d3a697 | ||
|
|
d77737f132 | ||
|
|
9ed5c6cb34 | ||
|
|
5b16a5dbb2 | ||
|
|
2c9c505b32 | ||
|
|
9425e06f8f | ||
|
|
e7134d8f68 | ||
|
|
e547d67f19 | ||
|
|
8b1d5aacf2 | ||
|
|
5a243e1b5f | ||
|
|
a957e16424 | ||
|
|
0d12eaf979 | ||
|
|
3e2787b0e0 | ||
|
|
35c632b716 | ||
|
|
801e2d6d59 | ||
|
|
7bd81d7a2b | ||
|
|
2b8ecf2c78 | ||
|
|
de13ac5093 | ||
|
|
ade906896c | ||
|
|
43181e39cc | ||
|
|
f60a9647b4 | ||
|
|
7dc1ffdd42 | ||
|
|
2913f1d965 | ||
|
|
7f85fb12e3 | ||
|
|
90f66d3759 | ||
|
|
fb09bee8d9 | ||
|
|
e31495b00b | ||
|
|
0557f29e0b | ||
|
|
e08b13f218 | ||
|
|
dee42eee7e | ||
|
|
1a0fe945a5 | ||
|
|
704144f9d1 | ||
|
|
a1ab29702f | ||
|
|
f619308ce5 | ||
|
|
c235da8cc0 | ||
|
|
777e0696ee | ||
|
|
95b8ba146e | ||
|
|
8463a28c7d | ||
|
|
bdee388dbd | ||
|
|
e0633dc816 | ||
|
|
668620a5f0 | ||
|
|
cfbb02a54c | ||
|
|
b22b44bbf5 | ||
|
|
80d9e32fba | ||
|
|
ef8975df86 | ||
|
|
09e482e893 | ||
|
|
d4421d47fc | ||
|
|
0ef8e773cc | ||
|
|
1dac20b866 | ||
|
|
ed2d715ce0 | ||
|
|
c82c49ea59 | ||
|
|
a9f8aec5f9 | ||
|
|
a63e9a5347 | ||
|
|
2581812118 | ||
|
|
c4fe803a95 | ||
|
|
93be5329ca | ||
|
|
80ba7e7152 | ||
|
|
f88526aa3a | ||
|
|
c0f08eee58 | ||
|
|
ef62ea35dc | ||
|
|
34eaa31776 | ||
|
|
a7316e6824 | ||
|
|
c0ab04f20c | ||
|
|
ed72e7c203 | ||
|
|
223d9a00bd | ||
|
|
8379f48e50 | ||
|
|
9e1268e388 | ||
|
|
57e0f2254a | ||
|
|
2cc14191b4 | ||
|
|
603dbeb823 | ||
|
|
55cb1f4140 | ||
|
|
55648a62ff | ||
|
|
62f9d24704 | ||
|
|
f036b0cf34 | ||
|
|
67493d1e9e | ||
|
|
e5bca7e526 | ||
|
|
52c5357ce7 | ||
|
|
d469cc2de7 |
@@ -1,3 +1,5 @@
|
|||||||
coverage/*
|
coverage/*
|
||||||
dist/
|
dist/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
src/postcss.config.js
|
||||||
|
src/segment.js
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
"jsx-a11y/anchor-is-valid": [ "error", {
|
"jsx-a11y/anchor-is-valid": [ "error", {
|
||||||
"components": [ "Link" ],
|
"components": [ "Link" ],
|
||||||
"specialLink": [ "to" ]
|
"specialLink": [ "to" ]
|
||||||
}]
|
}],
|
||||||
|
// https://github.com/yannickcr/eslint-plugin-react/issues/1754#issuecomment-378838053
|
||||||
|
// tl;dr: this rule is no longer going to cause any user-facing visual weirdness, its original motivation
|
||||||
|
"react/no-did-mount-set-state": "off"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"jest": true
|
"jest": true
|
||||||
|
|||||||
12
.travis.yml
12
.travis.yml
@@ -1,21 +1,14 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js: 12
|
||||||
- lts/*
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- "~/.npm"
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
recipients:
|
recipients:
|
||||||
- adusenbery@edx.org
|
- masters-grades@edx.org
|
||||||
- rreilly@edx.org
|
|
||||||
- schen@edx.org
|
|
||||||
on_success: never
|
on_success: never
|
||||||
on_failure: always
|
on_failure: always
|
||||||
webhooks: https://www.travisbuddy.com/
|
webhooks: https://www.travisbuddy.com/
|
||||||
on_success: never
|
on_success: never
|
||||||
before_install:
|
before_install:
|
||||||
- npm install -g npm@latest
|
|
||||||
- npm install -g greenkeeper-lockfile@1.14.0
|
- npm install -g greenkeeper-lockfile@1.14.0
|
||||||
install:
|
install:
|
||||||
- npm ci
|
- npm ci
|
||||||
@@ -23,6 +16,7 @@ before_script: greenkeeper-lockfile-update
|
|||||||
after_script: greenkeeper-lockfile-upload
|
after_script: greenkeeper-lockfile-upload
|
||||||
script:
|
script:
|
||||||
- make validate-no-uncommitted-package-lock-changes
|
- make validate-no-uncommitted-package-lock-changes
|
||||||
|
- npm run lint
|
||||||
- npm run test
|
- npm run test
|
||||||
- npm run build
|
- npm run build
|
||||||
after_success:
|
after_success:
|
||||||
|
|||||||
29
Dockerfile
29
Dockerfile
@@ -1,29 +0,0 @@
|
|||||||
# Copied from https://github.com/BretFisher/node-docker-good-defaults/blob/master/Dockerfile
|
|
||||||
|
|
||||||
FROM node:8.9.3
|
|
||||||
|
|
||||||
# Create app directory
|
|
||||||
RUN mkdir -p /edx/app
|
|
||||||
|
|
||||||
ARG NODE_ENV=production
|
|
||||||
ENV NODE_ENV $NODE_ENV
|
|
||||||
|
|
||||||
ARG PORT=80
|
|
||||||
ENV PORT $PORT
|
|
||||||
EXPOSE $PORT 1991
|
|
||||||
|
|
||||||
WORKDIR /edx
|
|
||||||
# Install app dependencies
|
|
||||||
# A wildcard is used to ensure both package.json AND package-lock.json are copied
|
|
||||||
# where available (npm@5+)
|
|
||||||
COPY package*.json ./
|
|
||||||
|
|
||||||
# If you are building your code for production
|
|
||||||
# RUN npm install --only=production
|
|
||||||
RUN npm install
|
|
||||||
ENV PATH /edx/app/node_modules/.bin:$PATH
|
|
||||||
|
|
||||||
WORKDIR /edx/app
|
|
||||||
COPY . /edx/app
|
|
||||||
|
|
||||||
ENTRYPOINT npm install && npm run start
|
|
||||||
149
LICENSE
149
LICENSE
@@ -1,23 +1,21 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
software and other kinds of works.
|
software and other kinds of works, specifically designed to ensure
|
||||||
|
cooperation with the community in the case of network server software.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
The licenses for most software and other practical works are designed
|
||||||
to take away your freedom to share and change the works. By contrast,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
share and change all versions of a program--to make sure it remains free
|
share and change all versions of a program--to make sure it remains free
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
software for all its users.
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
When we speak of free software, we are referring to freedom, not
|
||||||
price. Our General Public Licenses are designed to make sure that you
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
@@ -26,44 +24,34 @@ them if you wish), that you receive source code or can get it if you
|
|||||||
want it, that you can change the software or use pieces of it in new
|
want it, that you can change the software or use pieces of it in new
|
||||||
free programs, and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you
|
Developers that use our General Public Licenses protect your rights
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
you this License which gives you legal permission to copy, distribute
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
and/or modify the software.
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
A secondary benefit of defending all users' freedom is that
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
improvements made in alternate versions of the program, if they
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
receive widespread use, become available for other developers to
|
||||||
or can get the source code. And you must show them these terms so they
|
incorporate. Many developers of free software are heartened and
|
||||||
know their rights.
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
The GNU Affero General Public License is designed specifically to
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
ensure that, in such cases, the modified source code becomes available
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
An older license, called the Affero General Public License and
|
||||||
that there is no warranty for this free software. For both users' and
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
changed, so that their problems will not be attributed erroneously to
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
authors of previous versions.
|
this license.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
@@ -72,7 +60,7 @@ modification follow.
|
|||||||
|
|
||||||
0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
"This License" refers to version 3 of the GNU General Public License.
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
|
|
||||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
works, such as semiconductor masks.
|
works, such as semiconductor masks.
|
||||||
@@ -549,35 +537,45 @@ to collect a royalty for further conveying from those to whom you convey
|
|||||||
the Program, the only way you could satisfy both those terms and this
|
the Program, the only way you could satisfy both those terms and this
|
||||||
License would be to refrain entirely from conveying the Program.
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
|
Program, your modified version must prominently offer all users
|
||||||
|
interacting with it remotely through a computer network (if your version
|
||||||
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
|
Source of your version by providing access to the Corresponding Source
|
||||||
|
from a network server at no charge, through some standard or customary
|
||||||
|
means of facilitating copying of software. This Corresponding Source
|
||||||
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
|
following paragraph.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
Notwithstanding any other provision of this License, you have
|
||||||
permission to link or combine any covered work with a work licensed
|
permission to link or combine any covered work with a work licensed
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
under version 3 of the GNU General Public License into a single
|
||||||
combined work, and to convey the resulting work. The terms of this
|
combined work, and to convey the resulting work. The terms of this
|
||||||
License will continue to apply to the part which is the covered work,
|
License will continue to apply to the part which is the covered work,
|
||||||
but the special requirements of the GNU Affero General Public License,
|
but the work with which it is combined will remain governed by version
|
||||||
section 13, concerning interaction through a network will apply to the
|
3 of the GNU General Public License.
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
the GNU General Public License from time to time. Such new versions will
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
will be similar in spirit to the present version, but may differ in detail to
|
||||||
address new problems or concerns.
|
address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
Each version is given a distinguishing version number. If the
|
||||||
Program specifies that a certain numbered version of the GNU General
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
Public License "or any later version" applies to it, you have the
|
Public License "or any later version" applies to it, you have the
|
||||||
option of following the terms and conditions either of that numbered
|
option of following the terms and conditions either of that numbered
|
||||||
version or of any later version published by the Free Software
|
version or of any later version published by the Free Software
|
||||||
Foundation. If the Program does not specify a version number of the
|
Foundation. If the Program does not specify a version number of the
|
||||||
GNU General Public License, you may choose any version ever published
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
by the Free Software Foundation.
|
by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
If the Program specifies that a proxy can decide which future
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
public statement of acceptance of a version permanently authorizes you
|
public statement of acceptance of a version permanently authorizes you
|
||||||
to choose that version for the Program.
|
to choose that version for the Program.
|
||||||
|
|
||||||
@@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||||||
Copyright (C) <year> <name of author>
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU Affero General Public License as published
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
by the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU Affero General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short
|
If your software can interact with users remotely through a computer
|
||||||
notice like this when it starts in an interactive mode:
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
<program> Copyright (C) <year> <name of author>
|
interface could display a "Source" link that leads users to an archive
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
of the code. There are many ways you could offer source, and different
|
||||||
This is free software, and you are welcome to redistribute it
|
solutions will be better for different programs; see section 13 for the
|
||||||
under certain conditions; type `show c' for details.
|
specific requirements.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
|
||||||
parts of the General Public License. Of course, your program's commands
|
|
||||||
might be different; for a GUI interface, you would use an "about box".
|
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school,
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
For more information on this, and how to apply and follow the GNU GPL, see
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
<http://www.gnu.org/licenses/>.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program
|
|
||||||
into proprietary programs. If your program is a subroutine library, you
|
|
||||||
may consider it more useful to permit linking proprietary applications with
|
|
||||||
the library. If this is what you want to do, use the GNU Lesser General
|
|
||||||
Public License instead of this License. But first, please read
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
|
|||||||
32
Makefile
32
Makefile
@@ -1,35 +1,9 @@
|
|||||||
shell: ## run a shell on the cookie-cutter container
|
npm-install-%: ## install specified % npm package
|
||||||
docker exec -it edx.gradebook /bin/bash
|
npm install $* --save-dev
|
||||||
|
|
||||||
build:
|
|
||||||
docker-compose build
|
|
||||||
|
|
||||||
up: ## bring up cookie-cutter container
|
|
||||||
docker-compose up
|
|
||||||
|
|
||||||
up-detached: ## bring up cookie-cutter container in detached mode
|
|
||||||
docker-compose up -d
|
|
||||||
|
|
||||||
logs: ## show logs for cookie-cutter container
|
|
||||||
docker-compose logs -f
|
|
||||||
|
|
||||||
down: ## stop and remove cookie-cutter container
|
|
||||||
docker-compose down
|
|
||||||
|
|
||||||
npm-install-%: ## install specified % npm package on the cookie-cutter container
|
|
||||||
docker exec npm install $* --save-dev
|
|
||||||
git add package.json
|
git add package.json
|
||||||
|
|
||||||
restart:
|
|
||||||
make down
|
|
||||||
make up
|
|
||||||
|
|
||||||
restart-detached:
|
|
||||||
make down
|
|
||||||
make up-detached
|
|
||||||
|
|
||||||
validate-no-uncommitted-package-lock-changes:
|
validate-no-uncommitted-package-lock-changes:
|
||||||
git diff --exit-code package-lock.json
|
git diff --exit-code package-lock.json
|
||||||
|
|
||||||
test:
|
test:
|
||||||
docker exec -it edx.gradebook jest
|
npm run test
|
||||||
|
|||||||
29
README.md
29
README.md
@@ -1,7 +1,7 @@
|
|||||||
[](https://travis-ci.org/edx/gradebook) [](https://coveralls.io/github/edx/gradebook)
|
[](https://travis-ci.org/edx/frontend-app-gradebook) [](https://coveralls.io/github/edx/frontend-app-gradebook)
|
||||||
[](@edx/gradebook)
|
[](@edx/frontend-app-gradebook)
|
||||||
[](@edx/gradebook)
|
[](@edx/frontend-app-gradebook)
|
||||||
[](@edx/gradebook)
|
[](@edx/frontend-app-gradebook)
|
||||||
[](https://github.com/semantic-release/semantic-release)
|
[](https://github.com/semantic-release/semantic-release)
|
||||||
|
|
||||||
# gradebook
|
# gradebook
|
||||||
@@ -16,25 +16,25 @@ The front-end of our editable Gradebook feature.
|
|||||||
|
|
||||||
To install gradebook into your project:
|
To install gradebook into your project:
|
||||||
```
|
```
|
||||||
npm i --save @edx/gradebook
|
npm i --save @edx/frontend-app-gradebook
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running the UI Standalone
|
## Running the UI Standalone
|
||||||
|
|
||||||
After cloning the repository, run `make up-detached` in the `gradebook` directory - this will build and start the `gradebook` web application in a docker container.
|
To install the project please refer to the [`edX Developer Stack`](https://github.com/edx/devstack) instructions.
|
||||||
|
|
||||||
The web application runs on port **1991**, so when you go to `http://localhost:1991/course-v1:edX+DemoX+Demo_Course` you should see the UI (assuming you have such a Demo Course in your devstack). Note that you always have to provide a course id to actually see a gradebook.
|
The web application runs on port **1994**, so when you go to `http://localhost:1994/course-v1:edX+DemoX+Demo_Course` you should see the UI (assuming you have such a Demo Course in your devstack). Note that you always have to provide a course id to actually see a gradebook.
|
||||||
|
|
||||||
If you don't, you can see the log messages for the docker container by executing `make logs` in the `gradebook` directory.
|
If you don't, you can see the log messages for the docker container by executing `make gradebook-logs` in the `devstack` directory.
|
||||||
|
|
||||||
Note that `make up-detached` executes the `npm run start` script which will hot-reload JavaScript and Sass files changes, so you should (:crossed_fingers:) not need to do anything (other than wait) when making changes.
|
Note that starting the container executes the `npm run start` script which will hot-reload JavaScript and Sass files changes, so you should (:crossed_fingers:) not need to do anything (other than wait) when making changes.
|
||||||
|
|
||||||
## Configuring for local use in edx-platform
|
## Configuring for local use in edx-platform
|
||||||
|
|
||||||
Assuming you've got the UI running at `http://localhost:1991`, you can configure the LMS in edx-platform
|
Assuming you've got the UI running at `http://localhost:1994`, you can configure the LMS in edx-platform
|
||||||
to point to your local gradebook from the instructor dashboard by putting this settings in `lms/env/private.py`:
|
to point to your local gradebook from the instructor dashboard by putting this settings in `lms/env/private.py`:
|
||||||
```
|
```
|
||||||
WRITABLE_GRADEBOOK_URL = 'http://localhost:1991'
|
WRITABLE_GRADEBOOK_URL = 'http://localhost:1994'
|
||||||
```
|
```
|
||||||
|
|
||||||
There are also several edx-platform waffle and feature flags you'll have to enable from the Django admin:
|
There are also several edx-platform waffle and feature flags you'll have to enable from the Django admin:
|
||||||
@@ -49,6 +49,13 @@ in which you'd like to enable the gradebook. Add a course override flag using a
|
|||||||
``grades.writable_gradebook``. Make sure to check the ``enabled`` box. Alternatively, you could add this as a
|
``grades.writable_gradebook``. Make sure to check the ``enabled`` box. Alternatively, you could add this as a
|
||||||
regular waffle flag to enable the gradebook for all courses.
|
regular waffle flag to enable the gradebook for all courses.
|
||||||
|
|
||||||
|
## Running tests
|
||||||
|
|
||||||
|
1. Assuming that you're operating in the context of the edX devstack,
|
||||||
|
run `gradebook-shell` from your devstack directory. This will start a bash shell inside your
|
||||||
|
running gradebook container.
|
||||||
|
2. Run `make test` (which executes `npm run test`). This will run all of the gradebook tests.
|
||||||
|
|
||||||
## Directory Structure
|
## Directory Structure
|
||||||
|
|
||||||
* `config`
|
* `config`
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const path = require('path');
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
|
segment: path.resolve(__dirname, '../src/segment.js'),
|
||||||
app: path.resolve(__dirname, '../src/index.jsx'),
|
app: path.resolve(__dirname, '../src/index.jsx'),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ module.exports = Merge.smart(commonConfig, {
|
|||||||
entry: [
|
entry: [
|
||||||
// enable react's custom hot dev client so we get errors reported in the browser
|
// enable react's custom hot dev client so we get errors reported in the browser
|
||||||
require.resolve('react-dev-utils/webpackHotDevClient'),
|
require.resolve('react-dev-utils/webpackHotDevClient'),
|
||||||
|
path.resolve(__dirname, '../src/segment.js'),
|
||||||
path.resolve(__dirname, '../src/index.jsx'),
|
path.resolve(__dirname, '../src/index.jsx'),
|
||||||
],
|
],
|
||||||
module: {
|
module: {
|
||||||
@@ -97,10 +98,10 @@ module.exports = Merge.smart(commonConfig, {
|
|||||||
}),
|
}),
|
||||||
new webpack.EnvironmentPlugin({
|
new webpack.EnvironmentPlugin({
|
||||||
NODE_ENV: 'development',
|
NODE_ENV: 'development',
|
||||||
BASE_URL: 'localhost:1991',
|
BASE_URL: 'localhost:19000/gradebook',
|
||||||
LMS_BASE_URL: 'http://localhost:18000',
|
LMS_BASE_URL: 'http://localhost:18000',
|
||||||
LOGIN_URL: 'http://localhost:18000/login',
|
LOGIN_URL: 'http://localhost:18000/login',
|
||||||
LOGOUT_URL: 'http://localhost:18000/login',
|
LOGOUT_URL: 'http://localhost:18000/logout',
|
||||||
CSRF_TOKEN_API_PATH: '/csrf/api/v1/token',
|
CSRF_TOKEN_API_PATH: '/csrf/api/v1/token',
|
||||||
REFRESH_ACCESS_TOKEN_ENDPOINT: 'http://localhost:18000/login_refresh',
|
REFRESH_ACCESS_TOKEN_ENDPOINT: 'http://localhost:18000/login_refresh',
|
||||||
DATA_API_BASE_URL: 'http://localhost:8000',
|
DATA_API_BASE_URL: 'http://localhost:8000',
|
||||||
@@ -110,6 +111,24 @@ module.exports = Merge.smart(commonConfig, {
|
|||||||
FEATURE_FLAGS: {},
|
FEATURE_FLAGS: {},
|
||||||
ACCESS_TOKEN_COOKIE_NAME: 'edx-jwt-cookie-header-payload',
|
ACCESS_TOKEN_COOKIE_NAME: 'edx-jwt-cookie-header-payload',
|
||||||
CSRF_COOKIE_NAME: 'csrftoken',
|
CSRF_COOKIE_NAME: 'csrftoken',
|
||||||
|
SITE_NAME: 'edX',
|
||||||
|
MARKETING_SITE_BASE_URL: 'http://localhost:18000',
|
||||||
|
SUPPORT_URL: 'http://localhost:18000/support',
|
||||||
|
CONTACT_URL: 'http://localhost:18000/contact',
|
||||||
|
OPEN_SOURCE_URL: 'http://localhost:18000/openedx',
|
||||||
|
TERMS_OF_SERVICE_URL: 'http://localhost:18000/terms-of-service',
|
||||||
|
PRIVACY_POLICY_URL: 'http://localhost:18000/privacy-policy',
|
||||||
|
FACEBOOK_URL: 'https://www.facebook.com',
|
||||||
|
TWITTER_URL: 'https://twitter.com',
|
||||||
|
YOU_TUBE_URL: 'https://www.youtube.com',
|
||||||
|
LINKED_IN_URL: 'https://www.linkedin.com',
|
||||||
|
REDDIT_URL: 'https://www.reddit.com',
|
||||||
|
APPLE_APP_STORE_URL: 'https://www.apple.com/ios/app-store/',
|
||||||
|
GOOGLE_PLAY_URL: 'https://play.google.com/store',
|
||||||
|
ENTERPRISE_MARKETING_URL: 'http://example.com',
|
||||||
|
ENTERPRISE_MARKETING_UTM_SOURCE: 'example.com',
|
||||||
|
ENTERPRISE_MARKETING_UTM_CAMPAIGN: 'example.com Referral',
|
||||||
|
ENTERPRISE_MARKETING_FOOTER_UTM_MEDIUM: 'Footer',
|
||||||
}),
|
}),
|
||||||
// when the --hot option is not passed in as part of the command
|
// when the --hot option is not passed in as part of the command
|
||||||
// the HotModuleReplacementPlugin has to be specified in the Webpack configuration
|
// the HotModuleReplacementPlugin has to be specified in the Webpack configuration
|
||||||
@@ -120,7 +139,7 @@ module.exports = Merge.smart(commonConfig, {
|
|||||||
// reloading.
|
// reloading.
|
||||||
devServer: {
|
devServer: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
port: 1991,
|
port: 1994,
|
||||||
historyApiFallback: true,
|
historyApiFallback: true,
|
||||||
hot: true,
|
hot: true,
|
||||||
inline: true,
|
inline: true,
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ module.exports = Merge.smart(commonConfig, {
|
|||||||
minimize: true,
|
minimize: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'postcss-loader',
|
'postcss-loader', // for autoprefixing, needs to be before the sass loader, not sure why
|
||||||
{
|
{
|
||||||
loader: 'sass-loader', // compiles Sass to CSS
|
loader: 'sass-loader', // compiles Sass to CSS
|
||||||
options: {
|
options: {
|
||||||
@@ -126,6 +126,24 @@ module.exports = Merge.smart(commonConfig, {
|
|||||||
CSRF_COOKIE_NAME: 'csrftoken',
|
CSRF_COOKIE_NAME: 'csrftoken',
|
||||||
NEW_RELIC_APP_ID: null,
|
NEW_RELIC_APP_ID: null,
|
||||||
NEW_RELIC_LICENSE_KEY: null,
|
NEW_RELIC_LICENSE_KEY: null,
|
||||||
|
SITE_NAME: null,
|
||||||
|
MARKETING_SITE_BASE_URL: null,
|
||||||
|
SUPPORT_URL: null,
|
||||||
|
CONTACT_URL: null,
|
||||||
|
OPEN_SOURCE_URL: null,
|
||||||
|
TERMS_OF_SERVICE_URL: null,
|
||||||
|
PRIVACY_POLICY_URL: null,
|
||||||
|
FACEBOOK_URL: null,
|
||||||
|
TWITTER_URL: null,
|
||||||
|
YOU_TUBE_URL: null,
|
||||||
|
LINKED_IN_URL: null,
|
||||||
|
REDDIT_URL: null,
|
||||||
|
APPLE_APP_STORE_URL: null,
|
||||||
|
GOOGLE_PLAY_URL: null,
|
||||||
|
ENTERPRISE_MARKETING_URL: null,
|
||||||
|
ENTERPRISE_MARKETING_UTM_SOURCE: null,
|
||||||
|
ENTERPRISE_MARKETING_UTM_CAMPAIGN: null,
|
||||||
|
ENTERPRISE_MARKETING_FOOTER_UTM_MEDIUM: null,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
version: "2"
|
|
||||||
services:
|
|
||||||
web:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
args:
|
|
||||||
- NODE_ENV=development
|
|
||||||
container_name: edx.gradebook
|
|
||||||
image: edxops/front-end-cookie-cutter:latest
|
|
||||||
volumes:
|
|
||||||
- .:/edx/app:delegated
|
|
||||||
- notused:/edx/app/node_modules
|
|
||||||
ports:
|
|
||||||
- "1991:1991"
|
|
||||||
environment:
|
|
||||||
- NODE_ENV=development
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
notused:
|
|
||||||
46
documentation/decisions/0001-update-api-usage.rst
Normal file
46
documentation/decisions/0001-update-api-usage.rst
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
Usage of the bulk-update API
|
||||||
|
============================
|
||||||
|
|
||||||
|
Context
|
||||||
|
=======
|
||||||
|
|
||||||
|
The LMS Grades API exposes a set of Gradebook-related endpoints:
|
||||||
|
https://github.com/edx/edx-platform/blob/master/lms/djangoapps/grades/api/v1/gradebook_views.py
|
||||||
|
The ``bulk-update`` endpoint defined therein allows for the creation/modification of subsection
|
||||||
|
grades for multiple users and sections in a single request. This allows clients of the API to limit
|
||||||
|
the number of network requests made and to more easily manage client-side data. Moreover,
|
||||||
|
the course grade updates that occur during calls to this API are synchronous - the entire update operation
|
||||||
|
is completed before a response is given to the client.
|
||||||
|
|
||||||
|
For decisions made about the implementation of this API, see:
|
||||||
|
https://github.com/edx/edx-platform/blob/master/lms/djangoapps/grades/docs/decisions/0001-gradebook-api.rst
|
||||||
|
|
||||||
|
Decision
|
||||||
|
========
|
||||||
|
|
||||||
|
The Gradebook front-end will post data about a single subsection and user in a single request
|
||||||
|
to the ``bulk-update`` API. That is, we currently need only the "update" aspect of this
|
||||||
|
endpoint, and not the "bulk" aspect, for satisfying the requirements of the current UX.
|
||||||
|
|
||||||
|
Status
|
||||||
|
======
|
||||||
|
|
||||||
|
Accepted (circa December 2018)
|
||||||
|
|
||||||
|
Consequences
|
||||||
|
============
|
||||||
|
|
||||||
|
This is a scenario in which the implementation of the API is coupled to the
|
||||||
|
UX that depends on the API. Because the course grade update is synchronous, it means
|
||||||
|
the API response can contain the updated subsection and course grade data. Because
|
||||||
|
a response from the API contains this data, the UI can operate in a very familiar way:
|
||||||
|
|
||||||
|
- A user clicks a button to submit a request with grade update data to the update endpoint.
|
||||||
|
- On the server, the subsection and course grades are modified.
|
||||||
|
- In the meantime, the client-side user looks at a spinner.
|
||||||
|
- A response is returned with updated data and the spinner goes away.
|
||||||
|
- Updated data is displayed to the user, along with a message indicative of the update.
|
||||||
|
|
||||||
|
If the update becomes asynchronous, the user experience outlined above has to change.
|
||||||
|
Because a single call to this endpoint updates grades data for only a single user,
|
||||||
|
the endpoint does not necessarily have to utilize an asynchronous operation at this time.
|
||||||
9
openedx.yaml
Normal file
9
openedx.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# This file describes this Open edX repo, as described in OEP-2:
|
||||||
|
# http://open-edx-proposals.readthedocs.io/en/latest/oeps/oep-0002.html#specification
|
||||||
|
|
||||||
|
nick: grbk
|
||||||
|
oeps: {}
|
||||||
|
owner: schenedx
|
||||||
|
supporting_teams:
|
||||||
|
- masters-devs
|
||||||
|
openedx-release: {ref: master}
|
||||||
16896
package-lock.json
generated
16896
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
99
package.json
99
package.json
@@ -1,13 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@edx/gradebook",
|
"name": "@edx/frontend-app-gradebook",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"description": "edx editable gradebook-ui to manipulate grade overrides on subsections",
|
"description": "edx editable gradebook-ui to manipulate grade overrides on subsections",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/edx/gradebook.git"
|
"url": "git+https://github.com/edx/frontend-app-gradebook.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "NODE_ENV=production BABEL_ENV=production webpack --config=config/webpack.prod.config.js",
|
"build": "NODE_ENV=production BABEL_ENV=production webpack --config=config/webpack.prod.config.js",
|
||||||
|
"dev-build": "NODE_ENV=development BABEL_ENV=development webpack --config=config/webpack.dev.config.js",
|
||||||
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
"coveralls": "cat ./coverage/lcov.info | coveralls",
|
||||||
"is-es5": "es-check es5 ./dist/*.js",
|
"is-es5": "es-check es5 ./dist/*.js",
|
||||||
"lint": "eslint --ext .js --ext .jsx .",
|
"lint": "eslint --ext .js --ext .jsx .",
|
||||||
@@ -15,76 +16,85 @@
|
|||||||
"semantic-release": "semantic-release",
|
"semantic-release": "semantic-release",
|
||||||
"start": "NODE_ENV=development BABEL_ENV=development node_modules/.bin/webpack-dev-server --config=config/webpack.dev.config.js --progress",
|
"start": "NODE_ENV=development BABEL_ENV=development node_modules/.bin/webpack-dev-server --config=config/webpack.dev.config.js --progress",
|
||||||
"test": "jest --coverage --passWithNoTests",
|
"test": "jest --coverage --passWithNoTests",
|
||||||
|
"watch-tests": "jest --watch",
|
||||||
"travis-deploy-once": "travis-deploy-once"
|
"travis-deploy-once": "travis-deploy-once"
|
||||||
},
|
},
|
||||||
"author": "edX",
|
"author": "edX",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"homepage": "https://github.com/edx/gradebook#readme",
|
"homepage": "https://github.com/edx/frontend-app-gradebook#readme",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@edx/edx-bootstrap": "^0.4.3",
|
"@edx/edx-bootstrap": "^0.4.3",
|
||||||
"@edx/frontend-auth": "^1.2.1",
|
"@edx/frontend-auth": "^4.0.0",
|
||||||
"@edx/paragon": "^3.7.2",
|
"@edx/frontend-component-footer": "^4.1.5",
|
||||||
|
"@edx/paragon": "^7.1.5",
|
||||||
|
"@fortawesome/fontawesome-svg-core": "^1.2.25",
|
||||||
|
"@fortawesome/free-brands-svg-icons": "^5.11.2",
|
||||||
|
"@fortawesome/free-solid-svg-icons": "^5.11.2",
|
||||||
|
"@fortawesome/react-fontawesome": "^0.1.5",
|
||||||
|
"@redux-beacon/segment": "^1.0.0",
|
||||||
"babel-polyfill": "^6.26.0",
|
"babel-polyfill": "^6.26.0",
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.6",
|
||||||
"email-prop-type": "^1.1.5",
|
"email-prop-type": "^1.1.7",
|
||||||
"font-awesome": "^4.7.0",
|
"font-awesome": "^4.7.0",
|
||||||
"history": "^4.7.2",
|
"history": "^4.10.1",
|
||||||
"prop-types": "^15.5.10",
|
"prop-types": "^15.7.2",
|
||||||
"query-string": "^5.1.1",
|
"query-string": "^5.1.1",
|
||||||
"react": "^16.2.0",
|
"react": "^16.10.1",
|
||||||
"react-dom": "^16.2.0",
|
"react-dom": "^16.10.1",
|
||||||
"react-redux": "^5.0.7",
|
"react-intl": "^2.9.0",
|
||||||
"react-router": "^4.2.0",
|
"react-redux": "^5.1.1",
|
||||||
"react-router-dom": "^4.2.2",
|
"react-router": "^4.3.1",
|
||||||
|
"react-router-dom": "^4.3.1",
|
||||||
"react-router-redux": "^5.0.0-alpha.9",
|
"react-router-redux": "^5.0.0-alpha.9",
|
||||||
"redux": "^3.7.2",
|
"redux": "^3.7.2",
|
||||||
"redux-devtools-extension": "^2.13.2",
|
"redux-beacon": "^2.1.0",
|
||||||
|
"redux-devtools-extension": "^2.13.8",
|
||||||
"redux-logger": "^3.0.6",
|
"redux-logger": "^3.0.6",
|
||||||
"redux-thunk": "^2.2.0",
|
"redux-thunk": "^2.3.0",
|
||||||
"whatwg-fetch": "^2.0.3"
|
"whatwg-fetch": "^2.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "^9.4.2",
|
"autoprefixer": "^9.6.1",
|
||||||
"axios-mock-adapter": "^1.15.0",
|
"axios-mock-adapter": "^1.17.0",
|
||||||
"babel-cli": "^6.26.0",
|
"babel-cli": "^6.26.0",
|
||||||
"babel-eslint": "^8.2.2",
|
"babel-eslint": "^8.2.6",
|
||||||
"babel-jest": "^22.4.0",
|
"babel-jest": "^22.4.4",
|
||||||
"babel-loader": "^7.1.2",
|
"babel-loader": "^7.1.5",
|
||||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||||
"babel-preset-env": "^1.6.1",
|
"babel-preset-env": "^1.7.0",
|
||||||
"babel-preset-react": "^6.24.1",
|
"babel-preset-react": "^6.24.1",
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.6.1",
|
||||||
"css-loader": "^0.28.9",
|
"css-loader": "^0.28.11",
|
||||||
"enzyme": "^3.3.0",
|
"enzyme": "^3.10.0",
|
||||||
"enzyme-adapter-react-16": "^1.1.1",
|
"enzyme-adapter-react-16": "^1.14.0",
|
||||||
"es-check": "^2.0.2",
|
"es-check": "^2.3.0",
|
||||||
"eslint-config-edx": "^4.0.3",
|
"eslint-config-edx": "^4.0.4",
|
||||||
"fetch-mock": "^6.3.0",
|
"fetch-mock": "^6.5.2",
|
||||||
"file-loader": "^1.1.9",
|
"file-loader": "^1.1.9",
|
||||||
"html-webpack-harddisk-plugin": "^0.2.0",
|
"html-webpack-harddisk-plugin": "^0.2.0",
|
||||||
"html-webpack-plugin": "^3.0.3",
|
"html-webpack-plugin": "^3.2.0",
|
||||||
"husky": "^0.14.3",
|
"husky": "^0.14.3",
|
||||||
"identity-obj-proxy": "^3.0.0",
|
"identity-obj-proxy": "^3.0.0",
|
||||||
"image-webpack-loader": "^4.2.0",
|
"image-webpack-loader": "^4.2.0",
|
||||||
"jest": "^22.4.0",
|
"jest": "^22.4.4",
|
||||||
"mini-css-extract-plugin": "^0.4.0",
|
"mini-css-extract-plugin": "^0.4.0",
|
||||||
"node-sass": "^4.7.2",
|
"node-sass": "^4.12.0",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"react-dev-utils": "^5.0.0",
|
"react-dev-utils": "^5.0.3",
|
||||||
"react-test-renderer": "^16.2.0",
|
"react-test-renderer": "^16.10.1",
|
||||||
"redux-mock-store": "^1.5.1",
|
"redux-mock-store": "^1.5.3",
|
||||||
"sass-loader": "^6.0.6",
|
"sass-loader": "^6.0.6",
|
||||||
"semantic-release": "^15.10.7",
|
"semantic-release": "^15.13.24",
|
||||||
"style-loader": "^0.20.2",
|
"style-loader": "^0.20.3",
|
||||||
"travis-deploy-once": "^5.0.9",
|
"travis-deploy-once": "^5.0.11",
|
||||||
"webpack": "^4.25.1",
|
"webpack": "^4.41.0",
|
||||||
"webpack-cli": "^3.1.2",
|
"webpack-cli": "^3.3.9",
|
||||||
"webpack-dev-server": "^3.1.0",
|
"webpack-dev-server": "^3.8.2",
|
||||||
"webpack-merge": "^4.1.1"
|
"webpack-merge": "^4.2.2"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"setupFiles": [
|
"setupFiles": [
|
||||||
@@ -105,6 +115,7 @@
|
|||||||
],
|
],
|
||||||
"transformIgnorePatterns": [
|
"transformIgnorePatterns": [
|
||||||
"/node_modules/(?!(@edx/paragon)/).*/"
|
"/node_modules/(?!(@edx/paragon)/).*/"
|
||||||
]
|
],
|
||||||
|
"testURL": "http://localhost"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/App.scss
13
src/App.scss
@@ -1,12 +1,13 @@
|
|||||||
@import "~@edx/edx-bootstrap/sass/edx/theme";
|
|
||||||
@import "~bootstrap/scss/bootstrap";
|
@import "~@edx/paragon/scss/edx/theme.scss";
|
||||||
|
|
||||||
$fa-font-path: "~font-awesome/fonts";
|
$fa-font-path: "~font-awesome/fonts";
|
||||||
@import "~font-awesome/scss/font-awesome";
|
@import "~font-awesome/scss/font-awesome";
|
||||||
|
|
||||||
@import "~@edx/paragon/src/SearchField/SearchField";
|
$input-focus-box-shadow: $input-box-shadow; // hack to get upgrade to paragon 4.0.0 to work
|
||||||
@import "./components/Gradebook/gradebook";
|
|
||||||
|
@import "~@edx/frontend-component-footer/src/lib/scss/site-footer";
|
||||||
|
|
||||||
@import "./components/Gradebook/gradebook";
|
@import "./components/Gradebook/gradebook";
|
||||||
@import "./components/Gradebook/footer";
|
@import "./components/Drawer/Drawer";
|
||||||
@import "./components/Header/header";
|
|
||||||
|
|||||||
48
src/components/Drawer/Drawer.scss
Normal file
48
src/components/Drawer/Drawer.scss
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
$drawer-width: 350px;
|
||||||
|
|
||||||
|
.drawer-contents {
|
||||||
|
overflow-x: auto;
|
||||||
|
transition: margin 300ms cubic-bezier(0.4,0,0.2,1);
|
||||||
|
margin-left: 0;
|
||||||
|
.drawer.open + & {
|
||||||
|
margin-left: $drawer-width;
|
||||||
|
}
|
||||||
|
&.opened {
|
||||||
|
width: calc(100vw - #{$drawer-width});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-contents {
|
||||||
|
overflow-x: auto;
|
||||||
|
transition: margin 300ms cubic-bezier(0.4,0,0.2,1);
|
||||||
|
margin-left: 0;
|
||||||
|
.drawer.open + & {
|
||||||
|
margin-left: $drawer-width;
|
||||||
|
}
|
||||||
|
&.opened {
|
||||||
|
width: calc(100vw - #{$drawer-width});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-container .collapsible {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer {
|
||||||
|
height: 100%;
|
||||||
|
width: $drawer-width;
|
||||||
|
position: absolute;
|
||||||
|
transform: translateX(-$drawer-width);
|
||||||
|
flex-direction: column;
|
||||||
|
transition: transform 300ms cubic-bezier(0.4,0,0.2,1);
|
||||||
|
&.open {
|
||||||
|
transform: translateX(0%);
|
||||||
|
}
|
||||||
|
}
|
||||||
86
src/components/Drawer/index.jsx
Normal file
86
src/components/Drawer/index.jsx
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { Button } from '@edx/paragon';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import { faTimes } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
|
export default class Drawer extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {
|
||||||
|
open: props.initiallyOpen,
|
||||||
|
transitioning: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
deferToNextRepaint(callback) {
|
||||||
|
window.requestAnimationFrame(() =>
|
||||||
|
window.setTimeout(callback, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
close = () => {
|
||||||
|
if (this.state.open) {
|
||||||
|
this.toggleOpen();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
toggleOpen = () => {
|
||||||
|
this.setState({ transitioning: true });
|
||||||
|
// defer the transition to the next repaint so we can be sure that
|
||||||
|
// opening drawer is visible before it transitions
|
||||||
|
// (the start state of the opening animation doesn't work if the element starts hidden)
|
||||||
|
this.deferToNextRepaint(() => this.setState(prevState => ({ open: !prevState.open })));
|
||||||
|
};
|
||||||
|
|
||||||
|
handleSlideDone = (e) => {
|
||||||
|
if (e.currentTarget === e.target) {
|
||||||
|
this.setState({ transitioning: false });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div className="d-flex drawer-container">
|
||||||
|
<aside
|
||||||
|
className={classNames(
|
||||||
|
'drawer',
|
||||||
|
{
|
||||||
|
open: this.state.open,
|
||||||
|
'd-none': !this.state.transitioning && !this.state.open,
|
||||||
|
},
|
||||||
|
)}
|
||||||
|
onTransitionEnd={this.handleSlideDone}
|
||||||
|
>
|
||||||
|
<div className="drawer-header">
|
||||||
|
<h2>{this.props.title}</h2>
|
||||||
|
<Button
|
||||||
|
className="p-1"
|
||||||
|
onClick={this.close}
|
||||||
|
aria-label="Close Filters"
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faTimes} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{this.props.children}
|
||||||
|
</aside>
|
||||||
|
<div
|
||||||
|
className={classNames(
|
||||||
|
'drawer-contents',
|
||||||
|
'position-relative',
|
||||||
|
!this.state.drawerTransitioning && this.state.drawerOpen && 'opened',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{this.props.mainContent(this.toggleOpen)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Drawer.propTypes = {
|
||||||
|
initiallyOpen: PropTypes.bool.isRequired,
|
||||||
|
children: PropTypes.node.isRequired,
|
||||||
|
mainContent: PropTypes.func.isRequired,
|
||||||
|
title: PropTypes.node.isRequired,
|
||||||
|
};
|
||||||
153
src/components/FilterBadges/index.jsx
Normal file
153
src/components/FilterBadges/index.jsx
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import initialFilters from '../../data/constants/filters';
|
||||||
|
|
||||||
|
function FilterBadge({ name, value, onClick }) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<span className="badge badge-info">
|
||||||
|
<span>{`${name}: ${value}`}</span>
|
||||||
|
<button type="button" className="btn-info" aria-label="Close" onClick={onClick}>
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function RangeFilterBadge({
|
||||||
|
displayName,
|
||||||
|
filterName1,
|
||||||
|
filterValue1,
|
||||||
|
filterName2,
|
||||||
|
filterValue2,
|
||||||
|
handleBadgeClose,
|
||||||
|
}) {
|
||||||
|
return ((filterValue1 !== initialFilters[filterName1]) ||
|
||||||
|
(filterValue2 !== initialFilters[filterName2]))
|
||||||
|
&&
|
||||||
|
<FilterBadge
|
||||||
|
name={displayName}
|
||||||
|
value={`${filterValue1} - ${filterValue2}`}
|
||||||
|
onClick={handleBadgeClose}
|
||||||
|
/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function SingleValueFilterBadge({
|
||||||
|
displayName, filterName, filterValue, handleBadgeClose,
|
||||||
|
}) {
|
||||||
|
return (filterValue !== initialFilters[filterName]) &&
|
||||||
|
<FilterBadge
|
||||||
|
name={displayName}
|
||||||
|
value={filterValue}
|
||||||
|
onClick={handleBadgeClose}
|
||||||
|
/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function FilterBadges({
|
||||||
|
assignment,
|
||||||
|
assignmentType,
|
||||||
|
track,
|
||||||
|
cohort,
|
||||||
|
assignmentGradeMin,
|
||||||
|
assignmentGradeMax,
|
||||||
|
courseGradeMin,
|
||||||
|
courseGradeMax,
|
||||||
|
handleFilterBadgeClose,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<SingleValueFilterBadge
|
||||||
|
displayName="Assignment Type"
|
||||||
|
filterName="assignmentType"
|
||||||
|
filterValue={assignmentType}
|
||||||
|
handleBadgeClose={handleFilterBadgeClose(['assignmentType'])}
|
||||||
|
/>
|
||||||
|
<SingleValueFilterBadge
|
||||||
|
displayName="Assignment"
|
||||||
|
filterName="assignment"
|
||||||
|
filterValue={assignment}
|
||||||
|
handleBadgeClose={handleFilterBadgeClose(['assignment', 'assignmentGradeMax', 'assignmentGradeMin'])}
|
||||||
|
/>
|
||||||
|
<RangeFilterBadge
|
||||||
|
displayName="Assignment Grade"
|
||||||
|
filterName1="assignmentGradeMin"
|
||||||
|
filterValue1={assignmentGradeMin}
|
||||||
|
filterName2="assignmentGradeMax"
|
||||||
|
filterValue2={assignmentGradeMax}
|
||||||
|
handleBadgeClose={handleFilterBadgeClose(['assignmentGradeMin', 'assignmentGradeMax'])}
|
||||||
|
/>
|
||||||
|
<RangeFilterBadge
|
||||||
|
displayName="Course Grade"
|
||||||
|
filterName1="courseGradeMin"
|
||||||
|
filterValue1={courseGradeMin}
|
||||||
|
filterName2="courseGradeMax"
|
||||||
|
filterValue2={courseGradeMax}
|
||||||
|
handleBadgeClose={handleFilterBadgeClose(['courseGradeMin', 'courseGradeMax'])}
|
||||||
|
/>
|
||||||
|
<SingleValueFilterBadge
|
||||||
|
displayName="Track"
|
||||||
|
filterName="track"
|
||||||
|
filterValue={track}
|
||||||
|
handleBadgeClose={handleFilterBadgeClose(['track'])}
|
||||||
|
/>
|
||||||
|
<SingleValueFilterBadge
|
||||||
|
displayName="Cohort"
|
||||||
|
filterName="track"
|
||||||
|
filterValue={cohort}
|
||||||
|
handleBadgeClose={handleFilterBadgeClose(['cohort'])}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = state => (
|
||||||
|
{
|
||||||
|
assignment: (state.filters.assignment || {}).label,
|
||||||
|
assignmentType: state.filters.assignmentType,
|
||||||
|
track: state.filters.track,
|
||||||
|
cohort: state.filters.cohort,
|
||||||
|
assignmentGradeMin: state.filters.assignmentGradeMin,
|
||||||
|
assignmentGradeMax: state.filters.assignmentGradeMax,
|
||||||
|
courseGradeMin: state.filters.courseGradeMin,
|
||||||
|
courseGradeMax: state.filters.courseGradeMax,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const ConnectedFilterBadges = connect(mapStateToProps)(FilterBadges);
|
||||||
|
export default ConnectedFilterBadges;
|
||||||
|
|
||||||
|
FilterBadge.propTypes = {
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
value: PropTypes.string.isRequired,
|
||||||
|
onClick: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterBadges.defaultProps = {
|
||||||
|
assignment: initialFilters.assignmentType,
|
||||||
|
assignmentType: initialFilters.assignmentType,
|
||||||
|
track: initialFilters.track,
|
||||||
|
cohort: initialFilters.cohort,
|
||||||
|
assignmentGradeMin: initialFilters.assignmentGradeMin,
|
||||||
|
assignmentGradeMax: initialFilters.assignmentGradeMax,
|
||||||
|
courseGradeMin: initialFilters.courseGradeMin,
|
||||||
|
courseGradeMax: initialFilters.courseGradeMax,
|
||||||
|
};
|
||||||
|
|
||||||
|
FilterBadges.propTypes = {
|
||||||
|
assignment: PropTypes.string,
|
||||||
|
assignmentType: PropTypes.string,
|
||||||
|
track: PropTypes.string,
|
||||||
|
cohort: PropTypes.string,
|
||||||
|
assignmentGradeMin: PropTypes.string,
|
||||||
|
assignmentGradeMax: PropTypes.string,
|
||||||
|
courseGradeMin: PropTypes.string,
|
||||||
|
courseGradeMax: PropTypes.string,
|
||||||
|
handleFilterBadgeClose: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Hyperlink, Icon } from '@edx/paragon';
|
|
||||||
|
|
||||||
import EdXFooterLogo from '../../../assets/edx-footer.png';
|
|
||||||
|
|
||||||
export default function Footer() {
|
|
||||||
function renderLogo() {
|
|
||||||
return (
|
|
||||||
<img src={EdXFooterLogo} alt="edX logo" />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<footer
|
|
||||||
role="contentinfo"
|
|
||||||
aria-label="Page Footer"
|
|
||||||
className="footer d-flex justify-content-center border-top py-3 px-4"
|
|
||||||
>
|
|
||||||
<div className="max-width-1180 d-grid">
|
|
||||||
<div className="area-1">
|
|
||||||
<Hyperlink destination="https://www.edx.org/" content={renderLogo()} aria-label="edX Home" />
|
|
||||||
</div>
|
|
||||||
<div className="area-2">
|
|
||||||
<h2>edX</h2>
|
|
||||||
<ul className="list-unstyled p-0 m-0">
|
|
||||||
<li><a href="https://www.edx.org/about-us">About</a></li>
|
|
||||||
<li><a href="https://www.edx.org/enterprise">edX for Business</a></li>
|
|
||||||
<li><a href="https://www.edx.org/affiliate-program">Affiliates</a></li>
|
|
||||||
<li><a href="http://open.edx.org">Open edX</a></li>
|
|
||||||
<li><a href="https://www.edx.org/careers">Careers</a></li>
|
|
||||||
<li><a href="https://www.edx.org/news-announcements">News</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div className="area-3">
|
|
||||||
<h2>Legal</h2>
|
|
||||||
<ul className="list-unstyled p-0 m-0">
|
|
||||||
<li><a href="https://www.edx.org/edx-terms-service">Terms of Service & Honor Code</a></li>
|
|
||||||
<li><a href="https://www.edx.org/edx-privacy-policy">Privacy Policy</a></li>
|
|
||||||
<li><a href="https://www.edx.org/accessibility">Accessibility Policy</a></li>
|
|
||||||
<li><a href="https://www.edx.org/trademarks">Trademark Policy</a></li>
|
|
||||||
<li><a href="https://www.edx.org/sitemap">Sitemap</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div className="area-4">
|
|
||||||
<h2>Connect</h2>
|
|
||||||
<ul className="list-unstyled p-0 m-0">
|
|
||||||
<li><a href="https://www.edx.org/blog">Blog</a></li>
|
|
||||||
<li><a href="https://courses.edx.org/support/contact_us">Contact Us</a></li>
|
|
||||||
<li><a href="https://support.edx.org">Help Center</a></li>
|
|
||||||
<li><a href="https://www.edx.org/media-kit">Media Kit</a></li>
|
|
||||||
<li><a href="https://www.edx.org/donate">Donate</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div className="area-5">
|
|
||||||
<ul
|
|
||||||
className="d-flex flex-row justify-content-between list-unstyled max-width-222 p-0 mb-4"
|
|
||||||
>
|
|
||||||
{/* TODO: Use Paragon HyperLink with Icon. */}
|
|
||||||
{/* Would need to add rel to paragon if we still need it. */}
|
|
||||||
<li>
|
|
||||||
<a href="http://www.facebook.com/EdxOnline" title="Facebook" rel="noopener noreferrer" target="_blank">
|
|
||||||
<Icon className={['fa', 'fa-facebook-square', 'fa-2x']} screenReaderText="Like edX on Facebook" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://twitter.com/edXOnline" title="Twitter" rel="noopener noreferrer" target="_blank">
|
|
||||||
<Icon className={['fa', 'fa-twitter-square', 'fa-2x']} screenReaderText="Follow edX on Twitter" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://www.youtube.com/user/edxonline" title="Youtube" rel="noopener noreferrer" target="_blank">
|
|
||||||
<Icon className={['fa', 'fa-youtube-square', 'fa-2x']} screenReaderText="Subscribe to the edX YouTube channel" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://www.linkedin.com/company/edx" title="LinkedIn" rel="noopener noreferrer" target="_blank">
|
|
||||||
<Icon className={['fa', 'fa-linkedin-square', 'fa-2x']} screenReaderText="Follow edX on LinkedIn" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://plus.google.com/+edXOnline" title="Google+" rel="noopener noreferrer" target="_blank">
|
|
||||||
<Icon className={['fa', 'fa-google-plus-square', 'fa-2x']} screenReaderText="Follow edX on Google+" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://www.reddit.com/r/edx" title="Reddit" rel="noopener noreferrer" target="_blank">
|
|
||||||
<Icon className={['fa', 'fa-reddit-square', 'fa-2x']} screenReaderText="Subscribe to the edX subreddit" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<ul className="d-flex flex-row justify-content-between list-unstyled max-width-264 p-0 mb-5">
|
|
||||||
<li>
|
|
||||||
<a href="https://itunes.apple.com/us/app/edx/id945480667?mt=8" rel="noopener noreferrer" target="_blank">
|
|
||||||
<img
|
|
||||||
className="max-height-39"
|
|
||||||
alt="Download the edX mobile app from the Apple App Store"
|
|
||||||
src="https://prod-edxapp.edx-cdn.org/static/images/app/app_store_badge_135x40.d0558d910630.svg"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://play.google.com/store/apps/details?id=org.edx.mobile" rel="noopener noreferrer" target="_blank">
|
|
||||||
<img
|
|
||||||
className="max-height-39"
|
|
||||||
alt="Download the edX mobile app from Google Play"
|
|
||||||
src="https://prod-edxapp.edx-cdn.org/static/images/app/google_play_badge_45.6ea466e328da.png"
|
|
||||||
/>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<p>
|
|
||||||
© 2012–{(new Date().getFullYear())} edX Inc.
|
|
||||||
<br />
|
|
||||||
EdX, Open edX, and MicroMasters are registered trademarks of edX Inc.
|
|
||||||
| 粤ICP备17044299号-2
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
.max-width-222 {
|
|
||||||
max-width: 222px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.max-width-264 {
|
|
||||||
max-width: 264px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.max-width-1180 {
|
|
||||||
max-width: 1180px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.max-height-39 {
|
|
||||||
max-height: 39px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.d-grid {
|
|
||||||
display: grid;
|
|
||||||
}
|
|
||||||
|
|
||||||
$gray-footer: #fcfcfc;
|
|
||||||
$border-1: 1px solid $gray-200;
|
|
||||||
|
|
||||||
.footer {
|
|
||||||
background-color: $gray-footer;
|
|
||||||
|
|
||||||
.area-1 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 1;
|
|
||||||
border-bottom: $border-1;
|
|
||||||
padding-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-2 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 2;
|
|
||||||
border-bottom: $border-1;
|
|
||||||
padding: 1rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-3 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 3;
|
|
||||||
border-bottom: $border-1;
|
|
||||||
padding: 1rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-4 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 4;
|
|
||||||
border-bottom: $border-1;
|
|
||||||
padding: 1rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-5 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 5;
|
|
||||||
padding: 1rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (min-width: 717px) {
|
|
||||||
.area-1 {
|
|
||||||
grid-column: 1 / span 2;
|
|
||||||
grid-row: 1;
|
|
||||||
border-bottom: none;
|
|
||||||
padding: 1rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-2 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-3 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-4 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 4;
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-5 {
|
|
||||||
grid-column: 2;
|
|
||||||
grid-row: 2 / span 3;
|
|
||||||
border-left: $border-1;
|
|
||||||
padding-left: 1rem;
|
|
||||||
margin-left: 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (min-width: 870px) {
|
|
||||||
.area-1 {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 1 / span 3;
|
|
||||||
border-right: $border-1;
|
|
||||||
padding-right: 1rem;
|
|
||||||
margin-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-2 {
|
|
||||||
grid-column: 2;
|
|
||||||
grid-row: 1;
|
|
||||||
border-bottom: none;
|
|
||||||
border-right: $border-1;
|
|
||||||
padding-right: 1rem;
|
|
||||||
margin-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-3 {
|
|
||||||
grid-column: 3;
|
|
||||||
grid-row: 1;
|
|
||||||
border-bottom: none;
|
|
||||||
border-right: $border-1;
|
|
||||||
padding-right: 1rem;
|
|
||||||
margin-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-4 {
|
|
||||||
grid-column: 4;
|
|
||||||
grid-row: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-5 {
|
|
||||||
grid-column: 2 / span 3;
|
|
||||||
grid-row: 2;
|
|
||||||
border: none;
|
|
||||||
margin-left: 0;
|
|
||||||
padding-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (min-width: 1188px) {
|
|
||||||
.area-1 {
|
|
||||||
grid-column: 1 / span 1;
|
|
||||||
grid-row: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-2 {
|
|
||||||
grid-column: 2;
|
|
||||||
grid-row: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-3 {
|
|
||||||
grid-column: 3;
|
|
||||||
grid-row: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-4 {
|
|
||||||
grid-column: 4;
|
|
||||||
grid-row: 1;
|
|
||||||
border-right: $border-1;
|
|
||||||
padding-right: 1rem;
|
|
||||||
margin-right: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.area-5 {
|
|
||||||
grid-column: 5 / span 1;
|
|
||||||
grid-row: 1;
|
|
||||||
max-width: 372px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
left: 0;
|
||||||
background-color: #999;
|
background-color: #999;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
z-index: 99999;
|
z-index: 99999;
|
||||||
@@ -16,16 +17,16 @@
|
|||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gradebook-container{
|
.gradebook-content {
|
||||||
width: 500px;
|
// note that this width isn't well-abstracted from Drawer code.
|
||||||
@media only screen and (min-width: 640px) {
|
// if we need to change it we may need to dig into those styles as well
|
||||||
width: 630px;
|
width: 100vw;
|
||||||
|
.search-help-text {
|
||||||
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
@media only screen and (min-width: 992px) {
|
h4 {
|
||||||
width: 900px;
|
font-weight: bold;
|
||||||
}
|
margin-top: 2rem;
|
||||||
@media only screen and (min-width: 1200px) {
|
|
||||||
width: 1024px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,34 +39,64 @@
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.grade-history-header{
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-history-assignment{
|
||||||
|
padding-right: 49px;
|
||||||
|
}
|
||||||
|
.grade-history-student{
|
||||||
|
padding-right: 75px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-history-original-grade{
|
||||||
|
padding-right: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grade-history-current-grade{
|
||||||
|
padding-right: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
.gbook {
|
.gbook {
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
|
|
||||||
|
.grade-button {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.student-key {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
padding-left: 244px;
|
padding-left: 244px;
|
||||||
|
// prevents the table from shrinking to a width where "Final 01" breaks to two lines
|
||||||
|
min-width: 731px;
|
||||||
|
th {
|
||||||
|
vertical-align: top;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.table thead tr {
|
||||||
|
height: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table tr th:first-child {
|
.table tr th:first-child {
|
||||||
position: absolute;
|
border-bottom: none;
|
||||||
width: 160px;
|
|
||||||
height:50px;
|
|
||||||
display: block;
|
|
||||||
background-color: #fff;
|
|
||||||
border-bottom: none;
|
|
||||||
}
|
}
|
||||||
|
.table tr th:first-child,
|
||||||
.table tr td:first-child {
|
.table tr td:first-child {
|
||||||
position: absolute;
|
position: sticky;
|
||||||
width: 160px;
|
width: 160px;
|
||||||
height:50px;
|
left: 0;
|
||||||
display: block;
|
z-index: 1; // to float over the following children in the side-scrolling case
|
||||||
background-color: #fff;
|
background: white;
|
||||||
}
|
}
|
||||||
.table tr td:nth-child(2) {
|
|
||||||
box-sizing: content-box;
|
.table tbody th {
|
||||||
padding-left: 170px;
|
font-weight: normal;
|
||||||
}
|
|
||||||
.table tr th:nth-child(2) {
|
|
||||||
padding-left: 170px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.link-style {
|
.link-style {
|
||||||
@@ -77,3 +108,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.input-percent-label {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mb-85 {
|
||||||
|
margin-bottom: 85px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-dialog {
|
||||||
|
max-width: 1000px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrap-text-in-cell {
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,72 +1,146 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
Collapsible,
|
||||||
|
Icon,
|
||||||
InputSelect,
|
InputSelect,
|
||||||
|
InputText,
|
||||||
Modal,
|
Modal,
|
||||||
SearchField,
|
SearchField,
|
||||||
|
StatefulButton,
|
||||||
StatusAlert,
|
StatusAlert,
|
||||||
Table,
|
Table,
|
||||||
Icon,
|
Tabs,
|
||||||
} from '@edx/paragon';
|
} from '@edx/paragon';
|
||||||
import queryString from 'query-string';
|
import queryString from 'query-string';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
import { faDownload, faSpinner, faFilter } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { configuration } from '../../config';
|
import { configuration } from '../../config';
|
||||||
|
import PageButtons from '../PageButtons';
|
||||||
|
import Drawer from '../Drawer';
|
||||||
|
import { formatDateForDisplay } from '../../data/actions/utils';
|
||||||
|
import initialFilters from '../../data/constants/filters';
|
||||||
|
import ConnectedFilterBadges from '../FilterBadges';
|
||||||
|
|
||||||
|
|
||||||
const DECIMAL_PRECISION = 2;
|
const DECIMAL_PRECISION = 2;
|
||||||
|
const GRADE_OVERRIDE_HISTORY_COLUMNS = [{ label: 'Date', key: 'date' }, { label: 'Grader', key: 'grader' },
|
||||||
|
{ label: 'Reason', key: 'reason' },
|
||||||
|
{ label: 'Adjusted grade', key: 'adjustedGrade' }];
|
||||||
|
|
||||||
export default class Gradebook extends React.Component {
|
export default class Gradebook extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
filterValue: '',
|
filterValue: '',
|
||||||
|
courseGradeMin: '0',
|
||||||
|
courseGradeMax: '100',
|
||||||
modalOpen: false,
|
modalOpen: false,
|
||||||
modalModel: [{}],
|
adjustedGradeValue: 0,
|
||||||
updateVal: 0,
|
|
||||||
updateModuleId: null,
|
updateModuleId: null,
|
||||||
updateUserId: null,
|
updateUserId: null,
|
||||||
|
reasonForChange: '',
|
||||||
|
assignmentGradeMin: '0',
|
||||||
|
assignmentGradeMax: '100',
|
||||||
|
isMinCourseGradeFilterValid: true,
|
||||||
|
isMaxCourseGradeFilterValid: true,
|
||||||
};
|
};
|
||||||
|
this.fileFormRef = React.createRef();
|
||||||
|
this.fileInputRef = React.createRef();
|
||||||
|
this.myRef = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const urlQuery = queryString.parse(this.props.location.search);
|
const urlQuery = queryString.parse(this.props.location.search);
|
||||||
this.props.getRoles(this.props.match.params.courseId, urlQuery);
|
this.props.initializeFilters(urlQuery);
|
||||||
|
this.props.getRoles(this.props.courseId);
|
||||||
|
this.overrideReasonInput.focus();
|
||||||
|
|
||||||
|
const newStateFields = {};
|
||||||
|
['assignmentGradeMin', 'assignmentGradeMax', 'courseGradeMin', 'courseGradeMax'].forEach((attr) => {
|
||||||
|
if (urlQuery[attr]) {
|
||||||
|
newStateFields[attr] = urlQuery[attr];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setState(newStateFields);
|
||||||
|
}
|
||||||
|
|
||||||
|
onChange(e) {
|
||||||
|
this.setState({ [e.target.name]: e.target.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
setNewModalState = (userEntry, subsection) => {
|
setNewModalState = (userEntry, subsection) => {
|
||||||
|
this.props.fetchGradeOverrideHistory(
|
||||||
|
subsection.module_id,
|
||||||
|
userEntry.user_id,
|
||||||
|
);
|
||||||
|
|
||||||
let adjustedGradePossible = '';
|
let adjustedGradePossible = '';
|
||||||
let currentGradePossible = '';
|
|
||||||
if (subsection.attempted) {
|
if (subsection.attempted) {
|
||||||
adjustedGradePossible = ` / ${subsection.score_possible}`;
|
adjustedGradePossible = subsection.score_possible;
|
||||||
currentGradePossible = `/${subsection.score_possible}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
modalModel: [{
|
modalAssignmentName: `${subsection.subsection_name}`,
|
||||||
username: userEntry.username,
|
|
||||||
currentGrade: `${subsection.score_earned}${currentGradePossible}`,
|
|
||||||
adjustedGrade: (
|
|
||||||
<span>
|
|
||||||
<input
|
|
||||||
style={{ width: '25px' }}
|
|
||||||
type="text"
|
|
||||||
onChange={event => this.setState({ updateVal: event.target.value })}
|
|
||||||
/>{adjustedGradePossible}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
assignmentName: `${subsection.subsection_name}`,
|
|
||||||
}],
|
|
||||||
modalOpen: true,
|
modalOpen: true,
|
||||||
updateModuleId: subsection.module_id,
|
updateModuleId: subsection.module_id,
|
||||||
updateUserId: userEntry.user_id,
|
updateUserId: userEntry.user_id,
|
||||||
|
updateUserName: userEntry.username,
|
||||||
|
todaysDate: formatDateForDisplay(new Date()),
|
||||||
|
adjustedGradePossible,
|
||||||
|
reasonForChange: '',
|
||||||
|
adjustedGradeValue: '',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLearnerInformation = entry => (
|
||||||
|
<div>
|
||||||
|
<div>{entry.username}</div>
|
||||||
|
{entry.external_user_key && <div className="student-key">{entry.external_user_key}</div>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
getActiveTabs = () => {
|
||||||
|
if (this.props.showBulkManagement) {
|
||||||
|
return ['Grades', 'Bulk Management'];
|
||||||
|
}
|
||||||
|
return ['Grades'];
|
||||||
|
};
|
||||||
|
|
||||||
|
getAssignmentFilterOptions = () => [
|
||||||
|
{ label: 'All', value: '' },
|
||||||
|
...this.props.assignmentFilterOptions.map((assignment) => {
|
||||||
|
const { label, subsectionLabel } = assignment;
|
||||||
|
return {
|
||||||
|
label: `${label}: ${subsectionLabel}`,
|
||||||
|
value: label,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
|
||||||
|
getCourseGradeFilterAlertDialog = () => {
|
||||||
|
let dialog = '';
|
||||||
|
|
||||||
|
if (!this.state.isMinCourseGradeFilterValid) {
|
||||||
|
dialog += 'Minimum course grade value must be between 0 and 100. ';
|
||||||
|
}
|
||||||
|
if (!this.state.isMaxCourseGradeFilterValid) {
|
||||||
|
dialog += 'Maximum course grade value must be between 0 and 100. ';
|
||||||
|
}
|
||||||
|
return dialog;
|
||||||
|
};
|
||||||
|
|
||||||
handleAdjustedGradeClick = () => {
|
handleAdjustedGradeClick = () => {
|
||||||
this.props.updateGrades(
|
this.props.updateGrades(
|
||||||
this.props.match.params.courseId, [
|
this.props.courseId, [
|
||||||
{
|
{
|
||||||
user_id: this.state.updateUserId,
|
user_id: this.state.updateUserId,
|
||||||
usage_id: this.state.updateModuleId,
|
usage_id: this.state.updateModuleId,
|
||||||
grade: {
|
grade: {
|
||||||
earned_graded_override: this.state.updateVal,
|
earned_graded_override: this.state.adjustedGradeValue,
|
||||||
|
comment: this.state.reasonForChange,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -75,18 +149,46 @@ export default class Gradebook extends React.Component {
|
|||||||
this.props.selectedTrack,
|
this.props.selectedTrack,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.closeAssignmentModal();
|
||||||
|
}
|
||||||
|
|
||||||
|
closeAssignmentModal = () => {
|
||||||
|
this.props.doneViewingAssignment();
|
||||||
this.setState({
|
this.setState({
|
||||||
modalModel: [{}],
|
adjustedGradePossible: '',
|
||||||
|
adjustedGradeValue: '',
|
||||||
modalOpen: false,
|
modalOpen: false,
|
||||||
|
reasonForChange: '',
|
||||||
updateModuleId: null,
|
updateModuleId: null,
|
||||||
updateUserId: null,
|
updateUserId: null,
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
updateQueryParams = (queryKey, queryValue) => {
|
handleAssignmentFilterChange = (assignment) => {
|
||||||
|
const selectedFilterOption = this.props.assignmentFilterOptions.find(assig =>
|
||||||
|
assig.label === assignment);
|
||||||
|
const { type, id } = selectedFilterOption || {};
|
||||||
|
const typedValue = { label: assignment, type, id };
|
||||||
|
this.props.updateAssignmentFilter(typedValue);
|
||||||
|
this.updateQueryParams({ assignment: id });
|
||||||
|
this.props.updateGradesIfAssignmentGradeFiltersSet(
|
||||||
|
this.props.courseId,
|
||||||
|
this.props.selectedCohort,
|
||||||
|
this.props.selectedTrack,
|
||||||
|
this.props.selectedAssignmentType,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
updateQueryParams = (queryParams) => {
|
||||||
const parsed = queryString.parse(this.props.location.search);
|
const parsed = queryString.parse(this.props.location.search);
|
||||||
parsed[queryKey] = queryValue;
|
Object.keys(queryParams).forEach((key) => {
|
||||||
return `?${queryString.stringify(parsed)}`;
|
if (queryParams[key]) {
|
||||||
|
parsed[key] = queryParams[key];
|
||||||
|
} else {
|
||||||
|
delete parsed[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.props.history.push(`?${queryString.stringify(parsed)}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
mapAssignmentTypeEntries = (entries) => {
|
mapAssignmentTypeEntries = (entries) => {
|
||||||
@@ -94,7 +196,7 @@ export default class Gradebook extends React.Component {
|
|||||||
id: entry,
|
id: entry,
|
||||||
label: entry,
|
label: entry,
|
||||||
}));
|
}));
|
||||||
mapped.unshift({ id: 0, label: 'All' });
|
mapped.unshift({ id: 0, label: 'All', value: '' });
|
||||||
return mapped;
|
return mapped;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -116,8 +218,56 @@ export default class Gradebook extends React.Component {
|
|||||||
return mapped;
|
return mapped;
|
||||||
};
|
};
|
||||||
|
|
||||||
updateAssignmentTypes = (event) => {
|
formatHistoryRow = (row) => {
|
||||||
this.props.filterColumns(event, this.props.grades[0]);
|
const {
|
||||||
|
summaryOfRowsProcessed: {
|
||||||
|
total,
|
||||||
|
successfullyProcessed,
|
||||||
|
failed,
|
||||||
|
skipped,
|
||||||
|
},
|
||||||
|
unique_id: courseId,
|
||||||
|
originalFilename,
|
||||||
|
id,
|
||||||
|
user: username,
|
||||||
|
...rest
|
||||||
|
} = row;
|
||||||
|
const resultsText = [
|
||||||
|
`${total} Students: ${successfullyProcessed} processed`,
|
||||||
|
...(skipped > 0 ? [`${skipped} skipped`] : []),
|
||||||
|
...(failed > 0 ? [`${failed} failed`] : []),
|
||||||
|
].join(', ');
|
||||||
|
const resultsSummary = (
|
||||||
|
<a
|
||||||
|
href={`${configuration.LMS_BASE_URL}/api/bulk_grades/course/${courseId}/?error_id=${id}`}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<FontAwesomeIcon icon={faDownload} />
|
||||||
|
{resultsText}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
const filename = (
|
||||||
|
<span className="wrap-text-in-cell">
|
||||||
|
{originalFilename}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
const user = (
|
||||||
|
<span className="wrap-text-in-cell">
|
||||||
|
{username}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
resultsSummary,
|
||||||
|
filename,
|
||||||
|
user,
|
||||||
|
...rest,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
updateAssignmentTypes = (assignmentType) => {
|
||||||
|
this.props.filterAssignmentType(assignmentType);
|
||||||
|
this.updateQueryParams({ assignmentType });
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTracks = (event) => {
|
updateTracks = (event) => {
|
||||||
@@ -127,12 +277,12 @@ export default class Gradebook extends React.Component {
|
|||||||
selectedTrackSlug = selectedTrackItem.slug;
|
selectedTrackSlug = selectedTrackItem.slug;
|
||||||
}
|
}
|
||||||
this.props.getUserGrades(
|
this.props.getUserGrades(
|
||||||
this.props.match.params.courseId,
|
this.props.courseId,
|
||||||
this.props.selectedCohort,
|
this.props.selectedCohort,
|
||||||
selectedTrackSlug,
|
selectedTrackSlug,
|
||||||
|
this.props.selectedAssignmentType,
|
||||||
);
|
);
|
||||||
const updatedQueryStrings = this.updateQueryParams('track', selectedTrackSlug);
|
this.updateQueryParams({ track: selectedTrackSlug });
|
||||||
this.props.history.push(updatedQueryStrings);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
updateCohorts = (event) => {
|
updateCohorts = (event) => {
|
||||||
@@ -142,23 +292,68 @@ export default class Gradebook extends React.Component {
|
|||||||
selectedCohortId = selectedCohortItem.id;
|
selectedCohortId = selectedCohortItem.id;
|
||||||
}
|
}
|
||||||
this.props.getUserGrades(
|
this.props.getUserGrades(
|
||||||
this.props.match.params.courseId,
|
this.props.courseId,
|
||||||
selectedCohortId,
|
selectedCohortId,
|
||||||
this.props.selectedTrack,
|
this.props.selectedTrack,
|
||||||
|
this.props.selectedAssignmentType,
|
||||||
);
|
);
|
||||||
const updatedQueryStrings = this.updateQueryParams('cohort', selectedCohortId);
|
this.updateQueryParams({ cohort: selectedCohortId });
|
||||||
this.props.history.push(updatedQueryStrings);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mapSelectedAssignmentTypeEntry = (entry) => {
|
// At present, we don't store label and value in google analytics. By setting the label
|
||||||
const selectedAssignmentTypeEntry = this.props.assignmentTypes
|
// property of the below events, I want to verify that we can set the label of google anlatyics
|
||||||
.find(x => x.id === parseInt(entry, 10));
|
// The following properties of a google analytics event are:
|
||||||
if (selectedAssignmentTypeEntry) {
|
// category (used), name(used), lavel(not used), value(not used)
|
||||||
return selectedAssignmentTypeEntry.name;
|
handleClickExportGrades = () => {
|
||||||
}
|
this.props.downloadBulkGradesReport(this.props.courseId);
|
||||||
return 'All';
|
window.location = this.props.gradeExportUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleClickDownloadInterventions = () => {
|
||||||
|
this.props.downloadInterventionReport(this.props.courseId);
|
||||||
|
window.location = this.props.interventionExportUrl;
|
||||||
|
};
|
||||||
|
|
||||||
|
handleClickImportGrades = () => {
|
||||||
|
const fileInput = this.fileInputRef.current;
|
||||||
|
if (fileInput) {
|
||||||
|
fileInput.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleFileInputChange = (event) => {
|
||||||
|
const fileInput = event.target;
|
||||||
|
const file = fileInput.files[0];
|
||||||
|
const form = this.fileFormRef.current;
|
||||||
|
if (file && form) {
|
||||||
|
const formData = new FormData(form);
|
||||||
|
this.props.submitFileUploadFormData(this.props.courseId, formData).then(() => {
|
||||||
|
fileInput.value = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleSubmitAssignmentGrade = (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const {
|
||||||
|
assignmentGradeMin,
|
||||||
|
assignmentGradeMax,
|
||||||
|
} = this.state;
|
||||||
|
|
||||||
|
this.props.updateAssignmentLimits(assignmentGradeMin, assignmentGradeMax);
|
||||||
|
this.props.getUserGrades(
|
||||||
|
this.props.courseId,
|
||||||
|
this.props.selectedCohort,
|
||||||
|
this.props.selectedTrack,
|
||||||
|
this.props.selectedAssignmentType,
|
||||||
|
);
|
||||||
|
this.updateQueryParams({ assignmentGradeMin, assignmentGradeMax });
|
||||||
|
};
|
||||||
|
|
||||||
|
handleMinAssigGradeChange = assignmentGradeMin => this.setState({ assignmentGradeMin });
|
||||||
|
|
||||||
|
handleMaxAssigGradeChange = assignmentGradeMax => this.setState({ assignmentGradeMax });
|
||||||
|
|
||||||
mapSelectedCohortEntry = (entry) => {
|
mapSelectedCohortEntry = (entry) => {
|
||||||
const selectedCohortEntry = this.props.cohorts.find(x => x.id === parseInt(entry, 10));
|
const selectedCohortEntry = this.props.cohorts.find(x => x.id === parseInt(entry, 10));
|
||||||
if (selectedCohortEntry) {
|
if (selectedCohortEntry) {
|
||||||
@@ -175,20 +370,28 @@ export default class Gradebook extends React.Component {
|
|||||||
return 'Tracks';
|
return 'Tracks';
|
||||||
};
|
};
|
||||||
|
|
||||||
roundGrade = percent => parseFloat(percent.toFixed(DECIMAL_PRECISION));
|
roundGrade = percent => parseFloat((percent || 0).toFixed(DECIMAL_PRECISION));
|
||||||
|
|
||||||
formatter = {
|
formatter = {
|
||||||
percent: (entries, areGradesFrozen) => entries.map((entry) => {
|
percent: (entries, areGradesFrozen) => entries.map((entry) => {
|
||||||
const results = { username: entry.username };
|
const learnerInformation = this.getLearnerInformation(entry);
|
||||||
|
const results = {
|
||||||
|
Username: (
|
||||||
|
<div><span className="wrap-text-in-cell">{learnerInformation}</span></div>
|
||||||
|
),
|
||||||
|
Email: (
|
||||||
|
<span className="wrap-text-in-cell">{entry.email}</span>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
const assignments = entry.section_breakdown
|
const assignments = entry.section_breakdown
|
||||||
.filter(section => section.is_graded)
|
|
||||||
.reduce((acc, subsection) => {
|
.reduce((acc, subsection) => {
|
||||||
if (areGradesFrozen) {
|
if (areGradesFrozen) {
|
||||||
acc[subsection.label] = `${this.roundGrade(subsection.percent * 100)} %`;
|
acc[subsection.label] = `${this.roundGrade(subsection.percent * 100)} %`;
|
||||||
} else {
|
} else {
|
||||||
acc[subsection.label] = (
|
acc[subsection.label] = (
|
||||||
<button
|
<button
|
||||||
className="btn btn-header link-style"
|
className="btn btn-header link-style grade-button"
|
||||||
onClick={() => this.setNewModalState(entry, subsection)}
|
onClick={() => this.setNewModalState(entry, subsection)}
|
||||||
>
|
>
|
||||||
{this.roundGrade(subsection.percent * 100)}%
|
{this.roundGrade(subsection.percent * 100)}%
|
||||||
@@ -196,14 +399,22 @@ export default class Gradebook extends React.Component {
|
|||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
const totals = { total: `${this.roundGrade(entry.percent * 100)}%` };
|
const totals = { Total: `${this.roundGrade(entry.percent * 100)}%` };
|
||||||
return Object.assign(results, assignments, totals);
|
return Object.assign(results, assignments, totals);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
absolute: (entries, areGradesFrozen) => entries.map((entry) => {
|
absolute: (entries, areGradesFrozen) => entries.map((entry) => {
|
||||||
const results = { username: entry.username };
|
const learnerInformation = this.getLearnerInformation(entry);
|
||||||
|
const results = {
|
||||||
|
Username: (
|
||||||
|
<div><span className="wrap-text-in-cell">{learnerInformation}</span></div>
|
||||||
|
),
|
||||||
|
Email: (
|
||||||
|
<span className="wrap-text-in-cell">{entry.email}</span>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
const assignments = entry.section_breakdown
|
const assignments = entry.section_breakdown
|
||||||
.filter(section => section.is_graded)
|
|
||||||
.reduce((acc, subsection) => {
|
.reduce((acc, subsection) => {
|
||||||
const scoreEarned = this.roundGrade(subsection.score_earned);
|
const scoreEarned = this.roundGrade(subsection.score_earned);
|
||||||
const scorePossible = this.roundGrade(subsection.score_possible);
|
const scorePossible = this.roundGrade(subsection.score_possible);
|
||||||
@@ -226,175 +437,630 @@ export default class Gradebook extends React.Component {
|
|||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const totals = { total: `${this.roundGrade(entry.percent * 100)}/100` };
|
const totals = { Total: `${this.roundGrade(entry.percent * 100)}/100` };
|
||||||
return Object.assign(results, assignments, totals);
|
return Object.assign(results, assignments, totals);
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
lmsInstructorDashboardUrl = courseId => `${configuration.LMS_BASE_URL}/courses/${courseId}/instructor`;
|
lmsInstructorDashboardUrl = courseId => `${configuration.LMS_BASE_URL}/courses/${courseId}/instructor`;
|
||||||
|
|
||||||
|
formatHeadings = () => {
|
||||||
|
let headings = [...this.props.headings];
|
||||||
|
|
||||||
|
if (headings.length > 0) {
|
||||||
|
const userInformationHeadingLabel = (
|
||||||
|
<div>
|
||||||
|
<div>Username</div>
|
||||||
|
<div className="font-weight-normal student-key">Student Key*</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
const emailHeadingLabel = 'Email*';
|
||||||
|
|
||||||
|
headings = headings.map(heading => ({ label: heading, key: heading, width: 'col' }));
|
||||||
|
|
||||||
|
// replace username heading label to include additional user data
|
||||||
|
headings[0].label = userInformationHeadingLabel;
|
||||||
|
headings[0].width = 'col-2';
|
||||||
|
headings[1].label = emailHeadingLabel;
|
||||||
|
headings[1].width = 'col-2';
|
||||||
|
}
|
||||||
|
|
||||||
|
return headings;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCourseGradeFilterChange = (type, value) => {
|
||||||
|
const filterValue = value;
|
||||||
|
|
||||||
|
if (type === 'min') {
|
||||||
|
this.setState({
|
||||||
|
courseGradeMin: filterValue,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
courseGradeMax: filterValue,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleCourseGradeFilterApplyButtonClick = () => {
|
||||||
|
const { courseGradeMin, courseGradeMax } = this.state;
|
||||||
|
const isMinValid = this.isGradeFilterValueInRange(courseGradeMin);
|
||||||
|
const isMaxValid = this.isGradeFilterValueInRange(courseGradeMax);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
isMinCourseGradeFilterValid: isMinValid,
|
||||||
|
isMaxCourseGradeFilterValid: isMaxValid,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isMinValid && isMaxValid) {
|
||||||
|
this.props.updateCourseGradeFilter(
|
||||||
|
courseGradeMin,
|
||||||
|
courseGradeMax,
|
||||||
|
this.props.courseId,
|
||||||
|
);
|
||||||
|
this.props.getUserGrades(
|
||||||
|
this.props.courseId,
|
||||||
|
this.props.selectedCohort,
|
||||||
|
this.props.selectedTrack,
|
||||||
|
this.props.selectedAssignmentType,
|
||||||
|
{
|
||||||
|
courseGradeMin,
|
||||||
|
courseGradeMax,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
this.updateQueryParams({ courseGradeMin, courseGradeMax });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isGradeFilterValueInRange = (value) => {
|
||||||
|
const valueAsInt = parseInt(value, 10);
|
||||||
|
return valueAsInt >= 0 && valueAsInt <= 100;
|
||||||
|
};
|
||||||
|
|
||||||
|
handleFilterBadgeClose = filterNames => () => {
|
||||||
|
this.props.resetFilters(filterNames);
|
||||||
|
const queryParams = {};
|
||||||
|
filterNames.forEach((filterName) => {
|
||||||
|
queryParams[filterName] = false;
|
||||||
|
});
|
||||||
|
this.updateQueryParams(queryParams);
|
||||||
|
const stateUpdate = {};
|
||||||
|
const rangeStateFilters = ['assignmentGradeMin', 'assignmentGradeMax', 'courseGradeMin', 'courseGradeMax'];
|
||||||
|
rangeStateFilters.forEach((filterName) => {
|
||||||
|
if (filterNames.includes(filterName)) {
|
||||||
|
stateUpdate[filterName] = initialFilters[filterName];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.setState(stateUpdate);
|
||||||
|
this.props.getUserGrades(
|
||||||
|
this.props.courseId,
|
||||||
|
filterNames.includes('cohort') ? initialFilters.cohort : this.props.selectedCohort,
|
||||||
|
filterNames.includes('track') ? initialFilters.track : this.props.selectedTrack,
|
||||||
|
filterNames.includes('assignmentType') ? initialFilters.assignmentType : this.props.selectedAssignmentType,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="d-flex justify-content-center">
|
<Drawer
|
||||||
{ this.props.showSpinner && <div className="spinner-overlay"><Icon className={['fa', 'fa-spinner', 'fa-spin', 'fa-5x', 'color-black']} /></div>}
|
mainContent={toggleFilterDrawer => (
|
||||||
<div className="gradebook-container">
|
<div className="px-3 gradebook-content">
|
||||||
<div>
|
|
||||||
<a
|
<a
|
||||||
href={this.lmsInstructorDashboardUrl(this.props.match.params.courseId)}
|
href={this.lmsInstructorDashboardUrl(this.props.courseId)}
|
||||||
className="mb-3"
|
className="mb-3"
|
||||||
>
|
>
|
||||||
{'<< Back to Dashboard'}
|
<span aria-hidden="true">{'<< '}</span> {'Back to Dashboard'}
|
||||||
</a>
|
</a>
|
||||||
<h1>Gradebook</h1>
|
<h1>Gradebook</h1>
|
||||||
<h3> {this.props.match.params.courseId}</h3>
|
<h3> {this.props.courseId}</h3>
|
||||||
{ this.props.areGradesFrozen &&
|
{this.props.areGradesFrozen &&
|
||||||
<div className="alert alert-warning" role="alert" >
|
<div className="alert alert-warning" role="alert" >
|
||||||
The grades for this course are now frozen. Editing of grades is no longer allowed.
|
The grades for this course are now frozen. Editing of grades is no longer allowed.
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
{ !this.props.canUserViewGradebook &&
|
{(this.props.canUserViewGradebook === false) &&
|
||||||
<div className="alert alert-warning" role="alert" >
|
<div className="alert alert-warning" role="alert" >
|
||||||
You are not authorized to view the gradebook for this course. If you have a global role, please enroll in this course and try again.
|
You are not authorized to view the gradebook for this course.
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
<hr />
|
<Tabs labels={this.getActiveTabs()}>
|
||||||
<div className="d-flex justify-content-between" >
|
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<h4>Step 1: Filter the Grade Report</h4>
|
||||||
Score View:
|
<div className="d-flex justify-content-between" >
|
||||||
<span>
|
{this.props.showSpinner && <div className="spinner-overlay"><Icon className="fa fa-spinner fa-spin fa-5x color-black" /></div>}
|
||||||
<input
|
<Button className="btn-primary align-self-start" onClick={toggleFilterDrawer}><FontAwesomeIcon icon={faFilter} /> Edit Filters</Button>
|
||||||
id="score-view-percent"
|
<div>
|
||||||
className="ml-2 mr-1"
|
<SearchField
|
||||||
type="radio"
|
onSubmit={value =>
|
||||||
name="score-view"
|
this.props.searchForUser(
|
||||||
value="percent"
|
this.props.courseId,
|
||||||
defaultChecked
|
value,
|
||||||
onClick={() => this.props.toggleFormat('percent')}
|
this.props.selectedCohort,
|
||||||
|
this.props.selectedTrack,
|
||||||
|
this.props.selectedAssignmentType,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
inputLabel="Search for a learner"
|
||||||
|
onChange={filterValue => this.setState({ filterValue })}
|
||||||
|
onClear={() =>
|
||||||
|
this.props.getUserGrades(
|
||||||
|
this.props.courseId,
|
||||||
|
this.props.selectedCohort,
|
||||||
|
this.props.selectedTrack,
|
||||||
|
this.props.selectedAssignmentType,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
value={this.state.filterValue}
|
||||||
/>
|
/>
|
||||||
<label className="mr-2" htmlFor="score-view-percent">Percent</label>
|
<small className="form-text text-muted search-help-text">Search by username, email, or student key</small>
|
||||||
</span>
|
</div>
|
||||||
<span>
|
|
||||||
<input
|
|
||||||
id="score-view-absolute"
|
|
||||||
type="radio"
|
|
||||||
name="score-view"
|
|
||||||
value="absolute"
|
|
||||||
className="mr-1"
|
|
||||||
onClick={() => this.props.toggleFormat('absolute')}
|
|
||||||
/>
|
|
||||||
<label htmlFor="score-view-absolute">Absolute</label>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
{ this.props.assignmnetTypes.length > 0 &&
|
<ConnectedFilterBadges
|
||||||
<div className="student-filters">
|
handleFilterBadgeClose={this.handleFilterBadgeClose}
|
||||||
<span className="label">
|
/>
|
||||||
Assignment Types:
|
<StatusAlert
|
||||||
</span>
|
alertType="success"
|
||||||
<InputSelect
|
dialog="The grade has been successfully edited. You may see a slight delay before updates appear in the Gradebook."
|
||||||
name="assignment-types"
|
onClose={() => this.props.closeBanner()}
|
||||||
value={this.mapSelectedTrackEntry(this.props.selectedAssignmentType)}
|
open={this.props.showSuccess}
|
||||||
options={this.mapAssignmentTypeEntries(this.props.assignmnetTypes)}
|
/>
|
||||||
onChange={this.updateAssignmentTypes}
|
<StatusAlert
|
||||||
|
alertType="danger"
|
||||||
|
dialog={this.getCourseGradeFilterAlertDialog()}
|
||||||
|
dismissible={false}
|
||||||
|
open={
|
||||||
|
!this.state.isMinCourseGradeFilterValid ||
|
||||||
|
!this.state.isMaxCourseGradeFilterValid
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<h4>Step 2: View or Modify Individual Grades</h4>
|
||||||
|
{this.props.totalUsersCount ?
|
||||||
|
<div>
|
||||||
|
Showing
|
||||||
|
<span className="font-weight-bold"> {this.props.filteredUsersCount} </span>
|
||||||
|
of
|
||||||
|
<span className="font-weight-bold"> {this.props.totalUsersCount} </span>
|
||||||
|
total learners
|
||||||
|
</div> :
|
||||||
|
null
|
||||||
|
}
|
||||||
|
<div className="d-flex justify-content-between align-items-center mb-2">
|
||||||
|
<InputSelect
|
||||||
|
label="Score View:"
|
||||||
|
name="ScoreView"
|
||||||
|
value="percent"
|
||||||
|
options={[{ label: 'Percent', value: 'percent' }, { label: 'Absolute', value: 'absolute' }]}
|
||||||
|
onChange={this.props.toggleFormat}
|
||||||
|
/>
|
||||||
|
{this.props.showBulkManagement && (
|
||||||
|
<div>
|
||||||
|
<StatefulButton
|
||||||
|
buttonType="outline-primary"
|
||||||
|
onClick={this.handleClickExportGrades}
|
||||||
|
state={this.props.showSpinner ? 'pending' : 'default'}
|
||||||
|
labels={{
|
||||||
|
default: 'Bulk Management',
|
||||||
|
pending: 'Bulk Management',
|
||||||
|
}}
|
||||||
|
icons={{
|
||||||
|
default: <FontAwesomeIcon className="mr-2" icon={faDownload} />,
|
||||||
|
pending: <FontAwesomeIcon className="fa-spin mr-2" icon={faSpinner} />,
|
||||||
|
}}
|
||||||
|
disabledStates={['pending']}
|
||||||
|
/>
|
||||||
|
<StatefulButton
|
||||||
|
buttonType="outline-primary"
|
||||||
|
onClick={this.handleClickDownloadInterventions}
|
||||||
|
state={this.props.showSpinner ? 'pending' : 'default'}
|
||||||
|
className="ml-2"
|
||||||
|
labels={{
|
||||||
|
default: 'Interventions*',
|
||||||
|
pending: 'Interventions*',
|
||||||
|
}}
|
||||||
|
icons={{
|
||||||
|
default: <FontAwesomeIcon className="mr-2" icon={faDownload} />,
|
||||||
|
pending: <FontAwesomeIcon className="fa-spin mr-2" icon={faSpinner} />,
|
||||||
|
}}
|
||||||
|
disabledStates={['pending']}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="gradebook-container">
|
||||||
|
<div className="gbook">
|
||||||
|
<Table
|
||||||
|
columns={this.formatHeadings()}
|
||||||
|
data={this.formatter[this.props.format](
|
||||||
|
this.props.grades,
|
||||||
|
this.props.areGradesFrozen,
|
||||||
|
)}
|
||||||
|
rowHeaderColumnKey="username"
|
||||||
|
hasFixedColumnWidths
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
|
||||||
<div className="student-filters">
|
|
||||||
<span className="label">
|
|
||||||
Student Groups:
|
|
||||||
</span>
|
|
||||||
<InputSelect
|
|
||||||
name="Tracks"
|
|
||||||
disabled={this.props.tracks.length === 0}
|
|
||||||
value={this.mapSelectedTrackEntry(this.props.selectedTrack)}
|
|
||||||
options={this.mapTracksEntries(this.props.tracks)}
|
|
||||||
onChange={this.updateTracks}
|
|
||||||
/>
|
|
||||||
<InputSelect
|
|
||||||
name="Cohorts"
|
|
||||||
disabled={this.props.cohorts.length === 0}
|
|
||||||
value={this.mapSelectedCohortEntry(this.props.selectedCohort)}
|
|
||||||
options={this.mapCohortsEntries(this.props.cohorts)}
|
|
||||||
onChange={this.updateCohorts}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{PageButtons(this.props)}
|
||||||
<div>
|
<p>* available for learners in the Master's track only</p>
|
||||||
<div style={{ marginLeft: '10px', marginBottom: '10px' }}>
|
<Modal
|
||||||
<a href={`${this.lmsInstructorDashboardUrl(this.props.match.params.courseId)}#view-data_download`}>Generate Grade Report</a>
|
open={this.state.modalOpen}
|
||||||
</div>
|
title="Edit Grades"
|
||||||
<SearchField
|
closeText="Cancel"
|
||||||
onSubmit={value => this.props.searchForUser(this.props.match.params.courseId, value, this.props.selectedCohort, this.props.selectedTrack)}
|
body={(
|
||||||
onChange={filterValue => this.setState({ filterValue })}
|
<div>
|
||||||
onClear={() => this.props.getUserGrades(this.props.match.params.courseId, this.props.selectedCohort, this.props.selectedTrack)}
|
<div>
|
||||||
value={this.state.filterValue}
|
<div className="grade-history-header grade-history-assignment">Assignment: </div> <div>{this.state.modalAssignmentName}</div>
|
||||||
|
<div className="grade-history-header grade-history-student">Student: </div> <div>{this.state.updateUserName}</div>
|
||||||
|
<div className="grade-history-header grade-history-original-grade">Original Grade: </div> <div>{this.props.gradeOriginalEarnedGraded}</div>
|
||||||
|
<div className="grade-history-header grade-history-current-grade">Current Grade: </div> <div>{this.props.gradeOverrideCurrentEarnedGradedOverride}</div>
|
||||||
|
</div>
|
||||||
|
<StatusAlert
|
||||||
|
alertType="danger"
|
||||||
|
dialog="Error retrieving grade override history."
|
||||||
|
open={this.props.errorFetchingGradeOverrideHistory}
|
||||||
|
dismissible={false}
|
||||||
|
/>
|
||||||
|
{!this.props.errorFetchingGradeOverrideHistory && (
|
||||||
|
<Table
|
||||||
|
columns={GRADE_OVERRIDE_HISTORY_COLUMNS}
|
||||||
|
data={[...this.props.gradeOverrides, {
|
||||||
|
date: this.state.todaysDate,
|
||||||
|
reason: (<input
|
||||||
|
type="text"
|
||||||
|
name="reasonForChange"
|
||||||
|
value={this.state.reasonForChange}
|
||||||
|
onChange={value => this.onChange(value)}
|
||||||
|
ref={(input) => { this.overrideReasonInput = input; }}
|
||||||
|
/>),
|
||||||
|
adjustedGrade: (
|
||||||
|
<span>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="adjustedGradeValue"
|
||||||
|
value={this.state.adjustedGradeValue}
|
||||||
|
onChange={value => this.onChange(value)}
|
||||||
|
/>
|
||||||
|
{(this.state.adjustedGradePossible
|
||||||
|
|| this.props.gradeOriginalPossibleGraded)
|
||||||
|
&& ' / '}
|
||||||
|
{this.state.adjustedGradePossible
|
||||||
|
|| this.props.gradeOriginalPossibleGraded}
|
||||||
|
</span>),
|
||||||
|
}]}
|
||||||
|
/>)}
|
||||||
|
|
||||||
|
<div>Showing most recent actions (max 5). To see more, please contact
|
||||||
|
support.
|
||||||
|
</div>
|
||||||
|
<div>Note: Once you save, your changes will be visible to students.</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
buttons={[
|
||||||
|
<Button
|
||||||
|
buttonType="primary"
|
||||||
|
onClick={this.handleAdjustedGradeClick}
|
||||||
|
>
|
||||||
|
Save Grade
|
||||||
|
</Button>,
|
||||||
|
]}
|
||||||
|
onClose={this.closeAssignmentModal}
|
||||||
/>
|
/>
|
||||||
<div className="d-flex justify-content-end" style={{ marginTop: '20px' }}>
|
|
||||||
<Button
|
|
||||||
label="Previous"
|
|
||||||
buttonType="primary"
|
|
||||||
style={{ visibility: (!this.props.prevPage ? 'hidden' : 'visible') }}
|
|
||||||
onClick={() => this.props.getPrevNextGrades(this.props.prevPage, this.props.selectedCohort, this.props.selectedTrack)}
|
|
||||||
/>
|
|
||||||
<div style={{ width: '10px' }} />
|
|
||||||
<Button
|
|
||||||
label="Next"
|
|
||||||
buttonType="primary"
|
|
||||||
style={{ visibility: (!this.props.nextPage ? 'hidden' : 'visible') }}
|
|
||||||
onClick={() => this.props.getPrevNextGrades(this.props.nextPage, this.props.selectedCohort, this.props.selectedTrack)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{this.props.showBulkManagement && (
|
||||||
<br />
|
<div>
|
||||||
<StatusAlert
|
<h4>Use this feature by downloading a CSV for bulk management,
|
||||||
alertType="success"
|
overriding grades locally, and coming back here to upload.
|
||||||
dialog="The grade has been successfully edited."
|
</h4>
|
||||||
onClose={() => this.props.updateBanner(false)}
|
<form ref={this.fileFormRef} action={this.props.gradeExportUrl} method="post">
|
||||||
open={this.props.showSuccess}
|
<StatusAlert
|
||||||
/>
|
alertType="danger"
|
||||||
<div className="gbook">
|
dialog={this.props.bulkImportError}
|
||||||
<Table
|
open={this.props.bulkImportError}
|
||||||
columns={this.props.headings}
|
dismissible={false}
|
||||||
data={this.formatter[this.props.format](this.props.grades, this.props.areGradesFrozen)}
|
/>
|
||||||
tableSortable
|
<StatusAlert
|
||||||
defaultSortDirection="asc"
|
alertType="success"
|
||||||
defaultSortedColumn="username"
|
dialog="CSV processing. File uploads may take several minutes to complete"
|
||||||
|
open={this.props.uploadSuccess}
|
||||||
|
dismissible={false}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
className="d-none"
|
||||||
|
type="file"
|
||||||
|
name="csv"
|
||||||
|
label="Upload Grade CSV"
|
||||||
|
onChange={this.handleFileInputChange}
|
||||||
|
ref={this.fileInputRef}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
<Button
|
||||||
|
buttonType="primary"
|
||||||
|
onClick={this.handleClickImportGrades}
|
||||||
|
>
|
||||||
|
Import Grades
|
||||||
|
</Button>
|
||||||
|
<p>
|
||||||
|
Results appear in the table below.<br />
|
||||||
|
Grade processing may take a few seconds.
|
||||||
|
</p>
|
||||||
|
<Table
|
||||||
|
data={this.props.bulkManagementHistory.map(this.formatHistoryRow)}
|
||||||
|
hasFixedColumnWidths
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
key: 'filename',
|
||||||
|
label: 'Gradebook',
|
||||||
|
columnSortable: false,
|
||||||
|
width: 'col-5',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'resultsSummary',
|
||||||
|
label: 'Download Summary',
|
||||||
|
columnSortable: false,
|
||||||
|
width: 'col',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'user',
|
||||||
|
label: 'Who',
|
||||||
|
columnSortable: false,
|
||||||
|
width: 'col-1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'timeUploaded',
|
||||||
|
label: 'When',
|
||||||
|
columnSortable: false,
|
||||||
|
width: 'col',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
className="table-striped"
|
||||||
|
/>
|
||||||
|
</div>)}
|
||||||
|
</Tabs>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
initiallyOpen={false}
|
||||||
|
title={
|
||||||
|
<React.Fragment>
|
||||||
|
<FontAwesomeIcon icon={faFilter} /> Filter By...
|
||||||
|
</React.Fragment>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Collapsible title="Assignments" isOpen className="filter-group mb-3">
|
||||||
|
<div>
|
||||||
|
<div className="student-filters">
|
||||||
|
<span className="label">
|
||||||
|
Assignment Types:
|
||||||
|
</span>
|
||||||
|
<InputSelect
|
||||||
|
name="assignment-types"
|
||||||
|
aria-label="Assignment Types"
|
||||||
|
value={this.props.selectedAssignmentType}
|
||||||
|
options={this.mapAssignmentTypeEntries(this.props.assignmentTypes)}
|
||||||
|
onChange={this.updateAssignmentTypes}
|
||||||
|
disabled={this.props.assignmentFilterOptions.length === 0}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Modal
|
<div className="student-filters">
|
||||||
open={this.state.modalOpen}
|
<span className="label">
|
||||||
title="Edit Grades"
|
Assignment:
|
||||||
closeText="Cancel"
|
</span>
|
||||||
body={(
|
<InputSelect
|
||||||
<div>
|
name="assignment"
|
||||||
<h3>{this.state.modalModel[0].assignmentName}</h3>
|
aria-label="Assignment"
|
||||||
<Table
|
value={this.props.selectedAssignment}
|
||||||
columns={[{ label: 'Username', key: 'username' }, { label: 'Current grade', key: 'currentGrade' }, { label: 'Adjusted grade', key: 'adjustedGrade' }]}
|
options={this.getAssignmentFilterOptions()}
|
||||||
data={this.state.modalModel}
|
onChange={this.handleAssignmentFilterChange}
|
||||||
/>
|
disabled={this.props.assignmentFilterOptions.length === 0}
|
||||||
<div>Note: Once you save, your changes will be visible to students.</div>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
<p>Grade Range (0% - 100%)</p>
|
||||||
buttons={[
|
<form className="d-flex justify-content-between align-items-center" onSubmit={this.handleSubmitAssignmentGrade}>
|
||||||
<Button
|
<InputText
|
||||||
label="Save Grade"
|
label="Min Grade"
|
||||||
buttonType="primary"
|
name="assignmentGradeMin"
|
||||||
onClick={this.handleAdjustedGradeClick}
|
type="number"
|
||||||
/>,
|
min={0}
|
||||||
]}
|
max={100}
|
||||||
onClose={() => this.setState({
|
step={1}
|
||||||
modalOpen: false,
|
value={this.state.assignmentGradeMin}
|
||||||
modalModel: [{}],
|
disabled={!this.props.selectedAssignment}
|
||||||
updateVal: 0,
|
onChange={this.handleMinAssigGradeChange}
|
||||||
updateModuleId: null,
|
/>
|
||||||
updateUserId: null,
|
<span className="input-percent-label">%</span>
|
||||||
})}
|
<InputText
|
||||||
/>
|
label="Max Grade"
|
||||||
|
name="assignmentGradeMax"
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
step={1}
|
||||||
|
value={this.state.assignmentGradeMax}
|
||||||
|
disabled={!this.props.selectedAssignment}
|
||||||
|
onChange={this.handleMaxAssigGradeChange}
|
||||||
|
/>
|
||||||
|
<span className="input-percent-label">%</span>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className="btn-outline-secondary"
|
||||||
|
name="assignmentGradeMinMax"
|
||||||
|
disabled={!this.props.selectedAssignment}
|
||||||
|
>
|
||||||
|
Apply
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Collapsible>
|
||||||
</div>
|
<Collapsible title="Overall Grade" isOpen className="filter-group mb-3">
|
||||||
|
<div className="d-flex justify-content-between align-items-center">
|
||||||
|
<InputText
|
||||||
|
value={this.state.courseGradeMin}
|
||||||
|
name="minimum-grade"
|
||||||
|
label="Min Grade"
|
||||||
|
onChange={value => this.handleCourseGradeFilterChange('min', value)}
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
/>
|
||||||
|
<span className="input-percent-label">%</span>
|
||||||
|
<InputText
|
||||||
|
value={this.state.courseGradeMax}
|
||||||
|
name="max-grade"
|
||||||
|
label="Max Grade"
|
||||||
|
onChange={value => this.handleCourseGradeFilterChange('max', value)}
|
||||||
|
type="number"
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
/>
|
||||||
|
<span className="input-percent-label">%</span>
|
||||||
|
<Button
|
||||||
|
buttonType="outline-secondary"
|
||||||
|
onClick={this.handleCourseGradeFilterApplyButtonClick}
|
||||||
|
>
|
||||||
|
Apply
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Collapsible>
|
||||||
|
<Collapsible title="Student Groups" isOpen className="filter-group mb-3">
|
||||||
|
<InputSelect
|
||||||
|
name="Tracks"
|
||||||
|
aria-label="Tracks"
|
||||||
|
disabled={this.props.tracks.length === 0}
|
||||||
|
value={this.mapSelectedTrackEntry(this.props.selectedTrack)}
|
||||||
|
options={this.mapTracksEntries(this.props.tracks)}
|
||||||
|
onChange={this.updateTracks}
|
||||||
|
/>
|
||||||
|
<InputSelect
|
||||||
|
name="Cohorts"
|
||||||
|
aria-label="Cohorts"
|
||||||
|
disabled={this.props.cohorts.length === 0}
|
||||||
|
value={this.mapSelectedCohortEntry(this.props.selectedCohort)}
|
||||||
|
options={this.mapCohortsEntries(this.props.cohorts)}
|
||||||
|
onChange={this.updateCohorts}
|
||||||
|
/>
|
||||||
|
</Collapsible>
|
||||||
|
</Drawer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gradebook.defaultProps = {
|
||||||
|
areGradesFrozen: false,
|
||||||
|
assignmentTypes: [],
|
||||||
|
assignmentFilterOptions: [],
|
||||||
|
canUserViewGradebook: false,
|
||||||
|
cohorts: [],
|
||||||
|
grades: [],
|
||||||
|
gradeOverrides: [],
|
||||||
|
gradeOverrideCurrentEarnedGradedOverride: null,
|
||||||
|
gradeOriginalEarnedGraded: null,
|
||||||
|
gradeOriginalPossibleGraded: null,
|
||||||
|
location: {
|
||||||
|
search: '',
|
||||||
|
},
|
||||||
|
courseId: '',
|
||||||
|
selectedCohort: null,
|
||||||
|
selectedTrack: null,
|
||||||
|
selectedAssignmentType: '',
|
||||||
|
selectedAssignment: '',
|
||||||
|
showSpinner: false,
|
||||||
|
tracks: [],
|
||||||
|
bulkImportError: '',
|
||||||
|
uploadSuccess: false,
|
||||||
|
showBulkManagement: false,
|
||||||
|
bulkManagementHistory: [],
|
||||||
|
errorFetchingGradeOverrideHistory: false,
|
||||||
|
totalUsersCount: null,
|
||||||
|
filteredUsersCount: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
Gradebook.propTypes = {
|
||||||
|
areGradesFrozen: PropTypes.bool,
|
||||||
|
assignmentTypes: PropTypes.arrayOf(PropTypes.string),
|
||||||
|
assignmentFilterOptions: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
label: PropTypes.string,
|
||||||
|
subsectionLabel: PropTypes.string,
|
||||||
|
})),
|
||||||
|
canUserViewGradebook: PropTypes.bool,
|
||||||
|
cohorts: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
name: PropTypes.string,
|
||||||
|
id: PropTypes.number,
|
||||||
|
})),
|
||||||
|
filterAssignmentType: PropTypes.func.isRequired,
|
||||||
|
updateAssignmentFilter: PropTypes.func.isRequired,
|
||||||
|
updateAssignmentLimits: PropTypes.func.isRequired,
|
||||||
|
format: PropTypes.string.isRequired,
|
||||||
|
getRoles: PropTypes.func.isRequired,
|
||||||
|
getUserGrades: PropTypes.func.isRequired,
|
||||||
|
fetchGradeOverrideHistory: PropTypes.func.isRequired,
|
||||||
|
grades: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
percent: PropTypes.number,
|
||||||
|
section_breakdown: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
attempted: PropTypes.bool,
|
||||||
|
category: PropTypes.string,
|
||||||
|
label: PropTypes.string,
|
||||||
|
module_id: PropTypes.string,
|
||||||
|
percent: PropTypes.number,
|
||||||
|
scoreEarned: PropTypes.number,
|
||||||
|
scorePossible: PropTypes.number,
|
||||||
|
subsection_name: PropTypes.string,
|
||||||
|
})),
|
||||||
|
user_id: PropTypes.number,
|
||||||
|
user_name: PropTypes.string,
|
||||||
|
})),
|
||||||
|
gradeOverrides: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
date: PropTypes.string,
|
||||||
|
grader: PropTypes.string,
|
||||||
|
reason: PropTypes.string,
|
||||||
|
adjustedGrade: PropTypes.number,
|
||||||
|
})),
|
||||||
|
gradeOverrideCurrentEarnedGradedOverride: PropTypes.number,
|
||||||
|
gradeOriginalEarnedGraded: PropTypes.number,
|
||||||
|
gradeOriginalPossibleGraded: PropTypes.number,
|
||||||
|
doneViewingAssignment: PropTypes.func.isRequired,
|
||||||
|
headings: PropTypes.arrayOf(PropTypes.string).isRequired,
|
||||||
|
history: PropTypes.shape({
|
||||||
|
push: PropTypes.func,
|
||||||
|
}).isRequired,
|
||||||
|
location: PropTypes.shape({
|
||||||
|
search: PropTypes.string,
|
||||||
|
}),
|
||||||
|
courseId: PropTypes.string,
|
||||||
|
searchForUser: PropTypes.func.isRequired,
|
||||||
|
selectedAssignmentType: PropTypes.string,
|
||||||
|
selectedAssignment: PropTypes.string,
|
||||||
|
selectedCohort: PropTypes.string,
|
||||||
|
selectedTrack: PropTypes.string,
|
||||||
|
resetFilters: PropTypes.func.isRequired,
|
||||||
|
showSpinner: PropTypes.bool,
|
||||||
|
showSuccess: PropTypes.bool.isRequired,
|
||||||
|
toggleFormat: PropTypes.func.isRequired,
|
||||||
|
tracks: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
name: PropTypes.string,
|
||||||
|
})),
|
||||||
|
closeBanner: PropTypes.func.isRequired,
|
||||||
|
updateGrades: PropTypes.func.isRequired,
|
||||||
|
gradeExportUrl: PropTypes.string.isRequired,
|
||||||
|
interventionExportUrl: PropTypes.string.isRequired,
|
||||||
|
submitFileUploadFormData: PropTypes.func.isRequired,
|
||||||
|
bulkImportError: PropTypes.string,
|
||||||
|
uploadSuccess: PropTypes.bool,
|
||||||
|
errorFetchingGradeOverrideHistory: PropTypes.bool,
|
||||||
|
showBulkManagement: PropTypes.bool,
|
||||||
|
bulkManagementHistory: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
originalFilename: PropTypes.string.isRequired,
|
||||||
|
user: PropTypes.string.isRequired,
|
||||||
|
timeUploaded: PropTypes.string.isRequired,
|
||||||
|
summaryOfRowsProcessed: PropTypes.shape({
|
||||||
|
total: PropTypes.number.isRequired,
|
||||||
|
successfullyProcessed: PropTypes.number.isRequired,
|
||||||
|
failed: PropTypes.number.isRequired,
|
||||||
|
skipped: PropTypes.number.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
})),
|
||||||
|
totalUsersCount: PropTypes.number,
|
||||||
|
filteredUsersCount: PropTypes.number,
|
||||||
|
initializeFilters: PropTypes.func.isRequired,
|
||||||
|
updateGradesIfAssignmentGradeFiltersSet: PropTypes.func.isRequired,
|
||||||
|
updateCourseGradeFilter: PropTypes.func.isRequired,
|
||||||
|
downloadBulkGradesReport: PropTypes.func.isRequired,
|
||||||
|
downloadInterventionReport: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
.color-gray-dark {
|
|
||||||
color: #767676;
|
|
||||||
}
|
|
||||||
|
|
||||||
.weight-bold {
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.size-16 {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-bottom-blue {
|
|
||||||
border-bottom: 1px solid #0075b4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.border-bottom-gray {
|
|
||||||
border-bottom: 1px solid #e7e7e7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-link::after {
|
|
||||||
content: '\00BB';
|
|
||||||
padding-left: 4px;
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Hyperlink, Icon } from '@edx/paragon';
|
import { Hyperlink } from '@edx/paragon';
|
||||||
import { configuration } from '../../config';
|
|
||||||
|
|
||||||
import EdxLogo from '../../../assets/edx-sm.png';
|
import EdxLogo from '../../../assets/edx-sm.png';
|
||||||
|
|
||||||
export default class Header extends React.Component {
|
export default class Header extends React.Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
mobileNavOpen: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
renderLogo() {
|
renderLogo() {
|
||||||
return (
|
return (
|
||||||
<img src={EdxLogo} alt="edX logo" height="30" width="60" />
|
<img src={EdxLogo} alt="edX logo" height="30" width="60" />
|
||||||
@@ -22,18 +14,11 @@ export default class Header extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div className="mb-3">
|
<div className="mb-3">
|
||||||
<header className="d-flex justify-content-center align-items-center p-3 border-bottom-blue">
|
<header className="d-flex justify-content-center align-items-center p-3 border-bottom-blue">
|
||||||
<Hyperlink content={this.renderLogo()} destination="https://www.edx.org" />
|
<Hyperlink destination="https://www.edx.org">
|
||||||
|
{this.renderLogo()}
|
||||||
|
</Hyperlink>
|
||||||
<div />
|
<div />
|
||||||
</header>
|
</header>
|
||||||
{this.state.mobileNavOpen &&
|
|
||||||
<nav className="d-flex flex-column weight-bold size-16">
|
|
||||||
<a href="https://www.google.com" className="nav-link border-bottom-gray">Rick</a>
|
|
||||||
<a href="https://www.google.com" className="nav-link border-bottom-gray">Alex</a>
|
|
||||||
<a href="https://www.google.com" className="nav-link border-bottom-gray">Jasen</a>
|
|
||||||
<a href="https://www.google.com" className="nav-link border-bottom-gray">Doug</a>
|
|
||||||
<a href="https://www.google.com" className="nav-link border-bottom-gray">Simon</a>
|
|
||||||
</nav>
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
36
src/components/PageButtons/PageButtons.test.jsx
Normal file
36
src/components/PageButtons/PageButtons.test.jsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import renderer from 'react-test-renderer';
|
||||||
|
import PageButtons from '.';
|
||||||
|
|
||||||
|
const createInput = function createInput(prevPage, nextPage) {
|
||||||
|
return {
|
||||||
|
prevPage,
|
||||||
|
nextPage,
|
||||||
|
selectedTrack: 't',
|
||||||
|
selectedCohort: 'c',
|
||||||
|
getPrevNextGrades() {},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('PageButtons', () => {
|
||||||
|
const assertPageButtonsSnapshot = function assertPageButtonsSnapshot(input) {
|
||||||
|
const pb = renderer.create(PageButtons(input));
|
||||||
|
const tree = pb.toJSON();
|
||||||
|
expect(tree).toMatchSnapshot();
|
||||||
|
};
|
||||||
|
|
||||||
|
it('prev null, next null', () => {
|
||||||
|
assertPageButtonsSnapshot(createInput(null, null));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prev null, next not null', () => {
|
||||||
|
assertPageButtonsSnapshot(createInput(null, 'np'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prev not null, next null', () => {
|
||||||
|
assertPageButtonsSnapshot(createInput('pp', null));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('prev not null, next not null', () => {
|
||||||
|
assertPageButtonsSnapshot(createInput('pp', 'np'));
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`PageButtons prev not null, next not null 1`] = `
|
||||||
|
<div
|
||||||
|
className="d-flex justify-content-center"
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"paddingBottom": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={false}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Previous Page
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={false}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Next Page
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`PageButtons prev not null, next null 1`] = `
|
||||||
|
<div
|
||||||
|
className="d-flex justify-content-center"
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"paddingBottom": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={false}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Previous Page
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={true}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Next Page
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`PageButtons prev null, next not null 1`] = `
|
||||||
|
<div
|
||||||
|
className="d-flex justify-content-center"
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"paddingBottom": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={true}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Previous Page
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={false}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Next Page
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`PageButtons prev null, next null 1`] = `
|
||||||
|
<div
|
||||||
|
className="d-flex justify-content-center"
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"paddingBottom": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={true}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Previous Page
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-primary"
|
||||||
|
disabled={true}
|
||||||
|
onBlur={[Function]}
|
||||||
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
|
style={
|
||||||
|
Object {
|
||||||
|
"margin": "20px",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
Next Page
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
79
src/components/PageButtons/index.jsx
Normal file
79
src/components/PageButtons/index.jsx
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Button } from '@edx/paragon';
|
||||||
|
|
||||||
|
|
||||||
|
export default function PageButtons({
|
||||||
|
prevPage, nextPage, selectedTrack, selectedCohort, selectedAssignmentType,
|
||||||
|
getPrevNextGrades, match,
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="d-flex justify-content-center"
|
||||||
|
style={{ paddingBottom: '20px' }}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
style={{ margin: '20px' }}
|
||||||
|
buttonType="outline-primary"
|
||||||
|
disabled={!prevPage}
|
||||||
|
onClick={() =>
|
||||||
|
getPrevNextGrades(
|
||||||
|
prevPage,
|
||||||
|
match.params.courseId,
|
||||||
|
selectedCohort,
|
||||||
|
selectedTrack,
|
||||||
|
selectedAssignmentType,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
Previous Page
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
style={{ margin: '20px' }}
|
||||||
|
buttonType="outline-primary"
|
||||||
|
disabled={!nextPage}
|
||||||
|
onClick={() =>
|
||||||
|
getPrevNextGrades(
|
||||||
|
nextPage,
|
||||||
|
match.params.courseId,
|
||||||
|
selectedCohort,
|
||||||
|
selectedTrack,
|
||||||
|
selectedAssignmentType,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
Next Page
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
PageButtons.defaultProps = {
|
||||||
|
match: {
|
||||||
|
params: {
|
||||||
|
courseId: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nextPage: '',
|
||||||
|
prevPage: '',
|
||||||
|
selectedCohort: null,
|
||||||
|
selectedTrack: null,
|
||||||
|
selectedAssignmentType: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
PageButtons.propTypes = {
|
||||||
|
getPrevNextGrades: PropTypes.func.isRequired,
|
||||||
|
match: PropTypes.shape({
|
||||||
|
params: PropTypes.shape({
|
||||||
|
courseId: PropTypes.string,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
nextPage: PropTypes.string,
|
||||||
|
prevPage: PropTypes.string,
|
||||||
|
selectedAssignmentType: PropTypes.string,
|
||||||
|
selectedCohort: PropTypes.shape({
|
||||||
|
name: PropTypes.string,
|
||||||
|
}),
|
||||||
|
selectedTrack: PropTypes.shape({
|
||||||
|
name: PropTypes.string,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
@@ -2,86 +2,146 @@ import { connect } from 'react-redux';
|
|||||||
|
|
||||||
import Gradebook from '../../components/Gradebook';
|
import Gradebook from '../../components/Gradebook';
|
||||||
import {
|
import {
|
||||||
|
closeBanner,
|
||||||
|
doneViewingAssignment,
|
||||||
|
fetchGradeOverrideHistory,
|
||||||
fetchGrades,
|
fetchGrades,
|
||||||
fetchMatchingUserGrades,
|
fetchMatchingUserGrades,
|
||||||
fetchPrevNextGrades,
|
fetchPrevNextGrades,
|
||||||
updateGrades,
|
filterAssignmentType,
|
||||||
|
submitFileUploadFormData,
|
||||||
toggleGradeFormat,
|
toggleGradeFormat,
|
||||||
filterColumns,
|
updateGrades,
|
||||||
updateBanner,
|
updateGradesIfAssignmentGradeFiltersSet,
|
||||||
|
downloadBulkGradesReport,
|
||||||
|
downloadInterventionReport,
|
||||||
} from '../../data/actions/grades';
|
} from '../../data/actions/grades';
|
||||||
import { fetchCohorts } from '../../data/actions/cohorts';
|
import { fetchCohorts } from '../../data/actions/cohorts';
|
||||||
import { fetchTracks } from '../../data/actions/tracks';
|
import { fetchTracks } from '../../data/actions/tracks';
|
||||||
|
import { initializeFilters, resetFilters, updateAssignmentFilter, updateAssignmentLimits, updateCourseGradeFilter } from '../../data/actions/filters';
|
||||||
|
import stateHasMastersTrack from '../../data/selectors/tracks';
|
||||||
|
import {
|
||||||
|
getBulkManagementHistory,
|
||||||
|
getHeadings,
|
||||||
|
formatMinAssignmentGrade,
|
||||||
|
formatMaxAssignmentGrade,
|
||||||
|
formatMinCourseGrade,
|
||||||
|
formatMaxCourseGrade,
|
||||||
|
} from '../../data/selectors/grades';
|
||||||
|
import { selectableAssignmentLabels } from '../../data/selectors/filters';
|
||||||
|
import { getCohortNameById } from '../../data/selectors/cohorts';
|
||||||
import { fetchAssignmentTypes } from '../../data/actions/assignmentTypes';
|
import { fetchAssignmentTypes } from '../../data/actions/assignmentTypes';
|
||||||
import { getRoles } from '../../data/actions/roles';
|
import { getRoles } from '../../data/actions/roles';
|
||||||
|
import LmsApiService from '../../data/services/LmsApiService';
|
||||||
|
|
||||||
const mapStateToProps = state => (
|
function shouldShowSpinner(state) {
|
||||||
{
|
if (state.roles.canUserViewGradebook === true) {
|
||||||
grades: state.grades.results,
|
|
||||||
headings: state.grades.headings,
|
|
||||||
tracks: state.tracks.results,
|
|
||||||
cohorts: state.cohorts.results,
|
|
||||||
selectedTrack: state.grades.selectedTrack,
|
|
||||||
selectedCohort: state.grades.selectedCohort,
|
|
||||||
format: state.grades.gradeFormat,
|
|
||||||
showSuccess: state.grades.showSuccess,
|
|
||||||
prevPage: state.grades.prevPage,
|
|
||||||
nextPage: state.grades.nextPage,
|
|
||||||
assignmnetTypes: state.assignmentTypes.results,
|
|
||||||
areGradesFrozen: state.assignmentTypes.areGradesFrozen,
|
|
||||||
showSpinner: shouldShowSpinner(state),
|
|
||||||
canUserViewGradebook: state.roles.canUserViewGradebook
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
function shouldShowSpinner (state) {
|
|
||||||
if (state.roles.canUserViewGradebook === true){
|
|
||||||
return state.grades.showSpinner;
|
return state.grades.showSpinner;
|
||||||
} else if (state.roles.canUserViewGradebook === false){
|
} else if (state.roles.canUserViewGradebook === false) {
|
||||||
return false;
|
return false;
|
||||||
} else { // canUserViewGradebook === null
|
} // canUserViewGradebook === null
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => (
|
const mapStateToProps = (state, ownProps) => (
|
||||||
{
|
{
|
||||||
getUserGrades: (courseId, cohort, track) => {
|
courseId: ownProps.match.params.courseId,
|
||||||
dispatch(fetchGrades(courseId, cohort, track));
|
grades: state.grades.results,
|
||||||
},
|
gradeOverrides: state.grades.gradeOverrideHistoryResults,
|
||||||
searchForUser: (courseId, searchText, cohort, track) => {
|
gradeOverrideCurrentEarnedAllOverride: state.grades.gradeOverrideCurrentEarnedAllOverride,
|
||||||
dispatch(fetchMatchingUserGrades(courseId, searchText, cohort, track, false));
|
gradeOverrideCurrentPossibleAllOverride: state.grades.gradeOverrideCurrentPossibleAllOverride,
|
||||||
},
|
gradeOverrideCurrentEarnedGradedOverride: state.grades.gradeOverrideCurrentEarnedGradedOverride,
|
||||||
getPrevNextGrades: (endpoint, cohort, track) => {
|
gradeOverrideCurrentPossibleGradedOverride:
|
||||||
dispatch(fetchPrevNextGrades(endpoint, cohort, track));
|
state.grades.gradeOverrideCurrentPossibleGradedOverride,
|
||||||
},
|
gradeOriginalEarnedGraded: state.grades.gradeOriginalEarnedGraded,
|
||||||
getCohorts: (courseId) => {
|
gradeOriginalPossibleGraded: state.grades.gradeOriginalPossibleGraded,
|
||||||
dispatch(fetchCohorts(courseId));
|
headings: getHeadings(state),
|
||||||
},
|
tracks: state.tracks.results,
|
||||||
getTracks: (courseId) => {
|
cohorts: state.cohorts.results,
|
||||||
dispatch(fetchTracks(courseId));
|
selectedTrack: state.filters.track,
|
||||||
},
|
selectedCohort: state.filters.cohort,
|
||||||
getAssignmentTypes: (courseId) => {
|
selectedAssignmentType: state.filters.assignmentType,
|
||||||
dispatch(fetchAssignmentTypes(courseId));
|
selectedAssignment: (state.filters.assignment || {}).label,
|
||||||
},
|
format: state.grades.gradeFormat,
|
||||||
updateGrades: (courseId, updateData, searchText, cohort, track) => {
|
showSuccess: state.grades.showSuccess,
|
||||||
dispatch(updateGrades(courseId, updateData, searchText, cohort, track));
|
errorFetchingGradeOverrideHistory: state.grades.errorFetchingOverrideHistory,
|
||||||
},
|
prevPage: state.grades.prevPage,
|
||||||
toggleFormat: (formatType) => {
|
nextPage: state.grades.nextPage,
|
||||||
dispatch(toggleGradeFormat(formatType));
|
assignmentTypes: state.assignmentTypes.results,
|
||||||
},
|
assignmentFilterOptions: selectableAssignmentLabels(state),
|
||||||
filterColumns: (filterType, exampleUser) => {
|
areGradesFrozen: state.assignmentTypes.areGradesFrozen,
|
||||||
dispatch(filterColumns(filterType, exampleUser));
|
showSpinner: shouldShowSpinner(state),
|
||||||
},
|
canUserViewGradebook: state.roles.canUserViewGradebook,
|
||||||
updateBanner: (showSuccess) => {
|
gradeExportUrl: LmsApiService.getGradeExportCsvUrl(ownProps.match.params.courseId, {
|
||||||
dispatch(updateBanner(showSuccess));
|
cohort: getCohortNameById(state, state.filters.cohort),
|
||||||
},
|
track: state.filters.track,
|
||||||
getRoles: (matchParams, urlQuery) => {
|
assignment: (state.filters.assignment || {}).id,
|
||||||
dispatch(getRoles(matchParams, urlQuery));
|
assignmentType: state.filters.assignmentType,
|
||||||
},
|
assignmentGradeMin: formatMinAssignmentGrade(
|
||||||
|
state.filters.assignmentGradeMin,
|
||||||
|
{ assignmentId: (state.filters.assignment || {}).id },
|
||||||
|
),
|
||||||
|
assignmentGradeMax: formatMaxAssignmentGrade(
|
||||||
|
state.filters.assignmentGradeMax,
|
||||||
|
{ assignmentId: (state.filters.assignment || {}).id },
|
||||||
|
),
|
||||||
|
courseGradeMin: formatMinCourseGrade(state.filters.courseGradeMin),
|
||||||
|
courseGradeMax: formatMaxCourseGrade(state.filters.courseGradeMax),
|
||||||
|
}),
|
||||||
|
interventionExportUrl:
|
||||||
|
LmsApiService.getInterventionExportCsvUrl(ownProps.match.params.courseId, {
|
||||||
|
cohort: getCohortNameById(state, state.filters.cohort),
|
||||||
|
assignment: (state.filters.assignment || {}).id,
|
||||||
|
assignmentType: state.filters.assignmentType,
|
||||||
|
assignmentGradeMin: formatMinAssignmentGrade(
|
||||||
|
state.filters.assignmentGradeMin,
|
||||||
|
{ assignmentId: (state.filters.assignment || {}).id },
|
||||||
|
),
|
||||||
|
assignmentGradeMax: formatMaxAssignmentGrade(
|
||||||
|
state.filters.assignmentGradeMax,
|
||||||
|
{ assignmentId: (state.filters.assignment || {}).id },
|
||||||
|
),
|
||||||
|
courseGradeMin: formatMinCourseGrade(state.filters.courseGradeMin),
|
||||||
|
courseGradeMax: formatMaxCourseGrade(state.filters.courseGradeMax),
|
||||||
|
}),
|
||||||
|
bulkImportError: state.grades.bulkManagement &&
|
||||||
|
state.grades.bulkManagement.errorMessages ?
|
||||||
|
`Errors while processing: ${state.grades.bulkManagement.errorMessages.join(', ')}` :
|
||||||
|
'',
|
||||||
|
uploadSuccess: !!(state.grades.bulkManagement &&
|
||||||
|
state.grades.bulkManagement.uploadSuccess),
|
||||||
|
showBulkManagement: stateHasMastersTrack(state) && state.config.bulkManagementAvailable,
|
||||||
|
bulkManagementHistory: getBulkManagementHistory(state),
|
||||||
|
totalUsersCount: state.grades.totalUsersCount,
|
||||||
|
filteredUsersCount: state.grades.filteredUsersCount,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const mapDispatchToProps = {
|
||||||
|
doneViewingAssignment,
|
||||||
|
getUserGrades: fetchGrades,
|
||||||
|
fetchGradeOverrideHistory,
|
||||||
|
searchForUser: fetchMatchingUserGrades,
|
||||||
|
getPrevNextGrades: fetchPrevNextGrades,
|
||||||
|
getCohorts: fetchCohorts,
|
||||||
|
getTracks: fetchTracks,
|
||||||
|
getAssignmentTypes: fetchAssignmentTypes,
|
||||||
|
updateGrades,
|
||||||
|
toggleFormat: toggleGradeFormat,
|
||||||
|
filterAssignmentType,
|
||||||
|
closeBanner,
|
||||||
|
getRoles,
|
||||||
|
submitFileUploadFormData,
|
||||||
|
initializeFilters,
|
||||||
|
resetFilters,
|
||||||
|
updateAssignmentFilter,
|
||||||
|
updateAssignmentLimits,
|
||||||
|
updateGradesIfAssignmentGradeFiltersSet,
|
||||||
|
updateCourseGradeFilter,
|
||||||
|
downloadBulkGradesReport,
|
||||||
|
downloadInterventionReport,
|
||||||
|
};
|
||||||
|
|
||||||
const GradebookPage = connect(
|
const GradebookPage = connect(
|
||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps,
|
mapDispatchToProps,
|
||||||
|
|||||||
@@ -4,12 +4,17 @@ import {
|
|||||||
ERROR_FETCHING_ASSIGNMENT_TYPES,
|
ERROR_FETCHING_ASSIGNMENT_TYPES,
|
||||||
GOT_ARE_GRADES_FROZEN,
|
GOT_ARE_GRADES_FROZEN,
|
||||||
} from '../constants/actionTypes/assignmentTypes';
|
} from '../constants/actionTypes/assignmentTypes';
|
||||||
|
import GOT_BULK_MANAGEMENT_CONFIG from '../constants/actionTypes/config';
|
||||||
import LmsApiService from '../services/LmsApiService';
|
import LmsApiService from '../services/LmsApiService';
|
||||||
|
|
||||||
const startedFetchingAssignmentTypes = () => ({ type: STARTED_FETCHING_ASSIGNMENT_TYPES });
|
const startedFetchingAssignmentTypes = () => ({ type: STARTED_FETCHING_ASSIGNMENT_TYPES });
|
||||||
const errorFetchingAssignmentTypes = () => ({ type: ERROR_FETCHING_ASSIGNMENT_TYPES });
|
const errorFetchingAssignmentTypes = () => ({ type: ERROR_FETCHING_ASSIGNMENT_TYPES });
|
||||||
const gotAssignmentTypes = assignmentTypes => ({ type: GOT_ASSIGNMENT_TYPES, assignmentTypes });
|
const gotAssignmentTypes = assignmentTypes => ({ type: GOT_ASSIGNMENT_TYPES, assignmentTypes });
|
||||||
const gotGradesFrozen = areGradesFrozen => ({ type: GOT_ARE_GRADES_FROZEN, areGradesFrozen });
|
const gotGradesFrozen = areGradesFrozen => ({ type: GOT_ARE_GRADES_FROZEN, areGradesFrozen });
|
||||||
|
const gotBulkManagementConfig = bulkManagementEnabled => ({
|
||||||
|
type: GOT_BULK_MANAGEMENT_CONFIG,
|
||||||
|
data: bulkManagementEnabled,
|
||||||
|
});
|
||||||
|
|
||||||
const fetchAssignmentTypes = courseId => (
|
const fetchAssignmentTypes = courseId => (
|
||||||
(dispatch) => {
|
(dispatch) => {
|
||||||
@@ -19,6 +24,7 @@ const fetchAssignmentTypes = courseId => (
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatch(gotAssignmentTypes(Object.keys(data.assignment_types)));
|
dispatch(gotAssignmentTypes(Object.keys(data.assignment_types)));
|
||||||
dispatch(gotGradesFrozen(data.grades_frozen));
|
dispatch(gotGradesFrozen(data.grades_frozen));
|
||||||
|
dispatch(gotBulkManagementConfig(data.can_see_bulk_management));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
dispatch(errorFetchingAssignmentTypes());
|
dispatch(errorFetchingAssignmentTypes());
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ import {
|
|||||||
ERROR_FETCHING_ASSIGNMENT_TYPES,
|
ERROR_FETCHING_ASSIGNMENT_TYPES,
|
||||||
GOT_ARE_GRADES_FROZEN,
|
GOT_ARE_GRADES_FROZEN,
|
||||||
} from '../constants/actionTypes/assignmentTypes';
|
} from '../constants/actionTypes/assignmentTypes';
|
||||||
|
import GOT_BULK_MANAGEMENT_CONFIG from '../constants/actionTypes/config';
|
||||||
|
|
||||||
const mockStore = configureMockStore([thunk]);
|
const mockStore = configureMockStore([thunk]);
|
||||||
const axiosMock = new MockAdapter(apiClient);
|
const axiosMock = new MockAdapter(apiClient);
|
||||||
|
apiClient.isAccessTokenExpired = jest.fn();
|
||||||
|
apiClient.isAccessTokenExpired.mockReturnValue(false);
|
||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -40,12 +43,14 @@ describe('actions', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
grades_frozen: false,
|
grades_frozen: false,
|
||||||
|
can_see_bulk_management: true,
|
||||||
};
|
};
|
||||||
it('dispatches success action after fetching fetchAssignmentTypes', () => {
|
it('dispatches success action after fetching fetchAssignmentTypes', () => {
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{ type: STARTED_FETCHING_ASSIGNMENT_TYPES },
|
{ type: STARTED_FETCHING_ASSIGNMENT_TYPES },
|
||||||
{ type: GOT_ASSIGNMENT_TYPES, assignmentTypes: Object.keys(responseData.assignment_types) },
|
{ type: GOT_ASSIGNMENT_TYPES, assignmentTypes: Object.keys(responseData.assignment_types) },
|
||||||
{ type: GOT_ARE_GRADES_FROZEN, areGradesFrozen: responseData.grades_frozen },
|
{ type: GOT_ARE_GRADES_FROZEN, areGradesFrozen: responseData.grades_frozen },
|
||||||
|
{ type: GOT_BULK_MANAGEMENT_CONFIG, data: true },
|
||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
@@ -77,6 +82,7 @@ describe('actions', () => {
|
|||||||
{ type: STARTED_FETCHING_ASSIGNMENT_TYPES },
|
{ type: STARTED_FETCHING_ASSIGNMENT_TYPES },
|
||||||
{ type: GOT_ASSIGNMENT_TYPES, assignmentTypes: Object.keys(responseData.assignment_types) },
|
{ type: GOT_ASSIGNMENT_TYPES, assignmentTypes: Object.keys(responseData.assignment_types) },
|
||||||
{ type: GOT_ARE_GRADES_FROZEN, areGradesFrozen: true },
|
{ type: GOT_ARE_GRADES_FROZEN, areGradesFrozen: true },
|
||||||
|
{ type: GOT_BULK_MANAGEMENT_CONFIG, data: true },
|
||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
responseData.grades_frozen = true;
|
responseData.grades_frozen = true;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import {
|
|||||||
|
|
||||||
const mockStore = configureMockStore([thunk]);
|
const mockStore = configureMockStore([thunk]);
|
||||||
const axiosMock = new MockAdapter(apiClient);
|
const axiosMock = new MockAdapter(apiClient);
|
||||||
|
apiClient.isAccessTokenExpired = jest.fn();
|
||||||
|
apiClient.isAccessTokenExpired.mockReturnValue(false);
|
||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|||||||
54
src/data/actions/filters.js
Normal file
54
src/data/actions/filters.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import initialFilters from '../constants/filters';
|
||||||
|
import { INITIALIZE_FILTERS, RESET_FILTERS, UPDATE_ASSIGNMENT_FILTER, UPDATE_ASSIGNMENT_LIMITS, UPDATE_COURSE_GRADE_LIMITS } from '../constants/actionTypes/filters';
|
||||||
|
|
||||||
|
const initializeFilters = ({
|
||||||
|
assignment = initialFilters.assignment,
|
||||||
|
assignmentType = initialFilters.assignmentType,
|
||||||
|
track = initialFilters.track,
|
||||||
|
cohort = initialFilters.cohort,
|
||||||
|
assignmentGradeMin = initialFilters.assignmentGradeMin,
|
||||||
|
assignmentGradeMax = initialFilters.assignmentGradeMax,
|
||||||
|
courseGradeMin = initialFilters.courseGradeMin,
|
||||||
|
courseGradeMax = initialFilters.assignmentGradeMax,
|
||||||
|
}) => ({
|
||||||
|
type: INITIALIZE_FILTERS,
|
||||||
|
data: {
|
||||||
|
assignment: { id: assignment },
|
||||||
|
assignmentType,
|
||||||
|
track,
|
||||||
|
cohort,
|
||||||
|
assignmentGradeMin,
|
||||||
|
assignmentGradeMax,
|
||||||
|
courseGradeMin,
|
||||||
|
courseGradeMax,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const resetFilters = filterNames => ({
|
||||||
|
type: RESET_FILTERS,
|
||||||
|
filterNames,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateAssignmentFilter = assignment => ({
|
||||||
|
type: UPDATE_ASSIGNMENT_FILTER,
|
||||||
|
data: assignment,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateAssignmentLimits = (minGrade, maxGrade) => ({
|
||||||
|
type: UPDATE_ASSIGNMENT_LIMITS,
|
||||||
|
data: { minGrade, maxGrade },
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateCourseGradeFilter = (courseGradeMin, courseGradeMax, courseId) => ({
|
||||||
|
type: UPDATE_COURSE_GRADE_LIMITS,
|
||||||
|
data: {
|
||||||
|
courseGradeMin,
|
||||||
|
courseGradeMax,
|
||||||
|
courseId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export {
|
||||||
|
initializeFilters, resetFilters, updateAssignmentFilter,
|
||||||
|
updateAssignmentLimits, updateCourseGradeFilter,
|
||||||
|
};
|
||||||
@@ -7,79 +7,172 @@ import {
|
|||||||
GRADE_UPDATE_SUCCESS,
|
GRADE_UPDATE_SUCCESS,
|
||||||
GRADE_UPDATE_FAILURE,
|
GRADE_UPDATE_FAILURE,
|
||||||
TOGGLE_GRADE_FORMAT,
|
TOGGLE_GRADE_FORMAT,
|
||||||
SORT_GRADES,
|
FILTER_BY_ASSIGNMENT_TYPE,
|
||||||
FILTER_COLUMNS,
|
OPEN_BANNER,
|
||||||
UPDATE_BANNER,
|
CLOSE_BANNER,
|
||||||
|
START_UPLOAD,
|
||||||
|
UPLOAD_COMPLETE,
|
||||||
|
UPLOAD_ERR,
|
||||||
|
GOT_BULK_HISTORY,
|
||||||
|
BULK_HISTORY_ERR,
|
||||||
|
GOT_GRADE_OVERRIDE_HISTORY,
|
||||||
|
DONE_VIEWING_ASSIGNMENT,
|
||||||
|
ERROR_FETCHING_GRADE_OVERRIDE_HISTORY,
|
||||||
|
UPLOAD_OVERRIDE,
|
||||||
|
UPLOAD_OVERRIDE_ERROR,
|
||||||
|
BULK_GRADE_REPORT_DOWNLOADED,
|
||||||
|
INTERVENTION_REPORT_DOWNLOADED,
|
||||||
} from '../constants/actionTypes/grades';
|
} from '../constants/actionTypes/grades';
|
||||||
import LmsApiService from '../services/LmsApiService';
|
import LmsApiService from '../services/LmsApiService';
|
||||||
import store from '../store';
|
import { sortAlphaAsc, formatDateForDisplay } from './utils';
|
||||||
import { headingMapper, gradeSortMap, sortAlphaAsc } from './utils';
|
import { formatMaxAssignmentGrade, formatMinAssignmentGrade, formatMaxCourseGrade, formatMinCourseGrade } from '../selectors/grades';
|
||||||
|
import { getFilters } from '../selectors/filters';
|
||||||
import apiClient from '../apiClient';
|
import apiClient from '../apiClient';
|
||||||
|
|
||||||
const defaultAssignmentFilter = 'All';
|
const defaultAssignmentFilter = 'All';
|
||||||
|
|
||||||
const sortGrades = (columnName, direction) => {
|
const startedCsvUpload = () => ({ type: START_UPLOAD });
|
||||||
const sortFn = gradeSortMap(columnName, direction);
|
const finishedCsvUpload = () => ({ type: UPLOAD_COMPLETE });
|
||||||
const { results } = store.getState().grades;
|
const csvUploadError = data => ({ type: UPLOAD_ERR, data });
|
||||||
results.sort(sortFn);
|
const gotBulkHistory = data => ({ type: GOT_BULK_HISTORY, data });
|
||||||
|
const bulkHistoryError = () => ({ type: BULK_HISTORY_ERR });
|
||||||
/* have to make a copy of results or React wont know there was
|
|
||||||
* a change and wont trigger a re-render
|
|
||||||
*/
|
|
||||||
return ({ type: SORT_GRADES, results: [...results] });
|
|
||||||
};
|
|
||||||
|
|
||||||
const startedFetchingGrades = () => ({ type: STARTED_FETCHING_GRADES });
|
const startedFetchingGrades = () => ({ type: STARTED_FETCHING_GRADES });
|
||||||
const finishedFetchingGrades = () => ({ type: FINISHED_FETCHING_GRADES });
|
const finishedFetchingGrades = () => ({ type: FINISHED_FETCHING_GRADES });
|
||||||
const errorFetchingGrades = () => ({ type: ERROR_FETCHING_GRADES });
|
const errorFetchingGrades = () => ({ type: ERROR_FETCHING_GRADES });
|
||||||
const gotGrades = (grades, cohort, track, headings, prev, next) => ({
|
const errorFetchingGradeOverrideHistory = () => ({ type: ERROR_FETCHING_GRADE_OVERRIDE_HISTORY });
|
||||||
|
|
||||||
|
const gotGrades = ({
|
||||||
|
grades, cohort, track, assignmentType, headings, prev,
|
||||||
|
next, courseId, totalUsersCount, filteredUsersCount,
|
||||||
|
}) => ({
|
||||||
type: GOT_GRADES,
|
type: GOT_GRADES,
|
||||||
grades,
|
grades,
|
||||||
cohort,
|
cohort,
|
||||||
track,
|
track,
|
||||||
|
assignmentType,
|
||||||
headings,
|
headings,
|
||||||
prev,
|
prev,
|
||||||
next,
|
next,
|
||||||
|
courseId,
|
||||||
|
totalUsersCount,
|
||||||
|
filteredUsersCount,
|
||||||
|
});
|
||||||
|
|
||||||
|
const gotGradeOverrideHistory = ({
|
||||||
|
overrideHistory, currentEarnedAllOverride, currentPossibleAllOverride,
|
||||||
|
currentEarnedGradedOverride, currentPossibleGradedOverride,
|
||||||
|
originalGradeEarnedAll, originalGradePossibleAll, originalGradeEarnedGraded,
|
||||||
|
originalGradePossibleGraded,
|
||||||
|
}) => ({
|
||||||
|
type: GOT_GRADE_OVERRIDE_HISTORY,
|
||||||
|
overrideHistory,
|
||||||
|
currentEarnedAllOverride,
|
||||||
|
currentPossibleAllOverride,
|
||||||
|
currentEarnedGradedOverride,
|
||||||
|
currentPossibleGradedOverride,
|
||||||
|
originalGradeEarnedAll,
|
||||||
|
originalGradePossibleAll,
|
||||||
|
originalGradeEarnedGraded,
|
||||||
|
originalGradePossibleGraded,
|
||||||
});
|
});
|
||||||
|
|
||||||
const gradeUpdateRequest = () => ({ type: GRADE_UPDATE_REQUEST });
|
const gradeUpdateRequest = () => ({ type: GRADE_UPDATE_REQUEST });
|
||||||
const gradeUpdateSuccess = responseData => ({
|
const gradeUpdateSuccess = (courseId, responseData) => ({
|
||||||
type: GRADE_UPDATE_SUCCESS,
|
type: GRADE_UPDATE_SUCCESS,
|
||||||
|
courseId,
|
||||||
payload: { responseData },
|
payload: { responseData },
|
||||||
});
|
});
|
||||||
const gradeUpdateFailure = error => ({
|
const gradeUpdateFailure = (courseId, error) => ({
|
||||||
type: GRADE_UPDATE_FAILURE,
|
type: GRADE_UPDATE_FAILURE,
|
||||||
|
courseId,
|
||||||
|
payload: { error },
|
||||||
|
});
|
||||||
|
const uploadOverrideSuccess = courseId => ({
|
||||||
|
type: UPLOAD_OVERRIDE,
|
||||||
|
courseId,
|
||||||
|
});
|
||||||
|
// This action for google analytics only. Doesn't change redux state.
|
||||||
|
const downloadBulkGradesReport = courseId => ({
|
||||||
|
type: BULK_GRADE_REPORT_DOWNLOADED,
|
||||||
|
courseId,
|
||||||
|
});
|
||||||
|
// This action for google analytics only. Doesn't change redux state.
|
||||||
|
const downloadInterventionReport = courseId => ({
|
||||||
|
type: INTERVENTION_REPORT_DOWNLOADED,
|
||||||
|
courseId,
|
||||||
|
});
|
||||||
|
const uploadOverrideFailure = (courseId, error) => ({
|
||||||
|
type: UPLOAD_OVERRIDE_ERROR,
|
||||||
|
courseId,
|
||||||
payload: { error },
|
payload: { error },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const toggleGradeFormat = formatType => ({ type: TOGGLE_GRADE_FORMAT, formatType });
|
const toggleGradeFormat = formatType => ({ type: TOGGLE_GRADE_FORMAT, formatType });
|
||||||
|
|
||||||
const filterColumns = (filterType, exampleUser) => (
|
const filterAssignmentType = filterType => (
|
||||||
dispatch => dispatch({
|
dispatch => dispatch({
|
||||||
type: FILTER_COLUMNS,
|
type: FILTER_BY_ASSIGNMENT_TYPE,
|
||||||
headings: headingMapper(filterType)(dispatch, exampleUser),
|
filterType,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
const updateBanner = showSuccess => ({ type: UPDATE_BANNER, showSuccess });
|
const openBanner = () => ({ type: OPEN_BANNER });
|
||||||
|
const closeBanner = () => ({ type: CLOSE_BANNER });
|
||||||
|
|
||||||
const fetchGrades = (courseId, cohort, track, showSuccess) => (
|
const fetchGrades = (
|
||||||
(dispatch) => {
|
courseId,
|
||||||
|
cohort,
|
||||||
|
track,
|
||||||
|
assignmentType,
|
||||||
|
options = {},
|
||||||
|
) => (
|
||||||
|
(dispatch, getState) => {
|
||||||
dispatch(startedFetchingGrades());
|
dispatch(startedFetchingGrades());
|
||||||
return LmsApiService.fetchGradebookData(courseId, null, cohort, track)
|
const {
|
||||||
|
assignment,
|
||||||
|
assignmentGradeMax: assignmentMax,
|
||||||
|
assignmentGradeMin: assignmentMin,
|
||||||
|
courseGradeMin,
|
||||||
|
courseGradeMax,
|
||||||
|
} = getFilters(getState());
|
||||||
|
const { id: assignmentId } = assignment || {};
|
||||||
|
const assignmentGradeMax = formatMaxAssignmentGrade(assignmentMax, { assignmentId });
|
||||||
|
const assignmentGradeMin = formatMinAssignmentGrade(assignmentMin, { assignmentId });
|
||||||
|
const courseGradeMinFormatted = formatMinCourseGrade(courseGradeMin);
|
||||||
|
const courseGradeMaxFormatted = formatMaxCourseGrade(courseGradeMax);
|
||||||
|
return LmsApiService.fetchGradebookData(
|
||||||
|
courseId,
|
||||||
|
options.searchText || null,
|
||||||
|
cohort,
|
||||||
|
track,
|
||||||
|
{
|
||||||
|
assignment: assignmentId,
|
||||||
|
assignmentGradeMax,
|
||||||
|
assignmentGradeMin,
|
||||||
|
courseGradeMin: courseGradeMinFormatted,
|
||||||
|
courseGradeMax: courseGradeMaxFormatted,
|
||||||
|
},
|
||||||
|
|
||||||
|
)
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatch(gotGrades(
|
dispatch(gotGrades({
|
||||||
data.results.sort(sortAlphaAsc),
|
grades: data.results.sort(sortAlphaAsc),
|
||||||
cohort,
|
cohort,
|
||||||
track,
|
track,
|
||||||
headingMapper(defaultAssignmentFilter)(dispatch, data.results[0]),
|
assignmentType,
|
||||||
data.previous,
|
prev: data.previous,
|
||||||
data.next,
|
next: data.next,
|
||||||
));
|
courseId,
|
||||||
|
totalUsersCount: data.total_users_count,
|
||||||
|
filteredUsersCount: data.filtered_users_count,
|
||||||
|
}));
|
||||||
dispatch(finishedFetchingGrades());
|
dispatch(finishedFetchingGrades());
|
||||||
dispatch(updateBanner(!!showSuccess));
|
if (options.showSuccess) {
|
||||||
|
dispatch(openBanner());
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
dispatch(errorFetchingGrades());
|
dispatch(errorFetchingGrades());
|
||||||
@@ -87,43 +180,70 @@ const fetchGrades = (courseId, cohort, track, showSuccess) => (
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const fetchMatchingUserGrades = (courseId, searchText, cohort, track, showSuccess) => (
|
const formatGradeOverrideForDisplay = historyArray => historyArray.map(item => ({
|
||||||
(dispatch) => {
|
date: formatDateForDisplay(new Date(item.history_date)),
|
||||||
dispatch(startedFetchingGrades());
|
grader: item.history_user,
|
||||||
return LmsApiService.fetchGradebookData(courseId, searchText, cohort, track)
|
reason: item.override_reason,
|
||||||
|
adjustedGrade: item.earned_graded_override,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const doneViewingAssignment = () => dispatch => dispatch({
|
||||||
|
type: DONE_VIEWING_ASSIGNMENT,
|
||||||
|
});
|
||||||
|
const fetchGradeOverrideHistory = (subsectionId, userId) => (
|
||||||
|
dispatch =>
|
||||||
|
LmsApiService.fetchGradeOverrideHistory(subsectionId, userId)
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatch(gotGrades(
|
dispatch(gotGradeOverrideHistory({
|
||||||
data.results.sort(sortAlphaAsc),
|
overrideHistory: formatGradeOverrideForDisplay(data.history),
|
||||||
cohort,
|
currentEarnedAllOverride: data.override ? data.override.earned_all_override : null,
|
||||||
track,
|
currentPossibleAllOverride: data.override ? data.override.possible_all_override : null,
|
||||||
headingMapper(defaultAssignmentFilter)(dispatch, data.results[0]),
|
currentEarnedGradedOverride: data.override ? data.override.earned_graded_override : null,
|
||||||
data.previous,
|
currentPossibleGradedOverride: data.override ?
|
||||||
data.next,
|
data.override.possible_graded_override : null,
|
||||||
));
|
originalGradeEarnedAll: data.original_grade ? data.original_grade.earned_all : null,
|
||||||
dispatch(finishedFetchingGrades());
|
originalGradePossibleAll: data.original_grade ? data.original_grade.possible_all : null,
|
||||||
dispatch(updateBanner(showSuccess));
|
originalGradeEarnedGraded: data.original_grade ? data.original_grade.earned_graded : null,
|
||||||
|
originalGradePossibleGraded: data.original_grade ?
|
||||||
|
data.original_grade.possible_graded : null,
|
||||||
|
}));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
dispatch(errorFetchingGrades());
|
dispatch(errorFetchingGradeOverrideHistory());
|
||||||
});
|
})
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const fetchPrevNextGrades = (endpoint, cohort, track) => (
|
const fetchMatchingUserGrades = (
|
||||||
|
courseId,
|
||||||
|
searchText,
|
||||||
|
cohort,
|
||||||
|
track,
|
||||||
|
assignmentType,
|
||||||
|
showSuccess,
|
||||||
|
options = {},
|
||||||
|
) => {
|
||||||
|
const newOptions = { ...options, searchText, showSuccess };
|
||||||
|
return fetchGrades(courseId, cohort, track, assignmentType, newOptions);
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchPrevNextGrades = (endpoint, courseId, cohort, track, assignmentType) => (
|
||||||
(dispatch) => {
|
(dispatch) => {
|
||||||
dispatch(startedFetchingGrades());
|
dispatch(startedFetchingGrades());
|
||||||
return apiClient.get(endpoint)
|
return apiClient.get(endpoint)
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatch(gotGrades(
|
dispatch(gotGrades({
|
||||||
data.results.sort(sortAlphaAsc),
|
grades: data.results.sort(sortAlphaAsc),
|
||||||
cohort,
|
cohort,
|
||||||
track,
|
track,
|
||||||
headingMapper(defaultAssignmentFilter)(dispatch, data.results[0]),
|
assignmentType,
|
||||||
data.previous,
|
prev: data.previous,
|
||||||
data.next,
|
next: data.next,
|
||||||
));
|
courseId,
|
||||||
|
totalUsersCount: data.total_users_count,
|
||||||
|
filteredUsersCount: data.filtered_users_count,
|
||||||
|
}));
|
||||||
dispatch(finishedFetchingGrades());
|
dispatch(finishedFetchingGrades());
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@@ -132,22 +252,72 @@ const fetchPrevNextGrades = (endpoint, cohort, track) => (
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const updateGrades = (courseId, updateData, searchText, cohort, track) => (
|
const updateGrades = (courseId, updateData, searchText, cohort, track) => (
|
||||||
(dispatch) => {
|
(dispatch) => {
|
||||||
dispatch(gradeUpdateRequest());
|
dispatch(gradeUpdateRequest());
|
||||||
return LmsApiService.updateGradebookData(courseId, updateData)
|
return LmsApiService.updateGradebookData(courseId, updateData)
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatch(gradeUpdateSuccess(data));
|
dispatch(gradeUpdateSuccess(courseId, data));
|
||||||
dispatch(fetchMatchingUserGrades(courseId, searchText, cohort, track, true));
|
dispatch(fetchMatchingUserGrades(
|
||||||
|
courseId,
|
||||||
|
searchText,
|
||||||
|
cohort,
|
||||||
|
track,
|
||||||
|
defaultAssignmentFilter,
|
||||||
|
true,
|
||||||
|
{ searchText },
|
||||||
|
));
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
dispatch(gradeUpdateFailure(error));
|
dispatch(gradeUpdateFailure(courseId, error));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const submitFileUploadFormData = (courseId, formData) => (
|
||||||
|
(dispatch) => {
|
||||||
|
dispatch(startedCsvUpload());
|
||||||
|
return LmsApiService.uploadGradeCsv(courseId, formData).then(() => {
|
||||||
|
dispatch(finishedCsvUpload());
|
||||||
|
dispatch(uploadOverrideSuccess(courseId));
|
||||||
|
}).catch((err) => {
|
||||||
|
dispatch(uploadOverrideFailure(courseId, err));
|
||||||
|
if (err.status === 200 && err.data.error_messages.length) {
|
||||||
|
const { error_messages: errorMessages, saved, total } = err.data;
|
||||||
|
return dispatch(csvUploadError({ errorMessages, saved, total }));
|
||||||
|
}
|
||||||
|
return dispatch(csvUploadError({ errorMessages: ['Unknown error.'] }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const fetchBulkUpgradeHistory = courseId => (
|
||||||
|
dispatch =>
|
||||||
|
// todo add loading effect
|
||||||
|
LmsApiService.fetchGradeBulkOperationHistory(courseId).then((response) => {
|
||||||
|
dispatch(gotBulkHistory(response));
|
||||||
|
}).catch(() => dispatch(bulkHistoryError()))
|
||||||
|
);
|
||||||
|
|
||||||
|
const updateGradesIfAssignmentGradeFiltersSet = (
|
||||||
|
courseId,
|
||||||
|
cohort,
|
||||||
|
track,
|
||||||
|
assignmentType,
|
||||||
|
) => (dispatch, getState) => {
|
||||||
|
const { filters } = getState();
|
||||||
|
const hasAssignmentGradeFiltersSet = filters.assignmentGradeMax || filters.assignmentGradeMin;
|
||||||
|
if (hasAssignmentGradeFiltersSet) {
|
||||||
|
dispatch(fetchGrades(
|
||||||
|
courseId,
|
||||||
|
cohort,
|
||||||
|
track,
|
||||||
|
assignmentType,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
startedFetchingGrades,
|
startedFetchingGrades,
|
||||||
finishedFetchingGrades,
|
finishedFetchingGrades,
|
||||||
@@ -161,7 +331,13 @@ export {
|
|||||||
gradeUpdateFailure,
|
gradeUpdateFailure,
|
||||||
updateGrades,
|
updateGrades,
|
||||||
toggleGradeFormat,
|
toggleGradeFormat,
|
||||||
sortGrades,
|
filterAssignmentType,
|
||||||
filterColumns,
|
closeBanner,
|
||||||
updateBanner,
|
submitFileUploadFormData,
|
||||||
|
fetchBulkUpgradeHistory,
|
||||||
|
doneViewingAssignment,
|
||||||
|
fetchGradeOverrideHistory,
|
||||||
|
updateGradesIfAssignmentGradeFiltersSet,
|
||||||
|
downloadBulkGradesReport,
|
||||||
|
downloadInterventionReport,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ import {
|
|||||||
FINISHED_FETCHING_GRADES,
|
FINISHED_FETCHING_GRADES,
|
||||||
ERROR_FETCHING_GRADES,
|
ERROR_FETCHING_GRADES,
|
||||||
GOT_GRADES,
|
GOT_GRADES,
|
||||||
UPDATE_BANNER,
|
|
||||||
} from '../constants/actionTypes/grades';
|
} from '../constants/actionTypes/grades';
|
||||||
import { sortAlphaAsc } from './utils';
|
import { sortAlphaAsc } from './utils';
|
||||||
|
|
||||||
|
|
||||||
const mockStore = configureMockStore([thunk]);
|
const mockStore = configureMockStore([thunk]);
|
||||||
const axiosMock = new MockAdapter(apiClient);
|
const axiosMock = new MockAdapter(apiClient);
|
||||||
|
apiClient.isAccessTokenExpired = jest.fn();
|
||||||
|
apiClient.isAccessTokenExpired.mockReturnValue(false);
|
||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -27,7 +28,8 @@ describe('actions', () => {
|
|||||||
const courseId = 'course-v1:edX+DemoX+Demo_Course';
|
const courseId = 'course-v1:edX+DemoX+Demo_Course';
|
||||||
const expectedCohort = 1;
|
const expectedCohort = 1;
|
||||||
const expectedTrack = 'verified';
|
const expectedTrack = 'verified';
|
||||||
const fetchGradesURL = `${configuration.LMS_BASE_URL}/api/grades/v1/gradebook/${courseId}/?page_size=10&cohort_id=${expectedCohort}&enrollment_mode=${expectedTrack}`;
|
const expectedAssignmentType = 'Exam';
|
||||||
|
const fetchGradesURL = `${configuration.LMS_BASE_URL}/api/grades/v1/gradebook/${courseId}/?page_size=25&cohort_id=${expectedCohort}&enrollment_mode=${expectedTrack}`;
|
||||||
const responseData = {
|
const responseData = {
|
||||||
next: `${fetchGradesURL}&cursor=2344fda`,
|
next: `${fetchGradesURL}&cursor=2344fda`,
|
||||||
previous: null,
|
previous: null,
|
||||||
@@ -94,32 +96,25 @@ describe('actions', () => {
|
|||||||
grades: responseData.results.sort(sortAlphaAsc),
|
grades: responseData.results.sort(sortAlphaAsc),
|
||||||
cohort: expectedCohort,
|
cohort: expectedCohort,
|
||||||
track: expectedTrack,
|
track: expectedTrack,
|
||||||
headings: [
|
assignmentType: expectedAssignmentType,
|
||||||
{
|
|
||||||
columnSortable: true,
|
|
||||||
key: 'username',
|
|
||||||
label: 'Username',
|
|
||||||
onSort: expect.anything(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
columnSortable: true,
|
|
||||||
key: 'total',
|
|
||||||
label: 'Total',
|
|
||||||
onSort: expect.anything(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
prev: responseData.previous,
|
prev: responseData.previous,
|
||||||
next: responseData.next,
|
next: responseData.next,
|
||||||
|
courseId,
|
||||||
},
|
},
|
||||||
{ type: FINISHED_FETCHING_GRADES },
|
{ type: FINISHED_FETCHING_GRADES },
|
||||||
{ type: UPDATE_BANNER, showSuccess: false },
|
|
||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
axiosMock.onGet(fetchGradesURL)
|
axiosMock.onGet(fetchGradesURL)
|
||||||
.replyOnce(200, JSON.stringify(responseData));
|
.replyOnce(200, JSON.stringify(responseData));
|
||||||
|
|
||||||
return store.dispatch(fetchGrades(courseId, expectedCohort, expectedTrack, false)).then(() => {
|
return store.dispatch(fetchGrades(
|
||||||
|
courseId,
|
||||||
|
expectedCohort,
|
||||||
|
expectedTrack,
|
||||||
|
expectedAssignmentType,
|
||||||
|
false,
|
||||||
|
)).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -134,7 +129,49 @@ describe('actions', () => {
|
|||||||
axiosMock.onGet(fetchGradesURL)
|
axiosMock.onGet(fetchGradesURL)
|
||||||
.replyOnce(500, JSON.stringify({}));
|
.replyOnce(500, JSON.stringify({}));
|
||||||
|
|
||||||
return store.dispatch(fetchGrades(courseId, expectedCohort, expectedTrack, false)).then(() => {
|
return store.dispatch(fetchGrades(
|
||||||
|
courseId,
|
||||||
|
expectedCohort,
|
||||||
|
expectedTrack,
|
||||||
|
expectedAssignmentType,
|
||||||
|
false,
|
||||||
|
)).then(() => {
|
||||||
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('dispatches success action on empty response after fetching grades', () => {
|
||||||
|
const emptyResponseData = {
|
||||||
|
next: responseData.next,
|
||||||
|
previous: responseData.previous,
|
||||||
|
results: [],
|
||||||
|
};
|
||||||
|
const expectedActions = [
|
||||||
|
{ type: STARTED_FETCHING_GRADES },
|
||||||
|
{
|
||||||
|
type: GOT_GRADES,
|
||||||
|
grades: [],
|
||||||
|
cohort: expectedCohort,
|
||||||
|
track: expectedTrack,
|
||||||
|
assignmentType: expectedAssignmentType,
|
||||||
|
prev: responseData.previous,
|
||||||
|
next: responseData.next,
|
||||||
|
courseId,
|
||||||
|
},
|
||||||
|
{ type: FINISHED_FETCHING_GRADES },
|
||||||
|
];
|
||||||
|
const store = mockStore();
|
||||||
|
|
||||||
|
axiosMock.onGet(fetchGradesURL)
|
||||||
|
.replyOnce(200, JSON.stringify(emptyResponseData));
|
||||||
|
|
||||||
|
return store.dispatch(fetchGrades(
|
||||||
|
courseId,
|
||||||
|
expectedCohort,
|
||||||
|
expectedTrack,
|
||||||
|
expectedAssignmentType,
|
||||||
|
false,
|
||||||
|
)).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,23 +6,29 @@ import { fetchGrades } from './grades';
|
|||||||
import { fetchTracks } from './tracks';
|
import { fetchTracks } from './tracks';
|
||||||
import { fetchCohorts } from './cohorts';
|
import { fetchCohorts } from './cohorts';
|
||||||
import { fetchAssignmentTypes } from './assignmentTypes';
|
import { fetchAssignmentTypes } from './assignmentTypes';
|
||||||
|
import { getFilters } from '../selectors/filters';
|
||||||
import LmsApiService from '../services/LmsApiService';
|
import LmsApiService from '../services/LmsApiService';
|
||||||
|
|
||||||
const allowedRoles = ['staff', 'instructor', 'support'];
|
const allowedRoles = ['staff', 'instructor', 'support'];
|
||||||
|
|
||||||
const gotRoles = canUserViewGradebook => ({ type: GOT_ROLES, canUserViewGradebook });
|
const gotRoles = (canUserViewGradebook, courseId) => ({
|
||||||
|
type: GOT_ROLES,
|
||||||
|
canUserViewGradebook,
|
||||||
|
courseId,
|
||||||
|
});
|
||||||
const errorFetchingRoles = () => ({ type: ERROR_FETCHING_ROLES });
|
const errorFetchingRoles = () => ({ type: ERROR_FETCHING_ROLES });
|
||||||
|
|
||||||
const getRoles = (courseId, urlQuery) => (
|
const getRoles = courseId => (
|
||||||
dispatch => LmsApiService.fetchUserRoles(courseId)
|
(dispatch, getState) => LmsApiService.fetchUserRoles(courseId)
|
||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
const canUserViewGradebook = response.is_staff
|
const canUserViewGradebook = response.is_staff
|
||||||
|| (response.roles.some(role => (role.course_id === courseId)
|
|| (response.roles.some(role => (role.course_id === courseId)
|
||||||
&& allowedRoles.includes(role.role)));
|
&& allowedRoles.includes(role.role)));
|
||||||
dispatch(gotRoles(canUserViewGradebook));
|
dispatch(gotRoles(canUserViewGradebook, courseId));
|
||||||
|
const { cohort, track, assignmentType } = getFilters(getState());
|
||||||
if (canUserViewGradebook) {
|
if (canUserViewGradebook) {
|
||||||
dispatch(fetchGrades(courseId, urlQuery.cohort, urlQuery.track));
|
dispatch(fetchGrades(courseId, cohort, track, assignmentType));
|
||||||
dispatch(fetchTracks(courseId));
|
dispatch(fetchTracks(courseId));
|
||||||
dispatch(fetchCohorts(courseId));
|
dispatch(fetchCohorts(courseId));
|
||||||
dispatch(fetchAssignmentTypes(courseId));
|
dispatch(fetchAssignmentTypes(courseId));
|
||||||
|
|||||||
@@ -17,28 +17,30 @@ import { STARTED_FETCHING_ASSIGNMENT_TYPES } from '../constants/actionTypes/assi
|
|||||||
|
|
||||||
const mockStore = configureMockStore([thunk]);
|
const mockStore = configureMockStore([thunk]);
|
||||||
const axiosMock = new MockAdapter(apiClient);
|
const axiosMock = new MockAdapter(apiClient);
|
||||||
|
apiClient.isAccessTokenExpired = jest.fn();
|
||||||
|
apiClient.isAccessTokenExpired.mockReturnValue(false);
|
||||||
|
|
||||||
const course1Id = 'course-v1:edX+DemoX+Demo_Course';
|
const course1Id = 'course-v1:edX+DemoX+Demo_Course';
|
||||||
const course2Id = 'course-v1:edX+DemoX+Demo_Course_2';
|
const course2Id = 'course-v1:edX+DemoX+Demo_Course_2';
|
||||||
const rolesUrl = `${configuration.LMS_BASE_URL}/api/enrollment/v1/roles/?course_id=${encodeURIComponent(course1Id)}`;
|
const rolesUrl = `${configuration.LMS_BASE_URL}/api/enrollment/v1/roles/?course_id=${encodeURIComponent(course1Id)}`;
|
||||||
|
|
||||||
function makeRoleListObj(roles, isGlobalStaff){
|
function makeRoleListObj(roles, isGlobalStaff) {
|
||||||
return {
|
return {
|
||||||
roles: roles,
|
roles,
|
||||||
is_staff: isGlobalStaff,
|
is_staff: isGlobalStaff,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
function makeRoleObj(courseId, role) {
|
function makeRoleObj(courseId, role) {
|
||||||
return {
|
return {
|
||||||
course_id: courseId,
|
course_id: courseId,
|
||||||
role: role,
|
role,
|
||||||
}
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
const course1StaffRole = makeRoleObj(course1Id, "staff");
|
const course1StaffRole = makeRoleObj(course1Id, 'staff');
|
||||||
const course1DummyRole = makeRoleObj(course1Id, "dummy");
|
const course1DummyRole = makeRoleObj(course1Id, 'dummy');
|
||||||
const course2StaffRole = makeRoleObj(course2Id, "staff");
|
const course2StaffRole = makeRoleObj(course2Id, 'staff');
|
||||||
const course2DummyRole = makeRoleObj(course2Id, "dummy");
|
const course2DummyRole = makeRoleObj(course2Id, 'dummy');
|
||||||
const urlParams = { cohort: null, track: null };
|
const urlParams = { cohort: null, track: null };
|
||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
@@ -49,7 +51,7 @@ describe('actions', () => {
|
|||||||
describe('getRoles', () => {
|
describe('getRoles', () => {
|
||||||
it('dispatches got_roles action and subsequent actions after fetching role that allows gradebook', () => {
|
it('dispatches got_roles action and subsequent actions after fetching role that allows gradebook', () => {
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{ type: GOT_ROLES, canUserViewGradebook: true },
|
{ type: GOT_ROLES, canUserViewGradebook: true, courseId: course1Id },
|
||||||
{ type: STARTED_FETCHING_GRADES },
|
{ type: STARTED_FETCHING_GRADES },
|
||||||
{ type: STARTED_FETCHING_TRACKS },
|
{ type: STARTED_FETCHING_TRACKS },
|
||||||
{ type: STARTED_FETCHING_COHORTS },
|
{ type: STARTED_FETCHING_COHORTS },
|
||||||
@@ -57,7 +59,10 @@ describe('actions', () => {
|
|||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
axiosMock.onGet(rolesUrl)
|
axiosMock.onGet(rolesUrl)
|
||||||
.replyOnce(200, JSON.stringify(makeRoleListObj([course1StaffRole, course2DummyRole], false)));
|
.replyOnce(
|
||||||
|
200,
|
||||||
|
JSON.stringify(makeRoleListObj([course1StaffRole, course2DummyRole], false)),
|
||||||
|
);
|
||||||
|
|
||||||
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
@@ -66,7 +71,7 @@ describe('actions', () => {
|
|||||||
|
|
||||||
it('dispatches got_roles action and other actions after fetching irrelevent roles but user is global staff', () => {
|
it('dispatches got_roles action and other actions after fetching irrelevent roles but user is global staff', () => {
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{ type: GOT_ROLES, canUserViewGradebook: true },
|
{ type: GOT_ROLES, canUserViewGradebook: true, courseId: course1Id },
|
||||||
{ type: STARTED_FETCHING_GRADES },
|
{ type: STARTED_FETCHING_GRADES },
|
||||||
{ type: STARTED_FETCHING_TRACKS },
|
{ type: STARTED_FETCHING_TRACKS },
|
||||||
{ type: STARTED_FETCHING_COHORTS },
|
{ type: STARTED_FETCHING_COHORTS },
|
||||||
@@ -75,7 +80,10 @@ describe('actions', () => {
|
|||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
axiosMock.onGet(rolesUrl)
|
axiosMock.onGet(rolesUrl)
|
||||||
.replyOnce(200, JSON.stringify(makeRoleListObj([course1DummyRole, course2DummyRole], true)));
|
.replyOnce(
|
||||||
|
200,
|
||||||
|
JSON.stringify(makeRoleListObj([course1DummyRole, course2DummyRole], true)),
|
||||||
|
);
|
||||||
|
|
||||||
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
@@ -84,12 +92,17 @@ describe('actions', () => {
|
|||||||
|
|
||||||
it('dispatches got_roles action and no other actions after fetching role that disallows gradebook', () => {
|
it('dispatches got_roles action and no other actions after fetching role that disallows gradebook', () => {
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{ type: GOT_ROLES, canUserViewGradebook: false },
|
{
|
||||||
|
type: GOT_ROLES, canUserViewGradebook: false, courseId: course1Id,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
axiosMock.onGet(rolesUrl)
|
axiosMock.onGet(rolesUrl)
|
||||||
.replyOnce(200, JSON.stringify(makeRoleListObj([course1DummyRole, course2StaffRole], false)));
|
.replyOnce(
|
||||||
|
200,
|
||||||
|
JSON.stringify(makeRoleListObj([course1DummyRole, course2StaffRole], false)),
|
||||||
|
);
|
||||||
|
|
||||||
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
@@ -98,12 +111,15 @@ describe('actions', () => {
|
|||||||
|
|
||||||
it('dispatches got_roles action and no other actions after fetching empty roles', () => {
|
it('dispatches got_roles action and no other actions after fetching empty roles', () => {
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{ type: GOT_ROLES, canUserViewGradebook: false },
|
{ type: GOT_ROLES, canUserViewGradebook: false, courseId: course1Id },
|
||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
axiosMock.onGet(rolesUrl)
|
axiosMock.onGet(rolesUrl)
|
||||||
.replyOnce(200, JSON.stringify(makeRoleListObj([], false)));
|
.replyOnce(
|
||||||
|
200,
|
||||||
|
JSON.stringify(makeRoleListObj([], false)),
|
||||||
|
);
|
||||||
|
|
||||||
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
@@ -112,7 +128,7 @@ describe('actions', () => {
|
|||||||
|
|
||||||
it('dispatches got_roles action and other actions after fetching empty roles but user is global staff', () => {
|
it('dispatches got_roles action and other actions after fetching empty roles but user is global staff', () => {
|
||||||
const expectedActions = [
|
const expectedActions = [
|
||||||
{ type: GOT_ROLES, canUserViewGradebook: true },
|
{ type: GOT_ROLES, canUserViewGradebook: true, courseId: course1Id },
|
||||||
{ type: STARTED_FETCHING_GRADES },
|
{ type: STARTED_FETCHING_GRADES },
|
||||||
{ type: STARTED_FETCHING_TRACKS },
|
{ type: STARTED_FETCHING_TRACKS },
|
||||||
{ type: STARTED_FETCHING_COHORTS },
|
{ type: STARTED_FETCHING_COHORTS },
|
||||||
@@ -121,7 +137,10 @@ describe('actions', () => {
|
|||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
axiosMock.onGet(rolesUrl)
|
axiosMock.onGet(rolesUrl)
|
||||||
.replyOnce(200, JSON.stringify(makeRoleListObj([], true)));
|
.replyOnce(
|
||||||
|
200,
|
||||||
|
JSON.stringify(makeRoleListObj([], true)),
|
||||||
|
);
|
||||||
|
|
||||||
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
return store.dispatch(getRoles(course1Id, urlParams)).then(() => {
|
||||||
expect(store.getActions()).toEqual(expectedActions);
|
expect(store.getActions()).toEqual(expectedActions);
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import {
|
|||||||
GOT_TRACKS,
|
GOT_TRACKS,
|
||||||
ERROR_FETCHING_TRACKS,
|
ERROR_FETCHING_TRACKS,
|
||||||
} from '../constants/actionTypes/tracks';
|
} from '../constants/actionTypes/tracks';
|
||||||
|
import { hasMastersTrack } from '../selectors/tracks';
|
||||||
|
import { fetchBulkUpgradeHistory } from './grades';
|
||||||
import LmsApiService from '../services/LmsApiService';
|
import LmsApiService from '../services/LmsApiService';
|
||||||
|
|
||||||
const startedFetchingTracks = () => ({ type: STARTED_FETCHING_TRACKS });
|
const startedFetchingTracks = () => ({ type: STARTED_FETCHING_TRACKS });
|
||||||
@@ -16,6 +18,9 @@ const fetchTracks = courseId => (
|
|||||||
.then(response => response.data)
|
.then(response => response.data)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
dispatch(gotTracks(data.course_modes));
|
dispatch(gotTracks(data.course_modes));
|
||||||
|
if (hasMastersTrack(data.course_modes)) {
|
||||||
|
dispatch(fetchBulkUpgradeHistory(courseId));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
dispatch(errorFetchingTracks());
|
dispatch(errorFetchingTracks());
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import {
|
|||||||
|
|
||||||
const mockStore = configureMockStore([thunk]);
|
const mockStore = configureMockStore([thunk]);
|
||||||
const axiosMock = new MockAdapter(apiClient);
|
const axiosMock = new MockAdapter(apiClient);
|
||||||
|
apiClient.isAccessTokenExpired = jest.fn();
|
||||||
|
apiClient.isAccessTokenExpired.mockReturnValue(false);
|
||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -21,6 +23,7 @@ describe('actions', () => {
|
|||||||
|
|
||||||
describe('fetchTracks', () => {
|
describe('fetchTracks', () => {
|
||||||
const courseId = 'course-v1:edX+DemoX+Demo_Course';
|
const courseId = 'course-v1:edX+DemoX+Demo_Course';
|
||||||
|
const trackUrl = `${configuration.LMS_BASE_URL}/api/enrollment/v1/course/${courseId}?include_expired=1`;
|
||||||
|
|
||||||
it('dispatches success action after fetching tracks', () => {
|
it('dispatches success action after fetching tracks', () => {
|
||||||
const responseData = {
|
const responseData = {
|
||||||
@@ -54,7 +57,7 @@ describe('actions', () => {
|
|||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
axiosMock.onGet(`${configuration.LMS_BASE_URL}/api/enrollment/v1/course/${courseId}`)
|
axiosMock.onGet(trackUrl)
|
||||||
.replyOnce(200, JSON.stringify(responseData));
|
.replyOnce(200, JSON.stringify(responseData));
|
||||||
|
|
||||||
return store.dispatch(fetchTracks(courseId)).then(() => {
|
return store.dispatch(fetchTracks(courseId)).then(() => {
|
||||||
@@ -69,7 +72,7 @@ describe('actions', () => {
|
|||||||
];
|
];
|
||||||
const store = mockStore();
|
const store = mockStore();
|
||||||
|
|
||||||
axiosMock.onGet(`${configuration.LMS_BASE_URL}/api/enrollment/v1/course/${courseId}`)
|
axiosMock.onGet(trackUrl)
|
||||||
.replyOnce(500, JSON.stringify({}));
|
.replyOnce(500, JSON.stringify({}));
|
||||||
|
|
||||||
return store.dispatch(fetchTracks(courseId)).then(() => {
|
return store.dispatch(fetchTracks(courseId)).then(() => {
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
import { sortGrades } from './grades';
|
const formatDateForDisplay = (inputDate) => {
|
||||||
|
const options = {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
timeZone: 'UTC',
|
||||||
|
};
|
||||||
|
const timeOptions = {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
timeZone: 'UTC',
|
||||||
|
timeZoneName: 'short',
|
||||||
|
};
|
||||||
|
return `${inputDate.toLocaleDateString('en-US', options)} at ${inputDate.toLocaleTimeString('en-US', timeOptions)}`;
|
||||||
|
};
|
||||||
|
|
||||||
const sortAlphaAsc = (gradeRowA, gradeRowB) => {
|
const sortAlphaAsc = (gradeRowA, gradeRowB) => {
|
||||||
const a = gradeRowA.username.toUpperCase();
|
const a = gradeRowA.username.toUpperCase();
|
||||||
@@ -12,114 +26,5 @@ const sortAlphaAsc = (gradeRowA, gradeRowB) => {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortAlphaDesc = (gradeRowA, gradeRowB) => {
|
export { sortAlphaAsc, formatDateForDisplay };
|
||||||
const a = gradeRowA.username.toUpperCase();
|
|
||||||
const b = gradeRowB.username.toUpperCase();
|
|
||||||
if (a < b) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (a > b) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
const sortNumerically = (colKey, direction) => {
|
|
||||||
function getPercents(gradeRowA, gradeRowB) {
|
|
||||||
if (colKey !== 'total') {
|
|
||||||
return {
|
|
||||||
a: gradeRowA.section_breakdown.find(x => x.label === colKey).percent,
|
|
||||||
b: gradeRowB.section_breakdown.find(x => x.label === colKey).percent,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
a: gradeRowA.percent,
|
|
||||||
b: gradeRowB.percent,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortNumAsc(gradeRowA, gradeRowB) {
|
|
||||||
const { a, b } = getPercents(gradeRowA, gradeRowB);
|
|
||||||
return a - b;
|
|
||||||
}
|
|
||||||
|
|
||||||
function sortNumDesc(gradeRowA, gradeRowB) {
|
|
||||||
const { a, b } = getPercents(gradeRowA, gradeRowB);
|
|
||||||
return b - a;
|
|
||||||
}
|
|
||||||
|
|
||||||
return direction === 'desc' ? sortNumDesc : sortNumAsc;
|
|
||||||
};
|
|
||||||
|
|
||||||
function gradeSortMap(columnName, direction) {
|
|
||||||
if (columnName === 'username' && direction === 'desc') {
|
|
||||||
return sortAlphaDesc;
|
|
||||||
} else if (columnName === 'username') {
|
|
||||||
return sortAlphaAsc;
|
|
||||||
}
|
|
||||||
return sortNumerically(columnName, direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
const headingMapper = (filterKey) => {
|
|
||||||
function all(dispatch, entry) {
|
|
||||||
if (entry) {
|
|
||||||
const results = [{
|
|
||||||
label: 'Username',
|
|
||||||
key: 'username',
|
|
||||||
columnSortable: true,
|
|
||||||
onSort: (direction) => { dispatch(sortGrades('username', direction)); },
|
|
||||||
}];
|
|
||||||
|
|
||||||
const assignmentHeadings = entry.section_breakdown
|
|
||||||
.filter(section => section.is_graded && section.label)
|
|
||||||
.map(s => ({
|
|
||||||
label: s.label,
|
|
||||||
key: s.label,
|
|
||||||
columnSortable: true,
|
|
||||||
onSort: direction => dispatch(sortGrades(s.label, direction)),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const totals = [{
|
|
||||||
label: 'Total',
|
|
||||||
key: 'total',
|
|
||||||
columnSortable: true,
|
|
||||||
onSort: direction => dispatch(sortGrades('total', direction)),
|
|
||||||
}];
|
|
||||||
|
|
||||||
return results.concat(assignmentHeadings).concat(totals);
|
|
||||||
}
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function some(dispatch, entry) {
|
|
||||||
const results = [{
|
|
||||||
label: 'Username',
|
|
||||||
key: 'username',
|
|
||||||
columnSortable: true,
|
|
||||||
onSort: (direction) => { dispatch(sortGrades('username', direction)); },
|
|
||||||
}];
|
|
||||||
|
|
||||||
const assignmentHeadings = entry.section_breakdown
|
|
||||||
.filter(section => section.is_graded && section.label && section.category === filterKey)
|
|
||||||
.map(s => ({
|
|
||||||
label: s.label,
|
|
||||||
key: s.label,
|
|
||||||
columnSortable: false,
|
|
||||||
onSort: (direction) => { this.sortNumerically(s.label, direction); },
|
|
||||||
}));
|
|
||||||
|
|
||||||
const totals = [{
|
|
||||||
label: 'Total',
|
|
||||||
key: 'total',
|
|
||||||
columnSortable: true,
|
|
||||||
onSort: direction => dispatch(sortGrades('total', direction)),
|
|
||||||
}];
|
|
||||||
|
|
||||||
return results.concat(assignmentHeadings).concat(totals);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filterKey === 'All' ? all : some;
|
|
||||||
};
|
|
||||||
|
|
||||||
export { headingMapper, gradeSortMap, sortAlphaAsc };
|
|
||||||
|
|
||||||
|
|||||||
3
src/data/constants/actionTypes/config.js
Normal file
3
src/data/constants/actionTypes/config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
const GOT_BULK_MANAGEMENT_CONFIG = 'GOT_BULK_MANAGEMENT_CONFIG';
|
||||||
|
|
||||||
|
export default GOT_BULK_MANAGEMENT_CONFIG;
|
||||||
9
src/data/constants/actionTypes/filters.js
Normal file
9
src/data/constants/actionTypes/filters.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const INITIALIZE_FILTERS = 'INITIALIZE_FILTERS';
|
||||||
|
const RESET_FILTERS = 'RESET_FILTERS';
|
||||||
|
const UPDATE_ASSIGNMENT_FILTER = 'UPDATE_ASSIGNMENT_FILTER';
|
||||||
|
const UPDATE_ASSIGNMENT_LIMITS = 'UPDATE_ASSIGNMENT_LIMITS';
|
||||||
|
const UPDATE_COURSE_GRADE_LIMITS = 'UPDATE_COURSE_GRADE_LIMITS';
|
||||||
|
export {
|
||||||
|
INITIALIZE_FILTERS, RESET_FILTERS, UPDATE_ASSIGNMENT_FILTER,
|
||||||
|
UPDATE_ASSIGNMENT_LIMITS, UPDATE_COURSE_GRADE_LIMITS,
|
||||||
|
};
|
||||||
@@ -2,15 +2,32 @@ const STARTED_FETCHING_GRADES = 'STARTED_FETCHING_GRADES';
|
|||||||
const FINISHED_FETCHING_GRADES = 'FINISHED_FETCHING_GRADES';
|
const FINISHED_FETCHING_GRADES = 'FINISHED_FETCHING_GRADES';
|
||||||
const ERROR_FETCHING_GRADES = 'ERROR_FETCHING_GRADES';
|
const ERROR_FETCHING_GRADES = 'ERROR_FETCHING_GRADES';
|
||||||
const GOT_GRADES = 'GOT_GRADES';
|
const GOT_GRADES = 'GOT_GRADES';
|
||||||
|
const DONE_VIEWING_ASSIGNMENT = 'DONE_VIEWING_ASSIGNMENT';
|
||||||
|
const GOT_GRADE_OVERRIDE_HISTORY = 'GOT_GRADE_OVERRIDE_HISTORY';
|
||||||
|
const ERROR_FETCHING_GRADE_OVERRIDE_HISTORY = 'ERROR_FETCHING_GRADE_OVERRIDE_HISTORY';
|
||||||
|
|
||||||
|
const FILTER_SELECTED = 'FILTER_SELECTED';
|
||||||
|
const GRADE_OVERRIDE = 'GRADE_OVERRIDE';
|
||||||
|
const REPORT_DOWNLOADED = 'REPORT_DOWNLOADED';
|
||||||
|
const UPLOAD_OVERRIDE = 'UPLOAD_OVERRIDE';
|
||||||
|
const UPLOAD_OVERRIDE_ERROR = 'UPLOAD_OVERRIDE_ERROR';
|
||||||
|
|
||||||
const GRADE_UPDATE_REQUEST = 'GRADE_UPDATE_REQUEST';
|
const GRADE_UPDATE_REQUEST = 'GRADE_UPDATE_REQUEST';
|
||||||
const GRADE_UPDATE_SUCCESS = 'GRADE_UPDATE_SUCCESS';
|
const GRADE_UPDATE_SUCCESS = 'GRADE_UPDATE_SUCCESS';
|
||||||
const GRADE_UPDATE_FAILURE = 'GRADE_UPDATE_FAILURE';
|
const GRADE_UPDATE_FAILURE = 'GRADE_UPDATE_FAILURE';
|
||||||
|
|
||||||
const TOGGLE_GRADE_FORMAT = 'TOGGLE_GRADE_FORMAT';
|
const TOGGLE_GRADE_FORMAT = 'TOGGLE_GRADE_FORMAT';
|
||||||
const SORT_GRADES = 'SORT_GRADES';
|
const FILTER_BY_ASSIGNMENT_TYPE = 'FILTER_BY_ASSIGNMENT_TYPE';
|
||||||
const FILTER_COLUMNS = 'FILTER_COLUMNS';
|
const CLOSE_BANNER = 'CLOSE_BANNER';
|
||||||
const UPDATE_BANNER = 'UPDATE_BANNER';
|
const OPEN_BANNER = 'OPEN_BANNER';
|
||||||
|
|
||||||
|
const START_UPLOAD = 'START_UPLOAD';
|
||||||
|
const UPLOAD_COMPLETE = 'UPLOAD_COMPLETE';
|
||||||
|
const UPLOAD_ERR = 'UPLOAD_ERR';
|
||||||
|
const GOT_BULK_HISTORY = 'GOT_BULK_HISTORY';
|
||||||
|
const BULK_HISTORY_ERR = 'BULK_HISTORY_ERR';
|
||||||
|
const BULK_GRADE_REPORT_DOWNLOADED = 'BULK_GRADE_REPORT_DOWNLOADED';
|
||||||
|
const INTERVENTION_REPORT_DOWNLOADED = 'INTERVENTION_REPORT_DOWNLOADED';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
STARTED_FETCHING_GRADES,
|
STARTED_FETCHING_GRADES,
|
||||||
@@ -21,7 +38,22 @@ export {
|
|||||||
GRADE_UPDATE_SUCCESS,
|
GRADE_UPDATE_SUCCESS,
|
||||||
GRADE_UPDATE_FAILURE,
|
GRADE_UPDATE_FAILURE,
|
||||||
TOGGLE_GRADE_FORMAT,
|
TOGGLE_GRADE_FORMAT,
|
||||||
SORT_GRADES,
|
FILTER_BY_ASSIGNMENT_TYPE,
|
||||||
FILTER_COLUMNS,
|
OPEN_BANNER,
|
||||||
UPDATE_BANNER,
|
CLOSE_BANNER,
|
||||||
|
START_UPLOAD,
|
||||||
|
UPLOAD_COMPLETE,
|
||||||
|
UPLOAD_ERR,
|
||||||
|
GOT_BULK_HISTORY,
|
||||||
|
BULK_HISTORY_ERR,
|
||||||
|
DONE_VIEWING_ASSIGNMENT,
|
||||||
|
GOT_GRADE_OVERRIDE_HISTORY,
|
||||||
|
ERROR_FETCHING_GRADE_OVERRIDE_HISTORY,
|
||||||
|
FILTER_SELECTED,
|
||||||
|
GRADE_OVERRIDE,
|
||||||
|
REPORT_DOWNLOADED,
|
||||||
|
UPLOAD_OVERRIDE,
|
||||||
|
UPLOAD_OVERRIDE_ERROR,
|
||||||
|
BULK_GRADE_REPORT_DOWNLOADED,
|
||||||
|
INTERVENTION_REPORT_DOWNLOADED,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const GOT_ROLES = 'GOT_ROLES';
|
const GOT_ROLES = 'GOT_ROLES';
|
||||||
const ERROR_FETCHING_ROLES = 'ERROR_FETCHING_ROLES'
|
const ERROR_FETCHING_ROLES = 'ERROR_FETCHING_ROLES';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
GOT_ROLES,
|
GOT_ROLES,
|
||||||
|
|||||||
12
src/data/constants/filters.js
Normal file
12
src/data/constants/filters.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
const initialFilters = {
|
||||||
|
assignment: '',
|
||||||
|
assignmentType: '',
|
||||||
|
track: '',
|
||||||
|
cohort: '',
|
||||||
|
assignmentGradeMin: '0',
|
||||||
|
assignmentGradeMax: '100',
|
||||||
|
courseGradeMin: '0',
|
||||||
|
courseGradeMax: '100',
|
||||||
|
};
|
||||||
|
|
||||||
|
export default initialFilters;
|
||||||
15
src/data/reducers/config.js
Normal file
15
src/data/reducers/config.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import GOT_BULK_MANAGEMENT_CONFIG from '../constants/actionTypes/config';
|
||||||
|
|
||||||
|
const reducer = (state = {}, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case GOT_BULK_MANAGEMENT_CONFIG:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
bulkManagementAvailable: action.data,
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reducer;
|
||||||
76
src/data/reducers/filters.js
Normal file
76
src/data/reducers/filters.js
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import { GOT_GRADES, FILTER_BY_ASSIGNMENT_TYPE } from '../constants/actionTypes/grades';
|
||||||
|
|
||||||
|
import { INITIALIZE_FILTERS, UPDATE_ASSIGNMENT_FILTER, UPDATE_ASSIGNMENT_LIMITS, UPDATE_COURSE_GRADE_LIMITS, RESET_FILTERS } from '../constants/actionTypes/filters';
|
||||||
|
|
||||||
|
import initialFilters from '../constants/filters';
|
||||||
|
|
||||||
|
import { getAssignmentsFromResultsSubstate, chooseRelevantAssignmentData } from '../selectors/filters';
|
||||||
|
|
||||||
|
const initialState = {};
|
||||||
|
|
||||||
|
const reducer = (state = initialState, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case FILTER_BY_ASSIGNMENT_TYPE:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
assignmentType: action.filterType,
|
||||||
|
assignment: (
|
||||||
|
action.filterType !== '' &&
|
||||||
|
(state.assignment || {}).type !== action.filterType)
|
||||||
|
? '' : state.assignment,
|
||||||
|
};
|
||||||
|
case INITIALIZE_FILTERS:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
...action.data,
|
||||||
|
};
|
||||||
|
case GOT_GRADES: {
|
||||||
|
const { assignment } = state;
|
||||||
|
const { id, type } = assignment || {};
|
||||||
|
if (!type) {
|
||||||
|
const relevantAssignment = getAssignmentsFromResultsSubstate(action.grades)
|
||||||
|
.map(chooseRelevantAssignmentData)
|
||||||
|
.find(assig => assig.id === id);
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
track: action.track,
|
||||||
|
cohort: action.cohort,
|
||||||
|
assignment: relevantAssignment,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
track: action.track,
|
||||||
|
cohort: action.cohort,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case RESET_FILTERS: {
|
||||||
|
const result = { ...state };
|
||||||
|
action.filterNames.forEach((filterName) => {
|
||||||
|
result[filterName] = initialFilters[filterName];
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
case UPDATE_ASSIGNMENT_FILTER:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
assignment: action.data,
|
||||||
|
};
|
||||||
|
case UPDATE_ASSIGNMENT_LIMITS:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
assignmentGradeMin: action.data.minGrade,
|
||||||
|
assignmentGradeMax: action.data.maxGrade,
|
||||||
|
};
|
||||||
|
case UPDATE_COURSE_GRADE_LIMITS:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
courseGradeMin: action.data.courseGradeMin,
|
||||||
|
courseGradeMax: action.data.courseGradeMax,
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reducer;
|
||||||
@@ -3,13 +3,29 @@ import {
|
|||||||
ERROR_FETCHING_GRADES,
|
ERROR_FETCHING_GRADES,
|
||||||
GOT_GRADES,
|
GOT_GRADES,
|
||||||
TOGGLE_GRADE_FORMAT,
|
TOGGLE_GRADE_FORMAT,
|
||||||
FILTER_COLUMNS,
|
FILTER_BY_ASSIGNMENT_TYPE,
|
||||||
UPDATE_BANNER,
|
OPEN_BANNER,
|
||||||
SORT_GRADES,
|
CLOSE_BANNER,
|
||||||
|
START_UPLOAD,
|
||||||
|
UPLOAD_COMPLETE,
|
||||||
|
UPLOAD_ERR,
|
||||||
|
GOT_BULK_HISTORY,
|
||||||
|
DONE_VIEWING_ASSIGNMENT,
|
||||||
|
GOT_GRADE_OVERRIDE_HISTORY,
|
||||||
|
ERROR_FETCHING_GRADE_OVERRIDE_HISTORY,
|
||||||
} from '../constants/actionTypes/grades';
|
} from '../constants/actionTypes/grades';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
results: [],
|
results: [],
|
||||||
|
gradeOverrideHistoryResults: [],
|
||||||
|
gradeOverrideCurrentEarnedAllOverride: null,
|
||||||
|
gradeOverrideCurrentPossibleAllOverride: null,
|
||||||
|
gradeOverrideCurrentEarnedGradedOverride: null,
|
||||||
|
gradeOverrideCurrentPossibleGradedOverride: null,
|
||||||
|
gradeOriginalEarnedAll: null,
|
||||||
|
gradeOriginalPossibleAll: null,
|
||||||
|
gradeOriginalEarnedGraded: null,
|
||||||
|
gradeOriginalPossibleGraded: null,
|
||||||
headings: [],
|
headings: [],
|
||||||
startedFetching: false,
|
startedFetching: false,
|
||||||
finishedFetching: false,
|
finishedFetching: false,
|
||||||
@@ -19,6 +35,9 @@ const initialState = {
|
|||||||
prevPage: null,
|
prevPage: null,
|
||||||
nextPage: null,
|
nextPage: null,
|
||||||
showSpinner: true,
|
showSpinner: true,
|
||||||
|
bulkManagement: {},
|
||||||
|
totalUsersCount: 0,
|
||||||
|
filteredUsersCount: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const grades = (state = initialState, action) => {
|
const grades = (state = initialState, action) => {
|
||||||
@@ -30,12 +49,50 @@ const grades = (state = initialState, action) => {
|
|||||||
headings: action.headings,
|
headings: action.headings,
|
||||||
finishedFetching: true,
|
finishedFetching: true,
|
||||||
errorFetching: false,
|
errorFetching: false,
|
||||||
selectedTrack: action.track,
|
|
||||||
selectedCohort: action.cohort,
|
|
||||||
prevPage: action.prev,
|
prevPage: action.prev,
|
||||||
nextPage: action.next,
|
nextPage: action.next,
|
||||||
showSpinner: false,
|
showSpinner: false,
|
||||||
|
courseId: action.courseId,
|
||||||
|
totalUsersCount: action.totalUsersCount,
|
||||||
|
filteredUsersCount: action.filteredUsersCount,
|
||||||
};
|
};
|
||||||
|
case DONE_VIEWING_ASSIGNMENT: {
|
||||||
|
const {
|
||||||
|
gradeOverrideHistoryResults,
|
||||||
|
gradeOverrideCurrentEarnedAllOverride,
|
||||||
|
gradeOverrideCurrentPossibleAllOverride,
|
||||||
|
gradeOverrideCurrentEarnedGradedOverride,
|
||||||
|
gradeOverrideCurrentPossibleGradedOverride,
|
||||||
|
gradeOriginalEarnedAll,
|
||||||
|
gradeOriginalPossibleAll,
|
||||||
|
gradeOriginalEarnedGraded,
|
||||||
|
gradeOriginalPossibleGraded,
|
||||||
|
...rest
|
||||||
|
} = state;
|
||||||
|
return rest;
|
||||||
|
}
|
||||||
|
case GOT_GRADE_OVERRIDE_HISTORY:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
gradeOverrideHistoryResults: action.overrideHistory,
|
||||||
|
gradeOverrideCurrentEarnedAllOverride: action.currentEarnedAllOverride,
|
||||||
|
gradeOverrideCurrentPossibleAllOverride: action.currentPossibleAllOverride,
|
||||||
|
gradeOverrideCurrentEarnedGradedOverride: action.currentEarnedGradedOverride,
|
||||||
|
gradeOverrideCurrentPossibleGradedOverride: action.currentPossibleGradedOverride,
|
||||||
|
gradeOriginalEarnedAll: action.originalGradeEarnedAll,
|
||||||
|
gradeOriginalPossibleAll: action.originalGradePossibleAll,
|
||||||
|
gradeOriginalEarnedGraded: action.originalGradeEarnedGraded,
|
||||||
|
gradeOriginalPossibleGraded: action.originalGradePossibleGraded,
|
||||||
|
errorFetchingOverrideHistory: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
case ERROR_FETCHING_GRADE_OVERRIDE_HISTORY:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
finishedFetchingOverrideHistory: true,
|
||||||
|
errorFetchingOverrideHistory: true,
|
||||||
|
};
|
||||||
|
|
||||||
case STARTED_FETCHING_GRADES:
|
case STARTED_FETCHING_GRADES:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
@@ -54,24 +111,57 @@ const grades = (state = initialState, action) => {
|
|||||||
...state,
|
...state,
|
||||||
gradeFormat: action.formatType,
|
gradeFormat: action.formatType,
|
||||||
};
|
};
|
||||||
case FILTER_COLUMNS:
|
case FILTER_BY_ASSIGNMENT_TYPE:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
selectedAssignmentType: action.filterType,
|
||||||
headings: action.headings,
|
headings: action.headings,
|
||||||
};
|
};
|
||||||
case UPDATE_BANNER:
|
case OPEN_BANNER:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
showSuccess: action.showSuccess,
|
showSuccess: true,
|
||||||
};
|
};
|
||||||
case SORT_GRADES:
|
case CLOSE_BANNER:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
results: action.results,
|
showSuccess: false,
|
||||||
|
};
|
||||||
|
case START_UPLOAD: {
|
||||||
|
const { errorMessages, uploadSuccess, ...rest } = state.bulkManagement;
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
showSpinner: true,
|
||||||
|
bulkManagement: rest,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case UPLOAD_COMPLETE:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
showSpinner: false,
|
||||||
|
bulkManagement: { uploadSuccess: true, ...state.bulkManagement },
|
||||||
|
};
|
||||||
|
case UPLOAD_ERR:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
showSpinner: false,
|
||||||
|
bulkManagement: {
|
||||||
|
...state.bulkManagement,
|
||||||
|
...action.data,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
case GOT_BULK_HISTORY:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
bulkManagement: {
|
||||||
|
...state.bulkManagement,
|
||||||
|
history: action.data,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export { initialState as initialGradesState };
|
||||||
export default grades;
|
export default grades;
|
||||||
|
|||||||
@@ -1,27 +1,13 @@
|
|||||||
import grades from './grades';
|
import grades, { initialGradesState as initialState } from './grades';
|
||||||
import {
|
import {
|
||||||
STARTED_FETCHING_GRADES,
|
STARTED_FETCHING_GRADES,
|
||||||
ERROR_FETCHING_GRADES,
|
ERROR_FETCHING_GRADES,
|
||||||
GOT_GRADES,
|
GOT_GRADES,
|
||||||
TOGGLE_GRADE_FORMAT,
|
TOGGLE_GRADE_FORMAT,
|
||||||
FILTER_COLUMNS,
|
FILTER_BY_ASSIGNMENT_TYPE,
|
||||||
UPDATE_BANNER,
|
OPEN_BANNER,
|
||||||
SORT_GRADES,
|
|
||||||
} from '../constants/actionTypes/grades';
|
} from '../constants/actionTypes/grades';
|
||||||
|
|
||||||
const initialState = {
|
|
||||||
results: [],
|
|
||||||
headings: [],
|
|
||||||
startedFetching: false,
|
|
||||||
finishedFetching: false,
|
|
||||||
errorFetching: false,
|
|
||||||
gradeFormat: 'percent',
|
|
||||||
showSuccess: false,
|
|
||||||
prevPage: null,
|
|
||||||
nextPage: null,
|
|
||||||
showSpinner: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
const courseId = 'course-v1:edX+DemoX+Demo_Course';
|
const courseId = 'course-v1:edX+DemoX+Demo_Course';
|
||||||
const headingsData = [
|
const headingsData = [
|
||||||
{ name: 'exam' },
|
{ name: 'exam' },
|
||||||
@@ -108,11 +94,12 @@ describe('grades reducer', () => {
|
|||||||
headings: headingsData,
|
headings: headingsData,
|
||||||
errorFetching: false,
|
errorFetching: false,
|
||||||
finishedFetching: true,
|
finishedFetching: true,
|
||||||
selectedTrack: expectedTrack,
|
|
||||||
selectedCohort: expectedCohortId,
|
|
||||||
prevPage: expectedPrev,
|
prevPage: expectedPrev,
|
||||||
nextPage: expectedNext,
|
nextPage: expectedNext,
|
||||||
showSpinner: false,
|
showSpinner: false,
|
||||||
|
courseId,
|
||||||
|
totalUsersCount: 4,
|
||||||
|
filteredUsersCount: 2,
|
||||||
};
|
};
|
||||||
expect(grades(undefined, {
|
expect(grades(undefined, {
|
||||||
type: GOT_GRADES,
|
type: GOT_GRADES,
|
||||||
@@ -123,6 +110,9 @@ describe('grades reducer', () => {
|
|||||||
track: expectedTrack,
|
track: expectedTrack,
|
||||||
cohort: expectedCohortId,
|
cohort: expectedCohortId,
|
||||||
showSpinner: true,
|
showSpinner: true,
|
||||||
|
courseId,
|
||||||
|
totalUsersCount: 4,
|
||||||
|
filteredUsersCount: 2,
|
||||||
})).toEqual(expected);
|
})).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -145,7 +135,7 @@ describe('grades reducer', () => {
|
|||||||
headings: expectedHeadings,
|
headings: expectedHeadings,
|
||||||
};
|
};
|
||||||
expect(grades(undefined, {
|
expect(grades(undefined, {
|
||||||
type: FILTER_COLUMNS,
|
type: FILTER_BY_ASSIGNMENT_TYPE,
|
||||||
headings: expectedHeadings,
|
headings: expectedHeadings,
|
||||||
})).toEqual(expected);
|
})).toEqual(expected);
|
||||||
});
|
});
|
||||||
@@ -157,19 +147,7 @@ describe('grades reducer', () => {
|
|||||||
showSuccess: expectedShowSuccess,
|
showSuccess: expectedShowSuccess,
|
||||||
};
|
};
|
||||||
expect(grades(undefined, {
|
expect(grades(undefined, {
|
||||||
type: UPDATE_BANNER,
|
type: OPEN_BANNER,
|
||||||
showSuccess: expectedShowSuccess,
|
|
||||||
})).toEqual(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('updates sort grades state success', () => {
|
|
||||||
const expected = {
|
|
||||||
...initialState,
|
|
||||||
results: gradesData,
|
|
||||||
};
|
|
||||||
expect(grades(undefined, {
|
|
||||||
type: SORT_GRADES,
|
|
||||||
results: gradesData,
|
|
||||||
})).toEqual(expected);
|
})).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import grades from './grades';
|
|||||||
import tracks from './tracks';
|
import tracks from './tracks';
|
||||||
import assignmentTypes from './assignmentTypes';
|
import assignmentTypes from './assignmentTypes';
|
||||||
import roles from './roles';
|
import roles from './roles';
|
||||||
|
import filters from './filters';
|
||||||
|
import config from './config';
|
||||||
|
|
||||||
const rootReducer = combineReducers({
|
const rootReducer = combineReducers({
|
||||||
grades,
|
grades,
|
||||||
@@ -12,6 +14,8 @@ const rootReducer = combineReducers({
|
|||||||
tracks,
|
tracks,
|
||||||
assignmentTypes,
|
assignmentTypes,
|
||||||
roles,
|
roles,
|
||||||
|
filters,
|
||||||
|
config,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default rootReducer;
|
export default rootReducer;
|
||||||
|
|||||||
@@ -1,26 +1,27 @@
|
|||||||
import {
|
import {
|
||||||
GOT_ROLES,
|
GOT_ROLES,
|
||||||
ERROR_FETCHING_ROLES,
|
ERROR_FETCHING_ROLES,
|
||||||
} from '../constants/actionTypes/roles';
|
} from '../constants/actionTypes/roles';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
canUserViewGradebook: null,
|
canUserViewGradebook: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const roles = (state = initialState, action) => {
|
const roles = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case GOT_ROLES:
|
case GOT_ROLES:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
canUserViewGradebook: action.canUserViewGradebook,
|
canUserViewGradebook: action.canUserViewGradebook,
|
||||||
};
|
};
|
||||||
case ERROR_FETCHING_ROLES:
|
case ERROR_FETCHING_ROLES:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
canUserViewGradebook: false,
|
canUserViewGradebook: false,
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export default roles;
|
export default roles;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe('tracks reducer', () => {
|
|||||||
it('updates canUserViewGradebook to true', () => {
|
it('updates canUserViewGradebook to true', () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
...initialState,
|
...initialState,
|
||||||
canUserViewGradebook: true
|
canUserViewGradebook: true,
|
||||||
};
|
};
|
||||||
expect(roles(undefined, {
|
expect(roles(undefined, {
|
||||||
type: GOT_ROLES,
|
type: GOT_ROLES,
|
||||||
@@ -27,7 +27,7 @@ describe('tracks reducer', () => {
|
|||||||
it('updates canUserViewGradebook to false', () => {
|
it('updates canUserViewGradebook to false', () => {
|
||||||
const expected = {
|
const expected = {
|
||||||
...initialState,
|
...initialState,
|
||||||
canUserViewGradebook: false
|
canUserViewGradebook: false,
|
||||||
};
|
};
|
||||||
expect(roles(undefined, {
|
expect(roles(undefined, {
|
||||||
type: GOT_ROLES,
|
type: GOT_ROLES,
|
||||||
|
|||||||
12
src/data/selectors/cohorts.js
Normal file
12
src/data/selectors/cohorts.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
const getCohorts = state => state.cohorts.results || [];
|
||||||
|
|
||||||
|
const getCohortById = (state, selectedCohortId) => {
|
||||||
|
const cohort = getCohorts(state).find(coh => coh.id === selectedCohortId);
|
||||||
|
return cohort;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCohortNameById = (state, selectedCohortId) =>
|
||||||
|
(getCohortById(state, selectedCohortId) || {}).name;
|
||||||
|
|
||||||
|
export { getCohortById, getCohortNameById, getCohorts };
|
||||||
41
src/data/selectors/filters.js
Normal file
41
src/data/selectors/filters.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
const getFilters = state => state.filters || {};
|
||||||
|
|
||||||
|
const getAssignmentsFromResultsSubstate = results =>
|
||||||
|
(results[0] || {}).section_breakdown || [];
|
||||||
|
|
||||||
|
const selectableAssignments = (state) => {
|
||||||
|
const selectedAssignmentType = getFilters(state).assignmentType;
|
||||||
|
const needToFilter = selectedAssignmentType && selectedAssignmentType !== 'All';
|
||||||
|
const allAssignments = getAssignmentsFromResultsSubstate(state.grades.results);
|
||||||
|
if (needToFilter) {
|
||||||
|
return allAssignments.filter(assignment => assignment.category === selectedAssignmentType);
|
||||||
|
}
|
||||||
|
return allAssignments;
|
||||||
|
};
|
||||||
|
|
||||||
|
const chooseRelevantAssignmentData = assignment => ({
|
||||||
|
label: assignment.label,
|
||||||
|
subsectionLabel: assignment.subsection_name,
|
||||||
|
type: assignment.category,
|
||||||
|
id: assignment.module_id,
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectableAssignmentLabels = state =>
|
||||||
|
selectableAssignments(state).map(chooseRelevantAssignmentData);
|
||||||
|
|
||||||
|
const typeOfSelectedAssignment = (state) => {
|
||||||
|
const selectedAssignmentLabel = getFilters(state).assignment;
|
||||||
|
const sectionBreakdown = (state.grades.results[0] || {}).section_breakdown || [];
|
||||||
|
const selectedAssignment = sectionBreakdown.find(section =>
|
||||||
|
section.label === selectedAssignmentLabel);
|
||||||
|
return selectedAssignment && selectedAssignment.category;
|
||||||
|
};
|
||||||
|
|
||||||
|
export {
|
||||||
|
selectableAssignmentLabels,
|
||||||
|
selectableAssignments,
|
||||||
|
getFilters,
|
||||||
|
typeOfSelectedAssignment,
|
||||||
|
chooseRelevantAssignmentData,
|
||||||
|
getAssignmentsFromResultsSubstate,
|
||||||
|
};
|
||||||
123
src/data/selectors/grades.js
Normal file
123
src/data/selectors/grades.js
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
import { formatDateForDisplay } from '../actions/utils';
|
||||||
|
import { getFilters } from './filters';
|
||||||
|
|
||||||
|
const getRowsProcessed = (data) => {
|
||||||
|
const {
|
||||||
|
processed_rows: processed,
|
||||||
|
saved_rows: saved,
|
||||||
|
total_rows: total,
|
||||||
|
} = data;
|
||||||
|
return {
|
||||||
|
total,
|
||||||
|
successfullyProcessed: saved,
|
||||||
|
failed: processed - saved,
|
||||||
|
skipped: total - processed,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const transformHistoryEntry = (historyRow) => {
|
||||||
|
const {
|
||||||
|
modified,
|
||||||
|
original_filename: originalFilename,
|
||||||
|
data,
|
||||||
|
...rest
|
||||||
|
} = historyRow;
|
||||||
|
|
||||||
|
const timeUploaded = formatDateForDisplay(new Date(modified));
|
||||||
|
const summaryOfRowsProcessed = getRowsProcessed(data);
|
||||||
|
|
||||||
|
return {
|
||||||
|
timeUploaded,
|
||||||
|
originalFilename,
|
||||||
|
summaryOfRowsProcessed,
|
||||||
|
...rest,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const getBulkManagementHistoryFromState = state =>
|
||||||
|
state.grades.bulkManagement.history || [];
|
||||||
|
const getBulkManagementHistory = state =>
|
||||||
|
getBulkManagementHistoryFromState(state).map(transformHistoryEntry);
|
||||||
|
|
||||||
|
const headingMapper = (category, label = 'All') => {
|
||||||
|
const filters = {
|
||||||
|
all: section => section.label,
|
||||||
|
byCategory: section => section.label && section.category === category,
|
||||||
|
byLabel: section => section.label && section.label === label,
|
||||||
|
};
|
||||||
|
|
||||||
|
let filter;
|
||||||
|
if (label === 'All') {
|
||||||
|
filter = category === 'All' ? 'all' : 'byCategory';
|
||||||
|
} else {
|
||||||
|
filter = 'byLabel';
|
||||||
|
}
|
||||||
|
|
||||||
|
return (entry) => {
|
||||||
|
if (entry) {
|
||||||
|
const results = ['Username', 'Email'];
|
||||||
|
|
||||||
|
const assignmentHeadings = entry
|
||||||
|
.filter(filters[filter])
|
||||||
|
.map(s => s.label);
|
||||||
|
|
||||||
|
const totals = ['Total'];
|
||||||
|
|
||||||
|
return results.concat(assignmentHeadings).concat(totals);
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getExampleSectionBreakdown = state => (state.grades.results[0] || {}).section_breakdown || [];
|
||||||
|
|
||||||
|
const getHeadings = (state) => {
|
||||||
|
const filters = getFilters(state) || {};
|
||||||
|
const {
|
||||||
|
assignmentType: selectedAssignmentType,
|
||||||
|
assignment: selectedAssignment,
|
||||||
|
} = filters;
|
||||||
|
const assignments = getExampleSectionBreakdown(state);
|
||||||
|
const type = selectedAssignmentType || 'All';
|
||||||
|
const assignment = (selectedAssignment || {}).label || 'All';
|
||||||
|
return headingMapper(type, assignment)(assignments);
|
||||||
|
};
|
||||||
|
|
||||||
|
const composeFilters = (...predicates) => (percentGrade, options = {}) =>
|
||||||
|
predicates.reduce((accum, predicate) => {
|
||||||
|
if (predicate(percentGrade, options)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return accum;
|
||||||
|
}, percentGrade);
|
||||||
|
|
||||||
|
const percentGradeIsMax = percentGrade => (
|
||||||
|
percentGrade === '100'
|
||||||
|
);
|
||||||
|
|
||||||
|
const percentGradeIsMin = percentGrade => (
|
||||||
|
percentGrade === '0'
|
||||||
|
);
|
||||||
|
|
||||||
|
const assignmentIdIsDefined = (percentGrade, { assignmentId }) => (
|
||||||
|
!assignmentId
|
||||||
|
);
|
||||||
|
|
||||||
|
const formatMaxCourseGrade = composeFilters(percentGradeIsMax);
|
||||||
|
const formatMinCourseGrade = composeFilters(percentGradeIsMin);
|
||||||
|
const formatMaxAssignmentGrade = composeFilters(
|
||||||
|
percentGradeIsMax,
|
||||||
|
assignmentIdIsDefined,
|
||||||
|
);
|
||||||
|
const formatMinAssignmentGrade = composeFilters(
|
||||||
|
percentGradeIsMin,
|
||||||
|
assignmentIdIsDefined,
|
||||||
|
);
|
||||||
|
|
||||||
|
export {
|
||||||
|
getBulkManagementHistory,
|
||||||
|
getHeadings,
|
||||||
|
formatMinAssignmentGrade,
|
||||||
|
formatMaxAssignmentGrade,
|
||||||
|
formatMaxCourseGrade,
|
||||||
|
formatMinCourseGrade,
|
||||||
|
};
|
||||||
72
src/data/selectors/grades.test.js
Normal file
72
src/data/selectors/grades.test.js
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import { getBulkManagementHistory } from './grades';
|
||||||
|
|
||||||
|
const genericHistoryRow = {
|
||||||
|
id: 5,
|
||||||
|
class_name: 'bulk_grades.api.GradeCSVProcessor',
|
||||||
|
unique_id: 'course-v1:google+goog101+2018_spring',
|
||||||
|
operation: 'commit',
|
||||||
|
user: 'edx',
|
||||||
|
modified: '2019-07-16T20:25:46.700802Z',
|
||||||
|
original_filename: '',
|
||||||
|
data: {
|
||||||
|
total_rows: 5,
|
||||||
|
processed_rows: 3,
|
||||||
|
saved_rows: 3,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('getBulkManagementHistory', () => {
|
||||||
|
it('handles history being as-yet unloaded', () => {
|
||||||
|
const result = getBulkManagementHistory({ grades: { bulkManagement: {} } });
|
||||||
|
expect(result).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('formats dates for us', () => {
|
||||||
|
const result = getBulkManagementHistory({
|
||||||
|
grades: {
|
||||||
|
bulkManagement: {
|
||||||
|
history: [
|
||||||
|
genericHistoryRow,
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const [{ timeUploaded }] = result;
|
||||||
|
expect(timeUploaded).not.toMatch(/Z$/);
|
||||||
|
expect(timeUploaded).toContain(' at ');
|
||||||
|
});
|
||||||
|
|
||||||
|
const exerciseGetRowsProcessed = (input, expectation) => {
|
||||||
|
const result = getBulkManagementHistory({
|
||||||
|
grades: {
|
||||||
|
bulkManagement: {
|
||||||
|
history: [
|
||||||
|
{ ...genericHistoryRow, data: input },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const [{ summaryOfRowsProcessed }] = result;
|
||||||
|
expect(summaryOfRowsProcessed).toEqual(expect.objectContaining(expectation));
|
||||||
|
};
|
||||||
|
|
||||||
|
it('calculates skippage', () => {
|
||||||
|
exerciseGetRowsProcessed({
|
||||||
|
total_rows: 100,
|
||||||
|
processed_rows: 10,
|
||||||
|
saved_rows: 10,
|
||||||
|
}, {
|
||||||
|
skipped: 90,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('calculates failures', () => {
|
||||||
|
exerciseGetRowsProcessed({
|
||||||
|
total_rows: 10,
|
||||||
|
processed_rows: 100,
|
||||||
|
saved_rows: 10,
|
||||||
|
}, {
|
||||||
|
failed: 90,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
13
src/data/selectors/tracks.js
Normal file
13
src/data/selectors/tracks.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const compose = (...fns) => {
|
||||||
|
const [firstFunc, ...rest] = fns.reverse();
|
||||||
|
return (...args) =>
|
||||||
|
rest.reduce((accum, fn) => fn(accum), firstFunc(...args));
|
||||||
|
};
|
||||||
|
|
||||||
|
const getTracks = state => state.tracks.results || [];
|
||||||
|
const trackIsMasters = track => track.slug === 'masters';
|
||||||
|
const hasMastersTrack = tracks => tracks.some(trackIsMasters);
|
||||||
|
const stateHasMastersTrack = compose(hasMastersTrack, getTracks);
|
||||||
|
|
||||||
|
export { hasMastersTrack, trackIsMasters };
|
||||||
|
export default stateHasMastersTrack;
|
||||||
@@ -3,21 +3,45 @@ import { configuration } from '../../config';
|
|||||||
|
|
||||||
class LmsApiService {
|
class LmsApiService {
|
||||||
static baseUrl = configuration.LMS_BASE_URL;
|
static baseUrl = configuration.LMS_BASE_URL;
|
||||||
static pageSize = 10
|
static pageSize = 25
|
||||||
|
|
||||||
static fetchGradebookData(courseId, searchText, cohort, track) {
|
static fetchGradebookData(courseId, searchText, cohort, track, options = {}) {
|
||||||
let gradebookUrl = `${LmsApiService.baseUrl}/api/grades/v1/gradebook/${courseId}/`;
|
const queryParams = {};
|
||||||
|
queryParams.page_size = LmsApiService.pageSize;
|
||||||
gradebookUrl += `?page_size=${LmsApiService.pageSize}&`;
|
|
||||||
if (searchText) {
|
if (searchText) {
|
||||||
gradebookUrl += `username_contains=${searchText}&`;
|
queryParams.user_contains = searchText;
|
||||||
}
|
}
|
||||||
if (cohort) {
|
if (cohort) {
|
||||||
gradebookUrl += `cohort_id=${cohort}&`;
|
queryParams.cohort_id = cohort;
|
||||||
}
|
}
|
||||||
if (track) {
|
if (track) {
|
||||||
gradebookUrl += `enrollment_mode=${track}`;
|
queryParams.enrollment_mode = track;
|
||||||
}
|
}
|
||||||
|
if (options.assignmentGradeMax || options.assignmentGradeMin) {
|
||||||
|
if (!options.assignment) {
|
||||||
|
throw new Error('Gradebook LMS API requires assignment to be set to filter by min/max assig. grade');
|
||||||
|
}
|
||||||
|
queryParams.assignment = options.assignment;
|
||||||
|
if (options.assignmentGradeMin) {
|
||||||
|
queryParams.assignment_grade_min = options.assignmentGradeMin;
|
||||||
|
}
|
||||||
|
if (options.assignmentGradeMax) {
|
||||||
|
queryParams.assignment_grade_max = options.assignmentGradeMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (options.courseGradeMin) {
|
||||||
|
queryParams.course_grade_min = options.courseGradeMin;
|
||||||
|
}
|
||||||
|
if (options.courseGradeMax) {
|
||||||
|
queryParams.course_grade_max = options.courseGradeMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryParamString = Object.keys(queryParams)
|
||||||
|
.map(attr => `${attr}=${encodeURIComponent(queryParams[attr])}`)
|
||||||
|
.join('&');
|
||||||
|
|
||||||
|
const gradebookUrl = `${LmsApiService.baseUrl}/api/grades/v1/gradebook/${courseId}/?${queryParamString}`;
|
||||||
|
|
||||||
return apiClient.get(gradebookUrl);
|
return apiClient.get(gradebookUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +49,10 @@ class LmsApiService {
|
|||||||
/*
|
/*
|
||||||
updateData is expected to be a list of objects with the keys 'user_id' (an integer),
|
updateData is expected to be a list of objects with the keys 'user_id' (an integer),
|
||||||
'usage_id' (a string) and 'grade', which is an object with the keys:
|
'usage_id' (a string) and 'grade', which is an object with the keys:
|
||||||
'earned_all_override', 'possible_all_override', 'earned_graded_override', and 'possible_graded_override',
|
'earned_all_override',
|
||||||
|
'possible_all_override',
|
||||||
|
'earned_graded_override',
|
||||||
|
and 'possible_graded_override',
|
||||||
each of which should be an integer.
|
each of which should be an integer.
|
||||||
Example:
|
Example:
|
||||||
[
|
[
|
||||||
@@ -36,7 +63,8 @@ class LmsApiService {
|
|||||||
"earned_all_override": 11,
|
"earned_all_override": 11,
|
||||||
"possible_all_override": 11,
|
"possible_all_override": 11,
|
||||||
"earned_graded_override": 11,
|
"earned_graded_override": 11,
|
||||||
"possible_graded_override": 11
|
"possible_graded_override": 11,
|
||||||
|
"comment": "reason for override"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -46,7 +74,7 @@ class LmsApiService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static fetchTracks(courseId) {
|
static fetchTracks(courseId) {
|
||||||
const trackUrl = `${LmsApiService.baseUrl}/api/enrollment/v1/course/${courseId}`;
|
const trackUrl = `${LmsApiService.baseUrl}/api/enrollment/v1/course/${courseId}?include_expired=1`;
|
||||||
return apiClient.get(trackUrl);
|
return apiClient.get(trackUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +92,48 @@ class LmsApiService {
|
|||||||
const rolesUrl = `${LmsApiService.baseUrl}/api/enrollment/v1/roles/?course_id=${encodeURIComponent(courseId)}`;
|
const rolesUrl = `${LmsApiService.baseUrl}/api/enrollment/v1/roles/?course_id=${encodeURIComponent(courseId)}`;
|
||||||
return apiClient.get(rolesUrl);
|
return apiClient.get(rolesUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static getGradeExportCsvUrl(courseId, options = {}) {
|
||||||
|
const queryParams = ['track', 'cohort', 'assignment', 'assignmentType', 'assignmentGradeMax',
|
||||||
|
'assignmentGradeMin', 'courseGradeMin', 'courseGradeMax']
|
||||||
|
.filter(opt => options[opt] &&
|
||||||
|
options[opt] !== 'All')
|
||||||
|
.map(opt => `${opt}=${encodeURIComponent(options[opt])}`)
|
||||||
|
.join('&');
|
||||||
|
return `${LmsApiService.baseUrl}/api/bulk_grades/course/${courseId}/?${queryParams}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getInterventionExportCsvUrl(courseId, options = {}) {
|
||||||
|
const queryParams = ['track', 'cohort', 'assignment', 'assignmentType', 'assignmentGradeMax',
|
||||||
|
'assignmentGradeMin', 'courseGradeMin', 'courseGradeMax']
|
||||||
|
.filter(opt => options[opt] &&
|
||||||
|
options[opt] !== 'All')
|
||||||
|
.map(opt => `${opt}=${encodeURIComponent(options[opt])}`)
|
||||||
|
.join('&');
|
||||||
|
return `${LmsApiService.baseUrl}/api/bulk_grades/course/${courseId}/intervention?${queryParams}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static getGradeImportCsvUrl = LmsApiService.getGradeExportCsvUrl;
|
||||||
|
|
||||||
|
static uploadGradeCsv(courseId, formData) {
|
||||||
|
const fileUploadUrl = LmsApiService.getGradeImportCsvUrl(courseId);
|
||||||
|
return apiClient.post(fileUploadUrl, formData).then((result) => {
|
||||||
|
if (result.status === 200 && !result.data.error_messages.length) {
|
||||||
|
return result.data;
|
||||||
|
}
|
||||||
|
return Promise.reject(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static fetchGradeBulkOperationHistory(courseId) {
|
||||||
|
const url = `${LmsApiService.baseUrl}/api/bulk_grades/course/${courseId}/history/`;
|
||||||
|
return apiClient.get(url).then(response => response.data).catch(() => Promise.reject(Error('unhandled response error')));
|
||||||
|
}
|
||||||
|
|
||||||
|
static fetchGradeOverrideHistory(subsectionId, userId) {
|
||||||
|
const historyUrl = `${LmsApiService.baseUrl}/api/grades/v1/subsection/${subsectionId}/?user_id=${userId}&history_record_limit=5`;
|
||||||
|
return apiClient.get(historyUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LmsApiService;
|
export default LmsApiService;
|
||||||
|
|||||||
@@ -2,14 +2,99 @@ import { applyMiddleware, createStore } from 'redux';
|
|||||||
import thunkMiddleware from 'redux-thunk';
|
import thunkMiddleware from 'redux-thunk';
|
||||||
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
|
import { composeWithDevTools } from 'redux-devtools-extension/logOnlyInProduction';
|
||||||
import { createLogger } from 'redux-logger';
|
import { createLogger } from 'redux-logger';
|
||||||
|
import { createMiddleware } from 'redux-beacon';
|
||||||
|
import Segment, { trackEvent, trackPageView } from '@redux-beacon/segment';
|
||||||
|
import { GOT_ROLES } from './constants/actionTypes/roles';
|
||||||
|
import {
|
||||||
|
GOT_GRADES, GRADE_UPDATE_SUCCESS, GRADE_UPDATE_FAILURE, UPLOAD_OVERRIDE,
|
||||||
|
UPLOAD_OVERRIDE_ERROR, BULK_GRADE_REPORT_DOWNLOADED, INTERVENTION_REPORT_DOWNLOADED,
|
||||||
|
} from './constants/actionTypes/grades';
|
||||||
|
import { UPDATE_COURSE_GRADE_LIMITS } from './constants/actionTypes/filters';
|
||||||
|
|
||||||
import reducers from './reducers';
|
import reducers from './reducers';
|
||||||
|
|
||||||
const loggerMiddleware = createLogger();
|
const loggerMiddleware = createLogger();
|
||||||
|
const trackingCategory = 'gradebook';
|
||||||
|
|
||||||
|
const eventsMap = {
|
||||||
|
[GOT_ROLES]: trackPageView(action => ({
|
||||||
|
category: trackingCategory,
|
||||||
|
page: action.courseId,
|
||||||
|
})),
|
||||||
|
[GOT_GRADES]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.grades.displayed',
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
track: action.track,
|
||||||
|
cohort: action.cohort,
|
||||||
|
assignmentType: action.assignmentType,
|
||||||
|
prev: action.prev,
|
||||||
|
next: action.next,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
[GRADE_UPDATE_SUCCESS]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.grades.grade_override.succeeded',
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
updatedGrades: action.payload.responseData,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
[GRADE_UPDATE_FAILURE]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.grades.grade_override.failed',
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
error: action.payload.error,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
[UPLOAD_OVERRIDE]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.grades.upload.grades_overrides.succeeded',
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
[UPLOAD_OVERRIDE_ERROR]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.grades.upload.grades_overrides.failed',
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
error: action.payload.error,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
[UPDATE_COURSE_GRADE_LIMITS]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.grades.filter_applied',
|
||||||
|
label: action.courseId,
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
[BULK_GRADE_REPORT_DOWNLOADED]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.reports.grade_export.downloaded',
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
[INTERVENTION_REPORT_DOWNLOADED]: trackEvent(action => ({
|
||||||
|
name: 'edx.gradebook.reports.intervention.downloaded',
|
||||||
|
properties: {
|
||||||
|
category: trackingCategory,
|
||||||
|
label: action.courseId,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
|
||||||
|
const segmentMiddleware = createMiddleware(eventsMap, Segment());
|
||||||
|
|
||||||
|
|
||||||
const store = createStore(
|
const store = createStore(
|
||||||
reducers,
|
reducers,
|
||||||
composeWithDevTools(applyMiddleware(thunkMiddleware, loggerMiddleware)),
|
composeWithDevTools(applyMiddleware(thunkMiddleware, loggerMiddleware, segmentMiddleware)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export { trackingCategory };
|
||||||
export default store;
|
export default store;
|
||||||
|
|||||||
@@ -3,32 +3,92 @@ import React from 'react';
|
|||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
|
import SiteFooter from '@edx/frontend-component-footer';
|
||||||
|
import { IntlProvider } from 'react-intl';
|
||||||
|
|
||||||
|
import {
|
||||||
|
faFacebookSquare,
|
||||||
|
faTwitterSquare,
|
||||||
|
faLinkedin,
|
||||||
|
faRedditSquare,
|
||||||
|
} from '@fortawesome/free-brands-svg-icons';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
|
||||||
import apiClient from './data/apiClient';
|
import apiClient from './data/apiClient';
|
||||||
import Footer from './components/Gradebook/footer';
|
|
||||||
import GradebookPage from './containers/GradebookPage';
|
import GradebookPage from './containers/GradebookPage';
|
||||||
import Header from './components/Header';
|
import Header from './components/Header';
|
||||||
import store from './data/store';
|
import store from './data/store';
|
||||||
|
import FooterLogo from '../assets/edx-footer.png';
|
||||||
import './App.scss';
|
import './App.scss';
|
||||||
|
|
||||||
var courseId = window.location.pathname.substring(1);
|
const socialLinks = [
|
||||||
|
{
|
||||||
|
title: 'Facebook',
|
||||||
|
url: process.env.FACEBOOK_URL,
|
||||||
|
icon: <FontAwesomeIcon icon={faFacebookSquare} className="social-icon" size="2x" />,
|
||||||
|
screenReaderText: 'Like edX on Facebook',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Twitter',
|
||||||
|
url: process.env.TWITTER_URL,
|
||||||
|
icon: <FontAwesomeIcon icon={faTwitterSquare} className="social-icon" size="2x" />,
|
||||||
|
screenReaderText: 'Follow edX on Twitter',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'LinkedIn',
|
||||||
|
url: process.env.LINKED_IN_URL,
|
||||||
|
icon: <FontAwesomeIcon icon={faLinkedin} className="social-icon" size="2x" />,
|
||||||
|
screenReaderText: 'Follow edX on LinkedIn',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Reddit',
|
||||||
|
url: process.env.REDDIT_URL,
|
||||||
|
icon: <FontAwesomeIcon icon={faRedditSquare} className="social-icon" size="2x" />,
|
||||||
|
screenReaderText: 'Subscribe to the edX subreddit',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const App = () => (
|
const App = () => (
|
||||||
<Provider store={store}>
|
<IntlProvider>
|
||||||
<Router>
|
<Provider store={store}>
|
||||||
<div>
|
<Router>
|
||||||
<Header />
|
<div>
|
||||||
<main>
|
<Header />
|
||||||
<Switch>
|
<main>
|
||||||
<Route exact path="/:courseId" component={GradebookPage} />
|
<Switch>
|
||||||
</Switch>
|
<Route exact path="/gradebook/:courseId" component={GradebookPage} />
|
||||||
</main>
|
</Switch>
|
||||||
<Footer />
|
</main>
|
||||||
</div>
|
<SiteFooter
|
||||||
</Router>
|
siteName={process.env.SITE_NAME}
|
||||||
</Provider>
|
siteLogo={FooterLogo}
|
||||||
|
marketingSiteBaseUrl={process.env.MARKETING_SITE_BASE_URL}
|
||||||
|
supportUrl={process.env.SUPPORT_URL}
|
||||||
|
contactUrl={process.env.CONTACT_URL}
|
||||||
|
openSourceUrl={process.env.OPEN_SOURCE_URL}
|
||||||
|
termsOfServiceUrl={process.env.TERMS_OF_SERVICE_URL}
|
||||||
|
privacyPolicyUrl={process.env.PRIVACY_POLICY_URL}
|
||||||
|
appleAppStoreUrl={process.env.APPLE_APP_STORE_URL}
|
||||||
|
googlePlayUrl={process.env.GOOGLE_PLAY_URL}
|
||||||
|
socialLinks={socialLinks}
|
||||||
|
enterpriseMarketingLink={{
|
||||||
|
url: process.env.ENTERPRISE_MARKETING_URL,
|
||||||
|
queryParams: {
|
||||||
|
utm_source: process.env.ENTERPRISE_MARKETING_UTM_SOURCE,
|
||||||
|
utm_campaign: process.env.ENTERPRISE_MARKETING_UTM_CAMPAIGN,
|
||||||
|
utm_medium: process.env.ENTERPRISE_MARKETING_FOOTER_UTM_MEDIUM,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Router>
|
||||||
|
</Provider>
|
||||||
|
</IntlProvider>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (apiClient.ensurePublicOrAuthencationAndCookies(window.location.pathname)) {
|
apiClient.ensurePublicOrAuthenticationAndCookies(
|
||||||
ReactDOM.render(<App />, document.getElementById('root'));
|
window.location.pathname,
|
||||||
}
|
() => {
|
||||||
|
ReactDOM.render(<App />, document.getElementById('root'));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|||||||
85
src/segment.js
Normal file
85
src/segment.js
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// The code in this file is from Segment's website:
|
||||||
|
// https://segment.com/docs/sources/website/analytics.js/quickstart/
|
||||||
|
import { configuration } from './config';
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
// Create a queue, but don't obliterate an existing one!
|
||||||
|
const analytics = window.analytics = window.analytics || [];
|
||||||
|
|
||||||
|
// If the real analytics.js is already on the page return.
|
||||||
|
if (analytics.initialize) return;
|
||||||
|
|
||||||
|
// If the snippet was invoked already show an error.
|
||||||
|
if (analytics.invoked) {
|
||||||
|
if (window.console && console.error) {
|
||||||
|
console.error('Segment snippet included twice.');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoked flag, to make sure the snippet
|
||||||
|
// is never invoked twice.
|
||||||
|
analytics.invoked = true;
|
||||||
|
|
||||||
|
// A list of the methods in Analytics.js to stub.
|
||||||
|
analytics.methods = [
|
||||||
|
'trackSubmit',
|
||||||
|
'trackClick',
|
||||||
|
'trackLink',
|
||||||
|
'trackForm',
|
||||||
|
'pageview',
|
||||||
|
'identify',
|
||||||
|
'reset',
|
||||||
|
'group',
|
||||||
|
'track',
|
||||||
|
'ready',
|
||||||
|
'alias',
|
||||||
|
'debug',
|
||||||
|
'page',
|
||||||
|
'once',
|
||||||
|
'off',
|
||||||
|
'on',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Define a factory to create stubs. These are placeholders
|
||||||
|
// for methods in Analytics.js so that you never have to wait
|
||||||
|
// for it to load to actually record data. The `method` is
|
||||||
|
// stored as the first argument, so we can replay the data.
|
||||||
|
analytics.factory = function (method) {
|
||||||
|
return function () {
|
||||||
|
const args = Array.prototype.slice.call(arguments);
|
||||||
|
args.unshift(method);
|
||||||
|
analytics.push(args);
|
||||||
|
return analytics;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// For each of our methods, generate a queueing stub.
|
||||||
|
for (let i = 0; i < analytics.methods.length; i++) {
|
||||||
|
const key = analytics.methods[i];
|
||||||
|
analytics[key] = analytics.factory(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define a method to load Analytics.js from our CDN,
|
||||||
|
// and that will be sure to only ever load it once.
|
||||||
|
analytics.load = function (key, options) {
|
||||||
|
// Create an async script element based on your key.
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.type = 'text/javascript';
|
||||||
|
script.async = true;
|
||||||
|
script.src = `https://cdn.segment.com/analytics.js/v1/${
|
||||||
|
key}/analytics.min.js`;
|
||||||
|
|
||||||
|
// Insert our script next to the first script element.
|
||||||
|
const first = document.getElementsByTagName('script')[0];
|
||||||
|
first.parentNode.insertBefore(script, first);
|
||||||
|
analytics._loadOptions = options;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add a version to keep track of what's in the wild.
|
||||||
|
analytics.SNIPPET_VERSION = '4.1.0';
|
||||||
|
|
||||||
|
// Load Analytics.js with your key, which will automatically
|
||||||
|
// load the tools you've enabled for your account. Boosh!
|
||||||
|
analytics.load(configuration.SEGMENT_KEY);
|
||||||
|
}());
|
||||||
Reference in New Issue
Block a user