Update links to match the new pattern

This commit is contained in:
Kristin Aoki
2021-07-30 15:20:01 -04:00
parent d517f94c49
commit 4baf78c79e
12 changed files with 58 additions and 37 deletions

View File

@@ -22,10 +22,18 @@ Factory.define('block')
return blockId;
})
.attr(
'hash_key', ['hash_key'],
() => (Math.random().toString(36).substring(2, 15)),
)
.attr(
'id',
['id', 'block_id', 'type', 'courseId'],
(id, blockId, type, courseId) => {
['id', 'block_id', 'type', 'courseId', 'hash_key'],
(id, blockId, type, courseId, hashKey) => {
if (hashKey) {
return hashKey;
}
if (id) {
return id;
}
@@ -35,25 +43,33 @@ Factory.define('block')
return `block-v1:${courseInfo}+type@${type}+block@${blockId}`;
},
)
.attr(
'decoded_id', ['block_id', 'type', 'courseId'],
(blockId, type, courseId) => {
const courseInfo = courseId.split(':')[1];
return `block-v1:${courseInfo}+type@${type}+block@${blockId}`;
},
)
.attr(
'student_view_url',
['student_view_url', 'host', 'id'],
(url, host, id) => {
['student_view_url', 'host', 'decoded_id'],
(url, host, decodedId) => {
if (url) {
return url;
}
return `${host}/xblock/${id}`;
return `${host}/xblock/${decodedId}`;
},
)
.attr(
'legacy_web_url',
['legacy_web_url', 'host', 'courseId', 'id'],
(url, host, courseId, id) => {
['legacy_web_url', 'host', 'courseId', 'decoded_id'],
(url, host, courseId, decodedId) => {
if (url) {
return url;
}
return `${host}/courses/${courseId}/jump_to/${id}?experience=legacy`;
return `${host}/courses/${courseId}/jump_to/${decodedId}?experience=legacy`;
},
);