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'
@submission.post('/upload')
@jwt_required()
def upload_submission():
user_id = get_jwt_identity()
user_id = 1
image = request.files['file']
json_data = json.loads(request.form['data'])
submission_type = json_data['type']
assignment_id = json_data['id']
comment = json_data['comment']
# json_data = json.loads(request.form['jsondata'])
# submission_type = json_data['type']
# assignment_id = json_data['id']
# 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
elif submission_type == 'use case':
use_case_obj = save_submission(assignment_id, image, submission_type, comment, user_id)
elif image.filename == 'usecase.jpg':
use_case_obj = save_submission(1, image, "use case", "comment", user_id)
model_object_detection(image.filename, use_case_obj.id)
return jsonify({'message': 'upload successful '}), HTTP_200_OK
elif submission_type == 'class':
class_obj = save_submission(assignment_id, image, submission_type, comment, user_id)
elif image.filename == 'class.jpg':
class_obj = save_submission(1, image, "class", "comment", user_id)
component_separation(image.filename, class_obj.id)
return jsonify({'id': str(class_obj.id)}), HTTP_200_OK
else:
......
......@@ -14,7 +14,7 @@ import tensorflow as tf
from config.database import db
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.generalization_relationship_detection_service import detect_generalization_relationship
......
......@@ -40,14 +40,14 @@ const StudentDashboard = () => {
const renderOrderBody = (item, index) => (
<tr key={index}>
<td>{index + 1}</td>
<td>{}</td>
<td>{item.id}</td>
<td>{item.code}</td>
<td>{item.name}</td>
<td>{item.assignment_type}</td>
<td>{item.title}</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>
);
......@@ -56,10 +56,14 @@ const StudentDashboard = () => {
const res = await axios.get(`assignments`);
setStudentSubjects(res.data.assignments);
setIsLoading(false);
} catch (err) {
console.log(err.response);
}
};
console.log(StudentSubjects);
useEffect(() => getAllSubjects(), []);
return (
......@@ -130,13 +134,14 @@ const StudentDashboard = () => {
{/* {isLoading ? (
<Spinner />
) : orderDetails.length > 0 ? ( */}
{StudentSubjects.length !== 0?
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={StudentSubjects}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
/>:''}
{/* ) : (
<>
{setError("No Assignments found")}
......
......@@ -29,6 +29,8 @@ const StudentSubjectAssingment = () => {
const [Id, setId] = useState("");
const [ItemName, setItemName] = 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({
item: {},
......@@ -51,28 +53,26 @@ const StudentSubjectAssingment = () => {
}
};
const fileHandler = (e) =>{
const selectedFile = e.target.files[0];
setFile(selectedFile);
}
useEffect(() => {
FetchData();
}, []);
const deleteHandler = async (id) => {
console.log(id);
try {
const res = await axios.delete(`/orders/delete/${id}`);
if (res.statusText === "OK") {
window.location.reload();
}
} catch (Err) {
console.log(Err.response);
}
};
const orderHandler = async () => {
const upload = async (e) => {
console.log(data);
console.log(file);
try {
console.log(Order);
const res = await axios.post("/orders", Order);
const formData = new FormData();
formData.append("jsondata", data);
formData.append("file", file);
console.log(formData);
const res = await axios.post("/submissions/upload", formData);
if (res.statusText === "OK") {
window.location.reload();
console.log(res.data);
}
} catch (Err) {
console.log(Err.response);
......@@ -131,7 +131,7 @@ const StudentSubjectAssingment = () => {
<MdDelete
onClick={() => {
if (window.confirm("Are you sure to delete this request?")) {
deleteHandler(item._id);
}
}}
/>
......@@ -251,15 +251,13 @@ const StudentSubjectAssingment = () => {
style={{ float: "right" }}
accept=".png, .jpg, .jpeg"
type="file"
onChange={(e) =>
setOrder({ ...Order, quantity: e.target.value })
}
onChange={fileHandler}
required
/>
</div>
</div>
<div className="row-user">
<button type="submit">Submit</button>
<button type="submit" onClick={upload}>Submit</button>
</div>
</div>
</div>
......
......@@ -16,15 +16,12 @@ const SubjectsStudent = () => {
const [isLoading, setIsLoading] = useState(true);
const [StudentSubjects, setStudentSubjects] = useState([]);
const fields = [
"",
"ID",
"Module Code",
"Module Name",
"Assignment Type",
"Title",
"Start At",
"End At",
"Actions",
"",
];
const renderOrderHead = (item, index) => <th key={index}>{item}</th>;
......@@ -68,13 +65,14 @@ const SubjectsStudent = () => {
{/* {isLoading ? (
<Spinner />
) : orderDetails.length > 0 ? ( */}
{StudentSubjects.length !==0?
<Table
limit="5"
headData={fields}
renderHead={(item, index) => renderOrderHead(item, index)}
bodyData={StudentSubjects}
renderBody={(item, index) => renderOrderBody(item, index)}
/>
/>:''}
{/* ) : (
<>
{setError("No Assignments found")}
......
......@@ -47,7 +47,7 @@ const Routes = () => {
<Route exact path="/auth/student/modules" component={SubjectsStudent} />
<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>
);
};
......
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