Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsxGraph acts differently on regenerated question #2

Open
YannickNeyt opened this issue Jan 8, 2021 · 6 comments
Open

jsxGraph acts differently on regenerated question #2

YannickNeyt opened this issue Jan 8, 2021 · 6 comments

Comments

@YannickNeyt
Copy link

I made a drawing with jsxGraph:
image
But if I preview the question, the labels are off. Only when I ask for a second try, the labels are corrected (and stay so for other generated questions):
image
I noticed that the second time, the labels 'jump' in the first second from the incorrect to the correct place, this 'jump' doesn't occur when I first open the question.

The code for the drawing:

var div = Numbas.extensions.jsxgraph.makeBoard('400px','400px',{boundingBox:[-8,8,8,-8],grid:false,axis:false});
var board = div.board;
var p1 = board.create('point',[-ha,hb], {fixed:true,visible: false,withLabel:false});
var p2 = board.create('point',[-ha+xx,hb], {fixed:true,visible: false,withLabel:false});
var p3 = board.create('point',[-ha+xx,-hb+xx], {fixed:true,visible: false,withLabel:false});
var p4 = board.create('point',[ha-xx,-hb+xx], {fixed:true,visible: false,withLabel:false});
var p5 = board.create('point',[ha-xx,hb], {fixed:true,visible: false,withLabel:false});
var p6 = board.create('point',[ha,hb], {fixed:true,visible: false,withLabel:false});
var p7 = board.create('point',[ha,-hb], {fixed:true,visible: false,withLabel:false});
var p8 = board.create('point',[-ha,-hb], {fixed:true,visible: false,withLabel:false});
var poly = board.create('polygon',[p1,p2,p3,p4,p5,p6,p7,p8], { borders:{strokeColor:'black'} });
var h0 = board.create('point', [-ha,hb-xx], {fixed:true,visible: false,withLabel:false});
var h1 = board.create('point', [-ha+xx,hb-xx], {fixed:true,visible: false,withLabel:false});
var h2 = board.create('point', [ha-xx,hb-xx], {fixed:true,visible: false,withLabel:false});
var h3 = board.create('point', [ha,hb-xx], {fixed:true,visible: false,withLabel:false});      
var hseg1 = board.create('segment', [h0,h1], {firstarrow:{type:2,size:4},lastarrow:{type:2,size:4},withLabel:true, name:'$x$',label:{position:'top',offset:[-4,12]}});
var hseg2 = board.create('segment', [h2,h3], {firstarrow:{type:2,size:4},lastarrow:{type:2,size:4},withLabel:true, name:'$x$',label:{position:'top',offset:[-4,12]}});
var v0 = board.create('point', [0,-hb+xx], {fixed:true,visible: false,withLabel:false});
var v1 = board.create('point', [0,-hb], {fixed:true,visible: false,withLabel:false});
var vseg = board.create('segment', [v0,v1], {firstarrow:{type:2,size:4},lastarrow:{type:2,size:4},withLabel:true, name:'$x$',label:{position:'top',offset:[8,0]}});
var b0 = board.create('point', [-ha,-hb-0.5], {fixed:true,visible: false,withLabel:false});
var b1 = board.create('point', [ha,-hb-0.5], {fixed:true,visible: false,withLabel:false});
var base = board.create('segment', [b0,b1], {firstarrow:{type:2,size:4},lastarrow:{type:2,size:4},withLabel:true, name:'$'+a+'$',label:{position:'bot',offset:[-6,-12]}});
var l0 = board.create('point', [ha+0.5,hb], {fixed:true,visible: false,withLabel:false});
var l1 = board.create('point', [ha+0.5,-hb], {fixed:true,visible: false,withLabel:false});
var length = board.create('segment', [l0,l1], {firstarrow:{type:2,size:4},lastarrow:{type:2,size:4},withLabel:true, name:'$'+b+'$',label:{position:'top',offset:[8,0]}});
return div;
@christianp
Copy link
Member

Does adding a line board.update() just before the last line make it better? If so, I should make the extension do this for you.

@christianp
Copy link
Member

@YannickNeyt did you look at this any more?

@YannickNeyt
Copy link
Author

Sorry, I didn't, I just tried it, I don't think it changes anything.

@ugoertz
Copy link

ugoertz commented Feb 2, 2021

I also noticed this (this question). In that question it's a very minor issue, but it is noticeable that the labels are a little closer to the red dots for "try another" questions. For some weird reason the label offsets are ignored when the first question is generated.
The board update which I just added does not seem to help there, either.

@christianp
Copy link
Member

Is this still a problem?

@christianp christianp transferred this issue from numbas/Numbas Aug 9, 2022
@ugoertz
Copy link

ugoertz commented Aug 9, 2022

In the question I linked to the problem does not occur anymore. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants