mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: activity issues
This commit is contained in:
parent
a4c02602d9
commit
23036351a8
2 changed files with 20 additions and 4 deletions
|
|
@ -31,7 +31,7 @@ function ActivityClient(props: ActivityClientProps) {
|
||||||
function getChapterName(chapterId: string) {
|
function getChapterName(chapterId: string) {
|
||||||
let chapterName = "";
|
let chapterName = "";
|
||||||
course.chapters.forEach((chapter: any) => {
|
course.chapters.forEach((chapter: any) => {
|
||||||
if (chapter.chapter_id === chapterId) {
|
if (chapter.id === chapterId) {
|
||||||
chapterName = chapter.name;
|
chapterName = chapter.name;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -59,7 +59,7 @@ function ActivityClient(props: ActivityClientProps) {
|
||||||
|
|
||||||
<div className="flex justify-between items-center">
|
<div className="flex justify-between items-center">
|
||||||
<div className="flex flex-col -space-y-1">
|
<div className="flex flex-col -space-y-1">
|
||||||
<p className="font-bold text-gray-700 text-md">Chapter : {getChapterName(activity.chapter_id)}</p>
|
<p className="font-bold text-gray-700 text-md">Chapter : {getChapterName(activity.coursechapter_id)}</p>
|
||||||
<h1 className="font-bold text-gray-950 text-2xl first-letter:uppercase" >{activity.name}</h1>
|
<h1 className="font-bold text-gray-950 text-2xl first-letter:uppercase" >{activity.name}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex space-x-2">
|
<div className="flex space-x-2">
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,22 @@ async def update_coursechapters_meta(
|
||||||
# handle error when no documents are matched by the filter query
|
# handle error when no documents are matched by the filter query
|
||||||
print(f"No documents found for course chapter ID {coursechapter_id}")
|
print(f"No documents found for course chapter ID {coursechapter_id}")
|
||||||
|
|
||||||
|
# update activities in coursechapters
|
||||||
|
activity = request.app.db["activities"]
|
||||||
|
if coursechapters_metadata.chapters is not None:
|
||||||
|
for (
|
||||||
|
coursechapter_id,
|
||||||
|
chapter_metadata,
|
||||||
|
) in coursechapters_metadata.chapters.items():
|
||||||
|
# Update coursechapter_id in activities
|
||||||
|
filter_query = {"activity_id": {"$in": chapter_metadata["activityIds"]}}
|
||||||
|
update_query = {"$set": {"coursechapter_id": coursechapter_id}}
|
||||||
|
|
||||||
|
result = await activity.update_many(filter_query, update_query)
|
||||||
|
if result.matched_count == 0:
|
||||||
|
# handle error when no documents are matched by the filter query
|
||||||
|
print(f"No documents found for course chapter ID {coursechapter_id}")
|
||||||
|
|
||||||
return {"detail": "coursechapters metadata updated"}
|
return {"detail": "coursechapters metadata updated"}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue