• No se han encontrado resultados

ANEXO B. BLOG DE NOTAS DE REVISIÓN DE FF

In document TRABAJO FIN DE GRADO (página 107-119)

ANEXO B. BLOG DE NOTAS DE REVISIÓN

84

Figura 2:Errores detectados en sprint 11 (2)

Figura 3:Errores detectados en sprint 11 (3)

ANEXO . ANEXO B. BLOG DE NOTAS DE REVISIÓN DEFF 85

Figura 4:Errores detectados en sprint 11 (4)

ANEXO C. LIBRARY.JSON

Listado 2:Definición de library.json para Crucigrama

1 {

2 "title": "My CrossWord 1",

3 "description": "Haz tu propio crucigrama introduciendo las palabras y las pistas",

4 "majorVersion": 1,

5 "minorVersion": 0,

6 "patchVersion": 0,

7 "runnable": 1,

8 "author": "Jose Manuel Riballo Moreno",

9 "license": "cc-by-sa",

10 "machineName": "H5P.MyCrossWord1",

11 "preloadedCss": [

12 {"path": "css/mycrossword.css"}

13 ],

14 "preloadedJs": [

15 {

16 "path": "js/mycrossword.js"

17 },

18 {

19 "path": "js/crossword.js"

20 },

21 {

22 "path": "js/word.js"

23 },

24 {

25 "path": "js/cell.js"

26 }

27 ]

28 }

ANEXO D. SEMANTICS.JSON

Listado 3:Definición de semantics.json para Crucigrama

1 [

2 {

3 "label": "Words",

4 "name": "words",

5 "type": "list",

6 "entity": "word",

7 "min": 3,

8 "max": 30,

9 "field": {

10 "type": "group",

11 "label": "Word",

12 "fields": [

13 {

14 "label": "Text",

15 "name": "word_text",

16 "type": "text",

17 "maxLength": 15,

18 "description": "The word to find."

19 },

20 {

21 "label": "Clue",

22 "name": "clue",

23 "type": "text",

24 "maxLength": 100,

25 "description": "The clue."

26 }

27 ]

28 }

29 },

30 {

31 "name": "accent_mark",

32 "type": "boolean",

33 "label": "Accent marks",

34 "description": "Distinguish between accent mark character?",

90

35 "default": true

36 },

37 {

38 "name": "upper",

39 "type": "boolean",

40 "label": "Upper or Lower",

41 "description": "Distinguish between upper and lower case?",

42 "default": true

43 },

44 {

45 "name": "difficulty",

46 "type": "select",

47 "label": "Difficulty",

48 "description": "Select the difficulty",

49 "options": [

50 {

51 "value": "easy",

52 "label": "Easy"

53 },

54 {

55 "value": "normal",

56 "label": "Normal"

57 },

58 {

59 "value": "hard",

60 "label": "Hard"

61 }

62 ],

63 "default": "easy"

64 }

65 ]

ANEXO E. CROSSWORD.JS

Listado 4:Código de crucigrama

1 this.getGrid = function (max_tries){

2 var groups = [];

3 for(var tries = 0; tries < max_tries; tries++){

4 clear(); // clear the grid

5 var start_dir = randomDirection();

6 var r = Math.floor(grid.length / 2);

7 var c = Math.floor(grid[0].length / 2);

8 var word_element = word_elements[0];

9 if(start_dir == "across"){

10 c -= Math.floor(word_element.getLength()/2);

11 } else {

12 r -= Math.floor(word_element.getLength()/2);

13 }

14 if(canPlaceWordAt(word_element.getWord(), r, c, start_dir) !==

false){

15 placeWordAt(word_element.getWord(), word_element.getIndex(), r, c, start_dir);

16 } else {

17 bad_words = [word_element];

18 return null;

19 }

20 groups.push(word_elements.slice(1));

21 for(var g = 0; g < groups.length; g++){

22 word_has_been_added_to_grid = false;

23 for(var i = 0; i < groups[g].length; i++){

24 var word_element = groups[g][i];

25 var best_position =

findPositionForWord(word_element.getWord());

26 if(!best_position){

27 if(groups.length - 1 == g) groups.push([]);

28 groups[g+1].push(word_element);

29 } else {

30 var r = best_position["row"], c = best_position["col"], dir = best_position[’direction’];

92

31 placeWordAt(word_element.getWord(), word_element.getIndex(), r, c, dir);

32 word_has_been_added_to_grid = true;

33 }

34 }

35 if(!word_has_been_added_to_grid) break;

36 }

37 if(word_has_been_added_to_grid) return minimizeGrid(); //reduce the grid

38 }

39

40 bad_words = groups[groups.length - 1];

41 return null;

42 }

43 this.getLegend = function(grid){

44 var groups = {"across" : [], "down" : []};

45 var position = 1;

46 for(var r = 0; r < grid.length; r++){

47 for(var c = 0; c < grid[r].length; c++){

48 var cell = grid[r][c];

49 var increment_position = false;

50 for(var k in groups){

51 if(cell && cell[k] && cell[k][’is_start_of_word’]){// word start here?

52 var index = cell[k][’index’];

53 groups[k].push({"position" : position, "index" : index,

"clue" : clues_in[index], "word" : words_in[index]});

54 increment_position = true;

55 }

56 }if(increment_position) position++;

57 }

58 }

59 return groups;

60 }

61 var minimizeGrid = function(){

62 var r_min = GRID_ROWS-1, r_max = 0, c_min = GRID_COLS-1, c_max = 0;

63 for(var r = 0; r < GRID_ROWS; r++){//check min possible size

64 for(var c = 0; c < GRID_COLS; c++){

65 var cell = grid[r][c];

66 if(cell != null){

67 if(r < r_min) r_min = r;if(r > r_max) r_max = r;

68 if(c < c_min) c_min = c;if(c > c_max) c_max = c;

69 }

70 }

71 }

72 var rows = r_max - r_min + 1;

ANEXO . ANEXO E. CROSSWORD.JS 93

73 var cols = c_max - c_min + 1;

74 var new_grid = new Array(rows);

75 for(var r = 0; r < rows; r++){

76 for(var c = 0; c < cols; c++){new_grid[r] = new Array(cols);}

77 }

78

79 // copy the grid to the minimized one

80 for(var r = r_min, r2 = 0; r2 < rows; r++, r2++){

81 for(var c = c_min, c2 = 0; c2 < cols; c++, c2++){new_grid[r2][c2] = grid[r][c];}

82 }

83 return new_grid;

84 }

85 var addCellToGrid = function(word, index_of_word_in_input_list, index_of_char, r, c, direction){

86 var char = word.charAt(index_of_char);

87 if(grid[r][c] == null){

88 grid[r][c] = new H5P.MyCrossWord1.CrosswordCell(word, char);

89 if(!char_index[char]) char_index[char] = [];

90 char_index[char].push({"row" : r, "col" : c});

91 }

92 var is_start_of_word = (index_of_char == 0);

93 grid[r][c][direction] = new

H5P.MyCrossWord1.CrosswordCellNode(is_start_of_word, index_of_word_in_input_list);

94 }

95 var placeWordAt = function(word, index_of_word_in_input_list, row, col, direction){

96 if(direction == "across"){

97 for(var c = col, i = 0; c < col + word.length; c++, i++){

98 addCellToGrid(word, index_of_word_in_input_list, i, row, c, direction);

99 }

100 } else if(direction == "down"){

101 for(var r = row, i = 0; r < row + word.length; r++, i++){

102 addCellToGrid(word, index_of_word_in_input_list, i, r, col, direction);

103 }

104 }

105 }

106 var canPlaceCharAt = function(char, row, col){

107 if(grid[row][col] == null) return 0;// no intersection

108 if(grid[row][col][’char’] == char) return 1;// intersection

109 return false;

110 }

111 var canPlaceWordAt = function(word, row, col, direction){

112 if(row < 0 || row >= grid.length || col < 0 || col >=

94

grid[row].length) return false;// out of bounds

113 if(direction == "across"){

114 if(col + word.length > grid[row].length) return false;//word too long

115 if(col - 1 >= 0 && grid[row][col - 1] != null) return false;//left word

116 if(col + word.length < grid[row].length &&

grid[row][col+word.length] != null) return false;//right word

117 for(var r = row - 1, c = col, i = 0; r >= 0 && c < col + word.length; c++, i++){

118 var is_empty = grid[r][c] == null;

119 var is_intersection = grid[row][c] != null &&

grid[row][c][’char’] == word.charAt(i);

120 var can_place_here = is_empty || is_intersection;

121 if(!can_place_here) return false;

122 }

123 for(var r = row + 1, c = col, i = 0; r < grid.length && c <

col + word.length; c++, i++){

124 var is_empty = grid[r][c] == null;

125 var is_intersection = grid[row][c] != null &&

grid[row][c][’char’] == word.charAt(i);

126 var can_place_here = is_empty || is_intersection;

127 if(!can_place_here) return false;

128 }

129 var intersections = 0;

130 for(var c = col, i = 0; c < col + word.length; c++, i++){

131 var result = canPlaceCharAt(word.charAt(i), row, c);

132 if(result === false) return false;

133 intersections += result;

134 }

135 } else if(direction == "down"){

136 if(row + word.length > grid.length) return false;// out of bounds

137 if(row - 1 >= 0 && grid[row - 1][col] != null) return false;//

word above

138 if(row + word.length < grid.length &&

grid[row+word.length][col] != null) return false;//word below

139 for(var c = col - 1, r = row, i = 0; c >= 0 && r < row + word.length; r++, i++){

140 var is_empty = grid[r][c] == null;

141 var is_intersection = grid[r][col] != null &&

grid[r][col][’char’] == word.charAt(i);

142 var can_place_here = is_empty || is_intersection;

143 if(!can_place_here) return false;

144 }

In document TRABAJO FIN DE GRADO (página 107-119)

Documento similar