@pie-element/rubric 8.2.2-beta.4 → 8.2.2-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,73 +0,0 @@
1
- var lib = {};
2
-
3
- var interopRequireDefault = {exports: {}};
4
-
5
- (function (module) {
6
- function _interopRequireDefault(e) {
7
- return e && e.__esModule ? e : {
8
- "default": e
9
- };
10
- }
11
- module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
12
- }(interopRequireDefault));
13
-
14
- var defaults = {};
15
-
16
- Object.defineProperty(defaults, "__esModule", {
17
- value: true
18
- });
19
- defaults.default = void 0;
20
- defaults.default = {
21
- points: ['', '', '', ''],
22
- sampleAnswers: [null, null, null, null],
23
- maxPoints: 3,
24
- maxPointsEnabled: true,
25
- excludeZero: false,
26
- excludeZeroEnabled: true
27
- };
28
-
29
- var _interopRequireDefault = interopRequireDefault.exports;
30
- Object.defineProperty(lib, "__esModule", {
31
- value: true
32
- });
33
- var model_1 = lib.model = model;
34
- var validate_1 = lib.validate = validate;
35
- var _defaults = _interopRequireDefault(defaults);
36
- const normalize = model => ({
37
- ..._defaults.default,
38
- ...model
39
- });
40
- function model(model, session, env) {
41
- return new Promise(resolve => {
42
- const modelResult = normalize(model || {});
43
- resolve(env && env.role && env.role === 'instructor' ? modelResult : {});
44
- });
45
- }
46
- function markupToText(s) {
47
- return (s || '').replace(/(<([^>]+)>)/gi, '');
48
- }
49
-
50
- // IMPORTANT! If you make any changes to this function, please make sure you also update complex-rubric/controller/validateSimpleRubric function!“.
51
- function validate(model) {
52
- const {
53
- points
54
- } = model;
55
- const errors = {};
56
- const pointsDescriptorsErrors = {};
57
- (points || []).forEach((point, index) => {
58
- if (!point || point === '<div></div>') {
59
- pointsDescriptorsErrors[index] = 'Points descriptors cannot be empty.';
60
- } else {
61
- const identicalPointDescr = points.slice(index + 1).some(p => markupToText(p) === markupToText(point));
62
- if (identicalPointDescr) {
63
- pointsDescriptorsErrors[index] = 'Points descriptors should be unique.';
64
- }
65
- }
66
- });
67
- if (Object.keys(pointsDescriptorsErrors).length > 0) {
68
- errors.pointsDescriptorsErrors = pointsDescriptorsErrors;
69
- }
70
- return errors;
71
- }
72
-
73
- export { lib as default, model_1 as model, validate_1 as validate };
package/module/demo.js DELETED
@@ -1,33 +0,0 @@
1
- import Configure from './configure.js';
2
- import Element from './element.js';
3
- import * as controller from './controller.js';
4
-
5
- var generate = {};
6
-
7
- generate.model = (id, element) => ({
8
- id,
9
- element,
10
- points: ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'],
11
- sampleAnswers: [null, 'just right', 'not left', null],
12
- maxPoints: 3,
13
- excludeZero: false,
14
- });
15
-
16
- const { model } = generate;
17
-
18
- var config = {
19
- elements: {
20
- 'pie-rubric': '../..',
21
- },
22
- models: [model('1', 'pie-rubric')],
23
- };
24
-
25
- //Note: demo-el is a custom element loaded in the markup.
26
- customElements.whenDefined("demo-el").then(() => {
27
- config.models.forEach((m) => {
28
- const de = document.createElement("demo-el");
29
- document.body.appendChild(de);
30
- de.def = { tagName: m.element, Element, Configure, controller };
31
- de.model = m;
32
- });
33
- });
package/module/element.js DELETED
@@ -1 +0,0 @@
1
- import{_dll_react as e,_dll_mui__material_styles as t,_dll_mui__material as n,_dll_mui__material_collapse as i,_dll_pie_lib__render_ui as r,_dll_prop_types as o,_dll_react_dom_client as l,_dll_debug as s}from"../../../@pie-lib/shared-module@^5.1.1/module/index.js";import{_dll_pie_lib__math_rendering as a}from"../../../@pie-lib/math-rendering-module@^5.0.4/module/index.js";const c=e,{styled:d}=t,{ListItem:h}=n,{List:p}=n,m=i,{color:u}=r,{UiLayout:g}=r,x=o,b=d(g)({color:u.text(),backgroundColor:u.background(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:"8px 12px",textAlign:"left"},"& ul p, & ol p":{marginBottom:0,marginTop:0,lineHeight:"normal"}}),_=d(h)({display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"12px 0px"}),f=d("div")({color:u.text()}),y=d("h3")({color:u.text(),fontSize:"16px",fontWeight:"700",margin:0,paddingBottom:"6px"}),k=d("h4")({color:u.text(),fontSize:"16px",fontWeight:"normal",margin:0,paddingBottom:"6px"}),S=d("h2")(({theme:e})=>({display:"flex",alignItems:"center",cursor:"pointer",userSelect:"none",fontSize:e.typography.fontSize,fontWeight:"500",color:u.tertiary(),margin:0})),E=d("span")({display:"inline-flex",transition:"transform 0.2s",marginLeft:2,alignSelf:"center"}),w=d("h2")({position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",border:0,whiteSpace:"nowrap"}),C=x.shape({excludeZero:x.bool,points:x.arrayOf(x.string),sampleAnswers:x.arrayOf(x.string),animationsDisabled:x.bool});class v extends c.Component{__init(){this.dudUrl="javascript:;"}constructor(e){super(e),v.prototype.__init.call(this),v.prototype.__init2.call(this),this.state={rubricOpen:!1,linkPrefix:"Show"},this.toggleRubric=this.toggleRubric.bind(this)}static __initStatic(){this.propTypes={model:x.object.isRequired,animationsDisabled:x.bool,value:C}}toggleRubric(){this.setState({rubricOpen:!this.state.rubricOpen}),this.setState({linkPrefix:this.state.rubricOpen?"Show":"Hide"})}__init2(){this.shouldRenderPoint=(e,t)=>!t.excludeZero||0!==e}render(){const{model:e,value:t}=this.props;let{animationsDisabled:n}=this.props;if(n=n||t.animationsDisabled,t&&t.points){const{extraCSSRules:i}=e||{},{points:r,sampleAnswers:o}=t,l=c.createElement(p,{component:"nav"},r.slice(0).reverse().map((e,n)=>{n=r.length-n-1;const i=t.excludeZero?n+1:n;return c.createElement(c.Fragment,{key:n},c.createElement(_,{key:`P${n}`},c.createElement(y,null,1===i?`${i} PT`:`${i} PTS`),c.createElement(f,{dangerouslySetInnerHTML:{__html:e}})),o&&o[n]&&c.createElement(_,{key:`S${n}`},c.createElement(k,null,"Sample Answer"),c.createElement(f,{dangerouslySetInnerHTML:{__html:o[n]}})))}));return c.createElement(b,{extraCSSRules:i},c.createElement(w,null,"Rubric"),n?l:c.createElement(c.Fragment,null,c.createElement(S,{id:"rubric-toggle",tabIndex:0,role:"button","aria-expanded":this.state.rubricOpen,onClick:this.toggleRubric,onKeyPress:e=>{"Enter"!==e.key&&" "!==e.key||this.toggleRubric()}},this.state.linkPrefix," Rubric",c.createElement(E,{"aria-hidden":"true"},this.state.rubricOpen?c.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},c.createElement("polyline",{points:"18 15 12 9 6 15"})):c.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},c.createElement("polyline",{points:"6 9 12 15 18 9"})))),c.createElement(m,{in:this.state.rubricOpen,timeout:{enter:225,exit:195}},l)))}return null}}v.__initStatic();const R=e,{createRoot:L}=l,M=s,{renderMath:O}=a;class P extends HTMLElement{constructor(){super(),M.log("constructor called"),this.onModelChanged=this.onModelChanged.bind(this),this._root=null}set model(e){this._model=e,this._render()}onModelChanged(e){this._model=e,this._render()}connectedCallback(){this._render()}_render(){if(this._model){const e=R.createElement(v,{value:this._model});this._root||(this._root=L(this)),this._root.render(e),queueMicrotask(()=>{O(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{P as default};
package/module/index.html DELETED
@@ -1,21 +0,0 @@
1
-
2
- <!doctype html>
3
- <html>
4
- <head>
5
- <title>@pie-element/rubric@8.1.0-next.1</title>
6
- <script
7
- type="module"
8
- src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
9
-
10
- <link
11
- href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
12
- rel="stylesheet"
13
- />
14
- <style>
15
- html, body {
16
- font-family: 'Roboto', sans-serif;
17
- }
18
- </style>
19
- <script type="module" src="./demo.js"></script>
20
- </head>
21
- </html>
@@ -1,14 +0,0 @@
1
- {
2
- "name": "@pie-element/rubric",
3
- "version": "8.1.0-next.1",
4
- "modules": [
5
- {
6
- "name": "@pie-lib/shared-module",
7
- "version": "^5.1.1"
8
- },
9
- {
10
- "name": "@pie-lib/math-rendering-module",
11
- "version": "^5.0.4"
12
- }
13
- ]
14
- }
@@ -1,71 +0,0 @@
1
- import PrintElement from './print.js';
2
-
3
- var generate = {};
4
-
5
- generate.model = (id, element) => ({
6
- id,
7
- element,
8
- points: ['nothing right', 'a teeny bit right', 'mostly right', 'bingo'],
9
- sampleAnswers: [null, 'just right', 'not left', null],
10
- maxPoints: 3,
11
- excludeZero: false,
12
- });
13
-
14
- const { model } = generate;
15
-
16
- var config = {
17
- elements: {
18
- 'pie-rubric': '../..',
19
- },
20
- models: [model('1', 'pie-rubric')],
21
- };
22
-
23
- // new init - just shows off print!
24
-
25
- const init = async () => {
26
- console.log('define the element...');
27
- await Promise.all(
28
- config.models.map(async (m) => {
29
- try {
30
- const printTag = `${m.element}-print`;
31
- if (customElements.get(printTag)) {
32
- return true;
33
- } else {
34
- customElements.define(printTag, PrintElement);
35
- await customElements.whenDefined(printTag);
36
- return true;
37
- }
38
- } catch (e) {
39
- return false;
40
- }
41
- })
42
- );
43
-
44
- console.log('now apply the model...');
45
- config.models.forEach((m) => {
46
- const printTag = `${m.element}-print`;
47
- const h3s = document.createElement('h3');
48
- h3s.textContent = 'student mode';
49
- document.body.appendChild(h3s);
50
- const de = document.createElement(printTag);
51
- document.body.appendChild(de);
52
- de.options = {};
53
- de.model = m;
54
-
55
- const h3 = document.createElement('h3');
56
- h3.textContent = 'instructor mode';
57
- document.body.appendChild(h3);
58
- const instr = document.createElement(printTag);
59
- document.body.appendChild(instr);
60
- instr.options = { mode: 'instructor' };
61
- instr.model = JSON.parse(JSON.stringify(m));
62
- });
63
- };
64
-
65
- init()
66
- .then(() => {
67
- console.log('ready');
68
- })
69
- .catch((e) => {
70
- console.error(e);
71
- });
package/module/print.html DELETED
@@ -1,18 +0,0 @@
1
-
2
- <!doctype html>
3
- <html>
4
- <head>
5
- <title>@pie-element/rubric@8.1.0-next.1</title>
6
- <link
7
- href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
- rel="stylesheet"
9
- />
10
- <style>
11
- html, body {
12
- font-family: 'Roboto', sans-serif;
13
- }
14
- </style>
15
- <script type="module" src="./print-demo.js"></script>
16
- </head>
17
- <body></body>
18
- </html>
package/module/print.js DELETED
@@ -1 +0,0 @@
1
- import{_dll_react as e,_dll_mui__material_styles as t,_dll_mui__material as n,_dll_mui__material_collapse as r,_dll_pie_lib__render_ui as i,_dll_prop_types as o,_dll_debug as l,_dll_react_dom_client as a}from"../../../@pie-lib/shared-module@^5.1.1/module/index.js";import{_dll_pie_lib__math_rendering as s}from"../../../@pie-lib/math-rendering-module@^5.0.4/module/index.js";var c="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,p=c||u||Function("return this")(),d=p.Symbol,h=Object.prototype,m=h.hasOwnProperty,f=h.toString,g=d?d.toStringTag:void 0;var b=Object.prototype.toString;var v=d?d.toStringTag:void 0;function x(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":v&&v in Object(e)?function(e){var t=m.call(e,g),n=e[g];try{e[g]=void 0;var r=!0}catch(e){}var i=f.call(e);return r&&(t?e[g]=n:delete e[g]),i}(e):function(e){return b.call(e)}(e)}var y=/\s/;var _=/^\s+/;function S(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&y.test(e.charAt(t)););return t}(e)+1).replace(_,""):e}function k(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var E=/^[-+]0x[0-9a-f]+$/i,j=/^0b[01]+$/i,O=/^0o[0-7]+$/i,w=parseInt;function T(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==x(e)}(e))return NaN;if(k(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=k(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=S(e);var n=j.test(e);return n||O.test(e)?w(e.slice(2),n?2:8):E.test(e)?NaN:+e}var R=function(){return p.Date.now()},L=Math.max,C=Math.min;function M(e,t,n){var r,i,o,l,a,s,c=0,u=!1,p=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function h(t){var n=r,o=i;return r=i=void 0,c=t,l=e.apply(o,n)}function m(e){var n=e-s;return void 0===s||n>=t||n<0||p&&e-c>=o}function f(){var e=R();if(m(e))return g(e);a=setTimeout(f,function(e){var n=t-(e-s);return p?C(n,o-(e-c)):n}(e))}function g(e){return a=void 0,d&&r?h(e):(r=i=void 0,l)}function b(){var e=R(),n=m(e);if(r=arguments,i=this,s=e,n){if(void 0===a)return function(e){return c=e,a=setTimeout(f,t),u?h(e):l}(s);if(p)return clearTimeout(a),a=setTimeout(f,t),h(s)}return void 0===a&&(a=setTimeout(f,t)),l}return t=T(t)||0,k(n)&&(u=!!n.leading,o=(p="maxWait"in n)?L(T(n.maxWait)||0,t):o,d="trailing"in n?!!n.trailing:d),b.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=s=i=a=void 0},b.flush=function(){return void 0===a?l:g(R())},b}const P=e,{styled:D}=t,{ListItem:I}=n,{List:W}=n,$=r,{color:A}=i,{UiLayout:B}=i,H=o,N=D(B)({color:A.text(),backgroundColor:A.background(),"&:not(.MathJax) table":{borderCollapse:"collapse"},"&:not(.MathJax) table td, &:not(.MathJax) table th":{padding:"8px 12px",textAlign:"left"},"& ul p, & ol p":{marginBottom:0,marginTop:0,lineHeight:"normal"}}),z=D(I)({display:"flex",flexDirection:"column",alignItems:"flex-start",padding:"12px 0px"}),F=D("div")({color:A.text()}),J=D("h3")({color:A.text(),fontSize:"16px",fontWeight:"700",margin:0,paddingBottom:"6px"}),U=D("h4")({color:A.text(),fontSize:"16px",fontWeight:"normal",margin:0,paddingBottom:"6px"}),Z=D("h2")(({theme:e})=>({display:"flex",alignItems:"center",cursor:"pointer",userSelect:"none",fontSize:e.typography.fontSize,fontWeight:"500",color:A.tertiary(),margin:0})),q=D("span")({display:"inline-flex",transition:"transform 0.2s",marginLeft:2,alignSelf:"center"}),K=D("h2")({position:"absolute",width:"1px",height:"1px",padding:0,margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)",border:0,whiteSpace:"nowrap"}),G=H.shape({excludeZero:H.bool,points:H.arrayOf(H.string),sampleAnswers:H.arrayOf(H.string),animationsDisabled:H.bool});class Q extends P.Component{__init(){this.dudUrl="javascript:;"}constructor(e){super(e),Q.prototype.__init.call(this),Q.prototype.__init2.call(this),this.state={rubricOpen:!1,linkPrefix:"Show"},this.toggleRubric=this.toggleRubric.bind(this)}static __initStatic(){this.propTypes={model:H.object.isRequired,animationsDisabled:H.bool,value:G}}toggleRubric(){this.setState({rubricOpen:!this.state.rubricOpen}),this.setState({linkPrefix:this.state.rubricOpen?"Show":"Hide"})}__init2(){this.shouldRenderPoint=(e,t)=>!t.excludeZero||0!==e}render(){const{model:e,value:t}=this.props;let{animationsDisabled:n}=this.props;if(n=n||t.animationsDisabled,t&&t.points){const{extraCSSRules:r}=e||{},{points:i,sampleAnswers:o}=t,l=P.createElement(W,{component:"nav"},i.slice(0).reverse().map((e,n)=>{n=i.length-n-1;const r=t.excludeZero?n+1:n;return P.createElement(P.Fragment,{key:n},P.createElement(z,{key:`P${n}`},P.createElement(J,null,1===r?`${r} PT`:`${r} PTS`),P.createElement(F,{dangerouslySetInnerHTML:{__html:e}})),o&&o[n]&&P.createElement(z,{key:`S${n}`},P.createElement(U,null,"Sample Answer"),P.createElement(F,{dangerouslySetInnerHTML:{__html:o[n]}})))}));return P.createElement(N,{extraCSSRules:r},P.createElement(K,null,"Rubric"),n?l:P.createElement(P.Fragment,null,P.createElement(Z,{id:"rubric-toggle",tabIndex:0,role:"button","aria-expanded":this.state.rubricOpen,onClick:this.toggleRubric,onKeyPress:e=>{"Enter"!==e.key&&" "!==e.key||this.toggleRubric()}},this.state.linkPrefix," Rubric",P.createElement(q,{"aria-hidden":"true"},this.state.rubricOpen?P.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},P.createElement("polyline",{points:"18 15 12 9 6 15"})):P.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},P.createElement("polyline",{points:"6 9 12 15 18 9"})))),P.createElement($,{in:this.state.rubricOpen,timeout:{enter:225,exit:195}},l)))}return null}}Q.__initStatic();const V=e,{createRoot:X}=a,Y=l,{renderMath:ee}=s,te=Y("pie-element:rubric:print");class ne extends HTMLElement{constructor(){super(),this._options=null,this._model=null,this._session=[],this._root=null,this._rerender=M(()=>{if(this._model&&this._session){const t=(e=this._model,"instructor"===this._options.role?(e.value={...e},e.mode="evaluate",e.animationsDisabled=!0,e):{}),n=this._options&&V.createElement(Q,{...t});this._root||(this._root=X(this)),this._root.render(n),queueMicrotask(()=>{te("render complete - render math"),ee(this)})}else te("skip");var e},50,{leading:!1,trailing:!0})}set options(e){this._options=e}set model(e){this._model=e,this._rerender()}connectedCallback(){}disconnectedCallback(){this._root&&this._root.unmount()}}export{ne as default};