diff --git a/flows/002-oct-py-test.yml b/flows/002-oct-py-test.yml new file mode 100644 index 0000000..889bcf0 --- /dev/null +++ b/flows/002-oct-py-test.yml @@ -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! diff --git a/flows/exam-1.yml b/flows/exam-1.yml index 6ad7694..93b336e 100644 --- a/flows/exam-1.yml +++ b/flows/exam-1.yml @@ -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] - diff --git a/question-data/f.m b/question-data/f.m new file mode 100644 index 0000000..12aae8a --- /dev/null +++ b/question-data/f.m @@ -0,0 +1,3 @@ +function [ y ] = f( x ) + y = exp( -x .^ 2 ); +end %function