From 80b31f46df060874eb6fc44e607205fe9826403e Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Fri, 17 Aug 2012 10:39:01 -0400 Subject: [PATCH 1/6] Wip --- lms/templates/courseware/courseware.html | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 2950aa827e..95b9a690e7 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -72,3 +72,36 @@ + +
+ Calculator + +
+
+
+ + +
+ Hints +
+
Suffixes:
+
%kMGTcmunp
+
Operations:
+
^ * / + - ()
+
Functions:
+
sin, cos, tan, sqrt, log10, log2, ln, arccos, arcsin, arctan, abs
+
Constants
+
e, pi
+ + +
+
+
+ + +
+ +
+
From db492cc400a12368f0eb10b317398bcd2ef2470c Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Fri, 17 Aug 2012 10:59:51 -0400 Subject: [PATCH 2/6] Add back in calculator related code. --- lms/static/coffee/src/calculator.coffee | 2 +- lms/static/images/info-icon.png | Bin 0 -> 302 bytes lms/static/sass/application.scss | 1 + lms/static/sass/layout/_calculator.scss | 158 ++++++++++++++++++++++++ lms/urls.py | 2 +- 5 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 lms/static/images/info-icon.png create mode 100644 lms/static/sass/layout/_calculator.scss diff --git a/lms/static/coffee/src/calculator.coffee b/lms/static/coffee/src/calculator.coffee index 18e7fba4ec..2cf4893d52 100644 --- a/lms/static/coffee/src/calculator.coffee +++ b/lms/static/coffee/src/calculator.coffee @@ -8,7 +8,7 @@ class @Calculator toggle: (event) -> event.preventDefault() - $('li.calc-main').toggleClass 'open' + $('div.calc-main').toggleClass 'open' $('#calculator_wrapper #calculator_input').focus() if $('.calc.closed').length $('.calc').attr 'aria-label', 'Open Calculator' diff --git a/lms/static/images/info-icon.png b/lms/static/images/info-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..736b2f2374cc7826651ce592eab81a3271e1fc5a GIT binary patch literal 302 zcmV+}0nz@6P)NklRR#urEkzFl&+-@(5Yk!okHlEDU?1y*HSWN>RL)Ep@h&W z{VyrUaZg(^d`s?s|Kz$kMw+HN16V;!_~7XBy3GmHf(k+~r4kSBY|{bekg?}E^m)k; z9xQl+4*9}bQ)JSTqbBqOyICI##|yyV0qz1Z6vBE5mMRG~iwP`UP-p7IRv@go6RsaA107*qoM6N<$f@y(& AP5=M^ literal 0 HcmV?d00001 diff --git a/lms/static/sass/application.scss b/lms/static/sass/application.scss index 944d3b2884..df88361111 100644 --- a/lms/static/sass/application.scss +++ b/lms/static/sass/application.scss @@ -16,6 +16,7 @@ @import 'shared/course_filter'; @import 'shared/modal'; @import 'shared/activation_messages'; +@import 'layout/calculator'; @import 'multicourse/home'; @import 'multicourse/dashboard'; diff --git a/lms/static/sass/layout/_calculator.scss b/lms/static/sass/layout/_calculator.scss new file mode 100644 index 0000000000..948b26a759 --- /dev/null +++ b/lms/static/sass/layout/_calculator.scss @@ -0,0 +1,158 @@ +div.calc-main { + bottom: -126px; + left: 0; + position: fixed; + @include transition(bottom); + -webkit-appearance: none; + width: 100%; + z-index: 99; + + &.open { + bottom: -36px; + + div#calculator_wrapper form div.input-wrapper div.help-wrapper dl { + display: block; + } + } + + a.calc { + background: url("../images/calc-icon.png") rgba(#111, .9) no-repeat center; + border-bottom: 0; + @include border-radius(3px 3px 0 0); + color: #fff; + float: right; + height: 20px; + @include hide-text; + @include inline-block; + margin-right: 10px; + padding: 8px 12px; + position: relative; + top: -36px; + width: 16px; + + &:hover { + opacity: .8; + } + + &.closed { + background-image: url("../images/close-calc-icon.png"); + } + } + + div#calculator_wrapper { + background: rgba(#111, .9); + clear: both; + max-height: 90px; + position: relative; + top: -36px; + + form { + @extend .clearfix; + @include box-sizing(border-box); + padding: lh(); + + input#calculator_button { + background: #111; + border: 1px solid #000; + @include border-radius(0); + @include box-shadow(none); + @include box-sizing(border-box); + color: #fff; + float: left; + font-size: 30px; + font-weight: bold; + margin: 0 (flex-gutter() / 2); + padding: 0; + text-shadow: none; + -webkit-appearance: none; + width: flex-grid(.5) + flex-gutter(); + + &:hover { + color: #333; + } + } + + input#calculator_output { + background: #222; + border: 0; + @include box-shadow(none); + @include box-sizing(border-box); + color: #fff; + float: left; + font-size: 16px; + font-weight: bold; + margin: 1px 0 0; + padding: 10px; + -webkit-appearance: none; + width: flex-grid(4); + } + + div.input-wrapper { + @extend .clearfix; + float: left; + margin: 0; + position: relative; + width: flex-grid(7.5); + + input#calculator_input { + border: none; + @include box-shadow(none); + @include box-sizing(border-box); + font-size: 16px; + padding: 10px; + -webkit-appearance: none; + width: 100%; + + &:focus { + outline: none; + border: none; + } + } + + div.help-wrapper { + position: absolute; + right: 8px; + top: 15px; + + a { + background: url("../images/info-icon.png") center center no-repeat; + height: 17px; + @include hide-text; + width: 17px; + } + + dl { + background: #fff; + @include border-radius(3px); + @include box-shadow(0 0 3px #999); + color: #333; + display: none; + opacity: 0; + padding: 10px; + position: absolute; + right: -40px; + top: -110px; + @include transition(); + width: 500px; + + &.shown { + opacity: 1; + top: -115px; + } + + dt { + clear: both; + float: left; + font-weight: bold; + padding-right: lh(.5); + } + + dd { + float: left; + } + } + } + } + } + } +} diff --git a/lms/urls.py b/lms/urls.py index 86d654eb40..6415680a9d 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -110,7 +110,7 @@ if settings.COURSEWARE_ENABLED: name='change_setting'), # TODO: These views need to be updated before they work - # url(r'^calculate$', 'util.views.calculate'), + url(r'^calculate$', 'util.views.calculate'), # TODO: We should probably remove the circuit package. I believe it was only used in the old way of saving wiki circuits for the wiki # url(r'^edit_circuit/(?P[^/]*)$', 'circuit.views.edit_circuit'), # url(r'^save_circuit/(?P[^/]*)$', 'circuit.views.save_circuit'), From 8d747e44231e045b1f454eb155221728774a80d7 Mon Sep 17 00:00:00 2001 From: Matthew Mongeau Date: Fri, 17 Aug 2012 12:07:45 -0400 Subject: [PATCH 3/6] Conditionally show calculator --- common/lib/xmodule/xmodule/course_module.py | 18 +++++++ lms/templates/courseware/courseware.html | 53 +++++++++++---------- 2 files changed, 46 insertions(+), 25 deletions(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index 28668ef088..beade43aea 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -127,6 +127,24 @@ class CourseDescriptor(SequenceDescriptor): def grade_cutoffs(self): return self._grading_policy['GRADE_CUTOFFS'] + @property + def show_calculator(self): + return self.metadata.get("show_calculator", None) == "Yes" + + @lazyproperty + def __grading_policy(self): + policy_string = "" + + try: + with self.system.resources_fs.open("grading_policy.json") as grading_policy_file: + policy_string = grading_policy_file.read() + except (IOError, ResourceNotFoundError): + log.warning("Unable to load course settings file from grading_policy.json in course " + self.id) + + grading_policy = load_grading_policy(policy_string) + + return grading_policy + @lazyproperty def grading_context(self): """ diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 95b9a690e7..0d390d83a2 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -73,35 +73,38 @@ -
- Calculator -
-
-
- +% if course.show_calculator: +
+ Calculator -
- Hints -
-
Suffixes:
-
%kMGTcmunp
-
Operations:
-
^ * / + - ()
-
Functions:
-
sin, cos, tan, sqrt, log10, log2, ln, arccos, arcsin, arctan, abs
-
Constants
-
e, pi
+
+ +
+ - -
+ + +
-
- - -
+ + + +
- +% endif From 9d6bf9a8fdc27d206ab66596726967a02e18fb34 Mon Sep 17 00:00:00 2001 From: Kyle Fiedler Date: Mon, 20 Aug 2012 14:37:00 -0400 Subject: [PATCH 4/6] Added some fixes for the calculator --- lms/static/sass/application.scss | 1 - lms/static/sass/course.scss | 1 + .../sass/course/layout/_calculator.scss | 30 ++-- lms/static/sass/layout/_calculator.scss | 158 ------------------ 4 files changed, 16 insertions(+), 174 deletions(-) delete mode 100644 lms/static/sass/layout/_calculator.scss diff --git a/lms/static/sass/application.scss b/lms/static/sass/application.scss index df88361111..944d3b2884 100644 --- a/lms/static/sass/application.scss +++ b/lms/static/sass/application.scss @@ -16,7 +16,6 @@ @import 'shared/course_filter'; @import 'shared/modal'; @import 'shared/activation_messages'; -@import 'layout/calculator'; @import 'multicourse/home'; @import 'multicourse/dashboard'; diff --git a/lms/static/sass/course.scss b/lms/static/sass/course.scss index 6c63c17f1f..a8d93c4410 100644 --- a/lms/static/sass/course.scss +++ b/lms/static/sass/course.scss @@ -20,6 +20,7 @@ @import 'course/courseware/courseware'; @import 'course/courseware/sidebar'; @import 'course/courseware/amplifier'; +@import 'course/layout/calculator'; // course-specific courseware (all styles in these files should be gated by a diff --git a/lms/static/sass/course/layout/_calculator.scss b/lms/static/sass/course/layout/_calculator.scss index 117f5a78be..2819546f9f 100644 --- a/lms/static/sass/course/layout/_calculator.scss +++ b/lms/static/sass/course/layout/_calculator.scss @@ -1,4 +1,4 @@ -li.calc-main { +div.calc-main { bottom: -126px; left: 0; position: fixed; @@ -9,10 +9,6 @@ li.calc-main { &.open { bottom: -36px; - - div#calculator_wrapper form div.input-wrapper div.help-wrapper dl { - display: block; - } } a.calc { @@ -27,7 +23,7 @@ li.calc-main { margin-right: 10px; padding: 8px 12px; position: relative; - top: -36px; + top: -45px; width: 16px; &:hover { @@ -36,6 +32,7 @@ li.calc-main { &.closed { background-image: url("../images/close-calc-icon.png"); + top: -36px; } } @@ -61,6 +58,7 @@ li.calc-main { float: left; font-size: 30px; font-weight: bold; + height: 35px; margin: 0 (flex-gutter() / 2); padding: 0; text-shadow: none; @@ -73,7 +71,7 @@ li.calc-main { } input#calculator_output { - background: #222; + background: #111; border: 0; @include box-shadow(none); @include box-sizing(border-box); @@ -111,14 +109,14 @@ li.calc-main { div.help-wrapper { position: absolute; - right: 8px; - top: 15px; + right: 0; + top: 0; a { background: url("../images/info-icon.png") center center no-repeat; - height: 17px; + height: 35px; @include hide-text; - width: 17px; + width: 35px; } dl { @@ -127,28 +125,30 @@ li.calc-main { @include box-shadow(0 0 3px #999); color: #333; display: none; + line-height: lh(); opacity: 0; padding: 10px; position: absolute; right: -40px; - top: -110px; + top: -122px; @include transition(); - width: 500px; + width: 600px; &.shown { + display: block; opacity: 1; - top: -115px; } dt { clear: both; float: left; font-weight: bold; - padding-right: lh(.5); + padding-right: 12px; } dd { float: left; + margin-left: 0; } } } diff --git a/lms/static/sass/layout/_calculator.scss b/lms/static/sass/layout/_calculator.scss deleted file mode 100644 index 948b26a759..0000000000 --- a/lms/static/sass/layout/_calculator.scss +++ /dev/null @@ -1,158 +0,0 @@ -div.calc-main { - bottom: -126px; - left: 0; - position: fixed; - @include transition(bottom); - -webkit-appearance: none; - width: 100%; - z-index: 99; - - &.open { - bottom: -36px; - - div#calculator_wrapper form div.input-wrapper div.help-wrapper dl { - display: block; - } - } - - a.calc { - background: url("../images/calc-icon.png") rgba(#111, .9) no-repeat center; - border-bottom: 0; - @include border-radius(3px 3px 0 0); - color: #fff; - float: right; - height: 20px; - @include hide-text; - @include inline-block; - margin-right: 10px; - padding: 8px 12px; - position: relative; - top: -36px; - width: 16px; - - &:hover { - opacity: .8; - } - - &.closed { - background-image: url("../images/close-calc-icon.png"); - } - } - - div#calculator_wrapper { - background: rgba(#111, .9); - clear: both; - max-height: 90px; - position: relative; - top: -36px; - - form { - @extend .clearfix; - @include box-sizing(border-box); - padding: lh(); - - input#calculator_button { - background: #111; - border: 1px solid #000; - @include border-radius(0); - @include box-shadow(none); - @include box-sizing(border-box); - color: #fff; - float: left; - font-size: 30px; - font-weight: bold; - margin: 0 (flex-gutter() / 2); - padding: 0; - text-shadow: none; - -webkit-appearance: none; - width: flex-grid(.5) + flex-gutter(); - - &:hover { - color: #333; - } - } - - input#calculator_output { - background: #222; - border: 0; - @include box-shadow(none); - @include box-sizing(border-box); - color: #fff; - float: left; - font-size: 16px; - font-weight: bold; - margin: 1px 0 0; - padding: 10px; - -webkit-appearance: none; - width: flex-grid(4); - } - - div.input-wrapper { - @extend .clearfix; - float: left; - margin: 0; - position: relative; - width: flex-grid(7.5); - - input#calculator_input { - border: none; - @include box-shadow(none); - @include box-sizing(border-box); - font-size: 16px; - padding: 10px; - -webkit-appearance: none; - width: 100%; - - &:focus { - outline: none; - border: none; - } - } - - div.help-wrapper { - position: absolute; - right: 8px; - top: 15px; - - a { - background: url("../images/info-icon.png") center center no-repeat; - height: 17px; - @include hide-text; - width: 17px; - } - - dl { - background: #fff; - @include border-radius(3px); - @include box-shadow(0 0 3px #999); - color: #333; - display: none; - opacity: 0; - padding: 10px; - position: absolute; - right: -40px; - top: -110px; - @include transition(); - width: 500px; - - &.shown { - opacity: 1; - top: -115px; - } - - dt { - clear: both; - float: left; - font-weight: bold; - padding-right: lh(.5); - } - - dd { - float: left; - } - } - } - } - } - } -} From e55bbbc736971070382d29c8c497b959229b665e Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Wed, 29 Aug 2012 10:58:40 -0400 Subject: [PATCH 5/6] Remove __grading_policy related items, which got in here accidentally --- common/lib/xmodule/xmodule/course_module.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/common/lib/xmodule/xmodule/course_module.py b/common/lib/xmodule/xmodule/course_module.py index beade43aea..d15a438ea6 100644 --- a/common/lib/xmodule/xmodule/course_module.py +++ b/common/lib/xmodule/xmodule/course_module.py @@ -131,20 +131,6 @@ class CourseDescriptor(SequenceDescriptor): def show_calculator(self): return self.metadata.get("show_calculator", None) == "Yes" - @lazyproperty - def __grading_policy(self): - policy_string = "" - - try: - with self.system.resources_fs.open("grading_policy.json") as grading_policy_file: - policy_string = grading_policy_file.read() - except (IOError, ResourceNotFoundError): - log.warning("Unable to load course settings file from grading_policy.json in course " + self.id) - - grading_policy = load_grading_policy(policy_string) - - return grading_policy - @lazyproperty def grading_context(self): """ From 1acb7dc24f4b8299c7c1335a090c8ee116fa7c88 Mon Sep 17 00:00:00 2001 From: David Ormsbee Date: Thu, 6 Sep 2012 15:52:31 -0400 Subject: [PATCH 6/6] Add a short delay to calculator input focus so it doesn't jump to the bottom of the screen when you open it. --- lms/static/coffee/src/calculator.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lms/static/coffee/src/calculator.coffee b/lms/static/coffee/src/calculator.coffee index 2cf4893d52..788081ebd6 100644 --- a/lms/static/coffee/src/calculator.coffee +++ b/lms/static/coffee/src/calculator.coffee @@ -9,11 +9,14 @@ class @Calculator toggle: (event) -> event.preventDefault() $('div.calc-main').toggleClass 'open' - $('#calculator_wrapper #calculator_input').focus() if $('.calc.closed').length $('.calc').attr 'aria-label', 'Open Calculator' else $('.calc').attr 'aria-label', 'Close Calculator' + # TODO: Investigate why doing this without the timeout causes it to jump + # down to the bottom of the page. I suspect it's because it's putting the + # focus on the text field before it transitions onto the page. + setTimeout (-> $('#calculator_wrapper #calculator_input').focus()), 100 $('.calc').toggleClass 'closed'