Skip to content

Commit

Permalink
FIX: fixes after rebasing.
Browse files Browse the repository at this point in the history
FIX: fixes after rebasing.
  • Loading branch information
pstaabp committed Aug 26, 2022
1 parent c8e7cef commit 9c1d4cc
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/DB/Schema/ResultSet/UserSet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ sub getAllUserSetsForCourse ($self, %args) {
my $course = $self->rs('Course')->getCourse(info => $args{info}, as_result_set => 1);
my @user_sets = $self->search(
{
'courses.course_id' => $course->course_id
'course.course_id' => $course->course_id
},
{
join => [ { 'problem_set' => 'courses' }, { 'course_users' => 'users' } ]
join => [ { 'problem_set' => 'course' }, { 'course_user' => 'user' } ]
}
);

Expand Down
2 changes: 0 additions & 2 deletions src/layouts/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ import { endSession } from 'src/common/api-requests/session';
import { useSessionStore } from 'src/stores/session';
import { useSettingsStore } from 'src/stores/settings';
import type { CourseSettingInfo } from 'src/common/models/settings';
defineEmits(['toggle-menu', 'toggle-sidebar']);
const session = useSessionStore();
const settings = useSettingsStore();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/instructor/Instructor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (course_id !== session.course.course_id) {
await users.fetchGlobalCourseUsers(course_id);
await users.fetchCourseUsers(course_id);
await problem_sets.fetchProblemSets(course_id);
await settings.fetchDefaultSettings(course_id)
await settings.fetchGlobalSettings()
.then(() => settings.fetchCourseSettings(course_id))
.then(() => void setI18nLanguage(settings.getCourseSetting('language').value as string))
.catch((err) => logger.error(`${JSON.stringify(err)}`));
Expand Down
3 changes: 2 additions & 1 deletion src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ export const useSettingsStore = defineStore('settings', {
* This returns the course setting by name.
*/
getCourseSetting: (state) => (setting_name: string): CourseSetting => {
const session_store = useSessionStore();
const global_setting = state.global_settings.find(setting => setting.setting_name === setting_name);
if (global_setting) {
const db_course_setting = state.db_course_settings
.find(setting => setting.setting_id === global_setting?.setting_id);
return new CourseSetting(Object.assign(
db_course_setting?.toObject() ?? {},
db_course_setting?.toObject() ?? { course_id: session_store.course.course_id },
global_setting?.toObject()));
} else {
throw `The setting with name: '${setting_name}' does not exist.`;
Expand Down
1 change: 0 additions & 1 deletion tests/stores/set_problems.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { Dictionary, generic } from 'src/common/models';

import { loadCSV, cleanIDs } from '../utils';
import { checkPassword } from 'src/common/api-requests/session';
import { logger } from 'src/boot/logger';

const app = createApp({});

Expand Down
15 changes: 9 additions & 6 deletions tests/stores/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { CourseSetting, DBCourseSetting, GlobalSetting, ParseableDBCourseSetting

import { cleanIDs, loadCSV } from '../utils';
import { humanReadableTimeDuration } from 'src/common/models/parsers';
import { SessionInfo } from 'src/common/models/session';

describe('Test the settings store', () => {

Expand All @@ -49,8 +50,14 @@ describe('Test the settings store', () => {
.map(setting => ({
setting_name: setting.setting_name as string, value: setting.setting_value as SettingValueType
}));
// Login to the course as the admin in order to be authenticated for the rest of the test.
await api.post('login', { username: 'admin', password: 'admin' });
// Login to the course as an instructor of Arithmetic. (course_id: 4)
const response = await api.post('login', { username: 'lisa', password: 'lisa' });

// set the session course to the Arithmetic course (course_id: 4)
const session_store = useSessionStore();
session_store.updateSessionInfo(response.data as SessionInfo);
await session_store.fetchUserCourses();
session_store.setCourse(4);

const settings_store = useSettingsStore();
await settings_store.fetchGlobalSettings();
Expand Down Expand Up @@ -92,10 +99,6 @@ describe('Test the settings store', () => {
.filter(setting => arith_setting_ids.includes(setting.setting_id))
.map(setting => ({ setting_name: setting.setting_name, value: setting.value }));
expect(arith_settings_from_db).toStrictEqual(arith_settings);

// set the session course to this course
const session_store = useSessionStore();
session_store.setCourse({ course_id: 4, course_name: 'Arithmetic' });
});

test('Get a single course setting based on name', () => {
Expand Down
1 change: 0 additions & 1 deletion tests/stores/user_sets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import { createApp } from 'vue';
import { createPinia, setActivePinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import { api } from 'boot/axios';

import { useCourseStore } from 'src/stores/courses';
import { useProblemSetStore } from 'src/stores/problem_sets';
Expand Down

0 comments on commit 9c1d4cc

Please sign in to comment.