Skip to content
31 changes: 24 additions & 7 deletions src/pages/Dashboard/Summary/Summary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<SummaryCard v-for="(statistic, index) in statistics" :statistic="statistic" :key="index"/>
<SummaryCard v-for="(statistic, index) in summary" :statistic="statistic" :key="index"/>
</div>
</template>

Expand All @@ -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."
}
Expand Down
20 changes: 20 additions & 0 deletions src/services/Summary/summary-processing.js
Original file line number Diff line number Diff line change
@@ -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 };
19 changes: 19 additions & 0 deletions src/services/forum-processing.js
Original file line number Diff line number Diff line change
@@ -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 };
54 changes: 30 additions & 24 deletions src/services/local-processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions src/services/model/Log.js
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 12 additions & 0 deletions src/services/model/Summary.js
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 5 additions & 1 deletion src/vuex/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ const store = createStore({
status: false,
message: "Error: Something went wrong",
timeout: 0,
}
},
summary_types: null,
}
},
mutations: {
Expand All @@ -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;
}
}
});
Expand Down