My sessions: Get session list using graphql, reusing CourseCard.vue

pull/3924/head
Julio Montoya 3 years ago
parent 39075e748b
commit ac7544a82e
  1. 16
      assets/vue/components/course/CourseCard.vue
  2. 34
      assets/vue/components/session/SessionCard.vue
  3. 6
      assets/vue/components/session/SessionCardList.vue
  4. 94
      assets/vue/views/course/Home.vue
  5. 11
      assets/vue/views/user/courses/List.vue
  6. 65
      assets/vue/views/user/sessions/List.vue
  7. 2
      src/CoreBundle/Entity/AbstractResource.php
  8. 1
      src/CoreBundle/Entity/SessionRelCourseRelUser.php

@ -1,16 +1,4 @@
<template>
<!-- <q-card class="my-card">-->
<!-- <q-img src="https://cdn.quasar.dev/img/parallax2.jpg">-->
<!-- <div class="absolute-bottom text-h6">-->
<!-- Title-->
<!-- </div>-->
<!-- </q-img>-->
<!-- <q-card-section>-->
<!-- {{ lorem }}-->
<!-- </q-card-section>-->
<!-- </q-card>-->
<v-card
elevation="4"
>
@ -31,7 +19,7 @@
</div>
</div>
<div class="pt-6 ">
<div v-if="course.users" class="pt-6">
<div class="flex flex-row" v-if="course.users.edges.length">
<div class="flex flex-row pr-3" v-for="courseRelUser in course.users.edges">
<div class="pr-2">
@ -40,7 +28,6 @@
alt=""
/>
</div>
<div v-if="course.users.edges.length < 3 " class="text-xs flex-col">
<div>
{{ courseRelUser.node.user.firstname }} {{ courseRelUser.node.user.lastname }}
@ -48,7 +35,6 @@
</div>
</div>
</div>
</div>
<!-- <q-card-actions>-->
<!-- <q-btn-->

@ -1,23 +1,15 @@
<template>
<div class="text-h6 mt-4">{{ sessionRelUser.session.name }}</div>
<div class="text-h6 mt-4">{{ session.name }}</div>
<div class="grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-4">
<div
v-for="course in sessionRelUser.courses"
:key="course.id"
v-for="edge in session.sessionRelCourseRelUsers.edges"
:key="edge.node.course.id"
no-body
style="max-width: 540px;"
>
<q-card class="my-card">
<img src="/img/session_default.png" />
<q-card-section>
<div class="text-h7">
<!-- <router-link :to="'/course/' + course.course.id + '/home' + '?sid=' + sessionRelUser.session.id">-->
<a :href="'/course/' + course.course.id + '/home' + '?sid=' + sessionRelUser.session.id">
{{ course.course.title }}
</a>
</div>
</q-card-section>
</q-card>
<CourseCard
:course="edge.node.course"
/>
</div>
</div>
</template>
@ -28,16 +20,16 @@
}
</style>
<script>
import CourseCard from '../course/CourseCard.vue';
export default {
name: 'SessionCard',
props: {
sessionRelUser: Object,
},
data() {
return {
};
components: {
CourseCard,
},
methods: {
props: {
session: Object,
}
};
</script>

@ -1,10 +1,10 @@
<template>
<div
v-for="card in sessions"
:key="card.session.id"
v-for="session in sessions"
:key="session.id"
>
<SessionCard
:sessionRelUser="card"
:session="session"
/>
</div>
</template>

@ -7,48 +7,48 @@
<div>
<div class="flex flex-row" v-if="isCurrentTeacher && course">
<a class="btn btn-info mr-2">
<v-icon class="pr-2">mdi-eye</v-icon>
See as student
</a>
<div class="relative">
<!-- shadow rounded-full-->
<button
@click="dropdownOpen = !dropdownOpen"
class="relative z-10 block h-8 w-8 overflow-hidden focus:outline-none"
>
<v-icon>mdi-cog</v-icon>
</button>
<div
v-show="dropdownOpen"
@click="dropdownOpen = false"
class="fixed inset-0 h-full w-full z-10"
></div>
<div
v-show="dropdownOpen"
class="absolute right-0 mt-2 py-2 w-48 bg-white rounded-md shadow-xl z-20"
>
<q-list dense>
<!-- <q-item replace :to="'/main/messages/index.php'" clickable class="">-->
<!-- <q-item-section>Inbox</q-item-section>-->
<!-- </q-item>-->
<q-item
:href="goToCourseTool(course, tool)"
tag="a"
class=""
v-for="tool in tools.admin"
<a class="btn btn-info mr-2">
<v-icon class="pr-2">mdi-eye</v-icon>
See as student
</a>
<div class="relative">
<!-- shadow rounded-full-->
<button
@click="dropdownOpen = !dropdownOpen"
class="relative z-10 block h-8 w-8 overflow-hidden focus:outline-none"
>
<q-item-section> {{ tool.ctool.nameToTranslate }}</q-item-section>
</q-item>
</q-list>
</div>
</div>
<v-icon>mdi-cog</v-icon>
</button>
<div
v-show="dropdownOpen"
@click="dropdownOpen = false"
class="fixed inset-0 h-full w-full z-10"
></div>
<div
v-show="dropdownOpen"
class="absolute right-0 mt-2 py-2 w-48 bg-white rounded-md shadow-xl z-20"
>
<q-list dense>
<!-- <q-item replace :to="'/main/messages/index.php'" clickable class="">-->
<!-- <q-item-section>Inbox</q-item-section>-->
<!-- </q-item>-->
<q-item
:href="goToCourseTool(course, tool)"
tag="a"
class=""
v-for="tool in tools.admin"
>
<q-item-section> {{ tool.ctool.nameToTranslate }}</q-item-section>
</q-item>
</q-list>
</div>
</div>
</div>
</div>
</div>
</div>
<hr/>
@ -63,7 +63,7 @@
You don't have course content
</div>
<div>
Add a course introduction to display to your students.
Add a course introduction to display to your students.
</div>
<a class="btn btn-info">
<v-icon>mdi-plus</v-icon>
@ -73,17 +73,17 @@
</div>
</div>
<hr />
<hr/>
<div class="flex justify-between">
<div class="text-h6 font-bold">
Tools
</div>
<!-- <div>-->
<!-- <v-icon>-->
<!-- mdi-format-paint-->
<!-- </v-icon>-->
<!-- Customize-->
<!-- </div>-->
<!-- <div>-->
<!-- <v-icon>-->
<!-- mdi-format-paint-->
<!-- </v-icon>-->
<!-- Customize-->
<!-- </div>-->
</div>

@ -9,12 +9,10 @@
<script>
import CourseCardList from '../../../components/course/CourseCardList.vue';
import {ENTRYPOINT} from '../../../config/entrypoint';
import axios from "axios";
import {ref, computed} from "vue";
import { useStore } from 'vuex';
import {useStore} from 'vuex';
import gql from "graphql-tag";
import { useQuery, useResult } from '@vue/apollo-composable'
import {useQuery, useResult} from '@vue/apollo-composable'
export default {
name: 'CourseList',
@ -22,9 +20,6 @@ export default {
CourseCardList,
},
setup() {
//const courses = ref([]);
const status = ref('Loading');
const store = useStore();
let user = computed(() => store.getters['security/getUser']);
@ -42,7 +37,7 @@ export default {
);*/
const GET_COURSE_REL_USER = gql`
query getCourses($user: String!){
query getCourses($user: String!) {
courseRelUsers(user: $user) {
edges {
node {

@ -1,16 +1,16 @@
<template>
<div class="grid">
{{ status }}
<!-- {{ status }}-->
<SessionCardList :sessions="sessions" />
</div>
</template>
<script>
import SessionCardList from '../../../components/session/SessionCardList.vue';
import { ENTRYPOINT } from '../../../config/entrypoint';
import axios from "axios";
import {computed, ref} from "vue";
import {useStore} from "vuex";
import {ref, computed} from "vue";
import {useStore} from 'vuex';
import gql from "graphql-tag";
import {useQuery, useResult} from '@vue/apollo-composable'
export default {
name: 'SessionList',
@ -18,15 +18,14 @@ export default {
SessionCardList,
},
setup() {
const sessions = ref([]);
const status = ref('Loading');
const loading = ref('Loading');
const store = useStore();
let user = computed(() => store.getters['security/getUser']);
if (user.value) {
let userId = user.value.id;
axios.get(ENTRYPOINT + 'users/' + userId + '/sessions_rel_users.json').then(response => {
/*axios.get(ENTRYPOINT + 'users/' + userId + '/sessions_rel_users.json').then(response => {
if (Array.isArray(response.data)) {
sessions.value = response.data;
}
@ -35,12 +34,50 @@ export default {
console.log(error);
}).finally(() =>
status.value = ''
);
}
);*/
const GET_SESSION_REL_USER = gql`
query getSessions($user: String!) {
sessionRelUsers(user: $user) {
edges {
node {
session {
_id
name
displayStartDate
displayEndDate,
sessionRelCourseRelUsers(user: $user) {
edges {
node {
course {
_id
title
illustrationUrl
}
}
}
}
}
}
}
}
}
`;
const {result, loading, error} = useQuery(GET_SESSION_REL_USER, {
user: "/api/users/" + userId
}, );
const sessions = useResult(result, null, (data) => {
return data.sessionRelUsers.edges.map(function(edge) {
return edge.node.session;
});
});
return {
sessions,
status
return {
sessions,
loading
}
}
}
}

@ -53,7 +53,7 @@ abstract class AbstractResource
* Resource illustration URL - Property set by ResourceNormalizer.php.
*
* @ApiProperty(iri="http://schema.org/contentUrl")
* @Groups({"resource_file:read", "resource_node:read", "document:read", "media_object_read", "course:read", "course_rel_user:read"})
* @Groups({"resource_node:read", "document:read", "media_object_read", "course:read", "session:read", "course_rel_user:read", "session_rel_course_rel_user:read"})
*/
public ?string $illustrationUrl = null;

@ -29,7 +29,6 @@ use Symfony\Component\Validator\Constraints as Assert;
* )
* @ORM\Entity
*/
#[ApiFilter(SearchFilter::class, properties: ['user' => 'exact'])]
class SessionRelCourseRelUser
{

Loading…
Cancel
Save