def GET_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Edit a task """ if not id_checker(taskid): raise Exception("Invalid task id") course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False) try: task_data = self.task_factory.get_task_descriptor_content( courseid, taskid) except: task_data = None if task_data is None: task_data = {} environments = self.containers current_filetype = None try: current_filetype = self.task_factory.get_task_descriptor_extension( courseid, taskid) except: pass available_filetypes = self.task_factory.get_available_task_file_extensions( ) return self.template_helper.get_renderer().course_admin.task_edit( course, taskid, self.task_factory.get_problem_types(), task_data, environments, json.dumps(task_data.get('problems', {})), self.contains_is_html(task_data), current_filetype, available_filetypes, AccessibleTime, CourseTaskFiles.get_task_filelist(self.task_factory, courseid, taskid))
def API_GET(self): """ Returns a list of files and directories as a JSON list. Each entry of the output is an object (representing a file or directory) with the following properties: - "level": Integer. Indicates the depth level of this entry. - "is_directory": Boolean. Indicates whether the current entry is a directory. If False, it is a file. - "name": The file or directory name. - "complete_name": The full path of the entry. """ parameters = web.input() courseid = get_mandatory_parameter(parameters, "course_id") taskid = get_mandatory_parameter(parameters, "task_id") self.get_course_and_check_rights(courseid) file_list = CourseTaskFiles.get_task_filelist(self.task_factory, courseid, taskid) result = [{ "level": level, "is_directory": is_directory, "name": name, "complete_name": complete_name[1:] if complete_name.startswith("/") else complete_name } for level, is_directory, name, complete_name in file_list] return 200, result
def GET_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Edit a task """ if not id_checker(taskid): raise Exception("Invalid task id") course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False) try: task_data = self.task_factory.get_task_descriptor_content( courseid, taskid) except: task_data = None if task_data is None: task_data = {} # Sorting to asure that multilang is always the first option environments = self.containers if "multiple_languages" in environments: environments = list(environments) environments.remove("multiple_languages") environments.insert(0, "multiple_languages") environments = tuple(environments) current_filetype = None try: current_filetype = self.task_factory.get_task_descriptor_extension( courseid, taskid) except: pass available_filetypes = self.task_factory.get_available_task_file_extensions( ) additional_tabs = self.plugin_manager.call_hook( 'task_editor_tab', course=course, taskid=taskid, task_data=task_data, template_helper=self.template_helper) additional_footer = self.plugin_manager.call_hook( 'task_editor_footer', course=course, taskid=taskid, task_data=task_data, template_helper=self.template_helper) return self.template_helper.get_renderer().course_admin.task_edit( course, taskid, self.task_factory.get_problem_types(), task_data, environments, task_data.get('problems', {}), self.contains_is_html(task_data), current_filetype, available_filetypes, AccessibleTime, CourseTaskFiles.get_task_filelist(self.task_factory, courseid, taskid), additional_tabs, additional_footer)
def GET_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Edit a task """ if not id_checker(taskid): raise NotFound(description=_("Invalid task id")) course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False) try: task_data = self.task_factory.get_task_descriptor_content( courseid, taskid) except TaskNotFoundException: raise NotFound() # Ensure retrocompatibility task_data = _migrate_from_v_0_6(task_data) environment_types = self.environment_types environments = self.environments current_filetype = None try: current_filetype = self.task_factory.get_task_descriptor_extension( courseid, taskid) except: pass available_filetypes = self.task_factory.get_available_task_file_extensions( ) additional_tabs = self.plugin_manager.call_hook( 'task_editor_tab', course=course, taskid=taskid, task_data=task_data, template_helper=self.template_helper) return self.template_helper.render( "course_admin/task_edit.html", course=course, taskid=taskid, problem_types=self.task_factory.get_problem_types(), task_data=task_data, environment_types=environment_types, environments=environments, problemdata=json.dumps(task_data.get('problems', {})), contains_is_html=self.contains_is_html(task_data), current_filetype=current_filetype, available_filetypes=available_filetypes, AccessibleTime=AccessibleTime, file_list=CourseTaskFiles.get_task_filelist( self.task_factory, courseid, taskid), additional_tabs=additional_tabs)
def GET_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Edit a task """ if not id_checker(taskid): raise Exception("Invalid task id") course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False) try: task_data = self.task_factory.get_task_descriptor_content(courseid, taskid) except: task_data = None if task_data is None: task_data = {} environments = self.containers current_filetype = None try: current_filetype = self.task_factory.get_task_descriptor_extension(courseid, taskid) except: pass available_filetypes = self.task_factory.get_available_task_file_extensions() # custom problem-type: for pid in task_data.get("problems", {}): problem = task_data["problems"][pid] if (problem["type"] == "code" and "boxes" in problem) or problem["type"] not in ( "code", "code_single_line", "file", "match", "multiple_choice"): problem_copy = copy.deepcopy(problem) for i in ["name", "header"]: if i in problem_copy: del problem_copy[i] problem["custom"] = inginious.common.custom_yaml.dump(problem_copy) return self.template_helper.get_renderer().course_admin.task_edit( course, taskid, self.task_factory.get_problem_types(), task_data, environments, json.dumps( task_data.get( 'problems', {})), self.contains_is_html(task_data), current_filetype, available_filetypes, AccessibleTime, CourseTaskFiles.get_task_filelist(self.task_factory, courseid, taskid))
def GET_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Edit a task """ if not id_checker(taskid): raise Exception("Invalid task id") course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False) try: task_data = self.task_factory.get_task_descriptor_content( courseid, taskid) except: task_data = None if task_data is None: task_data = {} # Ensure retrocompatibility task_data = _migrate_from_v_0_6(task_data) environment_types = self.environment_types environments = self.environments current_filetype = None try: current_filetype = self.task_factory.get_task_descriptor_extension( courseid, taskid) except: pass available_filetypes = self.task_factory.get_available_task_file_extensions( ) additional_tabs = self.plugin_manager.call_hook( 'task_editor_tab', course=course, taskid=taskid, task_data=task_data, template_helper=self.template_helper) sectionid = web.input().get("sectionid", None) return self.template_helper.get_renderer().course_admin.task_edit( course, taskid, self.task_factory.get_problem_types(), task_data, environment_types, environments, task_data.get('problems', {}), self.contains_is_html(task_data), current_filetype, available_filetypes, AccessibleTime, CourseTaskFiles.get_task_filelist(self.task_factory, courseid, taskid), additional_tabs, sectionid)
def GET_AUTH(self, courseid, taskid): # pylint: disable=arguments-differ """ Edit a task """ if not id_checker(taskid): raise Exception("Invalid task id") course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False) try: task_data = self.task_factory.get_task_descriptor_content(courseid, taskid) except: task_data = None if task_data is None: task_data = {} environments = self.containers current_filetype = None try: current_filetype = self.task_factory.get_task_descriptor_extension(courseid, taskid) except: pass available_filetypes = self.task_factory.get_available_task_file_extensions() additional_tabs = self.plugin_manager.call_hook('task_editor_tab', course=course, taskid=taskid, task_data=task_data, template_helper=self.template_helper) return self.template_helper.get_renderer().course_admin.task_edit( course, taskid, self.task_factory.get_problem_types(), task_data, environments, task_data.get('problems',{}), self.contains_is_html(task_data), current_filetype, available_filetypes, AccessibleTime, CourseTaskFiles.get_task_filelist(self.task_factory, courseid, taskid), additional_tabs )
def init_flask_mapping(flask_app): flask_app.url_map.converters['cookieless'] = CookielessConverter flask_app.add_url_rule('/<cookieless:sessionid>', view_func=IndexPage.as_view('indexpage')) flask_app.add_url_rule('/<cookieless:sessionid>index', view_func=IndexPage.as_view('indexpage.alias')) flask_app.add_url_rule('/<cookieless:sessionid>signin', view_func=SignInPage.as_view('signinpage')) flask_app.add_url_rule('/<cookieless:sessionid>logout', view_func=LogOutPage.as_view('logoutpage')) flask_app.add_url_rule( '/<cookieless:sessionid>register', view_func=RegistrationPage.as_view('registrationpage')) flask_app.add_url_rule('/<cookieless:sessionid>queue', view_func=QueuePage.as_view('queuepage')) flask_app.add_url_rule( '/<cookieless:sessionid>register/<courseid>', view_func=CourseRegisterPage.as_view('courseregisterpage')) flask_app.add_url_rule( '/<cookieless:sessionid>marketplace', view_func=MarketplacePage.as_view('marketplacepage')) flask_app.add_url_rule( '/<cookieless:sessionid>marketplace/<courseid>', view_func=MarketplaceCoursePage.as_view('marketplacecoursepage')) flask_app.add_url_rule('/<cookieless:sessionid>course/<courseid>', view_func=CoursePage.as_view('coursepage')) flask_app.add_url_rule('/<cookieless:sessionid>course/<courseid>/<taskid>', view_func=TaskPage.as_view('taskpage')) flask_app.add_url_rule( '/<cookieless:sessionid>course/<courseid>/<taskid>/<path:path>', view_func=TaskPageStaticDownload.as_view('taskpagestaticdownload')) flask_app.add_url_rule('/<cookieless:sessionid>group/<courseid>', view_func=GroupPage.as_view('grouppage')) flask_app.add_url_rule( '/<cookieless:sessionid>auth/signin/<auth_id>', view_func=AuthenticationPage.as_view('authenticationpage')) flask_app.add_url_rule('/<cookieless:sessionid>auth/callback/<auth_id>', view_func=CallbackPage.as_view('callbackpage')) flask_app.add_url_rule('/<cookieless:sessionid>auth/share/<auth_id>', view_func=SharePage.as_view('sharepage')) flask_app.add_url_rule('/<cookieless:sessionid>pages/<pageid>', view_func=INGIniousStaticPage.as_view('staticpage')) flask_app.add_url_rule('/<cookieless:sessionid>courselist', view_func=CourseListPage.as_view('courselistpage')) flask_app.add_url_rule('/<cookieless:sessionid>mycourses', view_func=MyCoursesPage.as_view('mycoursespage')) flask_app.add_url_rule( '/<cookieless:sessionid>preferences', view_func=PrefRedirectPage.as_view('prefredirectpage')) flask_app.add_url_rule('/<cookieless:sessionid>preferences/bindings', view_func=BindingsPage.as_view('bindingspage')) flask_app.add_url_rule('/<cookieless:sessionid>preferences/delete', view_func=DeletePage.as_view('deletepage')) flask_app.add_url_rule('/<cookieless:sessionid>preferences/profile', view_func=ProfilePage.as_view('profilepage')) flask_app.add_url_rule('/<cookieless:sessionid>lti/task', view_func=LTITaskPage.as_view('ltitaskpage')) flask_app.add_url_rule('/<cookieless:sessionid>lti/<courseid>/<taskid>', view_func=LTILaunchPage.as_view( LTILaunchPage.endpoint)) flask_app.add_url_rule('/<cookieless:sessionid>lti/bind', view_func=LTIBindPage.as_view('ltibindpage')) flask_app.add_url_rule('/<cookieless:sessionid>lti/login', view_func=LTILoginPage.as_view('ltiloginpage')) flask_app.add_url_rule('/<cookieless:sessionid>lti/asset/<path:asset_url>', view_func=LTIAssetPage.as_view('ltiassetpage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>', view_func=CourseRedirectPage.as_view('courseredirect')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/settings', view_func=CourseSettingsPage.as_view('coursesettingspage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/students', view_func=CourseStudentListPage.as_view('coursestudentlistpage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/student/<username>', view_func=CourseStudentInfoPage.as_view('coursestudentinfopage')) flask_app.add_url_rule('/<cookieless:sessionid>submission/<submissionid>', view_func=SubmissionPage.as_view('submissionpage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/submissions', view_func=CourseSubmissionsPage.as_view('coursesubmissionspage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/tasks', view_func=CourseTaskListPage.as_view('coursetasklistpage')) flask_app.add_url_rule('/<cookieless:sessionid>admin/<courseid>/tags', view_func=CourseTagsPage.as_view('coursetagspage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/edit/audience/<audienceid>', view_func=CourseEditAudience.as_view('courseditaudience')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/edit/task/<taskid>', view_func=CourseEditTask.as_view('coursedittask')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/edit/task/<taskid>/files', view_func=CourseTaskFiles.as_view('coursetaskfiles')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/edit/task/<taskid>/dd_upload', view_func=CourseTaskFileUpload.as_view('coursetaskfileupload')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/danger', view_func=CourseDangerZonePage.as_view('coursedangerzonepage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/stats', view_func=CourseStatisticsPage.as_view('coursestatisticspage')) flask_app.add_url_rule( '/<cookieless:sessionid>admin/<courseid>/search_user/<request>', view_func=CourseAdminSearchUserPage.as_view( 'courseadminsearchuserpage')) flask_app.add_url_rule('/<cookieless:sessionid>api/v0/auth_methods', view_func=APIAuthMethods.as_view('apiauthmethods')) flask_app.add_url_rule( '/<cookieless:sessionid>api/v0/authentication', view_func=APIAuthentication.as_view('apiauthentication')) flask_app.add_url_rule('/<cookieless:sessionid>api/v0/courses', view_func=APICourses.as_view('apicourses.alias'), defaults={'courseid': None}) flask_app.add_url_rule('/<cookieless:sessionid>api/v0/courses/<courseid>', view_func=APICourses.as_view('apicourses')) flask_app.add_url_rule( '/<cookieless:sessionid>api/v0/courses/<courseid>/tasks', view_func=APITasks.as_view('apitasks.alias'), defaults={'taskid': None}) flask_app.add_url_rule( '/<cookieless:sessionid>api/v0/courses/<courseid>/tasks/<taskid>', view_func=APITasks.as_view('apitasks')) flask_app.add_url_rule( '/<cookieless:sessionid>api/v0/courses/<courseid>/tasks/<taskid>/submissions', view_func=APISubmissions.as_view('apisubmissions.alias')) flask_app.add_url_rule( '/<cookieless:sessionid>api/v0/courses/<courseid>/tasks/<taskid>/submissions/<submissionid>', view_func=APISubmissionSingle.as_view('apisubmissions'))