-
Notifications
You must be signed in to change notification settings - Fork 0
/
prendus-edit-question.html
213 lines (183 loc) · 15.2 KB
/
prendus-edit-question.html
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<script type="module" src="state/init-state-management.ts"></script>
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="prendus-view-question.html">
<link rel="import" href="text-editor-tools/prendus-variable-tool.html">
<link rel="import" href="text-editor-tools/prendus-fill-in-the-blank-tool.html">
<link rel="import" href="text-editor-tools/prendus-essay-tool.html">
<link rel="import" href="text-editor-tools/prendus-code-tool.html">
<link rel="import" href="text-editor-tools/prendus-multiple-choice-tool.html">
<link rel="import" href="text-editor-tools/prendus-multiple-select-tool.html">
<link rel="import" href="text-editor-tools/prendus-math-tool.html">
<link rel="import" href="text-editor-tools/prendus-image-tool.html">
<link rel="import" href="text-editor-tools/prendus-graph-tool.html">
<link rel="import" href="text-editor-tools/prendus-reset-tool.html">
<link rel="import" href="../../node_modules/juicy-ace-editor/juicy-ace-editor.html">
<link rel="import" href="../../bower_components/polymer/lib/elements/dom-if.html">
<link rel="import" href="../../bower_components/paper-tabs/paper-tabs.html">
<link rel="import" href="../../bower_components/iron-pages/iron-pages.html">
<link rel="import" href="../../bower_components/wysiwyg-e/wysiwyg-e.html">
<link rel="import" href="../../bower_components/iron-icon/iron-icon.html">
<link rel="import" href="../../bower_components/iron-icons/iron-icons.html">
<link rel="import" href="../../bower_components/paper-tooltip/paper-tooltip.html">
<style>
/*TODO To simplify compliance with the licenses, the Ubuntu font face is included directly*/
/*Ubuntu Font License v1.0 PREAMBLE This licence allows the licensed fonts to be used, studied, modified and redistributed freely. The fonts, including any derivative works, can be bundled, embedded, and redistributed provided the terms of this licence are met. The fonts and derivatives, however, cannot be released under any other licence. The requirement for fonts to remain under this licence does not require any document created using the fonts or their derivatives to be published under this licence, as long as the primary purpose of the document is not to be a vehicle for the distribution of the fonts. DEFINITIONS "Font Software" refers to the set of files released by the Copyright Holder(s) under this licence and clearly marked as such. This may include source files, build scripts and documentation. "Original Version" refers to the collection of Font Software components as received under this licence. "Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. "Copyright Holder(s)" refers to all individuals and companies who have a copyright ownership of the Font Software. "Substantially Changed" refers to Modified Versions which can be easily identified as dissimilar to the Font Software by users of the Font Software comparing the Original Version with the Modified Version. To "Propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification and with or without charging a redistribution fee), making available to the public, and in some countries other activities as well. PERMISSION & CONDITIONS This licence does not grant any rights under trademark law and all such rights are reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to propagate the Font Software, subject to the below conditions: 1) Each copy of the Font Software must contain the above copyright notice and this licence. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine- readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. 2) The font name complies with the following: (a) The Original Version must retain its name, unmodified. (b) Modified Versions which are Substantially Changed must be renamed to avoid use of the name of the Original Version or similar names entirely. (c) Modified Versions which are not Substantially Changed must be renamed to both (i) retain the name of the Original Version and (ii) add additional naming elements to distinguish the Modified Version from the Original Version. The name of such Modified Versions must be the name of the Original Version, with "derivative X" where X represents the name of the new work, appended to that name. 3) The name(s) of the Copyright Holder(s) and any contributor to the Font Software shall not be used to promote, endorse or advertise any Modified Version, except (i) as required by this licence, (ii) to acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with their explicit written permission. 4) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this licence, and must not be distributed under any other licence. The requirement for fonts to remain under this licence does not affect any document created using the Font Software, except any version of the Font Software extracted from a document created using the Font Software may only be distributed under this licence. TERMINATION This licence becomes null and void if any of the above conditions are not met. DISCLAIMER THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.*/
/*The MIT License (MIT) Copyright (c) 2015-2016 Ewerton Assis <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/
@import '../ubuntu-fontface/ubuntu.min.css';
/*TODO To simplify compliance with the licenses, the Ubuntu font face is included directly*/
</style>
<dom-module id="prendus-edit-question">
<template>
<style>
.editor {
width: 100%;
height: 50vh;
box-shadow: 0px 0px 3px grey;
margin: 0 auto;
}
.editorContainer {
position: relative;
}
#paperTabs {
width: 100%;
margin: 0 auto;
font-size: calc(50px - 1vw);
--paper-tabs-selection-bar-color: #2a9af2;
--paper-tab-ink: grey;
--paper-tab-content: {
font-family: Ubuntu;
padding: 25px;
}
height: auto;
}
paper-tab {
color: grey;
}
paper-tab.iron-selected {
border: 1px solid rgba(0, 0, 0, .2500);
box-shadow: 0px 0px 3px grey;
color: black;
}
#textEditor {
--wysiwyg-font: Ubuntu;
font-size: calc(40px - 1vw);
}
#codeEditor {
font-size: calc(40px - 1vw);
}
.previewContainer {
box-shadow: 0px 0px 3px grey;
padding: 25px;
margin-top: 25px;
}
.savingText {
color: grey;
position: absolute;
right: 20px;
bottom: 15px;
}
.switchEditorToJavaScriptIcon {
position: absolute;
right: -5px;
top: 40px;
cursor: pointer;
z-index: 1;
}
.switchEditorToAssessMLIcon {
position: absolute;
right: -5px;
top: 0px;
cursor: pointer;
z-index: 1;
background-color: grey;
color: white;
}
</style>
<dom-if if="[[loaded]]">
<template>
<iron-pages id="ironPages" selected="[[selected]]">
<div class="editorContainer">
<paper-button id="switchEditorToJavaScriptIcon" class="switchEditorToJavaScriptIcon" on-click="switchEditorClick">
<iron-icon icon="icons:tab"></iron-icon>
</paper-button>
<paper-tooltip for="switchEditorToJavaScriptIcon" offset="5">
<span>JavaScript</span>
</paper-tooltip>
<wysiwyg-e id="textEditor" class="editor" value="[[_question.text]]" on-value-changed="textEditorChanged" allowed-tag-names="[[getAllowedTagNames()]]">
<dom-if if="[[multipleChoiceTool]]">
<template>
<prendus-multiple-choice-tool id="prendus-multiple-choice-tool" on-insert-radio="insertRadio" user-radios="[[userRadiosFromCode]]" on-radio-correct-changed="radioCorrectChanged" on-radio-content-changed="radioContentChanged" on-question-stem-changed="insertQuestionStem" question="[[_question]]"></prendus-multiple-choice-tool>
</template>
</dom-if>
<dom-if if="[[multipleSelectTool]]">
<template>
<prendus-multiple-select-tool id="prendus-multiple-select-tool" on-insert-check="insertCheck" user-checks="[[userChecksFromCode]]" on-check-correct-changed="checkCorrectChanged" on-check-content-changed="checkContentChanged" on-question-stem-changed="insertQuestionStem" question="[[_question]]"></prendus-multiple-select-tool>
</template>
</dom-if>
<dom-if if="[[fillInTheBlankTool]]">
<template>
<prendus-fill-in-the-blank-tool id="prendus-fill-in-the-blank-tool" on-insert-input="insertInput" user-inputs="[[userInputsFromCode]]" on-input-answer-changed="inputAnswerChanged" question="[[_question]]"></prendus-fill-in-the-blank-tool>
</template>
</dom-if>
<dom-if if="[[essayTool]]">
<template>
<prendus-essay-tool id="prendus-essay-tool" on-insert-essay="insertEssay"></prendus-essay-tool>
</template>
</dom-if>
<dom-if if="[[codeTool]]">
<template>
<prendus-code-tool id="prendus-code-tool" on-insert-code="insertCode"></prendus-code-tool>
</template>
</dom-if>
<dom-if if="[[variableTool]]">
<template>
<prendus-variable-tool id="prendus-variable-tool" on-insert-variable="insertVariable"></prendus-variable-tool>
</template>
</dom-if>
<dom-if if="[[mathTool]]">
<template>
<prendus-math-tool id="prendus-math-tool" on-insert-math="insertMath"></prendus-math-tool>
</template>
</dom-if>
<dom-if if="[[imageTool]]">
<template>
<prendus-image-tool id="prendus-image-tool" on-insert-image="insertImage"></prendus-image-tool>
</template>
</dom-if>
<dom-if if="[[graphTool]]">
<template>
<prendus-graph-tool id="prendus-graph-tool" on-insert-graph="insertGraph"></prendus-graph-tool>
</template>
</dom-if>
<dom-if if="[[resetTool]]">
<template>
<prendus-reset-tool id="prendus-reset-tool" on-reset-text-and-code="resetTextAndCode"></prendus-reset-tool>
</template>
</dom-if>
</wysiwyg-e>
<div class="savingText">[[getSavingText(saving)]]</div>
</div>
<div class="editorContainer">
<paper-button id="switchEditorToAssessMLIcon" class="switchEditorToAssessMLIcon" on-click="switchEditorClick">
<iron-icon icon="icons:tab"></iron-icon>
</paper-button>
<paper-tooltip for="switchEditorToAssessMLIcon" offset="5">
<span>AssessML</span>
</paper-tooltip>
<juicy-ace-editor id="codeEditor" theme="ace/theme/chrome" mode="ace/mode/javascript" class="editor" value="[[_question.code]]" on-change="codeEditorChanged"></juicy-ace-editor>
<div class="savingText">[[getSavingText(saving)]]</div>
</div>
</iron-pages>
<div class="previewContainer">
<prendus-view-question question="[[_question]]"></prendus-view-question>
</div>
</template>
</dom-if>
<dom-if if="[[!loaded]]">
<template>
Loading...
</template>
</dom-if>
</template>
<script type="module" src="prendus-edit-question.ts"></script>
</dom-module>