RunestoneInteractive / RunestoneComponents

Packaging of the Runestone tools for publishing educational materials using github pages
http://runestoneinteractive.org
Other
101 stars 225 forks source link

Including "hidden code" before active code area #1134

Closed cchaz003 closed 3 years ago

cchaz003 commented 3 years ago

Is there any way that you can include hidden code in an active code area that is included before the active code? I am aware that the :include: directive allows you to include code from previous active code sections but from my understanding it only includes code from the visible area. We have a situation where we want students to have access to functions but not see the source for those functions. Something that looks like this:

## hidden from students ##
def foo(x):
  return x * 5

## student AC area ##
def bar(y):
  return foo(y)

## unittest code hidden from students ##
#tests for bar function
bnmnetp commented 3 years ago

runestone doc activecode shows you all of the options including what you want to do:

.. activecode:: uniqueid
       :nocanvas:  -- do not create a canvas
       :autograde: unittest
       :nopre: -- do not create an output component
       :above: -- put the canvas above the code
       :autorun: -- run this activecode as soon as the page is loaded
       :caption: this is the caption
       :include: div1,div2 -- invisibly include code from another activecode
       :hidecode: -- Don't show the editor initially
       :nocodelens: -- Do not show the codelens button
       :timelimit: -- set the time limit for this program in seconds
       :language: python, html, javascript, java, python2, python3
       :chatcodes: -- Enable users to talk about this code snippet with others
       :tour_1: audio tour track
       :tour_2: audio tour track
       :tour_3: audio tour track
       :tour_4: audio tour track
       :tour_5: audio tour track
       :stdin: : A file to simulate stdin (java, python2, python3)
       :datafile: : A datafile for the program to read (java, python2, python3)
       :sourcefile: : source files (java, python2, python3)
       :available_files: : other additional files (java, python2, python3)
       :enabledownload: -- allow textfield contents to be downloaded as *.py file
       :nopair: -- disable pair programming features
       :dburl: url to load database for sql mode

        If this is a homework problem instead of an example in the text
        then the assignment text should go here.  The assignment text ends with
        the line containing four tilde ~
        ~~~~
        print("Hidden code before students code - good for scaffolding")
        ^^^^
        print("hello world")
        ====
        print("Hidden code, such as unit tests come after the four = signs")

    config values (conf.py):

    - activecode_div_class - custom CSS class of the component's outermost div
    - activecode_hide_load_history - if True, hide the load history button
    - wasm_uri - Path or Full URL to folder containing WASM files for SQL. /_static is default
cchaz003 commented 3 years ago

Oh awesome, thanks!