Skip to content

Commit

Permalink
fix: fix code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Talha-Rizwan committed Dec 27, 2023
1 parent d934531 commit 4652099
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 35 deletions.
6 changes: 2 additions & 4 deletions openedx_cmi5_xblock/openedx_cmi5_xblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ def student_view(self, context=None):
},
)
return frag


@XBlock.handler
def lrs_endpoint(self, request, _suffix):
Expand Down Expand Up @@ -296,7 +295,7 @@ def launch_au_url(self, url):
else:
folder = self.extract_folder_path
lms_cmi5_url = requests.utils.unquote(self.storage.url(os.path.join(folder, url)))

params_joining_symbol = '&' if is_params_exist(lms_cmi5_url) else '?'
lms_cmi5_url = lms_cmi5_url + params_joining_symbol + self.get_launch_url_params()
return lms_cmi5_url
Expand Down Expand Up @@ -438,7 +437,6 @@ def index_page_url(self):
lms_cmi5_url = lms_cmi5_url + params_joining_symbol
return lms_cmi5_url + self.get_launch_url_params()


@property
def extract_folder_path(self):
"""
Expand Down Expand Up @@ -532,7 +530,7 @@ def update_package_fields(self):
if au_urls is not None:
self.index_page_path = au_urls[0].text
self.au_urls = [self.launch_au_url(au_url.text) for au_url in au_urls]
self.total_au_count = len(self.au_urls)
self.total_au_count = len(self.au_urls)
else:
self.index_page_path = self.find_relative_file_path('index.html')

Expand Down
44 changes: 13 additions & 31 deletions openedx_cmi5_xblock/static/js/src/openedx_cmi5_xblock.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* Javascript for CMI5XBlock. */
function CMI5XBlock(runtime, element, settings) {


$(function ($) {
/*
Use `gettext` provided by django-statici18n for static translations
Expand All @@ -13,52 +12,35 @@ function CMI5XBlock(runtime, element, settings) {
var nextButton = $('#nextButton');
var prevButton = $('#prevButton');
prevButton.prop('disabled', true)

if(settings.total_au_count === 1){
nextButton.prop('disabled', true)
}

nextButton.click(function () {

console.log("the au_urls are : ", settings.au_urls)
console.log("total au count : ", settings.total_au_count)
console.log("current au index: ", settings.current_au_index)



if(settings.current_au_index < settings.total_au_count-1){
settings.current_au_index+=1
prevButton.prop('disabled', false)

settings.current_au_index+=1
prevButton.prop('disabled', false)
if(settings.current_au_index === settings.total_au_count-1){
nextButton.prop('disabled', true)
}

}


$('.cmi5-embedded').attr('src', settings.au_urls[settings.current_au_index]);
});

});

prevButton.click(function () {

console.log("the au_urls are : ", settings.au_urls)
console.log("total au count : ", settings.total_au_count)
console.log("current au index: ", settings.current_au_index)

if(settings.current_au_index > 0){
prevButton.click(function () {

if(settings.current_au_index > 0){
settings.current_au_index-=1
nextButton.prop('disabled', false)

if(settings.current_au_index === 0){
prevButton.prop('disabled', true);
}
if(settings.current_au_index === 0){
prevButton.prop('disabled', true);
}


$('.cmi5-embedded').attr('src', settings.au_urls[settings.current_au_index]);

});

}
$('.cmi5-embedded').attr('src', settings.au_urls[settings.current_au_index]);
});
});
}

0 comments on commit 4652099

Please sign in to comment.