Commit 7302e815 authored by Devinda's avatar Devinda

add automatic_question/ lessonandexampage page

parent 8ad7b64d
......@@ -74,7 +74,7 @@ questionRouter.route('/update/:id').post((req, res) => {
});
});
questionRouter.route('/lessonNo/:id').get(function (req, res) {
questionRouter.route('c').get(function (req, res) {
console.log("Product Item ID");
console.log(req.params.id);
let id = req.params.id;
......
......@@ -2,36 +2,113 @@ import React, { Component } from 'react';
import axios from 'axios';
//import swal from 'sweetalert';
import { Link } from "react-router-dom";
import swal from "sweetalert";
export default class Automatic_question extends Component {
constructor(props){
super(props);
this.onChangeLessonNo = this.onChangeLessonNo.bind(this);
this.onChangeLessonName = this.onChangeLessonName.bind(this);
this.onChangeDefultMark = this.onChangeDefultMark.bind(this);
this.onChangeFeedBack = this.onChangeFeedBack.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.state = {
lesson_no : '',
lesson_name : '',
defult_mark : '',
general_feedback : '',
}
}
onChangeLessonNo(e){
this.setState({
lesson_no :e.target.value
});
}
onChangeLessonName(e){
this.setState({
lesson_name :e.target.value
});
}
onChangeDefultMark(e){
this.setState({
defult_mark :e.target.value
});
}
onChangeFeedBack(e){
this.setState({
general_feedback :e.target.value
});
}
onSubmit(e){
e.preventDefault();
//if(this.state.item_name != null && this.state.item_description != null && this.state.item_category != null && this.state.item_quantity != null && this.state.item_price){
console.log(`Form submitted:`);
console.log(`Lesson Name: ${this.state.lesson_name}`);
console.log(`Lesson No: ${this.state.lesson_no}`);
console.log(`Defualt mark: ${this.state.defult_mark}`);
console.log(`Genaral Feedback: ${this.state.general_feedback}`);
const newQuestion = {
lesson_no : this.state.lesson_no,
lesson_name : this.state.lesson_name,
defult_mark : this.state.defult_mark,
general_feedback : this.state.general_feedback,
};
axios.post('http://127.0.0.1:5000/generate')
.then(res => {this.setState({
question_id: res.data.question_id})
})
.catch(//swal("Good job!", "You clicked the button!", "warning"
);
swal("Data Saved Successfully!", "Your Details has been Saved Successfully!", "success");
}
render() {
return (
<div className="container">
<form onSubmit={this.onSubmit}>
<div className="row">
<div className="col-sm-5">
<label>Lesson name: </label>
<label>Lesson no: </label>
<div style={{padding: '0px'}}>
<input type="text" required className="form-control"
onChange={event => this.setState({ })}
<input type="text" required
className="form-control"
value={this.state.lesson_no}
onChange={this.onChangeLessonNo}
/>
</div>
</div>
<div className="col-sm-5">
<label>Lesson no: </label>
<label>Lesson name: </label>
<div style={{padding: '0px'}}>
<input type="text" required className="form-control"
onChange={event => this.setState({ })}
/>
<input type="text" required
className="form-control"
value={this.state.lesson_name}
onChange={this.onChangeLessonName}
/>
</div>
</div>
<div className="col-sm-5">
<label>defult_mark: </label>
<div style={{padding: '0px'}}>
<input type="text" required className="form-control"
onChange={event => this.setState({ })}
<input type="text" required
className="form-control"
value={this.state.defult_mark}
onChange={this.onChangeDefultMark}
/>
</div>
</div>
......@@ -39,8 +116,10 @@ export default class Automatic_question extends Component {
<div className="col-sm-5">
<label>general_feedback: </label>
<div style={{padding: '0px'}}>
<input type="text" required className="form-control"
onChange={event => this.setState({ })}
<input type="text" required
className="form-control"
value={this.state.general_feedback}
onChange={this.onChangeFeedBack}
/>
</div>
</div>
......
......@@ -20,6 +20,7 @@ export default class LessonAndExam extends Component {
let quizLessonTemp = []
axios.get('http://localhost:5000/')
.then(response => {
console.log(response);
this.setState({ lessonList: response.data.images });
console.log(this.state.lessonList.length)
})
......
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