 
     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


_ = require 'lodash'

module.exports = (ko, config) ->
  if !ko.mapping?
    throw Error "You need to load knockout-mapping for the exercise editor."
  class TaskViewModel

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

      @solution ?= ko.observable ''

  class ExercisePageViewModel
    constructor: (params) ->
