-
Notifications
You must be signed in to change notification settings - Fork 0
/
StlViewerNode.js
132 lines (119 loc) · 4.16 KB
/
StlViewerNode.js
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
StlViewerNode.prototype = new Node();
StlViewerNode.prototype.constructor = StlViewerNode;
StlViewerNode.prototype.parent = Node.prototype;
/*
* the name that displays in the authoring tool when the author creates a new step
*/
StlViewerNode.authoringToolName = "StlViewer";
/*
* will be seen by the author when they add a new step to their project to help
* them understand what kind of step this is
*/
StlViewerNode.authoringToolDescription = "This step renders STL files";
/**
* This is the constructor for the Node
*
* @param nodeType
* @param view
*/
function StlViewerNode(nodeType, view) {
this.view = view;
this.type = nodeType;
this.prevWorkNodeIds = [];
}
/**
* This function is called when the vle loads the step and parses
* the previous student answers, if any, so that it can reload
* the student's previous answers into the step.
*
* @param stateJSONObj
* @return a new state object
*/
StlViewerNode.prototype.parseDataJSONObj = function(stateJSONObj) {
return StlViewerState.prototype.parseDataJSONObj(stateJSONObj);
};
/**
* This function is called if there needs to be any special translation
* of the student work from the way the student work is stored to a
* human readable form. For example if the student work is stored
* as an array that contains 3 elements, for example
* ["apple", "banana", "orange"]
*
* and you wanted to display the student work like this
*
* Answer 1: apple
* Answer 2: banana
* Answer 3: orange
*
* you would perform that translation in this function.
*
* Note: In most cases you will not have to change the code in this function
*
* @param studentWork
* @return translated student work
*/
StlViewerNode.prototype.translateStudentWork = function(studentWork) {
return studentWork;
};
/**
* This function is called when the student exits the step. It is mostly
* used for error checking.
*
* Note: In most cases you will not have to change anything here.
*/
StlViewerNode.prototype.onExit = function() {
//check if the content panel has been set
if(this.contentPanel) {
if(this.contentPanel.save) {
//tell the content panel to save
this.contentPanel.save();
}
}
};
/**
* Renders the student work into the div. The grading tool will pass in a
* div id to this function and this function will insert the student data
* into the div.
*
* @param divId the id of the div we will render the student work into
* @param nodeVisit the student work
* @param childDivIdPrefix (optional) a string that will be prepended to all the
* div ids use this to prevent DOM conflicts such as when the show all work div
* uses the same ids as the show flagged work div
* @param workgroupId the id of the workgroup this work belongs to
*
* Note: you may need to add code to this function if the student
* data for your step is complex or requires additional processing.
* look at SensorNode.renderGradingView() as an example of a step that
* requires additional processing
*/
StlViewerNode.prototype.renderGradingView = function(divId, nodeVisit, childDivIdPrefix, workgroupId) {
//Get the latest student state object for this step
var stlViewerState = nodeVisit.getLatestWork();
/*
* get the step work id from the node visit in case we need to use it in
* a DOM id. we don't use it in this case but I have retrieved it in case
* someone does need it. look at SensorNode.js to view an example of
* how one might use it.
*/
var stepWorkId = nodeVisit.id;
var studentWork = stlViewerState.getStudentWork();
//put the student work into the div
$('#' + divId).html(studentWork.response);
};
/**
* Get the html file associated with this step that we will use to
* display to the student.
*
* @return a content object containing the content of the associated
* html for this step type
*/
StlViewerNode.prototype.getHTMLContentTemplate = function() {
return createContent('node/stlViewer/stlViewer.html');
};
//Add this node to the node factory so the vle knows it exists.
NodeFactory.addNode('StlViewerNode', StlViewerNode);
//used to notify scriptloader that this script has finished loading
if(typeof eventManager != 'undefined'){
eventManager.fire('scriptLoaded', 'vle/node/stlViewer/StlViewerNode.js');
};