Skip to content

Commit

Permalink
chore: add fixme's
Browse files Browse the repository at this point in the history
  • Loading branch information
NiedielnitsevIvan committed May 30, 2024
1 parent 074c5bd commit 81c0ec3
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions lms/djangoapps/discussion/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def update_discussions_on_course_publish(sender, course_key, **kwargs): # pylin
import pdb;
pdb.set_trace()
request = generate_request_with_service_user()
# FIXME: Change the block id to the actual block id
result = get_xblock_view_response(request, 'block-v1:new+123+new+type@problem+block@f7693d5dde094f65a28485582125936d', 'student_view')
print(result)

Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/discussion/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def _build_message_context(context, notification_type='forum_comment'): # lint-
'comment_username': comment_author.username,
'post_link': post_link,
'push_notification_extra_context': {
'course_id': str(context['course_id']),
'notification_type': notification_type,
'topic_id': context.get('thread_commentable_id', ''),
'thread_id': context['thread_id'],
Expand Down
6 changes: 4 additions & 2 deletions lms/djangoapps/offline_mode/utils/assets_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def save_asset_file(xblock, path, filename):
pass
else:
base_path = base_storage_path(xblock)
default_storage.save(f'{base_path}assets/{filename}', ContentFile(content))
default_storage.save(f'{base_path}assets/{filename}', ContentFile(content)) # FIXME: change to os.path.join


def remove_old_files(xblock):
Expand All @@ -55,6 +55,7 @@ def remove_old_files(xblock):
# Define the paths to the specific items to delete
asset_path = os.path.join(base_path, 'asset')
index_file_path = os.path.join(base_path, 'index.html')
# FIXME: change filename to block_id or move to constants
offline_zip_path = os.path.join(base_path, 'offline_content.zip')

# Delete the 'asset' directory if it exists
Expand Down Expand Up @@ -88,7 +89,7 @@ def is_offline_content_present(xblock):
"""
try:
base_path = base_storage_path(xblock)

# FIXME: change filename to block_id or move to constants
# Define the path to the 'offline_content.zip' file
offline_zip_path = os.path.join(base_path, 'offline_content.zip')

Expand Down Expand Up @@ -116,4 +117,5 @@ def base_storage_path(xblock):
Returns:
str: The constructed base storage path.
"""
# FIXME: change to os.path.join?
return '{loc.org}/{loc.course}/{loc.block_type}/{loc.block_id}/'.format(loc=xblock.location)
2 changes: 2 additions & 0 deletions lms/djangoapps/offline_mode/utils/html_manipulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def __init__(self, xblock, html_data):
self.xblock = xblock

def _replace_mathjax_link(self):
# FIXME: version shouldn't be hardcoded
mathjax_pattern = re.compile(r'src="https://cdn.jsdelivr.net/npm/[email protected]/MathJax.js[^"]*"')
return mathjax_pattern.sub('src="/static/mathjax/MathJax.js"', self.html_data)

Expand All @@ -34,6 +35,7 @@ def _replace_iframe(self, soup):

def _add_js_bridge(self, soup):
script_tag = soup.new_tag('script')
# FIXME: this script should be loaded from a file
script_tag.string = """
// JS bridge script
function sendMessageToiOS(message) {
Expand Down
6 changes: 3 additions & 3 deletions lms/djangoapps/offline_mode/utils/xblock_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@

User = get_user_model()

OFFLINE_SUPPORTED_XBLOCKS = ['html', 'problem']
OFFLINE_SUPPORTED_XBLOCKS = ['html', 'problem'] # FIXME: move this to settings


def is_offline_supported(xblock):
return xblock.location.block_type in OFFLINE_SUPPORTED_XBLOCKS


def is_modified(xblock):
file_path = f'{base_storage_path(xblock)}content_html.zip'
file_path = f'{base_storage_path(xblock)}content_html.zip' # FIXME: change filename, and change to os.path.join

try:
last_modified = default_storage.get_created_time(file_path)
Expand All @@ -33,7 +33,7 @@ def is_modified(xblock):


def generate_request_with_service_user():
user = User.objects.get(email='[email protected]')
user = User.objects.get(email='[email protected]') # FIXME: Change this to a valid user
request = HttpRequest()
request.user = user
# Set up the session
Expand Down
15 changes: 14 additions & 1 deletion lms/djangoapps/offline_mode/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import os
from django.conf import settings
from django.core.files.storage import default_storage

from opaque_keys.edx.keys import CourseKey
from rest_framework.response import Response
from rest_framework.views import APIView

from lms.djangoapps.offline_mode.utils.assets_management import is_offline_content_present, save_asset_file
from lms.djangoapps.offline_mode.utils.xblock_helpers import is_offline_supported
from xmodule.modulestore.django import modulestore


from .file_management import save_asset_file, remove_old_files, base_storage_path
from .tasks import generate_course_media


class OfflineXBlockStatusInfoView(APIView):
# FIXME: Add docstring

def get(self, request, course_id):
course_key = CourseKey.from_string(course_id)
Expand All @@ -21,7 +34,7 @@ def get(self, request, course_id):

html_data = default_storage.url(offline_zip_path)
if not html_data.startswith('http'):
html_data = f'{settings.LMS_ROOT_URL}{html_data}'
html_data = f'{settings.LMS_ROOT_URL}{html_data}' # FIXME: use os.path.join

last_modified = default_storage.get_created_time(offline_zip_path)
size = default_storage.size(offline_zip_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def update_info_api(self, html_data=None):
self.remove_old_files(base_path)

# Replace MathJax URL
# FIXME: version shouldn't be hardcoded
mathjax_pattern = re.compile(r'src="https://cdn.jsdelivr.net/npm/[email protected]/MathJax.js[^"]*"')
data = mathjax_pattern.sub(self._replace_mathjax_link, html_data)

Expand Down Expand Up @@ -72,6 +73,7 @@ def _replace_iframe(self, soup):

def _add_js_bridge(self, soup):
script_tag = soup.new_tag('script')
# FIXME: this script should be loaded from a file
script_tag.string = """
// Function to send messages to iOS
function sendMessageToiOS(message) {
Expand Down Expand Up @@ -209,7 +211,7 @@ def student_view_data(self):
html_data = default_storage.url(file_path)

if not html_data.startswith('http'):
html_data = f'{settings.LMS_ROOT_URL}{html_data}'
html_data = f'{settings.LMS_ROOT_URL}{html_data}' # FIXME: use os.path.join

last_modified = default_storage.get_created_time(file_path)
size = default_storage.size(file_path)
Expand Down

0 comments on commit 81c0ec3

Please sign in to comment.