Commit 647e77e456ca41f38f9ce117031da6d4fc5acbf2

  • avatar
  • vesal (Committer)
  • Fri Aug 26 20:37:07 EEST 2016
  • avatar
  • vesal (Author)
  • Fri Aug 26 20:37:07 EEST 2016
get age=min,max,all, valid=0,1,all from allAnswer , save freehand with less decimals
timApp/modules/cs/cs3.py
(2 / 2)
  
139139 """
140140 s_in = ""
141141 pwd = ""
142 if not ulimit: ulimit = "ulimit -f 1000 -t 10 -s 100 " # -v 2000 -s 100 -u 10
142 if not ulimit: ulimit = "ulimit -f 1000 -t 10 -s 600 " # -v 2000 -s 100 -u 10
143143 if uargs and len(uargs): args.extend(shlex.split(uargs))
144144 if stdin: s_in = " <" + stdin
145145 mkdirs(cwd + "/run")
553553 for rule in number_rule:
554554 r = rule
555555 if not isinstance(r, list):
556 r = re.findall(r"[-0-9.]+",r)
556 r = re.findall(r"-?[0-9.]+",r)
557557 if len(r) < 2: continue
558558 if len(r) < 3: r.append(r[1])
559559 try:
timApp/modules/imagex/imagex.py
(9 / 2)
  
219219 #Uncomment to see student answers
220220 #print("---drags---" + str(drags))
221221 #No points are awarded if all tries have been given or the final answer has been given to the student.
222 tnr = 0
222223 if targets != None:
223224 for target in targets:
224225 #Find object name from user input.
231231 target['max'] = get_value_def(target, "max", 100000)
232232 target['snapOffset'] = get_value_def(target, "snapOffset", [0, 0])
233233 target['n'] = 0;
234 tnr += 1
234235 print(target)
235236 if tries < max_tries: # and finalanswergiven == False:
236237 for selectkey in target['points'].keys():
243243 if target["n"] < target["max"] and \
244244 is_inside(target['type'],target['size'],-target['a'],target['position'],drag["position"]):
245245 target["n"] += 1;
246 points += (target['points'][selectkey])
246 drag["td"] = "trg" + str(tnr)
247 if "id" in target: drag["tid"] = target["id"]
248 pts = (target['points'][selectkey])
249 drag["points"] = pts
250 points += pts
247251 gottenpointsobj[selectkey] = target['points'][selectkey]
248252 gottenpoints.update(gottenpointsobj)
249253 gottenpointsobj = {}
321321
322322 #Save user input and points to markup
323323 tim_info = {"points": points}
324 save = {"userAnswer": userAnswer, 'freeHandData': freeHandData} #{"drags":drags,"tries":tries}
324 save = {"userAnswer": userAnswer}
325 if freeHandData: save['freeHandData'] = freeHandData #{"drags":drags,"tries":tries}
325326 if finalanswergiven: save["finalanswergiven"] = True
326327 result["save"] = save
327328 if not prevfinalanswergiven:
timApp/pluginControl.py
(1 / 0)
  
136136
137137 taketime("answ", "markup", len(plugins))
138138
139 answers = []
139140 if load_states and custom_state is None and user is not None:
140141 answers = answer_db.get_newest_answers(user['id'], list(state_map.keys()))
141142 for answer in answers:
timApp/routes/answer.py
(3 / 1)
  
249249 doc_id, _, _ = Plugin.parse_task_id(task_id)
250250 usergroup = request.args.get('group')
251251 age = request.args.get('age')
252 valid = request.args.get('valid',1)
253
252254 if not usergroup:
253255 usergroup = 0
254256 if not timdb.documents.exists(doc_id):
258258
259259 # Require full teacher rights for getting all answers
260260 verify_teacher_access(doc_id)
261 all_answers = timdb.answers.get_all_answers(task_id, usergroup, hide_names_in_teacher(doc_id), age)
261 all_answers = timdb.answers.get_all_answers(task_id, usergroup, hide_names_in_teacher(doc_id), age, valid)
262262 return jsonResponse(all_answers)
263263
264264
timApp/static/scripts/answerbrowser3.js
(6 / 1)
  
332332 $scope.getAllAnswers = function() {
333333 var sPageURL = decodeURIComponent(window.location.search.substring(1));
334334 var age = "";
335 var valid = "&valid=1";
335336 if ( sPageURL.indexOf("age=min") >= 0 ) age = "&age=min";
337 if ( sPageURL.indexOf("age=all") >= 0 ) age = "&age=all";
338 if ( sPageURL.indexOf("valid=all") >= 0 ) valid = "&valid=%";
339 if ( sPageURL.indexOf("valid=0") >= 0 ) valid = "&valid=0";
340 if ( sPageURL.indexOf("valid=1") >= 0 ) valid = "&valid=1";
336341 $scope.loading++;
337 $http.get('/allAnswers/' + $scope.taskId + '?rnd='+Math.random() + age, {params: {group: $scope.$parent.group}})
342 $http.get('/allAnswers/' + $scope.taskId + '?rnd='+Math.random() + age + valid, {params: {group: $scope.$parent.group}})
338343 .success(function (data, status, headers, config) {
339344 $scope.allAnswers = data.join("\n\n----------------------------------------------------------------------------------\n");
340345 var nw = $window;
timApp/static/scripts/imagex.js
(17 / 14)
  
5353};
5454
5555
56FreeHand.prototype.startSegment = function(p) {
57 if ( !p ) return;
56FreeHand.prototype.startSegment = function(pxy) {
57 if ( !pxy ) return;
58 var p = [Math.round(pxy.x), Math.round(pxy.y)];
5859 var ns = {};
5960 ns.color = this.params.color;
6061 ns.w = this.params.w;
7070};
7171
7272
73FreeHand.prototype.startSegmentDraw = function(redraw, p) {
74 if ( !p ) return;
73FreeHand.prototype.startSegmentDraw = function(redraw, pxy) {
74 if ( !pxy ) return;
75 var p = [Math.round(pxy.x), Math.round(pxy.y)];
7576 this.redraw = redraw;
7677 var ns = {};
7778 ns.color = this.params.color;
8383};
8484
8585
86FreeHand.prototype.addPoint = function(p) {
87 if ( !p ) return;
86FreeHand.prototype.addPoint = function(pxy) {
87 if ( !pxy ) return;
88 var p = [Math.round(pxy.x), Math.round(pxy.y)];
8889 var n = this.freeDrawing.length;
8990 if ( n == 0 ) this.startSegment(p);
9091 else {
111111};
112112
113113
114FreeHand.prototype.addPointDraw = function(ctx, p) {
115 if ( !p ) return;
114FreeHand.prototype.addPointDraw = function(ctx, pxy) {
115 if ( !pxy ) return;
116116 if ( this.params.lineMode ) {
117117 this.popPoint(1);
118118 if ( this.redraw ) this.redraw();
119119 }
120 this.line(ctx,this.prevPos, p);
121 this.addPoint(p);
120 this.line(ctx,this.prevPos, [pxy.x, pxy.y]);
121 this.addPoint(pxy);
122122};
123123
124124
162162 ctx.beginPath();
163163 ctx.strokeStyle = this.params.color;
164164 ctx.lineWidth = this.params.w;
165 ctx.moveTo(p1.x, p1.y);
166 ctx.lineTo(p2.x, p2.y);
165 ctx.moveTo(p1[0], p1[1]);
166 ctx.lineTo(p2[0], p2[1]);
167167 ctx.stroke();
168168}
169169
175175 ctx.beginPath();
176176 ctx.strokeStyle = seg.color;
177177 ctx.lineWidth = seg.w;
178 ctx.moveTo(seg.lines[0].x, seg.lines[0].y);
178 ctx.moveTo(seg.lines[0][0], seg.lines[0][1]);
179179 for (var lni = 1; lni < seg.lines.length; lni++) {
180 ctx.lineTo(seg.lines[lni].x, seg.lines[lni].y);
180 ctx.lineTo(seg.lines[lni][0], seg.lines[lni][1]);
181181 }
182182 ctx.stroke();
183183 }
timApp/timdb/answers.py
(23 / 10)
  
9595 AND user_id = ?
9696 GROUP BY task_id""" % template, task_ids + [user_id]))
9797
98 def get_all_answers(self, task_id: str, usergroup: int, hide_names: bool, age: str) -> List[str]:
98 def get_all_answers(self, task_id: str, usergroup: int, hide_names: bool, age: str, valid: str) -> List[str]:
9999 """Gets the all answers to task
100100
101101 :param task_id: The id of the task.
102102 :param usergroup: Group of users to search
103103 :param hide_names: Hide names
104 :param age: min or max
104 :param age: min, max or all
105 :param valid: 0, 1 or all
105106 """
106107 time_limit = "1900-09-12 22:00:00"
108 counts = "count(a.answered_on)"
109 groups = "group by a.task_id, u.id"
107110 minmax = "max"
108111 if age == "min":
109112 minmax = "min"
113 if age == "all":
114 minmax = ""
115 counts = "a.valid"
116 groups = "";
117
118
110119 answs = self.db.execute("""
111select u.name, a.task_id, a.content, """ + minmax + """(a.answered_on) as t, count(a.answered_on) as n
120select u.name, a.task_id, a.content, """ + minmax + """(a.answered_on) as t, """ + counts + """ as n, a.points as points
112121from answer as a, userAnswer as ua, user as u
113122where a.task_id like ? and ua.answer_id = a.id and u.id = ua.user_id and a.answered_on > ?
114group by a.task_id, u.id
115order by u.id,a.task_id;
116 """, [task_id, time_limit])
123and a.valid like ?
124""" + groups + """
125order by u.id,a.task_id,a.answered_on;
126 """, [task_id, time_limit, valid])
117127
118128 result = []
119129 if answs is None: return result
120130
121131 for row in answs:
122 header = row[0] + ": " + row[1] + "; " + row[3] + "; " + str(row[4])
132 header = row[0] + ": " + row[1] + "; " + row[3] + "; " + str(row[4]) + "; " + str(row[5])
123133 if hide_names: header = ""
124134 # print(separator + header)
125135 line = json.loads(row[2])
126 if not isinstance(line, list):
127 answ = line.get("usercode", "-")
128 result.append(header + "\n" + answ)
136 answ = str(line)
137 if isinstance(line, object):
138 if "usercode" in line:
139 answ = line.get("usercode", "-")
140
141 result.append(header + "\n" + answ)
129142
130143 return result
131144