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
d1f2ef6c
Commit
d1f2ef6c
authored
Jul 13, 2015
by
Tim Krones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paginate export results on the client.
parent
96496aa6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
141 additions
and
13 deletions
+141
-13
problem_builder/public/css/student_answers_dashboard.css
+1
-0
problem_builder/public/js/student_answers_dashboard.js
+131
-12
problem_builder/public/js/vendor/backbone.paginator.min.js
+0
-0
problem_builder/public/js/vendor/underscore-min.js
+0
-0
problem_builder/public/js/vendor/underscore.js
+0
-0
problem_builder/student_answers_dashboard.py
+1
-0
problem_builder/templates/html/student_answers_dashboard.html
+8
-1
No files found.
problem_builder/public/css/student_answers_dashboard.css
View file @
d1f2ef6c
...
@@ -41,6 +41,7 @@
...
@@ -41,6 +41,7 @@
display
:
none
;
display
:
none
;
}
}
.data-export-results
table
{
.data-export-results
table
{
width
:
100%
;
margin-top
:
1em
;
margin-top
:
1em
;
}
}
.data-export-results
thead
{
.data-export-results
thead
{
...
...
problem_builder/public/js/student_answers_dashboard.js
View file @
d1f2ef6c
...
@@ -100,22 +100,17 @@ function StudentAnswersDashboardBlock(runtime, element) {
...
@@ -100,22 +100,17 @@ function StudentAnswersDashboardBlock(runtime, element) {
}
}
)
)
));
));
// Display results
// Display results
var
$resultTableBody
=
$resultTable
.
find
(
'tbody'
);
var
results
=
_
.
map
(
status
.
last_export_result
.
display_data
,
function
(
row
)
{
$resultTableBody
.
empty
();
return
new
Result
(
null
,
{
values
:
row
});
_
.
each
(
status
.
last_export_result
.
display_data
,
function
(
row
,
index
)
{
var
tr
=
$
(
'<tr>'
);
if
(
index
%
2
===
0
)
{
tr
.
addClass
(
'even'
);
}
_
.
each
(
row
,
function
(
cell
)
{
tr
.
append
(
$
(
'<td>'
).
text
(
cell
));
});
$resultTableBody
.
append
(
tr
);
});
});
resultsView
.
collection
.
fullCollection
.
reset
(
results
);
resultsView
.
render
();
showResults
();
showResults
();
}
}
}
else
{
}
else
{
if
(
status
.
export_pending
)
{
if
(
status
.
export_pending
)
{
$statusArea
.
append
(
$
(
'<p>'
).
text
(
$statusArea
.
append
(
$
(
'<p>'
).
text
(
...
@@ -165,4 +160,128 @@ function StudentAnswersDashboardBlock(runtime, element) {
...
@@ -165,4 +160,128 @@ function StudentAnswersDashboardBlock(runtime, element) {
showSpinner
();
showSpinner
();
getStatus
();
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.paginator.min.js
0 → 100644
View file @
d1f2ef6c
This diff is collapsed.
Click to expand it.
problem_builder/public/js/vendor/underscore-min.js
View file @
d1f2ef6c
This diff is collapsed.
Click to expand it.
problem_builder/public/js/vendor/underscore.js
0 → 100644
View file @
d1f2ef6c
This diff is collapsed.
Click to expand it.
problem_builder/student_answers_dashboard.py
View file @
d1f2ef6c
...
@@ -113,6 +113,7 @@ class StudentAnswersDashboardBlock(XBlock):
...
@@ -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_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/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/underscore-min.js'
))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/vendor/backbone.paginator.min.js'
))
fragment
.
initialize_js
(
'StudentAnswersDashboardBlock'
)
fragment
.
initialize_js
(
'StudentAnswersDashboardBlock'
)
return
fragment
return
fragment
...
...
problem_builder/templates/html/student_answers_dashboard.html
View file @
d1f2ef6c
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
</div>
</div>
</div>
</div>
<div
class=
"data-export-results"
>
<div
id=
"results"
class=
"data-export-results"
>
<table>
<table>
<thead>
<thead>
<tr>
<tr>
...
@@ -67,6 +67,13 @@
...
@@ -67,6 +67,13 @@
<tbody></tbody>
<tbody></tbody>
</table>
</table>
<div
class=
"data-export-info"
></div>
<div
class=
"data-export-info"
></div>
<div
class=
"data-export-result-actions"
>
<button
id=
"first-page"
>
First
</button>
<button
id=
"prev-page"
>
Prev
</button>
<span
id=
"current-page"
></span>
/
<span
id=
"total-pages"
></span>
<button
id=
"next-page"
>
Next
</button>
<button
id=
"last-page"
>
Last
</button>
</div>
</div>
</div>
<div
class=
"data-export-status"
></div>
<div
class=
"data-export-status"
></div>
...
...
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