Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
problem-builder
Commits
56dc2734
Commit
56dc2734
authored
Jul 14, 2015
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make existing problem-builder tests pass.
parent
d1f2ef6c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
125 additions
and
123 deletions
+125
-123
problem_builder/public/js/student_answers_dashboard.js
+124
-123
problem_builder/public/js/vendor/backbone-min.js
+0
-0
problem_builder/student_answers_dashboard.py
+1
-0
No files found.
problem_builder/public/js/student_answers_dashboard.js
View file @
56dc2734
function
StudentAnswersDashboardBlock
(
runtime
,
element
)
{
'use strict'
;
var
$element
=
$
(
element
);
// Pagination
var
Result
=
Backbone
.
Model
.
extend
({
initialize
:
function
(
attrs
,
options
)
{
_
.
each
(
_
.
zip
(
Result
.
properties
,
options
.
values
),
function
(
pair
)
{
this
.
set
(
pair
[
0
],
pair
[
1
]);
},
this
);
}
},
{
properties
:
[
'section'
,
'subsection'
,
'unit'
,
'type'
,
'question'
,
'answer'
,
'username'
]
});
var
Results
=
Backbone
.
PageableCollection
.
extend
({
model
:
Result
,
getCurrentPage
:
function
()
{
var
currentPage
=
this
.
state
.
currentPage
;
return
this
.
getPage
(
currentPage
);
}
});
var
ResultsView
=
Backbone
.
View
.
extend
({
render
:
function
()
{
this
.
_insertRecords
(
this
.
collection
.
getCurrentPage
());
this
.
_updateControls
();
this
.
$
(
'#total-pages'
).
text
(
this
.
collection
.
state
.
totalPages
);
return
this
;
},
_insertRecords
:
function
(
records
)
{
var
tbody
=
this
.
$
(
'tbody'
);
tbody
.
empty
();
records
.
each
(
function
(
result
,
index
)
{
var
row
=
$
(
'<tr>'
);
if
(
index
%
2
===
0
)
{
row
.
addClass
(
'even'
);
}
_
.
each
(
Result
.
properties
,
function
(
name
)
{
row
.
append
(
$
(
'<td>'
).
text
(
result
.
get
(
name
)));
});
tbody
.
append
(
row
);
},
this
);
this
.
$
(
'#current-page'
).
text
(
this
.
collection
.
state
.
currentPage
);
},
events
:
{
'click #first-page'
:
'_firstPage'
,
'click #prev-page'
:
'_prevPage'
,
'click #next-page'
:
'_nextPage'
,
'click #last-page'
:
'_lastPage'
},
_firstPage
:
function
()
{
this
.
_insertRecords
(
this
.
collection
.
getFirstPage
());
this
.
_updateControls
();
},
_prevPage
:
function
()
{
if
(
this
.
collection
.
hasPreviousPage
())
{
this
.
_insertRecords
(
this
.
collection
.
getPreviousPage
());
}
this
.
_updateControls
();
},
_nextPage
:
function
()
{
if
(
this
.
collection
.
hasNextPage
())
{
this
.
_insertRecords
(
this
.
collection
.
getNextPage
());
}
this
.
_updateControls
();
},
_lastPage
:
function
()
{
this
.
_insertRecords
(
this
.
collection
.
getLastPage
());
this
.
_updateControls
();
},
_updateControls
:
function
()
{
var
currentPage
=
this
.
collection
.
state
.
currentPage
,
totalPages
=
this
.
collection
.
state
.
totalPages
,
firstPage
=
'#first-page'
,
prevPage
=
'#prev-page'
,
nextPage
=
'#next-page'
,
lastPage
=
'#last-page'
,
all
=
[
firstPage
,
prevPage
,
nextPage
,
lastPage
],
backward
=
[
firstPage
,
prevPage
],
forward
=
[
nextPage
,
lastPage
];
if
(
totalPages
===
1
)
{
this
.
_disable
(
all
);
}
else
{
if
(
currentPage
===
1
)
{
this
.
_disable
(
backward
);
this
.
_enable
(
forward
);
}
else
if
(
currentPage
===
totalPages
)
{
this
.
_enable
(
backward
);
this
.
_disable
(
forward
);
}
else
{
this
.
_enable
(
all
);
}
}
},
_enable
:
function
(
controls
)
{
_
.
each
(
controls
,
function
(
control
)
{
this
.
$
(
control
).
prop
(
'disabled'
,
false
);
},
this
);
},
_disable
:
function
(
controls
)
{
_
.
each
(
controls
,
function
(
control
)
{
this
.
$
(
control
).
prop
(
'disabled'
,
true
);
},
this
);
}
});
var
resultsView
=
new
ResultsView
({
collection
:
new
Results
([],
{
mode
:
"client"
,
state
:
{
pageSize
:
15
}
}),
el
:
$element
.
find
(
'#results'
)
});
// Set up gettext in case it isn't available in the client runtime:
if
(
typeof
gettext
==
"undefined"
)
{
window
.
gettext
=
function
gettext_stub
(
string
)
{
return
string
;
};
...
...
@@ -161,127 +285,4 @@ function StudentAnswersDashboardBlock(runtime, element) {
showSpinner
();
getStatus
();
// Pagination
var
Result
=
Backbone
.
Model
.
extend
({
initialize
:
function
(
attrs
,
options
)
{
_
.
each
(
_
.
zip
(
Result
.
properties
,
options
.
values
),
function
(
pair
)
{
this
.
set
(
pair
[
0
],
pair
[
1
]);
},
this
);
}
},
{
properties
:
[
'section'
,
'subsection'
,
'unit'
,
'type'
,
'question'
,
'answer'
,
'username'
]
});
var
Results
=
Backbone
.
PageableCollection
.
extend
({
model
:
Result
,
getCurrentPage
:
function
()
{
var
currentPage
=
this
.
state
.
currentPage
;
return
this
.
getPage
(
currentPage
);
}
});
var
ResultsView
=
Backbone
.
View
.
extend
({
render
:
function
()
{
this
.
_insertRecords
(
this
.
collection
.
getCurrentPage
());
this
.
_updateControls
();
this
.
$
(
'#total-pages'
).
text
(
this
.
collection
.
state
.
totalPages
);
return
this
;
},
_insertRecords
:
function
(
records
)
{
var
tbody
=
this
.
$
(
'tbody'
);
tbody
.
empty
();
records
.
each
(
function
(
result
,
index
)
{
var
row
=
$
(
'<tr>'
);
if
(
index
%
2
===
0
)
{
row
.
addClass
(
'even'
);
}
_
.
each
(
Result
.
properties
,
function
(
name
)
{
row
.
append
(
$
(
'<td>'
).
text
(
result
.
get
(
name
)));
});
tbody
.
append
(
row
);
},
this
);
this
.
$
(
'#current-page'
).
text
(
this
.
collection
.
state
.
currentPage
);
},
events
:
{
'click #first-page'
:
'_firstPage'
,
'click #prev-page'
:
'_prevPage'
,
'click #next-page'
:
'_nextPage'
,
'click #last-page'
:
'_lastPage'
},
_firstPage
:
function
()
{
this
.
_insertRecords
(
this
.
collection
.
getFirstPage
());
this
.
_updateControls
();
},
_prevPage
:
function
()
{
if
(
this
.
collection
.
hasPreviousPage
())
{
this
.
_insertRecords
(
this
.
collection
.
getPreviousPage
());
}
this
.
_updateControls
();
},
_nextPage
:
function
()
{
if
(
this
.
collection
.
hasNextPage
())
{
this
.
_insertRecords
(
this
.
collection
.
getNextPage
());
}
this
.
_updateControls
();
},
_lastPage
:
function
()
{
this
.
_insertRecords
(
this
.
collection
.
getLastPage
());
this
.
_updateControls
();
},
_updateControls
:
function
()
{
var
currentPage
=
this
.
collection
.
state
.
currentPage
,
totalPages
=
this
.
collection
.
state
.
totalPages
,
firstPage
=
'#first-page'
,
prevPage
=
'#prev-page'
,
nextPage
=
'#next-page'
,
lastPage
=
'#last-page'
,
all
=
[
firstPage
,
prevPage
,
nextPage
,
lastPage
],
backward
=
[
firstPage
,
prevPage
],
forward
=
[
nextPage
,
lastPage
];
if
(
totalPages
===
1
)
{
this
.
_disable
(
all
);
}
else
{
if
(
currentPage
===
1
)
{
this
.
_disable
(
backward
);
this
.
_enable
(
forward
);
}
else
if
(
currentPage
===
totalPages
)
{
this
.
_enable
(
backward
);
this
.
_disable
(
forward
);
}
else
{
this
.
_enable
(
all
);
}
}
},
_enable
:
function
(
controls
)
{
_
.
each
(
controls
,
function
(
control
)
{
this
.
$
(
control
).
prop
(
'disabled'
,
false
);
},
this
);
},
_disable
:
function
(
controls
)
{
_
.
each
(
controls
,
function
(
control
)
{
this
.
$
(
control
).
prop
(
'disabled'
,
true
);
},
this
);
}
});
var
resultsView
=
new
ResultsView
({
collection
:
new
Results
([],
{
mode
:
"client"
,
state
:
{
pageSize
:
15
}
}),
el
:
$element
.
find
(
'#results'
)
});
}
problem_builder/public/js/vendor/backbone-min.js
0 → 100644
View file @
56dc2734
This diff is collapsed.
Click to expand it.
problem_builder/student_answers_dashboard.py
View file @
56dc2734
...
...
@@ -113,6 +113,7 @@ class StudentAnswersDashboardBlock(XBlock):
fragment
.
add_css_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/css/student_answers_dashboard.css'
))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/student_answers_dashboard.js'
))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/vendor/underscore-min.js'
))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/vendor/backbone-min.js'
))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/vendor/backbone.paginator.min.js'
))
fragment
.
initialize_js
(
'StudentAnswersDashboardBlock'
)
return
fragment
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment