diff --git a/src/pages/Dashboard/Summary/Summary.vue b/src/pages/Dashboard/Summary/Summary.vue index 21e1837..388c0d6 100644 --- a/src/pages/Dashboard/Summary/Summary.vue +++ b/src/pages/Dashboard/Summary/Summary.vue @@ -8,7 +8,7 @@ sm:auto-rows-auto sm:grid-cols-1 md:auto-rows-auto md:grid-cols-2 xl:auto-rows-auto xl:grid-cols-3"> - + @@ -30,42 +30,59 @@ export default { InteractionCard, SummaryCard }, + computed: { + summary() { + let summary_types = this.$store.state.summary_types; + + this.statistics.forEach( (stat) => { + switch ( stat.statistic_name ) { + case 'Tasks': + stat.number = summary_types['Tarea'].count; + break; + case 'URL': + stat.number = summary_types['URL'].count; + break; + } + }); + return this.statistics + } + }, data(){ return{ statistics:[ { statistic_name: "Tasks", - number: 7342, + number: 0, icon: mdiTextBoxCheck , info:"The total number of interactions with all deliveries of a subject." }, { statistic_name: "Files", - number: 1913, + number: 0, icon: mdiFileDocumentOutline, info:" The total number of interactions with all files of a subject." }, { statistic_name: "Pages", - number:75, + number: 0, icon: mdiNewspaperVariantOutline, info:"The total number of interactions with the pages of a subject." }, { statistic_name: "URL", - number:34, + number: 0, icon: mdiLinkVariant, info: "The total number of interactions with the URL resource of a subject." }, { statistic_name: "Learning Tools Interoperability", - number:0, + number: 0, icon: mdiHammerScrewdriver, info:"The total number of interactions with the learning tools interoperability resources of a subject." }, { statistic_name: "Wiki", - number:1, + number: 0, icon: mdiWikipedia , info:"The total number of interactions with the wikis of a subject." } diff --git a/src/services/Summary/summary-processing.js b/src/services/Summary/summary-processing.js new file mode 100644 index 0000000..6e04586 --- /dev/null +++ b/src/services/Summary/summary-processing.js @@ -0,0 +1,20 @@ +function summary_processing(logs) { + let type = {}; + logs.forEach( (log) => { + // Process all types of logs and count each one of them + if ( type[log.type] !== undefined ) { + type[log.type].count +=1; + type[log.type].interactions[log.interaction] = (type[log.type].interactions[log.interaction] + 1) || 1; + } else { + type[log.type] = { + count: 1, + interactions: {} + } + type[log.type].interactions[log.interaction] = 1; + } + }) + + return type; +} + +export { summary_processing }; \ No newline at end of file diff --git a/src/services/forum-processing.js b/src/services/forum-processing.js new file mode 100644 index 0000000..f6736a5 --- /dev/null +++ b/src/services/forum-processing.js @@ -0,0 +1,19 @@ +import {summary_processing} from "@/services/Summary/summary-processing"; +import Log from "@/services/model/Log"; +import store from "@/vuex/store"; + +function forum_processing(data){ + let logs = []; + + data[0].forEach( (lg) => { + logs.push( + new Log(lg[0], lg[1], lg[2], lg[3], lg[4], lg[5], lg[6], lg[7], lg[8]) + ) + }) + + let summary_types = summary_processing(logs); + + store.commit('saveSummaryTypes', summary_types) +} + +export { forum_processing }; \ No newline at end of file diff --git a/src/services/local-processing.js b/src/services/local-processing.js index b33e856..9122d80 100644 --- a/src/services/local-processing.js +++ b/src/services/local-processing.js @@ -2,6 +2,7 @@ import store from "@/vuex/store"; import router from "@/router/router"; import Message from "@/services/model/Message"; +import {forum_processing} from "@/services/forum-processing"; const UNSUPPORTED_FILE_TYPE = -2 const SUPPORTED_FILE_TYPE = 2 @@ -28,31 +29,36 @@ function local_processing(file) { // Messages log file file_reader.onload = (event) => { let data = JSON.parse(event.target.result); - let messages = data[0]; - let forum = { - "forum_messages": [], - "messages": 0, - "users": 0, - "sentiments": {}, - } - - analyze_sentiment(messages).then( (processed_msg) => { - forum.forum_messages = processed_msg; - // Time format conversion - processed_msg.map( (msg) => { - convert_time(msg); + // Check whether it's a Moodle Logs or Moodle Forum message Logs file + if ( Array.isArray(data[0][0])) { + forum_processing(data); + } else { + let messages = data[0]; + let forum = { + "forum_messages": [], + "messages": 0, + "users": 0, + "sentiments": {}, + } + + analyze_sentiment(messages).then( (processed_msg) => { + forum.forum_messages = processed_msg; + // Time format conversion + processed_msg.map( (msg) => { + convert_time(msg); + }) + // Count messages + forum.messages = processed_msg.length; + // Count users + forum.users = count_users(processed_msg); + // Count sentiment ocurrences + forum.sentiments = count_sentiments(processed_msg); + // Store processed messages in vuex + store.commit('storeForumMessages', forum); + // Push to Dashboard > Sentiment + router.push('/dashboard/sentimental-analysis') }) - // Count messages - forum.messages = processed_msg.length; - // Count users - forum.users = count_users(processed_msg); - // Count sentiment ocurrences - forum.sentiments = count_sentiments(processed_msg); - // Store processed messages in vuex - store.commit('storeForumMessages', forum); - // Push to Dashboard > Sentiment - router.push('/dashboard/sentimental-analysis') - }) + } } file_reader.readAsText(file) diff --git a/src/services/model/Log.js b/src/services/model/Log.js new file mode 100644 index 0000000..5b2d68c --- /dev/null +++ b/src/services/model/Log.js @@ -0,0 +1,14 @@ +class Log { + constructor(date, id, name, course, type, interaction, client, ip) { + this.date = date; + this.id = id; + this.name = name; + this.course = course; + this.type = type; + this.interaction = interaction; + this.client = client; + this.ip = ip; + } +} + +export default Log; \ No newline at end of file diff --git a/src/services/model/Summary.js b/src/services/model/Summary.js new file mode 100644 index 0000000..3c0812b --- /dev/null +++ b/src/services/model/Summary.js @@ -0,0 +1,12 @@ +class Summary { + constructor(tasks, files, pages, url, lti, wiki) { + this.tasks = tasks; + this.files = files; + this.pages = pages; + this.url = url; + this.lti = lti; + this.wiki = wiki; + } +} + +export default Summary; \ No newline at end of file diff --git a/src/vuex/store.js b/src/vuex/store.js index d8dab65..10d78b5 100644 --- a/src/vuex/store.js +++ b/src/vuex/store.js @@ -34,7 +34,8 @@ const store = createStore({ status: false, message: "Error: Something went wrong", timeout: 0, - } + }, + summary_types: null, } }, mutations: { @@ -55,6 +56,9 @@ const store = createStore({ // Toggle alert this.state.alert.status = !this.state.alert.status; this.state.alert.message = message; + }, + saveSummaryTypes(state, summary_types) { + this.state.summary_types = summary_types; } } });