diff options
Diffstat (limited to 'python/edu/course-creator/resources')
6 files changed, 209 insertions, 0 deletions
diff --git a/python/edu/course-creator/resources/META-INF/plugin.xml b/python/edu/course-creator/resources/META-INF/plugin.xml new file mode 100644 index 000000000000..6a9a9ea90276 --- /dev/null +++ b/python/edu/course-creator/resources/META-INF/plugin.xml @@ -0,0 +1,60 @@ +<idea-plugin version="2"> + <id>org.jetbrains.plugins.coursecreator</id> + <name>Course Creator for PyCharm Educational</name> + <version>1.0</version> + + <description><![CDATA[ + Plugin allows you to create new course for PyCharm Education Edition. + ]]></description> + + <change-notes><![CDATA[ + ]]> + </change-notes> + <!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description --> + + <!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products + on how to target different products --> + <!-- uncomment to enable plugin in all products + <depends>com.intellij.modules.lang</depends> + --> + + <depends>com.intellij.modules.python</depends> + + <extensions defaultExtensionNs="com.intellij"> + <directoryProjectGenerator implementation="org.jetbrains.plugins.coursecreator.CCProjectGenerator"/> + <projectService serviceImplementation="org.jetbrains.plugins.coursecreator.CCProjectService"/> + <codeInsight.lineMarkerProvider language="Python" + implementationClass="org.jetbrains.plugins.coursecreator.highlighting.CCTaskLineMarkerProvider"/> + <treeStructureProvider implementation="org.jetbrains.plugins.coursecreator.projectView.CCTreeStructureProvider"/> + </extensions> + + <application-components> + <!-- Add your application components here --> + </application-components> + + <project-components> + <!-- Add your project components here --> + <component> + <implementation-class>org.jetbrains.plugins.coursecreator.CCProjectComponent</implementation-class> + </component> + </project-components> + + <actions> + <action id="CreateLesson" class="org.jetbrains.plugins.coursecreator.actions.CreateLesson"> + <add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFile"/> + </action> + <action id="CreateTaskFile" class="org.jetbrains.plugins.coursecreator.actions.CreateTaskFile"> + <add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFile"/> + </action> + <action id="CreateTask" class="org.jetbrains.plugins.coursecreator.actions.CreateTask"> + <add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFile"/> + </action> + <action id="AddTaskWindow" class="org.jetbrains.plugins.coursecreator.actions.AddTaskWindow"> + <add-to-group group-id="EditorPopupMenu" anchor="before" relative-to-action="CopyReference"/> + </action> + <action id="PackCourse" class="org.jetbrains.plugins.coursecreator.actions.CreateCourseArchive"> + <add-to-group group-id="MainToolBar" anchor="last" /> + </action> + </actions> + +</idea-plugin>
\ No newline at end of file diff --git a/python/edu/course-creator/resources/fileTemplates/internal/task.html.ft b/python/edu/course-creator/resources/fileTemplates/internal/task.html.ft new file mode 100644 index 000000000000..f6833496d1c1 --- /dev/null +++ b/python/edu/course-creator/resources/fileTemplates/internal/task.html.ft @@ -0,0 +1,4 @@ +<html> +Write your task text here. +<br> +</html>
\ No newline at end of file diff --git a/python/edu/course-creator/resources/fileTemplates/internal/task.py.ft b/python/edu/course-creator/resources/fileTemplates/internal/task.py.ft new file mode 100644 index 000000000000..0256e108786c --- /dev/null +++ b/python/edu/course-creator/resources/fileTemplates/internal/task.py.ft @@ -0,0 +1 @@ +# TODO: type solution here
\ No newline at end of file diff --git a/python/edu/course-creator/resources/fileTemplates/internal/test_helper.py.ft b/python/edu/course-creator/resources/fileTemplates/internal/test_helper.py.ft new file mode 100644 index 000000000000..1182b7815c06 --- /dev/null +++ b/python/edu/course-creator/resources/fileTemplates/internal/test_helper.py.ft @@ -0,0 +1,127 @@ +import sys + +def get_file_text(path): + """ get file text by path""" + file_io = open(path, "r") + text = file_io.read() + file_io.close() + return text + +def get_file_output(path): + # TODO: get file output by path + return "" + +def test_file_importable(): + """ tests there is no obvious syntax errors""" + path = sys.argv[-1] + try: + import_file(path) + except ImportError: + failed("File contains syntax errors") + return + except SyntaxError: + failed("File contains syntax errors") + return + except NameError: + failed("File contains syntax errors") + return + + passed() + +def import_file(path): + """ returns imported file """ + import imp + tmp = imp.load_source('tmp', path) + return tmp + +def import_task_file(): + """ returns imported file """ + path = sys.argv[-1] + return import_file(path) + +def test_is_not_empty(): + path = sys.argv[-1] + file_text = get_file_text(path) + + if len(file_text) > 0: + passed() + else: + failed("The file is empty. Please, reload the task and try again.") + +def test_is_initial_text(error_text="You should modify the file"): + path = sys.argv[-1] + text = get_initial_text(path) + file_text = get_file_text(path) + + if file_text.strip() == text: + failed(error_text) + else: + passed() + +def get_initial_text(path): + course_lib = sys.argv[-2] + + import os + # path format is "project_root/lessonX/taskY/file.py" + task_index = path.rfind(os.sep, 0, path.rfind(os.sep)) + index = path.rfind(os.sep, 0, task_index) + relative_path = path[index+1:] + initial_file_path = os.path.join(course_lib, relative_path) + return get_file_text(initial_file_path) + + +def test_text_equals(text, error_text): + path = sys.argv[-1] + file_text = get_file_text(path) + + if file_text.strip() == text: + passed() + else: + failed(error_text) + +def test_window_text_deleted(error_text="Don't just delete task text"): + windows = get_task_windows() + + for window in windows: + if len(window) == 0: + failed(error_text) + return + passed() + + +def failed(message="Please, reload the task and try again."): + print("#study_plugin FAILED + " + message) + +def passed(): + print("#study_plugin test OK") + +def get_task_windows(): + prefix = "#study_plugin_window = " + path = sys.argv[-1] + import os + windows_path = os.path.splitext(path)[0] + "_windows" + windows = [] + f = open(windows_path, "r") + window_text = "" + first = True + for line in f.readlines(): + if line.startswith(prefix): + if not first: + windows.append(window_text.strip()) + else: + first = False + window_text = line[len(prefix):] + else: + window_text += line + + if window_text: + windows.append(window_text.strip()) + + f.close() + return windows + +def run_common_tests(error_text="Please, reload file and try again"): + test_file_importable() + test_is_not_empty() + test_is_initial_text(error_text) + test_window_text_deleted(error_text)
\ No newline at end of file diff --git a/python/edu/course-creator/resources/fileTemplates/internal/tests.py.ft b/python/edu/course-creator/resources/fileTemplates/internal/tests.py.ft new file mode 100644 index 000000000000..2e6fd4c78eed --- /dev/null +++ b/python/edu/course-creator/resources/fileTemplates/internal/tests.py.ft @@ -0,0 +1,17 @@ +from test_helper import run_common_tests, failed, passed, get_task_windows + + +def test_task_windows(): + windows = get_task_windows() + window = windows[0] + if window != "": # TODO: your condition here + passed() + else: + failed() + + +if __name__ == '__main__': + run_common_tests() + test_task_windows() + + diff --git a/python/edu/course-creator/resources/icons/gutter.png b/python/edu/course-creator/resources/icons/gutter.png Binary files differnew file mode 100644 index 000000000000..244e6ca045c5 --- /dev/null +++ b/python/edu/course-creator/resources/icons/gutter.png |