Browse Source

fixed macro replacement; added space behind '<' replacement; all checkboxes with []; added macros replacement

tags/1.0.3^0
Robin Thoni 9 years ago
parent
commit
6f8a9083d5
1 changed files with 7 additions and 11 deletions
  1. 7
    11
      app/controllers/home.controller.js

+ 7
- 11
app/controllers/home.controller.js View File

37
                     .trim();
37
                     .trim();
38
                 $scope.macros.forEach(function(macro)
38
                 $scope.macros.forEach(function(macro)
39
                 {
39
                 {
40
-                    text = text.replace(new RegExp($scope.escapeRegExp(macro.latex) + "([^a-zA-Z])", "g"), function($1, $2)
40
+                    var regex = macro.latex.match(/[a-zA-Z0-9]$/) != null ? "([^a-zA-Z0-9])" : "";
41
+                    text = text.replace(new RegExp($scope.escapeRegExp(macro.latex) + regex, "g"), function($1, $2)
41
                     {
42
                     {
42
                         return macro.html + $2;
43
                         return macro.html + $2;
43
                     });
44
                     });
92
                 {
93
                 {
93
                     $scope.Data.Output += question.Text + "\n";
94
                     $scope.Data.Output += question.Text + "\n";
94
 
95
 
95
-                    var goodAnswersCount = 0;
96
-                    question.Answers.forEach(function(answer)
97
-                    {
98
-                        if (answer.Correct) {
99
-                            ++goodAnswersCount;
100
-                        }
101
-                    });
96
+
102
 
97
 
103
                     question.Answers.forEach(function(answer)
98
                     question.Answers.forEach(function(answer)
104
                     {
99
                     {
105
-                        $scope.Data.Output += "\t" + (goodAnswersCount > 1 ? "[" : "(") + (answer.Correct ? "x" : "") +
106
-                            (goodAnswersCount > 1 ? "]" : ")") + answer.Text + "\n";
100
+                        $scope.Data.Output += "\t[" + (answer.Correct ? "x" : "") + "]" + answer.Text + "\n";
107
                     });
101
                     });
108
                     $scope.Data.Output += "\n";
102
                     $scope.Data.Output += "\n";
109
                 });
103
                 });
118
             $scope.addMacro("\\RR", "\\mathbb{R}");
112
             $scope.addMacro("\\RR", "\\mathbb{R}");
119
             $scope.addMacro("\\CC", "\\mathbb{C}");
113
             $scope.addMacro("\\CC", "\\mathbb{C}");
120
             $scope.addMacro("\\QQ", "\\mathbb{Q}");
114
             $scope.addMacro("\\QQ", "\\mathbb{Q}");
115
+            $scope.addMacro("\\NN", "\\mathbb{N}");
116
+            $scope.addMacro("\\ZZ", "\\mathbb{Z}");
121
             $scope.addMacro("\\di", "\\displaystyle");
117
             $scope.addMacro("\\di", "\\displaystyle");
122
             $scope.addMacro("\\dd", "\\text{d}");
118
             $scope.addMacro("\\dd", "\\text{d}");
123
             $scope.addMacro("<<", "&#171;");
119
             $scope.addMacro("<<", "&#171;");
124
             $scope.addMacro(">>", "&#187;");
120
             $scope.addMacro(">>", "&#187;");
125
-            $scope.addMacro("<", "&#60;");
121
+            $scope.addMacro("<", "&#60; ");
126
             $scope.addMacro(">", "&#62;");
122
             $scope.addMacro(">", "&#62;");
127
             $scope.addMacro("\\\'{E}", "&#201;");
123
             $scope.addMacro("\\\'{E}", "&#201;");
128
             $scope.addMacro("\\\'{A}", "&#192;");
124
             $scope.addMacro("\\\'{A}", "&#192;");

Loading…
Cancel
Save