Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Bradley Miller
    @bnmnetp
    On the other hand, to make it easy for people to use the components outside of Sphinx, We really should bundle them up as one minified whole. Can you check into a couple of other options. Even if it is just a script to package them up together into a single runestone.js file. ?
    Kirby Olson
    @riknos314
    I'll see if I can find anything
    Bradley Miller
    @bnmnetp
    For the skulpt project we use the google closure compiler to package together a bunch of individual .js files into skulpt.min.js
    Kirby Olson
    @riknos314
    I basically automates the google closure compiler process
    I see no reason why we couldn't also use the google closure compiler as long as it maintains order so we can keep our prototype definitions working.
    Bradley Miller
    @bnmnetp
    Yes, and I know that it does preserve ordering as that is important for some things in skulpt as well.
    Kirby Olson
    @riknos314
    Excellent, I'll play around with that a bit today and try to get it running.
    Bradley Miller
    @bnmnetp
    Great. Thanks.
    Make sure you update your branch as I have been busy pushing changes to master.
    Isaiah Mayerchak
    @flysaiah
    We've modified clickable area so that it's a container that can hold anything, and anything within that container that has the data-correct or data-incorrect attribute will be clickable. This works perfectly with our intermediate HTML, but I'm not quite sure how to proceed with the Sphinx side. Are there ways that people can create tables/images/etc. in RST right now? Everything I've been working with up to this point has been with RST users entering just simple text (for questions/feedback/etc), but I'm not sure how to give them the freedom to put whatever they want into a clickable area container (ex. image or table) if there's no pre-defined way to do that.
    Right now the only way we can think of to give people that freedom is to have them write a block of HTML code and put it in a string in the RST.
    Bradley Miller
    @bnmnetp
    Yes, there are directives for adding an image and there is a syntax for making a table in rst. google sphinx restructuredtext primer
    Bradley Miller
    @bnmnetp
    @flysaiah, hint: This is where the nested_parse call becomes very important.
    Isaiah Mayerchak
    @flysaiah
    The problem I'm envisioning is if someone creates an img tag via Sphinx, we need to edit that img tag so that it has the attribute data-correct or data-incorrect. Wouldn't the nested_parse call just create the img tag without letting us change some of its properties?
    Bradley Miller
    @bnmnetp
    The details are very hazy, but I think once you have a node you can get access to its children.
    Isaiah Mayerchak
    @flysaiah
    Ok. I'll tinker around with it and see what I can do.
    Bradley Miller
    @bnmnetp
    Or you could create a role like the textarea role that you would use to surround an element that you want to be clickable kind of like what you are doing now, but more tricky, rather than adding an attribute. So I think you have two ways to go.
    Isaiah Mayerchak
    @flysaiah
    So, with the first way, are you suggesting that somewhere during the nested_parse process we could grab all of the nodes that it is parsing and modify them?
    Bradley Miller
    @bnmnetp
    I think that would happen during the visit_xxxx_node call not during parsing.
    For the second, The idea is that during visit_xxx_node you can create the opening tag. and then during depart_xxx_node you create the closing tag
    You might experiment by printing self.body in both the visit and the depart to see what you have available there too.
    Isaiah Mayerchak
    @flysaiah
    Yes--the second way I think I understand, it would pretty much be what I'm doing now, which is wrapping the clickable element in a span, but that would be a problem when it comes to images because of my CSS rules. I think the first way would probably be cleaner, too, it's just I'm not sure how exactly I'd do it. I'll do those print statements.
    Bradley Miller
    @bnmnetp
    The css can be adjusted to not apply to images.
    Isaiah Mayerchak
    @flysaiah
    You're right. The first way has yielded nothing but complications and errors so far, so I'll try wrapping it.
    Isaiah Mayerchak
    @flysaiah
    This message was deleted

    @bnmnetp I'm getting some strange behavior out of self.state.nested_parse() when the directive has content that isn't composed solely out of other directives (i.e. text). The content is getting parsed twice--for example, in the RST

    .. clickablearea:: click1
        :question: Click on all assignment statements.
        :feedback: Remember, the operator '=' is used for assignment.
    
        :click-incorrect:def main()::endclick:
            :click-correct:x = 4:endclick:
            for i in range(5):
                :click-correct:y = i:endclick:
                :click-incorrect:if y > 2::endclick:
                    print(y)

    , the code block starting with :click-incorrect: is getting rendered once normally, then once again after the full component has been rendered like this:

    <dl class="docutils">
    <dt>:click-incorrect:def main()::endclick:</dt>
    <dd><p class="first">:click-correct:x = 4:endclick:
    for i in range(5):</p>
    <blockquote class="last">
    <div><p>:click-correct:y = i:endclick:
    :click-incorrect:if y &gt; 2::endclick:</p>
    <blockquote>
    <div>print(y)</div></blockquote>
    </div></blockquote>
    </dd>
    </dl>

    Do you know why this is happening? It's a big roadblock and I'm unsure of what to do about it.

    Isaiah Mayerchak
    @flysaiah
    Edit: It's not rendering twice anymore, but it's still rendering as a weird <dl class-docutils> element.
    Bradley Miller
    @bnmnetp
    I haven’t run into that before. If you can’t figure it out, there is an irc channel and a forum for sphinx/rst development.
    Isaiah Mayerchak
    @flysaiah
    I think it's because there's never been an occasion to use a nested parse for a container directivd that held both other directives AND text as content. I'll check out the channel/forum.
    Bradley Miller
    @bnmnetp
    its exactly what reveal does right?
    Isaiah Mayerchak
    @flysaiah
    That's a very good point--I'll check what I'm doing differently between the two components to find out what's going wrong.
    Kirby Olson
    @riknos314
    Trying to combine the javascript files with google closure compiler hasn't been very fruitful. After modifying many of the files (getting rid of trailing commas) to stop the linter from throwing errors so that I could actually compile, the file that I get back doesn't work. I tried setting the compiler to the 'whitespace_only' setting so that it wouldn't minify variable names, and that still doesn't work. It appears to cause the various versions of jquery that we have to not play well with each other as I'm continually running into errors with $(...).method() is not a function where method is any number of different methods. I'll try a couple other methods and see if anything works.
    Bradley Miller
    @bnmnetp
    Are you trying to include the jquery instances in with the final file or are you leaving them separate?
    Kirby Olson
    @riknos314
    I've been trying to include all the js in the _static directory in the order that they appear in the head of the test page (which works flawlessly).
    I guess that I could experiment with making a few, smaller bundles. I just really don't want to mess with the order that things are loaded in because that has proven to be quite fragile in my experience.
    Bradley Miller
    @bnmnetp
    You could also start with the super simple approach of just using that order and then either manually or with cat combine them without any compression or additional messing around.
    Kirby Olson
    @riknos314
    I just tried concatenating the files at your suggestion, and I'm getting the exact same problems. Just to be sure that I didn't mess up the concatenation I grepped through the combined file and the methods are indeed defined. Maybe the files are parsed differently as individual files? I'll do some research.
    Isaiah Mayerchak
    @flysaiah
    I'm running into problem after problem with trying to wrap things inside click-correct or click-incorrect elements in rST for clickablearea, and I'm becoming increasingly doubtful about the possibility of it working at all, so I came up with another solution. In the case of having a number of images or a table, in the option spec of clickablearea the user can specify the indices of the images they would like to be correct, and the indices of the images they would like to be incorrect--much like what we do with multiple choice multiple answer. For example, if the user has 5 images inside the clickablearea directive they can list images 2, 3, and 5 as being correct and 1,4 as being incorrect. In a table, each data cell would be one index. If all they have is text, they can specify that with :iscode: and still wrap whatever they want in click-correct and click-incorrect wrappers--the index method will only be for images/tables/etc, so the old functionality is still preserved. The only limitation this has is that people won't be able to make both images and plain text (that isn't in a table) clickable in the same element (they can't use both indices AND wrappers), but I don't think that's something that would be very popular to do in the first place. Does this sound reasonable?
    Bradley Miller
    @bnmnetp
    The generated html element would have the correct or incorrect as an attribute then?
    Isaiah Mayerchak
    @flysaiah
    In the old case, everything would work as it has, so yes. In the new images/table case, the html wouldn't have the data-correct or data-incorrect attribute but I can add a data-correctElements and data-incorrectElements to the clickablearea component and add a function in our javascript that will parse those and the rest of the component will behave the same.
    It will be a feature that's really only for the Sphinx-rST parsing, but I've been running into a brick wall with doing this in Sphinx whereas I know this will work in the JS.
    Bradley Miller
    @bnmnetp
    OK, then.
    Bradley Miller
    @bnmnetp
    Hi guys, I built our CS1 book using all of the new directives that have been submitted as PRs. I have been uncovering some bugs and have filed those as Issues.
    If you could take a look at them and get some fixes. It would be nice to have one PR per fix unless they are really trivial, then I don’t mind if you bundle them.
    Isaiah Mayerchak
    @flysaiah
    I think we're seeing different errors with Parsons. I just checked the page source of the overview page on the example that's not working for me and it has all of the code it should have, it's just not rendering.
        <pre data-component="parsons" id="question1_100_4">
            <span data-question>sc-1-3: Construct a block of code that correctly implements the accumulator pattern.</span>x = 0
    for i in range(10)
       x = x + 1</pre>
    Isaiah Mayerchak
    @flysaiah
    I'm testing by removing specific parts of the new runestonebase and it seems that the block of code that defines the includes method is conflicting somehow with parsons.
    Isaiah Mayerchak
    @flysaiah
    I found the source of the problem--it's very strange, but after lots of console.logs I found that on line 870 of parsonsaux.js (which is where parsons errors out when runestonebase is on the page), the value of permutation[i] is an integer for the first 3 passes in the for loop, and the 4th pass through its value is
    "function Array.includes(searchElement)" which is declared in runestonebase. I have no idea how that is getting into the permutation array, but that's what's happening.
    The array only has 3 elements, but I think because whoever wrote the code for the function is doing iteration by items instead of by position, it is somehow accessing the prototype function of Array as an item in the array.
    Isaiah Mayerchak
    @flysaiah
    I was right: I changed all of the iterations by item to iterations by position (i.e. instead of "for var i in array_" it's now "for (var i = 0; i < _array.length; i++) and parsons is no longer broken. I'm fairly certain the same thing is happening in codelens, which is what is causing it to break too. I'll do a PR on this and on CL too when I fix too.