Skip to content

Commit

Permalink
Merge pull request #1: Use Bootstrap framework
Browse files Browse the repository at this point in the history
  • Loading branch information
yell0wsuit authored Dec 15, 2023
2 parents 34c0207 + 0bac50c commit 43d5155
Show file tree
Hide file tree
Showing 23 changed files with 1,082 additions and 1,586 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

The Diagnostic Tests tool help you improve your grammar and vocabulary skills. Each test has a range of questions to test your knowledge, and you can check your answer to see how well you did. After exiting a test, you can go back to the list of tests, see your answers again and retry questions.

![](https://i.imgur.com/RJ1T0MN.png)
![](https://i.imgur.com/m1KyL8r.png)

![](https://i.imgur.com/w0WDJyT.png)

==**Also check out the other tools**==
- [iWriter](https://github.com/yell0wsuit/iWriter): helps learners write effectively in English.
Expand Down
2 changes: 1 addition & 1 deletion db/data_11.json
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@
"rubric": "Look at these sentences. Do determiners A–D follow the same pattern: yes (Y) or no (N)?",
"rwText": ["Y", "N"],
"question": [{
"input_text": "<item>Most nurses</item> are still women. <item>Right</item><br/><est>Most of nurses are still women.</est> <item>Wrong</item><br/><item>Most of the/our/these nurses</item> are still women. <item>Right</item><br/><item>Most of them</item> are still women. <item>Right</item>",
"input_text": "<item>Most nurses</item> are still women. <item>Right</item><br/><s>Most of nurses are still women.</s> <item>Wrong</item><br/><item>Most of the/our/these nurses</item> are still women. <item>Right</item><br/><item>Most of them</item> are still women. <item>Right</item>",
"text": "many",
"answer": {
"right": "Y"
Expand Down
Binary file added images/favicon.ico
Binary file not shown.
313 changes: 222 additions & 91 deletions index.html

Large diffs are not rendered by default.

68 changes: 31 additions & 37 deletions scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var uAnswer = {};
app.controller("mainCtrl", function ($rootScope, $scope, $http, $templateRequest, $compile) {
// $scope.deleteAll = false;
scormApi.getExcercisedata(function (main) {
$(".mloader").hide();
$("#iLoader").addClass("d-none");
$rootScope.main = main.data;
$scope.hoverC = "";
$rootScope.d = {};
Expand All @@ -32,24 +32,20 @@ app.controller("mainCtrl", function ($rootScope, $scope, $http, $templateRequest
$scope.template = "templates/blank.html";
$rootScope.go = function (level, index, _topic) {
mFlag = false;
$(".loader").show();
$("#iLoader").removeClass("d-none");
$rootScope.fIndex = level;
$rootScope.fLevel = index;
$rootScope.main[index]["status"][level] = 2;
scrollToStart();

main_data = $rootScope.main;
$rootScope.loadJson(level, index, _topic);
};

$scope.delete_all = function () {
$(".mloader").show();
$scope.deleteAll = true;
scormApi.deleteMain();
};

$scope.load_section = function () {
$(".header").css("display", "table");
scrollToStart();

if ($(".resultFeedback").length > 0 && typeof uAnswer[$rootScope.fLevel] != "undefined") {
uAnswer[$rootScope.fLevel]["desc"] = $(".resultFeedback").text();
}
Expand Down Expand Up @@ -78,29 +74,29 @@ app.controller("mainCtrl", function ($rootScope, $scope, $http, $templateRequest
$(".template")
.last()
.append(
'<div ng-click="try(' +
'<button type="button" ng-click="try(' +
$rootScope.d.curr +
')" class="btn tryAgain" data-index="' +
')" class="btn btn-secondary tryAgain" data-index="' +
$rootScope.d.curr +
'">Try again</div>'
'">Try again</button>'
);
$rootScope.userStoredAnswer($rootScope.uData[$rootScope.d.curr]);
} else {
$(".current").html(
'<div class="emptyDiv"><div class="noResTitle"><div class="rubric"><span class="rubricNo">' +
($rootScope.d.curr + 1) +
'</span> <span class="rubricText">No results</span></div></div><div ng-click="try(' +
'</span> <span class="rubricText">No results</span></div></div><button type="button" ng-click="try(' +
$rootScope.d.curr +
')" data-index="' +
$rootScope.d.curr +
'" class="btn tryAgain">Try</div></div>'
'" class="btn btn-secondary tryAgain">Try</div></button>'
);
$(".template").removeClass("current").removeClass("template");
}
} else {
if ($rootScope.d.curr < $rootScope.d.size - 1) {
$(".loader").hide();
$(".template").append('<span class="btn endTest">Exit test</span>');
$("#iLoader").addClass("d-none");
$(".template").append('<div class="btn btn-secondary endTest">Exit test</div>');
$(".endTest").bind("click", function () {
$rootScope.$apply(function () {
$scope.results($rootScope.fLevel, $rootScope.fIndex);
Expand All @@ -113,8 +109,9 @@ app.controller("mainCtrl", function ($rootScope, $scope, $http, $templateRequest
//console.log("level-->" + level);
//console.log("index---->" + index);
$(".summaryWrapper").show();
$(".loader").show();
scrollToStart();
$("#iLoader").removeClass("d-none");

$(".summary").empty();
if (typeof index != "undefined") {
$rootScope.fIndex = index;
Expand Down Expand Up @@ -248,8 +245,7 @@ app.controller("mainCtrl", function ($rootScope, $scope, $http, $templateRequest

$rootScope.nextExercise = function () {
scrollToStart();

$(".loader").show();
$("#iLoader").removeClass("d-none");
$scope.disable = false;
if ($rootScope.d.curr < $rootScope.d.size - 1) {
$scope.template = "templates/blank.html";
Expand All @@ -258,7 +254,7 @@ app.controller("mainCtrl", function ($rootScope, $scope, $http, $templateRequest
setTimeout(function () {
$rootScope.resetData();
$scope.template = "templates/" + $rootScope.d.exercise["template"] + ".html";
$(".loader").fadeOut(300);
$("#iLoader").addClass("d-none");
});
} else {
scrollToStart();
Expand All @@ -276,7 +272,7 @@ app.controller("mainCtrl", function ($rootScope, $scope, $http, $templateRequest
});
angular.module("myApp.summaryCtrl", []).controller("summaryCtrl", function ($scope, $rootScope, $filter, $timeout, $templateRequest, $compile) {
$(".myApp").css({ height: "500px", position: "relative", overflow: "hidden" });
$(".loader").show();
$("#iLoader").removeClass("d-none");
var tplC = angular.element(".summary"); //template container
var data = $scope.data.exercise,
c = 0;
Expand All @@ -296,7 +292,7 @@ angular.module("myApp.summaryCtrl", []).controller("summaryCtrl", function ($sco
};

function a() {
$(".loader").show();
$("#iLoader").removeClass("d-none");
$templateRequest("templates/" + data[c].template + ".html").then(function (html) {
$rootScope.d.exercise = data[c];
$rootScope.resetData();
Expand Down Expand Up @@ -326,8 +322,9 @@ angular.module("myApp.summaryCtrl", []).controller("summaryCtrl", function ($sco
//console.log("----------All template loaded---------------");
//console.log("-------------------------");
scrollToStart();

$(".myApp").removeAttr("style");
$(".loader").fadeOut(300);
$("#iLoader").addClass("d-none");
$(".radioRow").find(".iconParent").removeClass("clicked");
if (typeof uAnswer[$rootScope.fLevel] != "undefined" && typeof uAnswer[$rootScope.fLevel]["index"] != "undefined") {
$(".radioRow").eq(uAnswer[$rootScope.fLevel]["index"]).find(".iconParent").addClass("clicked");
Expand Down Expand Up @@ -1308,7 +1305,7 @@ angular.module("myApp.mRadioCtrl", []).controller("mRadioCtrl", function ($scope
$(this)
.find(".radioBtn")
.find(".patch.p_" + right + "")
.css("background-color", "#87b03f");
.css("background-color", "var(--bs-success-border-subtle)");
}
}
if (q[i].answer.hasOwnProperty("feedback")) {
Expand Down Expand Up @@ -1422,7 +1419,7 @@ angular.module("myApp.single_radio", []).controller("single_radio", function ($s
_this
.find(".radioBtn")
.find(".patch.p_" + q.rIndex + "")
.css("background-color", "#87b03f");
.css("background-color", "var(--bs-success-border-subtle)");
}
if (q.answer.hasOwnProperty("feedback")) {
_this.after('<div class="feedback">' + q.answer.feedback.should_be + "</div>");
Expand Down Expand Up @@ -1530,7 +1527,7 @@ angular.module("myApp.mRadioTextCtrl", []).controller("mRadioTextCtrl", function
.find(".radioTxt:contains(" + r_Ans + ")")
.prev()
.prev()
.css("background-color", "#87b03f");
.css("background-color", "var(--bs-success-border-subtle)");

// }
if (q[i].answer.hasOwnProperty("feedback")) {
Expand All @@ -1545,21 +1542,20 @@ angular.module("myApp.mRadioTextCtrl", []).controller("mRadioTextCtrl", function
if ((r_Ans == "Wrong" || r_Ans == "W" || r_Ans == "N" || r_Ans == "Y") && typeof q[i].answer[1] != "undefined") {
if (maxW < $(".questionSet").width()) {
var temp = $compile(
'<div class="radioTxtEntry"><textarea rows="1" class="textEntry userInput" ng-keyup="keypress($event)" style="max-width:' +
'<div class="radioTxtEntry"><textarea rows="1" class="textEntry userInput form-control" ng-keyup="keypress($event)" style="max-width:' +
maxW +
'px" autocorrect="off" autocapitalize="none" spellcheck="false"></textarea></div>'
)($scope);
} else {
var temp = $compile(
'<div class="radioTxtEntry"><textarea rows="1" class="textEntry userInput" ng-keyup="keypress($event)" autocorrect="off" autocapitalize="none" spellcheck="false"></textarea></div>'
'<div class="radioTxtEntry"><textarea rows="1" class="textEntry userInput form-control" ng-keyup="keypress($event)" autocorrect="off" autocapitalize="none" spellcheck="false"></textarea></div>'
)($scope);
}
$(this).after(temp);
}
});
$(".textEntry").autogrow({ vertical: true, horizontal: false, flickering: false });
angular.element(".current .radioBtn").unbind();
scrollToStart();
} else {
$(".current .feedback2").remove();
clicks = 1;
Expand Down Expand Up @@ -1759,13 +1755,10 @@ var checkAns = function (uAns, rAns, exact) {
}
return correct_flag;
};

var scrollToStart = function () {
var targetOffset = $(".mshell").offset().top - 10;
//console.log("targetOffset--->" + targetOffset);
setTimeout(function () {
$("html, body").animate({ scrollTop: targetOffset }, 500);
//$(window).scrollTop(targetOffset);
}, 200);
window.scrollTo({top: targetOffset, behavior: "smooth"});
};

var updateAtag = function () {
Expand All @@ -1776,7 +1769,7 @@ var updateAtag = function () {
temp = "language-terminology";
cLink = "./";
}
$(this).attr("href", '#');
$(this).attr("href");
});
};
var uploadUserData = function (index, level, data) {
Expand All @@ -1798,7 +1791,8 @@ var uploadUserData = function (index, level, data) {
};

$(document).ready(function () {
setTimeout(function () {
scrollToStart();
}, 2500);
scrollToStart();
});

const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))
6 changes: 3 additions & 3 deletions scripts/bootstrap.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ angular
}
});
temp = temp.join(
"<div style='display:inline-block'><textarea rows='1' cols='1' class='gapFill' autocorrect='off' autocapitalize='none' spellcheck='false'></textarea></div>"
"<div style='display:inline-block'><textarea rows='1' cols='1' class='gapFill form-control' autocorrect='off' autocapitalize='none' spellcheck='false'></textarea></div>"
);
return temp;
}
Expand Down
29 changes: 27 additions & 2 deletions scripts/scorm.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
var Scrom = function () {
var _this = this;
this.checkUserAnswer = function (index, cb) {
console.log('stubbed')
};
let controller_status = false;
let dataItem = localStorage.getItem("peu-diagnostic-data_" + index);
if (dataItem !== null) {
controller_status = true;
cb(true);
} else {
cb(false);
}
}

this.getExcercisedata = function (cb) {
const peuDiagnosticData = localStorage.getItem("peu-diagnostic-main");
Expand Down Expand Up @@ -60,4 +67,22 @@ var Scrom = function () {
console.error("Error fetching data:", error);
});
};

function getKeysWithPrefix(prefix) {
return Object.keys(localStorage).filter(key => key.startsWith(prefix));
}
const prefix = "peu-diagnostic-data_";
let keys = getKeysWithPrefix(prefix);
const resetButtonHome = document.getElementById("resetButtonHome");
const modalElement = document.getElementById("confirmResetModal");
const modal = new bootstrap.Modal(modalElement);
if (keys.length > 0) {
resetButtonHome.classList.remove("d-none");
}

document.getElementById("confirmResetButton").addEventListener("click", function () {
localStorage.clear();
modal.hide();
location.reload();
});
};
6 changes: 3 additions & 3 deletions styles/bootstrap.min.css

Large diffs are not rendered by default.

106 changes: 0 additions & 106 deletions styles/reset.css

This file was deleted.

Loading

0 comments on commit 43d5155

Please sign in to comment.