 
     submit: (task) =>
       if task? #submit this task only
-
+        @saveTask task.id, ko.mapping.toJS(task), (status) ->
+          console.log 'Submit: ' + status
       else #submit everything
-        config.saveExercise exercise.id, ko.mapping.toJS(@tasks), (status) ->
+        @saveExercise exercise.id, ko.mapping.toJS(@tasks), (status) ->
           console.log 'Submit: ' + status
 
     # called through afterRender event in template html
     init: () =>
       $(".popupinfo").popup()
 
-  viewModel: ExercisePageViewModel
-  template: config.html
+  ExercisePageViewModel: ExercisePageViewModel

      @hasTitle = ko.computed => @title()? and @title().trim() isnt ''

      @solution ?= ko.observable ''
      @init = =>
        config.taskInitialized @

  class ExercisePageViewModel
    constructor: (params) ->

      @exerciseNotFound = ko.observable(no)
      @isOld = ko.observable true

      @getExercise params.id, (exercise, status, error) =>
        if exercise?
          @exercise = exercise
          @number exercise.number
