Mask grades on progress page according to "Show Correctness" setting.

This commit is contained in:
Jillian Vogel
2017-05-02 23:11:18 +09:30
committed by Tim Krones
parent e8a36957b1
commit 6ca8a702ae
11 changed files with 481 additions and 47 deletions

View File

@@ -7,7 +7,7 @@ from logging import getLogger
from lms.djangoapps.grades.scores import get_score, possibly_scored
from lms.djangoapps.grades.models import BlockRecord, PersistentSubsectionGrade
from xmodule import block_metadata_utils, graders
from xmodule.graders import AggregatedScore
from xmodule.graders import AggregatedScore, ShowCorrectness
from ..config.waffle import waffle, WRITE_ONLY_IF_ENGAGED
@@ -27,6 +27,7 @@ class SubsectionGradeBase(object):
self.format = getattr(subsection, 'format', '')
self.due = getattr(subsection, 'due', None)
self.graded = getattr(subsection, 'graded', False)
self.show_correctness = getattr(subsection, 'show_correctness', '')
self.course_version = getattr(subsection, 'course_version', None)
self.subtree_edited_timestamp = getattr(subsection, 'subtree_edited_on', None)
@@ -47,6 +48,12 @@ class SubsectionGradeBase(object):
)
return self.all_total.attempted
def show_grades(self, has_staff_access):
"""
Returns whether subsection scores are currently available to users with or without staff access.
"""
return ShowCorrectness.correctness_available(self.show_correctness, self.due, has_staff_access)
class ZeroSubsectionGrade(SubsectionGradeBase):
"""
@@ -224,7 +231,7 @@ class SubsectionGrade(SubsectionGradeBase):
log_func(
u"Grades: SG.{}, subsection: {}, course: {}, "
u"version: {}, edit: {}, user: {},"
u"total: {}/{}, graded: {}/{}".format(
u"total: {}/{}, graded: {}/{}, show_correctness: {}".format(
log_statement,
self.location,
self.location.course_key,
@@ -235,5 +242,6 @@ class SubsectionGrade(SubsectionGradeBase):
self.all_total.possible,
self.graded_total.earned,
self.graded_total.possible,
self.show_correctness,
)
)

View File

@@ -1,11 +1,11 @@
"""
Grades Transformer
"""
import json
from base64 import b64encode
from functools import reduce as functools_reduce
from hashlib import sha1
from logging import getLogger
import json
from lms.djangoapps.course_blocks.transformers.utils import collect_unioned_set_field, get_field_on_block
from openedx.core.djangoapps.content.block_structure.transformer import BlockStructureTransformer
@@ -29,6 +29,7 @@ class GradesTransformer(BlockStructureTransformer):
graded: (boolean)
has_score: (boolean)
weight: (numeric)
show_correctness: (string) when to show grades (one of 'always', 'past_due', 'never')
Additionally, the following value is calculated and stored as a
transformer_block_field for each block:
@@ -37,7 +38,16 @@ class GradesTransformer(BlockStructureTransformer):
"""
WRITE_VERSION = 4
READ_VERSION = 4
FIELDS_TO_COLLECT = [u'due', u'format', u'graded', u'has_score', u'weight', u'course_version', u'subtree_edited_on']
FIELDS_TO_COLLECT = [
u'due',
u'format',
u'graded',
u'has_score',
u'weight',
u'course_version',
u'subtree_edited_on',
u'show_correctness',
]
EXPLICIT_GRADED_FIELD_NAME = 'explicit_graded'