-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6358 from mishaschwartz/v2.1.7
V2.1.7
- Loading branch information
Showing
59 changed files
with
6,823 additions
and
10,459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION=v2.1.6,PATCH_LEVEL=DEV | ||
VERSION=v2.1.7,PATCH_LEVEL=DEV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
// | ||
//= link_tree ../images | ||
//= link_tree ../builds | ||
//= link flatpickr/dist/flatpickr.css |
175 changes: 175 additions & 0 deletions
175
app/assets/javascripts/Components/Modals/release_urls_modal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
import React from "react"; | ||
import Modal from "react-modal"; | ||
import ReactTable from "react-table"; | ||
import Flatpickr from "react-flatpickr"; | ||
|
||
class ReleaseUrlsModal extends React.Component { | ||
constructor() { | ||
super(); | ||
this.state = {loading: false}; | ||
} | ||
|
||
componentDidMount() { | ||
Modal.setAppElement("body"); | ||
} | ||
|
||
refreshViewTokens = result_ids => { | ||
if (!confirm(I18n.t("submissions.refresh_token_confirmation"))) { | ||
return; | ||
} | ||
this.setState({loading: true}, () => { | ||
$.ajax({ | ||
type: "PUT", | ||
url: Routes.refresh_view_tokens_course_assignment_results_url( | ||
this.props.course_id, | ||
this.props.assignment_id, | ||
{result_ids: result_ids} | ||
), | ||
}).then(res => this.props.refreshViewTokens(res, () => this.setState({loading: false}))); | ||
}); | ||
}; | ||
|
||
refreshViewTokenExpiry = (expiry_datetime, result_ids) => { | ||
if ( | ||
result_ids.length > 1 && | ||
!confirm( | ||
expiry_datetime | ||
? I18n.t("submissions.update_all_token_expiry_confirmation", {date: expiry_datetime}) | ||
: I18n.t("submissions.clear_all_token_expiry_confirmation") | ||
) | ||
) { | ||
return; | ||
} | ||
this.setState({loading: true}, () => { | ||
$.ajax({ | ||
type: "PUT", | ||
url: Routes.update_view_token_expiry_course_assignment_results_url( | ||
this.props.course_id, | ||
this.props.assignment_id, | ||
{result_ids: result_ids, expiry_datetime: expiry_datetime} | ||
), | ||
}).then(res => this.props.refreshViewTokenExpiry(res, () => this.setState({loading: false}))); | ||
}); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Modal | ||
className="react-modal" | ||
isOpen={this.props.isOpen} | ||
onRequestClose={this.props.onRequestClose} | ||
> | ||
<div className="rt-action-box"> | ||
<button onClick={() => this.refreshViewTokens(this.props.data.map(d => d["result_id"]))}> | ||
{I18n.t("submissions.refresh_all_tokens")} | ||
</button> | ||
<Flatpickr | ||
placeholder={I18n.t("submissions.update_all_token_expiry")} | ||
onClose={selectedDates => { | ||
this.refreshViewTokenExpiry( | ||
selectedDates[0], | ||
this.props.data.map(d => d["result_id"]) | ||
); | ||
}} | ||
options={{ | ||
altInput: true, | ||
altFormat: I18n.t("time.format_string.flatpickr"), | ||
dateFormat: "Z", | ||
}} | ||
/> | ||
<a | ||
className={"button"} | ||
href={Routes.download_view_tokens_course_assignment_results_url( | ||
this.props.course_id, | ||
this.props.assignment_id, | ||
{result_ids: this.props.data.map(d => d["result_id"])} | ||
)} | ||
> | ||
{I18n.t("download")} | ||
</a> | ||
</div> | ||
<ReactTable | ||
data={this.props.data} | ||
filterable | ||
defaultSorted={[{id: "group_name"}]} | ||
loading={this.state.loading} | ||
columns={[ | ||
{ | ||
show: false, | ||
accessor: "_id", | ||
id: "_id", | ||
}, | ||
{ | ||
Header: I18n.t("activerecord.models.group.one"), | ||
accessor: "group_name", | ||
id: "group_name", | ||
Cell: this.props.groupNameWithMembers, | ||
minWidth: 250, | ||
filterMethod: this.props.groupNameFilter, | ||
}, | ||
{ | ||
Header: I18n.t("submissions.release_token"), | ||
id: "result_view_token", | ||
filterable: false, | ||
sortable: false, | ||
minWidth: 250, | ||
Cell: row => { | ||
return ( | ||
<div> | ||
<a | ||
href="#" | ||
className="refresh" | ||
onClick={() => this.refreshViewTokens([row.original.result_id])} | ||
title={I18n.t("refresh")} | ||
/> | ||
{row.original.result_view_token} | ||
</div> | ||
); | ||
}, | ||
}, | ||
{ | ||
Header: I18n.t("submissions.release_token_expires"), | ||
id: "result_view_token_expiry", | ||
filterable: false, | ||
sortable: false, | ||
minWidth: 200, | ||
Cell: row => { | ||
return ( | ||
<Flatpickr | ||
value={row.original.result_view_token_expiry} | ||
onClose={selectedDates => | ||
this.refreshViewTokenExpiry(selectedDates[0], [row.original.result_id]) | ||
} | ||
options={{ | ||
altInput: true, | ||
altFormat: I18n.t("time.format_string.flatpickr"), | ||
dateFormat: "Z", | ||
}} | ||
/> | ||
); | ||
}, | ||
}, | ||
]} | ||
SubComponent={row => { | ||
if (row.original.result_view_token) { | ||
const url = Routes.view_marks_course_result_url( | ||
this.props.course_id, | ||
row.original.result_id, | ||
{view_token: row.original.result_view_token} | ||
); | ||
return ( | ||
<div style={{whiteSpace: "pre-wrap"}}> | ||
{I18n.t("submissions.release_url_with_token", {url: url})} | ||
</div> | ||
); | ||
} else { | ||
return ""; | ||
} | ||
}} | ||
/> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
export default ReleaseUrlsModal; |
60 changes: 60 additions & 0 deletions
60
app/assets/javascripts/Components/Modals/submit_view_token_modal.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from "react"; | ||
import {render} from "react-dom"; | ||
import Modal from "react-modal"; | ||
|
||
class SubmitViewTokenModal extends React.Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
isOpen: false, | ||
token: null, | ||
}; | ||
} | ||
|
||
componentDidMount() { | ||
Modal.setAppElement("body"); | ||
} | ||
|
||
onSubmit = () => { | ||
$.ajax({ | ||
url: Routes.view_token_check_course_result_path(this.props.course_id, this.props.result_id, { | ||
view_token: this.state.token, | ||
}), | ||
}).then( | ||
() => { | ||
window.location = Routes.view_marks_course_result_path( | ||
this.props.course_id, | ||
this.props.result_id, | ||
{view_token: this.state.token} | ||
); | ||
}, | ||
() => this.setState({isOpen: false, token: null}) | ||
); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Modal | ||
className="react-modal" | ||
isOpen={this.state.isOpen} | ||
onRequestClose={() => this.setState({isOpen: false, token: null})} | ||
> | ||
<p>{I18n.t("results.view_token_submit")}</p> | ||
<form onSubmit={this.onSubmit}> | ||
<div className={"modal-container-vertical"}> | ||
<div className={"modal-container"}> | ||
<input onChange={e => this.setState({token: e.target.value})} /> | ||
</div> | ||
<div className={"modal-container"}> | ||
<input type="submit" value={I18n.t("results.submit_token")} /> | ||
</div> | ||
</div> | ||
</form> | ||
</Modal> | ||
); | ||
} | ||
} | ||
|
||
export function makeSubmitViewTokenModal(elem, props) { | ||
return render(<SubmitViewTokenModal {...props} />, elem); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.