Skip to content

Commit

Permalink
Merge pull request #86 from MatsMoll/develop
Browse files Browse the repository at this point in the history
[ExamSession][iOS Link] Added new exam session mode and link to iOS app
  • Loading branch information
MatsMoll authored Nov 8, 2020
2 parents ef79f87 + 101c5ea commit 107bb7d
Show file tree
Hide file tree
Showing 24 changed files with 827 additions and 474 deletions.
43 changes: 43 additions & 0 deletions Public/assets/images/Download_on_the_App_Store_Badge_NO.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/assets/images/ios/Goal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/assets/images/ios/MultipleChoice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/assets/images/ios/Results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Public/assets/images/ios/Widget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions Public/assets/js/exam/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function startExam(id) {

let url = "/api/exams/" + id + "/start";

fetch(url, {
method: "POST",
headers: {
"Accept": "application/json, text/plain, */*",
"Content-Type" : "application/json"
}
})
.then(function (response) {
if (response.ok) {
return response.json();
} else {
throw new Error(response.statusText);
}
})
.then(function (json) {
let sessionID = json["id"];
window.location.href = "/exam-sessions/" + sessionID + "/tasks/1";
})
}
1 change: 0 additions & 1 deletion Public/assets/js/flash-card/draft/json-data.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function jsonData() {

return new Promise(function (resolve, reject) {
let noteSession = $("#note-session").val();

Expand Down
9 changes: 5 additions & 4 deletions Public/assets/js/flash-card/json-data.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
function jsonData() {
var subtopicId = parseInt($("#card-topic-id").val());
var examPaperSemester = $("#card-exam-semester").val();
var examPaperYear = parseInt($("#card-exam-year").val());
var examID = parseInt($("#card-exam-id").val());
var descriptionValue = description.value();
if (descriptionValue.length == 0) {
descriptionValue = null;
}
var question = $("#card-question").val();
var solutionValue = solution.value();

if (isNaN(examID)) {
examID = null
}
if (isNaN(subtopicId) || subtopicId < 1) {
throw Error("Velg et tema");
}
Expand All @@ -21,8 +23,7 @@ function jsonData() {

return JSON.stringify({
"isTestable" : false,
"examPaperSemester" : examPaperSemester === "" ? null : examPaperSemester,
"examPaperYear" : examPaperYear,
"examID" : examID,
"subtopicId" : subtopicId,
"description" : descriptionValue,
"question" : question,
Expand Down
116 changes: 61 additions & 55 deletions Public/assets/js/flash-card/submit-performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ function revealSolution() {
$("#goal-progress-bar").addClass("bg-success");
}
}
submitPerformance(knowledgeScore, function (){})
}
}

Expand Down Expand Up @@ -66,11 +65,12 @@ function submitAndEndSession() {
function submitPerformance(score, handleSuccess) {

if (isSubmitting) {
console.log("Skipping")
return
}
isSubmitting = true;

var url = "/api/practice-sessions/" + sessionID() + "/submit/flash-card";
var url = "/api/" + sessionType() + "/" + sessionID() + "/submit/typing-task";

fetch(url, {
method: "POST",
Expand All @@ -83,7 +83,7 @@ function submitPerformance(score, handleSuccess) {
.then(function (response) {
isSubmitting = false;
if (response.ok) {
return response.json();
return
} else {
throw new Error(response.statusText);
}
Expand Down Expand Up @@ -151,62 +151,66 @@ function answerJsonData(score) {
}

function estimatedScore(shouldSetScore) {
let url = "/api/practice-sessions/" + sessionID() + "/tasks/" + taskIndex() + "/estimate";
let url = "/api/" + sessionType() + "/" + sessionID() + "/tasks/" + taskIndex() + "/estimate";

$("#estimated-score-card").fadeIn();
$("#estimated-score-card").removeClass("d-none");
$("#estimate-spinner").html('<div class="d-flex justify-content-center"><div class="spinner-border" role="status"><span class="sr-only">Loading...</span></div></div>')

fetch(url, {
method: "POST",
headers: {
"Accept": "application/json, text/plain, */*",
"Content-Type" : "application/json"
},
body: answerJsonData("3")
})
.then(function (response) {
if (response.ok) {
return response.json();
} else {
throw new Error(response.statusText);
}
})
.then(function (json) {
let score = json["score"];
let roundedScore = Math.round(score * 4);
// Setting a default score of 3
submitPerformance(knowledgeScore, function (){
fetch(url, {
method: "POST",
headers: {
"Accept": "application/json, text/plain, */*",
"Content-Type" : "application/json"
},
body: answerJsonData("3")
})
.then(function (response) {
if (response.ok) {
return response.json();
} else {
throw new Error(response.statusText);
}
})
.then(function (json) {
let score = json["score"];
let roundedScore = Math.round(score * 4);

var text = "Vi estimerer at du";
if (shouldSetScore == true) {
registerScore(roundedScore);
}
if (roundedScore >= 4) {
text += " kan denne oppgaven veldig godt 💯"
} else if (roundedScore >= 3) {
text += " kan denne oppgaven godt 🔥"
} else if (roundedScore >= 2) {
text += " kan noe 🙌"
} else {
text += " kanskje burde lese litt mer 🤔"
}

$("#estimate-spinner").addClass("d-none");
$("#answer-estimate").text(text);
$("#answer-estimate").removeClass("d-none");
let improvements = json["improvements"];
if (improvements.lenght != 0) {
$("#estimated-score-card .card-body").append("<br>Kanskje nevn noe mer om dette?<ul>")
}
console.log(improvements);
for (const index in improvements) {
$("#estimated-score-card .card-body").append("<li>" + improvements[index]["word"] + "</li>");
}
if (improvements.lenght != 0) {
$("#estimated-score-card .card-body").append("</ul>")
}
})
.catch(function (error) {
console.log(error)
if (shouldSetScore == true) {
registerScore(roundedScore);
}

var text = "Vi estimerer at du";

if (roundedScore >= 4) {
text += " kan denne oppgaven veldig godt 💯"
} else if (roundedScore >= 3) {
text += " kan denne oppgaven godt 🔥"
} else if (roundedScore >= 2) {
text += " kan noe 🙌"
} else {
text += " kanskje burde lese litt mer 🤔"
}

$("#estimate-spinner").addClass("d-none");
$("#answer-estimate").text(text);
$("#answer-estimate").removeClass("d-none");
let improvements = json["improvements"];
if (improvements.lenght != 0) {
$("#estimated-score-card .card-body").append("<br>Kanskje nevn noe mer om dette?<ul>")
}
for (const index in improvements) {
$("#estimated-score-card .card-body").append("<li>" + improvements[index]["word"] + "</li>");
}
if (improvements.lenght != 0) {
$("#estimated-score-card .card-body").append("</ul>")
}
})
.catch(function (error) {
console.log(error)
})
})
}

Expand All @@ -220,7 +224,7 @@ function loadHints() {
} else if (hintIndex > 0) {
return
}
let url = "/api/practice-sessions/" + sessionID() + "/tasks/" + taskIndex() + "/estimate";
let url = "/api/" + sessionType() + "/" + sessionID() + "/tasks/" + taskIndex() + "/estimate";

fetch(url, {
method: "POST",
Expand Down Expand Up @@ -251,4 +255,6 @@ function revealHint() {
$("<div class='card'><div class='card-body' id='hint-card'></div></div>").hide().appendTo("#main-task-content .col-lg-7").fadeIn();
}
$("<div id='#hint-" + hintIndex + "'><h6>Hint nr: " + (hintIndex + 1) + "</h6><p class='text-dark'>" + hints[hintIndex++]["word"] + "</p></div>").hide().appendTo("#hint-card").fadeIn();
}
}

function sessionType() { return window.location.pathname.split("/")[1]; }
9 changes: 5 additions & 4 deletions Public/assets/js/multiple-choise/json-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ function jsonData() {
if (descriptionValue.length < 1) {
descriptionValue = null;
}
var examPaperSemester = $("#create-multiple-exam-semester").val();
var examPaperYear = parseInt($("#create-multiple-exam-year").val());
var examID = parseInt($("#card-exam-id").val());
var question = $("#create-multiple-question").val();
var isMultipleSelect = $("#create-multiple-select").prop("checked");
var isTestable = $("#create-multiple-testable").prop("checked");
var solutionValue = solution.value();

if (isNaN(examID)) {
examID = null
}
if (isNaN(subtopicId) || subtopicId < 1) {
throw Error("Velg et tema");
}
Expand All @@ -41,8 +43,7 @@ function jsonData() {

return JSON.stringify({
"isTestable" : isTestable,
"examPaperSemester" : examPaperSemester === "" ? null : examPaperSemester,
"examPaperYear" : examPaperYear,
"examID" : examID,
"subtopicId" : subtopicId,
"description" : descriptionValue,
"question" : question,
Expand Down
Loading

0 comments on commit 107bb7d

Please sign in to comment.