define("bundles/content-feedback/components/flag/GradingProblemFeedbackEditor",["require","exports","module","classnames","react-with-addons","./../FeedbackEditor","bundles/content-feedback/actions/ProgrammingGradingProblemsActions","bundles/phoenix/utils/CMLUtils","i18n!nls/content-feedback","vendor/cnpm/fluxible.v0-4/addons/connectToStores","css!./__styles__/GradingProblemFeedbackEditor"],function(require,exports,module){"use strict";function _defaults(e,a){for(var i=Object.getOwnPropertyNames(a),t=0;t<i.length;t++){var r=i[t],n=Object.getOwnPropertyDescriptor(a,r);n&&n.configurable&&void 0===e[r]&&Object.defineProperty(e,r,n)}return e}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):_defaults(t,e))}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function defineProperties(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,e.key,e)}}return function(e,t,r){return t&&defineProperties(e.prototype,t),r&&defineProperties(e,r),e}}(),o=function get(i,c,d){var r=!0;e:for(;r;){var t=i,s=c,o=d;r=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,s);if(void 0===e){var n=Object.getPrototypeOf(t);if(null===n)return void 0;i=n,c=s,d=o,r=!0,e=n=void 0;continue e}if("value"in e)return e.value;var a=e.get;if(void 0===a)return void 0;return a.call(o)}},c=require("classnames"),e=require("react-with-addons"),s=require("./../FeedbackEditor"),n=require("bundles/content-feedback/actions/ProgrammingGradingProblemsActions"),t=require("bundles/phoenix/utils/CMLUtils"),r=require("i18n!nls/content-feedback"),d=require("vendor/cnpm/fluxible.v0-4/addons/connectToStores");require("css!./__styles__/GradingProblemFeedbackEditor");var l=n.loadProgrammingSubmittedParts,u=n.loadProgrammingPartGradingFeedbacks,p=n.saveProgrammingPartGradingFeedbacks,a=function PartState(e,r,n){_classCallCheck(this,PartState),this.id=e,this.isChecked=r||!1,this.cml=n||t.create("")},m=function(n){function GradingProblemFeedbackEditor(r,n){var e=this;_classCallCheck(this,GradingProblemFeedbackEditor),o(Object.getPrototypeOf(GradingProblemFeedbackEditor.prototype),"constructor",this).call(this,r,n),this.handleCheck=function(r,i){e.state.partStates[r.id]||(e.state.partStates[r.id]=new a(r.id));var n=e.state.partStates[r.id];n.isChecked=i.target.checked,n.cml=i.target.checked?n.cml:t.create(""),e.forceUpdate()},this.handleSend=function(t){t.preventDefault(),e.context.executeAction(p,{courseId:e.props.itemMetadata.get("course.id"),itemId:e.props.itemMetadata.get("id"),parts:e.props.submittedParts.map(function(t){return{id:t.id,submissionId:t.submissionId,content:e.state.partStates[t.id].cml}})}),e.setState({partStates:null}),e.props.onSend()},this.handleChange=function(t,r){e.state.partStates[t.id]||(e.state.partStates[t.id]=new a(t.id)),e.state.partStates[t.id].cml=r,e.forceUpdate()},this.handleCancel=function(t){t.preventDefault(),e.initializePartStates(e.props.submittedParts,e.props.feedbacks),e.props.onCancel()},this.context.executeAction(l,{itemMetadata:r.itemMetadata}),this.state={loading:!0,partStates:null}}return _inherits(GradingProblemFeedbackEditor,n),i(GradingProblemFeedbackEditor,null,[{key:"propTypes",value:{itemMetadata:e.PropTypes.object.isRequired,isFocused:e.PropTypes.bool,placeholder:e.PropTypes.string.isRequired,onCancel:e.PropTypes.func.isRequired,onRemove:e.PropTypes.func.isRequired,onSend:e.PropTypes.func.isRequired,submittedParts:e.PropTypes.arrayOf(e.PropTypes.shape({id:e.PropTypes.string.isRequired,label:e.PropTypes.string.isRequired,submissionId:e.PropTypes.string.isRequired})),feedbacks:e.PropTypes.object},enumerable:!0},{key:"contextTypes",value:{executeAction:e.PropTypes.func.isRequired},enumerable:!0}]),i(GradingProblemFeedbackEditor,[{key:"componentWillReceiveProps",value:function componentWillReceiveProps(e){this.state.loading&&e.submittedParts&&(this.context.executeAction(u,{courseId:this.props.itemMetadata.get("course.id"),itemId:this.props.itemMetadata.get("id"),parts:e.submittedParts}),e.feedbacks&&(this.initializePartStates(e.submittedParts,e.feedbacks),this.setState({loading:!1})))}},{key:"initializePartStates",value:function initializePartStates(r,n){var e={};r.forEach(function(r){var i=n[r.id],s=i&&i.comments?i.comments:{},o=s.grading||s.content||t.create("");e[r.id]=new a(r.id,!t.isEmpty(o),o)}),this.setState({partStates:e})}},{key:"isLoaded",value:function isLoaded(){return this.props.submittedParts&&this.state.partStates&&this.props.feedbacks}},{key:"areAnyPartsChecked",value:function areAnyPartsChecked(){var e=this;return this.props.submittedParts.some(function(r){var t=e.state.partStates[r.id];return t&&t.isChecked})}},{key:"areAllCheckedPartsFilled",value:function areAllCheckedPartsFilled(){var e=this;return this.props.submittedParts.every(function(n){var r=e.state.partStates[n.id];return r&&(!r.isChecked||!t.isEmpty(r.cml))})}},{key:"allowSend",value:function allowSend(){var e=this;if(!this.isLoaded())return!1;return this.props.submittedParts.some(function(n){var r=e.props.feedbacks[n.id],a=e.state.partStates[n.id],i=r&&r.comments?r.comments:{},s=i.grading||i.content||t.create("");return a&&t.getInnerText(s)!==t.getInnerText(a.cml)})}},{key:"renderContent",value:function renderContent(){var t=this,n=this.props,a=n.submittedParts,i=n.isFocused;if(!this.isLoaded())return e.createElement("div",null,e.createElement("p",null,r("Loading...")));if(0===a.length)return e.createElement("div",null,e.createElement("p",null,r("You must submit the assignment before providing feedback on specific parts.")));var o=c("flag-action",{disabled:!this.allowSend()});return e.createElement("div",null,e.createElement("p",null,r("Which parts would you like to report?")),e.createElement("ul",{className:"part-list"},a.map(function(r,o){var n=t.state.partStates[r.id],c=n&&n.cml,a=n&&n.isChecked;return e.createElement("li",null,e.createElement("label",null,e.createElement("input",{type:"checkbox",checked:a,onChange:t.handleCheck.bind(t,r)}),r.label),a&&e.createElement(s,{cml:c,onChange:t.handleChange.bind(t,r),isFocused:i&&0===o,placeholder:"Describe problem"}))})),e.createElement("hr",{className:"flag-actions-divider"}),e.createElement("div",{className:"flag-actions"},e.createElement("a",{href:"#",className:o,onClick:this.handleSend},r("Send")),e.createElement("a",{href:"#",className:"flag-action",onClick:this.handleCancel},r(this.state.flagExists?"Remove":"Cancel"))))}},{key:"render",value:function render(){return e.createElement("div",{className:"rc-GradingProblemFeedbackEditor c-flag-editor"},this.renderContent())}}]),GradingProblemFeedbackEditor}(e.Component);module.exports=d(m,["ProgrammingGradingProblemsStore"],function(t,r){var e=t.ProgrammingGradingProblemsStore;return{submittedParts:e.getSubmittedParts(),feedbacks:e.getFeedbacks()}})});
define("bundles/content-feedback/components/rating-dashboard/CourseRatingsDashboardContent",["require","exports","module","react-with-addons","moment","bundles/teach-course/components/CountHeader","./CourseReviewList","./CourseRatingValueSelect","./CourseLearnerAudienceSelect","./AverageCourseRating","./CourseRatingBreakdown","bundles/content-feedback/actions/CourseRatingActions","js/lib/coursera.react-intl","i18n!nls/content-feedback","vendor/cnpm/fluxible.v0-4/addons/connectToStores","bundles/content-feedback/models/RatingCollection","bundles/content-feedback/models/CourseRatingStats","bundles/teach-course/components/AppMessage","css!./__styles__/CourseRatingsDashboardContent"],function(require,exports,module){"use strict";function _defaults(e,o){for(var a=Object.getOwnPropertyNames(o),t=0;t<a.length;t++){var n=a[t],r=Object.getOwnPropertyDescriptor(o,n);r&&r.configurable&&void 0===e[n]&&Object.defineProperty(e,n,r)}return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):_defaults(t,e))}var C=function(){function defineProperties(r,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,e.key,e)}}return function(e,t,n){return t&&defineProperties(e.prototype,t),n&&defineProperties(e,n),e}}(),f=function get(a,c,u){var n=!0;e:for(;n;){var t=a,s=c,i=u;n=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,s);if(void 0===e){var r=Object.getPrototypeOf(t);if(null===r)return void 0;a=r,c=s,u=i,n=!0,e=r=void 0;continue e}if("value"in e)return e.value;var o=e.get;if(void 0===o)return void 0;return o.call(i)}},e=require("react-with-addons"),h=require("moment"),c=require("bundles/teach-course/components/CountHeader"),m=require("./CourseReviewList"),u=require("./CourseRatingValueSelect"),l=require("./CourseLearnerAudienceSelect"),d=require("./AverageCourseRating"),p=require("./CourseRatingBreakdown"),n=require("bundles/content-feedback/actions/CourseRatingActions"),g=n.getCourseRatingStats,v=n.filterCourseRatings,s=n.getCourseReviews,i=n.filterCourseReviews,o=require("js/lib/coursera.react-intl"),b=o.FormattedMessage,r=o.FormattedHTMLMessage,t=require("i18n!nls/content-feedback"),R=require("vendor/cnpm/fluxible.v0-4/addons/connectToStores"),w=require("bundles/content-feedback/models/RatingCollection"),y=require("bundles/content-feedback/models/CourseRatingStats"),A=require("bundles/teach-course/components/AppMessage");require("css!./__styles__/CourseRatingsDashboardContent");var a=function(n){function CourseRatingsDashboardContent(){var e=this;_classCallCheck(this,CourseRatingsDashboardContent),f(Object.getPrototypeOf(CourseRatingsDashboardContent.prototype),"constructor",this).apply(this,arguments),this.handleInfiniteScroll=function(){var t=e.props,n=t.courseId,r=t.reviewCollection,o=t.ratingValue,a=t.learnerAudience;e.context.executeAction(s,{courseId:n,reviewCollection:r,ratingValue:o,learnerAudience:a})},this.handleRatingValueChange=function(n){var t=e.props,r=t.courseId,o=t.learnerAudience;e.context.executeAction(i,{courseId:r,ratingValue:n,learnerAudience:o})},this.handleLearnerAudienceChange=function(n){var t=e.props,r=t.courseId,o=t.ratingValue;e.context.executeAction(v,{courseId:r,ratingValue:o,learnerAudience:n})}}return _inherits(CourseRatingsDashboardContent,n),C(CourseRatingsDashboardContent,[{key:"componentDidMount",value:function componentDidMount(){var e=this.props,t=e.courseId,r=e.reviewCollection,o=e.ratingValue,n=e.learnerAudience;this.context.executeAction(s,{courseId:t,reviewCollection:r,ratingValue:o,learnerAudience:n}),this.context.executeAction(g,{courseId:t,learnerAudience:n})}},{key:"render",value:function render(){var n=this.props.reviewCollection.totalCount,o=h().format("h:mm a, MMMM Do, YYYY");return e.createElement("div",{className:"rc-CourseRatingsDashboardContent"},e.createElement("h1",{className:"c-course-ratings-heading"},t("Ratings")),this.props.showTeachDescription&&e.createElement("div",{className:"c-course-ratings-description"},e.createElement(r,{message:t('Learners can rate courses at any point as they progress\n                but must be enrolled to rate a course. <a target="_blank" href={url}>Learn more</a>'),url:"https://partner.coursera.help/hc/en-us/articles/205619429-Course-and-Specialization-Dashboards"}),e.createElement("div",{className:"c-course-ratings-updated-at"},e.createElement(r,{message:t("Last updated <strong>{timestamp}</strong>. Updated real time."),timestamp:o}))),e.createElement("div",{className:"c-course-learner-audience-container"},e.createElement(l,{learnerAudience:this.props.learnerAudience,onChange:this.handleLearnerAudienceChange})),this.props.courseRatingStats&&e.createElement("div",{className:"c-course-rating-stats"},e.createElement(d,{courseRatingStats:this.props.courseRatingStats}),this.props.showCourseRatingBreakdown&&e.createElement(p,{courseRatingStats:this.props.courseRatingStats})),e.createElement(u,{ratingValue:this.props.ratingValue,onChange:this.handleRatingValueChange}),e.createElement("div",{className:"c-course-review-count-container"},this.props.isLoadingReviews&&t("Loading Reviews..."),!this.props.isLoadingReviews&&e.createElement(c,{value:n,message:e.createElement(b,{message:t("{reviewCount, plural, =0 {Reviews} one {Review} other {Reviews}}"),reviewCount:n})}),!this.props.isLoadingReviews&&this.props.showTeachDescription&&e.createElement("div",{className:"abuse-container"},e.createElement(r,{message:t("To flag an abusive review for removal, please contact <a href={link}>{email}</a>"),link:"mailto:partner-support@coursera.org",email:"*****@*****.**"}))),e.createElement("div",{className:"c-course-reviews"},!!n&&e.createElement(m,{reviewCollection:this.props.reviewCollection,onInfiniteScroll:this.handleInfiniteScroll}),!this.props.isLoadingReviews&&!n&&e.createElement(A,{heading:t("There are no reviews to display")})))}}],[{key:"propTypes",value:{courseId:e.PropTypes.string.isRequired,isLoadingReviews:e.PropTypes.bool.isRequired,ratingValue:e.PropTypes.object.isRequired,learnerAudience:e.PropTypes.object.isRequired,courseRatingStats:e.PropTypes.instanceOf(y),reviewCollection:e.PropTypes.instanceOf(w).isRequired,showCourseRatingBreakdown:e.PropTypes.bool,showTeachDescription:e.PropTypes.bool},enumerable:!0},{key:"contextTypes",value:{executeAction:e.PropTypes.func.isRequired},enumerable:!0},{key:"defaultProps",value:{showCourseRatingBreakdown:!0,showTeachDescription:!0},enumerable:!0}]),CourseRatingsDashboardContent}(e.Component);module.exports=R(a,["CourseRatingStore"],function(t,n){var e=t.CourseRatingStore;return{courseRatingStats:e.getCourseRatingStats(),isLoadingReviews:e.getIsLoadingReviews(),reviewCollection:e.getReviewCollection(),ratingValue:e.getRatingValue(),learnerAudience:e.getLearnerAudience()}}),module.exports.BaseComp=a});
Example #3
0
define("bundles/content-feedback/components/rating-dashboard/CourseReview",["require","exports","module","react-with-addons","moment","bundles/phoenix/template/models/userAuthorization","bundles/phoenix/components/CML","bundles/content-feedback/actions/CourseRatingActions","bundles/content-feedback/components/rating/CourseRatingIcons","bundles/content-feedback/models/RatingFeedback","bundles/reply-message/components/ReplyMessage","bundles/reply-message/constants/ReplyMessageConstants","css!./__styles__/CourseReview"],function(require,exports,module){"use strict";function _defaults(e,r){for(var s=Object.getOwnPropertyNames(r),t=0;t<s.length;t++){var n=s[t],o=Object.getOwnPropertyDescriptor(r,n);o&&o.configurable&&void 0===e[n]&&Object.defineProperty(e,n,o)}return e}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):_defaults(t,e))}var n=function(){function defineProperties(o,n){for(var t=0;t<n.length;t++){var e=n[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(o,e.key,e)}}return function(e,t,n){return t&&defineProperties(e.prototype,t),n&&defineProperties(e,n),e}}(),o=function get(s,i,u){var n=!0;e:for(;n;){var t=s,a=i,c=u;n=!1,null===t&&(t=Function.prototype);var e=Object.getOwnPropertyDescriptor(t,a);if(void 0===e){var o=Object.getPrototypeOf(t);if(null===o)return void 0;s=o,i=a,u=c,n=!0,e=o=void 0;continue e}if("value"in e)return e.value;var r=e.get;if(void 0===r)return void 0;return r.call(c)}},e=require("react-with-addons"),r=require("moment"),s=require("bundles/phoenix/template/models/userAuthorization"),t=require("bundles/phoenix/components/CML"),a=require("bundles/content-feedback/actions/CourseRatingActions"),c=a.deleteFeedback,i=require("bundles/content-feedback/components/rating/CourseRatingIcons"),u=require("bundles/content-feedback/models/RatingFeedback"),l=require("bundles/reply-message/components/ReplyMessage"),d=require("bundles/reply-message/constants/ReplyMessageConstants"),p=d.EntryTypes;require("css!./__styles__/CourseReview");var m=function(a){function CourseReview(){var e=this;_classCallCheck(this,CourseReview),o(Object.getPrototypeOf(CourseReview.prototype),"constructor",this).apply(this,arguments),this.deleteFeedback=function(){confirm("Are you sure you want to delete this?")&&e.context.executeAction(c,e.props.ratingFeedback.id)}}return _inherits(CourseReview,a),n(CourseReview,[{key:"render",value:function render(){var n=this.props.ratingFeedback,o=n.value,a=n.comment,c=n.timestamp,u=n.id,d=r(c).format("D MMM YYYY");return e.createElement("div",{className:"rc-CourseReview"},e.createElement("div",{className:"c-course-review-content"},s.isSuperuser()&&e.createElement("a",{href:"#",className:"delete-feedback-container",onClick:this.deleteFeedback},e.createElement("i",{className:"delete-feedback"})),e.createElement("div",{className:"c-course-review-header"},e.createElement("div",{className:"c-course-review-timestamp"},d)),e.createElement(i,{value:o}),e.createElement(t,{cml:a}),this.context.isAdminView&&e.createElement(l,{entryId:u,entryType:p.Feedback})))}}],[{key:"propTypes",value:{ratingFeedback:e.PropTypes.instanceOf(u).isRequired},enumerable:!0},{key:"contextTypes",value:{executeAction:e.PropTypes.func.isRequired,isAdminView:e.PropTypes.bool},enumerable:!0}]),CourseReview}(e.Component);module.exports=m});