Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Qa quiz #316

Closed
wants to merge 28 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
General updates
  • Loading branch information
Cliff Eby committed Nov 4, 2014
commit 26a40693e77daa1163edf52db8fe1322060fd025
18 changes: 13 additions & 5 deletions app/models/qa.server.model.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,10 @@ var mongoose = require('mongoose'),
//
var AnswerSchema = new mongoose.Schema({
text: String,
selectedAnswer: Boolean});
selectedAnswer: {
type: Boolean,
default: false
}});
/**
* Qa Schema
*/
@@ -20,10 +23,15 @@ var QaSchema = new Schema({
type: Date,
default: Date.now
},
question: {
type: String,
default: '',
trim: true
selected: {
type: Boolean,
default: false
},
question: {
type: String,
default: '',
trim: true

},
questionNumber: {
type: String,
26 changes: 26 additions & 0 deletions app/models/quiz.server.model.js
Original file line number Diff line number Diff line change
@@ -39,6 +39,32 @@ var QuizSchema = new Schema({
default: '',
trim: true
},
hintOn: {
type: Boolean,
default: false,
trim: true
},
timeOn: {
type: Boolean,
default: false,
trim: true
},
fifty50On: {
type: Boolean,
default: false,
trim: true
},
randomizeQuestionsOn: {
type: Boolean,
default: false,
trim: true
},
randomizeAnswersOn: {
type: Boolean,
default: false,
trim: true

},
qa: [{ type: Schema.ObjectId, ref: 'Qa' }]

});
6 changes: 2 additions & 4 deletions public/modules/qas/views/edit-qa.client.view.html
Original file line number Diff line number Diff line change
@@ -26,16 +26,14 @@ <h1>Edit Qa</h1>
<button type='button' class='btn2' ng-click='deleteChoice($event)'>{{$index+1}}</button>
</span>
</div>
</div>


<div class="form-group">
<button type="button" class="btn btn-default" ng-click="addChoice()">
<span class="glyphicon glyphicon-plus"></span> Add another
</button>

</div>


<section class='col-md-6'>
<div class="form-group">
<label class="control-label" for="content">Image URL</label>
@@ -100,4 +98,4 @@ <h1>Edit Qa</h1>
</div>
</form>
</div>
</section>
</section>
43 changes: 39 additions & 4 deletions public/modules/quizzes/controllers/quizzes.client.controller.js
Original file line number Diff line number Diff line change
@@ -5,15 +5,20 @@ angular.module('quizzes').controller('QuizzesController', ['$scope', '$statePara
'Authentication', 'Quizzes','Qas','qasInitService',
function($scope, $stateParams, $location, Authentication, Quizzes,Qas, qasInitService ) {
$scope.authentication = Authentication;

$scope.difficultyDropdown = qasInitService.difficultyDropdown();
// Create new Quiz
$scope.create = function() {
// Create new Quiz object
var quiz = new Quizzes ({
name: this.name,
category: this.category,
keyWords: this.keyWords,
quizNumber: this.quizNumber
quizNumber: this.quizNumber,
hintOn: this.hintOn,
timeOn: this.timeOn,
fifty50On: this.fifty50On,
randomizeQuestionsOn: this.randomizeQuestionsOn,
randomizeAnswersOn: this.randomizeAnswersOn
});

// Redirect after save
@@ -28,6 +33,11 @@ angular.module('quizzes').controller('QuizzesController', ['$scope', '$statePara
this.keyWords = '';
this.category = '';
this.quizNumber = '';
this.hintOn = "";
this.timeOn = "";
this.fifty50On = "";
this.randomizeQuestionsOn = "";
this.randomizeAnswersOn = "";
};

// Remove existing Quiz
@@ -69,10 +79,35 @@ angular.module('quizzes').controller('QuizzesController', ['$scope', '$statePara

// Find existing Quiz
$scope.findOne = function() {
$scope.quiz = Quizzes.get({
var quiz;
var qas = Qas.query();
quiz = Quizzes.get({
quizId: $stateParams.quizId
});
console.log("from quuizctrl.findOne",$scope.quiz);
$scope.quiz = quiz;
$scope.qas = qas;
$scope.quiz.qa = [];

//if (qas.choices[0].selectedAnswer)
//{
// $scope.qas.sAnswer[0]=qas[0].choices[0].text
//};
$scope.todos =qas;
//[
// {text:'learn angular', done:true, a:[1,2]},
// {text:'build an angular app', done:false, a:[3,2]}];

console.log('todo',qas,Object.keys($scope.todos).length,$scope.todos);
var oldTodos = $scope.todos;
$scope.todos = [];
angular.forEach(oldTodos, function(todo) {
$scope.todos.push(todo);
});

console.log($scope.todos);


console.log("from quuizctrl.findOne",$scope.quiz,$scope.quiz.qa);
};
}
]);
16 changes: 14 additions & 2 deletions public/modules/quizzes/views/create-quiz.client.view.html
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ <h1>New Quiz</h1>
<div class="col-md-12">
<form class="form-horizontal" data-ng-submit="create()" novalidate>
<fieldset>
<div class="form-group">
<div class="col-md-6 form-group">
<label class="control-label" for="name">Name</label>
<div class="controls">
<input type="text" data-ng-model="name" id="name" class="form-control" placeholder="Name" required>
@@ -17,7 +17,19 @@ <h1>New Quiz</h1>
<input type="text" data-ng-model="quizNumber" id="number" class="form-control" placeholder="Number" required>

</div>
</div>
<div class="col-m-6">
<br/>
<select ng-model="dd" ng-options=" dp2.label for dp2 in difficultyDropdown" data-style="btn-primary" bs-select>
<option value=""> Difficulty
</select>{{dd.label}}
<input type='checkbox' data-ng-model='qa.hintOn'>Allow Hint</input>
<input type='checkbox' data-ng-model='qa.timeOn'>Timed</input></br>
<input type='checkbox' data-ng-model='qa.fifty50On'>50/50</input>
<input type='checkbox' data-ng-model='qa.randomizeAnswersOn'>Randomize Answers</input></br>
<input type='checkbox' data-ng-model='qa.randomizeQuestionsOn'>Randomize Questions</input>
</div>

<div class="form-group">
<input type="submit" class="btn btn-default">
</div>
@@ -27,4 +39,4 @@ <h1>New Quiz</h1>
</fieldset>
</form>
</div>
</section>
</section>
8 changes: 3 additions & 5 deletions public/modules/quizzes/views/edit-quiz.client.view.html
Original file line number Diff line number Diff line change
@@ -19,11 +19,9 @@ <h1>Edit Quiz1</h1>
</div>
</div>
<br/>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li ng-repeat="dp2 in difficultyDropdown">
<a>{{dp2.label}}</a>
</li>
</ul>
<select ng-model="dd" ng-options=" dp2.label for dp2 in difficultyDropdown" data-style="btn-primary" bs-select>
<option value=""> Difficulty
</select>{{dd.label}}
<input type='checkbox' data-ng-model='qa.hintOn'>Allow Hint</input>
<input type='checkbox' data-ng-model='qa.timeOn'>Timed</input></br>
<input type='checkbox' data-ng-model='qa.fifty50On'>50/50</input>