-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplateWorksheetFunction.js
More file actions
78 lines (63 loc) · 1.94 KB
/
Copy pathtemplateWorksheetFunction.js
File metadata and controls
78 lines (63 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//change functionName
function functionName(title,promptQuestion){
//title is title of first page (e.g. adding integers) [STR]
//prompt Question is overarching question for all questions. (e.g. solve, calculate, find x) [STR]
template.createTitle(doc,title);
template.addNameDate(doc);
doc.fontSize(12);
doc.text(promptQuestion);
for(let i=0;i<10;i++){
appendQuestion();
}
template.addLogo(doc);
template.addBorder(doc);
createAnswerKey();
template.addLogo(doc);
template.addBorder(doc);
function appendQuestion(){
let arr=createQuestion();
(window.store).push(arr);
doc.fillColor("black");
doc.text(arr[0],{
});
doc.fillColor("white")
doc.text(arr[1],{
})
doc.moveDown();
}
function createQuestion(){
//=============================================================================Modify Here
//logic for question. question is a string
let question;
window.numb++;
return ["\n"+window.numb+") "+question,createAnswer(question)+"\n"];
}
function createAnswer(arr){
//==============================================================================Modify Here
//logic for answer. Answer is a string.
let answer;
return "Answer: "+answer;
}
function createAnswerKey(){
doc.fillColor("black");
doc.addPage();
doc.fontSize(20).text("Answer Key",{
align:"center",
underline:true,
});
doc.fontSize(12);
for(items of window.store){
doc.fillColor("black");
doc.text(items[0]);
doc.moveDown();
doc.fillColor("red");
doc.text(items[1]);
};
};
// finalize the PDF and end the stream
doc.end();
stream.on('finish', function(){
url = stream.toBlobURL('application/pdf')
document.getElementById("i").src=url;
});
};