Commit 570f7589 authored by inusha maduranga's avatar inusha maduranga

Implimented E-learning Platform Student and Lecturer Registration,Login...

Implimented E-learning Platform Student and Lecturer Registration,Login functions(Front-end and Back-end)
parent ee41a400
/Back-end/E-learning-ws/target/
/Back-end/elearning/target/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>Tomcat</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
<netbeans.compile.on.save>none</netbeans.compile.on.save>
</properties>
</project-shared-configuration>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cdap_2020_027</groupId>
<artifactId>elearning</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>elearning-ws</name>
<description>E-learning Spring Boot </description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- In production build use below dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.cdap_2020_027.elearning;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class ElearningWsApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(ElearningWsApplication.class, args);
}
}
package com.cdap_2020_027.elearning.controller;
import com.cdap_2020_027.elearning.model.CommonResponse;
import com.cdap_2020_027.elearning.model.LoginRequest;
import com.cdap_2020_027.elearning.model.LoginResponse;
import com.cdap_2020_027.elearning.model.SystemUser;
import com.cdap_2020_027.elearning.service.SystemUserServiceImpl;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
*
* @author (IT17119122 ** Liyanage I.M)
*/
@RestController
@CrossOrigin
public class UserController {
@Autowired
SystemUserServiceImpl systemUserServiceImpl;
@RequestMapping(value = "/login", method = RequestMethod.POST)
public ResponseEntity<LoginResponse> login(@RequestBody LoginRequest loginRequest) {
try{
Object systemUser = systemUserServiceImpl.findByUsernameandPassword(loginRequest.getUsername(),loginRequest.getPassword());
if(systemUser == null) {
LoginResponse loginResponse = new LoginResponse();
loginResponse.setResponseCode("LOGIN_FAILED’");
loginResponse.setResponseMessage("Login failed");
return new ResponseEntity<>(loginResponse, HttpStatus.OK);
}
LoginResponse loginResponse = new LoginResponse();
loginResponse.setResponseCode("LOGIN_SUCCESS");
loginResponse.setResponseMessage("Successfully logged in");
loginResponse.setSystemUser(systemUser);
return new ResponseEntity<>(loginResponse, HttpStatus.OK);
} catch (Exception ex) {
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@RequestMapping(value = "/save/systemuser", method = RequestMethod.POST)
public ResponseEntity<CommonResponse> saveSystemUser(@Valid @RequestBody SystemUser systemUser) {
try {
systemUserServiceImpl.saveUser(systemUser);
return new ResponseEntity<>(new CommonResponse("SUCSESS", "Item successfully saved"), HttpStatus.OK);
} catch (Exception ex) {
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}
package com.cdap_2020_027.elearning.model;
/**
*
* @author IT17119122
*/
public class CommonResponse {
private String responseCode;
private String responseText;
public CommonResponse() {
}
public CommonResponse(String responseCode, String responseText) {
this.responseCode = responseCode;
this.responseText = responseText;
}
public String getResponseCode() {
return responseCode;
}
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
public String getResponseText() {
return responseText;
}
public void setResponseText(String responseText) {
this.responseText = responseText;
}
}
package com.cdap_2020_027.elearning.model;
/**
*
* @author (IT17119122 ** Liyanage I.M)
*/
public class LoginRequest {
private String username;
private String password;
public LoginRequest(String username, String password) {
this.username = username;
this.password = password;
}
public LoginRequest() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
package com.cdap_2020_027.elearning.model;
/**
*
* @author (IT17119122 ** Liyanage I.M)
*/
public class LoginResponse {
private String responseCode;
private String responseMessage;
private String type;
private Object systemUser;
public LoginResponse(String responseCode, String responseMessage, String type , Object systemUser) {
this.responseCode = responseCode;
this.responseMessage = responseMessage;
this.systemUser = systemUser;
this.type = type;
}
public LoginResponse() {
}
public String getResponseCode() {
return responseCode;
}
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
public String getResponseMessage() {
return responseMessage;
}
public void setResponseMessage(String responseMessage) {
this.responseMessage = responseMessage;
}
public Object getSystemUser() {
return systemUser;
}
public void setSystemUser(Object systemUser) {
this.systemUser = systemUser;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.cdap_2020_027.elearning.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Table;
import javax.persistence.Id;
/**
*
* @author (IT17119122 ** Liyanage I.M)
*/
@Entity
@Table(name = "systemuser")
public class SystemUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Integer id;
@Column(name = "USERNAME")
private String username;
@Column(name = "PASSWORD")
private String password;
@Column(name = "EMAIL")
private String email;
@Column(name = "TYPE")
private String type;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.cdap_2020_027.elearning.repository;
import com.cdap_2020_027.elearning.model.SystemUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
public interface SystemUserRepository extends JpaRepository<SystemUser, Integer>{
@Query("select su from SystemUser su where su.username = ?1 and su.password = ?2")
SystemUser findByUsernameandPassword(String username,String password);
}
package com.cdap_2020_027.elearning.service;
import com.cdap_2020_027.elearning.model.SystemUser;
import com.cdap_2020_027.elearning.repository.SystemUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
* @author (IT17119122 ** Liyanage I.M)
*/
@Service
public class SystemUserServiceImpl {
@Autowired
SystemUserRepository systemUserRepository;
public SystemUser findByUsernameandPassword(String username,String password) {
SystemUser systemUser = systemUserRepository.findByUsernameandPassword(username,password);
return systemUser;
}
public void saveUser(SystemUser systemUser) {
systemUserRepository.save(systemUser);
}
}
## datasource
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/elearning_db?useUnicode=true&zeroDateTimeBehavior=convertToNull
spring.datasource.initialize=true
spring.datasource.username=root
spring.datasource.password=123
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
server.port = 8090
#Enable multiple application in single tomcat server
spring.jmx.enabled= false
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/elearning"/>
<!DOCTYPE html>
<html>
<head>
<title>Start Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="JSX" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/React_Frontend.iml" filepath="$PROJECT_DIR$/.idea/React_Frontend.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br>
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
This diff is collapsed.
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"bootstrap": "^4.3.1",
"react": "^16.8.6",
"react-bootstrap-table": "^4.3.1",
"react-dom": "^16.8.6",
"react-router-dom": "^5.0.0",
"react-scripts": "3.0.1",
"react-select": "^2.4.3",
"reactstrap": "^8.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
.App {
text-align: center;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 40vmin;
pointer-events: none;
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.divider {
height: 1px;
width:100%;
display:block; /* for use on default inline elements like span */
margin: 9px 0;
overflow: hidden;
background-color: #e5e5e5;
}
import React, { Component } from 'react'
import axios from 'axios'
import './App.css';
import constant from '../src/service/constant';
import Select from 'react-select';
import AsyncSelect from 'react-select/lib/Async';
class App extends Component{
constructor(props) {
super(props)
this.state = {
// LocationList:[],
// startTimeList:[],
startLocation: '',
endLocation: '',
startTime: ''
}
}
changeHandler = (e) => {
this.setState({[e.target.name]: e.target.value })
}
submitHandler = (e) => {
e.preventDefault()
const{startLocation , endLocation , startTime} = this.state
console.log(this.state)
axios.post(constant()+'/findtrain', {startLocation , endLocation , startTime} )
.then(response => {
console.log(response)
if(response.data === ''){
this.props.history.push("/App")
}else{
this.props.history.push({
pathname : '/AddTicket',
state: { detail: response.data }
}
);
}
})
.catch(error => {
console.log(error)
})
}
componentWillMount() {
// e.preventDefault()
axios.get(constant()+'/trarin/location')
.then(response => {
this.setState({
LocationList: response.data
})
}).catch(error => {
console.log(error)
})
console.log(this.LocationList)
axios.get(constant()+'/trarin/starttime')
.then(response => {
this.setState({
startTimeList: response.data
})
}).catch(error => {
console.log(error)
})
}
logOutButtonHandler = () => {
this.props.history.push("/")
}
// renderLocationList() {
// return (this.state.LocationList.map(data =>({label:data,value:data})))
// }
// renderTimeList() {
// return (this.state.startTimeList.map(data =>({label:data,value:data})))
// }
render() {
const { startLocation, endLocation, startTime } = this.state;
// let options = this.state.startLocation.map(function (LocationList) {
// return { value: LocationList, label: LocationList};
// })
return (
<div className="container">
<div className="row">
<div className="col-lg-12">
<div className="panel panel-default">
<div className="panel-heading">
<button type="submit" className="btn btn-outline-danger btn float-right" onClick={this.logOutButtonHandler}>Logout</button>
<h3 className="panel-title">
Train Ticket Reservation
</h3>
</div>
</div>
</div>
</div>
<div className="row">
<div className="col-lg-12">
<div className="panel-body">
<form onSubmit={this.submitHandler}>
<div className="form-group">
<label>Start Location:</label>
{/* <Select options={ this.renderLocationList() } value={startLocation} name="startLocation" onChange={this.changeHandler} placeholder='Select Loaction'/> */}
<input type="text" className="form-control" name="startLocation" value={startLocation} onChange={this.changeHandler} placeholder="Start Location" />
</div>
<div className="form-group">
<label>End Location:</label>
{/* <Select options={ this.renderLocationList() } value={endLocation} name="endLocation" onChange={this.changeHandler} placeholder='Select Loaction'/> */}
<input type="text" className="form-control" name="endLocation" value={endLocation} onChange={this.changeHandler} placeholder="End Location" />
</div>
<div className="form-group">
<label>Start Time:</label>
{/* <Select options={ this.renderTimeList() } value={startTime} name="startTime" onChange={this.changeHandler} placeholder='Select time'/> */}
<input type="text" className="form-control" name="startTime" value={startTime} onChange={this.changeHandler} placeholder="Start Time" />
</div>
<button type="submit" className="btn btn-outline-primary findBtn">Find</button>
</form>
</div>
</div>
</div>
</div>
)
}
}
export default App;
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
import React, { Component } from 'react'
class Lecturer extends Component{
constructor(pros){
super(pros)
this.state = {
}
}
render(){
return(
<div className="container">
<h2>Lecturer Page</h2>
</div>
)
}
}
export default Lecturer
\ No newline at end of file
import React, { Component } from 'react'
import { Link , withRouter} from 'react-router-dom';
import axios from 'axios'
import constant from '../service/constant';
class Login extends Component {
constructor(props) {
super(props)
this.state = {
username: '',
password:''
}
}
changeHandler = (e) => {
this.setState({[e.target.name]: e.target.value })
}
submitHandler = (e) => {
e.preventDefault()
console.log(this.state)
axios.post(constant()+'/login', this.state)
.then(response => {
console.log(response)
if(response.data.systemUser.type === "Student"){
this.props.history.push({
pathname : '/Student',
state: { detail: response.data }
});
}else if(response.data.systemUser.type === "Lecturer"){
this.props.history.push({
pathname : '/Lecturer',
state: { detail: response.data }
});
}else{
this.props.history.push("/")
}
// console.log(response)
// if(response.data.responseCode === "LOGIN_SUCCESS"){
// this.props.history.push({
// pathname : '/UploadPage',
// state: { detail: response.data }
// });
// }else{
// this.props.history.push("/")
// }
})
.catch(error => {
console.log(error)
})
}
registerButtonHandler = () => {
this.props.history.push("/Register")
}
render() {
const { username, password } = this.state;
return (
<div className="container">
<div className="panel panel-default">
<div className="panel-heading">
<h3 className="panel-title">
Login
</h3>
</div>
<div className="panel-body">
<form onSubmit={this.submitHandler}>
<div className="form-group">
<label>User Name:</label>
<input type="text" className="form-control" name="username" value={username} onChange={this.changeHandler} placeholder="User name" required/>
</div>
<div className="form-group">
<label>Password:</label>
<input type="password" className="form-control" name="password" value={password} onChange={this.changeHandler} placeholder="Password" required />
</div>
<button type="submit" className="btn btn-outline-primary loginBtn">Login</button>
<button type="button" className="btn btn-outline-secondary registerBtn" onClick={this.registerButtonHandler}>Register</button>
</form>
</div>
</div>
</div>
)
}
}
export default Login
import React, { Component } from 'react'
import { Link } from 'react-router-dom';
import axios from 'axios'
import constant from '../service/constant';
class Register extends Component {
constructor(props) {
super(props)
this.state = {
username:'',
email:'',
password:'',
typeList:['Lecturer','Student'],
type:'Lecturer'
}
}
changeHandler = (e) => {
const state = this.state
state[e.target.name] = e.target.value;
this.setState(state)
}
userTypeHandler = (e) => {
const state = this.state
state[e.target.name] = e.target.value;
this.setState(state)
}
componentDidMount() {
axios.get(constant()+'/getcourse').then(
data => {
this.setState({
Courses: data.data
})
}
)
}
submitHandler = (e) => {
e.preventDefault()
console.log(this.state)
axios.post(constant()+'/save/systemuser', this.state)
.then(response => {
console.log(response)
if(response.data != ''){
alert(`User added . now you can log in to the system`);
this.props.history.push("/")
}
})
.catch(error => {
console.log(error)
})
}
loginButtonHandler = () => {
this.props.history.push("/")
}
render() {
const { username,email, password, type} = this.state;
return (
<div className="container">
<div className="panel panel-default">
<div className="panel-heading">
<h3 className="panel-title">
User Registration
</h3>
</div>
<div className="panel-body">
<form onSubmit={this.submitHandler}>
<div className="form-group">
<label>User Name:</label>
<input type='text' id="validationCustom01" className="form-control" name="username" value={username} onChange={this.changeHandler} placeholder="User name" pattern="^[a-zA-Z0-9_]+$" title="Enter user name is requird"/>
</div>
<div className="form-group">
<label>Password:</label>
<input type='password' className="form-control" name="password" value={password} onChange={this.changeHandler} placeholder="Password" />
</div>
<div className="form-group">
<label>Email:</label>
<input type='email' className="form-control" name="email" value={email} onChange={this.changeHandler} placeholder="Email" />
</div>
<div className="form-group">
<label>User Type:</label>
<select className="form-control" name="type" onChange={this.userTypeHandler} value={type}>
{
this.state.typeList.map(sub => {
return (
<option key={sub.id} value={sub.id}>{sub} </option>
)
})
}
</select>
</div>
<button type="submit" className="btn btn btn-outline-success registerBtn">Submit</button>
<button type="button" className="btn btn-outline-secondary loginBtn" onClick={this.loginButtonHandler}>Login</button>
</form>
</div>
</div>
</div>
);
}
}
export default Register
import React, { Component } from 'react'
class ResultItem extends Component {
render() {
return (
<tr>
{/* <th scope="row">{index + 1}</th> */}
<td>{this.props.codeLineItem.codeNumber}</td>
<td>{this.props.codeLineItem.lineNumber}</td>
<td>{this.props.codeLineItem.pStatement}</td>
</tr>
)
}
}
export default ResultItem;
import React, { Component } from 'react'
class Student extends Component {
constructor(pros){
super(pros)
this.state = {
}
}
render(){
return(
<div className="container">
<h2>Student Page</h2>
</div>
)
}
}
export default Student;
import React from 'react'
function constant (){
return'http://localhost:8084/elearning'
}
export default constant
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}
.loginBtn {
width: 100px;
margin-right: 20px;
}
.findBtn {
width: 200px;
}
.registerBtn {
width: 100px;
margin-right: 20px;
}
.AppPageHeading {
background-color: #563d7c;
}
.AppBody{
background-color:#d4d4d4;
}
/* .table1Td{
padding-left: 400px;
width: 612px;
} */
.table1{
width:100%;
border: 3px;
text-align: center;
}
.header1{
text-align: center;
}
.tableRow1{
padding-left: 400px;
width: 612px;
}
.tableColumn1{
padding-left: 400px;
width: 612px;
}
.lable1{
padding-left: 220px;
}
.input1{
margin-left: 208px;
width:800px;
}
.button1Div{
text-align: center;
}
.sampathBankBtn {
margin-right: 20px;
width: 200px;
}
.dialogBtn {
margin-right: 20px;
width: 200px;
}
.lable2{
padding-left: 260px;
}
.loginHeder{
background-color: #563d7c;
}
.navBar {
/* background-color: #e3f2fd; */
background-color:#563d7c;
}
.navBarTitle {
color: white;
font-family:"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
}
a:link {
text-decoration: none;
}
.logoutLink {
color: white;
}
h6:hover{
color: blue;
}
.logoutBtn {
text-align: right;
}
.th1{
/* text-align: right; */
width:500px;
}
.td1{
/* text-align: left */
width:500px;
}
.instructorBtn{
width: 200px;
margin-right: 20px;
margin-bottom: 100px;
}
.resultViewBtn {
width: 150px;
margin-right: 20px;
}
\ No newline at end of file
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router, Route ,HashRouter, NavLink } from 'react-router-dom';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import Register from './components/Register';
import Login from './components/Login';
import Student from './components/Student';
import Lecturer from './components/Lecturer';
ReactDOM.render(
<Router>
{/* <div style={secionStyle}> */}
<div>
<nav className="navbar navbar-light navBar" >
<a className="navbar-brand " href="#"><h4 className="navBarTitle">E-Learning Platform</h4></a>
</nav>
<br/>
<Route exact path='/' component={Login} />
<Route path='/Register' component={Register} />
<Route path='/App' component={App} />
<Route path='/Student' component={Student} />
<Route path='/Lecturer' component={Lecturer} />
</div>
{/* </div> */}
</Router>,
document.getElementById('root')
);
serviceWorker.unregister();
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
<g fill="#61DAFB">
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
<circle cx="420.9" cy="296.5" r="45.7"/>
<path d="M520.5 78.1z"/>
</g>
</svg>
import React from 'react'
function constant (){
return'http://localhost:8084/elearning'
}
export default constant
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}
-- phpMyAdmin SQL Dump
-- version 4.7.7
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Mar 18, 2020 at 05:12 PM
-- Server version: 10.1.30-MariaDB
-- PHP Version: 7.2.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `elearning_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `systemuser`
--
CREATE TABLE `systemuser` (
`ID` int(11) NOT NULL,
`USERNAME` varchar(255) NOT NULL,
`PASSWORD` varchar(255) NOT NULL,
`EMAIL` varchar(255) DEFAULT NULL,
`TYPE` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `systemuser`
--
INSERT INTO `systemuser` (`ID`, `USERNAME`, `PASSWORD`, `EMAIL`, `TYPE`) VALUES
(1, 'inusha', '123', 'inusham45@gmail.com', ''),
(2, 'inusham', '123', 'inusham45@gmail.com', ''),
(3, 'naduni', '123', 'naduni@gmail.com', '');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `systemuser`
--
ALTER TABLE `systemuser`
ADD PRIMARY KEY (`ID`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `systemuser`
--
ALTER TABLE `systemuser`
MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
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