Skip to content

Commit

Permalink
Added Question Creator Page With Option to Select Number of Quiz Ques…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
pkumar1025 committed May 29, 2024
1 parent 933a578 commit 729447f
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 22 deletions.
7 changes: 5 additions & 2 deletions stanford/frontend/assets/js/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import UserDashboardApi from "./containers/UserDashboardApi";
import Quiz from "./containers/quiz/Quiz";
import Settings from "./containers/SettingsContainer";
import {startTime, changePage} from "./actions/Actions";
import Instructor from "./containers/InstructorContainer"
import {ComingSoon} from "./components/dashboard/ComingSoon.jsx"
import Instructor from "./containers/InstructorContainer";
import {ComingSoon} from "./components/dashboard/ComingSoon.jsx";
import {QuestionCreator} from "./components/dashboard/QuestionCreator.jsx";

// import {DemoPage} from "./components/dashboard/DemoPage.jsx"

history.listen(
Expand All @@ -36,6 +38,7 @@ export class App extends React.Component {
<Route path="/dashboard/settings" component={Settings}/>
<Route path="/dashboard/instructor" component={Instructor}/>
<Route path="/dashboard/quiz/:quizId" component={Quiz}/>
<Route path="/dashboard/QuestionCreator" component={QuestionCreator} />
{/* <Route path="/dashboard/demo" component={DemoPage}/>
*/} </div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class MainDashboard extends React.Component {
</Tabs>;
} else {
// TODO: Replace the # below with an internal link to the course selection page
return <h6>You aren't currently enrolled in a course. Sign up for one <a href="/dashboard/settings">here</a>!</h6>
return <h6>You aren't currently enrolled in a course. Sign up for one <a href="/dashboard/questioncreator">here</a>!</h6>
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* Styles for Question Creator */

/* Header */
.header {
text-align: center;
margin-top: 20px;
}

/* Form container */
.form-container {
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
width: 80%;
max-width: 800px;
}

/* Form label */
.form-label {
font-weight: bold;
}

/* Form input */
.form-input {
padding: 8px;
border: 1px solid #ccc;
border-radius: 5px;
transition: border-color 0.3s;
}

.form-input:focus {
border-color: #003366; /* Dark blue color when focused */
}

/* Form select */
.form-select {
padding: 8px;
border: 1px solid #ccc;
border-radius: 5px;
transition: border-color 0.3s;
appearance: none;
}

.form-select:focus {
border-color: #003366; /* Dark blue color when focused */
}

/* Answer option */
.answer-option {
margin-right: 10px;
}

/* Submit button */
.submit-button {
background-color: #003366; /* Dark blue color */
color: #fff; /* Text color */
padding: 10px 20px; /* Adjust padding as needed */
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}

.submit-button:hover {
background-color: #001a33; /* Darker blue color on hover */
}

/* Dark blue submit button */
.submit-button-dark {
background-color: #003366; /* Dark blue color */
color: #fff; /* Text color */
padding: 10px 20px; /* Adjust padding as needed */
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}

.submit-button-dark:hover {
background-color: #001a33; /* Darker blue color on hover */
}
109 changes: 109 additions & 0 deletions stanford/frontend/assets/js/components/dashboard/QuestionCreator.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React from 'react';
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
import "react-tabs/style/react-tabs.css";
import { Container } from "reactstrap";


export class QuestionCreator extends React.Component {
constructor(props) {
super(props);
this.state = {
numQuestions: 1, // Default to 1 question
questions: []
};
}

handleNumQuestionsChange = (event) => {
this.setState({ numQuestions: event.target.value });
};

handleSubmit = (event) => {
event.preventDefault();
const questions = Array.from({ length: this.state.numQuestions }, (_, index) => ({
id: index + 1,
question: '',
author: '',
difficulty: 'easy',
answers: ['', '', '', '']
}));
this.setState({ questions });
};

renderQuestionFields = () => {
return this.state.questions.map((question, index) => (
<div key={index} className="question-section">
<div className="d-flex align-items-center question-fields">
<div style={{ marginRight: '10px' }}>
<label className="form-label">Question #{question.id}:</label>
<input type="text" className="form-input" style={{ width: '500px' }} />
</div>
<div style={{ marginRight: '10px' }}>
<label className="form-label">Author:</label>
<input type="text" className="form-input" style={{ width: '300px' }} />
</div>
<div>
<label className="form-label">Difficulty:</label>
<select className="form-select">
<option value="easy">Easy</option>
<option value="medium">Medium</option>
<option value="hard">Hard</option>
</select>
</div>
</div>
<div className="d-flex align-items-center answer-fields">
<div className="answer-option mr-3">
<label className="form-label">Answer 1:</label>
<input type="text" className="form-input" style={{ height: '50px', width: '200px' }} />
</div>
<div className="answer-option mr-3">
<label className="form-label">Answer 2:</label>
<input type="text" className="form-input" style={{ height: '50px', width: '200px' }} />
</div>
<div className="answer-option mr-3">
<label className="form-label">Answer 3:</label>
<input type="text" className="form-input" style={{ height: '50px', width: '200px' }} />
</div>
<div className="answer-option">
<label className="form-label">Answer 4:</label>
<input type="text" className="form-input" style={{ height: '50px', width: '200px' }} />
</div>
</div>
<br />
<br />
<br />
</div>
));
};

render() {
return (
<Container className="vh-100 d-flex flex-column" style={{ backgroundColor: '#d8e6ff' }}>
<div>
<h1 className="header">Question Creator</h1>
</div>
<div className="form-container">
<b className="form-label">Enter Number of Questions Here:</b>
<form onSubmit={this.handleSubmit}>
<div className="d-flex align-items-center mt-2">
<input
name="numQuestions"
type="number"
min="1"
value={this.state.numQuestions}
onChange={this.handleNumQuestionsChange}
className="form-input mr-2"
/>
<button type="submit" className="submit-button">Submit</button>
</div>
</form>
<br />
{this.renderQuestionFields()}
{/* Submit button at the bottom */}
<div className="d-flex justify-content-center">
<button className="submit-button-dark">Submit</button>
</div>
</div>
</Container>
);
}
}
19 changes: 0 additions & 19 deletions stanford/frontend/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,25 +139,6 @@ <h3>Save Lives</h3>
</div>
</section>

<section class="text-center">
<br>
<br>
<h3>COVID-19 Content Update Video</h3>
<br>
<br>
<div class="container">
<div class="row">
<div class="col">
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" src="https://www.youtube.com/embed/vBCmBHM96BU" width="200"
height="200" allowfullscreen=""></iframe>
</div>
</div>
</div>
</div>

</section>

<section class="text-center">
<br>
<br>
Expand Down

0 comments on commit 729447f

Please sign in to comment.