Skip to content

Commit

Permalink
added dependencies angular boostrap jquery
Browse files Browse the repository at this point in the history
  • Loading branch information
wgermaine committed Jan 23, 2017
1 parent c72307d commit 907feaf
Show file tree
Hide file tree
Showing 9 changed files with 559 additions and 0 deletions.
20 changes: 20 additions & 0 deletions assets/matchquizdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[{
"qid": 123, // question id - cannot be repeated
"qtype": "matchAns", // either: "oneAns", "typedAns", "matchAns", "dragOneAns", "None"
"qpicture1": "/link", // picture that matches to picture2
"qpicture2": "/link", // picture that matches to picture1
"qtext1": "Text of Picture 1", // picture1 text
"qtext2": "Text of Picture 2", // picture 2 text
// "corrAnsWiki": "Synopsis of wikipedia page", /// possible implementation
"corrAnsDesc": "Description of the answer", // elaboration of ans
},
{
"qid": 123, // question id - cannot be repeated
"qtype": "matchAns", // either: "oneAns", "typedAns", "matchAns", "dragOneAns", "None"
"qpicture1": "/link", // picture that matches to picture2
"qpicture2": "/link", // picture that matches to picture1
"qtext1": "Text of Picture 1", // picture1 text
"qtext2": "Text of Picture 2", // picture 2 text
// "corrAnsWiki": "Synopsis of wikipedia page", /// possible implementation
"corrAnsDesc": "Description of the answer", // elaboration of ans
}]
25 changes: 25 additions & 0 deletions assets/quizdata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[{
"qid": 0, // question id - cannot be repeated
"question":"How do you say 'name' in English?", // required
"qpicture": "/link/image.jpg", // optional img to go along w question
"qtype": "oneAns", // either: "oneAns", "typedAns", "matchAns", "dragOneAns", "None"
"corrAnswer":["Nama", ""], // correct answer - may have alternate answer
// "corrAnsWiki": "Synopsis of wikipedia page", /// possible implementation
"corrAnsDesc": "Description of the answer", // elaboration of ans
"othAnswer1": "Ans1", // other incorrect answers
"othAnswer2": "Ans2",
"othAnswer3": "Ans3"
},
{
"qid": 1, // question id - cannot be repeated
"question":"How do you say 'name' in English?", // required
"qpicture": "/link/image.jpg", // optional img to go along w question
"qtype": "oneAns", // either: "oneAns", "typedAns", "matchAns", "dragOneAns", "None"
"corrAnswer":["Nama", ""], // correct answer - may have alternate answer
// "corrAnsWiki": "Synopsis of wikipedia page", /// possible implementation
"corrAnsDesc": "Description of the answer", // elaboration of ans
"othAnswer1": "Ans1", // other incorrect answers
"othAnswer2": "Ans2",
"othAnswer3": "Ans3"
}
]
1 change: 1 addition & 0 deletions css/bootstrap.min.css.map

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="id" data-ng-app="quizApp">
<head>
<title></title>
<meta charset="utf-8" />

<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5
elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the
page via file:// -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<section id="matchAns"
data-ng-app="matchAnsApp">
</section>
<section id="typedAns"
data-ng-app="typedAnsApp">
</section>
<section id="oneAns"
data-ng-app="oneAnsApp">
</section>
<section id="dragOneAns"
data-ng-app="dragOneAnsApp">
</section>

<section id="resultsPage"
data-ng-app="resultsApp">

</section>

<!-- jQuery - required for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.min.js"></script>
<!-- All Bootstrap plug-ins file -->
<script src="js/bootstrap.min.js"></script>
<!–- Basic AngularJS -->
<script src="js/angular.min.js"></script>
</body>
</html>
120 changes: 120 additions & 0 deletions indexApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
var app = angular.module("quizApp");

app.controller("typedAnsCtrl", function($scope, http) {
$scope.displayQuestion = function() {};
$scope.
})


// redirect to Cate page
$scope.redirectCate = function(index)
{
$scope.cateIndex = index;
$scope.homeShow = false;
$scope.cateShow = true;
$scope.cardShow = false;
}
});


// category ctrl
app.controller("cateCtrl", function ($scope)
{
// make new category
$scope.addCate = function()
{
$scope.category.push($scope.newCat);
$scope.newCat = null;
}

// update category
$scope.updateCate = function(cate, cateIndex)
{
$scope.category[cateIndex] = cate;
}

// delete category
$scope.delCate = function(cateIndex)
{
$scope.category.splice(cateIndex, 1);
}
});

// card ctrl
app.controller("cardCtrl", function($scope, $http) {
// make new card in category
$scope.addCard = function()
{
$scope.category[$scope.cateIndex].cards.push($scope.newCard);
$scope.newCard = null;
}

// updates card
$scope.updateCard = function(aCard, cardIndex) {
$scope.category[$scope.cateIndex].cards[cardIndex] = aCard;
}

// delete card
$scope.delCard = function(cardIndex)
{
$scope.category[$scope.cateIndex].cards.splice(cardIndex, 1);
}

// shuffle cards
$scope.shuffleCards = function()
{
$scope.generated = [];
$scope.currentIndex = $scope.category[$scope.cateIndex].cards.length;
$scope.cindex = $scope.category[$scope.cateIndex].cards.length;

while ($scope.cindex >= 1) {
$scope.randIndex = Math.floor(Math.random() * $scope.currentIndex); // add 1 for 1-4
if($scope.generated.includes($scope.category[$scope.cateIndex].cards[$scope.randIndex]) == false) {
$scope.generated.push($scope.category[$scope.cateIndex].cards[$scope.randIndex]);
$scope.cindex -= 1;
}
}
$scope.category[$scope.cateIndex].cards = $scope.generated;
}
});

app.controller("cardTestCtrl", function($scope, $http, $q) {
$scope.cardsRemembered = [];
$scope.iteration = 0;
var cardsIndex = 0;

var url = "data/cards.json";
$http.get(url).then(
function(response) {
$scope.cardsNotRemembered = response.data;
},
function(response) {
// error handling routine
});

var index = cardsIndex;

$scope.changeCardStatus = function(answer) {
$scope.cardDescShow = false;
$scope.iteration += 1;

if ($scope.cardsNotRemembered[$scope.cateIndex].cards.length > 0) {

if(answer == 'yes') {

if ($scope.cardsNotRemembered[$scope.cateIndex].cards.length != 0) {
$scope.cardsRemembered.push($scope.cardsNotRemembered[$scope.cateIndex].cards[index]);

$scope.cardsNotRemembered[$scope.cateIndex].cards.splice(index, 1);
}
}

$scope.currentCardShow = $scope.cardsNotRemembered[$scope.cateIndex].cards[index];
}

// #to_implement Make completed thing a bit final
if ($scope.cardsNotRemembered[$scope.cateIndex].cards.length == 0) {
$scope.finalCardShow = true;
}
}
});
Loading

0 comments on commit 907feaf

Please sign in to comment.