EDU-277 Implement separate feature usage statistics for PyCharm Educational Edition

This commit is contained in:
Ekaterina Tuzova
2016-06-29 11:16:01 +03:00
parent 5bb2719ce5
commit a4d61d5334
2 changed files with 61 additions and 0 deletions
@@ -98,6 +98,8 @@
<extendWordSelectionHandler implementation="com.jetbrains.edu.learning.StudyAnswerPlaceholderExtendWordHandler"/>
<renameHandler implementation="com.jetbrains.edu.learning.StudyRenameHandler"/>
<refactoring.moveHandler implementation="com.jetbrains.edu.learning.StudyMoveDelegate" order="first"/>
<statistics.usagesCollector implementation="com.jetbrains.edu.learning.statistics.EduUsagesCollector"/>
</extensions>
<extensions defaultExtensionNs="Edu">
<optionsProvider instance="com.jetbrains.edu.learning.stepic.StepicStudyOptions"/>
@@ -0,0 +1,59 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.edu.learning.statistics;
import com.intellij.internal.statistic.AbstractApplicationUsagesCollector;
import com.intellij.internal.statistic.CollectUsagesException;
import com.intellij.internal.statistic.beans.GroupDescriptor;
import com.intellij.internal.statistic.beans.UsageDescriptor;
import com.intellij.openapi.project.Project;
import com.jetbrains.edu.learning.StudyTaskManager;
import com.jetbrains.edu.learning.core.EduNames;
import com.jetbrains.edu.learning.courseFormat.Course;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
public class EduUsagesCollector extends AbstractApplicationUsagesCollector {
private static final String GROUP_ID = "educational-course";
@NotNull
@Override
public Set<UsageDescriptor> getProjectUsages(@NotNull Project project) throws CollectUsagesException {
final Set<UsageDescriptor> result = new HashSet<UsageDescriptor>();
final Course course = StudyTaskManager.getInstance(project).getCourse();
if (course != null) {
if (course.isAdaptive()) {
result.add(new UsageDescriptor("Adaptive", 1));
}
else if (EduNames.STUDY.equals(course.getCourseMode())) {
result.add(new UsageDescriptor(EduNames.STUDY, 1));
}
else {
result.add(new UsageDescriptor("Course Creator", 1));
}
}
return result;
}
@NotNull
@Override
public GroupDescriptor getGroupId() {
return GroupDescriptor.create(GROUP_ID);
}
}