Skip to content

Commit

Permalink
Merge pull request #969 from UniversityOfHelsinkiCS/trunk
Browse files Browse the repository at this point in the history
Make feedback visible to users
  • Loading branch information
sasumaki authored Jun 4, 2019
2 parents 8b93eaa + 1de6b80 commit 3dc67b7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 9 deletions.
57 changes: 49 additions & 8 deletions services/backend/oodikone2-backend/src/services/studytrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,37 @@ const formatCredit = credit => {
return { id, year, credits }
}

const fuckup = (provider, since, studentnumbers) => Credit.findAll({
attributes: ['id', 'course_code', 'credits', 'attainment_date', 'student_studentnumber'],
include: {
model: Course,
attributes: ['code'],
required: true,
where: {
is_study_module: false
},
include: {
model: Provider,
attributes: [],
required: true,
where: {
providercode: provider
}
}
},
where: {
credittypecode: {
[Op.notIn]: [10, 9]
},
attainment_date: {
[Op.gte]: since
},
student_studentnumber: {
[Op.in]: studentnumbers
}
}
}).map(formatCredit)

const getCreditsForProvider = (provider, since) => Credit.findAll({
attributes: ['id', 'course_code', 'credits', 'attainment_date'],
include: {
Expand Down Expand Up @@ -183,6 +214,7 @@ const combineStatistics = (creditStats, studyrightStats, thesisStats) => {
return Object.values(stats)
}

// providercode here
const productivityStatsForStudytrack = async (studytrack, since) => {
const providercode = studytrackToProviderCode(studytrack)
const promises = [
Expand Down Expand Up @@ -341,14 +373,19 @@ const tranferredToStudyprogram = async (studentnumbers, startDate, studytrack, e
})
}

const getCreditsFromStudyprogrammeStudents = async (studytrack, startDate, studentnumbers) => {
const providercode = studytrackToProviderCode(studytrack)
const test = await fuckup(providercode, startDate, studentnumbers)
return test.map(formatCredit)
}

const productivityStats = async (studentnumbers, startDate, studytrack, endDate) => {
return Promise.all([creditsAfter(studentnumbers, startDate),
graduationsFromClass(studentnumbers, studytrack),
thesesFromClass(studentnumbers, startDate, studytrack),
gendersFromClass(studentnumbers),
countriesFromClass(studentnumbers),
tranferredToStudyprogram(studentnumbers, startDate, studytrack, endDate)
])
graduationsFromClass(studentnumbers, studytrack),
thesesFromClass(studentnumbers, startDate, studytrack),
gendersFromClass(studentnumbers),
countriesFromClass(studentnumbers),
tranferredToStudyprogram(studentnumbers, startDate, studytrack, endDate)])
}

const getYears = (since) => {
Expand Down Expand Up @@ -385,10 +422,13 @@ const throughputStatsForStudytrack = async (studytrack, since) => {
const startDate = `${year}-${semesterStart['FALL']}`
const endDate = `${moment(year, 'YYYY').add(1, 'years').format('YYYY')}-${semesterEnd['SPRING']}`
const studentnumbers = await studentnumbersWithAllStudyrightElements([studytrack], startDate, endDate, false, false)
const creditsForStudyprogramme = await getCreditsFromStudyprogrammeStudents(studytrack, startDate, studentnumbers)
const [credits, graduated, theses, genders, countries, transferred] =
await productivityStats(studentnumbers, startDate, studytrack, endDate)
delete genders[null]
delete countries[null]
const test = creditsForStudyprogramme.map(formatCredit)
console.log(test)

const creditValues = credits.reduce((acc, curr) => {
acc.mte30 = curr >= 30 ? acc.mte30 + 1 : acc.mte30
Expand Down Expand Up @@ -418,11 +458,12 @@ const throughputStatsForStudytrack = async (studytrack, since) => {
totals.thesisB = theses.BACHELOR ? totals.thesisB + theses.BACHELOR : totals.thesisB
totals.students = totals.students + credits.length
totals.graduated = totals.graduated + graduated.length,
totals.inTargetTime = totals.inTargetTime + inTargetTime,
totals.transferred = totals.transferred + transferred.count
totals.inTargetTime = totals.inTargetTime + inTargetTime,
totals.transferred = totals.transferred + transferred.count
return {
year: `${year}-${year + 1}`,
credits: credits.map(cr => cr === null ? 0 : cr),
creditsForStudyprogramme: creditsForStudyprogramme.map(cr => cr === null ? 0 : cr),
graduated: graduated.length,
inTargetTime,
thesisM: theses.MASTER || 0,
Expand Down
2 changes: 1 addition & 1 deletion services/oodikone2-frontend/src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const routes = {
usage: { menuRoute: '/usage', route: '/usage', translateId: 'usage', reqRights: ['usage'] },
sandbox: { menuRoute: '/sandbox', route: '/sandbox', translateId: 'sandbox', reqRights: ['dev'] },
oodilearn: { menuRoute: '/oodilearn', route: '/oodilearn', translateId: 'oodilearn', reqRights: ['oodilearn'] },
feedback: { menuRoute: '/feedback', route: '/feedback', translateId: 'feedback', reqRights: ['users'] }
feedback: { menuRoute: '/feedback', route: '/feedback', translateId: 'feedback' }
}

export const hiddenRoutes = {
Expand Down

0 comments on commit 3dc67b7

Please sign in to comment.