Commit 13c5bbf2 authored by Weerasinghe D.N.H's avatar Weerasinghe D.N.H

db commit

parent c709d5ff
...@@ -11,6 +11,7 @@ from routes.module_routes import module ...@@ -11,6 +11,7 @@ from routes.module_routes import module
from routes.assignment_routes import assignment from routes.assignment_routes import assignment
from routes.diagram_routes import diagram from routes.diagram_routes import diagram
from routes.submission_routes import submission from routes.submission_routes import submission
from routes.plagiarism_routes import use_case_diagram_plagiarism
APP_ROOT = os.path.dirname(os.path.abspath(__file__)) APP_ROOT = os.path.dirname(os.path.abspath(__file__))
...@@ -47,6 +48,7 @@ app.register_blueprint(module) ...@@ -47,6 +48,7 @@ app.register_blueprint(module)
app.register_blueprint(assignment) app.register_blueprint(assignment)
app.register_blueprint(diagram) app.register_blueprint(diagram)
app.register_blueprint(submission) app.register_blueprint(submission)
app.register_blueprint(use_case_diagram_plagiarism)
@app.before_first_request @app.before_first_request
......
...@@ -10,11 +10,45 @@ const StudentSubjectAssingment = () => { ...@@ -10,11 +10,45 @@ const StudentSubjectAssingment = () => {
const [Loading, setLoading] = useState(false); const [Loading, setLoading] = useState(false);
const [Trigger, setTrigger] = useState(false); const [Trigger, setTrigger] = useState(false);
const [assignment, setAssignment] = useState([]); const [assignment, setAssignment] = useState([]);
const [submission, setSubmission] = useState({
type: "",
comment: "",
id: 2,
file: {},
});
const fileHandler = (e) => {
console.log(e);
setSubmission({ ...submission, file: e.target.files[0] });
console.log(submission);
};
const FetchData = async () => { const FetchData = async () => {
try { try {
const res = await axios.get("assignments/" + id); const res = await axios.get("assignments/" + id);
setAssignment(res.data.assignment); setAssignment(res.data.assignment);
setSubmission({ ...submission, id: id });
if (assignment.assignment_type === 1) {
setSubmission({ ...submission, type: "use case" });
} else if (assignment.assignment_type === 2) {
setSubmission({ ...submission, type: "class" });
} else {
setSubmission({ ...submission, type: "use case" });
}
} catch (error) {
console.log(error.response);
}
};
const onSubmit = async (e) => {
e.preventDefault();
try {
const res = await axios.post("submissions/upload/", submission, {
headers: { token: localStorage.getItem("token") },
});
window.alert("Assignment added successfully");
window.location.reload();
} catch (error) { } catch (error) {
console.log(error.response); console.log(error.response);
} }
...@@ -30,7 +64,7 @@ const StudentSubjectAssingment = () => { ...@@ -30,7 +64,7 @@ const StudentSubjectAssingment = () => {
<div id="main" className="layout__content"> <div id="main" className="layout__content">
<TopNav /> <TopNav />
<div className="layout__content-main"> <div className="layout__content-main">
<h1 className="page-header"> Module Assignments</h1> <h1 className="page-header"> Assignments</h1>
<div className="row"> <div className="row">
<div className="col-12"> <div className="col-12">
<div className="card"> <div className="card">
...@@ -56,13 +90,15 @@ const StudentSubjectAssingment = () => { ...@@ -56,13 +90,15 @@ const StudentSubjectAssingment = () => {
style={{ float: "right" }} style={{ float: "right" }}
accept=".png, .jpg, .jpeg" accept=".png, .jpg, .jpeg"
type="file" type="file"
onChange={(e) => console.log(" submission")} onChange={fileHandler}
required required
/> />
</div> </div>
</div> </div>
<div className="row-user"> <div className="row-user">
<button type="submit">Submit</button> <button type="submit" onClick={onSubmit}>
Submit
</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -63,7 +63,7 @@ const Routes = () => { ...@@ -63,7 +63,7 @@ const Routes = () => {
<Route <Route
exact exact
path="/auth/student/assignment" path="/auth/student/assignment/:id"
component={StudentSubjectAssingment} component={StudentSubjectAssingment}
/> />
</Switch> </Switch>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment