Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions flows/002-oct-py-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
title: "Octave and Python Code"
description: |
# Octave and Python Code

rules:
access:
-
if_has_role: [student, ta, instructor]
permissions: [view,end_session]

grade_identifier: null

pages:

################################################################################
-
type: OctaveCodeQuestion
id: octave_test_apply_function
value: 1
timeout: 10
title: "Applying a Function in Octave"
access_rules:
add_permissions:
- submit_answer
- change_answer
- see_correctness

prompt: |
### Applying a Function in Octave

Apply the provided function `f` to the provided array `x`. Store the result in `y`.

(`x` has the value `[ 1 2 3 4 5 ]` and is already defined and available for you.)

setup_code: |
x = [ 1 2 3 4 5 ];

initial_code: |
y = f( ___ );

names_for_user: [ x ]

names_from_user: [ y ]

data_files: [ "./question-data/f.m" ]

test_code: |
pts = 0.0

try:
from oct2py import octave
from oct2py import Struct,Cell,StructArray

import numpy as np

test_y = octave.eval( "exp( -[ 1 2 3 4 5 ] .^ 2 );" )

assert np.allclose( y,test_y )
pts = 1.0

except NameError:
feedback.finish( 0.0,'Something is wrong. Have you created `y`?' )
except AssertionError:
feedback.finish( 0.0,'Something is wrong. Have you used `f` on `x` to obtain `y`?' )
except:
feedback.finish( 0.0,'Keep trying. If you get stuck, please ask a TA for help on Piazza or office hours.' )

if np.isclose( pts,1.0 ):
feedback.finish( pts,'Success! You have evaluated the function correctly.' )
else:
feedback.finish( pts,'Keep trying. If you get stuck, please ask a TA for help on Piazza or office hours.' )


correct_code: |
y = f(x);

################################################################################
-
type: PythonCodeQuestion
id: python_test_apply_function
value: 1
timeout: 10
title: "Applying a Function in Python"
access_rules:
add_permissions:
- submit_answer
- change_answer
- see_correctness

prompt: |
### Applying a Function in Python

Apply the provided function `f` to the provided array `x`. Store the result in `y`.

(`x` has the value `numpy.ndarray( [ 1,2,3,4,5 ] )` and is already defined and available for you.)

setup_code: |
import numpy as np
x = np.array( [ 1,2,3,4,5 ] );
def f( x ):
return np.exp( -x**2 )

initial_code: |
y = f( ___ );

names_for_user: [ x,f ]

names_from_user: [ y ]

data_files: [ ]

test_code: |
pts = 0.0

try:
import numpy as np

test_x = np.array( [ 1,2,3,4,5 ] );
test_y = np.exp( -x ** 2 )

assert np.allclose( y,test_y )
pts = 1.0

except NameError:
feedback.finish( 0.0,'Something is wrong. Have you created `y`?' )
except AssertionError:
feedback.finish( 0.0,'Something is wrong. Have you used `f` on `x` to obtain `y`?' )
except:
feedback.finish( 0.0,'Keep trying. If you get stuck, please ask a TA for help on Piazza or office hours.' )

if np.isclose( pts,1.0 ):
feedback.finish( pts,'Success! You have evaluated the function correctly.' )
else:
feedback.finish( pts,'Keep trying. If you get stuck, please ask a TA for help on Piazza or office hours.' )


correct_code: |
y = f(x);

completion_text: |

# End of Octave and Python Code Test

Hopefully things are working well!
26 changes: 15 additions & 11 deletions flows/exam-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,28 @@ rules:
permissions: []

-
if_in_facility: test_center
if_session_duration_shorter_than_minutes: 0.5
permissions: [view, submit_answer, end_session, see_session_time, lock_down_as_exam_session]
if_has_role: [instructor]
permissions: [view, submit_answer, change_answer, end_session, see_correctness, see_session_time]

-
if_in_facility: test_center
message: "You exam will end soon."
if_session_duration_shorter_than_minutes: 1
permissions: [view, submit_answer, end_session, see_session_time, lock_down_as_exam_session]
if_in_facility: "cbtf"
if_session_duration_shorter_than_minutes: 45 # length until warning appears
permissions: [view, submit_answer, change_answer, end_session, see_correctness, see_session_time, lock_down_as_exam_session]

-
if_in_facility: test_center
if_in_facility: "cbtf"
message: "Your exam will end soon."
if_session_duration_shorter_than_minutes: 120 # keep in mind DRES students!
permissions: [view, submit_answer, change_answer, end_session, see_correctness, see_session_time, lock_down_as_exam_session]

-
if_in_facility: "cbtf"
if_in_progress: True
message: "You exam has ended. You may no longer make changes. Please click 'Submit assignment' to finish."
permissions: [view, end_session, see_correctness, see_session_time, lock_down_as_exam_session]
message: "Your exam has ended. You may no longer make changes to your answers. Please click 'Submit assignment' to finish."
permissions: [view, change_answer, end_session, see_correctness, see_correctness, see_session_time, lock_down_as_exam_session]

-
if_in_facility: test_center
if_in_facility: "cbtf"
permissions: [view, see_correctness, see_session_time]

-
Expand Down
3 changes: 3 additions & 0 deletions question-data/f.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function [ y ] = f( x )
y = exp( -x .^ 2 );
end %function