Feature: Class formationScenario: Class has a teacher When a class is createdThen the class must have one teacherScenario: Class with no students When a class is createdThen the class cannot have zero studentsScenario: Class has more than one student When a class is createdThen the class must have at least one studentScenario: Class has several students When a class is createdThen the class can have several studentsFeature: Teacher dealing with quizzesScenario: Teacher create a quiz When a teacher create a quizThen the quiz must belong to a classScenario: Teacher assign a quiz When a quiz existsThen the quiz must be assigned to several studentsFeature: Quiz creationScenario: Quiz creation When a quiz is createdThen the quiz must have at least one questionFeature: Question creationScenario: Question creation When a question is createdThen the question must have multiple choiceFeature: Quiz solvingScenario: Solving entire quiz When a student answers one question from a quiz with one questionThen the quiz is finishedScenario: Solving partial quiz When a student answers one question from a quiz with two questionsThen the quiz is not finishedScenario: Solve quiz correctly with one question When a student answers one question currectly from a quiz with one questionThen the quiz grade is 10Scenario: Solve quiz correctly with multiple questions When a student answers two questions currectly from a quiz with two questionsThen the quiz grade is 10Scenario: Solve quiz partially correct When a student answers one question currectly from a quiz with two questionsThen the quiz grade is 5Scenario: Solve quiz partially incorrect When a student answers one question incurrectly from a quiz with two questionsThen the quiz grade is 5Scenario: Solve quiz incorrectly When a student answers one question incurrectly from a quiz with one questionThen the quiz grade is 0Feature: Overall student gradeScenario: Student one quiz over the semester When a student has one quiz assigned to semester 2000.1And the student has grade 7 for this quizThen the student grade is 7 for semester 2000.1Scenario: Student multiple quizzes over the semester When a student has two quizzes assigned to semester 2000.1And the student has grade 10 for the first quizAnd the student has grade 8 for the second quizThen the student grade is 9 for semester 2000.1Scenario: Student with quizzes spanning several semesters When a student has one quiz assigned to semester 2000.1And the student has another quiz assigned to semester 2000.2And the student has grade 9 for the first quizAnd the student has grade 7 for the second quizThen the student grade is 7 for semester 2000.2
/***ThisReactclassisintendedtoqueryanendpointthatwillreturnanalphanumericstring,afterclickingabutton.*Thiscomponentispassedaprop"apiQueryDelay",whichdelaystheendpointrequestbyNmilliseconds.Thereisa*secondbuttontodisablethisfunctionalityandhavetheendpointrequestrunimmediatelyafterbuttonclick.*Thisdataisthentobedisplayedinsideasimplecontainer.*The"queryAPI"XHRhandlerwillreturntheendpointresponseintheformofaPromise(suchasaxios,fetch).*Theresponseobjectwilllooklikethefollowing:{data:"A0B3HCJ"}*Thecontainingelementrefisn't used, but should remain within the class.*Pleaseidentify,correctandcommentonanyerrorsorbadpracticesyouseeintheReactcomponentclassbelow.*Additionally,pleasefeelfreetochangethecodestyleasyouseefit.*Pleasenote-Reactversionforthisexerciseis15.5.4*/importReact,{Component,Fragment}from'react';importqueryAPIfrom'queryAPI';exportdefaultclassextendsComponent{staticdisplayName='ShowResultsFromAPI'staticdefaultProps={apiQueryDelay:0,}staticpropTypes={apiQueryDelay:React.propTypes.number}constructor(props){super(props);this.state={apiQueryDelay:props.apiQueryDelay,data:'',error:false,};}onDisableDelay(){this.setState({apiQueryDelay:0});}submitRequest(){setTimeout(()=>this.fetchData(),this.state.apiQueryDelay);}asyncfetchData(){try{constresponse=awaitqueryAPI();if(!response||!response.data){thrownewError(`Response did not return any data. Response: ${response}`);}this.setState({data:response.data,error:false,});}catch(err){console.error(err);this.setState({error:true});}}render(){return(<Fragment><divclassName="content-container"ref={(element)=>{this.container=element;}}>{this.state.error?<p>Sorry-therewasanerrorwithyourrequest.</p>:<p>{this.state.data}</p>}</div><buttononClick={this.onDisableDelay.bind(this)}>Disablerequestdelay</button><buttononClick={this.submitRequest.bind(this)}>Requestdatafromendpoint</button></Fragment>);}}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.