Skip to content
Snippets Groups Projects
Commit 77aacc02 authored by srosse's avatar srosse
Browse files

OO-2870: add selenium to check negative point setting in QTI 2.1

parent f0acd231
No related branches found
No related tags found
No related merge requests found
Showing
with 245 additions and 4 deletions
......@@ -2928,4 +2928,222 @@ public class ImsQTI21Test {
.assertOnAssessmentTestScore(2)
.assertOnAssessmentTestMaxScore(2);
}
/**
* An author make a test and use the negative points.<br>
* 3 users search the test, pass the test or not and
* check their results.
*
* @param authorLoginPage
* @param participantBrowser
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void qti21EditorNegativePoints(@InitialPage LoginPage authorLoginPage,
@Drone @User WebDriver participantBrowser)
throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou");
UserVO asuka = new UserRestClient(deploymentUrl).createRandomUser("Asuka");
UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei");
authorLoginPage.loginAs(author.getLogin(), author.getPassword());
String qtiTestTitle = "Choices QTI 2.1 " + UUID.randomUUID();
navBar
.openAuthoringEnvironment()
.createQTI21Test(qtiTestTitle)
.clickToolbarBack();
QTI21Page qtiPage = QTI21Page
.getQTI12Page(browser);
QTI21EditorPage qtiEditor = qtiPage
.edit();
//customize the section
qtiEditor
.selectSection()
.selectExpertOptions()
.sectionTitle(false)
.save();
//edit the default single choice
qtiEditor
.selectItem("Single Choice");
QTI21SingleChoiceEditorPage scEditor = new QTI21SingleChoiceEditorPage(browser);
scEditor
.setAnswer(0, "Wrong")
.addChoice(1)
.setCorrect(1)
.setAnswer(1, "Correct")
.addChoice(2)
.setAnswer(2, "Faux")
.save();
scEditor
.selectScores()
.selectAssessmentMode(ScoreEvaluation.perAnswer)
.setMaxScore("2.0")
.setMinScore("-1.0")
.setScore("Wrong", "-1")
.setScore("Correct", "2")
.setScore("Faux", "-1")
.save();
//add a multiple choice
QTI21MultipleChoiceEditorPage mcEditor = qtiEditor
.addMultipleChoice();
mcEditor
.setAnswer(0, "Correct")
.setCorrect(0)
.addChoice(1)
.setCorrect(1)
.setAnswer(1, "Ok")
.addChoice(2)
.setAnswer(2, "Faux")
.addChoice(3)
.setAnswer(3, "Falsch")
.save();
mcEditor.selectScores()
.selectAssessmentMode(ScoreEvaluation.perAnswer)
.setMaxScore("2.0")
.setMinScore("-2")
.setScore("Correct", "1")
.setScore("Ok", "1")
.setScore("Faux", "-2")
.setScore("Falsch", "-2")
.save();
//add an hotspot
QTI21HotspotEditorPage hotspotEditor = qtiEditor
.addHotspot();
// 2 spots
URL backgroundImageUrl = JunitTestHelper.class.getResource("file_resources/house.jpg");
File backgroundImageFile = new File(backgroundImageUrl.toURI());
hotspotEditor
.updloadBackground(backgroundImageFile)
.resizeCircle()
.moveCircle(300, 120)
.addRectangle()
.moveRectangle(150, 150)
.setCardinality(Cardinality.SINGLE)
.save();
hotspotEditor
.selectScores()
.selectAssessmentMode(ScoreEvaluation.perAnswer)
.setMaxScore("3.0")
.setMinScore("-2")
.setScore("1.", "3.0") //circle
.setScore("2.", "-2") //rectangle
.save();
qtiPage
.clickToolbarBack();
// access to all
qtiPage
.accessConfiguration()
.setUserAccess(UserAccess.guest)
.clickToolbarBack();
// show results
qtiPage
.options()
.showResults(Boolean.TRUE, QTI21AssessmentResultsOptions.allOptions())
.save();
//a user search the content package
LoginPage userLoginPage = LoginPage.getLoginPage(participantBrowser, deploymentUrl);
userLoginPage
.loginAs(ryomou.getLogin(), ryomou.getPassword())
.resume();
NavigationPage userNavBar = new NavigationPage(participantBrowser);
userNavBar
.openMyCourses()
.openSearch()
.extendedSearch(qtiTestTitle)
.select(qtiTestTitle)
.start();
// make the test with all correct answers
QTI21Page ryomouQtiPage = QTI21Page
.getQTI12Page(participantBrowser);
ryomouQtiPage
.assertOnAssessmentItem()
.assertHiddenSection()
.answerSingleChoice("Correct")
.saveAnswer()
.answerMultipleChoice("Ok")
.answerMultipleChoice("Correct")
.saveAnswer()
.answerHotspot("circle")
.saveAnswer()
.endTest()
//check the results
.assertOnAssessmentResults()
.assertOnAssessmentTestScore(7)
.assertOnAssessmentTestMaxScore(7);
//a second user search the content package
LoginPage asukaLoginPage = LoginPage.getLoginPage(participantBrowser, deploymentUrl);
asukaLoginPage
.loginAs(asuka.getLogin(), asuka.getPassword())
.resume();
NavigationPage asukaNavBar = new NavigationPage(participantBrowser);
asukaNavBar
.openMyCourses()
.openSearch()
.extendedSearch(qtiTestTitle)
.select(qtiTestTitle)
.start();
// make the test with all correct answers
QTI21Page asukaQtiPage = QTI21Page
.getQTI12Page(participantBrowser);
asukaQtiPage
.assertOnAssessmentItem()
.assertHiddenSection()
.answerSingleChoice("Wrong")
.saveAnswer()
.answerMultipleChoice("Falsch")
.answerMultipleChoice("Faux")
.saveAnswer()
.answerHotspot("rect")
.saveAnswer()
.endTest()
//check the results
.assertOnAssessmentResults()
.assertOnAssessmentTestScore(0) // -1 + -4 but never under 0
.assertOnAssessmentTestMaxScore(7);
//a third user search the content package
LoginPage reiLoginPage = LoginPage.getLoginPage(participantBrowser, deploymentUrl);
reiLoginPage
.loginAs(rei.getLogin(), rei.getPassword())
.resume();
NavigationPage reiNavBar = new NavigationPage(participantBrowser);
reiNavBar
.openMyCourses()
.openSearch()
.extendedSearch(qtiTestTitle)
.select(qtiTestTitle)
.start();
// make the test with some correct answers
QTI21Page reiQtiPage = QTI21Page
.getQTI12Page(participantBrowser);
reiQtiPage
.assertOnAssessmentItem()
.assertHiddenSection()
.answerSingleChoice("Faux")
.saveAnswer()
.answerMultipleChoice("Ok")
.answerMultipleChoice("Correct")
.saveAnswer()
.answerHotspot("circle")
.saveAnswer()
.endTest()
//check the results
.assertOnAssessmentResults()
.assertOnAssessmentTestScore(4) // -1 + 2 + 3 points
.assertOnAssessmentTestMaxScore(7);
}
}
......@@ -219,11 +219,12 @@ public class CourseEditorPageFragment {
browser.findElement(createNodeButton).click();
OOGraphene.waitModalDialog(browser);
By node = By.xpath("//div[@id='o_course_editor_choose_nodetype']//a[contains(@class,'o_sel_course_editor_node-" + nodeAlias + "')]");
By nodeBy = By.xpath("//div[@id='o_course_editor_choose_nodetype']//a[contains(@class,'o_sel_course_editor_node-" + nodeAlias + "')]");
OOGraphene.waitElement(nodeBy, browser);
if("lti".equals(nodeAlias)) {
OOGraphene.clickAndWait(node, browser);
OOGraphene.clickAndWait(nodeBy, browser);
} else {
browser.findElement(node).click();
browser.findElement(nodeBy).click();
OOGraphene.waitBusy(browser);
}
return this;
......
......@@ -77,6 +77,7 @@ public class MemberListConfigurationPage {
public MemberListConfigurationPage save() {
By configBy = By.cssSelector("fieldset.o_sel_cmembers_settings button.btn-primary");
OOGraphene.click(configBy, browser);
OOGraphene.waitBusy(browser);
return this;
}
......
......@@ -69,6 +69,14 @@ public class QTI21ChoicesScoreEditorPage {
return this;
}
public QTI21ChoicesScoreEditorPage setMinScore(String minScore) {
By minScoreBy = By.cssSelector("div.o_sel_assessment_item_min_score input[type='text']");
WebElement minScoreEl = browser.findElement(minScoreBy);
minScoreEl.clear();
minScoreEl.sendKeys(minScore);
return this;
}
public QTI21ChoicesScoreEditorPage save() {
By saveBy = By.cssSelector("fieldset.o_sel_assessment_item_options button.btn.btn-primary");
browser.findElement(saveBy).click();
......
......@@ -120,6 +120,7 @@ public class QTI21HotspotEditorPage extends QTI21AssessmentItemEditorPage {
public QTI21HotspotEditorPage save() {
By saveBy = By.cssSelector("div.o_sel_hotspots_save button.btn.btn-primary");
OOGraphene.click(saveBy, browser);
OOGraphene.waitBusy(browser);
return this;
}
......
......@@ -69,6 +69,14 @@ public class QTI21HotspotScoreEditorPage {
return this;
}
public QTI21HotspotScoreEditorPage setMinScore(String minScore) {
By minScoreBy = By.cssSelector("div.o_sel_assessment_item_min_score input[type='text']");
WebElement minScoreEl = browser.findElement(minScoreBy);
minScoreEl.clear();
minScoreEl.sendKeys(minScore);
return this;
}
public QTI21HotspotScoreEditorPage save() {
By saveBy = By.cssSelector("fieldset.o_sel_assessment_item_options button.btn.btn-primary");
browser.findElement(saveBy).click();
......
......@@ -66,6 +66,7 @@ public class QTI21KprimEditorPage extends QTI21AssessmentItemEditorPage {
public QTI21KprimEditorPage save() {
By saveBy = By.cssSelector("fieldset.o_sel_choices_save button.btn.btn-primary");
OOGraphene.click(saveBy, browser);
OOGraphene.waitBusy(browser);
return this;
}
......
......@@ -87,6 +87,7 @@ public class QTI21MatchEditorPage extends QTI21AssessmentItemEditorPage {
public QTI21MatchEditorPage save() {
By saveBy = By.cssSelector("div.o_sel_match_save button.btn.btn-primary");
OOGraphene.click(saveBy, browser);
OOGraphene.waitBusy(browser);
return this;
}
......
......@@ -76,6 +76,7 @@ public class QTI21MultipleChoiceEditorPage extends QTI21AssessmentItemEditorPage
public QTI21MultipleChoiceEditorPage save() {
By saveBy = By.cssSelector("fieldset.o_sel_choices_save button.btn.btn-primary");
OOGraphene.click(saveBy, browser);
OOGraphene.waitBusy(browser);
return this;
}
......
......@@ -72,6 +72,7 @@ public class QTI21SingleChoiceEditorPage extends QTI21AssessmentItemEditorPage {
public QTI21SingleChoiceEditorPage save() {
By saveBy = By.cssSelector("fieldset.o_sel_choices_save button.btn.btn-primary");
OOGraphene.click(saveBy, browser);
OOGraphene.waitBusy(browser);
return this;
}
......
......@@ -25,7 +25,7 @@
<property name="dimensions">1024x800</property>
<!--
<property name="downloadBinaries">no</property>
<property name="chromeDriverBinary">target/drone/b77c9c71b52302fcfe6b40dcd143f1d0/chromedriver</property>
<property name="chromeDriverBinary">target/drone/3d520b8ede8e9deb8c9a2efe2aec5f35/chromedriver</property>
<property name="firefoxDriverBinary">target/drone/30f3fdc84d76c53de2916008a889d26f/geckodriver</property>
-->
<property name="firefoxUserPreferences">src/test/profile/firefox/prefs.js</property>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment