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
182b4803
Commit
182b4803
authored
Jan 27, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanups
parent
9699d0a5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
31 deletions
+38
-31
mentoring/components/common.py
+1
-1
mentoring/components/step.py
+20
-0
mentoring/components/table.py
+0
-1
mentoring/dataexport.py
+4
-5
mentoring/mentoring.py
+13
-24
No files found.
mentoring/components/common.py
View file @
182b4803
# -*- coding: utf-8 -*-
#
# Copyright (
C) 2015
OpenCraft
# Copyright (
c) 2014-2015 Harvard, edX &
OpenCraft
#
# This software's license gives you freedom; you can copy, convey,
# propagate, redistribute and/or modify this program under the terms of
...
...
mentoring/components/step.py
View file @
182b4803
# -*- coding: utf-8 -*-
#
# Copyright (c) 2014-2015 Harvard, edX & OpenCraft
#
# This software's license gives you freedom; you can copy, convey,
# propagate, redistribute and/or modify this program under the terms of
# the GNU Affero General Public License (AGPL) as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version of the AGPL published by the FSF.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program in a file in the toplevel directory called
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
#
class
StepParentMixin
(
object
):
"""
An XBlock mixin for a parent block containing Step children
...
...
mentoring/components/table.py
View file @
182b4803
...
...
@@ -30,7 +30,6 @@ from xblock.fields import Scope, String
from
xblock.fragment
import
Fragment
from
xblockutils.resources
import
ResourceLoader
loader
=
ResourceLoader
(
__name__
)
# Globals ###########################################################
...
...
mentoring/dataexport.py
View file @
182b4803
...
...
@@ -44,11 +44,10 @@ def list2csv(row):
"""
Convert a list to a CSV string (single row)
"""
f
=
StringIO
()
writer
=
unicodecsv
.
writer
(
f
,
encoding
=
'utf-8'
)
writer
.
writerow
(
row
)
f
.
seek
(
0
)
return
f
.
read
()
with
StringIO
()
as
f
:
writer
=
unicodecsv
.
writer
(
f
,
encoding
=
'utf-8'
)
writer
.
writerow
(
row
)
return
f
.
getvalue
()
# Classes ###########################################################
...
...
mentoring/mentoring.py
View file @
182b4803
...
...
@@ -34,9 +34,7 @@ from xblock.core import XBlock
from
xblock.fields
import
Boolean
,
Scope
,
String
,
Integer
,
Float
,
List
from
xblock.fragment
import
Fragment
from
components.title
import
TitleBlock
from
components.header
import
SharedHeaderBlock
from
components.message
import
MentoringMessageBlock
from
components
import
TitleBlock
,
SharedHeaderBlock
,
MentoringMessageBlock
from
components.step
import
StepParentMixin
,
StepMixin
from
xblockutils.resources
import
ResourceLoader
...
...
@@ -162,7 +160,7 @@ class MentoringBlock(XBlock, StepParentMixin):
@property
def
score
(
self
):
"""Compute the student score taking into account the weight of each step."""
weights
=
[
float
(
self
.
runtime
.
get_block
(
step_id
)
.
weight
)
for
step_id
in
self
.
steps
]
weights
=
(
float
(
self
.
runtime
.
get_block
(
step_id
)
.
weight
)
for
step_id
in
self
.
steps
)
total_child_weight
=
sum
(
weights
)
if
total_child_weight
==
0
:
return
(
0
,
0
,
0
,
0
)
...
...
@@ -177,25 +175,24 @@ class MentoringBlock(XBlock, StepParentMixin):
# Migrate stored data if necessary
self
.
migrate_fields
()
title
=
""
header
=
""
fragment
=
Fragment
()
title
=
u""
header
=
u""
child_content
=
u""
for
child_id
in
self
.
children
:
child
=
self
.
runtime
.
get_block
(
child_id
)
if
isinstance
(
child
,
TitleBlock
):
title
=
child
.
content
continue
elif
isinstance
(
child
,
SharedHeaderBlock
):
header
=
child
.
render
(
'mentoring_view'
,
context
)
.
content
continue
elif
isinstance
(
child
,
MentoringMessageBlock
):
# TODO
continue
child_fragment
=
child
.
render
(
'mentoring_view'
,
context
)
fragment
.
add_frag_resources
(
child_fragment
)
child_content
+=
child_fragment
.
content
pass
# TODO
else
:
child_fragment
=
child
.
render
(
'mentoring_view'
,
context
)
fragment
.
add_frag_resources
(
child_fragment
)
child_content
+=
child_fragment
.
content
fragment
.
add_content
(
loader
.
render_template
(
'templates/html/mentoring.html'
,
{
'self'
:
self
,
...
...
@@ -205,17 +202,9 @@ class MentoringBlock(XBlock, StepParentMixin):
'missing_dependency_url'
:
self
.
has_missing_dependency
and
self
.
next_step_url
,
}))
fragment
.
add_css_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/css/mentoring.css'
))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/vendor/underscore-min.js'
))
if
self
.
is_assessment
:
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring_assessment_view.js'
)
)
else
:
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring_standard_view.js'
)
)
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/vendor/underscore-min.js'
))
js_file
=
'public/js/mentoring_{}_view.js'
.
format
(
'assessment'
if
self
.
is_assessment
else
'standard'
)
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
js_file
))
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring.js'
))
fragment
.
add_resource
(
loader
.
load_unicode
(
'templates/html/mentoring_attempts.html'
),
"text/html"
)
fragment
.
add_resource
(
loader
.
load_unicode
(
'templates/html/mentoring_grade.html'
),
"text/html"
)
...
...
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