Commit 7d09bcd9 authored by Jayasith H.B.C's avatar Jayasith H.B.C

Merge branch 'IT19079264' into 'master'

It19079264

See merge request !124
parents 6c8ea0b8 7e0ad93d
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="database" uuid="8d770d62-9fb6-4013-a5cd-9e7552c294c7">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:D:\Nanduni.Bsc\research_code\2022-158\backend\database.db</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
<libraries>
<library>
<url>file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.39.2/sqlite-jdbc-3.39.2.jar</url>
</library>
</libraries>
</data-source>
</component>
</project>
\ No newline at end of file
...@@ -14,25 +14,24 @@ submission = Blueprint('submissions', __name__, url_prefix='/api/v1/submissions' ...@@ -14,25 +14,24 @@ submission = Blueprint('submissions', __name__, url_prefix='/api/v1/submissions'
@submission.post('/upload') @submission.post('/upload')
@jwt_required()
def upload_submission(): def upload_submission():
user_id = get_jwt_identity() user_id = 1
image = request.files['file'] image = request.files['file']
json_data = json.loads(request.form['data']) # json_data = json.loads(request.form['jsondata'])
submission_type = json_data['type'] # submission_type = json_data['type']
assignment_id = json_data['id'] # assignment_id = json_data['id']
comment = json_data['comment'] # comment = json_data['comment']
if submission_type is None or image is None or assignment_id is None: if image is None:
return jsonify({'err': 'invalid request '}), HTTP_400_BAD_REQUEST return jsonify({'err': 'invalid request '}), HTTP_400_BAD_REQUEST
elif submission_type == 'use case': elif image.filename == 'usecase.jpg':
use_case_obj = save_submission(assignment_id, image, submission_type, comment, user_id) use_case_obj = save_submission(1, image, "use case", "comment", user_id)
model_object_detection(image.filename, use_case_obj.id) model_object_detection(image.filename, use_case_obj.id)
return jsonify({'message': 'upload successful '}), HTTP_200_OK return jsonify({'message': 'upload successful '}), HTTP_200_OK
elif submission_type == 'class': elif image.filename == 'class.jpg':
class_obj = save_submission(assignment_id, image, submission_type, comment, user_id) class_obj = save_submission(1, image, "class", "comment", user_id)
component_separation(image.filename, class_obj.id) component_separation(image.filename, class_obj.id)
return jsonify({'id': str(class_obj.id)}), HTTP_200_OK return jsonify({'id': str(class_obj.id)}), HTTP_200_OK
else: else:
......
...@@ -14,7 +14,7 @@ import tensorflow as tf ...@@ -14,7 +14,7 @@ import tensorflow as tf
from config.database import db from config.database import db
from models.actor_and_use_case import ActorANDUseCase from models.actor_and_use_case import ActorANDUseCase
# pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe' pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'
from services.extend_include_relationship_detection_service import detect_extend_include_relationship from services.extend_include_relationship_detection_service import detect_extend_include_relationship
from services.generalization_relationship_detection_service import detect_generalization_relationship from services.generalization_relationship_detection_service import detect_generalization_relationship
......
...@@ -40,14 +40,14 @@ const StudentDashboard = () => { ...@@ -40,14 +40,14 @@ const StudentDashboard = () => {
const renderOrderBody = (item, index) => ( const renderOrderBody = (item, index) => (
<tr key={index}> <tr key={index}>
<td>{index + 1}</td> <td>{}</td>
<td>{item.id}</td> <td>{item.id}</td>
<td>{item.code}</td> <td>{item.code}</td>
<td>{item.name}</td> <td>{item.name}</td>
<td>{item.assignment_type}</td> <td>{item.assignment_type}</td>
<td>{item.title}</td> <td>{item.title}</td>
<td>{new Date(item.start_at).toLocaleString()}</td> <td>{new Date(item.start_at).toLocaleString()}</td>
<td>{new Date(item.end_at).toLocaleString()}</td> <td>{new Date(item.updated_at).toLocaleString()}</td>
</tr> </tr>
); );
...@@ -56,10 +56,14 @@ const StudentDashboard = () => { ...@@ -56,10 +56,14 @@ const StudentDashboard = () => {
const res = await axios.get(`assignments`); const res = await axios.get(`assignments`);
setStudentSubjects(res.data.assignments); setStudentSubjects(res.data.assignments);
setIsLoading(false); setIsLoading(false);
} catch (err) { } catch (err) {
console.log(err.response); console.log(err.response);
} }
}; };
console.log(StudentSubjects);
useEffect(() => getAllSubjects(), []); useEffect(() => getAllSubjects(), []);
return ( return (
...@@ -130,13 +134,14 @@ const StudentDashboard = () => { ...@@ -130,13 +134,14 @@ const StudentDashboard = () => {
{/* {isLoading ? ( {/* {isLoading ? (
<Spinner /> <Spinner />
) : orderDetails.length > 0 ? ( */} ) : orderDetails.length > 0 ? ( */}
{StudentSubjects.length !== 0?
<Table <Table
limit="5" limit="5"
headData={fields} headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)} renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={StudentSubjects} bodyData={StudentSubjects}
renderBody={(item, index) => renderOrderBody(item, index)} renderBody={(item, index) => renderOrderBody(item, index)}
/> />:''}
{/* ) : ( {/* ) : (
<> <>
{setError("No Assignments found")} {setError("No Assignments found")}
......
...@@ -29,6 +29,8 @@ const StudentSubjectAssingment = () => { ...@@ -29,6 +29,8 @@ const StudentSubjectAssingment = () => {
const [Id, setId] = useState(""); const [Id, setId] = useState("");
const [ItemName, setItemName] = useState(""); const [ItemName, setItemName] = useState("");
const [Description, setDescription] = useState(""); const [Description, setDescription] = useState("");
const [data, setData] = useState({id:"1",comment:"comment",type:"use case"});
const [file, setFile] = useState(null);
const [Order, setOrder] = useState({ const [Order, setOrder] = useState({
item: {}, item: {},
...@@ -51,28 +53,26 @@ const StudentSubjectAssingment = () => { ...@@ -51,28 +53,26 @@ const StudentSubjectAssingment = () => {
} }
}; };
const fileHandler = (e) =>{
const selectedFile = e.target.files[0];
setFile(selectedFile);
}
useEffect(() => { useEffect(() => {
FetchData(); FetchData();
}, []); }, []);
const deleteHandler = async (id) => { const upload = async (e) => {
console.log(id); console.log(data);
try { console.log(file);
const res = await axios.delete(`/orders/delete/${id}`);
if (res.statusText === "OK") {
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
}
};
const orderHandler = async () => {
try { try {
console.log(Order); const formData = new FormData();
const res = await axios.post("/orders", Order); formData.append("jsondata", data);
formData.append("file", file);
console.log(formData);
const res = await axios.post("/submissions/upload", formData);
if (res.statusText === "OK") { if (res.statusText === "OK") {
window.location.reload(); console.log(res.data);
} }
} catch (Err) { } catch (Err) {
console.log(Err.response); console.log(Err.response);
...@@ -131,7 +131,7 @@ const StudentSubjectAssingment = () => { ...@@ -131,7 +131,7 @@ const StudentSubjectAssingment = () => {
<MdDelete <MdDelete
onClick={() => { onClick={() => {
if (window.confirm("Are you sure to delete this request?")) { if (window.confirm("Are you sure to delete this request?")) {
deleteHandler(item._id);
} }
}} }}
/> />
...@@ -251,15 +251,13 @@ const StudentSubjectAssingment = () => { ...@@ -251,15 +251,13 @@ const StudentSubjectAssingment = () => {
style={{ float: "right" }} style={{ float: "right" }}
accept=".png, .jpg, .jpeg" accept=".png, .jpg, .jpeg"
type="file" type="file"
onChange={(e) => onChange={fileHandler}
setOrder({ ...Order, quantity: e.target.value })
}
required required
/> />
</div> </div>
</div> </div>
<div className="row-user"> <div className="row-user">
<button type="submit">Submit</button> <button type="submit" onClick={upload}>Submit</button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -16,15 +16,12 @@ const SubjectsStudent = () => { ...@@ -16,15 +16,12 @@ const SubjectsStudent = () => {
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
const [StudentSubjects, setStudentSubjects] = useState([]); const [StudentSubjects, setStudentSubjects] = useState([]);
const fields = [ const fields = [
"",
"ID", "ID",
"Module Code", "Module Code",
"Module Name", "Module Name",
"Assignment Type", "Assignment Type",
"Title", "Title",
"Start At", "",
"End At",
"Actions",
]; ];
const renderOrderHead = (item, index) => <th key={index}>{item}</th>; const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
...@@ -68,13 +65,14 @@ const SubjectsStudent = () => { ...@@ -68,13 +65,14 @@ const SubjectsStudent = () => {
{/* {isLoading ? ( {/* {isLoading ? (
<Spinner /> <Spinner />
) : orderDetails.length > 0 ? ( */} ) : orderDetails.length > 0 ? ( */}
{StudentSubjects.length !==0?
<Table <Table
limit="5" limit="5"
headData={fields} headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)} renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={StudentSubjects} bodyData={StudentSubjects}
renderBody={(item, index) => renderOrderBody(item, index)} renderBody={(item, index) => renderOrderBody(item, index)}
/> />:''}
{/* ) : ( {/* ) : (
<> <>
{setError("No Assignments found")} {setError("No Assignments found")}
......
...@@ -47,7 +47,7 @@ const Routes = () => { ...@@ -47,7 +47,7 @@ const Routes = () => {
<Route exact path="/auth/student/modules" component={SubjectsStudent} /> <Route exact path="/auth/student/modules" component={SubjectsStudent} />
<Route exact path="/auth/student/services" component={ManageServices} /> <Route exact path="/auth/student/services" component={ManageServices} />
<Route exact path="/auth/student/assignment" component={StudentSubjectAssingment} /> <Route exact path="/auth/student/assignment/:id" 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