Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Conditional tag #17

Closed
osnr opened this issue May 19, 2011 · 0 comments
Closed

Conditional tag #17

osnr opened this issue May 19, 2011 · 0 comments

Comments

@osnr
Copy link
Contributor

osnr commented May 19, 2011

Add an if tag which checks a VAR and displays the content inside depending on the content of the VAR?

Omar R.
May-18 6:09 PM
hrm, could we need conditional hints?
right now the situation is that I have a type of problem where you need to calculate the median
issue is that some number arrays have a central number and some don't, so the hint is different depending on length of the number array
Marcia L.
May-18 6:10 PM
yeah i think it is def legit
Omar R.
May-18 6:10 PM
I could put the hint in a VAR, but then I don't get to use HTML
and using any more javascript than that is messy
even the VAR thing is messy
since I feel like we want as much real content text to be in the actual HTML content section as possible
Omar R.
May-18 6:11 PM
well, what we're doing here is basically a client-side template language specialized for exercises
Marcia L.
May-18 6:15 PM
yeah i came across a similar problem for exponents, where i wanted a diff hint for when the exp = 0. i worked around it by creating two problem types... but it wasn't quite as natural
Omar R.
May-18 6:18 PM
or just some kind of inline conditional tag in general
Omar R.
May-18 6:19 PM
I mean, I don't know what the model @john envisions is and what stuff he's trying to preserve, so maybe he has a suggestion for how we can achieve this nicely without having to generate different problem types for each edge case
John R.
May-18 7:18 PM
I was actually thinking about conditionals today - specifically with regard to how we generate unique multiple choice sets
for example there was the one exercise where we didn't want to generate a solution that was a prime number

beneater pushed a commit that referenced this issue Mar 9, 2015
Summary:
The functions in utils/graphie-drawing.js (which I think are just used by
graphie-to-png users) take an `options` object which includes style properties
and non-style properties all jumbled together.

The `getStyles()` function promises to extract the style properties, but
doesn't actually filter out only style properties.

This leads to a weird side-effect. If you pass a property value that is a
function to `$.css()`, the function will get called and the return value will
be applied as the property value.

This fixes `getStyles()` to only include style properties that are actually
style properties. It's possible I missed some, but I think I got all the ones
we use. Good news is this is only used by graphie-to-png users, so the risk of
breaking something on the live site is pretty much nil.

Test Plan:
1. Run ./app.py
2. http://localhost:5001/
3. Enter this:
```
init({range: [[-10, 10], [-10, 10]], scale: 20});

var i = 0;
drawPolygon({
    whyIsThisCalled: function() {
        i += 1;
    }
});
console.log("Was called " + i + " times");
```
4. Regraph and see "Was called 0 times" in the console.
5. Load and graph templates #13, #17, #18, #19, and #20 and verify they look the same.

Reviewers: emily, alex

Reviewed By: alex

Subscribers: aria, kevinb

Differential Revision: https://phabricator.khanacademy.org/D16505
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants