From 32524727ce6b31a343e1afcbbb8d838ae1eeb8f6 Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Thu, 31 Jan 2013 09:00:06 -0500 Subject: [PATCH] Create a test framework and make it so that we force a mock backend when we don't have an ajax url --- lms/static/coffee/fixtures/staff_grading.html | 76 +++++++++++++++++++ .../coffee/spec/staff_grading_spec.coffee | 11 +++ .../src/staff_grading/staff_grading.coffee | 8 +- 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 lms/static/coffee/fixtures/staff_grading.html create mode 100644 lms/static/coffee/spec/staff_grading_spec.coffee diff --git a/lms/static/coffee/fixtures/staff_grading.html b/lms/static/coffee/fixtures/staff_grading.html new file mode 100644 index 0000000000..2fe5a39a17 --- /dev/null +++ b/lms/static/coffee/fixtures/staff_grading.html @@ -0,0 +1,76 @@ +
+ +
+

Staff grading

+ +
+
+
+
+ + +
+

Instructions

+
+

This is the list of problems that current need to be graded in order to train the machine learning models. Each problem needs to be trained separately, and we have indicated the number of student submissions that need to be graded in order for a model to be generated. You can grade more than the minimum required number of submissions--this will improve the accuracy of machine learning, though with diminishing returns. You can see the current accuracy of machine learning while grading.

+
+ +

Problem List

+ +
+
+ + + +
+

+
+

Problem Information

+
+
+

Maching Learning Information

+
+
+
+
+

Question

+
+
+
+ +
+ +
+ +
+ +
+

Grading

+ +
+
+

Student Submission

+
+
+
+
+

+

+

+

+ +
+ + +
+ + +
+ +
+ +
+
+ diff --git a/lms/static/coffee/spec/staff_grading_spec.coffee b/lms/static/coffee/spec/staff_grading_spec.coffee new file mode 100644 index 0000000000..595a9eb550 --- /dev/null +++ b/lms/static/coffee/spec/staff_grading_spec.coffee @@ -0,0 +1,11 @@ +describe 'StaffGrading', -> + beforeEach -> + spyOn Logger, 'log' + @mockBackend = new StaffGradingBackend('url', true) + + describe 'constructor', -> + beforeEach -> + @staff_grading = new StaffGrading(@mockBackend) + + it 'we are originally in the list view', -> + expect(@staff_grading.list_view).toBe(true) diff --git a/lms/static/coffee/src/staff_grading/staff_grading.coffee b/lms/static/coffee/src/staff_grading/staff_grading.coffee index c7a8a01bab..005a8e682e 100644 --- a/lms/static/coffee/src/staff_grading/staff_grading.coffee +++ b/lms/static/coffee/src/staff_grading/staff_grading.coffee @@ -9,9 +9,13 @@ state_graded = "graded" state_no_data = "no_data" state_error = "error" -class StaffGradingBackend +class @StaffGradingBackend constructor: (ajax_url, mock_backend) -> @ajax_url = ajax_url + # prevent this from trying to make requests when we don't have + # a proper url + if !ajax_url + mock_backend = true @mock_backend = mock_backend if @mock_backend @mock_cnt = 0 @@ -142,7 +146,7 @@ The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for t .error => callback({success: false, error: "Error occured while performing this operation"}) -class StaffGrading +class @StaffGrading constructor: (backend) -> @backend = backend