wrapper.html 3.78 KB
Newer Older
1
2
3
4
5
6
7
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>title</title>
    <script src="/static/lib/jquery/jquery-3.2.1.min.js"></script>
    <script src="/static/lib/fioipem/jschannel-190528.js"></script>
8
    <script src="/static/lib/fioipem/task-xd-pr-190528.js"></script>
9
10
11
12
13
    <script src="/static/lib/medal/medal-0.0.2.js"></script>
  </head>
  <body style="margin:0px; padding:0px; overflow: hidden;">
    <script>

14
15
16
17
18
$("body").prepend('<iframe src="' + location.search.substr(1) + '?channelId=task" id="ifr" style="border: 0px; width:100vw; height:100vh;margin:0px; padding:0px; "></iframe>');


var options = {
  minScore:0,
19
  maxScore:100,
20
21
22
  noScore:0,
  randomSeed:0,
  readOnly:false,
23
  options:{difficulty:"easy", log:1},
24
25
26
27
28
29
30
31
}

var myLoadViews = {
  editor: true,
  forum: true,
  hints: true,
  submission: true,
  task: true,
32
  grader: true,
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  metadata: true,
}

var myViews = {
  task: true,
}

function ec(name) {
  return function(e){
    console.log(name + " error:");
    console.log(e);
  }
}

function noop(){}

function getTaskProxyCallback(task) {
  function reloadAnswerCallback() {
51
    task.gradeAnswer("", {}, noop, ec("task.gradeAnswer"));
52
53
54
55
56
57
58
59
60
  }

  function reloadStateCallback() {
    function load_task_callback(data) {
      if ("text" in data) {
        task.reloadAnswer(data["text"], reloadAnswerCallback, ec("task.reloadAnswer"));
      } else {
        task.reloadAnswer('', reloadAnswerCallback, ec("task.reloadAnswer"));
      }
61
    }
62
63
64
65
    function load_task_error() {
      task.reloadAnswer('', reloadAnswerCallback, ec("task.reloadAnswer"));
      alert("Laden fehlgeschlagen");
    }
66

67
    window.load_task_object(load_task_callback, load_task_error);
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  }

  function showViewsCallback(){
    task.reloadState('', reloadStateCallback, ec("task.reloadState"));
  }

  function loadCallback(){
    task.showViews(myViews, showViewsCallback, ec("task.showViews"));
  }

  function getViewsCallback(views){
    task.load(myLoadViews, loadCallback, ec("task.load"))
  }

  function getAnswerCallback(answer) {
    console.log("In task.gradeAnswer callback:");
    console.log(answer);

86
87
88
89
    function gradeAnswerCallback(score, message, scoreToken){
      function save_task_callback() {
        console.log("OK transmission");
      };
90
91
92
93
      function save_task_error() {
        console.log("ERROR transmission");
        alert("Speichern fehlgeschlagen");
      };
94

95
      window.save_task_object({"text": answer}, score, save_task_callback, save_task_error);
96
97
    }

98
99
100
101
102
103
104
105
106
107
108
109
110
    task.gradeAnswer(answer, {}, gradeAnswerCallback, ec("task.gradeAnswer"));
  }

  var platform = {
    getTaskParams: function(key, def, cb, ecb) {
      if (!key && !def) {
        cb(options);
      }
      else {
        cb();
      }
    },
    validate: function(mode, cb, ecb) {
111
112
113
114
115
116
117
      if (mode == 'done') {
        task.getAnswer(getAnswerCallback, ec("task.getAnswer"));
        if (cb) {cb();}
      }
      else if (mode == 'next' || mode == 'nextImmediate') {
        window.parent.redirectOverview();
      }
118
119
120
121
      if (mode == 'log') {
        task.getAnswer(getAnswerCallback, ec("task.getAnswer"));
        if (cb) {cb();}
      }
122
123
124
125
      else {
        console.error("Unknown mode: '" + mode + "'");
        if (ecb) {ecb();}
      }
126
    },
127
    showViews: function(views, cb, ecb) {
128
129
      cb(options);
    },
130
    openUrl: function(textId, cb, ecb) {
131
132
      cb();
    },
133
    askHint: function(ht, cb, ecb) {
134
135
136
137
138
      cb();
    },
    updateDisplay: function(opt, cb, ecb) {
      cb();
    },
139
    initWithTask: function(t, cb, ecb) {
140
141
142
143
144
145
146
147
148
149
150
151
152
153
      cb(options);
    },
  };

  TaskProxyManager.setPlatform(task, platform);

  task.getViews(getViewsCallback, ec("task.getViews"));
}

function main() {
  TaskProxyManager.getTaskProxy("ifr", getTaskProxyCallback, false, ec("task.getTaskProxy"));
}

setTimeout(main, 1);
154
155
156
157

    </script>
  </body>
</html>