auto generate the discussion id on create. Also add 'discussion_id' to the list of 'system-metadata' so that end users cannot edit it
This commit is contained in:
@@ -9,6 +9,7 @@ from fs.osfs import OSFS
|
||||
from itertools import repeat
|
||||
from path import path
|
||||
from datetime import datetime, timedelta
|
||||
from uuid import uuid4
|
||||
|
||||
from importlib import import_module
|
||||
from xmodule.errortracker import null_error_tracker, exc_info_to_str
|
||||
@@ -496,6 +497,12 @@ class MongoModuleStore(ModuleStoreBase):
|
||||
"""
|
||||
try:
|
||||
source_item = self.collection.find_one(location_to_query(source))
|
||||
|
||||
# allow for some programmatically generated substitutions in metadata, e.g. Discussion_id's should be auto-generated
|
||||
for key in source_item['metadata'].keys():
|
||||
if source_item['metadata'][key] == '$$GUID$$':
|
||||
source_item['metadata'][key] = uuid4().hex
|
||||
|
||||
source_item['_id'] = Location(location).dict()
|
||||
self.collection.insert(source_item)
|
||||
item = self._load_items([source_item])[0]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
metadata:
|
||||
display_name: Discussion Tag
|
||||
for: Topic-Level Student-Visible Label
|
||||
id: 6002x_group_discussion_by_this
|
||||
id: $$GUID$$
|
||||
discussion_category: Week 1
|
||||
data: |
|
||||
<discussion />
|
||||
|
||||
@@ -340,7 +340,7 @@ class XModuleDescriptor(XModuleFields, HTMLSnippet, ResourceTemplates, XBlock):
|
||||
|
||||
# cdodge: this is a list of metadata names which are 'system' metadata
|
||||
# and should not be edited by an end-user
|
||||
system_metadata_fields = ['data_dir', 'published_date', 'published_by', 'is_draft']
|
||||
system_metadata_fields = ['data_dir', 'published_date', 'published_by', 'is_draft', 'discussion_id']
|
||||
|
||||
# A list of descriptor attributes that must be equal for the descriptors to
|
||||
# be equal
|
||||
|
||||
Reference in New Issue
Block a user