diff --git a/dataBaseSchema.sql b/dataBaseSchema.sql index 7703b73..d451188 100644 --- a/dataBaseSchema.sql +++ b/dataBaseSchema.sql @@ -91,8 +91,7 @@ ALTER TABLE certification OWNER TO postgres; CREATE TABLE post ( id uuid DEFAULT public.gen_random_uuid() NOT NULL, content text, - created_on timestamp without time zone DEFAULT timezone('utc'::text, now()), - title character varying(255) + created_on timestamp without time zone DEFAULT timezone('utc'::text, now()) ); @@ -130,6 +129,7 @@ CREATE TABLE "user" ( ALTER TABLE "user" OWNER TO postgres; + -- -- Data for Name: user; Type: TABLE DATA; Schema: open_certification_trainer; Owner: postgres -- @@ -284,4 +284,3 @@ GRANT ALL ON TABLE "user" TO dev; -- -- PostgreSQL database dump complete --- diff --git a/src/components/Assessment.tsx b/src/components/Assessment.tsx index eddd8e2..c630726 100644 --- a/src/components/Assessment.tsx +++ b/src/components/Assessment.tsx @@ -145,6 +145,10 @@ export default class Assessment extends React.Component(array: Array): void { let j, x, i; + if (!array) { + return; + } + for (i = array.length - 1; i > 0; i--) { j = Math.floor(Math.random() * (i + 1)); x = array[i]; @@ -153,7 +157,9 @@ export default class Assessment extends React.Component(certification.questions); + for (let i = 0; certification.questions && i < certification.questions.length; i++) { let question = certification.questions[i]; @@ -175,7 +181,7 @@ export default class Assessment extends React.Component { - this.shuffleAnswers(data); + this.shuffleCertification(data); this.setState({certification: data as Certification, session: this.getDefaultState().session, activeQuestion: 0}); }); @@ -333,6 +339,7 @@ export default class Assessment extends React.Component +

Version {this.state.certification.version}

{this.state.certification.name}

diff --git a/src/components/CertificationManagement.tsx b/src/components/CertificationManagement.tsx index 81c8fcc..6294851 100644 --- a/src/components/CertificationManagement.tsx +++ b/src/components/CertificationManagement.tsx @@ -47,6 +47,7 @@ export default class CertificationManagement extends React.Component + Is Published {this.state.certification.questions ? (this.state.certification.questions.map((q, index) => ( this.onQuestionChange(index, q)} requestDeletion={() => this.deleteQuestion(index)} question={q} key={q.id} />) diff --git a/src/components/CertificationOverview.tsx b/src/components/CertificationOverview.tsx index 26d92ae..a7f6b26 100644 --- a/src/components/CertificationOverview.tsx +++ b/src/components/CertificationOverview.tsx @@ -77,6 +77,7 @@ export default class CertificationOverview extends React.Component +

Version {this.state.certification.version}

{this.state.certification.name}

{this.state.certification.questions ? (this.state.certification.questions.map(q => () diff --git a/src/components/PortalManagement.tsx b/src/components/PortalManagement.tsx index ed2c8f0..f92d0c9 100644 --- a/src/components/PortalManagement.tsx +++ b/src/components/PortalManagement.tsx @@ -21,49 +21,6 @@ export default class PortalManagement extends React.Component { - return results.json(); - }) - .then((users: Array) => { - this.setState({ - users: users - }); - }); - } - - fetchPosts(){ - return fetch("/posts", - { - credentials: 'include' - }) - .then(results => { - return results.json(); - }) - .then((posts: Array) => { - this.setState({ - posts: posts - }); - }); - } - - componentDidMount(){ - this.fetchUsers(); - this.fetchPosts(); - } - - setInput(e: any) { - this.setState({postInput: e.target.value}); } render(){ @@ -87,36 +44,13 @@ export default class PortalManagement extends React.Component - - - - - - - - - - - - {this.state.users.map(u => { return ()})} - -
UsernameFirst NameLast NameE-MailIs Admin
+

Groups - In construction

- - - - - - - - - {this.state.posts.map(p => { return ()})} - -
TitleCreated On
+
diff --git a/src/components/PostEditView.tsx b/src/components/PostEditView.tsx index d0caab9..e5a9d51 100644 --- a/src/components/PostEditView.tsx +++ b/src/components/PostEditView.tsx @@ -4,6 +4,8 @@ import DbPost from "../model/DbPost"; import IBaseProps from "../domain/IBaseProps"; import * as ReactMarkdown from "react-markdown"; import MessageBar from "./MessageBar"; +import * as CodeMirror from "react-codemirror"; +import * as uuid from "uuid/v4"; interface PostEditViewState { post: DbPost; @@ -24,6 +26,7 @@ export default class PostEditView extends React.PureComponent { + this.setState({ + errors: [], + message: "Successfully deleted post" + }); + }) + .catch(err => { + this.setState({ + errors: [err] + }); + }); + } + save(){ - let postId = this.props.match.params.postId; + let postId = this.state.post.id; + let headers = new Headers(); + headers.set("Content-Type", "application/json"); fetch(`/posts/${postId}`, { method: "POST", credentials: 'include', - body: JSON.stringify(this.state.post) + body: JSON.stringify(this.state.post), + headers: headers }) - .then(results => { - return results.json(); - }) - .then((posts: Array) => { + .then(() => { this.setState({ errors: [], message: "Successfully saved post" @@ -90,16 +120,17 @@ export default class PostEditView extends React.PureComponent + + + - -