How to use the xblock.core.XBlock.json_handler function in XBlock

To help you get started, we’ve selected a few XBlock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kalyzee / knotes / videoknotes / videoknotes.py View on Github external
    @XBlock.json_handler
    def studio_submit(self, data, suffix=''):
        """
        Called when submitting the form in Studio.
        """
        self.href = data.get('href')

        return {'result': 'success'}
github MarCnu / videojsXBlock / videojs / videojs.py View on Github external
    @XBlock.json_handler
    def save_videojs(self, data, suffix=''):
        """
        The saving handler.
        """
        self.display_name = data['display_name']
        self.url = data['url']
        self.allow_download = True if data['allow_download'] == "True" else False # Str to Bool translation
        self.source_text = data['source_text']
        self.source_url = data['source_url']
        self.start_time = ''.join(data['start_time'].split()) # Remove whitespace
        self.end_time = ''.join(data['end_time'].split()) # Remove whitespace
        
        return {
            'result': 'success',
        }
github edx / XBlock / xblock / problem.py View on Github external
    @XBlock.json_handler
    def check(self, submissions, suffix=''):  # pylint: disable=unused-argument
        """
        Processess the `submissions` with each provided Checker.

        First calls the submit() method on each InputBlock. Then, for each Checker,
        finds the values it needs and passes them to the appropriate `check()` method.

        Returns a dictionary of 'submitResults': {input_name: user_submitted_results},
        'checkResults': {checker_name: results_passed_through_checker}

        """
        self.problem_attempted = True
        context = self.calc_context({})

        child_map = {}
        # self.children is an attribute obtained from ChildrenModelMetaclass, so disable the
github oppia / oppia / integrations / openedx_xblock_20150715_v0.0.0 / xblock-oppia / oppia / oppia.py View on Github external
    @XBlock.json_handler
    def studio_submit(self, data, suffix=''):
        """
        Called when submitting the form in Studio.
        """
        self.oppiaid = data.get('oppiaid')
        self.src = data.get('src')
        self.width = data.get('width')
        self.height = data.get('height')

        return {'result': 'success'}
github open-craft / xblock-simplevideo / simplevideo.py View on Github external
    @XBlock.json_handler
    def studio_submit(self, data, suffix=''):
        """
        Called when submitting the form in Studio.
        """
        self.href = data.get('href')
        self.maxwidth = data.get('maxwidth')
        self.maxheight = data.get('maxheight')

        return {'result': 'success'}
github Kalyzee / knotes / videoknotes / videoknotes.py View on Github external
    @XBlock.json_handler
    def publish_notes(self, data, suffix=''):
        """Make a note public only for the teacher
        """ 
        student = self.__get_current_user()
        timecoded = KNote.objects.get(pk=data.get("pk"))
        if ((timecoded.timecoded_comment.user.pk == self.scope_ids.user_id) and (has_studio_write_access(student, self.scope_ids.usage_id.course_key))):
            is_public = False
            if (data.get("public") == "true"):
                is_public = True
            timecoded.is_public = data.get("public")
            timecoded.save()
            return {'result': 'success'}
        else :
            return {'error': 'bad credential'}
github edx / XBlock / xblock / problem.py View on Github external
    @XBlock.json_handler
    def rerandomize(self, unused, suffix=''):  # pylint: disable=unused-argument
        """Set a new random seed for the student."""
        self.set_student_seed()
        return {'status': 'ok'}
github oppia / oppia / integrations / openedx_xblock_20150715_v0.0.0 / xblock-oppia / oppia / oppia.py View on Github external
    @XBlock.json_handler
    def on_exploration_completed(self, data, suffix=''):
        """Called when the exploration has been completed."""
        self._log('Exploration %s has been completed.' % self.oppiaid)
github oppia / oppia / integrations / openedx_xblock_20150715_v0.0.0 / xblock-oppia / oppia / oppia.py View on Github external
    @XBlock.json_handler
    def on_state_transition(self, data, suffix=''):
        """Called when a state transition in the exploration has occurred."""
        self._log(
            "Recording the following state transition for exploration %s: "
            "'%s' to '%s'" % (
                self.oppiaid, data['oldStateName'], data['newStateName']))
github edx / XBlock / thumbs / thumbs / thumbs.py View on Github external
    @XBlock.json_handler
    def vote(self, data, suffix=''):  # pylint: disable=unused-argument
        """
        Update the vote count in response to a user action.
        """
        # Here is where we would prevent a student from voting twice, but then
        # we couldn't click more than once in the demo!
        #
        #     if self.voted:
        #         log.error("cheater!")
        #         return

        if data['voteType'] not in ('up', 'down'):
            log.error('error!')
            return

        if data['voteType'] == 'up':