Skip to content

Estado de la aplicación

sonsoleslp edited this page Sep 2, 2018 · 12 revisions

Introduction

One of the main features of redux is the inmuttability, to say, when an object want to be changed, it is not assigned to the new value that is wanted otherwise it is recreated again with the updated value (object doesn't mutates). The advantage of this is that we can know if the object has mutated recently (comparing the reference instead of the value, and the deeper is the object, the bigger the difference is) and if there is a graphic library that is able to repaint efficiently the interface(like in React case), it can be appreciated an increase of the application performance.

To change the state, you will mainly use the function Object.assign and the notation spread (...), both charactericts are defined in the versions 6 and 7 of Ecmascript, that why they aren't still supported by all browsers and they need to use transpilers functions to ensure compatibility. Nevertheless, it can't be used in all necessary cases and there are sometimes that what is done directly is to assign the new object to the portion of state desired (i.e., if you want to reorded an index array).

To know exactly how these two features work, better check the docs, but mainly they mix both objects and return a new one, in the case of Object.assign, the first parameter is an empty object (it is returned and filled with the function result), the second is the original object (the correspondant state part) and the third is an object with the second property that wants to be changed and its new values. In case of a spread notation, it is used to tell that properties should be copied and added to a new object (generally it is used to add elements to an array). Nevertheles, you can see fast in case of deleting an array, the easiest is to return a new name filtering the unwanted element.

Also, after the design guides of Redux, it is recommended not to treat the state as a gigantic tree of objects but more as a database, where you can know the ids of elements somewhere from one place or another. This has been shown to be comfortable sometimes, i.e. it is very easy to know how many EditorBox there is in a view in a certain moment, go through them or tell the parentship relationships between them, because that the identifiers are stored of the EditorBox children and there is a dictionary of them to access to its data.

Description

These are the elements of the state and after, a brief descriptions of the most relevant elements.

    {
        "undoGroup": {
            "past": [],
            "present":{
                "version":"1",
                "lastActionDispatched":"INDEX_SELECT",
                "globalConfig":{
                    "title":"EdiphyDoc",
                    "author":"GING",
                    "canvasRatio":1.7777777777777777,
                    "age":{
                        "max":100,
                        "min":0
                    },
                    "typicalLearningTime":{
                        "h":0,
                        "m":"30",
                        "s":0
                    },
                    "difficulty":"very easy",
                    "rights":"cc-by",
                    "description":"Example",
                    "thumbnail":"http://localhost:8081/fb8d18d216bebbe4dfc39f0b1771a3b4.jpg",
                    "language":"en",
                    "keywords":[{"id":1,"text":"github"}, {"id":2, "text":"ediphy"}, {"id":3, "text":"docs"}],
                    "version":"1.0.0",
                    "status":"draft",
                    "context":"other",
                    "hideGlobalScore":false,
                    "minTimeProgress":10,
                    "visorNav":{
                        "player":true,
                        "sidebar":true,
                        "keyBindings":true
                    },
                    "modifiedState":true,
                    "showAlert":false,
                    "everPublished":false
                },
                "boxesById":{
                    "bs-1535353910908":{
                        "parent":"pa-1535353910908",
                        "id":"bs-1535353910908",
                        "container":0,
                        "level":-1,
                        "col":0,
                        "row":0,
                        "position":{
                            "type":"relative",
                            "x":0,
                            "y":0
                        },
                        "draggable":false,
                        "resizable":false,
                        "showTextEditor":false,
                        "fragment":{},
                        "children":["sc-1535353912282"],
                        "sortableContainers":{
                            "sc-1535353912282":{
                                "children":["bo-1535353912282"],
                                "style":{
                                    "padding":"0px",
                                    "borderColor":"#ffffff",
                                    "borderWidth":"0px",
                                    "borderStyle":"solid",
                                    "opacity":"1",
                                    "textAlign":"center",
                                },
                                "height":"auto",
                                "key":"sc-1535353912282",
                                "colDistribution":[100],
                                "cols":[[100]]
                            }
                        },
                        "containedViews":[]
                        },
                    "bo-1535353912282":{
                        "id":"bo-1535353912282",
                        "parent":"bs-1535353910908",
                        "container":"sc-1535353912282",
                        "level":0,
                        "col":0,
                        "row":0,
                        "position":{
                            "x":0,
                            "y":0,
                            "type":"relative"
                        },
                        "draggable":true,
                        "resizable":false,
                        "showTextEditor":false,
                        "fragment":{
                        },
                        "children":[],
                        "sortableContainers":{ },
                        "containedViews":["cv-1535353924845"]
                    },
                    "bo-1535353943033":{
                        "id":"bo-1535353943033",
                        "parent":"pa-1497983247795",
                        "container":0,
                        "level":0,
                        "col":0,
                        "row":0,
                        "position":{
                        "x":"27.430293896006027%",
                        "y":"14.611260053619302%",
                        "type":"absolute"},
                        "draggable":true,
                        "resizable":true,
                        "showTextEditor":false,
                        "fragment":{
                        },
                        "children":[],
                        "sortableContainers":{
                        },
                        "containedViews":["cv-1535353959572"]
                    },
                    "bo-1535353987146":{
                        "id":"bo-1535353987146",
                        "parent":"cv-1535353924845",
                        "container":0,
                        "level":0,
                        "col":0,
                        "row":0,
                        "position":{
                            "x":"21.77%",
                            "y":"26.47%",
                            "type":"absolute"
                        },
                        "draggable":true,
                        "resizable":true,
                        "showTextEditor":false,
                        "fragment":{},
                        "children":[
                            "sc-Question",
                            "sc-Answer0",
                            "sc-Answer1",
                            "sc-Answer2",
                            "sc-Feedback"
                        ],
                        "sortableContainers":{
                            "sc-Question":{
                                "children":["bo-1535353987152_0"],
                                "style":{
                                    "padding":"0px",
                                    "borderColor":"#ffffff",
                                    "borderWidth":"0px",
                                    "borderStyle":"solid",
                                    "opacity":"1",
                                    "textAlign":"left",
                                    "className":""
                                },
                                "height":"auto",
                                "key":"sc-Question",
                                "colDistribution":[100],
                                "cols":[[100]]
                            },
                            "sc-Answer0":{
                                "children":["bo-1535353987152_1"],
                                "style":{
                                    "padding":"0px",
                                    "borderColor":"#ffffff",
                                    "borderWidth":"0px",
                                    "borderStyle":"solid",
                                    "opacity":"1",
                                    "textAlign":"left",
                                    "className":""
                                },
                                "height":"auto",
                                "key":"sc-Answer0",
                                "colDistribution":[100],
                                "cols":[[100]]
                            },
                            "sc-Answer1":{
                                "children":["bo-1535353987152_2"],
                                "style":{
                                    "padding":"0px",
                                    "borderColor":"#ffffff",
                                    "borderWidth":"0px",
                                    "borderStyle":"solid",
                                    "opacity":"1",
                                    "textAlign":"left",
                                    "className":""
                                },
                                "height":"auto",
                                "key":"sc-Answer1",
                                "colDistribution":[100],
                                "cols":[[100]]
                            },
                            "sc-Answer2":{
                                "children":["bo-1535353987152_3"],
                                "style":{
                                    "padding":"0px",
                                    "borderColor":"#ffffff",
                                    "borderWidth":"0px",
                                    "borderStyle":"solid",
                                    "opacity":"1",
                                    "textAlign":"left",
                                    "className":""
                                },
                                "height":"auto",
                                "key":"sc-Answer2",
                                "colDistribution":[100],
                                "cols":[[100]]
                            },
                            "sc-Feedback":{
                                "children":["bo-1535353987152_4"],
                                "style":{
                                "padding":"0px",
                                    "borderColor":"#ffffff",
                                    "borderWidth":"0px",
                                    "borderStyle":"solid",
                                    "opacity":"1",
                                    "textAlign":"left",
                                    "className":""
                                },
                                "height":"auto",
                                "key":"sc-Feedback",
                                "colDistribution":[100],
                                "cols":[[100]]
                            }
                        },
                        "containedViews":[]
                    },
                    "bo-1535353987152_0":{
                        "id":"bo-1535353987152_0",
                        "parent":"bo-1535353987146",
                        "container":"sc-Question",
                        "level":1,
                        "col":0,
                        "row":0,
                        "position":{
                            "x":0,
                            "y":0,
                            "type":"relative"
                        },
                        "content":{
                        "node":"root",
                        "child":[{"node":"element",
                        "tag":"p",
                        "child":[{"node":"text",
                        "text":"Esta es una pregunta con varias opciones para responder. Sólo una puede ser correcta. Puedes escribir aquí el enunciado de la pregunta"}]}]},
                        "draggable":true,
                        "resizable":false,
                        "showTextEditor":false,
                        "fragment":{
                        },
                        "children":[],
                        "sortableContainers":{
                        },
                        "containedViews":[]
                    },
                    "bo-1535353987152_1":{
                        "id":"bo-1535353987152_1",
                        "parent":"bo-1535353987146",
                        "container":"sc-Answer0",
                        "level":1,
                        "col":0,
                        "row":0,
                        "position":{
                            "x":0,
                            "y":0,
                            "type":"relative"
                        },
                        "content":{
                        "node":"root",
                        "child":[{"node":"element",
                        "tag":"p",
                        "child":[{"node":"text",
                        "text":"Respuesta 1"}]}]},
                        "draggable":true,
                        "resizable":false,
                        "showTextEditor":false,
                        "fragment":{
                        },
                        "children":[],
                        "sortableContainers":{
                        },
                        "containedViews":[]},
                    "bo-1535353987152_2":{
                        "id":"bo-1535353987152_2",
                        "parent":"bo-1535353987146",
                        "container":"sc-Answer1",
                        "level":1,
                        "col":0,
                        "row":0,
                        "position":{
                            "x":0,
                            "y":0,
                            "type":"relative"
                        },
                        "content":{
                        "node":"root",
                        "child":[{"node":"element",
                        "tag":"p",
                        "child":[{"node":"text",
                        "text":"Respuesta 2"}]}]},
                        "draggable":true,
                        "resizable":false,
                        "showTextEditor":false,
                        "fragment":{
                        },
                        "children":[],
                        "sortableContainers":{
                        },
                        "containedViews":[]
                    },
                    "bo-1535353987152_3":{
                        "id":"bo-1535353987152_3",
                        "parent":"bo-1535353987146",
                        "container":"sc-Answer2",
                        "level":1,
                        "col":0,
                        "row":0,
                        "position":{
                            "x":0,
                            "y":0,
                            "type":"relative"
                        },
                        "content":{
                        "node":"root",
                        "child":[{"node":"element",
                        "tag":"p",
                        "child":[{"node":"text",
                        "text":"Respuesta 3"}]}]},
                        "draggable":true,
                        "resizable":false,
                        "showTextEditor":false,
                        "fragment":{
                        },
                        "children":[],
                        "sortableContainers":{
                        },
                        "containedViews":[]
                    },
                    "bo-1535353987152_4":{
                        "id":"bo-1535353987152_4",
                        "parent":"bo-1535353987146",
                        "container":"sc-Feedback",
                        "level":1,
                        "col":0,
                        "row":0,
                        "position":{
                            "x":0,
                            "y":0,
                            "type":"relative"
                        },
                        "content":{
                        "node":"root",
                        "child":[{"node":"element",
                        "tag":"p",
                        "child":[{"node":"text",
                        "text":"Aquí puedes incluir una explicación acerca de la respuesta"}]}]},
                        "draggable":true,
                        "resizable":false,
                        "showTextEditor":false,
                        "fragment":{
                        },
                        "children":[],
                        "sortableContainers":{
                        },
                        "containedViews":[]
                    }
                },
                "boxSelected":-1,
                "boxLevelSelected":0,
                "indexSelected":"cv-1535353924845",
                "marksById":{
                    "rm-1535353924845":{
                        "id":"rm-1535353924845",
                        "origin":"bo-1535353912282",
                        "title":"Nueva marca 1",
                        "connection":"cv-1535353924845",
                        "color":"#3939ac",
                        "connectMode":"existing",
                        "displayMode":"navigate",
                        "value":"48.51,53.59"
                    },
                    "rm-1535353936013":{
                        "id":"rm-1535353936013",
                        "origin":"bo-1535353912282",
                        "title":"Nueva marca 2",
                        "connection":"Hello!",
                        "color":"#000001",
                        "connectMode":"popup",
                        "displayMode":"navigate",
                        "value":"79.25,60.38"
                    },
                    "rm-1535353952372":{
                        "id":"rm-1535353952372",
                        "origin":"bo-1535353943033",
                        "title":"Nueva marca 3",
                        "connection":"http://vishub.org/",
                        "color":"#020100",
                        "connectMode":"external",
                        "displayMode":"navigate",
                        "value":"41.18,40.11, 1"
                    },
                    "rm-1535353959572":{
                        "id":"rm-1535353959572",
                        "origin":"bo-1535353943033",
                        "title":"Nueva marca 4",
                        "connection":"pa-1535353910908",
                        "color":"#000002",
                        "connectMode":"existing",
                        "displayMode":"navigate",
                        "value":"70.26,27.86,1"
                    }
                },
                "navItemsIds":[
                    "pa-1497983247795",
                    "se-1535354055428",
                    "pa-1535353910908"
                    ],
                "navItemSelected":"pa-1535353910908",
                "navItemsById":{
                    "0":{
                        "id":0,
                        "children":[
                            "pa-1497983247795",
                            "se-1535354055428"
                        ],
                        "boxes":[],
                        "level":0,
                        "type":"",
                        "hidden":false,
                        "isExpanded":true
                        },
                    "pa-1497983247795":{
                        "id":"pa-1497983247795",
                        "isExpanded":true,
                        "parent":0,
                        "linkedBoxes":{ },
                        "children":[],
                        "boxes":["bo-1535353943033"],
                        "level":1,
                        "type":"slide",
                        "hidden":false,
                        "customSize":0
                    },
                    "pa-1535353910908":{
                        "id":"pa-1535353910908",
                        "isExpanded":true,
                        "parent":"se-1535354055428",
                        "children":[],
                        "boxes":["bs-1535353910908"],
                        "linkedBoxes":{
                            "rm-1535353959572":"bo-1535353943033"
                        },
                        "level":2,
                        "type":"document",
                        "hidden":false,
                        "customSize":0
                    },
                    "se-1535354055428":{
                        "id":"se-1535354055428",
                        "isExpanded":true,
                        "parent":0,
                        "children":["pa-1535353910908"],
                        "boxes":[],
                        "linkedBoxes":{ },
                        "level":1,
                        "type":"section",
                        "hidden":false,
                    }
                },
                "containedViewsById":{
                    "cv-1535353924845":{
                        "info":"new",
                        "type":"slide",
                        "id":"cv-1535353924845",
                        "parent":{
                            "rm-1535353924845":"bo-1535353912282"
                        },
                        "boxes":["bo-1535353987146"],
                    }
                },
                "containedViewSelected":"cv-1535353924845",
                "displayMode":"list",
                "pluginToolbarsById":{
                    "bs-1535353910908":{
                        "id":"bs-1535353910908",
                        "pluginId":"sortable_container",
                        "showTextEditor":false,
                        "state":{ },
                        "structure":{
                            "aspectRatio":true,
                            "height":"",
                            "position":"absolute",
                            "rotation":"",
                            "width":""
                        },
                        "style":{
                            "backgroundColor":"#ffffff",
                            "boderWidth":0,
                            "borderColor":"#000000",
                            "borderRadius":0,
                            "borderStyle":"solid",
                            "opacity":1,
                            "padding":0
                        }
                    },
                    "bo-1535353912282":{
                        "id":"bo-1535353912282",
                        "pluginId":"HotspotImages",
                        "state":{
                            "url":"http://vishub.org/pictures/12.jpg"
                        },
                        "structure":{
                            "height":"auto",
                            "width":25,
                            "widthUnit":"%",
                            "heightUnit":"px",
                            "rotation":0,
                            "aspectRatio":true,
                            "position":"absolute"
                        },
                        "style":{
                            "padding":0,
                            "backgroundColor":"#ffffff",
                            "borderWidth":0,
                            "borderStyle":"solid",
                            "borderColor":"#000000",
                            "borderRadius":0,
                            "opacity":1
                            },
                            "showTextEditor":false
                        },
                    "bo-1535353943033":{
                        "id":"bo-1535353943033",
                        "pluginId":"EnrichedPDF",
                        "state":{
                            "url":"https://media.readthedocs.org/pdf/flask-cors/latest/flask-cors.pdf",
                            "numPages":null,
                            "pageNumber":1
                        },
                        "structure":{
                            "height":78.88739946380697,
                            "width":43.03692539562924,
                            "widthUnit":"%",
                            "heightUnit":"%",
                            "rotation":0,
                            "aspectRatio":false,
                            "position":"absolute",
                            "x":"21.57%",
                            "y":"15.622815013404825%"
                        },
                        "style":{
                            "borderWidth":2,
                            "borderStyle":"solid",
                            "borderColor":"#333",
                            "borderRadius":0,
                            "opacity":1
                        },
                        "showTextEditor":false
                    },
                    "bo-1535353987146":{
                        "id":"bo-1535353987146",
                        "pluginId":"MultipleChoice",
                        "state":{
                            "nBoxes":3,
                            "showFeedback":true,
                            "letters":true,
                            "__pluginContainerIds":{
                                "sc-Question":{
                                    "id":"sc-Question",
                                    "name":"Pregunta",
                                    "height":"auto"
                                },
                                "sc-Answer0":{
                                    "id":"sc-Answer0",
                                    "name":"Respuesta 1",
                                    "height":"auto"
                                },
                                "sc-Answer1":{
                                    "id":"sc-Answer1",
                                    "name":"Respuesta 2",
                                    "height":"auto"
                                },
                                "sc-Answer2":{
                                    "id":"sc-Answer2",
                                    "name":"Respuesta 3",
                                    "height":"auto"
                                },
                                "sc-Feedback":{
                                    "id":"sc-Feedback",
                                    "name":"Explicación",
                                    "height":"auto"
                                }
                            }
                        },
                        "structure":{
                            "height":"auto",
                            "width":60,
                            "widthUnit":"%",
                            "heightUnit":"%",
                            "rotation":0,
                            "aspectRatio":false,
                            "position":"absolute"
                        },
                        "style":{
                            "padding":10,
                            "backgroundColor":"#ffffff",
                            "borderWidth":1,
                            "borderStyle":"solid",
                            "borderColor":"#dbdbdb",
                            "borderRadius":0,
                            "opacity":1
                        },
                        "showTextEditor":false
                    },
                    "bo-1535353987152_0":{
                        "id":"bo-1535353987152_0",
                        "pluginId":"BasicText",
                        "state":{
                            __text":"<p>Esta es una pregunta con varias opciones para responder. Sólo una puede ser correcta. Puedes escribir aquí el enunciado de la pregunta</p>"
                        },
                        "structure":{
                            "height":"auto",
                            "width":"auto",
                            "widthUnit":"%",
                            "heightUnit":"px",
                            "rotation":0,
                            "aspectRatio":false,
                            "position":"absolute"
                        },
                        "style":{
                            "padding":7,
                            "backgroundColor":"rgba(255, 255, 255, 0)",
                            "borderWidth":0,
                            "borderStyle":"solid",
                            "borderColor":"#000000",
                            "borderRadius":0,
                            "opacity":1
                        },
                        "showTextEditor":false
                    },
                    "bo-1535353987152_1":{
                        "id":"bo-1535353987152_1",
                        "pluginId":"BasicText",
                        "state":{
                            "__text":"<p>Respuesta 1</p>"
                        },
                        "structure":{
                            "height":"auto",
                            "width":"auto",
                            "widthUnit":"%",
                            "heightUnit":"px",
                            "rotation":0,
                            "aspectRatio":false,
                            "position":"absolute"
                        },
                        "style":{
                            "padding":7,
                            "backgroundColor":"rgba(255, 255, 255, 0)",
                            "borderWidth":0,
                            "borderStyle":"solid",
                            "borderColor":"#000000",
                            "borderRadius":0,
                            "opacity":1
                        },
                        "showTextEditor":false
                    },
                    "bo-1535353987152_2":{
                        "id":"bo-1535353987152_2",
                        "pluginId":"BasicText",
                        "state":{
                            "__text":"<p>Respuesta 2</p>"
                        },
                        "structure":{
                            "height":"auto",
                            "width":"auto",
                            "widthUnit":"%",
                            "heightUnit":"px",
                            "rotation":0,
                            "aspectRatio":false,
                            "position":"absolute"
                        },
                        "style":{
                            "padding":7,
                            "backgroundColor":"rgba(255, 255, 255, 0)",
                            "borderWidth":0,
                            "borderStyle":"solid",
                            "borderColor":"#000000",
                            "borderRadius":0,
                            "opacity":1
                        },
                        "showTextEditor":false
                    },
                    "bo-1535353987152_3":{
                        "id":"bo-1535353987152_3",
                        "pluginId":"BasicText",
                        "state":{
                            "__text":"<p>Respuesta 3</p>"
                        },
                        "structure":{
                            "height":"auto",
                            "width":"auto",
                            "widthUnit":"%",
                            "heightUnit":"px",
                            "rotation":0,
                            "aspectRatio":false,
                            "position":"absolute"
                        },
                        "style":{
                            padding":7,
                            "backgroundColor":"rgba(255, 255, 255, 0)",
                            "borderWidth":0,
                            "borderStyle":"solid",
                            "borderColor":"#000000",
                            "borderRadius":0,
                            "opacity":1
                        },
                        "showTextEditor":false},
                    "bo-1535353987152_4":{
                        "id":"bo-1535353987152_4",
                        "pluginId":"BasicText",
                        "state":{
                            "__text":"<p>Aquí puedes incluir una explicación acerca de la respuesta</p>"},
                        "structure":{
                            "height":"auto",
                            "width":"auto",
                            "widthUnit":"%",
                            "heightUnit":"px",
                            "rotation":0,
                            "aspectRatio":false,
                            "position":"absolute"
                        },
                        "style":{
                            "padding":7,
                            "backgroundColor":"rgba(255, 255, 255, 0)",
                            "borderWidth":0,
                            "borderStyle":"solid",
                            "borderColor":"#000000",
                            "borderRadius":0,
                            "opacity":1
                        },
                        "showTextEditor":false
                    }
                },
                "viewToolbarsById":{
                    "pa-1497983247795":{
                        "id":"pa-1497983247795",
                        "viewName":"Intro",
                        "breadcrumb":"hidden",
                        "courseTitle":"hidden",
                        "documentSubtitle":"hidden",
                        "documentSubtitleContent":"Subtítulo",
                        "documentTitle":"expanded",
                        "documentTitleContent":"",
                        "numPage":"hidden",
                        "numPageContent":"",
                        "background":"#ffffff",
                        "backgroundAttr":"",
                        "aspectRatio":""
                    },
                    "pa-1535353910908":{
                        "id":"pa-1535353910908",
                        "breadcrumb":"reduced",
                        "doc_type":"document",
                        "viewName":"Final",
                        "courseTitle":"hidden",
                        "documentSubtitle":"hidden",
                        "documentSubtitleContent":"Subtítulo",
                        "documentTitle":"expanded",
                        "documentTitleContent":"",
                        "numPage":"hidden",
                        "numPageContent":1,
                        "customSize":0,
                        "aspectRatio":true,
                        "background":"#ffffff",
                        "backgroundAttr":""
                        },
                    "cv-1535353924845":{
                        "id":"cv-1535353924845",
                        "breadcrumb":"hidden",
                        "doc_type":"slide",
                        "viewName":"Extra",
                        "courseTitle":"hidden",
                        "documentSubtitle":"hidden",
                        "documentSubtitleContent":"Subtítulo",
                        "documentTitle":"expanded",
                        "documentTitleContent":"",
                        "numPage":"hidden",
                        "numPageContent":"",
                        "customSize":0,
                        "aspectRatio":true,
                        "background":"#ffffff",
                        "backgroundAttr":""},
                    "se-1535354055428":{
                        "id":"se-1535354055428",
                        "breadcrumb":"reduced",
                        "doc_type":"section",
                        "viewName":"F1",
                        "courseTitle":"hidden",
                        "documentSubtitle":"hidden",
                        "documentSubtitleContent":"Subtítulo",
                        "documentTitle":"expanded",
                        "documentTitleContent":"",
                        "numPage":"hidden",
                        "numPageContent":2,
                        "customSize":0,
                        "aspectRatio":true,
                        "background":"#ffffff",
                        "backgroundAttr":""
                    }
                },
                "exercises":{
                    "pa-1497983247795":{
                        "id":"pa-1497983247795",
                        "submitButton":true,
                        "trackProgress":false,
                        "attempted":false,
                        "weight":10,
                        "minForPass":50,
                        "exercises":{},
                        "score":0
                    },
                    "pa-1535353910908":{
                        "id":"pa-1535353910908",
                        "submitButton":true,
                        "trackProgress":false,
                        "attempted":false,
                        "minForPass":50,
                        "score":0,
                        "weight":10,
                        "exercises":{}
                    },
                    "cv-1535353924845":{
                        "id":"cv-1535353924845",
                        "submitButton":true,
                        "trackProgress":false,
                        "attempted":false,
                        "minForPass":50,
                        "score":0,
                        "weight":10,
                        "exercises":{
                            "bo-1535353987146":{
                                "name":"MultipleChoice",
                                "id":"bo-1535353987146",
                                "weight":1,
                                "correctAnswer":0,
                                "currentAnswer":false,
                                "attempted":false,
                                "score":0
                            }
                        }
                    }
                },
                "isBusy":{
                    "value":false,
                    "msg":"La operación se ha realizado correctamente",
                    "reason":"saving_state"
                },
            },
            "future":[]
        },
        "status":"draft",
        "everPublished":false,
        "filesUploaded":{
            "file-1535354328935":{
                "id":"file-1535354328935",
                "url":"http://localhost:8081/fb8d18d216bebbe4dfc39f0b1771a3b4.jpg",
                "name":"desert.jpg",
                "keywords":"",
                "mimetype":"image/jpeg"
            }
        }
    }

La aplicación emplea redux-undo, para facilitar la implementación de las acciones de deshacer/rehacer. Es por ello que las propiedades que se pueden deshacer/rehacer están en un grupo aparte (undoGroup), que contiene el estado actual (present) y la lista de estados pasados y futuros (past y future respectivamente). Dentro del objeto present, se encuentra la información más relevante acerca del contenido del documento Ediphy. Alguno de los campos más interesantes son los siguientes: The application uses redux-undoin order to make it easier to implement the undo/redo actions. Thus, the propeties that can be undone/redone are in a separate group (undoGroup), which contains the current state (present) and the list of past and future states. Inside the present object is where the most relevant information about an Ediphy document is. Some of the most interesting fields are the following:

  • version is the version number of the Ediphy document with which the content is being edited.
  • globalConfig is a dictionary that has the global proyect configuration. In the section Configuración Global all of the properties are explained.
  • boxesById is a dictionary that contains every EditorBox using its identifier as key. It can be appreciated that each one of them has a lot of information:
  • id: determines if it is an EditorBox, the identifier begins with "bo-"; if it is a EditorBoxSortable, it begins with "bs-".
  • parent: parent identifier. It can be either a view (page or sections) or another EditorBox.
  • container: container identifier. If it is a child of a EditorBox, it will be store inside a SortableContainer, and this property will store the identifier of itself (this SortableContainer and probably other will appear as EditorBox children).
  • children: array with children identifiers (refering to SortableContainer, and not to EditorBox),
  • sortableContainers: dictionary that contains the definition of every SortableContainer children of the actual EditorBox. These have an ids array (this time EditorBox), height and distribution of columns and rows of the SortableContainer.
  • content: JSON that discraves the HTML of the plugin template.
  • text: variable that saves the exact output of CKEditor to restore it when editing again. It is only used if the plugin has activated text edition.
  • draggable: boolean that tells if you can drag inside its container.
  • resizable: boolean that tells if you can modify its size manually.
  • col: column number taht is inside its SortableContainer.
  • row: row number that is inside its SortableContainer
  • position: Dictionary that includes information about the position of a EditorBox. Precisely:
    • x: Position x.
    • y: Position y.
    • type: Can be a floating box (absolute) or ordered (relative)
  • boxSelected: stores the identifier of the EditorBox selecting or -1 if none
  • boxes it is an array where al EditorBox identifiers are inside a document.
  • navItemsIds it is an array where all identfiers of every views (page and sections) are.
  • navItemsById it is a dictionary that contains all views using its identifier as key (as prefix "se-" for sections and "pa-" for pages). Also, there is always a ghost view with a 0 identifier that is the parent of every single view.
  • navItemSelected stores the unique identifier of the view that is being edited
  • containedViewsById it is a dictionary that contains every contained view using its identifier as key (it is used "cv-" as prefix to distinguish from the others). It is important to tell that, because all the views are at the same level, the object parent of every of them references the EditorBox and tells the concrete place where it is linked. In the example is clearly understood.
  • containedViewSelected stores the unique identifier of the contained view that is being edited
  • marksById stores information relative to the marks. It is an object in which the keys are the mark identifiers and the object contain the mark information with the following attributes.
    • id": Identifier of the mark
    • origin": Identifier of the box that contains the mark
    • title": Name of the mark
    • connection": Target (identifierr of the view, link or text)
    • color: Color of the mark
    • connectMode": Type of connection (to an existing view, a new one, an external link or pop-up)
    • value": Value of the mark (the format is different for each plugin)
  • indexSelected stores the unique identifier of the contained view or view that is being edited in the index, in other words, the one that can be deleted, create pages, etc.
  • pluginToolbarsById it is a dictionary with every toolbar of the EditorBox, using as an identifier key of the correspondant EditorBox. The following properties are specially relevant:
    • id: Identifier of the box
    • pluginId: Identifier of the plugin
    • state: State of the box (depends on the plugin)
    • structure: Structure (contains information relative to the width, height, etc)
    • style: Style of the box (CSS properties)
  • viewToolbarsById it is a dictionary with every toolbar of the views and contained views, using as a key the identifier of the corresponding view. The following properties are especially relevant for each view:
    • id: Identifier of the view
    • viewName: Name of the view in the index
    • breadcrumb: Determines if the breadcrumbs (hierarchy of the sections) are shown in the view
    • courseTitle: : Determines if the document global title is shown in the view
    • documentSubtitle: Determines if a subtitle is shown in the view
    • documentSubtitleContent: Content of the subtitle
    • documentTitle: Determines if the view title is shown in the view
    • documentTitleContent: Content of the tiel (by default same as in the index)
    • numPage: Determines if the page number is shown in the view
    • numPageContent: Page number
    • background: View background
    • backgroundAttr: Background type (center, repeat), same as in css
    • aspectRatio: Aspect ratio (on slides)
  • exercises is a dictionary with all the information relative to the exercies. It has a two-level hierarchy: views and boxes. The first one includes key-value pairs where the key is the view identifier and the values is an object with the following properties:
    • id: Identifier of the view
    • submitButton:Determines if a submit button should be shown in the view (used in the visor)
    • attempted: Indicates if the user has already submitted the exercises in this view (used in the visor)
    • minForPass: Minimum grade for passing.
    • score: Score obtained (used in the visor)
    • weight: Weight of the view over the sum of the views weight.
    • exercises: It is an object that contains key-value pairs in which the key is the box identifier and the value is an object with the following properties:
      • name: Name of the type of exercise
      • id: Box identifier
      • weight: Weight of the exercise over the sum of all of the exercises in the view.
      • correctAnswer: Correct answer specified by the author
      • currentAnswer: Answer selected by the user (used in the visor)
      • attempted: Indicates if an user has already submitted the exercise (used in the visor)
      • score : Score obtained for the exercise (used in the visor)

Future improvement

Delete properties of a state that are not used or are redundant

Clone this wiki locally