@pie-element/graphing-solution-set 1.8.1-next.0 → 1.8.1-next.1

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 +0,0 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["VALID_GRID_VALUES","PREFERRED_VALID_GRID_VALUES","VALID_LABEL_VALUES","getGridValues","axis","size","prefferedValues","minValue","max","min","maxValue","values","filter","value","getLabelValues","applyConstraints","oldGridValues","oldLabelValues","gridValues","labelValues","step","includes","preferredValues","lowestValue","labelStep","getPlotablePoints","prop","tickValues","tickVal","indexOf","push","Math","round","tV","filterPlotableMarks","domain","range","answers","domainValues","rangeValues","isPointPlotable","x","y","Object","entries","reduce","newAnswers","key","answer","marks","mark","type","points","find","point","from","root","to","edge","building","distance","a","b","Number","sqrt","toFixed","pointInPolygon","polygon","c","inside","clonePolygon","i","length","lineIntersect","x1","y1","x2","y2","x3","y3","x4","y4","ua","denominator","isPointInsideGraph","isPointOnOrInsideGraph","findIntersectionPointForMark","intersectionPoint","tempData","intersection","sortPointsClockWise","sort","cy","cx","center","startAng","forEach","ang","atan2","PI","angle","ccwPoints","reverse","unshift","pop","map","attr","dotProduct","v1","v2","magnitude","v","angleBetweenVectors","dot","magV1","magV2","acos","pointInAngle","commonPoint","point1","point2","testPoint","vector1","vector2","testVector","angle1","angle2","angleSum","tolerance","abs","removeDuplicatesFromArray","array","obj","index","findIndex","o","removeDuplicateAndFilterSections","sections","section","findSectionsInSolutionSetForOneLine","concat","findSectionsInSolutionSetForTwoLines","gssLineData","mark1","mark2","cornerPoints","intersectPoint","intersectionPoint1","intersectionPoint2","j","bucket","newCornerPoints","k","sections1","sections2","o1","some","o2","sections3","findSectionsInSolutionSet","numberOfLines","pointInsidePolygon","num_vertices","p1","p2","x_intersection","checkIfLinesAreAdded"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAEA;AACA,IAAMA,iBAAiB,GAAG,CACxB,IADwB,EA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AGyH,EAAE,CAACzH,CAAR,KAAc0H,EAAE,CAAC3H,CAAH,GAAO0H,EAAE,CAAC1H,CAAxB,CAAD,IAAgC2H,EAAE,CAAC1H,CAAH,GAAOyH,EAAE,CAACzH,CAA1C,IAA+CyH,EAAE,CAAC1H,CAAzE;;AACA,cAAI0H,EAAE,CAAC1H,CAAH,KAAS2H,EAAE,CAAC3H,CAAZ,IAAiBA,CAAC,IAAI4H,cAA1B,EAA0C;AACxChG,YAAAA,MAAM,GAAG,CAACA,MAAV;AACD;AACF;AACF;AACF;;AACD8F,IAAAA,EAAE,GAAGC,EAAL;AACD;;AACD,SAAO/F,MAAP;AACD,CAtBM;AAwBP;AACA;AACA;AACA;AACA;;;;;AACO,IAAMiG,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACxB,WAAD,EAAc9F,MAAd,EAAyB;AAC3D,MAAIA,MAAM,CAACwB,MAAP,KAAkB,CAAtB,EAAyB;AACvB,WAAO,KAAP;AACD;;AACD,MAAIsE,WAAW,CAACkB,aAAZ,KAA8B,CAAlC,EAAqC;AACnC,QAAIhH,MAAM,CAACwB,MAAP,KAAkB,CAAtB,EAAyB;AACvB,aAAO,CAACxB,MAAM,CAAC,CAAD,CAAN,CAAUW,QAAlB;AACD;AACF,GAJD,MAIO;AACL,QAAIX,MAAM,CAACwB,MAAP,KAAkB,CAAtB,EAAyB;AACvB,aAAO,KAAP;AACD,KAFD,MAEO;AACL,aAAO,CAACxB,MAAM,CAAC,CAAD,CAAN,CAAUW,QAAlB;AACD;AACF;AACF,CAfM","sourcesContent":["import isEqual from 'lodash/isEqual';\n\n/*Valid grid values*/\nconst VALID_GRID_VALUES = [\n 0.01, 0.02, 0.04, 0.05, 0.0625, 0.1, 0.125, 0.2, 0.25, 0.5, 1, 2, 3, 4, 5, 8, 10, 12, 15, 20, 40, 50, 64, 100, 500,\n 1000,\n];\n\n// same as VALID_GRID_VALUES but next values are excluded: 0.04, 0.0625, 0.125, 3, 4, 8, 12, 15, 40, 64\nconst PREFERRED_VALID_GRID_VALUES = [0.01, 0.02, 0.05, 0.1, 0.2, 0.25, 0.5, 1, 2, 5, 10, 20, 50, 100, 500, 1000];\n\n/*Valid label values*/\nexport const VALID_LABEL_VALUES = {\n 0.01: [0, 0.01, 0.02, 0.04, 0.05, 0.1],\n 0.02: [0, 0.02, 0.04, 0.1],\n 0.04: [0, 0.04, 0.08, 0.16, 0.2],\n 0.05: [0, 0.05, 0.1, 0.2, 0.25],\n 0.0625: [0, 0.0625, 0.125, 0.25, 0.5],\n 0.1: [0, 0.1, 0.2, 0.4, 0.5, 1],\n 0.125: [0, 0.125, 0.25, 0.5, 1],\n 0.2: [0, 0.2, 0.5, 0.1],\n 0.25: [0, 0.25, 0.5, 1, 2],\n 0.5: [0, 0.5, 1, 2],\n 1: [0, 1, 2, 4, 5, 10],\n 2: [0, 2, 4, 8, 10],\n 3: [0, 3, 6, 12, 15],\n 4: [0, 4, 8, 16, 20],\n 5: [0, 5, 10, 20, 25],\n 8: [0, 8, 16, 32, 40, 64],\n 10: [0, 10, 20, 40, 50, 100],\n 12: [0, 12, 24],\n 15: [0, 15, 30, 60],\n 20: [0, 20, 40, 80, 100],\n 40: [0, 40, 80, 160, 200],\n 50: [0, 50, 100, 200, 250],\n 64: [0, 64, 128],\n 100: [0, 100, 200, 400, 500],\n 500: [0, 500, 1000, 2500],\n 1000: [0, 1000, 2000, 4000, 5000],\n};\n\n/*\n * Function to get grid values\n * @param {Object} axis - axis object\n * @param {Number} size - size of the axis\n * @param {Boolean} prefferedValues - flag to get preffered values\n * */\nexport const getGridValues = (axis, size, prefferedValues = false) => {\n const minValue = (10 * (axis.max - axis.min)) / size;\n const maxValue = minValue * 10;\n const values = prefferedValues ? PREFERRED_VALID_GRID_VALUES : VALID_GRID_VALUES;\n return values.filter((value) => value >= minValue && value <= maxValue);\n};\n\n/*\n * Function to get label values\n * @param {Number} value - value of the axis step\n * */\nexport const getLabelValues = (value) => VALID_LABEL_VALUES[value] || [];\n\n/*\n * Function to apply constraints\n * @param {Object} axis - axis object\n * @param {Number} size - size of the axis\n * @param {Array} oldGridValues - old grid values\n * @param {Array} oldLabelValues - old label values\n * */\nexport const applyConstraints = (axis, size, oldGridValues, oldLabelValues) => {\n const gridValues = getGridValues(axis, size);\n let labelValues = getLabelValues(axis.step);\n if (!isEqual(oldGridValues, gridValues) && !gridValues.includes(axis.step)) {\n const preferredValues = getGridValues(axis, size, true);\n const lowestValue = preferredValues[0] || 1;\n axis.step = lowestValue;\n labelValues = getLabelValues(lowestValue);\n if (!labelValues.includes(axis.labelStep)) {\n axis.labelStep = lowestValue;\n }\n return { gridValues, labelValues };\n }\n if (!isEqual(oldLabelValues, labelValues) && !labelValues.includes(axis.labelStep)) {\n axis.labelStep = axis.step;\n }\n return { gridValues, labelValues };\n};\n\n// also used in pie-lib/graphing/utils as 'getTickValues'\n/*\n * Function to get plotable points\n * @param {Object} prop - axis object\n * */\nconst getPlotablePoints = (prop) => {\n const tickValues = [];\n let tickVal = 0;\n while (tickVal >= prop.min && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal - prop.step) * 10000) / 10000;\n }\n tickVal = Math.round(prop.step * 10000) / 10000;\n while (tickVal <= prop.max && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal + prop.step) * 10000) / 10000;\n }\n // return only ticks that are inside the min-max interval\n if (tickValues) {\n return tickValues.filter((tV) => tV >= prop.min && tV <= prop.max);\n }\n return [];\n};\n\n/*\n * Function to get plotable marks\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * @param {Object} answers - answers object\n * */\nexport const filterPlotableMarks = (domain, range, answers) => {\n const domainValues = getPlotablePoints(domain);\n const rangeValues = getPlotablePoints(range);\n const isPointPlotable = (x, y) => domainValues.includes(x) && rangeValues.includes(y);\n return Object.entries(answers || {}).reduce((newAnswers, [key, answer]) => {\n newAnswers[key] = {\n ...answer,\n marks: (answer.marks || []).filter((mark) => {\n if (mark.type === 'point') {\n return isPointPlotable(mark.x, mark.y);\n }\n if (mark.type === 'polygon') {\n return !mark.points.find((point) => !isPointPlotable(point.x, point.y));\n }\n const from = mark.from || mark.root;\n const to = mark.to || mark.edge;\n return mark.building\n ? isPointPlotable(from.x, from.y)\n : isPointPlotable(from.x, from.y) && isPointPlotable(to.x, to.y);\n }),\n };\n return newAnswers;\n }, {});\n};\n\n//////////////////////////////////////////////////////////////////////////////////\n// BELOW FUNCTIONS ARE USED IN src/utils as well\n//////////////////////////////////////////////////////////////////////////////////\n\n/*\n * Function to calculate the distance between two points\n * @param {Object} a - point a\n * @param {Object} b - point b\n * */\nconst distance = (a, b) => {\n return Number(Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2).toFixed(3));\n};\n\n/*\n * Function to check if a point lies on edges of a polygon\n * @param {Object} point - point object\n * @param {Array} polygon - polygon points array\n * */\nconst pointInPolygon = (point, polygon) => {\n let c = point;\n let inside = false;\n let clonePolygon = [...polygon];\n clonePolygon.push(polygon[0]);\n for (let i = 0; i < clonePolygon.length - 1; i++) {\n let a = clonePolygon[i];\n let b = clonePolygon[i + 1];\n // check if point is on the edge\n if (distance(a, c) + distance(c, b) === distance(a, b)) {\n inside = true;\n break;\n }\n }\n return inside;\n};\n\n/*\n * Function to get the intersection point of two lines\n * @param {Number} x1 - x coordinate of point 1 of line 1\n * @param {Number} y1 - y coordinate of point 1 of line 1\n * @param {Number} x2 - x coordinate of point 2 of line 1\n * @param {Number} y2 - y coordinate of point 2 of line 1\n * @param {Number} x3 - x coordinate of point 1 of line 2\n * @param {Number} y3 - y coordinate of point 1 of line 2\n * @param {Number} x4 - x coordinate of point 2 of line 2\n * @param {Number} y4 - y coordinate of point 2 of line 2\n * */\nconst lineIntersect = (x1, y1, x2, y2, x3, y3, x4, y4) => {\n let ua,\n denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);\n if (denominator === 0) {\n return null;\n }\n ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator;\n return {\n x: Number((x1 + ua * (x2 - x1)).toFixed(3)),\n y: Number((y1 + ua * (y2 - y1)).toFixed(3)),\n };\n};\n\n/*\n * Check if a point is inside the graph\n * @param {Object} point - point object\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst isPointInsideGraph = (point, domain, range) => {\n return point.x > domain.min && point.x < domain.max && point.y > range.min && point.y < range.max;\n};\n\n/*\n * Check if a point is on or inside the graph\n * @param {Object} point - point object\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst isPointOnOrInsideGraph = (point, domain, range) => {\n return point.x >= domain.min && point.x <= domain.max && point.y >= range.min && point.y <= range.max;\n};\n\n/*\n * Find the intersection point of a mark with the graph\n * @param {Object} mark - mark object\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst findIntersectionPointForMark = (mark, domain, range) => {\n let intersectionPoint = [];\n let tempData = [\n [domain.max, range.max, domain.max, range.min],\n [domain.min, range.max, domain.min, range.min],\n [domain.min, range.max, domain.max, range.max],\n [domain.min, range.min, domain.max, range.min],\n ];\n for (let i = 0; i < tempData.length; i++) {\n let intersection = lineIntersect(\n mark.from.x,\n mark.from.y,\n mark.to.x,\n mark.to.y,\n tempData[i][0],\n tempData[i][1],\n tempData[i][2],\n tempData[i][3],\n );\n if (intersection && isPointOnOrInsideGraph(intersection, domain, range)) {\n intersectionPoint.push(intersection);\n }\n }\n return intersectionPoint;\n};\n\n/*\n * Sort points in clockwise direction for a polygon\n * @param {Array} points - points array\n * */\nconst sortPointsClockWise = (points) => {\n // Find min max to get center and Sort from top to bottom\n points.sort((a, b) => a.y - b.y);\n // Get center y\n const cy = (points[0].y + points[points.length - 1].y) / 2;\n // Sort from right to left\n points.sort((a, b) => b.x - a.x);\n // Get center x\n const cx = (points[0].x + points[points.length - 1].x) / 2;\n // Center point\n const center = { x: cx, y: cy };\n // As the points are sorted from right to left the first point is the rightmost Starting angle used to reference other angles\n let startAng;\n points.forEach((point) => {\n let ang = Math.atan2(point.y - center.y, point.x - center.x);\n if (!startAng) {\n startAng = ang;\n } else {\n if (ang < startAng) {\n // ensure that all points are clockwise of the start point\n ang += Math.PI * 2;\n }\n }\n point.angle = ang; // add the angle to the point\n });\n // first sort clockwise\n points.sort((a, b) => a.angle - b.angle);\n // then reverse the order\n const ccwPoints = points.reverse();\n // move the last point back to the start\n ccwPoints.unshift(ccwPoints.pop());\n return ccwPoints.map(({ angle, ...attr }) => attr);\n};\n\n/*\n * Function to calculate the dot product of two vectors\n * @param {Object} v1 - point 1\n * @param {Object} v2 - point 2\n * */\nconst dotProduct = (v1, v2) => {\n return v1.x * v2.x + v1.y * v2.y;\n};\n\n/*\n * Function to calculate the magnitude of a vector\n * @param {Object} v - point object\n * */\nconst magnitude = (v) => {\n return Math.sqrt(v.x * v.x + v.y * v.y);\n};\n\n/*\n * Function to calculate the angle between two vectors in radians\n * @param {Object} v1 - point 1\n * @param {Object} v2 - point 2\n * */\nconst angleBetweenVectors = (v1, v2) => {\n const dot = dotProduct(v1, v2);\n const magV1 = magnitude(v1);\n const magV2 = magnitude(v2);\n // Ensure the dot product is within the domain of the acos function\n return Math.acos(dot / (magV1 * magV2));\n};\n\n/*\n * Function to check if a point lies between the angle formed by two lines\n * @param {Object} commonPoint - common point of the two lines\n * @param {Object} point1 - point 1 of cone\n * @param {Object} point2 - point 2 of cone\n * @param {Object} testPoint - point to be tested\n * */\nconst pointInAngle = (commonPoint, point1, point2, testPoint) => {\n const vector1 = { x: point1.x - commonPoint.x, y: point1.y - commonPoint.y };\n const vector2 = { x: point2.x - commonPoint.x, y: point2.y - commonPoint.y };\n const testVector = { x: testPoint.x - commonPoint.x, y: testPoint.y - commonPoint.y };\n const angle1 = angleBetweenVectors(vector1, testVector);\n const angle2 = angleBetweenVectors(vector2, testVector);\n const angleSum = angle1 + angle2;\n // Check if the sum of angles is approximately equal to the angle between the two lines\n // You may need to adjust the tolerance (e.g., 0.0001) based on your specific requirements\n const tolerance = 0.0001;\n return Math.abs(angleSum - angleBetweenVectors(vector1, vector2)) < tolerance;\n};\n\n/*\n * Function to remove duplicate points from an array\n * @param {Array} array - array of points\n * */\nconst removeDuplicatesFromArray = (array) => {\n return array.filter((obj, index) => {\n return index === array.findIndex((o) => obj.x === o.x && obj.y === o.y);\n });\n};\n\n/*\n * Function to remove duplicate points and filter sections\n * @param {Array} sections - array of sections\n * */\nconst removeDuplicateAndFilterSections = (sections) => {\n //removing duplicate points.\n for (let i = 0; i < sections.length; i++) {\n sections[i] = sections[i].filter((obj, index) => {\n return index === sections[i].findIndex((o) => obj.x === o.x && obj.y === o.y);\n });\n }\n //removing arrays with two points\n sections = sections.filter((section) => section.length > 2);\n //sorting the points in clockwise direction\n for (let i = 0; i < sections.length; i++) {\n sections[i] = sortPointsClockWise(sections[i]);\n }\n return sections;\n};\n\n/*\n * Function to find sections in solution set for one line\n * @param {Array} intersectionPoint - intersection point\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst findSectionsInSolutionSetForOneLine = (intersectionPoint, domain, range) => {\n let sections = [];\n sections.push([].concat(intersectionPoint));\n sections.push([].concat(intersectionPoint));\n if (\n (intersectionPoint[0].x === domain.max && intersectionPoint[1].y === range.max) ||\n (intersectionPoint[1].x === domain.max && intersectionPoint[0].y === range.max)\n ) {\n sections[0].push({ x: domain.max, y: range.max });\n sections[1].push({ x: domain.min, y: range.max }, { x: domain.min, y: range.min }, { x: domain.max, y: range.min });\n } else if (\n (intersectionPoint[0].x === domain.min && intersectionPoint[1].y === range.max) ||\n (intersectionPoint[1].x === domain.min && intersectionPoint[0].y === range.max)\n ) {\n sections[0].push({ x: domain.min, y: range.max });\n sections[1].push({ x: domain.max, y: range.max }, { x: domain.max, y: range.min }, { x: domain.min, y: range.min });\n } else if (\n (intersectionPoint[0].x === domain.min && intersectionPoint[1].y === range.min) ||\n (intersectionPoint[1].x === domain.min && intersectionPoint[0].y === range.min)\n ) {\n sections[0].push({ x: domain.min, y: range.min });\n sections[1].push({ x: domain.max, y: range.min }, { x: domain.max, y: range.max }, { x: domain.min, y: range.max });\n } else if (\n (intersectionPoint[0].x === domain.max && intersectionPoint[1].y === range.min) ||\n (intersectionPoint[1].x === domain.max && intersectionPoint[0].y === range.min)\n ) {\n sections[0].push({ x: domain.max, y: range.min });\n sections[1].push({ x: domain.min, y: range.min }, { x: domain.min, y: range.max }, { x: domain.max, y: range.max });\n } else if (\n (intersectionPoint[0].x === domain.min && intersectionPoint[1].x === domain.max) ||\n (intersectionPoint[0].x === domain.max && intersectionPoint[1].x === domain.min)\n ) {\n sections[0].push({ x: domain.min, y: range.max }, { x: domain.max, y: range.max });\n sections[1].push({ x: domain.min, y: range.min }, { x: domain.max, y: range.min });\n } else if (\n (intersectionPoint[0].y === range.min && intersectionPoint[1].y === range.max) ||\n (intersectionPoint[0].y === range.max && intersectionPoint[1].y === range.min)\n ) {\n sections[0].push({ x: domain.min, y: range.min }, { x: domain.min, y: range.max });\n sections[1].push({ x: domain.max, y: range.min }, { x: domain.max, y: range.max });\n }\n return removeDuplicateAndFilterSections(sections);\n};\n\n/*\n * Function to find sections in solution set for two lines\n * @param {Object} gssLineData - graphing solution set line data\n * @param {Array} answers - answers array\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nconst findSectionsInSolutionSetForTwoLines = (gssLineData, answers, domain, range) => {\n let mark1 = answers[0];\n let mark2 = answers[1];\n let cornerPoints = [\n { x: domain.min, y: range.min },\n { x: domain.min, y: range.max },\n { x: domain.max, y: range.min },\n { x: domain.max, y: range.max },\n ];\n let intersectPoint = lineIntersect(\n mark1.from.x,\n mark1.from.y,\n mark1.to.x,\n mark1.to.y,\n mark2.from.x,\n mark2.from.y,\n mark2.to.x,\n mark2.to.y,\n );\n let sections = [];\n let intersectionPoint1 = findIntersectionPointForMark(mark1, domain, range);\n intersectionPoint1 = removeDuplicatesFromArray(intersectionPoint1);\n let intersectionPoint2 = findIntersectionPointForMark(mark2, domain, range);\n intersectionPoint2 = removeDuplicatesFromArray(intersectionPoint2);\n if (intersectPoint && isPointInsideGraph(intersectPoint, domain, range)) {\n for (let i = 0; i < intersectionPoint1.length; i++) {\n for (let j = 0; j < intersectionPoint2.length; j++) {\n let bucket = [];\n let newCornerPoints = [];\n bucket.push(intersectPoint);\n bucket.push(intersectionPoint1[i]);\n bucket.push(intersectionPoint2[j]);\n for (let k = 0; k < cornerPoints.length; k++) {\n if (pointInAngle(intersectPoint, intersectionPoint1[i], intersectionPoint2[j], cornerPoints[k])) {\n bucket.push(cornerPoints[k]);\n } else {\n newCornerPoints.push(cornerPoints[k]);\n }\n }\n cornerPoints = newCornerPoints;\n sections.push(bucket);\n }\n }\n } else {\n let sections1 = findSectionsInSolutionSetForOneLine(intersectionPoint1, domain, range);\n let sections2 = findSectionsInSolutionSetForOneLine(intersectionPoint2, domain, range);\n for (let i = 0; i < sections1.length; i++) {\n if (\n !(pointInPolygon(intersectionPoint2[0], sections1[i]) && pointInPolygon(intersectionPoint2[1], sections1[i]))\n ) {\n sections.push(sections1[i]);\n }\n }\n for (let i = 0; i < sections2.length; i++) {\n if (\n !(pointInPolygon(intersectionPoint1[0], sections2[i]) && pointInPolygon(intersectionPoint1[1], sections2[i]))\n ) {\n sections.push(sections2[i]);\n }\n }\n for (let i = 0; i < sections.length; i++) {\n cornerPoints = cornerPoints.filter(function (o1) {\n return !sections[i].some(function (o2) {\n return o1.x === o2.x && o1.y === o2.y;\n });\n });\n }\n let sections3 = cornerPoints.concat(intersectionPoint1, intersectionPoint2);\n sections.push(sections3);\n }\n return removeDuplicateAndFilterSections(sections);\n};\n\n/*\n * Function to find sections in solution set\n * @param {Object} gssLineData - graphing solution set line data\n * @param {Array} answers - answers array\n * @param {Object} domain - domain object\n * @param {Object} range - range object\n * */\nexport const findSectionsInSolutionSet = (gssLineData, answers, domain, range) => {\n if (gssLineData.numberOfLines === 1) {\n const intersectionPoint = findIntersectionPointForMark(answers[0], domain, range);\n gssLineData.sections = findSectionsInSolutionSetForOneLine(intersectionPoint, domain, range);\n } else {\n gssLineData.sections = findSectionsInSolutionSetForTwoLines(gssLineData, answers, domain, range);\n }\n return gssLineData;\n};\n\n/*\n * Function to check if a point is inside a polygon\n * @param {Object} point - point to be checked\n * @param {Array} polygon - polygon points array\n * */\nexport const pointInsidePolygon = (point, polygon) => {\n const num_vertices = polygon.length;\n const x = point.x;\n const y = point.y;\n let inside = false;\n let p1 = polygon[0];\n let p2;\n for (let i = 1; i <= num_vertices; i++) {\n p2 = polygon[i % num_vertices];\n if (y > Math.min(p1.y, p2.y)) {\n if (y <= Math.max(p1.y, p2.y)) {\n if (x <= Math.max(p1.x, p2.x)) {\n const x_intersection = ((y - p1.y) * (p2.x - p1.x)) / (p2.y - p1.y) + p1.x;\n if (p1.x === p2.x || x <= x_intersection) {\n inside = !inside;\n }\n }\n }\n }\n p1 = p2;\n }\n return inside;\n};\n\n/*\n * Function to check if lines are added in the graph\n * @param {Object} gssLineData - graphing solution set line data\n * @param {Array} answer - answer array\n * */\nexport const checkIfLinesAreAdded = (gssLineData, answer) => {\n if (answer.length === 0) {\n return false;\n }\n if (gssLineData.numberOfLines === 1) {\n if (answer.length === 1) {\n return !answer[0].building;\n }\n } else {\n if (answer.length !== 2) {\n return false;\n } else {\n return !answer[1].building;\n }\n }\n};\n"],"file":"utils.js"}
@@ -1,71 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
-
8
- /*
9
- * This file contains the default configuration for the Graphing Solution Set Item Type.
10
- * Model is similar to the one used in graphing item type except for the gssLineData object which handles
11
- * the configuration for the lines and the solution set.
12
- *
13
- * Same model is used in configure/src default.js
14
- * */
15
- var _default = {
16
- answers: {
17
- correctAnswer: {
18
- name: 'Correct Answer',
19
- marks: []
20
- }
21
- },
22
- arrows: {
23
- left: true,
24
- right: true,
25
- up: true,
26
- down: true
27
- },
28
- marks: [],
29
- defaultGridConfiguration: 0,
30
- domain: {
31
- min: -5,
32
- max: 5,
33
- step: 1,
34
- labelStep: 1,
35
- axisLabel: 'x'
36
- },
37
- graph: {
38
- width: 500,
39
- height: 500
40
- },
41
- gssLineData: {
42
- numberOfLines: 1,
43
- selectedTool: 'lineA',
44
- sections: [],
45
- lineA: {
46
- lineType: 'Solid'
47
- }
48
- },
49
- includeAxes: true,
50
- labels: {},
51
- labelsEnabled: true,
52
- padding: true,
53
- prompt: '',
54
- range: {
55
- min: -5,
56
- max: 5,
57
- step: 1,
58
- labelStep: 1,
59
- axisLabel: 'y'
60
- },
61
- rationale: '',
62
- standardGrid: false,
63
- title: '',
64
- coordinatesOnHover: false,
65
- promptEnabled: true,
66
- rationaleEnabled: true,
67
- teacherInstructionsEnabled: true,
68
- studentInstructionsEnabled: true
69
- };
70
- exports["default"] = _default;
71
- //# sourceMappingURL=defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/defaults.js"],"names":["answers","correctAnswer","name","marks","arrows","left","right","up","down","defaultGridConfiguration","domain","min","max","step","labelStep","axisLabel","graph","width","height","gssLineData","numberOfLines","selectedTool","sections","lineA","lineType","includeAxes","labels","labelsEnabled","padding","prompt","range","rationale","standardGrid","title","coordinatesOnHover","promptEnabled","rationaleEnabled","teacherInstructionsEnabled","studentInstructionsEnabled"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;eACe;AACbA,EAAAA,OAAO,EAAE;AACPC,IAAAA,aAAa,EAAE;AACbC,MAAAA,IAAI,EAAE,gBADO;AAEbC,MAAAA,KAAK,EAAE;AAFM;AADR,GADI;AAObC,EAAAA,MAAM,EAAE;AACNC,IAAAA,IAAI,EAAE,IADA;AAENC,IAAAA,KAAK,EAAE,IAFD;AAGNC,IAAAA,EAAE,EAAE,IAHE;AAINC,IAAAA,IAAI,EAAE;AAJA,GAPK;AAabL,EAAAA,KAAK,EAAE,EAbM;AAcbM,EAAAA,wBAAwB,EAAE,CAdb;AAebC,EAAAA,MAAM,EAAE;AACNC,IAAAA,GAAG,EAAE,CAAC,CADA;AAENC,IAAAA,GAAG,EAAE,CAFC;AAGNC,IAAAA,IAAI,EAAE,CAHA;AAINC,IAAAA,SAAS,EAAE,CAJL;AAKNC,IAAAA,SAAS,EAAE;AALL,GAfK;AAsBbC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAE,GADF;AAELC,IAAAA,MAAM,EAAE;AAFH,GAtBM;AA0BbC,EAAAA,WAAW,EAAE;AACXC,IAAAA,aAAa,EAAE,CADJ;AAEXC,IAAAA,YAAY,EAAE,OAFH;AAGXC,IAAAA,QAAQ,EAAE,EAHC;AAIXC,IAAAA,KAAK,EAAE;AACLC,MAAAA,QAAQ,EAAE;AADL;AAJI,GA1BA;AAkCbC,EAAAA,WAAW,EAAE,IAlCA;AAmCbC,EAAAA,MAAM,EAAE,EAnCK;AAoCbC,EAAAA,aAAa,EAAE,IApCF;AAqCbC,EAAAA,OAAO,EAAE,IArCI;AAsCbC,EAAAA,MAAM,EAAE,EAtCK;AAuCbC,EAAAA,KAAK,EAAE;AACLnB,IAAAA,GAAG,EAAE,CAAC,CADD;AAELC,IAAAA,GAAG,EAAE,CAFA;AAGLC,IAAAA,IAAI,EAAE,CAHD;AAILC,IAAAA,SAAS,EAAE,CAJN;AAKLC,IAAAA,SAAS,EAAE;AALN,GAvCM;AA8CbgB,EAAAA,SAAS,EAAE,EA9CE;AA+CbC,EAAAA,YAAY,EAAE,KA/CD;AAgDbC,EAAAA,KAAK,EAAE,EAhDM;AAiDbC,EAAAA,kBAAkB,EAAE,KAjDP;AAkDbC,EAAAA,aAAa,EAAE,IAlDF;AAmDbC,EAAAA,gBAAgB,EAAE,IAnDL;AAoDbC,EAAAA,0BAA0B,EAAE,IApDf;AAqDbC,EAAAA,0BAA0B,EAAE;AArDf,C","sourcesContent":["/*\n * This file contains the default configuration for the Graphing Solution Set Item Type.\n * Model is similar to the one used in graphing item type except for the gssLineData object which handles\n * the configuration for the lines and the solution set.\n *\n * Same model is used in configure/src default.js\n * */\nexport default {\n answers: {\n correctAnswer: {\n name: 'Correct Answer',\n marks: [],\n },\n },\n arrows: {\n left: true,\n right: true,\n up: true,\n down: true,\n },\n marks: [],\n defaultGridConfiguration: 0,\n domain: {\n min: -5,\n max: 5,\n step: 1,\n labelStep: 1,\n axisLabel: 'x',\n },\n graph: {\n width: 500,\n height: 500,\n },\n gssLineData: {\n numberOfLines: 1,\n selectedTool: 'lineA',\n sections: [],\n lineA: {\n lineType: 'Solid',\n },\n },\n includeAxes: true,\n labels: {},\n labelsEnabled: true,\n padding: true,\n prompt: '',\n range: {\n min: -5,\n max: 5,\n step: 1,\n labelStep: 1,\n axisLabel: 'y',\n },\n rationale: '',\n standardGrid: false,\n title: '',\n coordinatesOnHover: false,\n promptEnabled: true,\n rationaleEnabled: true,\n teacherInstructionsEnabled: true,\n studentInstructionsEnabled: true,\n};\n"],"file":"defaults.js"}
@@ -1,423 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.getBestAnswer = exports.getAnswerCorrected = exports.createCorrectResponseSession = exports.compareMarks = void 0;
9
- exports.model = model;
10
- exports.normalize = void 0;
11
- exports.outcome = outcome;
12
- exports.validate = void 0;
13
-
14
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
-
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
-
18
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
-
20
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
21
-
22
- var _debug = _interopRequireDefault(require("debug"));
23
-
24
- var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
25
-
26
- var _uniqWith = _interopRequireDefault(require("lodash/uniqWith"));
27
-
28
- var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
29
-
30
- var _defaults = _interopRequireDefault(require("./defaults"));
31
-
32
- var _utils = require("./utils");
33
-
34
- var _excluded = ["defaultTool", "prompt", "promptEnabled", "graph", "answers", "toolbarTools"];
35
-
36
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
37
-
38
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
39
-
40
- var log = (0, _debug["default"])('@pie-element:graphing-solution-set:controller');
41
-
42
- var initializeGraphMap = function initializeGraphMap() {
43
- return {
44
- line: []
45
- };
46
- };
47
- /*
48
- * Function to compare two marks
49
- * @param {Object} mark1 - first mark
50
- * @param {Object} mark2 - second mark
51
- * */
52
-
53
-
54
- var compareMarks = function compareMarks(mark1, mark2) {
55
- // marks can be compared with equalMarks[type] function only if they have the same type;
56
- // if type is different, they are clearly not equal
57
- return !!(mark1 && mark2 && mark1.type === mark2.type && _utils.equalMarks[mark1.type] && _utils.equalMarks[mark1.type](mark1, mark2));
58
- };
59
- /*
60
- * Function to get the corrected answer
61
- * @param {Object} sessionAnswers - array of marks from session
62
- * @param {Object} marks - array of marks from correct answer
63
- * */
64
-
65
-
66
- exports.compareMarks = compareMarks;
67
-
68
- var getAnswerCorrected = function getAnswerCorrected(_ref) {
69
- var sessionAnswers = _ref.sessionAnswers,
70
- correctAnswers = _ref.marks;
71
- sessionAnswers = sessionAnswers || [];
72
- correctAnswers = correctAnswers || [];
73
- var rez = (0, _cloneDeep["default"])(sessionAnswers).reduce(function (correctedAnswer, answer) {
74
- var answerIsCorrect = correctAnswers.find(function (mark) {
75
- return compareMarks(answer, mark);
76
- });
77
- answer.correctness = answerIsCorrect ? 'correct' : 'incorrect';
78
- return [].concat((0, _toConsumableArray2["default"])(correctedAnswer), [answer]);
79
- }, []); // add missing objects from correct answer
80
-
81
- var missingAnswers = (0, _cloneDeep["default"])(correctAnswers).reduce(function (correctedAnswer, answer) {
82
- var answerIndex = sessionAnswers.find(function (mark) {
83
- return compareMarks(answer, mark);
84
- });
85
-
86
- if (!answerIndex) {
87
- // means that corrected answer is missing from session, so we mark it as missing object
88
- return [].concat((0, _toConsumableArray2["default"])(correctedAnswer), [_objectSpread(_objectSpread({}, answer), {}, {
89
- correctness: 'missing'
90
- })]);
91
- }
92
-
93
- return correctedAnswer;
94
- }, []);
95
- return [].concat((0, _toConsumableArray2["default"])(rez), (0, _toConsumableArray2["default"])(missingAnswers));
96
- };
97
- /*
98
- * Function to get the best answer
99
- * @param {Object} question - question object
100
- * @param {Object} session - session object
101
- * @param {Object} env - env object
102
- * */
103
-
104
-
105
- exports.getAnswerCorrected = getAnswerCorrected;
106
-
107
- var getBestAnswer = function getBestAnswer(question, session) {
108
- var env = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
109
-
110
- // questionPossibleAnswers contains all possible answers (correct response and alternates);
111
- var _ref2 = question || {},
112
- _ref2$answers = _ref2.answers,
113
- questionPossibleAnswers = _ref2$answers === void 0 ? {} : _ref2$answers,
114
- scoringType = _ref2.scoringType;
115
-
116
- var _ref3 = session || {},
117
- answer = _ref3.answer; // filter the incomplete objects
118
-
119
-
120
- Object.entries(questionPossibleAnswers || {}).forEach(function (_ref4) {
121
- var _ref5 = (0, _slicedToArray2["default"])(_ref4, 2),
122
- key = _ref5[0],
123
- value = _ref5[1];
124
-
125
- return questionPossibleAnswers[key] = _objectSpread(_objectSpread({}, value), {}, {
126
- marks: value === null || value === void 0 ? void 0 : value.marks.filter(function (mark) {
127
- return !mark.building;
128
- })
129
- });
130
- }); // initialize answer if no values
131
-
132
- answer = answer || []; // initialize one possible answer if no values
133
-
134
- if ((0, _isEmpty["default"])(questionPossibleAnswers)) {
135
- questionPossibleAnswers = {
136
- correctAnswer: initializeGraphMap()
137
- };
138
- } else {
139
- questionPossibleAnswers = _objectSpread({
140
- correctAnswer: questionPossibleAnswers.correctAnswer
141
- }, (0, _utils.sortedAnswers)(questionPossibleAnswers));
142
- } // student's answers without DUPLICATES
143
-
144
-
145
- var sessionAnswers = (0, _uniqWith["default"])(answer, compareMarks); // array of possible answers entries
146
-
147
- var possibleAnswers = Object.entries(questionPossibleAnswers);
148
- return possibleAnswers.reduce(function (acc, entry) {
149
- // iterating each possible answer (main + alternates)
150
- var possibleAnswerKey = entry[0];
151
- var possibleAnswer = entry[1] || {};
152
- var marks = possibleAnswer.marks;
153
-
154
- if (!marks || !marks.length) {
155
- return acc;
156
- } // returns array of marks, each having 'correctness' property
157
-
158
-
159
- var correctedAnswer = getAnswerCorrected({
160
- sessionAnswers: sessionAnswers,
161
- marks: marks
162
- });
163
- var correctMarks = correctedAnswer.filter(function (answer) {
164
- return answer.correctness === 'correct';
165
- }); // filter out missing objects because they do not affect the calculation of the score
166
- // only correct and incorrect are needed
167
-
168
- var scoredCorrectedAnswer = correctedAnswer.filter(function (answer) {
169
- return answer.correctness !== 'missing';
170
- });
171
- var maxScore = marks.length;
172
- var score = correctMarks.length; // if extra placements
173
-
174
- if (scoredCorrectedAnswer.length > maxScore) {
175
- score -= scoredCorrectedAnswer.length - maxScore;
176
- }
177
-
178
- if (score < 0) {
179
- score = 0;
180
- }
181
-
182
- if (score / maxScore > acc.bestScore || !acc.foundOneSolution) {
183
- acc.bestScore = Math.floor(score / maxScore);
184
- acc.bestScoreAnswerKey = possibleAnswerKey;
185
- acc.answersCorrected = correctedAnswer;
186
- acc.foundOneSolution = true;
187
- }
188
-
189
- return acc;
190
- }, {
191
- bestScore: 0,
192
- bestScoreAnswerKey: null,
193
- // initially we just suppose all the answers are incorrect
194
- answersCorrected: (0, _cloneDeep["default"])(sessionAnswers).map(function (answer) {
195
- return _objectSpread(_objectSpread({}, answer), {}, {
196
- correctness: 'incorrect'
197
- });
198
- }),
199
- foundOneSolution: false
200
- });
201
- };
202
- /*
203
- * Constant normalize
204
- * @param {Object} question - question object
205
- * */
206
-
207
-
208
- exports.getBestAnswer = getBestAnswer;
209
-
210
- var normalize = function normalize(question) {
211
- return _objectSpread(_objectSpread({}, _defaults["default"]), question);
212
- };
213
- /*
214
- * Function to set model
215
- * @param {Object} question - question object
216
- * @param {Object} session - session object
217
- * @param {Object} env - env object
218
- * */
219
-
220
-
221
- exports.normalize = normalize;
222
-
223
- function model(question, session, env) {
224
- return new Promise(function (resolve) {
225
- var normalizedQuestion = normalize(question); // ensure removing of invalid answers
226
- // need this if undo redo was last operation
227
-
228
- session.answer = (0, _utils.removeInvalidAnswers)(session.answer); // console.log('normalizedQuestion', normalizedQuestion);
229
-
230
- var _ref6 = normalizedQuestion || {},
231
- defaultTool = _ref6.defaultTool,
232
- prompt = _ref6.prompt,
233
- promptEnabled = _ref6.promptEnabled,
234
- graph = _ref6.graph,
235
- answers = _ref6.answers,
236
- toolbarTools = _ref6.toolbarTools,
237
- questionProps = (0, _objectWithoutProperties2["default"])(_ref6, _excluded);
238
-
239
- var arrows = normalizedQuestion.arrows;
240
-
241
- var _ref7 = env || {},
242
- mode = _ref7.mode,
243
- role = _ref7.role; // This is used for offering support for old models which have the property arrows: boolean
244
- // Same thing is set in authoring : packages/graphing/configure/src/configure.jsx - componentDidMount
245
-
246
-
247
- if (typeof arrows === 'boolean') {
248
- if (arrows) {
249
- arrows = {
250
- left: true,
251
- right: true,
252
- up: true,
253
- down: true
254
- };
255
- } else {
256
- arrows = {
257
- left: false,
258
- right: false,
259
- up: false,
260
- down: false
261
- };
262
- }
263
- }
264
-
265
- var base = _objectSpread(_objectSpread({}, questionProps), {}, {
266
- answers: answers,
267
- arrows: arrows,
268
- defaultTool: 'line',
269
- disabled: env.mode !== 'gather',
270
- prompt: promptEnabled ? prompt : null,
271
- rationale: null,
272
- size: graph,
273
- showToggle: env.mode === 'evaluate' && !(0, _isEmpty["default"])(answers) && answers.correctAnswer && answers.correctAnswer.marks && !(0, _isEmpty["default"])(answers.correctAnswer.marks),
274
- teacherInstructions: null,
275
- toolbarTools: toolbarTools
276
- });
277
-
278
- if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
279
- var _ref8 = normalizedQuestion || {},
280
- rationale = _ref8.rationale,
281
- rationaleEnabled = _ref8.rationaleEnabled,
282
- teacherInstructions = _ref8.teacherInstructions,
283
- teacherInstructionsEnabled = _ref8.teacherInstructionsEnabled;
284
-
285
- base.rationale = rationaleEnabled ? rationale : null;
286
- base.teacherInstructions = teacherInstructionsEnabled ? teacherInstructions : null;
287
- }
288
-
289
- if (mode === 'evaluate') {
290
- if (!(0, _isEmpty["default"])(answers) && answers.correctAnswer && answers.correctAnswer.marks && !(0, _isEmpty["default"])(answers.correctAnswer.marks)) {
291
- var _getBestAnswer = getBestAnswer(normalizedQuestion, session, env),
292
- answersCorrected = _getBestAnswer.answersCorrected,
293
- bestScoreAnswerKey = _getBestAnswer.bestScoreAnswerKey,
294
- bestScore = _getBestAnswer.bestScore; // array of marks from session with 'correctness' property set
295
-
296
-
297
- base.answersCorrected = answersCorrected;
298
- base.correctResponse = bestScoreAnswerKey ? (answers[bestScoreAnswerKey] || {}).marks : [];
299
- base.showToggle = base.showToggle && bestScore !== 1;
300
- } else {
301
- base.answersCorrected = session && session.answer || [];
302
- base.correctResponse = [];
303
- }
304
- }
305
-
306
- log('base: ', base);
307
- resolve(base);
308
- });
309
- }
310
- /*
311
- * Function to check the outcome
312
- * @param {Object} question - question object
313
- * @param {Object} session - session object
314
- * @param {Object} env - env object
315
- * */
316
-
317
-
318
- function outcome(question, session) {
319
- var env = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
320
- return new Promise(function (resolve) {
321
- if (!session || (0, _isEmpty["default"])(session)) {
322
- resolve({
323
- score: 0,
324
- empty: true
325
- });
326
- }
327
-
328
- if (env.mode !== 'evaluate' || (0, _isEmpty["default"])(question.answers) || question.answers && question.answers.correctAnswer && (0, _isEmpty["default"])(question.answers.correctAnswer.marks)) {
329
- resolve({
330
- score: 0
331
- });
332
- }
333
-
334
- var _getBestAnswer2 = getBestAnswer(question, session, env),
335
- bestScore = _getBestAnswer2.bestScore;
336
-
337
- resolve({
338
- score: bestScore
339
- });
340
- });
341
- }
342
- /*
343
- * Constant to create correct response session
344
- * @param {Object} question - question object
345
- * @param {Object} env - env object
346
- * */
347
-
348
-
349
- var createCorrectResponseSession = function createCorrectResponseSession(question, env) {
350
- return new Promise(function (resolve) {
351
- if (env.mode !== 'evaluate' && env.role === 'instructor') {
352
- var _ref9 = question || {},
353
- answers = _ref9.answers;
354
-
355
- var marks = [];
356
-
357
- if (answers && Object.values(answers)) {
358
- var correctAnswer = answers.correctAnswer || Object.values(answers)[0] || {};
359
- marks = correctAnswer.marks || [];
360
- }
361
-
362
- resolve({
363
- answer: marks,
364
- id: '1'
365
- });
366
- } else {
367
- resolve(null);
368
- }
369
- });
370
- };
371
- /*
372
- * Constant to validate model before saving item
373
- * @param {Object} model - model object
374
- * */
375
-
376
-
377
- exports.createCorrectResponseSession = createCorrectResponseSession;
378
-
379
- var validate = function validate() {
380
- var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
381
- var answers = model.answers,
382
- gssLineData = model.gssLineData;
383
- var errors = {};
384
- var correctAnswerErrors = {};
385
- var found = false;
386
-
387
- if (gssLineData.numberOfLines === 1) {
388
- if (answers.correctAnswer.marks.length < 1) {
389
- found = true;
390
- correctAnswerErrors.correctAnswer = 'At least 1 line object should be defined.';
391
- } else if (answers.correctAnswer.marks.length === 1 && answers.correctAnswer.marks[0].building) {
392
- found = true;
393
- correctAnswerErrors.correctAnswer = '1 or more graph object should be correctly defined.';
394
- }
395
- } else {
396
- if (answers.correctAnswer.marks.length < 2) {
397
- found = true;
398
- correctAnswerErrors.correctAnswer = 'At least 2 line object should be defined.';
399
- } else if (answers.correctAnswer.marks.length === 2) {
400
- if (answers.correctAnswer.marks[0].building || answers.correctAnswer.marks[1].building) {
401
- found = true;
402
- correctAnswerErrors.correctAnswer = '1 or more graph object should be correctly defined.';
403
- }
404
- }
405
- }
406
-
407
- var polygon = answers.correctAnswer.marks.find(function (mark) {
408
- return mark.type === 'polygon';
409
- });
410
-
411
- if (!found && (!gssLineData.selectedTool === 'solutionSet' || !polygon)) {
412
- correctAnswerErrors.correctAnswer = 'Please select a solution set for the graphing solution set item.';
413
- }
414
-
415
- if (!(0, _isEmpty["default"])(correctAnswerErrors)) {
416
- errors.correctAnswerErrors = correctAnswerErrors;
417
- }
418
-
419
- return errors;
420
- };
421
-
422
- exports.validate = validate;
423
- //# sourceMappingURL=index.js.map